Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit f2b109c

Browse files
committed
rely on buildconfig
1 parent aa92913 commit f2b109c

File tree

2 files changed

+14
-4
lines changed
  • Examples/CodePushDemoApp/android/app/src/main/java/com/microsoft/codepushdemoapp
  • android/app/src/main/java/com/microsoft/codepush/react

2 files changed

+14
-4
lines changed

Examples/CodePushDemoApp/android/app/src/main/java/com/microsoft/codepushdemoapp/MainActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler {
1616

17-
private final String TEST_FOLDER_PREFIX = "CodePushDemoAppTests/";
1817
private ReactInstanceManager mReactInstanceManager;
1918
private ReactRootView mReactRootView;
2019

@@ -25,7 +24,7 @@ protected void onCreate(Bundle savedInstanceState) {
2524
super.onCreate(savedInstanceState);
2625
mReactRootView = new ReactRootView(this);
2726

28-
codePush = new CodePush("DEPLOYMENT_KEY_HERE", this);
27+
codePush = new CodePush("DEPLOYMENT_KEY_HERE", this, BuildConfig.DEBUG);
2928

3029
ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
3130
.setApplication(getApplication())

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ public class CodePush {
6767

6868
private Activity mainActivity;
6969
private Context applicationContext;
70+
private final boolean isDebugMode;
7071

7172
public CodePush(String deploymentKey, Activity mainActivity) {
73+
this(deploymentKey, mainActivity, false);
74+
}
75+
76+
public CodePush(String deploymentKey, Activity mainActivity, boolean isDebugMode) {
7277
SoLoader.init(mainActivity, false);
7378
this.deploymentKey = deploymentKey;
7479
this.codePushPackage = new CodePushPackage(mainActivity.getFilesDir().getAbsolutePath());
7580
this.mainActivity = mainActivity;
7681
this.applicationContext = mainActivity.getApplicationContext();
7782
this.deploymentKey = deploymentKey;
83+
this.isDebugMode = isDebugMode;
7884

7985
PackageInfo pInfo = null;
8086
try {
@@ -145,7 +151,10 @@ public String getBundleUrl(String assetsBundleFileName) {
145151
} else {
146152
// The binary version is newer.
147153
didUpdate = false;
148-
this.clearUpdates();
154+
if (!this.isDebugMode) {
155+
this.clearUpdates();
156+
}
157+
149158
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
150159
return binaryJsBundleUrl;
151160
}
@@ -194,7 +203,9 @@ private void initializeUpdateAfterRestart() {
194203
rollbackPackage();
195204
} else {
196205
// Clear the React dev bundle cache so that new updates can be loaded.
197-
clearReactDevBundleCache();
206+
if (!this.isDebugMode) {
207+
clearReactDevBundleCache();
208+
}
198209
// Mark that we tried to initialize the new update, so that if it crashes,
199210
// we will know that we need to rollback when the app next starts.
200211
savePendingUpdate(pendingUpdate.getString(PENDING_UPDATE_HASH_KEY),

0 commit comments

Comments
 (0)