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

Commit 9c546ab

Browse files
committed
Merge pull request #311 from Microsoft/fix-rollback-android
Fix rollback android
2 parents ef70bd7 + 9cb4e54 commit 9c546ab

File tree

7 files changed

+26
-22
lines changed

7 files changed

+26
-22
lines changed

Examples/CodePushDemoApp/crossplatformdemo.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ let CodePushDemoApp = React.createClass({
1818
let self = this;
1919
try {
2020
return await CodePush.sync(
21-
{
21+
{
2222
updateDialog: true,
2323
installMode: CodePush.InstallMode.ON_NEXT_RESUME
24-
},
24+
},
2525
(syncStatus) => {
2626
switch(syncStatus) {
27-
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
27+
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
2828
self.setState({
2929
syncMessage: "Checking for update."
3030
});
@@ -80,36 +80,36 @@ let CodePushDemoApp = React.createClass({
8080
CodePush.log(error);
8181
}
8282
},
83-
83+
8484
componentDidMount() {
8585
CodePush.notifyApplicationReady();
8686
},
87-
87+
8888
getInitialState() {
8989
return { };
9090
},
91-
91+
9292
render() {
9393
let syncView, syncButton, progressView;
94-
94+
9595
if (this.state.syncMessage) {
9696
syncView = (
9797
<Text style={styles.messages}>{this.state.syncMessage}</Text>
9898
);
9999
} else {
100-
syncButton = (
100+
syncButton = (
101101
<Button style={{color: 'green'}} onPress={this.sync}>
102102
Start Sync!
103103
</Button>
104104
);
105105
}
106-
106+
107107
if (this.state.progress) {
108108
progressView = (
109109
<Text style={styles.messages}>{this.state.progress.receivedBytes} of {this.state.progress.totalBytes} bytes received</Text>
110110
);
111111
}
112-
112+
113113
return (
114114
<View style={styles.container}>
115115
<Text style={styles.welcome}>

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public CodePush(String deploymentKey, Activity mainActivity, boolean isDebugMode
109109
currentInstance = this;
110110

111111
clearDebugCacheIfNeeded();
112+
initializeUpdateAfterRestart();
112113
}
113114

114115
private void clearDebugCacheIfNeeded() {
@@ -382,11 +383,6 @@ public String getName() {
382383
return "CodePush";
383384
}
384385

385-
@Override
386-
public void initialize() {
387-
CodePush.this.initializeUpdateAfterRestart();
388-
}
389-
390386
private void loadBundleLegacy() {
391387
Intent intent = mainActivity.getIntent();
392388
mainActivity.finish();
@@ -418,6 +414,7 @@ private void loadBundle() {
418414
public void run() {
419415
try {
420416
recreateMethod.invoke(instanceManager);
417+
initializeUpdateAfterRestart();
421418
}
422419
catch (Exception e) {
423420
// The recreation method threw an unknown exception

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public CodePushMalformedDataException(String path, Throwable cause) {
99
public CodePushMalformedDataException(String url, MalformedURLException cause) {
1010
super("The package has an invalid downloadUrl: " + url, cause);
1111
}
12-
}
12+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public WritableMap getCurrentPackageInfo() {
7171
try {
7272
return CodePushUtils.getWritableMapFromFile(statusFilePath);
7373
} catch (IOException e) {
74+
// Should not happen.
7475
throw new CodePushUnknownException("Error getting current package info" , e);
7576
}
7677
}
@@ -79,6 +80,7 @@ public void updateCurrentPackageInfo(ReadableMap packageInfo) {
7980
try {
8081
CodePushUtils.writeReadableMapToFile(packageInfo, getStatusFilePath());
8182
} catch (IOException e) {
83+
// Should not happen.
8284
throw new CodePushUnknownException("Error updating current package info" , e);
8385
}
8486
}
@@ -100,6 +102,10 @@ public String getCurrentPackageBundlePath(String bundleFileName) {
100102
}
101103

102104
WritableMap currentPackage = getCurrentPackage();
105+
if (currentPackage == null) {
106+
return null;
107+
}
108+
103109
String relativeBundlePath = CodePushUtils.tryGetString(currentPackage, RELATIVE_BUNDLE_PATH_KEY);
104110
if (relativeBundlePath == null) {
105111
return CodePushUtils.appendPathComponent(packageFolder, bundleFileName);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ public static WritableMap getWritableMapFromFile(String filePath) throws IOExcep
202202
JSONObject json = new JSONObject(content);
203203
return convertJsonObjectToWritable(json);
204204
} catch (JSONException jsonException) {
205+
// Should not happen
205206
throw new CodePushMalformedDataException(filePath, jsonException);
206207
}
207208
}

ios/CodePush/CodePushConfig.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ - (instancetype)init
2727
{
2828
self = [super init];
2929
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
30-
30+
3131
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
3232
NSString *buildVersion = [infoDictionary objectForKey:(NSString *)kCFBundleVersionKey];
3333
NSString *deploymentKey = [infoDictionary objectForKey:@"CodePushDeploymentKey"];
3434
NSString *serverURL = [infoDictionary objectForKey:@"CodePushServerURL"];
35-
35+
3636
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
3737
NSString *clientUniqueId = [userDefaults stringForKey:ClientUniqueIDConfigKey];
3838
if (clientUniqueId == nil) {
3939
clientUniqueId = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
4040
[userDefaults setObject:clientUniqueId forKey:ClientUniqueIDConfigKey];
4141
[userDefaults synchronize];
4242
}
43-
43+
4444
if (!serverURL) {
4545
serverURL = @"https://codepush.azurewebsites.net/";
4646
}
47-
47+
4848
_configDictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
4949
appVersion,AppVersionConfigKey,
5050
buildVersion,BuildVdersionConfigKey,
5151
serverURL,ServerURLConfigKey,
5252
clientUniqueId,ClientUniqueIDConfigKey,
5353
deploymentKey,DeploymentKeyConfigKey,
5454
nil];
55-
55+
5656
return self;
5757
}
5858

request-fetch-adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
headers: headers,
2222
body: requestBody
2323
});
24-
24+
2525
const statusCode = response.status;
2626
const body = await response.text();
2727
callback(null, { statusCode, body });

0 commit comments

Comments
 (0)