From 201735ebad5ddac232be8ab6c96670c1b2102e07 Mon Sep 17 00:00:00 2001 From: Anna Kocheshkova Date: Mon, 25 Jun 2018 16:16:47 +0300 Subject: [PATCH] Get update folder method (#1323) * Exposed current update path. * Check for null * API reference update --- .../main/java/com/microsoft/codepush/react/CodePush.java | 9 ++++++++- docs/api-android.md | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 39acb66e2..2742a6e3f 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -17,7 +17,6 @@ import org.json.JSONObject; import java.io.File; -import java.io.NotActiveException; import java.util.ArrayList; import java.util.List; @@ -159,6 +158,14 @@ long getBinaryResourcesModifiedTime() { } } + public String getPackageFolder() { + JSONObject codePushLocalPackage = mUpdateManager.getCurrentPackage(); + if (codePushLocalPackage == null) { + return null; + } + return mUpdateManager.getPackageFolderPath(codePushLocalPackage.optString("packageHash")); + } + @Deprecated public static String getBundleUrl() { return getJSBundleFile(); diff --git a/docs/api-android.md b/docs/api-android.md index 2cdf13d39..e2158156f 100644 --- a/docs/api-android.md +++ b/docs/api-android.md @@ -57,4 +57,6 @@ As an alternative to constructors *you can also use `CodePushBuilder`* to setup - __getBundleUrl(String bundleName)__ - Returns the path to the most recent version of your app's JS bundle file, using the specified resource name (e.g. `index.android.bundle`). This method has the same resolution behavior as the Objective-C equivalent described above. +- __getPackageFolder()__ - Returns the path to the current update folder. + - __overrideAppVersion(String appVersionOverride)__ - Sets the version of the application's binary interface, which would otherwise default to the Play Store version specified as the `versionName` in the `build.gradle`. This should be called a single time, before the CodePush instance is constructed.