@@ -29,6 +29,7 @@ public class CodePush implements ReactPackage {
2929 private static boolean sIsRunningBinaryVersion = false ;
3030 private static boolean sNeedToReportRollback = false ;
3131 private static boolean sTestConfigurationFlag = false ;
32+ private static String sAppVersionOverride = null ;
3233
3334 private boolean mDidUpdate = false ;
3435
@@ -40,7 +41,7 @@ public class CodePush implements ReactPackage {
4041 private SettingsManager mSettingsManager ;
4142
4243 // Config properties.
43- private String mAppVersion ;
44+ private String mPListAppVersion ;
4445 private String mDeploymentKey ;
4546 private String mServerUrl = "https://codepush.azurewebsites.net/" ;
4647
@@ -65,7 +66,7 @@ public CodePush(String deploymentKey, Context context, boolean isDebugMode) {
6566
6667 try {
6768 PackageInfo pInfo = mContext .getPackageManager ().getPackageInfo (mContext .getPackageName (), 0 );
68- mAppVersion = pInfo .versionName ;
69+ mPListAppVersion = pInfo .versionName ;
6970 } catch (PackageManager .NameNotFoundException e ) {
7071 throw new CodePushUnknownException ("Unable to get package info for " + mContext .getPackageName (), e );
7172 }
@@ -96,7 +97,7 @@ public boolean didUpdate() {
9697 }
9798
9899 public String getAppVersion () {
99- return mAppVersion ;
100+ return sAppVersionOverride == null ? mPListAppVersion : sAppVersionOverride ;
100101 }
101102
102103 public String getAssetsBundleFileName () {
@@ -177,14 +178,14 @@ public String getJSBundleFileInternal(String assetsBundleFileName) {
177178 String packageAppVersion = CodePushUtils .tryGetString (packageMetadata , "appVersion" );
178179 if (binaryModifiedDateDuringPackageInstall != null &&
179180 binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
180- (isUsingTestConfiguration () || this .mAppVersion .equals (packageAppVersion ))) {
181+ (isUsingTestConfiguration () || this .getAppVersion () .equals (packageAppVersion ))) {
181182 CodePushUtils .logBundleUrl (packageFilePath );
182183 sIsRunningBinaryVersion = false ;
183184 return packageFilePath ;
184185 } else {
185186 // The binary version is newer.
186187 this .mDidUpdate = false ;
187- if (!this .mIsDebugMode || !this .mAppVersion .equals (packageAppVersion )) {
188+ if (!this .mIsDebugMode || !this .getAppVersion () .equals (packageAppVersion )) {
188189 this .clearUpdates ();
189190 }
190191
@@ -249,6 +250,10 @@ boolean needToReportRollback() {
249250 return sNeedToReportRollback ;
250251 }
251252
253+ public static void overrideAppVersion (String appVersionOverride ) {
254+ sAppVersionOverride = appVersionOverride ;
255+ }
256+
252257 private void rollbackPackage () {
253258 WritableMap failedPackage = mUpdateManager .getCurrentPackage ();
254259 mSettingsManager .saveFailedUpdate (failedPackage );
@@ -280,7 +285,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactAppli
280285 CodePushNativeModule codePushModule = new CodePushNativeModule (reactApplicationContext , this , mUpdateManager , mTelemetryManager , mSettingsManager );
281286 CodePushDialog dialogModule = new CodePushDialog (reactApplicationContext );
282287
283- List <NativeModule > nativeModules = new ArrayList <>();
288+ List <NativeModule > nativeModules = new ArrayList <>();
284289 nativeModules .add (codePushModule );
285290 nativeModules .add (dialogModule );
286291 return nativeModules ;
0 commit comments