From 0414d251b12caddfdfee2a3392ea8dcc6c5565e0 Mon Sep 17 00:00:00 2001 From: zhanghan Date: Fri, 27 Dec 2024 13:36:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=81=E5=BC=8F?= =?UTF-8?q?=E5=8D=87=E7=BA=A7UI=E4=BA=A4=E4=BA=92=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghan --- common/src/main/ets/const/update_const.ts | 11 ++++ .../src/main/ets/manager/UpgradeInterface.ets | 5 +- feature/ota/src/main/ets/OtaPage.ets | 1 + .../ota/src/main/ets/manager/StateManager.ets | 53 +++++++++++++++++-- .../ota/src/main/ets/util/VersionUtils.ets | 18 +++++++ .../main/resources/base/element/string.json | 12 +++++ .../main/resources/zh_CN/element/string.json | 12 +++++ .../oh/base/src/main/ets/pages/newVersion.ets | 34 +++++++++--- 8 files changed, 135 insertions(+), 11 deletions(-) diff --git a/common/src/main/ets/const/update_const.ts b/common/src/main/ets/const/update_const.ts index 5921576..c328984 100644 --- a/common/src/main/ets/const/update_const.ts +++ b/common/src/main/ets/const/update_const.ts @@ -71,6 +71,11 @@ export enum UpdateState { */ INSTALL_SUCCESS = 82, + /** + * 状态-安装暂停 + */ + INSTALL_PAUSE = 83, + /** * 状态--升级中 */ @@ -109,6 +114,12 @@ export interface OtaStatus { endReason?: string; } +export enum OtaType { + NORMAL_OTA = 0, + AB_REGULAR_OTA = 1, + AB_STREAM_OTA = 2 +} + /** * 升级错误码 * diff --git a/common/src/main/ets/manager/UpgradeInterface.ets b/common/src/main/ets/manager/UpgradeInterface.ets index 66deb6d..bb80a16 100644 --- a/common/src/main/ets/manager/UpgradeInterface.ets +++ b/common/src/main/ets/manager/UpgradeInterface.ets @@ -113,7 +113,10 @@ export interface VersionPageInfo { * 生效模式 */ effectiveMode?: update.EffectiveMode; - + /** + * 升级模式 + */ + otaType?:update.OtaType; /** * 更新日志 */ diff --git a/feature/ota/src/main/ets/OtaPage.ets b/feature/ota/src/main/ets/OtaPage.ets index 074f111..a7c48d8 100644 --- a/feature/ota/src/main/ets/OtaPage.ets +++ b/feature/ota/src/main/ets/OtaPage.ets @@ -50,6 +50,7 @@ export class OtaPage implements IPage { version: component.displayVersion, size: component.size, effectiveMode: component.effectiveMode, + otaType:component.otaType, changelog: { version: component.displayVersion, size: FormatUtils.formatFileSize(component.size), diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index 260d6d4..a116e6c 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -108,6 +108,9 @@ export namespace StateManager { case UpdateState.INSTALLING: stateObject = new Installing(); break; + case UpdateState.INSTALL_PAUSE: + stateObject = new InstallPause(); + break case UpdateState.INSTALL_FAILED: stateObject = new InstallFailed(); break; @@ -327,6 +330,35 @@ export class Downloading extends BaseState { } } +export class InstallPause extends BaseState { + constructor() { + super(); + this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); + this.actionSet.push(UpdateAction.SHOW_PROCESS_VIEW); + + this.actionSet.push(UpdateAction.INSTALL); + + this.state = UpdateState.INSTALL_PAUSE; + this.downloadStateText = $r('app.string.download_status_download_pause'); + this.buttonText = $r('app.string.continue'); + this.buttonClickAction = UpdateAction.INSTALL; + + this.isButtonClickable = true; + } + + async notify(context?: common.Context, eventId?: update.EventId): Promise { + if (!VersionUtils.isInNewVersionPage()) { + return; + } + if (this.otaStatus?.endReason) { + await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); + let message = await context.resourceManager.getString($r('app.string.install_pause_message').id); + ToastUtils.showToast(message); + } + + } +} + /** * 状态--下载暂停 * @@ -463,10 +495,23 @@ export class Installing extends BaseState { super(); this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); this.actionSet.push(UpdateAction.SHOW_PROCESS_VIEW); - this.state = UpdateState.INSTALLING; - this.buttonText = $r('app.string.btn_upgrade') - this.isButtonClickable = false; - this.downloadStateText = $r('app.string.new_version_status_installing'); + this.checkAbStreamInstall() + } + + async checkAbStreamInstall(){ + let isABStreamInstall = await VersionUtils.isABStreamInstall(); + if(isABStreamInstall){ + this.state = UpdateState.INSTALLING; + this.buttonText = $r('app.string.cancel') + this.isButtonClickable = true; + this.downloadStateText = $r('app.string.new_version_status_installing'); + this.buttonClickAction = UpdateAction.CANCEL; + }else{ + this.state = UpdateState.INSTALLING; + this.buttonText = $r('app.string.btn_upgrade') + this.isButtonClickable = false; + this.downloadStateText = $r('app.string.new_version_status_installing'); + } } async notify(context?: common.Context): Promise { diff --git a/feature/ota/src/main/ets/util/VersionUtils.ets b/feature/ota/src/main/ets/util/VersionUtils.ets index b9cb303..b6427d0 100644 --- a/feature/ota/src/main/ets/util/VersionUtils.ets +++ b/feature/ota/src/main/ets/util/VersionUtils.ets @@ -129,6 +129,24 @@ export namespace VersionUtils { })?.[0]; return component?.effectiveMode === update.EffectiveMode.LIVE_AND_COLD; } + + /** + * 是否是AB升级 + * + * @return 是否是AB升级 + */ + export async function isABStreamInstall(): Promise { + let newVersionInfo = globalThis.cachedNewVersionInfo || await OtaUpdateManager.getInstance().getNewVersion() + .then(upgradeData => { + this.log(`isABInstall upgradeData: ${upgradeData}`); + return upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; + }); + let components: update.VersionComponent[] = VersionUtils.sortComponents(newVersionInfo?.versionComponents); + let component: update.VersionComponent = components?.filter((component: update.VersionComponent) => { + return component.componentType == update.ComponentType.OTA; + })?.[0]; + return component?.otaType === update.OtaType.AB_STREAM_OTA; + } } export default VersionUtils; \ No newline at end of file diff --git a/feature/ota/src/main/resources/base/element/string.json b/feature/ota/src/main/resources/base/element/string.json index 78940f0..1ff53f7 100644 --- a/feature/ota/src/main/resources/base/element/string.json +++ b/feature/ota/src/main/resources/base/element/string.json @@ -12,6 +12,10 @@ "name":"btn_upgrade", "value":"Install" }, + { + "name": "btn_pause", + "value": "pause" + }, { "name":"title_new_version", "value":"New version" @@ -140,6 +144,14 @@ "name":"install_success_message", "value":"Update successfully installed" }, + { + "name":"install_pause_message", + "value":"Update pause. Please try again." + }, + { + "name":"install_pause", + "value":"Update pause" + }, { "name":"install_fail_message", "value":"Installation failed" diff --git a/feature/ota/src/main/resources/zh_CN/element/string.json b/feature/ota/src/main/resources/zh_CN/element/string.json index 2a49048..78814df 100644 --- a/feature/ota/src/main/resources/zh_CN/element/string.json +++ b/feature/ota/src/main/resources/zh_CN/element/string.json @@ -12,6 +12,10 @@ "name":"btn_upgrade", "value":"安装" }, + { + "name": "btn_pause", + "value": "暂停" + }, { "name":"title_new_version", "value":"新版本" @@ -140,6 +144,14 @@ "name":"install_success_message", "value":"新版本安装成功" }, + { + "name":"install_pause_message", + "value":"安装暂停,请重试" + }, + { + "name":"install_pause", + "value":"安装暂停" + }, { "name":"install_fail_message", "value":"新版本安装失败" diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index 950d053..5337144 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -38,6 +38,8 @@ import { StateManager, UpdateAction } from '@ohos/ota/src/main/ets/manager/State import { UpgradeAdapter } from '@ohos/ota/src/main/ets/UpgradeAdapter'; import { VersionUtils } from '@ohos/ota/src/main/ets/util/VersionUtils'; import { NotificationHelper } from '@ohos/ota/src/main/ets/notify/NotificationHelper'; +import prompt from '@ohos.prompt'; +import RouterUtils from '@ohos/ota/src/main/ets/util/RouterUtils'; /** * 新版本页面 @@ -60,6 +62,7 @@ struct NewVersion { private dialogText: string | Resource = ''; @State private isInitComplete: boolean = false; private effectiveMode: update.EffectiveMode = update.EffectiveMode.COLD; + @State otaType: update.OtaType = update.OtaType.AB_STREAM_OTA; private dialogType: CountDownDialogType = CountDownDialogType.OTA; @State private buttonText: string = ''; @StorageProp('installStatusRefresh') @Watch('refresh') @@ -172,12 +175,14 @@ struct NewVersion { } let stateButtonText = StateManager.getButtonText(this.updateStatus); this.buttonText = FormatUtils.toUpperCase(globalThis.abilityContext, stateButtonText); - this.isButtonVisible = this.updateStatus !== UpdateState.INSTALLING && + this.isButtonVisible = this.updateStatus !== UpdateState.INSTALL_FAILED && (this.isABInstall() || this.updateStatus !== UpdateState.INSTALL_SUCCESS) && this.updateStatus !== UpdateState.UPGRADING && this.updateStatus !== UpdateState.UPGRADE_FAILED && - this.updateStatus !== UpdateState.UPGRADE_SUCCESS; + this.updateStatus !== UpdateState.UPGRADE_SUCCESS && + (this.isABStreamInstall() || this.updateStatus !== UpdateState.INSTALL_PAUSE)&& + (this.isABStreamInstall() || this.updateStatus !== UpdateState.INSTALLING); } public async initNewVersionPageInfo(): Promise { @@ -197,6 +202,7 @@ struct NewVersion { this.dialogText = pageInfo?.countDownDialogInfo?.dialogText; this.dialogType = pageInfo?.countDownDialogInfo?.dialogType; this.effectiveMode = pageInfo?.effectiveMode; + this.otaType = pageInfo?.otaType; let size: number = 0; let array: ChangelogInfo[] = []; @@ -237,10 +243,18 @@ struct NewVersion { if (await NetUtils.isCellularNetwork()) { DialogHelper.displayNetworkDialog({ onConfirm: () => { - OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); + if(this.otaType === update.OtaType.AB_STREAM_OTA){ + this.upgrade(); + }else{ + OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); + } } }); } else { - OtaUpdateManager.getInstance().download(); + if(this.otaType === update.OtaType.AB_STREAM_OTA){ + this.upgrade(); + }else{ + OtaUpdateManager.getInstance().download(); + } } break; case UpdateAction.INSTALL: @@ -253,7 +267,11 @@ struct NewVersion { OtaUpdateManager.getInstance().cancel(); break; case UpdateAction.RESUME: - OtaUpdateManager.getInstance().resumeDownload(); + if(this.otaType === update.OtaType.AB_STREAM_OTA){ + this.upgrade(); + }else{ + OtaUpdateManager.getInstance().resumeDownload(); + } break; default: break; @@ -337,7 +355,11 @@ struct NewVersion { } private isABInstall(): boolean { - return this.effectiveMode === update.EffectiveMode.LIVE_AND_COLD; + return this.effectiveMode === update.EffectiveMode.LIVE_AND_COLD || this.otaType === update.OtaType.AB_STREAM_OTA; + } + + private isABStreamInstall(): boolean { + return this.otaType === update.OtaType.AB_STREAM_OTA; } private refresh() { -- Gitee From 37f18305df53f01c366e8a53c9e499f735e36a53 Mon Sep 17 00:00:00 2001 From: zhanghan Date: Wed, 22 Jan 2025 15:53:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9OtaType=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghan --- common/src/main/ets/const/update_const.ts | 9 +++++---- common/src/main/ets/manager/UpgradeInterface.ets | 2 +- feature/ota/src/main/ets/OtaPage.ets | 2 +- feature/ota/src/main/ets/util/VersionUtils.ets | 2 +- product/oh/base/src/main/ets/pages/newVersion.ets | 14 +++++++------- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/common/src/main/ets/const/update_const.ts b/common/src/main/ets/const/update_const.ts index c328984..c79878e 100644 --- a/common/src/main/ets/const/update_const.ts +++ b/common/src/main/ets/const/update_const.ts @@ -114,10 +114,11 @@ export interface OtaStatus { endReason?: string; } -export enum OtaType { - NORMAL_OTA = 0, - AB_REGULAR_OTA = 1, - AB_STREAM_OTA = 2 +export enum OtaMode { + REGULAR = 0, + STREAM = 1, // 1<<0 + AB = 2, // 1<<1 + AB_STREAM = 3 // STREAM|AB } /** diff --git a/common/src/main/ets/manager/UpgradeInterface.ets b/common/src/main/ets/manager/UpgradeInterface.ets index bb80a16..eed8e3e 100644 --- a/common/src/main/ets/manager/UpgradeInterface.ets +++ b/common/src/main/ets/manager/UpgradeInterface.ets @@ -116,7 +116,7 @@ export interface VersionPageInfo { /** * 升级模式 */ - otaType?:update.OtaType; + otaMode?:update.OtaMode; /** * 更新日志 */ diff --git a/feature/ota/src/main/ets/OtaPage.ets b/feature/ota/src/main/ets/OtaPage.ets index a7c48d8..37cec3e 100644 --- a/feature/ota/src/main/ets/OtaPage.ets +++ b/feature/ota/src/main/ets/OtaPage.ets @@ -50,7 +50,7 @@ export class OtaPage implements IPage { version: component.displayVersion, size: component.size, effectiveMode: component.effectiveMode, - otaType:component.otaType, + otaMode:component.otaMode, changelog: { version: component.displayVersion, size: FormatUtils.formatFileSize(component.size), diff --git a/feature/ota/src/main/ets/util/VersionUtils.ets b/feature/ota/src/main/ets/util/VersionUtils.ets index b6427d0..98e8ee3 100644 --- a/feature/ota/src/main/ets/util/VersionUtils.ets +++ b/feature/ota/src/main/ets/util/VersionUtils.ets @@ -145,7 +145,7 @@ export namespace VersionUtils { let component: update.VersionComponent = components?.filter((component: update.VersionComponent) => { return component.componentType == update.ComponentType.OTA; })?.[0]; - return component?.otaType === update.OtaType.AB_STREAM_OTA; + return component?.otaMode === update.OtaMode.AB_STREAM; } } diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index 5337144..a1b2ecb 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -62,7 +62,7 @@ struct NewVersion { private dialogText: string | Resource = ''; @State private isInitComplete: boolean = false; private effectiveMode: update.EffectiveMode = update.EffectiveMode.COLD; - @State otaType: update.OtaType = update.OtaType.AB_STREAM_OTA; + @State otaMode: update.OtaMode = update.OtaMode.AB_STREAM; private dialogType: CountDownDialogType = CountDownDialogType.OTA; @State private buttonText: string = ''; @StorageProp('installStatusRefresh') @Watch('refresh') @@ -202,7 +202,7 @@ struct NewVersion { this.dialogText = pageInfo?.countDownDialogInfo?.dialogText; this.dialogType = pageInfo?.countDownDialogInfo?.dialogType; this.effectiveMode = pageInfo?.effectiveMode; - this.otaType = pageInfo?.otaType; + this.otaMode = pageInfo?.otaMode; let size: number = 0; let array: ChangelogInfo[] = []; @@ -243,14 +243,14 @@ struct NewVersion { if (await NetUtils.isCellularNetwork()) { DialogHelper.displayNetworkDialog({ onConfirm: () => { - if(this.otaType === update.OtaType.AB_STREAM_OTA){ + if(this.isABStreamInstall()){ this.upgrade(); }else{ OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); } } }); } else { - if(this.otaType === update.OtaType.AB_STREAM_OTA){ + if(this.isABStreamInstall()){ this.upgrade(); }else{ OtaUpdateManager.getInstance().download(); @@ -267,7 +267,7 @@ struct NewVersion { OtaUpdateManager.getInstance().cancel(); break; case UpdateAction.RESUME: - if(this.otaType === update.OtaType.AB_STREAM_OTA){ + if(this.isABStreamInstall()){ this.upgrade(); }else{ OtaUpdateManager.getInstance().resumeDownload(); @@ -355,11 +355,11 @@ struct NewVersion { } private isABInstall(): boolean { - return this.effectiveMode === update.EffectiveMode.LIVE_AND_COLD || this.otaType === update.OtaType.AB_STREAM_OTA; + return this.effectiveMode === update.EffectiveMode.LIVE_AND_COLD || this.isABStreamInstall(); } private isABStreamInstall(): boolean { - return this.otaType === update.OtaType.AB_STREAM_OTA; + return this.otaMode === update.OtaMode.AB_STREAM; } private refresh() { -- Gitee From 24cfec16e6bb4dbec12ae6f94919256eaf759328 Mon Sep 17 00:00:00 2001 From: zhanghan24325 Date: Fri, 20 Jun 2025 17:53:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9OtaMode=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghan24325 --- AppScope/app.json5 | 4 ++-- common/src/main/ets/const/update_const.ts | 8 ++++---- feature/ota/src/main/ets/manager/StateManager.ets | 14 +++++++------- feature/ota/src/main/ets/util/VersionUtils.ets | 2 +- product/oh/base/src/main/ets/pages/newVersion.ets | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AppScope/app.json5 b/AppScope/app.json5 index f706bbb..b6ab6f3 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,8 +3,8 @@ "bundleName": "com.ohos.updateapp", "debug": false, "vendor": "example", - "versionCode": 2040000120, - "versionName": "204.0.0.120", + "versionCode": 2040000127, + "versionName": "204.0.0.127", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true diff --git a/common/src/main/ets/const/update_const.ts b/common/src/main/ets/const/update_const.ts index c79878e..abf5aca 100644 --- a/common/src/main/ets/const/update_const.ts +++ b/common/src/main/ets/const/update_const.ts @@ -115,10 +115,10 @@ export interface OtaStatus { } export enum OtaMode { - REGULAR = 0, - STREAM = 1, // 1<<0 - AB = 2, // 1<<1 - AB_STREAM = 3 // STREAM|AB + REGULAR_OTA = 0, + STREAM_OTA = 1, + AB_REGULAR_OTA = 2, + AB_STREAM_OTA = 3 } /** diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index a116e6c..1c9b625 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -110,7 +110,7 @@ export namespace StateManager { break; case UpdateState.INSTALL_PAUSE: stateObject = new InstallPause(); - break + break; case UpdateState.INSTALL_FAILED: stateObject = new InstallFailed(); break; @@ -495,20 +495,20 @@ export class Installing extends BaseState { super(); this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); this.actionSet.push(UpdateAction.SHOW_PROCESS_VIEW); - this.checkAbStreamInstall() + this.checkAbStreamInstall(); } - async checkAbStreamInstall(){ + async checkAbStreamInstall() { let isABStreamInstall = await VersionUtils.isABStreamInstall(); - if(isABStreamInstall){ + if (isABStreamInstall) { this.state = UpdateState.INSTALLING; - this.buttonText = $r('app.string.cancel') + this.buttonText = $r('app.string.cancel'); this.isButtonClickable = true; this.downloadStateText = $r('app.string.new_version_status_installing'); this.buttonClickAction = UpdateAction.CANCEL; - }else{ + } else { this.state = UpdateState.INSTALLING; - this.buttonText = $r('app.string.btn_upgrade') + this.buttonText = $r('app.string.btn_upgrade'); this.isButtonClickable = false; this.downloadStateText = $r('app.string.new_version_status_installing'); } diff --git a/feature/ota/src/main/ets/util/VersionUtils.ets b/feature/ota/src/main/ets/util/VersionUtils.ets index 98e8ee3..9284da3 100644 --- a/feature/ota/src/main/ets/util/VersionUtils.ets +++ b/feature/ota/src/main/ets/util/VersionUtils.ets @@ -145,7 +145,7 @@ export namespace VersionUtils { let component: update.VersionComponent = components?.filter((component: update.VersionComponent) => { return component.componentType == update.ComponentType.OTA; })?.[0]; - return component?.otaMode === update.OtaMode.AB_STREAM; + return component?.otaMode === update.OtaMode.AB_STREAM_OTA; } } diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index a1b2ecb..4fac9a5 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -62,7 +62,7 @@ struct NewVersion { private dialogText: string | Resource = ''; @State private isInitComplete: boolean = false; private effectiveMode: update.EffectiveMode = update.EffectiveMode.COLD; - @State otaMode: update.OtaMode = update.OtaMode.AB_STREAM; + @State otaMode: update.OtaMode = update.OtaMode.AB_STREAM_OTA; private dialogType: CountDownDialogType = CountDownDialogType.OTA; @State private buttonText: string = ''; @StorageProp('installStatusRefresh') @Watch('refresh') @@ -359,7 +359,7 @@ struct NewVersion { } private isABStreamInstall(): boolean { - return this.otaMode === update.OtaMode.AB_STREAM; + return this.otaMode === update.OtaMode.AB_STREAM_OTA; } private refresh() { -- Gitee From 2ea91e60b6605ed6019ffe006d8a6c16e5d3e3c8 Mon Sep 17 00:00:00 2001 From: zhanghan24325 Date: Sat, 21 Jun 2025 10:21:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8C=89=E8=A7=84=E8=8C=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghan24325 --- .../ota/src/main/ets/manager/StateManager.ets | 10 +++---- .../oh/base/src/main/ets/pages/newVersion.ets | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index 1c9b625..2bd43f3 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -109,7 +109,7 @@ export namespace StateManager { stateObject = new Installing(); break; case UpdateState.INSTALL_PAUSE: - stateObject = new InstallPause(); + stateObject = new InstallPaused(); break; case UpdateState.INSTALL_FAILED: stateObject = new InstallFailed(); @@ -330,7 +330,7 @@ export class Downloading extends BaseState { } } -export class InstallPause extends BaseState { +export class InstallPaused extends BaseState { constructor() { super(); this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); @@ -500,17 +500,15 @@ export class Installing extends BaseState { async checkAbStreamInstall() { let isABStreamInstall = await VersionUtils.isABStreamInstall(); + this.state = UpdateState.INSTALLING; + this.downloadStateText = $r('app.string.new_version_status_installing'); if (isABStreamInstall) { - this.state = UpdateState.INSTALLING; this.buttonText = $r('app.string.cancel'); this.isButtonClickable = true; - this.downloadStateText = $r('app.string.new_version_status_installing'); this.buttonClickAction = UpdateAction.CANCEL; } else { - this.state = UpdateState.INSTALLING; this.buttonText = $r('app.string.btn_upgrade'); this.isButtonClickable = false; - this.downloadStateText = $r('app.string.new_version_status_installing'); } } diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index 4fac9a5..9f8c7f6 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -176,13 +176,14 @@ struct NewVersion { let stateButtonText = StateManager.getButtonText(this.updateStatus); this.buttonText = FormatUtils.toUpperCase(globalThis.abilityContext, stateButtonText); this.isButtonVisible = - this.updateStatus !== UpdateState.INSTALL_FAILED && - (this.isABInstall() || this.updateStatus !== UpdateState.INSTALL_SUCCESS) && - this.updateStatus !== UpdateState.UPGRADING && - this.updateStatus !== UpdateState.UPGRADE_FAILED && - this.updateStatus !== UpdateState.UPGRADE_SUCCESS && - (this.isABStreamInstall() || this.updateStatus !== UpdateState.INSTALL_PAUSE)&& - (this.isABStreamInstall() || this.updateStatus !== UpdateState.INSTALLING); + this.updateStatus !== UpdateState.INSTALL_FAILED && + (this.isABInstall() || this.updateStatus !== UpdateState.INSTALL_SUCCESS) && + this.updateStatus !== UpdateState.UPGRADING && + this.updateStatus !== UpdateState.UPGRADE_FAILED && + this.updateStatus !== UpdateState.UPGRADE_SUCCESS && + (this.isABStreamInstall() || + (this.updateStatus !== UpdateState.INSTALL_PAUSE && + this.updateStatus !== UpdateState.INSTALLING)); } public async initNewVersionPageInfo(): Promise { @@ -243,16 +244,16 @@ struct NewVersion { if (await NetUtils.isCellularNetwork()) { DialogHelper.displayNetworkDialog({ onConfirm: () => { - if(this.isABStreamInstall()){ + if (this.isABStreamInstall()) { this.upgrade(); - }else{ + } else { OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); } } }); } else { - if(this.isABStreamInstall()){ + if (this.isABStreamInstall()) { this.upgrade(); - }else{ + } else { OtaUpdateManager.getInstance().download(); } } @@ -267,9 +268,9 @@ struct NewVersion { OtaUpdateManager.getInstance().cancel(); break; case UpdateAction.RESUME: - if(this.isABStreamInstall()){ + if (this.isABStreamInstall()) { this.upgrade(); - }else{ + } else { OtaUpdateManager.getInstance().resumeDownload(); } break; -- Gitee