@@ -29,6 +29,7 @@ public class CodePush implements ReactPackage {
29
29
private static boolean sIsRunningBinaryVersion = false ;
30
30
private static boolean sNeedToReportRollback = false ;
31
31
private static boolean sTestConfigurationFlag = false ;
32
+ private static String sAppVersionOverride = null ;
32
33
33
34
private boolean mDidUpdate = false ;
34
35
@@ -40,7 +41,7 @@ public class CodePush implements ReactPackage {
40
41
private SettingsManager mSettingsManager ;
41
42
42
43
// Config properties.
43
- private String mAppVersion ;
44
+ private String mPListAppVersion ;
44
45
private String mDeploymentKey ;
45
46
private String mServerUrl = "https://codepush.azurewebsites.net/" ;
46
47
@@ -65,7 +66,7 @@ public CodePush(String deploymentKey, Context context, boolean isDebugMode) {
65
66
66
67
try {
67
68
PackageInfo pInfo = mContext .getPackageManager ().getPackageInfo (mContext .getPackageName (), 0 );
68
- mAppVersion = pInfo .versionName ;
69
+ mPListAppVersion = pInfo .versionName ;
69
70
} catch (PackageManager .NameNotFoundException e ) {
70
71
throw new CodePushUnknownException ("Unable to get package info for " + mContext .getPackageName (), e );
71
72
}
@@ -96,7 +97,7 @@ public boolean didUpdate() {
96
97
}
97
98
98
99
public String getAppVersion () {
99
- return mAppVersion ;
100
+ return sAppVersionOverride == null ? mPListAppVersion : sAppVersionOverride ;
100
101
}
101
102
102
103
public String getAssetsBundleFileName () {
@@ -177,14 +178,14 @@ public String getJSBundleFileInternal(String assetsBundleFileName) {
177
178
String packageAppVersion = CodePushUtils .tryGetString (packageMetadata , "appVersion" );
178
179
if (binaryModifiedDateDuringPackageInstall != null &&
179
180
binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
180
- (isUsingTestConfiguration () || this .mAppVersion .equals (packageAppVersion ))) {
181
+ (isUsingTestConfiguration () || this .getAppVersion () .equals (packageAppVersion ))) {
181
182
CodePushUtils .logBundleUrl (packageFilePath );
182
183
sIsRunningBinaryVersion = false ;
183
184
return packageFilePath ;
184
185
} else {
185
186
// The binary version is newer.
186
187
this .mDidUpdate = false ;
187
- if (!this .mIsDebugMode || !this .mAppVersion .equals (packageAppVersion )) {
188
+ if (!this .mIsDebugMode || !this .getAppVersion () .equals (packageAppVersion )) {
188
189
this .clearUpdates ();
189
190
}
190
191
@@ -249,6 +250,10 @@ boolean needToReportRollback() {
249
250
return sNeedToReportRollback ;
250
251
}
251
252
253
+ public static void overrideAppVersion (String appVersionOverride ) {
254
+ sAppVersionOverride = appVersionOverride ;
255
+ }
256
+
252
257
private void rollbackPackage () {
253
258
WritableMap failedPackage = mUpdateManager .getCurrentPackage ();
254
259
mSettingsManager .saveFailedUpdate (failedPackage );
@@ -280,7 +285,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactAppli
280
285
CodePushNativeModule codePushModule = new CodePushNativeModule (reactApplicationContext , this , mUpdateManager , mTelemetryManager , mSettingsManager );
281
286
CodePushDialog dialogModule = new CodePushDialog (reactApplicationContext );
282
287
283
- List <NativeModule > nativeModules = new ArrayList <>();
288
+ List <NativeModule > nativeModules = new ArrayList <>();
284
289
nativeModules .add (codePushModule );
285
290
nativeModules .add (dialogModule );
286
291
return nativeModules ;
0 commit comments