Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CodePush.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ if (NativeCodePush) {
MANUAL: 2
},
UpdateState: {
RUNNING: NativeCodePush.codePushUpdateStateRunning,
PENDING: NativeCodePush.codePushUpdateStatePending,
LATEST: NativeCodePush.codePushUpdateStateLatest
RUNNING: 0,//NativeCodePush.codePushUpdateStateRunning
PENDING: 1,//NativeCodePush.codePushUpdateStatePending
LATEST: 2 // NativeCodePush.codePushUpdateStateLatest
},
DeploymentStatus: {
FAILED: "DeploymentFailed",
Expand Down
25 changes: 16 additions & 9 deletions harmony/codePush/src/main/ets/CodePushNativeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class CodePushNativeModule extends TurboModule implements TM.RTNCodePush.
let currentPackage = new CodePushUpdateManager('').getCurrentPackage();
if (!currentPackage) {
Logger.info(TAG, `currentPackage is empty`);
return Promise.resolve(null);
return null;
}

let currentUpdateIsPending: boolean = false;
Expand All @@ -154,26 +154,33 @@ export class CodePushNativeModule extends TurboModule implements TM.RTNCodePush.
if (updateState == CodePushUpdateState.PENDING.valueOf() && !currentUpdateIsPending) {
// The caller wanted a pending update
// but there isn't currently one.
return Promise.resolve(null);
return null;
} else if (updateState == CodePushUpdateState.RUNNING.valueOf() && currentUpdateIsPending) {
// The caller wants the running update, but the current
// one is pending, so we need to grab the previous.
let previousPackage = new CodePushUpdateManager('').getPreviousPackage();

if (previousPackage == null) {
Logger.info(TAG, `currentPackage previousPackage is null`);
return Promise.resolve(null);
}
// let previousPackage = new CodePushUpdateManager('').getPreviousPackage();

return Promise.resolve(previousPackage);
// if (previousPackage == null) {
// Logger.info(TAG, `currentPackage previousPackage is null`);
// return null;
// }

// return previousPackage;
let previousPackage = new CodePushUpdateManager('').getCurrentPackageInfo();
const packageHash = {
packageHash:previousPackage['previousPackage']
}
Logger.info(TAG, `doInBackgroundForUpdateMetadata previousPackage=${packageHash}`);
return packageHash
} else {
if (this.mCodePush.isRunningBinaryVersion()) {
currentPackage["_isDebugOnly"] = true;
}
// Enable differentiating pending vs. non-pending updates
currentPackage["isPending"] = currentUpdateIsPending;
Logger.info(TAG, `currentPackage currentPackage=${JSON.stringify(currentPackage)}`);
return Promise.resolve(currentPackage);
return currentPackage;
}
} catch (e) {
// We need to recover the app in case 'codepush.json' is corrupted
Expand Down
7 changes: 6 additions & 1 deletion harmony/codePush/src/main/ets/CodePushUpdateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ export class CodePushUpdateManager {
if (previousPackageHash != null && !(previousPackageHash === packageHash)) {
FileUtils.deleteDirectoryAtPath(this.getPackageFolderPath(previousPackageHash));
}
info[CodePushConstants.PREVIOUS_PACKAGE_KEY] = info[CodePushConstants.CURRENT_PACKAGE_KEY];
if(!currentPackageHash){
info[CodePushConstants.PREVIOUS_PACKAGE_KEY] = packageHash;
}else{
info[CodePushConstants.PREVIOUS_PACKAGE_KEY] = currentPackageHash;
}

}
info['currentPackage'] = packageHash
Logger.info(TAG, 'installPackage--newInfo=' + JSON.stringify(info))
Expand Down