From 057386d73e1f0e94f850e49b4cf6a8a2dd811152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Tue, 1 Jul 2025 21:25:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?arkts1.1=20Signed-off-by:=20=E9=82=B9?= =?UTF-8?q?=E5=8F=8B=E6=9D=BE=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AppScope/app.json5 | 4 +- build-profile.json5 | 12 +- common/BuildProfile.ets | 19 + common/build-profile.json5 | 1 + common/{package.json => oh-package.json5} | 2 +- common/package-lock.json | 5 - .../src/main/ets/component/CheckingDots.ets | 2 +- .../src/main/ets/component/HomeCardView.ets | 8 +- common/src/main/ets/component/TitleBar.ets | 2 +- common/src/main/ets/const/update_const.ts | 57 +- common/src/main/ets/manager/UpdateManager.ts | 70 +- common/src/main/ets/util/CommonUtils.ts | 142 +++ .../util/{FormatUtils.ts => FormatUtils.ets} | 54 +- .../ets/util/{NetUtils.ts => NetUtils.ets} | 9 +- common/src/main/ets/util/UpdateUtils.ets | 14 +- feature/ota/BuildProfile.ets | 19 + feature/ota/build-profile.json5 | 1 + feature/ota/oh-package-lock.json5 | 19 + .../ota/{package.json => oh-package.json5} | 7 - feature/ota/package-lock.json | 11 - feature/ota/src/main/ets/UpgradeAdapter.ets | 4 +- .../main/ets/components/ChangelogContent.ets | 36 +- .../main/ets/components/ProgressContent.ets | 8 +- .../dialog/CountDownInstallDialogBuilder.ets | 16 +- .../ota/src/main/ets/dialog/DialogHelper.ets | 108 +- .../{DialogUtils.ts => DialogUtils.ets} | 94 +- .../main/ets/dialog/MessageDialogBuilder.ets | 2 +- .../src/main/ets/manager/OtaUpdateManager.ets | 72 +- .../ota/src/main/ets/manager/StateManager.ets | 68 +- .../main/ets/notify/NotificationHelper.ets | 52 +- ...tionManager.ts => NotificationManager.ets} | 17 +- .../src/main/ets/util/ChangelogParseUtils.ets | 126 +- .../util/{RouterUtils.ts => RouterUtils.ets} | 3 +- .../util/{ToastUtils.ts => ToastUtils.ets} | 0 .../ota/src/main/ets/util/VersionUtils.ets | 13 +- .../main/resources/base/element/string.json | 12 - .../main/resources/zh_CN/element/string.json | 12 - oh-package-lock.json5 | 10 + package.json => oh-package.json5 | 7 +- package-lock.json | 1094 ----------------- product/oh/base/oh-package-lock.json5 | 25 + .../base/{package.json => oh-package.json5} | 4 +- product/oh/base/package-lock.json | 22 - .../{MainAbility.ts => MainAbility.ets} | 6 +- .../{service.ts => service.ets} | 13 +- .../{serviceStub.ts => serviceStub.ets} | 0 .../src/main/ets/pages/currentVersion.ets | 21 +- product/oh/base/src/main/ets/pages/index.ets | 35 +- .../oh/base/src/main/ets/pages/newVersion.ets | 71 +- product/oh/base/src/main/module.json5 | 4 +- 50 files changed, 799 insertions(+), 1614 deletions(-) create mode 100644 common/BuildProfile.ets rename common/{package.json => oh-package.json5} (92%) delete mode 100644 common/package-lock.json create mode 100644 common/src/main/ets/util/CommonUtils.ts rename common/src/main/ets/util/{FormatUtils.ts => FormatUtils.ets} (69%) rename common/src/main/ets/util/{NetUtils.ts => NetUtils.ets} (91%) create mode 100644 feature/ota/BuildProfile.ets create mode 100644 feature/ota/oh-package-lock.json5 rename feature/ota/{package.json => oh-package.json5} (63%) delete mode 100644 feature/ota/package-lock.json rename feature/ota/src/main/ets/dialog/{DialogUtils.ts => DialogUtils.ets} (65%) rename feature/ota/src/main/ets/notify/{NotificationManager.ts => NotificationManager.ets} (81%) rename feature/ota/src/main/ets/util/{RouterUtils.ts => RouterUtils.ets} (96%) rename feature/ota/src/main/ets/util/{ToastUtils.ts => ToastUtils.ets} (100%) create mode 100644 oh-package-lock.json5 rename package.json => oh-package.json5 (76%) delete mode 100644 package-lock.json create mode 100644 product/oh/base/oh-package-lock.json5 rename product/oh/base/{package.json => oh-package.json5} (80%) delete mode 100644 product/oh/base/package-lock.json rename product/oh/base/src/main/ets/MainAbility/{MainAbility.ts => MainAbility.ets} (95%) rename product/oh/base/src/main/ets/ServiceExtAbility/{service.ts => service.ets} (88%) rename product/oh/base/src/main/ets/ServiceExtAbility/{serviceStub.ts => serviceStub.ets} (100%) diff --git a/AppScope/app.json5 b/AppScope/app.json5 index b6ab6f3..11dac29 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,8 +3,8 @@ "bundleName": "com.ohos.updateapp", "debug": false, "vendor": "example", - "versionCode": 2040000127, - "versionName": "204.0.0.127", + "versionCode": 2040000128, + "versionName": "204.0.0.128", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true diff --git a/build-profile.json5 b/build-profile.json5 index aee89f0..f81b4c4 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,11 +1,19 @@ { "app": { - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, "products": [ { "name": "default", "signingConfig": "release", + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "arkTSVersion": "1.1", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } } ] }, diff --git a/common/BuildProfile.ets b/common/BuildProfile.ets new file mode 100644 index 0000000..883d509 --- /dev/null +++ b/common/BuildProfile.ets @@ -0,0 +1,19 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ + +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ + +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/common/build-profile.json5 b/common/build-profile.json5 index 35dff6d..61d0468 100644 --- a/common/build-profile.json5 +++ b/common/build-profile.json5 @@ -1,5 +1,6 @@ { "apiType": "stageMode", + "arkTSVersion": '1.1', "buildOption": { } } diff --git a/common/package.json b/common/oh-package.json5 similarity index 92% rename from common/package.json rename to common/oh-package.json5 index da97b7a..afe7346 100644 --- a/common/package.json +++ b/common/oh-package.json5 @@ -7,7 +7,7 @@ "version": "1.0.0", "main": "index.ets", "types": "", - "repository": {}, + "repository": "", "license": "ISC", "dependencies": {}, "type": "module" diff --git a/common/package-lock.json b/common/package-lock.json deleted file mode 100644 index 01b613f..0000000 --- a/common/package-lock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@ohos/common", - "version": "1.0.0", - "lockfileVersion": 1 -} diff --git a/common/src/main/ets/component/CheckingDots.ets b/common/src/main/ets/component/CheckingDots.ets index 45fe1ce..1301525 100644 --- a/common/src/main/ets/component/CheckingDots.ets +++ b/common/src/main/ets/component/CheckingDots.ets @@ -23,7 +23,7 @@ export struct CheckingDots { @Prop @Watch('onDotTextPlayChange') private dotTextPlay: boolean; private newVersionDotText: string= '.'; - private checkingTid: number = null; + private checkingTid: number | null = null; @State private dotNumber: number = 0; aboutToDisappear() { diff --git a/common/src/main/ets/component/HomeCardView.ets b/common/src/main/ets/component/HomeCardView.ets index 647d9ab..5a7ffbf 100644 --- a/common/src/main/ets/component/HomeCardView.ets +++ b/common/src/main/ets/component/HomeCardView.ets @@ -28,8 +28,10 @@ export struct HomeCardView { private indexVideo: number = 99; private aspectRatioHorizontal: number = 16 / 7; private aspectRatioVertical: number = 1 / 1; - private onVideoFinished: () => boolean; - private videoController: VideoController; + private onVideoFinished: () => boolean = () => { + return false; + }; + private videoController: VideoController = new VideoController(); @State private handleVideoPlay: boolean = false; onChange() { @@ -45,7 +47,7 @@ export struct HomeCardView { } } - @Builder showLogoMedia(constraintSize) { + @Builder showLogoMedia(constraintSize: ConstraintSizeOptions) { Stack({ alignContent: Alignment.Center }) { Video({ src: $r('app.media.video'), diff --git a/common/src/main/ets/component/TitleBar.ets b/common/src/main/ets/component/TitleBar.ets index 059cf97..68f50a6 100644 --- a/common/src/main/ets/component/TitleBar.ets +++ b/common/src/main/ets/component/TitleBar.ets @@ -24,7 +24,7 @@ import { LogUtils } from '../util/LogUtils'; @Component export struct TitleBar { private static readonly TAG = 'TitleBar'; - private title: string | Resource; + private title: string | Resource = ''; private onBack?: () => boolean; build() { diff --git a/common/src/main/ets/const/update_const.ts b/common/src/main/ets/const/update_const.ts index abf5aca..b43b90f 100644 --- a/common/src/main/ets/const/update_const.ts +++ b/common/src/main/ets/const/update_const.ts @@ -101,12 +101,12 @@ export interface OtaStatus { /** * 状态 */ - status: number; + status?: number; /** * 进度 */ - percent: number; + percent?: number; /** * 终止原因 @@ -145,47 +145,47 @@ export enum ErrorCode { /** * 错误码--鉴权失败 */ - AUTH_FAIL = '-208', + AUTH_FAIL = -208, /** * 错误码--鉴权失败服务错误 */ - AUTH_SERVER_ERROR = '-209', + AUTH_SERVER_ERROR = -209, /** * 错误码--鉴权失败系统错误 */ - AUTH_SYSTEM_ERROR = '-210', + AUTH_SYSTEM_ERROR = -210, /** * 错误码--网络错误 */ - NETWORK_ERROR = '-301', + NETWORK_ERROR = -301, /** * 错误码--空间不足 */ - NO_ENOUGH_MEMORY = '-304', + NO_ENOUGH_MEMORY = -304, /** * 错误码--检验失败 */ - VERIFY_PACKAGE_FAIL = '-305', + VERIFY_PACKAGE_FAIL = -305, /** * 错误码--部分升級失敗 */ - UPDATE_PART_FAIL = '-409', + UPDATE_PART_FAIL = -409, /** * 错误码--电量不足 */ - NO_ENOUGH_BATTERY = '-830', + NO_ENOUGH_BATTERY = -830, /** * 错误码--网络不允许 */ - NETWORK_NOT_ALLOW = '3148800' + NETWORK_NOT_ALLOW = 3148800 } /** @@ -258,17 +258,17 @@ export interface Features { /** * 标题 */ - title: string; + title?: string; /** * 标识 */ - id: string; + id?: string; /** * 特性类型 */ - featureModuleType: string; + featureModuleType?: string; /** * 特性数组 @@ -278,7 +278,7 @@ export interface Features { /** * 图标 */ - icon: Icon; + icon?: Icon; } /** @@ -290,7 +290,7 @@ export interface Feature { /** * 子标题 */ - subTitle: string; + subTitle?: string; /** * 内容数组 @@ -307,17 +307,17 @@ export interface Icon { /** * 标识 */ - id: string; + id?: string; /** * 包名 */ - pkg: string; + pkg?: string; /** * 数据流字串 */ - res: string; + res?: string; } /** @@ -473,4 +473,21 @@ export const PACKAGE_NAME = 'com.ohos.updateapp'; /** * 主ability名 */ -export const MAIN_ABILITY_NAME = 'com.ohos.updateapp.MainAbility'; \ No newline at end of file +export const MAIN_ABILITY_NAME = 'com.ohos.updateapp.MainAbility'; + +/** + * Updater Event information + * + * @since 2024-08-27 + */ +export interface CustomEventInfo { + /** + * Task event id + */ + eventId: number; + + /** + * Task body info + */ + taskBody: update.TaskBody; +} \ No newline at end of file diff --git a/common/src/main/ets/manager/UpdateManager.ts b/common/src/main/ets/manager/UpdateManager.ts index 3c32f48..8f984a6 100644 --- a/common/src/main/ets/manager/UpdateManager.ts +++ b/common/src/main/ets/manager/UpdateManager.ts @@ -18,7 +18,6 @@ import update from '@ohos.update'; import { PACKAGE_NAME, UpdateState, UpgradeCallResult, } from '../const/update_const'; import type { BusinessError, OtaStatus, UpgradeData} from '../const/update_const'; import { LogUtils } from '../util/LogUtils'; -import { UpdateUtils } from '../util/UpdateUtils'; /** * 方法超时控制装饰器 @@ -55,7 +54,7 @@ export function enableTimeOutCheck(timeout?: number): MethodDecorator { result.then(innerRes => { clearTimeout(requestTimeout); resolve(innerRes); - }).catch(err => { + }).catch((err: BusinessError) => { LogUtils.error('UpdateManager', 'err: ' + JSON.stringify(err)); clearTimeout(requestTimeout); upgradeData.callResult = UpgradeCallResult.ERROR; @@ -68,7 +67,6 @@ export function enableTimeOutCheck(timeout?: number): MethodDecorator { } export interface IUpdate { - bind(subType: number, callback : Function): void; getOtaStatus(): Promise>; getNewVersion(): Promise>; getNewVersionDescription(descVersionDigest: string, descFormat: update.DescriptionFormat, @@ -90,30 +88,62 @@ export interface IUpdate { export class UpdateManager implements IUpdate { private otaUpdater: update.Updater; - public constructor() { + public constructor(subType: number, upgradeDeviceId?: string, deviceType?: number, packageName?: string) { + let upgradeInfo: update.UpgradeInfo = { + upgradeApp: packageName ?? PACKAGE_NAME, + businessType: { + vendor: update.BusinessVendor.PUBLIC, + subType: subType + } + }; + try { + this.otaUpdater = update.getOnlineUpdater(upgradeInfo); + } catch (error) { + LogUtils.error('UpdateManager',`getOnlineUpdater fail ${error?.code} ${error?.message}`); + } } /** * 绑定DUE * - * @param subType 升级类型 * @param callback 回调 */ - bind(subType: number, callback: update.UpgradeTaskCallback): void { - let upgradeInfo: update.UpgradeInfo = { - upgradeApp: PACKAGE_NAME, - businessType: { - vendor: update.BusinessVendor.PUBLIC, - subType: subType - } - }; + on(callback: update.UpgradeTaskCallback): void { + if (!callback) { + LogUtils.error('UpdateManager', 'on callback null'); + return; + } + let eventClassifyInfo: update.EventClassifyInfo = { + eventClassify: update.EventClassify.TASK, + extraInfo: '' + } try { - this.otaUpdater = update.getOnlineUpdater(upgradeInfo); - let eventClassifyInfo: update.EventClassifyInfo = { eventClassify: 0x01000000, extraInfo: '' }; this.otaUpdater?.on(eventClassifyInfo, callback); } catch (error) { - LogUtils.error('UpdateManager', 'otaUpdater init fail ' + JSON.stringify(error)); + LogUtils.error('UpdateManager', `otaUpdater on fail ${error?.code} ${error?.message}`); + } + } + + /** + * 取消绑定DUE + * + * @param callback 回调 + */ + off(callback: update.UpgradeTaskCallback): void { + if (!callback) { + LogUtils.error('UpdateManager', 'off callback null'); + return; + } + let eventClassifyInfo: update.EventClassifyInfo = { + eventClassify: update.EventClassify.TASK, + extraInfo: '' + } + + try { + this.otaUpdater?.off(eventClassifyInfo, callback); + } catch (error) { + LogUtils.error('UpdateManager', `otaUpdater off fail ${error?.code} ${error?.message}`); } } @@ -237,7 +267,7 @@ export class UpdateManager implements IUpdate { data: [{ errorCode: err?.data?.[0]?.errorCode }] } }; - if (!UpdateUtils.isSuccessCallback(result, err)) { + if (!result && err) { this.logError('getCurrentVersionDescription error is ${JSON.stringify(err)}'); upgradeData.callResult = UpgradeCallResult.ERROR; } @@ -496,9 +526,9 @@ export interface Message { */ export class MessageQueue { private queue: Array; - private handleMessage: (context: common.Context, eventInfo: update.EventInfo) => Promise; + private handleMessage: (message: Message) => Promise; - constructor(handleMessage: (context: common.Context, eventInfo: update.EventInfo) => Promise) { + constructor(handleMessage: (message: Message) => Promise) { this.queue = new Array(); this.handleMessage = handleMessage; } @@ -520,7 +550,7 @@ export class MessageQueue { private async loop(): Promise { let message: Message = this.peek(); if (message) { - await this.handleMessage?.(message.context, message.eventInfo).catch(err => { + await this.handleMessage?.(message.context, message.eventInfo).catch((err: BusinessError) => { LogUtils.error('MessageQueue', 'loop err:' + JSON.stringify(err)); }); this.poll(); diff --git a/common/src/main/ets/util/CommonUtils.ts b/common/src/main/ets/util/CommonUtils.ts new file mode 100644 index 0000000..12afd92 --- /dev/null +++ b/common/src/main/ets/util/CommonUtils.ts @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type update from '@ohos.update'; +import type common from '@ohos.app.ability.common'; +import { StartOptions } from '@kit.AbilityKit'; +import { MAIN_ABILITY_NAME, PACKAGE_NAME, UpdateState, OtaStatus } from '../const/update_const'; +import type { BusinessError } from '../const/update_const'; +import { LogUtils } from './LogUtils'; + +const TIME_OUT_FOR_START_ABILITY = 500; +type unionContext = common.UIAbilityContext | common.ServiceExtensionContext | common.UIExtensionContext; + +/** + * 接口工具 + * + * @since 2025-06-07 + */ +export class CommonUtils { + /** + * 判空处理 + * + * @param value 值 + * @return 是否为空 + */ + static isEmpty(value: T): boolean { + return value === null || value === undefined; + } + + + /** + * JSON stringify方法封装 + * + * @param value JS对象 + * @return json字符串 + */ + static stringify(value: T): string { + if (value) { + try { + return JSON.stringify(value); + } catch (exception) { + LogUtils.error('CommonUtils', 'JSON.stringify failed !!'); + return ''; + } + } + return ''; + } + + /** + * json 字符串解析 + * + * @param content json 字符串 + * @return T 解析后返回值 + */ + static parseJson(content: string): T { + if (!content) { + return null; + } + try { + return JSON.parse(content) as T; + } catch (exception) { + LogUtils.error('CommonUtils', 'paramJson failed !!'); + } + return null; + } + + /** + * string判空处理 + * + * @param value string值 + * @return 是否为空 + */ + static isStringEmpty(value: string | undefined | null): boolean { + return value === null || value === undefined || value === ''; + } +} + +/** + * 装饰器--弹框时,前台判断处理 + */ +export function foregroundCheck() { + return (target: Object, propertyKey: string, descriptor: PropertyDescriptor): void => { + const original = descriptor.value; + descriptor.value = (context: common.Context, otaStatus: OtaStatus, + eventId?: update.EventId, ...args): void => { + if (globalThis.AbilityStatus !== 'ON_FOREGROUND') { + globalThis.reNotify = true; + globalThis.otaStatusFromService = otaStatus; + globalThis.eventIdFromService = eventId; + LogUtils.log('foregroundCheck', 'do startMainAbilityIndex.'); + + // 应用在后台时,无法弹框,需杀掉ability后,重新拉起界面弹框 + globalThis.abilityContext?.terminateSelf(); + setTimeout(() => { + startMainAbilityIndex(context); + }, TIME_OUT_FOR_START_ABILITY); + return; + } + original.call(this, ...args); + }; + }; +} + +/** + * 启动Ability + * + * @param context 要启动Ability的context + * @param want 要启动Ability的want + * @param options 配置项 + */ +export function startAbility(context: common.Context, want: Want, options?: StartOptions): void { + if (!context || !want) { + LogUtils.error('CommonUtils', 'Failed to start ability with error: context or want is null.'); + return; + } + (context as unionContext).startAbility(want, options).then(() => { + LogUtils.info('CommonUtils', 'Succeed to start ability' ); + }).catch((error: BusinessError) => { + LogUtils.error('CommonUtils', 'Failed to start ability with error: ' + JSON.stringify(error)); + }); +} + +export function startMainAbilityIndex(context: common.Context): void { + let want: Want = { + bundleName: PACKAGE_NAME, + abilityName: MAIN_ABILITY_NAME, + uri: 'pages/newVersion', + }; + startAbility(context, want, undefined); +} \ No newline at end of file diff --git a/common/src/main/ets/util/FormatUtils.ts b/common/src/main/ets/util/FormatUtils.ets similarity index 69% rename from common/src/main/ets/util/FormatUtils.ts rename to common/src/main/ets/util/FormatUtils.ets index bb30220..6fd2018 100644 --- a/common/src/main/ets/util/FormatUtils.ts +++ b/common/src/main/ets/util/FormatUtils.ets @@ -17,13 +17,14 @@ import type common from '@ohos.app.ability.common'; import { DeviceUtils } from '../util/DeviceUtils'; import { LogUtils } from './LogUtils'; +const DECIMAL_POINT = 2; + /** * 格式化工具 * * @since 2022-06-06 */ -export namespace FormatUtils { - const DECIMAL_POINT = 2; +export class FormatUtils { /** * 格式化文件大小 @@ -32,7 +33,7 @@ export namespace FormatUtils { * @param decimalPoint 精确到小数点后两位 * @return 格式化后的字符串 */ - export function formatFileSize(bytes: number, decimalPoint = DECIMAL_POINT): string { + static formatFileSize(bytes: number, decimalPoint = DECIMAL_POINT): string { if (bytes <= 0) { return '0 Bytes'; } @@ -54,7 +55,7 @@ export namespace FormatUtils { * @param args 待匹配的内容 * @return 格式化后的字符串 */ - export function formatStr(message: string, ...args: (string | number)[]): string { + static formatStr(message: string, ...args: (string | number)[]): string { if (!message) { return ''; } @@ -78,7 +79,7 @@ export namespace FormatUtils { * @param args 待匹配的内容 * @return 转大写后的字符串 */ - export function toUpperCase(context: common.Context, text: ResourceStr, ...args: (string | number)[]): string { + static toUpperCase(context: common.Context, text: ResourceStr, ...args: (string | number)[]): string { if (!text) { return ''; } @@ -86,7 +87,7 @@ export namespace FormatUtils { return text.toUpperCase(); } else { let message: string = context?.resourceManager.getStringSync(text.id); - return formatStr(message, ...args).toUpperCase(); + return FormatUtils.formatStr(message, ...args).toUpperCase(); } } @@ -96,45 +97,8 @@ export namespace FormatUtils { * @param num 待格式化数字 * @return 格式化之后的数字 */ - export function getNumberFormat(num: number): string { + static getNumberFormat(num: number): string { let language: string = DeviceUtils.getSystemLanguage(); let numfmt: Intl.NumberFormat = new Intl.NumberFormat(language, {style:'percent', notation:'standard'}); return numfmt.format(num); - } - - /** - * JSON stringify方法封装 - * - * @param value JS对象 - * @return json字符串 - */ - export function stringify(value: T): string { - if (value) { - try { - return JSON.stringify(value); - } catch (exception) { - LogUtils.error('FormateUtils', 'JSON.stringify failed !!'); - return ''; - } - } - return ''; - } - - /** - * json 字符串解析 - * - * @param content json 字符串 - * @return T 解析后返回值 - */ - export function parseJson(content: string): T | null { - if (!content) { - return null; - } - try { - return JSON.parse(content) as T; - } catch (exception) { - LogUtils.error('FormateUtils', 'paramJson failed !!'); - } - return null; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/common/src/main/ets/util/NetUtils.ts b/common/src/main/ets/util/NetUtils.ets similarity index 91% rename from common/src/main/ets/util/NetUtils.ts rename to common/src/main/ets/util/NetUtils.ets index c054f52..d744fb1 100644 --- a/common/src/main/ets/util/NetUtils.ts +++ b/common/src/main/ets/util/NetUtils.ets @@ -14,6 +14,7 @@ */ import connection from '@ohos.net.connection'; +import { BusinessError } from '../const/update_const'; import { LogUtils } from '../util/LogUtils'; /** @@ -34,11 +35,11 @@ export namespace NetUtils { connection.getNetCapabilities(netHandle).then((info) => { LogUtils.log('NetUtils', 'getNetCapabilities data ' + JSON.stringify(info)); resolve(info?.bearerTypes?.length !== 0); - }).catch((err) => { + }).catch((err: BusinessError) => { LogUtils.log('NetUtils', 'getNetCapabilities err ' + JSON.stringify(err)); resolve(false); }); - }).catch((err) => { + }).catch((err: BusinessError) => { LogUtils.log('NetUtils', 'getDefaultNet err ' + JSON.stringify(err)); resolve(false); }); @@ -57,11 +58,11 @@ export namespace NetUtils { connection.getNetCapabilities(netHandle).then((info) => { LogUtils.log('NetUtils', 'getNetCapabilities data ' + JSON.stringify(info)); resolve(info?.bearerTypes?.length === 1 && info?.bearerTypes?.[0] === connection.NetBearType.BEARER_CELLULAR); - }).catch((err) => { + }).catch((err: BusinessError) => { LogUtils.log('NetUtils', 'getNetCapabilities err ' + JSON.stringify(err)); resolve(false); }); - }).catch((err) => { + }).catch((err: BusinessError) => { LogUtils.log('NetUtils', 'getDefaultNet err ' + JSON.stringify(err)); resolve(false); }); diff --git a/common/src/main/ets/util/UpdateUtils.ets b/common/src/main/ets/util/UpdateUtils.ets index f03a21d..f49ca52 100644 --- a/common/src/main/ets/util/UpdateUtils.ets +++ b/common/src/main/ets/util/UpdateUtils.ets @@ -14,12 +14,16 @@ */ import update from '@ohos.update'; +import { StartOptions } from '@kit.AbilityKit'; +import type { BusinessError } from '../const/update_const'; +import type common from '@ohos.app.ability.common'; import { LogUtils } from './LogUtils'; /** * 日志TAG */ const TAG = 'UpdateUtils'; +type unionContext = common.UIAbilityContext | common.ServiceExtensionContext | common.UIExtensionContext; /** * 接口工具 @@ -58,14 +62,14 @@ export namespace UpdateUtils { * @param want 要启动Ability的want * @param options 配置项 */ - export function startAbility(context: any, want, options): void { + export function startAbility(context: common.Context, want: Want, options?: StartOptions): void { if (!context || !want) { LogUtils.error(TAG, 'Failed to start ability with error: context or want is null.'); return; } - context.startAbility(want, options).then((data) => { + (context as unionContext).startAbility(want, options).then((data) => { LogUtils.info(TAG, 'Succeed to start ability with data: ' + JSON.stringify(data)); - }).catch((error) => { + }).catch((error: BusinessError) => { LogUtils.error(TAG, 'Failed to start ability with error: ' + JSON.stringify(error)); }); } @@ -76,7 +80,7 @@ export namespace UpdateUtils { * @param err 返回信息 * @param return 接口调用结果 */ - export function isSuccessCallback(result: unknown, err: any): boolean { - return result && !err; + export function isSuccessCallback(result: Object, err: Object): boolean { + return !!result && !err; } } \ No newline at end of file diff --git a/feature/ota/BuildProfile.ets b/feature/ota/BuildProfile.ets new file mode 100644 index 0000000..883d509 --- /dev/null +++ b/feature/ota/BuildProfile.ets @@ -0,0 +1,19 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ + +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ + +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/feature/ota/build-profile.json5 b/feature/ota/build-profile.json5 index 35dff6d..61d0468 100644 --- a/feature/ota/build-profile.json5 +++ b/feature/ota/build-profile.json5 @@ -1,5 +1,6 @@ { "apiType": "stageMode", + "arkTSVersion": '1.1', "buildOption": { } } diff --git a/feature/ota/oh-package-lock.json5 b/feature/ota/oh-package-lock.json5 new file mode 100644 index 0000000..53c2937 --- /dev/null +++ b/feature/ota/oh-package-lock.json5 @@ -0,0 +1,19 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. Do NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../common": "@ohos/common@../../common" + }, + "packages": { + "@ohos/common@../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../common", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/feature/ota/package.json b/feature/ota/oh-package.json5 similarity index 63% rename from feature/ota/package.json rename to feature/ota/oh-package.json5 index 2abe885..297a409 100644 --- a/feature/ota/package.json +++ b/feature/ota/oh-package.json5 @@ -1,16 +1,9 @@ { "name": "ota", "description": "a npm package which contains arkUI2.0 page", - "ohos": { - "org": "" - }, "version": "1.0.0", - "main": "index.ets", - "types": "", - "repository": {}, "license": "ISC", "dependencies": { "@ohos/common": "file:../../common" }, - "type": "module" } diff --git a/feature/ota/package-lock.json b/feature/ota/package-lock.json deleted file mode 100644 index 5382de1..0000000 --- a/feature/ota/package-lock.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ota", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/common": { - "version": "file:../../common" - } - } -} diff --git a/feature/ota/src/main/ets/UpgradeAdapter.ets b/feature/ota/src/main/ets/UpgradeAdapter.ets index 99e7131..d3ba799 100644 --- a/feature/ota/src/main/ets/UpgradeAdapter.ets +++ b/feature/ota/src/main/ets/UpgradeAdapter.ets @@ -24,8 +24,8 @@ import type { INotify, IPage } from '@ohos/common/src/main/ets/manager/UpgradeIn * @since 2022-12-01 */ export class UpgradeAdapter { - private _notifyInstance: INotify; - private _page: IPage; + private _notifyInstance: INotify | undefined = undefined; + private _page: IPage | undefined = undefined; private constructor() { globalThis.upgradeAdapter = this; diff --git a/feature/ota/src/main/ets/components/ChangelogContent.ets b/feature/ota/src/main/ets/components/ChangelogContent.ets index ef71e11..f3e6ddb 100644 --- a/feature/ota/src/main/ets/components/ChangelogContent.ets +++ b/feature/ota/src/main/ets/components/ChangelogContent.ets @@ -32,9 +32,9 @@ import ChangelogParseUtils from '../util/ChangelogParseUtils'; */ @Component export struct ChangelogContent { - @State private changelogInfoList: Array = null; - private isCurrentPage: boolean; - isNeedFold: boolean; + @State private changelogInfoList: Array | null = null; + private isCurrentPage: boolean = false; + isNeedFold: boolean = false; @Prop @Watch('parseChangelog') description: string; @State private isParseChangelogFinished: boolean = false; @@ -44,7 +44,7 @@ export struct ChangelogContent { ForEach(this.changelogInfoList, (item: ChangelogInfo, index?: number) => { ChangelogCard({ changelogInfo: item, - index: this.changelogInfoList?.length > 1 ? index + 1 : 0, + index: (this.changelogInfoList && this.changelogInfoList?.length > 1) ? index + 1 : 0, isCurrentPage: this.isCurrentPage }); }) @@ -66,12 +66,12 @@ export struct ChangelogContent { } @Builder setEndFeature() { - Text(this.changelogInfoList?.[0].endFeatures.title) + Text(this.changelogInfoList?.[0].endFeatures?.title) .fontSize($r('app.float.changelog_content_end_title')) .fontColor($r('sys.color.ohos_fa_text_secondary')) .fontWeight(FontWeight.Medium) .width('100%') - ForEach(this.changelogInfoList?.[0].endFeatures.featureList, (feature: Feature) => { + ForEach(this.changelogInfoList?.[0].endFeatures?.featureList, (feature: Feature) => { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { ForEach(feature.contents, (content: string) => { Text(content) @@ -79,7 +79,7 @@ export struct ChangelogContent { .fontSize($r('app.float.changelog_end_word')) .fontWeight(FontWeight.Regular) .align(Alignment.Start) - .padding({ top: this.changelogInfoList?.[0].endFeatures.featureList.indexOf(feature) == 0 ? + .padding({ top: this.changelogInfoList?.[0].endFeatures?.featureList.indexOf(feature) == 0 ? $r('app.float.changelog_tablet_has_feature_padding_top') : $r('app.float.changelog_tablet_no_feature_padding_top') }); @@ -95,7 +95,7 @@ export struct ChangelogContent { private parseChangelog(): void { this.logInfo('parseChangelog'); - let list: ChangelogInfo[] = null; + let list: ChangelogInfo[] | null = null; if (this.description) { list = JSON.parse(this.description); } @@ -119,17 +119,17 @@ export struct ChangelogContent { }); }); this.isParseChangelogFinished = true; - this.changelogInfoList = isParseSuccess ? list : null; + this.changelogInfoList = isParseSuccess ? list : []; } else { this.logInfo('description is null'); } } - private getHeaderFeatures(changelog: Changelog, language: string): Features { + private getHeaderFeatures(changelog: Changelog, language: string): Features | undefined { return this.getTargetFeatures(changelog, language, 'header'); } - private getEndFeatures(changelog: Changelog, language: string): Features{ + private getEndFeatures(changelog: Changelog, language: string): Features | undefined { return this.getTargetFeatures(changelog, language, 'end'); } @@ -138,7 +138,7 @@ export struct ChangelogContent { if (changelog == null || language == null) { return featuresList; } - let lang: Language = changelog.language.get(language); + let lang: Language | undefined = changelog.language.get(language); if (lang == null) { return featuresList; } @@ -152,20 +152,22 @@ export struct ChangelogContent { return featuresList; } - private getTargetFeatures(changelog: Changelog, language: string, type: string): Features { + private getTargetFeatures(changelog: Changelog, language: string, type: string): Features | undefined { if (changelog == null || language == null) { return null; } - let lang: Language = changelog.language.get(language); + let lang: Language | undefined = changelog.language.get(language); if (lang == null) { return null; } + let _features: Features | undefined; for (let index = 0; index < lang.featuresArray.length; index++) { const features = lang.featuresArray[index]; if (features != null && features.featureModuleType == type) { return features; } } + return _features; } build(): void{ @@ -188,8 +190,8 @@ export struct ChangelogContent { */ @Component struct ChangelogCard { - changelogInfo: ChangelogInfo; - index: number; + changelogInfo: ChangelogInfo | null = null; + index: number = 0; isCurrentPage: boolean = false; aboutToAppear() { @@ -241,7 +243,7 @@ struct ChangelogCard { } @Builder setStartFeature(changelogInfo: ChangelogInfo) { - if (changelogInfo.headFeatures.featureList) { + if (changelogInfo.headFeatures && changelogInfo.headFeatures.featureList) { this.setFeatureContent(changelogInfo.headFeatures.featureList) } } diff --git a/feature/ota/src/main/ets/components/ProgressContent.ets b/feature/ota/src/main/ets/components/ProgressContent.ets index 3987f41..7c7d73e 100644 --- a/feature/ota/src/main/ets/components/ProgressContent.ets +++ b/feature/ota/src/main/ets/components/ProgressContent.ets @@ -21,10 +21,10 @@ import { StateManager, UpdateAction } from '../manager/StateManager'; * @param progress 进度值 * @return 显示进度值 */ -function getDisplayProgress(progress): number { +function getDisplayProgress(progress: number): number { let displayProgress = 0; if (!isNaN(progress)) { - displayProgress = (progress).toFixed(0); + displayProgress = Number((progress).toFixed(0)); } return displayProgress; } @@ -37,9 +37,9 @@ function getDisplayProgress(progress): number { @Component export struct ProgressContent { @StorageProp('updateStatus') - private updateStatus: number = AppStorage.Get('updateStatus'); + private updateStatus: number = AppStorage.Get('updateStatus') as number; @StorageProp('downloadProgress') - private downloadProgress: number = AppStorage.Get('downloadProgress'); + private downloadProgress: number = AppStorage.Get('downloadProgress') as number; @Builder ProgressView() { Stack({ alignContent: Alignment.Center }) { diff --git a/feature/ota/src/main/ets/dialog/CountDownInstallDialogBuilder.ets b/feature/ota/src/main/ets/dialog/CountDownInstallDialogBuilder.ets index ca465fc..78aa2b8 100644 --- a/feature/ota/src/main/ets/dialog/CountDownInstallDialogBuilder.ets +++ b/feature/ota/src/main/ets/dialog/CountDownInstallDialogBuilder.ets @@ -24,7 +24,7 @@ import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils' @CustomDialog export struct CountDownInstallDialogBuilder { @StorageProp('configLanguage') - @Watch('onLanguageChange') private configLanguage: string = AppStorage.Get('configLanguage'); + @Watch('onLanguageChange') private configLanguage: string = AppStorage.Get('configLanguage') as string; /** * 控制器 @@ -34,7 +34,7 @@ export struct CountDownInstallDialogBuilder { /** * 文本显示内容 */ - textString: Resource | string; + textString: Resource | string = ''; /** * 取消按钮显示内容 @@ -49,7 +49,7 @@ export struct CountDownInstallDialogBuilder { /** * 弹窗类型 */ - dialogType: CountDownDialogType; + dialogType: CountDownDialogType | undefined = undefined; /** * 倒计时 @@ -59,14 +59,16 @@ export struct CountDownInstallDialogBuilder { /** * 取消回调 */ - cancel: () => void; + cancel: () => void = () => { + }; /** * 确认回调 */ - confirm: () => void; + confirm: () => void = () => { + }; - private intervalID: number = null; + private intervalID: number | null = null; aboutToAppear() { this.getCount(); @@ -95,7 +97,7 @@ export struct CountDownInstallDialogBuilder { private initButtonText(): void { this.cancelBtnText = FormatUtils.toUpperCase(globalThis.abilityContext, $r('app.string.later')); - let confirmBtnRes = null; + let confirmBtnRes: ResourceStr = ''; if (this.dialogType == CountDownDialogType.OTA) { confirmBtnRes = $r('app.string.install_now'); } else if (this.dialogType == CountDownDialogType.OTA_AB) { diff --git a/feature/ota/src/main/ets/dialog/DialogHelper.ets b/feature/ota/src/main/ets/dialog/DialogHelper.ets index c67e0bd..be3581c 100644 --- a/feature/ota/src/main/ets/dialog/DialogHelper.ets +++ b/feature/ota/src/main/ets/dialog/DialogHelper.ets @@ -13,16 +13,14 @@ * limitations under the License. */ +import update from '@ohos.update'; import { DeviceUtils } from '@ohos/common/src/main/ets/util/DeviceUtils'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; +import { UpdateState } from '@ohos/common/src/main/etc/const/update_const'; +import { OtaUpdateManager } from '../manager/OtaUpdateManager'; +import RouteUtils from '../util/RouteUtils'; -/** - * 弹框辅助者 - * - * @since 2022-06-05 - */ -export namespace DialogHelper { /** * 弹框操作接口 * @@ -32,20 +30,68 @@ export namespace DialogHelper { /** * 取消 */ - onCancel?: () => void; + onCancel(): void; /** * 确认 */ - onConfirm?: () => void; + onConfirm(): void; } +/** + * 重试检测动作 + */ +calss RetryCheckAction implements DialogOperator { + onConfirm(): void { + RouterUtils.singletonHomePage(); + } + onCancel(): void { + RouterUtils.singletonHomePage(); + } +}; + +export const retryCheckAction: DialogOperator = new RetryCheckAction(); + +/** + * 重试下载动作 + */ +class RetryDownloadAction implements DialogOperator { + onConfirm(): void { + OtaUpdateManager.getInstance().setUpdateState(UpdateState.CHECK_SUCCESS); + } + onCancel(): void { + OtaUpdateManager.getInstance().setUpdateState(UpdateState.CHECK_SUCCESS); + } +}; + +const retryDownloadAction: DialogOperator = new RetryDownloadAction(); + +/** + * 重试安装动作 + */ +class RetryUpgradeAction implements DialogOperator { + onConfirm(): void { + OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); + } + onCancel(): void { + OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); + } +}; + +const retryUpgradeAction: DialogOperator = new RetryUpgradeAction(); + +/** + * 弹框辅助者 + * + * @since 2022-06-05 + */ +export namespace DialogHelper { /** * 网络弹框 * * @param operator 回调 */ - export function displayNetworkDialog(operator: DialogOperator): void { + export function displayNetworkDialog(): void { AlertDialog.show( { title: $r('app.string.software_update'), @@ -54,7 +100,8 @@ export namespace DialogHelper { value: FormatUtils.toUpperCase(globalThis.abilityContext, $r('app.string.cancel')), action: () => { logInfo('Callback when the first button is clicked'); - operator.onCancel?.(); + onCancel: () => { + }; }, backgroundColor: $r('sys.float.ohos_id_corner_radius_button') }, @@ -62,7 +109,9 @@ export namespace DialogHelper { value: $r('app.string.ok'), action: () => { logInfo('Callback when the second button is clicked'); - operator.onConfirm?.(); + onConfirm: () => { + OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); + }; }, backgroundColor: $r('sys.float.ohos_id_corner_radius_button') }, @@ -71,7 +120,7 @@ export namespace DialogHelper { }, alignment: DeviceUtils.getDialogLocation(), offset: ({ - dx: '0vp', + dx: "0vp", dy: DeviceUtils.getDialogOffsetY() }), autoCancel: false @@ -84,8 +133,8 @@ export namespace DialogHelper { * * @param operator 回调 */ - export function displayUpgradeFailDialog(operator ?: DialogOperator): void { - defaultNoTitleDialog($r('app.string.update_fail'), operator); + export function displayUpgradeFailDialog(): void { + defaultNoTitleDialog($r('app.string.update_fail'), retryCheckAction); } /** @@ -93,8 +142,8 @@ export namespace DialogHelper { * * @param operator 回调 */ - export function displayDownloadFailDialog(operator ?: DialogOperator): void { - defaultNoTitleDialog($r('app.string.download_fail'), operator); + export function displayDownloadFailDialog(): void { + defaultNoTitleDialog($r('app.string.download_fail'), retryCheckAction); } /** @@ -116,13 +165,24 @@ export namespace DialogHelper { FormatUtils.getNumberFormat(0.3)), operator); } +/** + * 下载空间不足弹框 + * + * @param operator 回调 + */ + export function displayDownloadNotEnoughSpaceDialog(): void { + defaultKnowDialog($r('app.string.space_not_enough_title'), $r('app.string.space_not_enough_content'), + retryDownloadAction); + } + /** * 空间不足弹框 * * @param operator 回调 */ - export function displayNotEnoughSpaceDialog(operator ?: DialogOperator): void { - defaultKnowDialog($r('app.string.space_not_enough_title'), $r('app.string.space_not_enough_content'), operator); + export function displayUpgradeNotEnoughSpaceDialog(): void { + defaultKnowDialog($r('app.string.space_not_enough_title'), $r('app.string.space_not_enough_content'), + retryUpgradeAction); } /** @@ -130,8 +190,8 @@ export namespace DialogHelper { * * @param operator 回调 */ - export function displayVerifyFailDialog(operator ?: DialogOperator): void { - defaultNoTitleDialog($r('app.string.package_verify_fail'), operator); + export function displayVerifyFailDialog(): void { + defaultNoTitleDialog($r('app.string.package_verify_fail'), retryCheckAction); } /** @@ -163,7 +223,7 @@ export namespace DialogHelper { * @param confirmText 确认按钮显示内容 * @param operator 回调 */ - function showDialog(title: string | Resource, message: string | Resource, confirmText?: string | Resource, + function showDialog(title: string | Resource | null, message: string | Resource, confirmText?: string | Resource, operator ?: DialogOperator): void { AlertDialog.show( { @@ -173,7 +233,7 @@ export namespace DialogHelper { value: confirmText, action: () => { logInfo('defaultKnowDialog button is clicked'); - if (operator) { + if (operator && operator.onConfirm) { operator.onConfirm(); } }, @@ -181,8 +241,8 @@ export namespace DialogHelper { }, cancel: () => { logInfo('Closed callbacks'); - if(operator) { - operator.onCancel(); + if(operator && operator.onCancel) { + operator?.onCancel(); } }, alignment: DeviceUtils.getDialogLocation(), diff --git a/feature/ota/src/main/ets/dialog/DialogUtils.ts b/feature/ota/src/main/ets/dialog/DialogUtils.ets similarity index 65% rename from feature/ota/src/main/ets/dialog/DialogUtils.ts rename to feature/ota/src/main/ets/dialog/DialogUtils.ets index 3525711..a7a2cc3 100644 --- a/feature/ota/src/main/ets/dialog/DialogUtils.ts +++ b/feature/ota/src/main/ets/dialog/DialogUtils.ets @@ -23,78 +23,64 @@ import { OtaUpdateManager } from '../manager/OtaUpdateManager'; import RouterUtils from '../util/RouterUtils'; import { DialogHelper } from './DialogHelper'; -const TIME_OUT_FOR_START_ABILITY = 500; - /** - * 装饰器--弹框时,前台判断处理 + * 弹框操作接口 + * @since 2025-06-09 */ -function foregroundCheck() { - return function inner(target: unknown, propertyKey: string, descriptor: PropertyDescriptor): void { - const original = descriptor.value; - descriptor.value = function (context: common.Context, otaStatus: OtaStatus, - eventId?: update.EventId, ...args): void { - if (globalThis.AbilityStatus !== 'ON_FOREGROUND') { - globalThis.reNotify = true; - globalThis.otaStatusFromService = otaStatus; - globalThis.eventIdFromService = eventId; - LogUtils.log('foregroundCheck', 'do startMainAbilityIndex.'); - - // 应用在后台时,无法弹框,需杀掉ability后,重新拉起界面弹框 - globalThis.abilityContext?.terminateSelf(); - setTimeout(() => { - startMainAbilityIndex(context); - }, TIME_OUT_FOR_START_ABILITY); - return; - } - original.call(this, ...args); - }; - }; -} +interface DialogOperator { + /** + * 取消 + */ + onCancel(): void; -function startMainAbilityIndex(context: common.Context): void { - let want = { - bundleName: PACKAGE_NAME, - abilityName: MAIN_ABILITY_NAME, - uri: 'pages/newVersion', - }; - UpdateUtils.startAbility(context, want, null); + /** + * 确认 + */ + onConfirm(): void; } /** * 重试下载动作 */ -const retryDownloadAction = { - onConfirm: (): void => { +class RetryDownloadAction implements DialogOperator { + onConfirm(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.CHECK_SUCCESS); - }, - onCancel: (): void => { + } + onCancel(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.CHECK_SUCCESS); - }, + } }; +const retryDownloadAction: DialogOperator = new RetryDownloadAction(); + /** * 重试安装动作 */ -const retryUpgradeAction = { - onConfirm: (): void => { +class RetryUpgradeAction implements DialogOperator { + onConfirm(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); - }, - onCancel: (): void => { + } + onCancel(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); - }, + } }; +const retryUpgradeAction: DialogOperator = new RetryUpgradeAction(); + /** * 重试检测动作 */ -const retryCheckAction = { - onConfirm: (): void => { +calss RetryCheckAction implements DialogOperator { + onConfirm(): void { RouterUtils.singletonHomePage(); - }, onCancel: (): void => { + } + onCancel(): void { RouterUtils.singletonHomePage(); - }, + } }; + const retryCheckAction: DialogOperator = new RetryCheckAction(); + /** * 弹框工具类 * @@ -110,7 +96,7 @@ export class DialogUtils { static showDownloadNotEnoughSpaceDialog(context: common.Context, otaStatus: OtaStatus, eventId?: update.EventId): void { LogUtils.log('DialogUtils', 'showDownloadNotEnoughSpaceDialog'); - DialogHelper.displayNotEnoughSpaceDialog(retryDownloadAction); + DialogHelper.displayDownloadNotEnoughSpaceDialog(); } /** @@ -131,9 +117,9 @@ export class DialogUtils { * @param context 上下文 */ @foregroundCheck() - static showVerifyFailDialog(context: common.Context, otaStatus: OtaStatus, eventId?: update.EventId): void { + static showVerifyFailDialog(context: common.Context, otaStatus?: OtaStatus, eventId?: update.EventId): void { LogUtils.log('DialogUtils', 'showVerifyFailDialog'); - DialogHelper.displayVerifyFailDialog(retryCheckAction); + DialogHelper.displayVerifyFailDialog(); } /** @@ -142,9 +128,9 @@ export class DialogUtils { * @param context 上下文 */ @foregroundCheck() - static showDownloadFailDialog(context: common.Context, otaStatus: OtaStatus, eventId?: update.EventId): void { + static showDownloadFailDialog(context: common.Context, otaStatus?: OtaStatus, eventId?: update.EventId): void { LogUtils.log('DialogUtils', 'showDownloadFailDialog'); - DialogHelper.displayDownloadFailDialog(retryCheckAction); + DialogHelper.displayDownloadFailDialog(); } /** @@ -156,7 +142,7 @@ export class DialogUtils { static showUpgradeNotEnoughSpaceDialog(context: common.Context, otaStatus: OtaStatus, eventId?: update.EventId): void { LogUtils.log('DialogUtils', 'showUpgradeNotEnoughSpaceDialog'); - DialogHelper.displayNotEnoughSpaceDialog(retryUpgradeAction); + DialogHelper.displayUpgradeNotEnoughSpaceDialog(); } /** @@ -177,8 +163,8 @@ export class DialogUtils { * @param context 上下文 */ @foregroundCheck() - static showUpgradeFailDialog(context: common.Context, otaStatus: OtaStatus, eventId?: update.EventId): void { + static showUpgradeFailDialog(context: common.Context, otaStatus?: OtaStatus, eventId?: update.EventId): void { LogUtils.log('DialogUtils', 'showUpgradeFailDialog'); - DialogHelper.displayUpgradeFailDialog(retryCheckAction); + DialogHelper.displayUpgradeFailDialog(); } } \ No newline at end of file diff --git a/feature/ota/src/main/ets/dialog/MessageDialogBuilder.ets b/feature/ota/src/main/ets/dialog/MessageDialogBuilder.ets index 4b659e7..5cc3df3 100644 --- a/feature/ota/src/main/ets/dialog/MessageDialogBuilder.ets +++ b/feature/ota/src/main/ets/dialog/MessageDialogBuilder.ets @@ -23,7 +23,7 @@ export struct MessageDialogBuilder { /** * 内容 */ - message: ResourceStr; + message: ResourceStr = ''; /** * 控制器 diff --git a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets index 6c9661e..56c2dfd 100644 --- a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets +++ b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets @@ -17,9 +17,10 @@ import type common from '@ohos.app.ability.common'; import update from '@ohos.update'; import type Want from '@ohos.app.ability.Want'; import { ErrorCode } from '@ohos/common/src/main/ets/const/update_const'; -import type { OtaStatus, UpgradeData, } from '@ohos/common/src/main/ets/const/update_const'; +import type { BusinessError, OtaStatus, UpgradeData, CustomEventInfo } + from '@ohos/common/src/main/ets/const/update_const'; import { UpdateState, UpgradeCallResult, } from '@ohos/common/src/main/ets/const/update_const'; -import type { Message } from '@ohos/common/src/main/ets/manager/UpdateManager'; +import { Message } from '@ohos/common/src/main/ets/manager/UpdateManager'; import { UpdateManager, MessageQueue, @@ -31,6 +32,7 @@ import type { BaseState } from '../manager/StateManager'; import { StateManager } from '../manager/StateManager'; import { NotificationManager } from '../notify/NotificationManager'; import VersionUtils from '../util/VersionUtils'; +import { CommonUtils } from '@ohos/common/src/main/ets/util/CommonUtils'; import { UpgradeAdapter } from '../UpgradeAdapter'; import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; @@ -41,13 +43,14 @@ import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; */ export class OtaUpdateManager { private static readonly KEY = 'EventInfo'; - private _updateStatus: number; - private _downloadProgress: number; - private lastStatus: number; - private stateObj: BaseState; + private _updateStatus: number | null = null; + private _downloadProgress?: number; + private lastStatus?: number; + private stateObj?: BaseState; private otaStatusHolder: OtaStatusHolder; private updateManager: UpdateManager; private messageQueue: MessageQueue; + private otaUpdaterCallback: update.UpgradeTaskCallback; /** * 单例--升级管理类对象实例 @@ -62,10 +65,21 @@ export class OtaUpdateManager { this.log('OtaUpdateManager init.'); globalThis.otaUpdateManager = this; this.otaStatusHolder = new OtaStatusHolder(); - this.messageQueue = new MessageQueue(this.handleMessage.bind(this)); + this.messageQueue = new MessageQueue((message: Message): Promise => this.handleMessage(message)); + this.updateManager = new UpdateMananger(update.BusinessSubType.FIRMWARE); + this.otaUpdaterCallback = (eventInfo: update.EventInfo): void => { + this.notifyUpdateStatusRemote(eventInfo); + }; + } - this.updateManager = new UpdateManager(); - this.updateManager.bind(update.BusinessSubType.FIRMWARE, this.notifyUpdateStatusRemote.bind(this)); + off(): void { + this.log('otaUpdater off'); + this.updateManager.off(this.otaUpdaterCallback); + } + + on(): void { + this.log('otaUpdater on'); + this.updateManager.on(this.otaUpdaterCallback); } /** @@ -77,7 +91,7 @@ export class OtaUpdateManager { return new Promise((resolve, reject) => { this.updateManager.getOtaStatus().then((result: UpgradeData) => { if (result?.callResult === UpgradeCallResult.OK) { - this.refreshState(result?.data); + this.refreshState(result?.data as otaStatus); } resolve(result); }); @@ -151,11 +165,11 @@ export class OtaUpdateManager { return new Promise((resolve, reject) => { this.updateManager.upgrade(versionDigest, order).then(()=> { resolve(); - }).catch(err => { + }).catch((err: BusinessError) => { let status: OtaStatus = { status: order === update.Order.APPLY ? UpdateState.INSTALL_SUCCESS : UpdateState.DOWNLOAD_SUCCESS, percent: 100, - endReason: err?.data?.[0]?.errorCode?.toString() || ErrorCode.DEFAULT_ERROR, + endReason: err?.data?.[0]?.errorCode?.toString() || ErrorCode.DEFAULT_ERROR as string, }; this.notifyUpdateStatus(status, globalThis.abilityContext); this.logError('upgrade err:' + JSON.stringify(err)); @@ -174,7 +188,7 @@ export class OtaUpdateManager { let versionDigest: string = await VersionUtils.getNewVersionDigest(); this.setDownloadProgress(0); this.updateManager.download(versionDigest, downloadNetwork, update.Order.DOWNLOAD) - .catch(err => { + .catch((err: BusinessError) => { let status: OtaStatus = { status: UpdateState.CHECK_SUCCESS, percent: 0, @@ -192,7 +206,7 @@ export class OtaUpdateManager { this.setUpdateState(UpdateState.DOWNLOADING); this.updateManager.resumeDownload(versionDigest, update.NetType.WIFI).then(result => { this.log('resumeDownload result:' + JSON.stringify(result)); - }).catch(err => { + }).catch((err: BusinessError) => { let status: OtaStatus = { status: UpdateState.DOWNLOAD_PAUSE, percent: this.getDownloadProgress(), @@ -226,7 +240,7 @@ export class OtaUpdateManager { * * @return 升级状态 */ - getUpdateState(): number { + getUpdateState(): number | null { return this._updateStatus; } @@ -235,7 +249,7 @@ export class OtaUpdateManager { * * @param value 状态 */ - setUpdateState(value): void { + setUpdateState(value: number): void { if (this._updateStatus !== Number(value) && value !== undefined && value !== null) { this._updateStatus = Number(value); AppStorage.Set('updateStatus', this._updateStatus); @@ -247,7 +261,7 @@ export class OtaUpdateManager { * * @return 升级进度 */ - getDownloadProgress(): number { + getDownloadProgress(): number | undefined { return this._downloadProgress; } @@ -256,7 +270,7 @@ export class OtaUpdateManager { * * @param value 进度 */ - setDownloadProgress(value): void { + setDownloadProgress(value: number): void { if (this._downloadProgress !== value && value !== undefined && value !== null) { this._downloadProgress = value; AppStorage.Set('downloadProgress', this._downloadProgress); @@ -301,13 +315,14 @@ export class OtaUpdateManager { this.messageQueue.execute(message); } - private async handleMessage(context: common.Context, eventInfo: update.EventInfo): Promise { + private async handleMessage(message: Message): Promise { + let eventInfo: CustomEventInfo = message.eventInfo as CustomEventInfo; let otaStatus: OtaStatus = this.getFormattedOtaStatus(eventInfo); if (this.isTerminalState(otaStatus)) { globalThis.lastVersionName = await VersionUtils.obtainNewVersionName(eventInfo?.taskBody); } let versionDigest: string = eventInfo?.taskBody?.versionDigestInfo?.versionDigest ?? ''; - await this.notifyUpdateStatus(otaStatus, context, versionDigest, eventInfo?.eventId); + await this.notifyUpdateStatus(otaStatus, message.context, versionDigest, eventInfo?.eventId); } private async notifyUpdateStatus(otaStatus: OtaStatus, context: common.Context, verDigest?: string, @@ -327,6 +342,9 @@ export class OtaUpdateManager { } private isTerminalState(otaStatus: OtaStatus): boolean { + if (CommonUtils.isEmpty(otaStatus)) { + return false; + } let status = otaStatus?.status ?? UpdateState.INIT; if (status === UpdateState.INIT || status === UpdateState.DOWNLOAD_FAILED || status === UpdateState.INSTALL_FAILED || status === UpdateState.UPGRADE_SUCCESS || @@ -369,11 +387,11 @@ export class OtaUpdateManager { public async handleWant(want: Want, context: common.Context): Promise { let action: string = want?.action ?? ''; if (await NotificationManager.handleAction(action, context)) { - this.log('handleWant:' + FormatUtils.stringify(want)); + this.log('handleWant:' + CommonUtils.stringify(want)); return; } let eventInfo = this.wantParser(want); - this.log('handleWant: eventInfo is ' + FormatUtils.stringify(eventInfo)); + this.log('handleWant: eventInfo is ' + CommonUtils.stringify(eventInfo)); if (!eventInfo?.eventId) { this.log('eventInfo?.eventId is null'); return; @@ -387,13 +405,13 @@ export class OtaUpdateManager { * @return 是否升级终止 */ public isTerminal(): boolean { - return this.isTerminalState(this.stateObj?.otaStatus); + return this.isTerminalState(this.stateObj?.otaStatus as OtaStatus); } private wantParser(want: Want): update.EventInfo { let eventInfo: update.EventInfo = want?.parameters?.[OtaUpdateManager.KEY] as update.EventInfo; if (typeof eventInfo === 'string') { - eventInfo = FormatUtils.parseJson(eventInfo); + eventInfo = CommonUtils.parseJson(eventInfo); } return eventInfo; } @@ -418,7 +436,7 @@ export class OtaUpdateManager { let otaStatus: OtaStatus = { status: eventInfo.taskBody?.status, percent: eventInfo.taskBody?.progress, - endReason: !endReason || endReason === '0' ? null : endReason, + endReason: !endReason || endReason === '0' ? '' : endReason, }; if (!otaStatus.status) { otaStatus.status = this.getUpdateStateFromEventId(eventInfo.eventId); @@ -426,8 +444,8 @@ export class OtaUpdateManager { return otaStatus; } - private getUpdateStateFromEventId(eventId: update.EventId): UpdateState { - let status: UpdateState; + private getUpdateStateFromEventId(eventId: update.EventId): UpdateState | undefined { + let status: UpdateState | undefined = undefined; switch (eventId) { case update.EventId.EVENT_TASK_RECEIVE: status = UpdateState.CHECK_SUCCESS; diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index 2bd43f3..b2fdd93 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -78,7 +78,7 @@ export namespace StateManager { * @param status 状态 * @return 按钮点击行为 */ - export function getButtonClickAction(status: number): UpdateAction { + export function getButtonClickAction(status: number): UpdateAction | undefined { return OtaUpdateManager.getInstance().getStateObj(status).buttonClickAction; } @@ -89,8 +89,8 @@ export namespace StateManager { * @return 实例对象 */ export function createInstance(status: OtaStatus | number): BaseState { - let state: number = (typeof status === 'number') ? status : status?.status; - let stateObject: BaseState = null; + let state: number = (typeof status === 'number') ? status : Number(status?.status); + let stateObject: BaseState | null = null; switch (state) { case UpdateState.DOWNLOAD_CANCEL: // fall through case UpdateState.CHECK_SUCCESS: @@ -108,9 +108,6 @@ export namespace StateManager { case UpdateState.INSTALLING: stateObject = new Installing(); break; - case UpdateState.INSTALL_PAUSE: - stateObject = new InstallPaused(); - break; case UpdateState.INSTALL_FAILED: stateObject = new InstallFailed(); break; @@ -196,7 +193,7 @@ export class BaseState { /** * 状态对象 */ - public otaStatus: OtaStatus; + public otaStatus?: OtaStatus; /** * 进度 @@ -231,7 +228,7 @@ export class BaseState { /** * 按钮对应的升级行为 */ - public buttonClickAction: UpdateAction; + public buttonClickAction?: UpdateAction; /** * 数据刷新 @@ -240,8 +237,8 @@ export class BaseState { */ refresh(otaStatus: OtaStatus): void { this.otaStatus = otaStatus; - if (this.otaStatus?.percent) { - this.percent = otaStatus?.percent; + if (this.otaStatus?.percent !== undefined && this.otaStatus?.percent !== null) { + this.percent = otaStatus?.percent as number; } } @@ -286,7 +283,7 @@ export class CheckSuccess extends BaseState { async notify(context?: common.Context, eventId?: update.EventId): Promise { if (this.otaStatus?.endReason) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); - switch (this.otaStatus.endReason) { + switch (Number(this.otaStatus.endReason)) { case ErrorCode.NETWORK_ERROR: let message = await context.resourceManager.getString($r('app.string.network_err_toast').id); ToastUtils.showToast(message); @@ -330,35 +327,6 @@ export class Downloading extends BaseState { } } -export class InstallPaused 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); - } - - } -} - /** * 状态--下载暂停 * @@ -382,7 +350,7 @@ export class DownloadPause extends BaseState { } if (this.otaStatus?.endReason) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); - switch (this.otaStatus?.endReason) { + switch (Number(this.otaStatus?.endReason)) { case ErrorCode.NETWORK_ERROR: if (eventId == update.EventId.EVENT_DOWNLOAD_PAUSE) { DialogUtils.showDownloadNoNetworkDialog(context, this.otaStatus, eventId); @@ -423,7 +391,7 @@ export class DownloadFailed extends BaseState { async notify(context?: common.Context, eventId?: update.EventId): Promise { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); - switch (this.otaStatus.endReason) { + switch (Number(this.otaStatus?.endReason)) { case ErrorCode.VERIFY_PACKAGE_FAIL: DialogUtils.showVerifyFailDialog(context, this.otaStatus, eventId); break; @@ -452,7 +420,7 @@ export class DownloadSuccess extends BaseState { this.buttonClickAction = UpdateAction.INSTALL; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { let isABInstall = await VersionUtils.isABInstall(); LogUtils.info('StateManager:', 'notify ab flag ' + isABInstall + ',eventId:' + eventId); if (eventId == update.EventId.EVENT_DOWNLOAD_SUCCESS && isABInstall) { @@ -470,7 +438,7 @@ export class DownloadSuccess extends BaseState { } if (this.otaStatus?.endReason) { - switch (this.otaStatus.endReason) { + switch (Number(this.otaStatus.endReason)) { case ErrorCode.NO_ENOUGH_MEMORY: DialogUtils.showUpgradeNotEnoughSpaceDialog(context, this.otaStatus, eventId); break; @@ -512,7 +480,7 @@ export class Installing extends BaseState { } } - async notify(context?: common.Context): Promise { + async notify(context: common.Context): Promise { if (this.percent == 100) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); return; @@ -542,7 +510,7 @@ export class InstallSuccess extends BaseState { this.buttonClickAction = UpdateAction.REBOOT; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { if (eventId == update.EventId.EVENT_APPLY_WAIT) { LogUtils.info('StateManager', 'ab install complete to count down'); if (!VersionUtils.isInNewVersionPage()) { @@ -569,14 +537,14 @@ export class InstallFailed extends BaseState { this.isButtonClickable = false; } - async notify(context?: common.Context): Promise { + async notify(context: common.Context): Promise { AppStorage.Set('installStatusRefresh', JSON.stringify(this.otaStatus)); await UpgradeAdapter.getInstance().getNotifyInstance()?.isServiceReady(); await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); if (VersionUtils.isInNewVersionPage()) { DialogUtils.showUpgradeFailDialog(context, this.otaStatus); } else { - let versionName = globalThis.lastVersionName; + let versionName: string = globalThis.lastVersionName as string; LogUtils.log('StateManager', 'InstallFailed versionName is ' + versionName); await UpgradeAdapter.getInstance().getNotifyInstance()?.showUpgradeFailed(versionName, context); } @@ -621,13 +589,13 @@ export class UpgradeSuccess extends BaseState { this.isButtonClickable = false; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { if (eventId == update.EventId.EVENT_UPGRADE_SUCCESS) { LogUtils.info('StateManager', 'Upgrade success'); AppStorage.Set('installStatusRefresh', JSON.stringify(this.otaStatus)); await UpgradeAdapter.getInstance().getNotifyInstance()?.isServiceReady(); await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); - let versionName = globalThis.lastVersionName; + let versionName: string = globalThis.lastVersionName as string; LogUtils.info('StateManager', 'UpgradeSuccess versionName is ' + versionName); await UpgradeAdapter.getInstance().getNotifyInstance()?.showUpgradeSuccess(versionName, context); } else { diff --git a/feature/ota/src/main/ets/notify/NotificationHelper.ets b/feature/ota/src/main/ets/notify/NotificationHelper.ets index cd8cd9f..9a4691a 100644 --- a/feature/ota/src/main/ets/notify/NotificationHelper.ets +++ b/feature/ota/src/main/ets/notify/NotificationHelper.ets @@ -16,7 +16,7 @@ import notification from '@ohos.notificationManager'; import wantAgent from '@ohos.app.ability.wantAgent'; import type common from '@ohos.app.ability.common'; -import { Action, PACKAGE_NAME } from '@ohos/common/src/main/ets/const/update_const'; +import { BusinessError, Action, PACKAGE_NAME } from '@ohos/common/src/main/ets/const/update_const'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { INotify } from '@ohos/common/src/main/ets/manager/UpgradeInterface'; @@ -29,13 +29,13 @@ export class NotificationHelper implements INotify { /** * 跳转信息--跳转到搜包页面 */ - private checkWantAgentInfo = { + private checkWantAgentInfo: wantAgent.WantAgentInfo = { wants: [{ bundleName: PACKAGE_NAME, abilityName: 'ServiceExtAbility', action: Action.NOTIFICATION_CHECK }], - operationType: wantAgent.OperationType.START_ABILITY, + actionType: wantAgent.OperationType.START_ABILITY, requestCode: 0, wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], }; @@ -43,13 +43,13 @@ export class NotificationHelper implements INotify { /** * 跳转信息--下载中拉起界面 */ - private downloadingWantAgentInfo = { + private downloadingWantAgentInfo: wantAgent.WantAgentInfo = { wants: [{ bundleName: PACKAGE_NAME, abilityName: 'ServiceExtAbility', action: Action.NOTIFICATION_DETAIL }], - operationType: wantAgent.OperationType.START_ABILITY, + actionType: wantAgent.OperationType.START_ABILITY, requestCode: 0, wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG], }; @@ -61,10 +61,10 @@ export class NotificationHelper implements INotify { * @param progress 进度 * @param context 上下文 */ - async showDownloading(version, progress, context): Promise { + async showDownloading(version: string, progress: number, context: common.Context): Promise { let templateName: string = 'downloadTemplate'; if (!globalThis.isSupportTemplate) { - globalThis.isSupportTemplate = await notification.isSupportTemplate(templateName).catch(err => { + globalThis.isSupportTemplate = await notification.isSupportTemplate(templateName).catch((err: BusinessError) => { this.logError('showDownloading isSupportTemplate failed because ' + JSON.stringify(err)); return false; }); @@ -73,9 +73,9 @@ export class NotificationHelper implements INotify { this.logError('showDownloading is not supportTemplate'); return; } - var notificationRequest = { + let notificationRequest: notification.NotificationRequest = { content: { - contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + notificationContentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: await context.resourceManager.getString($r('app.string.software_update').id), text: await context.resourceManager.getString($r('app.string.software_download_progress').id) @@ -92,10 +92,12 @@ export class NotificationHelper implements INotify { wantAgent: await wantAgent.getWantAgent(this.downloadingWantAgentInfo), id: 5, label: '111', - slotType: notification.SlotType.SERVICE_INFORMATION, + notificationSlotType: notification.SlotType.SERVICE_INFORMATION, deliveryTime: new Date().getTime() } - await notification.publish(notificationRequest).catch((err) => { + await notification.publish(notificationRequest).then(() => { + this.logInfo(`showDownloading publish promise success.`); + }).catch((err: BusinessError) => { this.logError('showDownloading notification publish failed because ' + JSON.stringify(err)); }); } @@ -107,10 +109,10 @@ export class NotificationHelper implements INotify { * @param progress 进度 * @param context 上下文 */ - async showInstalling(version, progress, context): Promise { + async showInstalling(version: string, progress: number, context: common.Context): Promise { let templateName: string = 'installTemplate'; if (!globalThis.isSupportTemplate) { - globalThis.isSupportTemplate = await notification.isSupportTemplate(templateName).catch(err => { + globalThis.isSupportTemplate = await notification.isSupportTemplate(templateName).catch((err: BusinessError) => { this.logError('showInstalling isSupportTemplate failed because ' + JSON.stringify(err)); return false; }); @@ -119,9 +121,9 @@ export class NotificationHelper implements INotify { this.logError('showInstalling is not supportTemplate'); return; } - var notificationRequest = { + let notificationRequest: notification.NotificationRequest = { content: { - contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + notificationContentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: await context.resourceManager.getString($r('app.string.software_update').id), text: await context.resourceManager.getString($r('app.string.software_install_progress').id) @@ -138,10 +140,10 @@ export class NotificationHelper implements INotify { wantAgent: await wantAgent.getWantAgent(this.downloadingWantAgentInfo), id: 5, label: '111', - slotType: notification.SlotType.SERVICE_INFORMATION, + notificationSlotType: notification.SlotType.SERVICE_INFORMATION, deliveryTime: new Date().getTime() } - await notification.publish(notificationRequest).catch((err) => { + await notification.publish(notificationRequest).catch((err: BusinessError) => { this.logError('showInstalling publish failed because ' + JSON.stringify(err)); }); } @@ -152,9 +154,9 @@ export class NotificationHelper implements INotify { * @param context 实上下文 */ async showUpgradeFailed(versionName: string, context: common.Context): Promise { - let request = { + let request: notification.NotificationRequest = { content: { - contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + notificationContentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: await context.resourceManager.getString($r('app.string.install_fail_message').id), text: versionName @@ -162,11 +164,11 @@ export class NotificationHelper implements INotify { }, wantAgent: await wantAgent.getWantAgent(this.checkWantAgentInfo), id: 3, - slotType: notification.SlotType.SERVICE_INFORMATION + notificationSlotType: notification.SlotType.SERVICE_INFORMATION } await notification.publish(request).then(() => { this.logInfo('showUpgradeFailed publish promise success.'); - }).catch((err) => { + }).catch((err: BusinessError) => { this.logError('showUpgradeFailed publish promise failed because ' + JSON.stringify(err)); }); } @@ -177,9 +179,9 @@ export class NotificationHelper implements INotify { * @param context 实上下文 */ async showUpgradeSuccess(versionName: string, context: common.Context): Promise { - let request = { + let request: notification.NotificationRequest = { content: { - contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + notificationContentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: await context.resourceManager.getString($r('app.string.install_success_message').id), text: versionName @@ -187,11 +189,11 @@ export class NotificationHelper implements INotify { }, wantAgent: await wantAgent.getWantAgent(this.checkWantAgentInfo), id: 4, - slotType: notification.SlotType.SERVICE_INFORMATION + notificationSlotType: notification.SlotType.SERVICE_INFORMATION } await notification.publish(request).then(() => { this.logInfo('showUpgradeSuccess publish promise success.'); - }).catch((err) => { + }).catch((err: BusinessError) => { this.logError('showUpgradeSuccess publish promise failed because ' + JSON.stringify(err)); }); } diff --git a/feature/ota/src/main/ets/notify/NotificationManager.ts b/feature/ota/src/main/ets/notify/NotificationManager.ets similarity index 81% rename from feature/ota/src/main/ets/notify/NotificationManager.ts rename to feature/ota/src/main/ets/notify/NotificationManager.ets index f008773..5530b6e 100644 --- a/feature/ota/src/main/ets/notify/NotificationManager.ts +++ b/feature/ota/src/main/ets/notify/NotificationManager.ets @@ -14,6 +14,7 @@ */ import type common from '@ohos.app.ability.common'; +import { StartOptions } from '@kit.AbilityKit'; import { Action, PACKAGE_NAME, @@ -42,10 +43,10 @@ export class NotificationManager { static async handleAction(action: string, context: common.Context): Promise { switch (action) { case Action.NOTIFICATION_CHECK: - this.handleCheckAction(context); + NotificationManager.handleCheckAction(context); return true; case Action.NOTIFICATION_DETAIL: - await this.handleDetailAction(context); + await NotificationManager.handleDetailAction(context); return true; default: return false; @@ -54,31 +55,31 @@ export class NotificationManager { private static handleCheckAction(context: common.Context): void { LogUtils.log(TAG, 'handleCheckAction'); - this.startAbility('pages/index', context); + NotificationManager.startAbility('pages/index', context); } private static async handleDetailAction(context: common.Context): Promise { LogUtils.log(TAG, 'handleDetailAction'); if (await RouterUtils.isCanToNewVersion()) { - this.startAbility('pages/newVersion', context); + NotificationManager.startAbility('pages/newVersion', context); } else { - this.startAbility('pages/index', context); + NotificationManager.startAbility('pages/index', context); } } public static async startToNewVersion(context: common.Context): Promise { if (await RouterUtils.isCanToNewVersion()) { - this.startAbility('pages/newVersion', context); + NotificationManager.startAbility('pages/newVersion', context); } } private static startAbility(uri: string, context: common.Context): void { - let want = { + let want: Want = { bundleName: PACKAGE_NAME, abilityName: MAIN_ABILITY_NAME, uri: uri }; - let options = { + let options: StartOptions = { windowMode: 0, displayId: 2 }; diff --git a/feature/ota/src/main/ets/util/ChangelogParseUtils.ets b/feature/ota/src/main/ets/util/ChangelogParseUtils.ets index d63d552..55c8f1f 100644 --- a/feature/ota/src/main/ets/util/ChangelogParseUtils.ets +++ b/feature/ota/src/main/ets/util/ChangelogParseUtils.ets @@ -16,6 +16,35 @@ import convertXml from '@ohos.convertxml'; import type { Features, Language, Feature, Changelog, Icon } from '@ohos/common/src/main/ets/const/update_const'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; +import { CommonUtils } from '@ohos/common/src/main/ets/util/CommonUtils'; + +/** + * xml 元素 + * + * @since 2025-06-09 + */ +interface XmlElement { + _elements?: XmlElement[]; + _name?: string; + _type?: string; + _text?: string; + _attributes?: XmlAttributes +} + +/** + * xml 元素属性 + * + * @since 2025-06-09 + */ +interface XmlAttributes { + name?: string; + id?:string; + pkg?: string; + res?: string; + module?: string; + type?: string; + title?: string; +} let conv = new convertXml.ConvertXML(); @@ -48,22 +77,22 @@ namespace ChangelogParseUtils { * @param res 待解析的string * @param callback 解析结果回调 */ - export function parseXml(res: string, callback: (data: Changelog) => void): void { + export function parseXml(res: string, callback: (data?: Changelog) => void): void { logInfo('read file parse start'); changelog = { language: new Map() }; if (!res) { logError('res is null!'); - callback(null); + callback(); return; } - let xmlResult: Object = conv.convert(res, options); + let xmlResult: XmlElement = conv.convert(res, options) as XmlElement; if (!xmlResult || !xmlResult['_elements'] || xmlResult['_elements'].length <= 0) { logError('xmlResult is null! ' + JSON.stringify(xmlResult)); callback(null); return; } - let root = xmlResult['_elements'][0]; - if (!root || !root['_elements'] || root['_elements'].length <= 0) { + let root: XmlElement | undefined = xmlResult._elements[0]; + if (!root || !root._elements || root._elements.length <= 0) { logError('root is null! ' + JSON.stringify(root)); callback(null); return; @@ -73,44 +102,47 @@ namespace ChangelogParseUtils { callback(changelog); } - function parseRoot(root: any): void { + function parseRoot(root: XmlElement): void { // 倒序解析,先解析Icon - let icons = {}; - logInfo('root length ' + root['_elements'].length); - for (let index = root['_elements'].length; index > 0; index--) { - let element = root['_elements'][index - 1]; + let icons: Map = new Map(); + if (root?.elements === undefined) { + return; + } + logInfo('root length ' + root?._elements?.length); + for (let index = root?._elements?.length; index > 0; index--) { + let element = root?._elements[index - 1]; if (!element) { logError('element is null! ' + JSON.stringify(element)); continue; } - if (element['_type'] === 'element' && element['_name'] === 'default-language') { - let attribute = element['_attributes']['name']; + if (element._type === 'element' && element._name === 'default-language') { + let attribute = element._attributes?.name; logInfo('default-language :' + attribute); changelog.defLanguage = attribute; } - if (element['_type'] === 'element' && element['_name'] === 'displayType') { - let attribute = element['_elements']?.[0]?.['_text']; + if (element._type === 'element' && element._name === 'displayType') { + let attribute = Number(element._elements?.[0]?._text); logInfo('displayType :' + attribute); changelog.displayType = attribute; } - if (element['_type'] === 'element' && element['_name'] === 'icons') { - let iconsElement = element['_elements']; + if (element._type === 'element' && element._name === 'icons') { + let iconsElement = element._elements ?? []; parseIcons(iconsElement, icons); } parseLanguage(element, icons); } } - function parseLanguage(element: any, icons: Object): void { + function parseLanguage(element: XmlElement, icons: Map): void { let language: Language = { featuresArray: [] }; - if (element['_type'] === 'element' && element['_name'] === 'language') { + if (element._type === 'element' && element._name === 'language') { let attribute: string; - if (!element['_attributes']) { + if (!element._attributes) { logError('language is null :' + JSON.stringify(element['_attributes'])); return; } - attribute = element['_attributes']['name']; - let languageElement = element['_elements']; + attribute = element._attributes.name ?? ''; + let languageElement = element._elements; language.language = attribute; changelog.language.set(language.language, language); @@ -122,7 +154,11 @@ namespace ChangelogParseUtils { } } - function parseIcons(iconsElement: any, icons: Object): void { + function parseIcons(iconsElement: XmlElement[], icons: Map): void { + if (CommonUtils.IsEmpty(iconsElement)) { + logError(`iconsElement is null${JSON.stringify(iconElement)}`); + return; + } let icon: Icon; for (let index = 0; index < iconsElement.length; index++) { let iconElement = iconsElement[index]; @@ -130,18 +166,20 @@ namespace ChangelogParseUtils { logError('iconElement is null :' + JSON.stringify(iconElement)); continue; } - if (iconElement['_type'] === 'element' && iconElement['_name'] === 'icon') { + if (iconElement._type === 'element' && iconElement._name === 'icon') { icon = { - id: iconElement['_attributes']['id'], - pkg: iconElement['_attributes']['pkg'], - res: iconElement['_attributes']['res'], + id: iconElement?._attributes?.id, + pkg: iconElement?._attributes?.pkg, + res: iconElement?._attributes?.res, }; - icons[icon.id] = icon; + if (icon?.id !== null && icon.id !== undefined) { + icons.set(icon?.id, icon); + } } } } - function parseFeatures(languageElement: any, language: Language, icons: Object): void { + function parseFeatures(languageElement: XmlElement[], language: Language, icons: Map): void { let features: Features; for (let index = 0; index < languageElement.length; index++) { let featuresElement = languageElement[index]; @@ -150,19 +188,21 @@ namespace ChangelogParseUtils { continue; } - if (featuresElement['_type'] === 'element' && featuresElement['_name'] === 'features') { - let moduleString = featuresElement['_attributes']['module']; - let typeString = featuresElement['_attributes']['type']; - let id = featuresElement['_attributes']['id']; - let featureElement = featuresElement['_elements']; + if (featuresElement._type === 'element' && featuresElement._name === 'features') { + let moduleString = featuresElement._attributes?.module; + let typeString = featuresElement._attributes?.type; + let id = featuresElement?._attributes.id; + let featureElement = featuresElement._elements; let featureList: Feature[] = []; features = { title: moduleString, id: id, featureModuleType: typeString, featureList: featureList, - icon: icons[id], }; + if (id !== null && id !== undefined) { + features.icon = icons.get(id) + } language.featuresArray.push(features); if (!featureElement || featureElement.length <= 0) { @@ -174,11 +214,11 @@ namespace ChangelogParseUtils { } } - function parseFeature(featureElement: any, featureList: Array): void { - let feature: Feature; + function parseFeature(featureElement: XmlElement[], featureList: Array): void { + let feature: Feature | null = null; for (let index = 0; index < featureElement.length; index++) { let featureItem = featureElement[index]; - if (featureItem['_type'] !== 'element' || featureItem['_name'] !== 'feature') { + if (featureItem._type !== 'element' || featureItem._name !== 'feature') { continue; } if (!featureItem) { @@ -186,13 +226,13 @@ namespace ChangelogParseUtils { continue; } - let title: string; - if (featureItem['_attributes']) { - title = featureItem['_attributes']['title']; + let title: string | undefined; + if (featureItem._attributes) { + title = featureItem._attributes.title; } - let content: string; - if (featureItem['_elements']) { - content = featureItem['_elements'][0]['_text']; + let content: string | undefined; + if (featureItem._elements) { + content = featureItem._elements[0]._text as string; } if (title) { feature = { subTitle: title, contents: [] }; diff --git a/feature/ota/src/main/ets/util/RouterUtils.ts b/feature/ota/src/main/ets/util/RouterUtils.ets similarity index 96% rename from feature/ota/src/main/ets/util/RouterUtils.ts rename to feature/ota/src/main/ets/util/RouterUtils.ets index d622959..2e48445 100644 --- a/feature/ota/src/main/ets/util/RouterUtils.ts +++ b/feature/ota/src/main/ets/util/RouterUtils.ets @@ -82,7 +82,8 @@ namespace RouterUtils { if (upgradeData.data?.status === UpdateState.UPGRADING) { resolve(false); } else { - let isAllow: boolean = StateManager.isAllowExecute(upgradeData.data?.status, UpdateAction.SHOW_NEW_VERSION); + let isAllow: boolean = StateManager.isAllowExecute(upgradeData.data?.status as number, + UpdateAction.SHOW_NEW_VERSION); resolve(isAllow); } } else { diff --git a/feature/ota/src/main/ets/util/ToastUtils.ts b/feature/ota/src/main/ets/util/ToastUtils.ets similarity index 100% rename from feature/ota/src/main/ets/util/ToastUtils.ts rename to feature/ota/src/main/ets/util/ToastUtils.ets diff --git a/feature/ota/src/main/ets/util/VersionUtils.ets b/feature/ota/src/main/ets/util/VersionUtils.ets index 9284da3..6e6bb20 100644 --- a/feature/ota/src/main/ets/util/VersionUtils.ets +++ b/feature/ota/src/main/ets/util/VersionUtils.ets @@ -52,7 +52,7 @@ export namespace VersionUtils { * @return 新版本名称 */ export async function obtainNewVersionName(info: update.NewVersionInfo | update.TaskBody): Promise { - let component: update.VersionComponent = sortComponents(info?.versionComponents)?.[0]; + let component: update.VersionComponent | undefined = sortComponents(info?.versionComponents)?.[0]; return component?.displayVersion ?? ''; } @@ -80,7 +80,7 @@ export namespace VersionUtils { * @param components 升级包集合 * @return 升级包集合 */ - export function sortComponents(components: Array): Array { + export function sortComponents(components: Array): Array | null { if (components) { return components.sort((component: update.VersionComponent, nextComponent: update.VersionComponent) => { return component.componentType - nextComponent.componentType; @@ -118,13 +118,14 @@ export namespace VersionUtils { * @return 是否是AB升级 */ export async function isABInstall(): Promise { - let newVersionInfo = globalThis.cachedNewVersionInfo || await OtaUpdateManager.getInstance().getNewVersion() + let newVersionInfo: update.NewVersionInfo = globalThis.cachedNewVersionInfo || + await OtaUpdateManager.getInstance().getNewVersion() .then(upgradeData => { - this.log(`isABInstall upgradeData: ${upgradeData}`); + LogUtils.info(TAG, `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) => { + let components: update.VersionComponent[] | null = VersionUtils.sortComponents(newVersionInfo?.versionComponents); + let component: update.VersionComponent | undefined = components?.filter((component: update.VersionComponent) => { return component.componentType == update.ComponentType.OTA; })?.[0]; return component?.effectiveMode === update.EffectiveMode.LIVE_AND_COLD; diff --git a/feature/ota/src/main/resources/base/element/string.json b/feature/ota/src/main/resources/base/element/string.json index 1ff53f7..78940f0 100644 --- a/feature/ota/src/main/resources/base/element/string.json +++ b/feature/ota/src/main/resources/base/element/string.json @@ -12,10 +12,6 @@ "name":"btn_upgrade", "value":"Install" }, - { - "name": "btn_pause", - "value": "pause" - }, { "name":"title_new_version", "value":"New version" @@ -144,14 +140,6 @@ "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 78814df..2a49048 100644 --- a/feature/ota/src/main/resources/zh_CN/element/string.json +++ b/feature/ota/src/main/resources/zh_CN/element/string.json @@ -12,10 +12,6 @@ "name":"btn_upgrade", "value":"安装" }, - { - "name": "btn_pause", - "value": "暂停" - }, { "name":"title_new_version", "value":"新版本" @@ -144,14 +140,6 @@ "name":"install_success_message", "value":"新版本安装成功" }, - { - "name":"install_pause_message", - "value":"安装暂停,请重试" - }, - { - "name":"install_pause", - "value":"安装暂停" - }, { "name":"install_fail_message", "value":"新版本安装失败" diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000..a2e9109 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,10 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. Do NOT EDIT THIS FILE DIRECTLY.", + "specifiers": {}, + "packages": {} +} \ No newline at end of file diff --git a/package.json b/oh-package.json5 similarity index 76% rename from package.json rename to oh-package.json5 index 0ea372a..ac0d0e2 100644 --- a/package.json +++ b/oh-package.json5 @@ -1,4 +1,5 @@ { + "modelVersion": "5.1.0", "license": "ISC", "devDependencies": {}, "author": "", @@ -16,9 +17,7 @@ }, "version": "1.0.0", "dependencies": { - "@ohos/hvigor": "1.4.0", - "@ohos/hvigor-ohos-plugin": "1.4.0", - "hypium": "^1.0.0", - "@ohos/hypium": "1.0.3" + //"hypium": "^1.0.0", + //"@ohos/hypium": "1.0.3" } } diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 7069b0d..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1094 +0,0 @@ -{ - "name": "updateapp", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/hos-sdkmanager-common": { - "version": "2.1.6", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hos-sdkmanager-common/-/@ohos/hos-sdkmanager-common-2.1.6.tgz", - "integrity": "sha512-DAT3YbqBE5/6lEOPTQA4pyNt5Wv790AlXcE5iIAofb47uXKmXf3EYL7UBoBRI0U8gJ9qnD/wNuW0vwMrlK8rDw==", - "requires": { - "@ohos/sdkmanager-common": "2.3.4" - } - }, - "@ohos/hvigor": { - "version": "1.4.0", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor/-/@ohos/hvigor-1.4.0.tgz", - "integrity": "sha512-UNWl/KYWaRLmcyXN3tJh0XpmGswjVhSZ08BCukpTrjOSgU335L3PHI6yZJ6PuXxkAxMKgt46IOi4wVdFo8NAPA==", - "requires": { - "@ohos/hvigor-base": "1.4.0", - "fs-extra": "10.0.1", - "interpret": "1.4.0", - "liftoff": "4.0.0", - "mute-stdout": "1.0.0", - "pretty-hrtime": "1.0.0", - "typescript": "4.7.4", - "v8flags": "3.2.0", - "yargs": "17.5.1" - } - }, - "@ohos/hvigor-base": { - "version": "1.4.0", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.4.0.tgz", - "integrity": "sha512-67VK4Of6HgWMDdfa4eMb0MDcDAasctDpK6Akvttwe9U+aV5HSsRJuFS1f3cNGs5+shKyApvj8+AV7VqjzqHsVA==", - "requires": { - "fs-extra": "10.0.1", - "iconv-lite": "0.6.3", - "json5": "2.2.3", - "lodash": "4.17.21", - "log4js": "6.4.1", - "once": "1.4.0", - "pretty-hrtime": "1.0.0" - } - }, - "@ohos/hvigor-ohos-plugin": { - "version": "1.4.0", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.4.0.tgz", - "integrity": "sha512-fVGPFfjzLitY8d19kPSuMiGdw2KsZPTnaquTq910g8X0WCwYCR+N25m1LmS44H/48/mV1/ciiJusivPn3EvLJw==", - "requires": { - "@ohos/hos-sdkmanager-common": "2.1.6", - "@ohos/sdkmanager-common": "2.3.4", - "adm-zip": "0.5.9", - "ajv": "8.10.0", - "deasync": "0.1.28", - "execa": "5.1.1", - "fast-xml-parser": "4.0.3", - "fs-extra": "10.0.1", - "glob": "7.2.0", - "iconv-lite": "0.6.3", - "json5": "2.2.3", - "lodash": "4.17.21", - "pretty-hrtime": "1.0.3", - "resolve-package-path": "4.0.3" - }, - "dependencies": { - "pretty-hrtime": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==" - } - } - }, - "@ohos/hypium": { - "version": "1.0.3", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hypium/-/@ohos/hypium-1.0.3.tgz", - "integrity": "sha512-QKh8ngJk1ySbAiKpSTLP5EJIbT8Oja1zV3zwgLD7U9+KX7w2gjNIk3qoP+d13CwpEfaSR3Lxt3exlQLwWSFx3g==" - }, - "@ohos/sdkmanager-common": { - "version": "2.3.4", - "resolved": "https://repo.harmonyos.com/npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-2.3.4.tgz", - "integrity": "sha512-3WATGJS2lO1EV7F7KzfHCdYwJzr5n+vdrRD65ahHHXptjko1UneBwvY1WEpxSJShQQc4lwKyBK7+6UOsc+NA/w==", - "requires": { - "axios": "0.24.0", - "jszip": "^3.7.0" - } - }, - "adm-zip": { - "version": "0.5.9", - "resolved": "https://repo.huaweicloud.com/repository/npm/adm-zip/-/adm-zip-0.5.9.tgz", - "integrity": "sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg==" - }, - "ajv": { - "version": "8.10.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "array-each": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==" - }, - "array-slice": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-slice/-/array-slice-1.1.0.tgz", - "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" - }, - "axios": { - "version": "0.24.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "requires": { - "follow-redirects": "^1.14.4" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "bindings": { - "version": "1.5.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" - }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "date-format": { - "version": "4.0.14", - "resolved": "https://repo.huaweicloud.com/repository/npm/date-format/-/date-format-4.0.14.tgz", - "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==" - }, - "deasync": { - "version": "0.1.28", - "resolved": "https://repo.huaweicloud.com/repository/npm/deasync/-/deasync-0.1.28.tgz", - "integrity": "sha512-QqLF6inIDwiATrfROIyQtwOQxjZuek13WRYZ7donU5wJPLoP67MnYxA6QtqdvdBy2mMqv5m3UefBVdJjvevOYg==", - "requires": { - "bindings": "^1.5.0", - "node-addon-api": "^1.7.1" - } - }, - "debug": { - "version": "4.3.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==" - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" - }, - "execa": { - "version": "5.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "requires": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - } - }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "fast-xml-parser": { - "version": "4.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/fast-xml-parser/-/fast-xml-parser-4.0.3.tgz", - "integrity": "sha512-xhQbg3a/EYNHwK0cxIG1nZmVkHX/0tWihamn5pU4Mhd9KEVE2ga8ZJiqEUgB2sApElvAATOdMTLjgqIpvYDUkQ==", - "requires": { - "strnum": "^1.0.5" - } - }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "findup-sync": { - "version": "5.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/findup-sync/-/findup-sync-5.0.0.tgz", - "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.3", - "micromatch": "^4.0.4", - "resolve-dir": "^1.0.1" - } - }, - "fined": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fined/-/fined-2.0.0.tgz", - "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", - "requires": { - "expand-tilde": "^2.0.2", - "is-plain-object": "^5.0.0", - "object.defaults": "^1.1.0", - "object.pick": "^1.3.0", - "parse-filepath": "^1.0.2" - } - }, - "flagged-respawn": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", - "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" - }, - "flatted": { - "version": "3.2.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==" - }, - "follow-redirects": { - "version": "1.15.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==" - }, - "for-own": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==", - "requires": { - "for-in": "^1.0.1" - } - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" - }, - "get-stream": { - "version": "6.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" - }, - "glob": { - "version": "7.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, - "graceful-fs": { - "version": "4.2.11", - "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, - "has": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "requires": { - "function-bind": "^1.1.1" - } - }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "human-signals": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" - }, - "hypium": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/hypium/-/hypium-1.0.0.tgz", - "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" - }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, - "immediate": { - "version": "3.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "ini": { - "version": "1.3.8", - "resolved": "https://repo.huaweicloud.com/repository/npm/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" - }, - "interpret": { - "version": "1.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" - }, - "is-absolute": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-absolute/-/is-absolute-1.0.0.tgz", - "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", - "requires": { - "is-relative": "^1.0.0", - "is-windows": "^1.0.1" - } - }, - "is-core-module": { - "version": "2.11.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", - "requires": { - "has": "^1.0.3" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "is-plain-object": { - "version": "5.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" - }, - "is-relative": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-relative/-/is-relative-1.0.0.tgz", - "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", - "requires": { - "is-unc-path": "^1.0.0" - } - }, - "is-stream": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" - }, - "is-unc-path": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", - "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", - "requires": { - "unc-path-regex": "^0.1.2" - } - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==" - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "json5": { - "version": "2.2.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==" - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "jszip": { - "version": "3.10.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/jszip/-/jszip-3.10.1.tgz", - "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", - "requires": { - "lie": "~3.3.0", - "pako": "~1.0.2", - "readable-stream": "~2.3.6", - "setimmediate": "^1.0.5" - } - }, - "kind-of": { - "version": "6.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" - }, - "lie": { - "version": "3.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lie/-/lie-3.3.0.tgz", - "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", - "requires": { - "immediate": "~3.0.5" - } - }, - "liftoff": { - "version": "4.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/liftoff/-/liftoff-4.0.0.tgz", - "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", - "requires": { - "extend": "^3.0.2", - "findup-sync": "^5.0.0", - "fined": "^2.0.0", - "flagged-respawn": "^2.0.0", - "is-plain-object": "^5.0.0", - "object.map": "^1.0.1", - "rechoir": "^0.8.0", - "resolve": "^1.20.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "log4js": { - "version": "6.4.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/log4js/-/log4js-6.4.1.tgz", - "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", - "requires": { - "date-format": "^4.0.3", - "debug": "^4.3.3", - "flatted": "^3.2.4", - "rfdc": "^1.3.0", - "streamroller": "^3.0.2" - } - }, - "make-iterator": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/make-iterator/-/make-iterator-1.0.1.tgz", - "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", - "requires": { - "kind-of": "^6.0.2" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==" - }, - "merge-stream": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "mute-stdout": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", - "integrity": "sha512-MaSQenn0f9oxIjtCufclpV00MuYTiHaXPbdcfPIM+quMqoa8cXywjHHx4LhhIAZlXqPWMdcUpYviajfmHtHRJw==" - }, - "node-addon-api": { - "version": "1.7.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/node-addon-api/-/node-addon-api-1.7.2.tgz", - "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==" - }, - "npm-run-path": { - "version": "4.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "requires": { - "path-key": "^3.0.0" - } - }, - "object.defaults": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==", - "requires": { - "array-each": "^1.0.1", - "array-slice": "^1.0.0", - "for-own": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "object.map": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==", - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", - "requires": { - "isobject": "^3.0.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "pako": { - "version": "1.0.11", - "resolved": "https://repo.huaweicloud.com/repository/npm/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" - }, - "parse-filepath": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", - "requires": { - "is-absolute": "^1.0.0", - "map-cache": "^0.2.0", - "path-root": "^0.1.1" - } - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==" - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "path-root": { - "version": "0.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", - "requires": { - "path-root-regex": "^0.1.0" - } - }, - "path-root-regex": { - "version": "0.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==" - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, - "pretty-hrtime": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", - "integrity": "sha512-CU2l5CYUAptUYq/671ajexQfXuxJFwwg0n243Kdkx8bTjeenedsWgu8TGHPm03vLfNtk3aTXgySKPp3Usykudw==" - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "punycode": { - "version": "2.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==" - }, - "readable-stream": { - "version": "2.3.8", - "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rechoir": { - "version": "0.8.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/rechoir/-/rechoir-0.8.0.tgz", - "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", - "requires": { - "resolve": "^1.20.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" - }, - "resolve": { - "version": "1.22.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", - "requires": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, - "resolve-package-path": { - "version": "4.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", - "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", - "requires": { - "path-root": "^0.1.1" - } - }, - "rfdc": { - "version": "1.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" - }, - "signal-exit": { - "version": "3.0.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" - }, - "streamroller": { - "version": "3.1.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.1.5.tgz", - "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", - "requires": { - "date-format": "^4.0.14", - "debug": "^4.3.4", - "fs-extra": "^8.1.0" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - } - } - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-final-newline": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" - }, - "strnum": { - "version": "1.0.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/strnum/-/strnum-1.0.5.tgz", - "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - }, - "typescript": { - "version": "4.7.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==" - }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==" - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "requires": { - "punycode": "^2.1.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" - }, - "v8flags": { - "version": "3.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/v8flags/-/v8flags-3.2.0.tgz", - "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" - }, - "yargs": { - "version": "17.5.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - } - }, - "yargs-parser": { - "version": "21.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" - } - } -} diff --git a/product/oh/base/oh-package-lock.json5 b/product/oh/base/oh-package-lock.json5 new file mode 100644 index 0000000..9a7c9a9 --- /dev/null +++ b/product/oh/base/oh-package-lock.json5 @@ -0,0 +1,25 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. Do NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/common@../../../common": { + "name": "@ohos/common", + "version": "1.0.0", + "resolved": "../../../common", + "registryType": "local" + }, + "ota@../../../feature/ota": { + "name": "ota", + "version": "1.0.0", + "resolved": "../../../feature/ota", + "registryType": "local", + "dependencies": { + "@ohos/common": "file:../../common" + } + } + } +} \ No newline at end of file diff --git a/product/oh/base/package.json b/product/oh/base/oh-package.json5 similarity index 80% rename from product/oh/base/package.json rename to product/oh/base/oh-package.json5 index 91ab873..20c8669 100644 --- a/product/oh/base/package.json +++ b/product/oh/base/oh-package.json5 @@ -7,10 +7,10 @@ "directoryLevel": "module" }, "description": "updateapp description", - "repository": {}, + "repository": "", "license": "ISC", "dependencies": { "@ohos/common": "file:../../../common", - "@ohos/ota": "file:../../../feature/ota" + "ota": "file:../../../feature/ota" } } diff --git a/product/oh/base/package-lock.json b/product/oh/base/package-lock.json deleted file mode 100644 index aa2a3b5..0000000 --- a/product/oh/base/package-lock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "updateapp", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/common": { - "version": "file:../../../common" - }, - "@ohos/ota": { - "version": "file:../../../feature/ota", - "requires": { - "@ohos/common": "file:../../../common" - }, - "dependencies": { - "@ohos/common": { - "version": "file:../../../common" - } - } - } - } -} diff --git a/product/oh/base/src/main/ets/MainAbility/MainAbility.ts b/product/oh/base/src/main/ets/MainAbility/MainAbility.ets similarity index 95% rename from product/oh/base/src/main/ets/MainAbility/MainAbility.ts rename to product/oh/base/src/main/ets/MainAbility/MainAbility.ets index ca592d6..fec27a1 100644 --- a/product/oh/base/src/main/ets/MainAbility/MainAbility.ts +++ b/product/oh/base/src/main/ets/MainAbility/MainAbility.ets @@ -22,8 +22,8 @@ import type window from '@ohos.window'; import type { Configuration } from '@ohos.app.ability.Configuration'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import type { OtaStatus } from '@ohos/common/src/main/ets/const/update_const'; -import { StateManager } from '@ohos/ota/src/main/ets/manager/StateManager'; -import { NotificationHelper } from '@ohos/ota/src/main/ets/notify/NotificationHelper'; +import { StateManager } from 'ota/src/main/ets/manager/StateManager'; +import { NotificationHelper } from 'ota/src/main/ets/notify/NotificationHelper'; /** * 主Ability @@ -32,7 +32,7 @@ import { NotificationHelper } from '@ohos/ota/src/main/ets/notify/NotificationHe */ export default class MainAbility extends Ability { private static readonly WAITING_PREPARE_TIME = 1500; - private language: string = ''; + private language: string | undefined = ''; onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { this.log('BaseAbility onCreate:' + this.context.config.screenDensity); diff --git a/product/oh/base/src/main/ets/ServiceExtAbility/service.ts b/product/oh/base/src/main/ets/ServiceExtAbility/service.ets similarity index 88% rename from product/oh/base/src/main/ets/ServiceExtAbility/service.ts rename to product/oh/base/src/main/ets/ServiceExtAbility/service.ets index 2171c11..8adb6c7 100644 --- a/product/oh/base/src/main/ets/ServiceExtAbility/service.ts +++ b/product/oh/base/src/main/ets/ServiceExtAbility/service.ets @@ -16,9 +16,10 @@ import Extension from '@ohos.app.ability.ServiceExtensionAbility'; import type Want from '@ohos.app.ability.Want'; import type rpc from '@ohos.rpc'; -import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; -import { OtaUpdateManager } from '@ohos/ota/src/main/ets/manager/OtaUpdateManager'; +import { CommonUtils } from '@ohos/common/src/main/ets/util/CommonUtils'; +import { OtaUpdateManager } from 'ota/src/main/ets/manager/OtaUpdateManager'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; +import type { BusinessError } from '@ohos/common/src/main/ets/const/update_const"; import { ServiceExtStub } from './serviceStub'; /** @@ -36,7 +37,7 @@ export default class ServiceExtAbility extends Extension { private connectTimeoutId: number | null = null; onCreate(want: Want): void { - LogUtils.log(ServiceExtAbility.TAG, 'onCreate:' + FormatUtils.stringify(want)); + LogUtils.log(ServiceExtAbility.TAG, 'onCreate:' + CommonUtils.stringify(want)); globalThis.extensionContext = this.context; // when start ServiceExtAbility ,set context } @@ -70,9 +71,9 @@ export default class ServiceExtAbility extends Extension { }, this.connectTimeout * 1000); let want: Want = { - parameters: FormatUtils.parseJson(message) + parameters: CommonUtils.parseJson(message) }; - LogUtils.log(ServiceExtAbility.TAG, 'onConnect:' + FormatUtils.stringify(want)); + LogUtils.log(ServiceExtAbility.TAG, 'onConnect:' + CommonUtils.stringify(want)); OtaUpdateManager.getInstance().handleWant(want, globalThis.extensionContext); } @@ -93,7 +94,7 @@ export default class ServiceExtAbility extends Extension { const terminateDelayTime = 2000; setTimeout(()=> { LogUtils.info(ServiceExtAbility.TAG, 'stopSelf'); - this.context?.terminateSelf().catch((err) => { + this.context?.terminateSelf().catch((err: BusinessError) => { LogUtils.error(ServiceExtAbility.TAG, 'stopSelf err is ' + JSON.stringify(err)); }); }, terminateDelayTime); diff --git a/product/oh/base/src/main/ets/ServiceExtAbility/serviceStub.ts b/product/oh/base/src/main/ets/ServiceExtAbility/serviceStub.ets similarity index 100% rename from product/oh/base/src/main/ets/ServiceExtAbility/serviceStub.ts rename to product/oh/base/src/main/ets/ServiceExtAbility/serviceStub.ets diff --git a/product/oh/base/src/main/ets/pages/currentVersion.ets b/product/oh/base/src/main/ets/pages/currentVersion.ets index 789461d..3180ad8 100644 --- a/product/oh/base/src/main/ets/pages/currentVersion.ets +++ b/product/oh/base/src/main/ets/pages/currentVersion.ets @@ -18,10 +18,10 @@ import { UpgradeCallResult } from '@ohos/common/src/main/ets/const/update_const' import { TitleBar } from '@ohos/common/src/main/ets/component/TitleBar'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { VersionPageInfo } from '@ohos/common/src/main/ets/manager/UpgradeInterface'; -import { UpgradeAdapter } from '@ohos/ota/src/main/ets/UpgradeAdapter'; -import { ChangelogContent } from '@ohos/ota/src/main/ets/components/ChangelogContent'; -import { OtaUpdateManager } from '@ohos/ota/src/main/ets/manager/OtaUpdateManager'; -import { VersionUtils } from '@ohos/ota/src/main/ets/util/VersionUtils'; +import { UpgradeAdapter } from 'ota/src/main/ets/UpgradeAdapter'; +import { ChangelogContent } from 'ota/src/main/ets/components/ChangelogContent'; +import { OtaUpdateManager } from 'ota/src/main/ets/manager/OtaUpdateManager'; +import { VersionUtils } from 'ota/src/main/ets/util/VersionUtils'; /** * 当前版本页面 @@ -32,7 +32,7 @@ import { VersionUtils } from '@ohos/ota/src/main/ets/util/VersionUtils'; @Component struct CurrentVersion { - @State private versionArray: Array = null; + @State private versionArray: Array | null = null; aboutToAppear() { globalThis.currentVersionThis = this; @@ -50,10 +50,11 @@ struct CurrentVersion { return; } let components: update.VersionComponent[] = VersionUtils.sortComponents( - upgradeData.data?.versionComponents); + upgradeData.data?.versionComponents) ?? []; this.versionArray = components.map((component: update.VersionComponent) => { return UpgradeAdapter.getInstance() - .getPageInstance()?.getCurrentVersionPageInfo(components, componentDescription?.data); + .getPageInstance()?.getCurrentVersionPageInfo(components, componentDescription?.data as + update.ComponentDescription[]); }).filter((versionPageInfo: VersionPageInfo) => { return versionPageInfo != null; }); @@ -104,16 +105,16 @@ struct CurrentVersion { .textOverflow({ overflow: TextOverflow.Ellipsis }) .fontWeight(FontWeight.Medium) .width('100%') - .textAlign(this.versionArray.length > 1 ? TextAlign.Start : TextAlign.Center) + .textAlign((this.versionArray && (this.versionArray.length > 1)) ? TextAlign.Start : TextAlign.Center) .padding({ right: $r('app.float.version_padding'), left: $r('app.float.version_padding'), - bottom: this.versionArray.length > 1 ? $r('app.float.current_version_name_margin_bottom') : + bottom: (this.versionArray && (this.versionArray.length > 1)) ? $r('app.float.current_version_name_margin_bottom') : $r('app.float.current_version_name_margin_bottom_single') }) ChangelogContent({ isCurrentPage: true, - isNeedFold: this.versionArray?.length > 1, + isNeedFold: (this.versionArray && (this.versionArray.length > 1)) ?? false, description: JSON.stringify([pageInfo.changelog]) }) }) diff --git a/product/oh/base/src/main/ets/pages/index.ets b/product/oh/base/src/main/ets/pages/index.ets index e78742b..afc5a6f 100644 --- a/product/oh/base/src/main/ets/pages/index.ets +++ b/product/oh/base/src/main/ets/pages/index.ets @@ -27,11 +27,11 @@ import { HomeCardView } from '@ohos/common/src/main/ets/component/HomeCardView'; import { CheckingDots } from '@ohos/common/src/main/ets/component/CheckingDots'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; -import RouterUtils from '@ohos/ota/src/main/ets/util/RouterUtils'; -import { VersionUtils } from '@ohos/ota/src/main/ets/util/VersionUtils'; -import { OtaUpdateManager } from '@ohos/ota/src/main/ets/manager/OtaUpdateManager'; -import { StateManager, UpdateAction } from '@ohos/ota/src/main/ets/manager/StateManager'; -import ToastUtils from '@ohos/ota/src/main/ets/util/ToastUtils'; +import RouterUtils from 'ota/src/main/ets/util/RouterUtils'; +import { VersionUtils } from 'ota/src/main/ets/util/VersionUtils'; +import { OtaUpdateManager } from 'ota/src/main/ets/manager/OtaUpdateManager'; +import { StateManager, UpdateAction } from 'ota/src/main/ets/manager/StateManager'; +import ToastUtils from 'ota/src/main/ets/util/ToastUtils'; /** * 搜包的状态 @@ -56,20 +56,20 @@ struct Index { @State dotTextPlay: boolean = false; @State newVersionStatus: string = NewVersionStatus.NO_NEW_VERSION; @StorageProp('updateStatus') - private updateStatus: number = AppStorage.Get('updateStatus'); + private updateStatus: number = AppStorage.Get('updateStatus') as number; private displayVersion: string = VersionUtils.getDisplayVersionForIndex(); private videoController: VideoController = new VideoController(); - private initUpdateStatus: number = OtaUpdateManager.getInstance().getUpdateState(); + private initUpdateStatus: number | null | undefined = OtaUpdateManager.getInstance().getUpdateState(); private actionCallBack: Array<() => void> = []; private checkTimes: number= 0; - private checkIntervalId: number; + private checkIntervalId: number | null = null; private checkLoopTimes: number = 0; @State private buttonText: string = ''; /** * 是否已经有搜包结果 */ - private checkEndStatus: NewVersionStatus = null; + private checkEndStatus: NewVersionStatus | null = null; /** * 用来控制视频显示或者隐藏,解决卡顿 @@ -101,7 +101,7 @@ struct Index { return true; } - private notifyNewVersionStatus(newVersionStatus): void { + private notifyNewVersionStatus(newVersionStatu: NewVersionStatus): void { this.log('perform updateNewVersionStatus:' + newVersionStatus); this.checkEndStatus = newVersionStatus; // 延时更新 if (newVersionStatus == NewVersionStatus.CHECKING) { @@ -119,7 +119,7 @@ struct Index { this.checkLoopTimes = 0; this.notifyNewVersionStatus(NewVersionStatus.CHECKING); let upgradeData: UpgradeData = await OtaUpdateManager.getInstance().getOtaStatus(); - let otaStatus: OtaStatus = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; + let otaStatus: OtaStatus | undefined | null = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; this.initUpdateStatus = otaStatus?.status; if (StateManager.isAllowExecute(this.updateStatus, UpdateAction.CHECK_NEW_VERSION)) { this.performCheckNewVersion(); @@ -152,7 +152,7 @@ struct Index { return; } } - let errorCode: ErrorCode = upgradeData.error?.data?.[0]?.errorCode; + let errorCode: ErrorCode | undefined = upgradeData.error?.data?.[0]?.errorCode; if (errorCode == ErrorCode.CHECK_SYSTEM_BUSY) { setTimeout(() => { if (this.checkLoopTimes >= UpdateConstant.CHECKING_RETRY_TIME) { @@ -167,7 +167,7 @@ struct Index { if (errorCode == ErrorCode.CHECK_NETWORK_ERR) { this.actionCallBack.push(async () => { - let message = await globalThis.abilityContext.resourceManager.getString($r('app.string.network_err_toast').id); + let message: string = await globalThis.abilityContext.resourceManager.getString($r('app.string.network_err_toast').id); ToastUtils.showToast(message); }) } @@ -247,9 +247,9 @@ struct Index { } let currentStatus = OtaUpdateManager.getInstance().getUpdateState(); this.log(`checkNewVersion, currentStatus = ${currentStatus} `); - if (this.initUpdateStatus != currentStatus) { + if (this.initUpdateStatus != currentStatus && currentStatus !== null) { const checkedStatus = [UpdateState.INIT, UpdateState.UPGRADE_FAILED, UpdateState.UPGRADE_SUCCESS]; - return currentStatus in checkedStatus; + return checkedStatus.includes(currentStatus); } return false; } @@ -263,9 +263,10 @@ struct Index { Column() { Scroll() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { - HomeCardView({ playVideo: this.displayVideo, videoController: this.videoController, onVideoFinished: () => { + HomeCardView({ playVideo: this.displayVideo, videoController: this.videoController, onVideoFinished: + (): boolean => { this.checkTimes++; - return this.onCheckAction.call(this); + return this.onCheckAction.bind(this); } }) Text(this.displayVersion) .fontSize($r('app.float.home_text_size_version_name')) diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index 9f8c7f6..b628036 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -19,7 +19,8 @@ import { OtaStatus, UpdateState, UpgradeCallResult, - UpgradeData + UpgradeData, + BusinessError } from '@ohos/common/src/main/ets/const/update_const'; import update from '@ohos.update'; import { TitleBar } from '@ohos/common/src/main/ets/component/TitleBar'; @@ -28,18 +29,17 @@ import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { DeviceUtils } from '@ohos/common/src/main/ets/util/DeviceUtils'; import { ChangelogInfo, IPage, VersionPageInfo } from '@ohos/common/src/main/ets/manager/UpgradeInterface'; import { NetUtils } from '@ohos/common/src/main/ets/util/NetUtils'; -import { DialogHelper } from '@ohos/ota/src/main/ets/dialog/DialogHelper'; -import { ChangelogContent } from '@ohos/ota/src/main/ets/components/ChangelogContent'; -import { ProgressContent } from '@ohos/ota/src/main/ets/components/ProgressContent'; -import { OtaUpdateManager } from '@ohos/ota/src/main/ets/manager/OtaUpdateManager'; -import { CountDownInstallDialogBuilder } from '@ohos/ota/src/main/ets/dialog/CountDownInstallDialogBuilder'; -import { MessageDialogBuilder, } from '@ohos/ota/src/main/ets/dialog/MessageDialogBuilder'; -import { StateManager, UpdateAction } from '@ohos/ota/src/main/ets/manager/StateManager'; -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'; +import { DialogUtils } from 'ota/src/main/ets/dialog/DialogUtils'; +import { DialogHelper } from 'ota/src/main/ets/dialog/DialogHelper'; +import { ChangelogContent } from 'ota/src/main/ets/components/ChangelogContent'; +import { ProgressContent } from 'ota/src/main/ets/components/ProgressContent'; +import { OtaUpdateManager } from 'ota/src/main/ets/manager/OtaUpdateManager'; +import { CountDownInstallDialogBuilder } from 'ota/src/main/ets/dialog/CountDownInstallDialogBuilder'; +import { MessageDialogBuilder, } from 'ota/src/main/ets/dialog/MessageDialogBuilder'; +import { StateManager, UpdateAction } from 'ota/src/main/ets/manager/StateManager'; +import { UpgradeAdapter } from 'ota/src/main/ets/UpgradeAdapter'; +import { VersionUtils } from 'ota/src/main/ets/util/VersionUtils'; +import { NotificationHelper } from 'ota/src/main/ets/notify/NotificationHelper'; /** * 新版本页面 @@ -56,17 +56,17 @@ struct NewVersion { @State private isButtonEnable: boolean = true; @State private isButtonVisible: boolean = true; @StorageProp('updateStatus') - @Watch('initDataByStatus') private updateStatus: number = AppStorage.Get('updateStatus'); + @Watch('initDataByStatus') private updateStatus: number = AppStorage.Get('updateStatus') as number; @StorageProp('isClickInstall') @Watch('onInstallClick') - private isClickInstall: number = AppStorage.Get('isClickInstall'); - private dialogText: string | Resource = ''; + private isClickInstall: number = AppStorage.Get('isClickInstall') as number; + private dialogText: string | Resource | undefined = ''; @State private isInitComplete: boolean = false; - private effectiveMode: update.EffectiveMode = update.EffectiveMode.COLD; - @State otaMode: update.OtaMode = update.OtaMode.AB_STREAM_OTA; - private dialogType: CountDownDialogType = CountDownDialogType.OTA; + private effectiveMode: update.EffectiveMode | undefined = update.EffectiveMode.COLD; + @state otaMode: update.OtaMode = update.OtaMode.AB_STREAM_OTA; + private dialogType: CountDownDialogType | undefined = CountDownDialogType.OTA; @State private buttonText: string = ''; @StorageProp('installStatusRefresh') @Watch('refresh') - private installStatusRefresh: string = AppStorage.Get('installStatusRefresh'); + private installStatusRefresh: string = AppStorage.Get('installStatusRefresh') as string; private countdownDialogController = new CustomDialogController({ builder: CountDownInstallDialogBuilder({ @@ -122,7 +122,7 @@ struct NewVersion { private async handleAbnormalState(): Promise { let upgradeData: UpgradeData = await OtaUpdateManager.getInstance().getOtaStatus(); - let otaStatus: OtaStatus = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; + let otaStatus: OtaStatus | null | undefined = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; let state = otaStatus?.status; if (!state || state === UpdateState.INIT || state === UpdateState.UPGRADE_SUCCESS || state === UpdateState.UPGRADE_FAILED || state === UpdateState.INSTALL_FAILED) { @@ -135,7 +135,7 @@ struct NewVersion { this.log('onPageHide NewVersionPage'); } - onBackPress() { + onBackPress(): boolean { return globalThis.displayCountdownDialog; } @@ -187,7 +187,8 @@ struct NewVersion { } public async initNewVersionPageInfo(): Promise { - let newVersionInfo = globalThis.cachedNewVersionInfo || await OtaUpdateManager.getInstance().getNewVersion() + let newVersionInfo: update.NewVersionInfo = globalThis.cachedNewVersionInfo || + await OtaUpdateManager.getInstance().getNewVersion() .then(upgradeData => { this.log(`initDataByStatus upgradeData: ${upgradeData}`); return upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; @@ -196,7 +197,8 @@ struct NewVersion { if (!newVersionInfo) { return; } - let components: update.VersionComponent[] = VersionUtils.sortComponents(newVersionInfo?.versionComponents); + let components: update.VersionComponent[] = VersionUtils.sortComponents(newVersionInfo?.versionComponents) ?? [] as + update.VersionComponent[]; let pageInfo: VersionPageInfo = await UpgradeAdapter.getInstance() .getPageInstance()?.getNewVersionPageInfo(components); this.displayNewVersionName = pageInfo?.version; @@ -213,7 +215,7 @@ struct NewVersion { continue; } let versionPageInfo: VersionPageInfo = await page.getNewVersionPageInfo(components, componentDescription.data); - size += versionPageInfo.size; + size += versionPageInfo.size ?? 0; array.push(versionPageInfo.changelog); } this.changelogArray = array; @@ -225,7 +227,7 @@ struct NewVersion { this.log('upgrade effectiveMode ' + this.effectiveMode); this.isButtonEnable = false; let order = this.isABInstall() ? update.Order.INSTALL: update.Order.INSTALL_AND_APPLY - OtaUpdateManager.getInstance().upgrade(order).catch(err => { + OtaUpdateManager.getInstance().upgrade(order).catch((err: BusinessError) => { this.isButtonEnable = true; }); } @@ -247,9 +249,10 @@ struct NewVersion { if (this.isABStreamInstall()) { this.upgrade(); } else { - OtaUpdateManager.getInstance().download(update.NetType.CELLULAR); + OtaUpdateManager.getInstance().download(update.NetTupe.CELLULAR); } - } }); + } + }); } else { if (this.isABStreamInstall()) { this.upgrade(); @@ -268,11 +271,11 @@ struct NewVersion { OtaUpdateManager.getInstance().cancel(); break; case UpdateAction.RESUME: - if (this.isABStreamInstall()) { - this.upgrade(); - } else { - OtaUpdateManager.getInstance().resumeDownload(); - } + if (this.isABStreamInstall()) { + this.upgrade(); + } else { + OtaUpdateManager.getInstance().resumeDownload(); + } break; default: break; @@ -368,7 +371,7 @@ struct NewVersion { return; } let otaStatus: OtaStatus = JSON.parse(this.installStatusRefresh); - let status: UpdateState = otaStatus?.status; + let status: UpdateState | undefined = otaStatus?.status; if (status === UpdateState.INSTALL_FAILED || status === UpdateState.UPGRADE_FAILED || status === UpdateState.UPGRADE_SUCCESS) { this.closeUpgradeDialog(); diff --git a/product/oh/base/src/main/module.json5 b/product/oh/base/src/main/module.json5 index 1123f89..b628b66 100644 --- a/product/oh/base/src/main/module.json5 +++ b/product/oh/base/src/main/module.json5 @@ -25,7 +25,7 @@ "abilities": [ { "name": "com.ohos.updateapp.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "srcEntry": "./ets/MainAbility/MainAbility.ets", "description": "$string:description_mainability", "icon": "$media:icon", "label": "$string:entry_MainAbility", @@ -67,7 +67,7 @@ "description": "service", "type": "service", "visible": true, - "srcEntrance": "./ets/ServiceExtAbility/service.ts" + "srcEntrance": "./ets/ServiceExtAbility/service.ets" } ], "requestPermissions": [ -- Gitee From be12e2169ab491d75fb668dd7e6c33e6cea45b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Tue, 1 Jul 2025 13:29:05 +0000 Subject: [PATCH 2/4] 123 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- common/src/main/ets/util/FormatUtils.ets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/ets/util/FormatUtils.ets b/common/src/main/ets/util/FormatUtils.ets index 6fd2018..40539b7 100644 --- a/common/src/main/ets/util/FormatUtils.ets +++ b/common/src/main/ets/util/FormatUtils.ets @@ -101,4 +101,5 @@ export class FormatUtils { let language: string = DeviceUtils.getSystemLanguage(); let numfmt: Intl.NumberFormat = new Intl.NumberFormat(language, {style:'percent', notation:'standard'}); return numfmt.format(num); - } \ No newline at end of file + } +} \ No newline at end of file -- Gitee From 74494c44ffb9a40f93ea5bd269c5293161c11e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Tue, 1 Jul 2025 13:54:19 +0000 Subject: [PATCH 3/4] 222 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- common/src/main/ets/util/NetUtils.ets | 2 +- common/src/main/ets/util/UpdateUtils.ets | 4 ++-- .../main/ets/components/ChangelogContent.ets | 6 +++--- .../ota/src/main/ets/dialog/DialogHelper.ets | 18 +++++++++--------- .../ota/src/main/ets/dialog/DialogUtils.ets | 7 ++++--- .../src/main/ets/manager/OtaUpdateManager.ets | 12 ++++++------ .../ota/src/main/ets/manager/StateManager.ets | 6 +++--- .../src/main/ets/util/ChangelogParseUtils.ets | 16 ++++++++-------- product/oh/base/build-profile.json5 | 1 + product/oh/base/oh-package-lock.json5 | 6 +++++- .../src/main/ets/ServiceExtAbility/service.ets | 2 +- product/oh/base/src/main/ets/pages/index.ets | 2 +- .../oh/base/src/main/ets/pages/newVersion.ets | 1 - 13 files changed, 44 insertions(+), 39 deletions(-) diff --git a/common/src/main/ets/util/NetUtils.ets b/common/src/main/ets/util/NetUtils.ets index d744fb1..38b3518 100644 --- a/common/src/main/ets/util/NetUtils.ets +++ b/common/src/main/ets/util/NetUtils.ets @@ -15,7 +15,7 @@ import connection from '@ohos.net.connection'; import { BusinessError } from '../const/update_const'; -import { LogUtils } from '../util/LogUtils'; +import { LogUtils } from './LogUtils'; /** * 网络判断工具类 diff --git a/common/src/main/ets/util/UpdateUtils.ets b/common/src/main/ets/util/UpdateUtils.ets index f49ca52..8012eeb 100644 --- a/common/src/main/ets/util/UpdateUtils.ets +++ b/common/src/main/ets/util/UpdateUtils.ets @@ -67,8 +67,8 @@ export namespace UpdateUtils { LogUtils.error(TAG, 'Failed to start ability with error: context or want is null.'); return; } - (context as unionContext).startAbility(want, options).then((data) => { - LogUtils.info(TAG, 'Succeed to start ability with data: ' + JSON.stringify(data)); + (context as unionContext).startAbility(want, options).then(() => { + LogUtils.info(TAG, 'Succeed to start ability'); }).catch((error: BusinessError) => { LogUtils.error(TAG, 'Failed to start ability with error: ' + JSON.stringify(error)); }); diff --git a/feature/ota/src/main/ets/components/ChangelogContent.ets b/feature/ota/src/main/ets/components/ChangelogContent.ets index f3e6ddb..0ba81d2 100644 --- a/feature/ota/src/main/ets/components/ChangelogContent.ets +++ b/feature/ota/src/main/ets/components/ChangelogContent.ets @@ -41,7 +41,7 @@ export struct ChangelogContent { @Builder buildChangelog() { Column() { if (this.changelogInfoList && this.isParseChangelogFinished) { - ForEach(this.changelogInfoList, (item: ChangelogInfo, index?: number) => { + ForEach(this.changelogInfoList, (item: ChangelogInfo, index: number = 0) => { ChangelogCard({ changelogInfo: item, index: (this.changelogInfoList && this.changelogInfoList?.length > 1) ? index + 1 : 0, @@ -154,11 +154,11 @@ export struct ChangelogContent { private getTargetFeatures(changelog: Changelog, language: string, type: string): Features | undefined { if (changelog == null || language == null) { - return null; + return; } let lang: Language | undefined = changelog.language.get(language); if (lang == null) { - return null; + return; } let _features: Features | undefined; for (let index = 0; index < lang.featuresArray.length; index++) { diff --git a/feature/ota/src/main/ets/dialog/DialogHelper.ets b/feature/ota/src/main/ets/dialog/DialogHelper.ets index be3581c..632e699 100644 --- a/feature/ota/src/main/ets/dialog/DialogHelper.ets +++ b/feature/ota/src/main/ets/dialog/DialogHelper.ets @@ -17,9 +17,9 @@ import update from '@ohos.update'; import { DeviceUtils } from '@ohos/common/src/main/ets/util/DeviceUtils'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { FormatUtils } from '@ohos/common/src/main/ets/util/FormatUtils'; -import { UpdateState } from '@ohos/common/src/main/etc/const/update_const'; +import { UpdateState } from '@ohos/common/src/main/ets/const/update_const'; import { OtaUpdateManager } from '../manager/OtaUpdateManager'; -import RouteUtils from '../util/RouteUtils'; +import RouterUtils from '../util/RouterUtils'; /** * 弹框操作接口 @@ -41,7 +41,7 @@ import RouteUtils from '../util/RouteUtils'; /** * 重试检测动作 */ -calss RetryCheckAction implements DialogOperator { +class RetryCheckAction implements DialogOperator { onConfirm(): void { RouterUtils.singletonHomePage(); } @@ -76,7 +76,7 @@ class RetryUpgradeAction implements DialogOperator { onCancel(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); } -}; +} const retryUpgradeAction: DialogOperator = new RetryUpgradeAction(); @@ -120,7 +120,7 @@ export namespace DialogHelper { }, alignment: DeviceUtils.getDialogLocation(), offset: ({ - dx: "0vp", + dx: '0vp', dy: DeviceUtils.getDialogOffsetY() }), autoCancel: false @@ -151,8 +151,8 @@ export namespace DialogHelper { * * @param operator 回调 */ - export function displayNoNetworkDialog(operator ?: DialogOperator): void { - defaultKnowDialog($r('app.string.net_error_title'), $r('app.string.net_error_content'), operator); + export function displayNoNetworkDialog(): void { + defaultKnowDialog($r('app.string.net_error_title'), $r('app.string.net_error_content')); } /** @@ -160,9 +160,9 @@ export namespace DialogHelper { * * @param operator 回调 */ - export function displayNotEnoughBatteryDialog(operator ?: DialogOperator): void { + export function displayNotEnoughBatteryDialog(): void { defaultKnowDialog($r('app.string.battery_not_enough_title'), $r('app.string.battery_not_enough_content', - FormatUtils.getNumberFormat(0.3)), operator); + FormatUtils.getNumberFormat(0.3))); } /** diff --git a/feature/ota/src/main/ets/dialog/DialogUtils.ets b/feature/ota/src/main/ets/dialog/DialogUtils.ets index a7a2cc3..9b21c9e 100644 --- a/feature/ota/src/main/ets/dialog/DialogUtils.ets +++ b/feature/ota/src/main/ets/dialog/DialogUtils.ets @@ -19,6 +19,7 @@ import type { OtaStatus } from '@ohos/common/src/main/ets/const/update_const'; import { MAIN_ABILITY_NAME, PACKAGE_NAME, UpdateState } from '@ohos/common/src/main/ets/const/update_const'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; import { UpdateUtils } from '@ohos/common/src/main/ets/util/UpdateUtils'; +import { foregroundCheck } from '@ohos/common/src/main/ets/util/CommonUtils'; import { OtaUpdateManager } from '../manager/OtaUpdateManager'; import RouterUtils from '../util/RouterUtils'; import { DialogHelper } from './DialogHelper'; @@ -63,14 +64,14 @@ class RetryUpgradeAction implements DialogOperator { onCancel(): void { OtaUpdateManager.getInstance().setUpdateState(UpdateState.DOWNLOAD_SUCCESS); } -}; +} const retryUpgradeAction: DialogOperator = new RetryUpgradeAction(); /** * 重试检测动作 */ -calss RetryCheckAction implements DialogOperator { +class RetryCheckAction implements DialogOperator { onConfirm(): void { RouterUtils.singletonHomePage(); } @@ -79,7 +80,7 @@ calss RetryCheckAction implements DialogOperator { } }; - const retryCheckAction: DialogOperator = new RetryCheckAction(); + export const retryCheckAction: DialogOperator = new RetryCheckAction(); /** * 弹框工具类 diff --git a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets index 56c2dfd..4ff3c6f 100644 --- a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets +++ b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets @@ -50,7 +50,7 @@ export class OtaUpdateManager { private otaStatusHolder: OtaStatusHolder; private updateManager: UpdateManager; private messageQueue: MessageQueue; - private otaUpdaterCallback: update.UpgradeTaskCallback; + private otaUpdaterCallBack: update.UpgradeTaskCallback; /** * 单例--升级管理类对象实例 @@ -66,20 +66,20 @@ export class OtaUpdateManager { globalThis.otaUpdateManager = this; this.otaStatusHolder = new OtaStatusHolder(); this.messageQueue = new MessageQueue((message: Message): Promise => this.handleMessage(message)); - this.updateManager = new UpdateMananger(update.BusinessSubType.FIRMWARE); - this.otaUpdaterCallback = (eventInfo: update.EventInfo): void => { + this.updateManager = new UpdateManager(update.BusinessSubType.FIRMWARE); + this.otaUpdaterCallBack = (eventInfo: update.EventInfo): void => { this.notifyUpdateStatusRemote(eventInfo); }; } off(): void { this.log('otaUpdater off'); - this.updateManager.off(this.otaUpdaterCallback); + this.updateManager.off(this.otaUpdaterCallBack); } on(): void { this.log('otaUpdater on'); - this.updateManager.on(this.otaUpdaterCallback); + this.updateManager.on(this.otaUpdaterCallBack); } /** @@ -91,7 +91,7 @@ export class OtaUpdateManager { return new Promise((resolve, reject) => { this.updateManager.getOtaStatus().then((result: UpgradeData) => { if (result?.callResult === UpgradeCallResult.OK) { - this.refreshState(result?.data as otaStatus); + this.refreshState(result?.data as OtaStatus); } resolve(result); }); diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index b2fdd93..67abbdf 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -280,7 +280,7 @@ export class CheckSuccess extends BaseState { this.buttonClickAction = UpdateAction.DOWNLOAD; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { if (this.otaStatus?.endReason) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); switch (Number(this.otaStatus.endReason)) { @@ -344,7 +344,7 @@ export class DownloadPause extends BaseState { this.buttonClickAction = UpdateAction.RESUME; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { if (!VersionUtils.isInNewVersionPage()) { return; } @@ -389,7 +389,7 @@ export class DownloadFailed extends BaseState { this.buttonClickAction = UpdateAction.CANCEL; } - async notify(context?: common.Context, eventId?: update.EventId): Promise { + async notify(context: common.Context, eventId?: update.EventId): Promise { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); switch (Number(this.otaStatus?.endReason)) { case ErrorCode.VERIFY_PACKAGE_FAIL: diff --git a/feature/ota/src/main/ets/util/ChangelogParseUtils.ets b/feature/ota/src/main/ets/util/ChangelogParseUtils.ets index 55c8f1f..beb21e1 100644 --- a/feature/ota/src/main/ets/util/ChangelogParseUtils.ets +++ b/feature/ota/src/main/ets/util/ChangelogParseUtils.ets @@ -86,15 +86,15 @@ namespace ChangelogParseUtils { return; } let xmlResult: XmlElement = conv.convert(res, options) as XmlElement; - if (!xmlResult || !xmlResult['_elements'] || xmlResult['_elements'].length <= 0) { + if (!xmlResult || !xmlResult._elements || xmlResult._elements.length <= 0) { logError('xmlResult is null! ' + JSON.stringify(xmlResult)); - callback(null); + callback(); return; } let root: XmlElement | undefined = xmlResult._elements[0]; if (!root || !root._elements || root._elements.length <= 0) { logError('root is null! ' + JSON.stringify(root)); - callback(null); + callback(); return; } parseRoot(root); @@ -105,7 +105,7 @@ namespace ChangelogParseUtils { function parseRoot(root: XmlElement): void { // 倒序解析,先解析Icon let icons: Map = new Map(); - if (root?.elements === undefined) { + if (root?._elements === undefined) { return; } logInfo('root length ' + root?._elements?.length); @@ -138,7 +138,7 @@ namespace ChangelogParseUtils { if (element._type === 'element' && element._name === 'language') { let attribute: string; if (!element._attributes) { - logError('language is null :' + JSON.stringify(element['_attributes'])); + logError('language is null :' + JSON.stringify(element._attributes)); return; } attribute = element._attributes.name ?? ''; @@ -155,8 +155,8 @@ namespace ChangelogParseUtils { } function parseIcons(iconsElement: XmlElement[], icons: Map): void { - if (CommonUtils.IsEmpty(iconsElement)) { - logError(`iconsElement is null${JSON.stringify(iconElement)}`); + if (CommonUtils.isEmpty(iconsElement)) { + logError(`iconsElement is null${JSON.stringify(iconsElement)}`); return; } let icon: Icon; @@ -191,7 +191,7 @@ namespace ChangelogParseUtils { if (featuresElement._type === 'element' && featuresElement._name === 'features') { let moduleString = featuresElement._attributes?.module; let typeString = featuresElement._attributes?.type; - let id = featuresElement?._attributes.id; + let id = featuresElement?._attributes?.id; let featureElement = featuresElement._elements; let featureList: Feature[] = []; features = { diff --git a/product/oh/base/build-profile.json5 b/product/oh/base/build-profile.json5 index 7343e90..a5abcf4 100644 --- a/product/oh/base/build-profile.json5 +++ b/product/oh/base/build-profile.json5 @@ -1,5 +1,6 @@ { "apiType": 'stageMode', + "arkTSVersion": '1.1', "buildOption": { }, "targets": [ diff --git a/product/oh/base/oh-package-lock.json5 b/product/oh/base/oh-package-lock.json5 index 9a7c9a9..a3a1b74 100644 --- a/product/oh/base/oh-package-lock.json5 +++ b/product/oh/base/oh-package-lock.json5 @@ -6,7 +6,11 @@ "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. Do NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "@ohos/common@../../../common": { + "@ohos/common@../../../common": "@ohos/common@../../../common", + "ota@../../../feature/ota": "ota@../../../feature/ota" + }, + "packages": { + "@ohos/common@../../../common": { "name": "@ohos/common", "version": "1.0.0", "resolved": "../../../common", diff --git a/product/oh/base/src/main/ets/ServiceExtAbility/service.ets b/product/oh/base/src/main/ets/ServiceExtAbility/service.ets index 8adb6c7..071e92a 100644 --- a/product/oh/base/src/main/ets/ServiceExtAbility/service.ets +++ b/product/oh/base/src/main/ets/ServiceExtAbility/service.ets @@ -19,7 +19,7 @@ import type rpc from '@ohos.rpc'; import { CommonUtils } from '@ohos/common/src/main/ets/util/CommonUtils'; import { OtaUpdateManager } from 'ota/src/main/ets/manager/OtaUpdateManager'; import { LogUtils } from '@ohos/common/src/main/ets/util/LogUtils'; -import type { BusinessError } from '@ohos/common/src/main/ets/const/update_const"; +import type { BusinessError } from '@ohos/common/src/main/ets/const/update_const'; import { ServiceExtStub } from './serviceStub'; /** diff --git a/product/oh/base/src/main/ets/pages/index.ets b/product/oh/base/src/main/ets/pages/index.ets index afc5a6f..352cc70 100644 --- a/product/oh/base/src/main/ets/pages/index.ets +++ b/product/oh/base/src/main/ets/pages/index.ets @@ -101,7 +101,7 @@ struct Index { return true; } - private notifyNewVersionStatus(newVersionStatu: NewVersionStatus): void { + private notifyNewVersionStatus(newVersionStatus: NewVersionStatus): void { this.log('perform updateNewVersionStatus:' + newVersionStatus); this.checkEndStatus = newVersionStatus; // 延时更新 if (newVersionStatus == NewVersionStatus.CHECKING) { diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index b628036..59bd513 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -1,4 +1,3 @@ -import { DialogUtils } from '../../../../../../../feature/ota/src/main/ets/dialog/DialogUtils'; /* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); -- Gitee From 9e4fc6ff5dd18f4821f9743116df82a7b5a2859c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 2 Jul 2025 00:33:07 +0000 Subject: [PATCH 4/4] codeCheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- product/oh/base/src/main/ets/pages/index.ets | 3 ++- product/oh/base/src/main/ets/pages/newVersion.ets | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/product/oh/base/src/main/ets/pages/index.ets b/product/oh/base/src/main/ets/pages/index.ets index 352cc70..f2b8ed1 100644 --- a/product/oh/base/src/main/ets/pages/index.ets +++ b/product/oh/base/src/main/ets/pages/index.ets @@ -119,7 +119,8 @@ struct Index { this.checkLoopTimes = 0; this.notifyNewVersionStatus(NewVersionStatus.CHECKING); let upgradeData: UpgradeData = await OtaUpdateManager.getInstance().getOtaStatus(); - let otaStatus: OtaStatus | undefined | null = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; + let otaStatus: OtaStatus | undefined | null = upgradeData.callResult == + UpgradeCallResult.OK ? upgradeData.data : null; this.initUpdateStatus = otaStatus?.status; if (StateManager.isAllowExecute(this.updateStatus, UpdateAction.CHECK_NEW_VERSION)) { this.performCheckNewVersion(); diff --git a/product/oh/base/src/main/ets/pages/newVersion.ets b/product/oh/base/src/main/ets/pages/newVersion.ets index 59bd513..3a75e82 100644 --- a/product/oh/base/src/main/ets/pages/newVersion.ets +++ b/product/oh/base/src/main/ets/pages/newVersion.ets @@ -121,7 +121,8 @@ struct NewVersion { private async handleAbnormalState(): Promise { let upgradeData: UpgradeData = await OtaUpdateManager.getInstance().getOtaStatus(); - let otaStatus: OtaStatus | null | undefined = upgradeData.callResult == UpgradeCallResult.OK ? upgradeData.data : null; + let otaStatus: OtaStatus | null | undefined = upgradeData.callResult == + UpgradeCallResult.OK ? upgradeData.data : null; let state = otaStatus?.status; if (!state || state === UpdateState.INIT || state === UpdateState.UPGRADE_SUCCESS || state === UpdateState.UPGRADE_FAILED || state === UpdateState.INSTALL_FAILED) { -- Gitee