diff --git a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets index e617369a743469dc128c2ac70692f2e2bed4cc4c..c57e24f4e99cd68843741e76b579f6d3e5da21a4 100644 --- a/feature/ota/src/main/ets/manager/OtaUpdateManager.ets +++ b/feature/ota/src/main/ets/manager/OtaUpdateManager.ets @@ -58,7 +58,7 @@ export class OtaUpdateManager { } private constructor() { - this.log('OtaUpdateManager init.'); + this.logError('OtaUpdateManager init.'); globalThis.otaUpdateManager = this; this.otaStatusHolder = new OtaStatusHolder(); this.messageQueue = new MessageQueue(this.handleMessage.bind(this)); @@ -276,11 +276,14 @@ export class OtaUpdateManager { } private refreshState(otaStatus: OtaStatus): void { + this.logError('refreshState, otaStatus: ' + JSON.stringify(otaStatus)); + if (!this.stateObj || this.lastStatus !== otaStatus.status) { this.stateObj = StateManager.createInstance(otaStatus); } this.stateObj.refresh(otaStatus); this.lastStatus = otaStatus.status; + this.logError('refreshState, this.lastStatus: ' + this.lastStatus); this.setUpdateState(this.stateObj.state); this.setDownloadProgress(this.stateObj.percent); } @@ -301,9 +304,14 @@ export class OtaUpdateManager { } private async handleMessage(context: common.Context, eventInfo: update.EventInfo): Promise { + this.logError('handleMessage, eventId: .' + eventInfo.eventId); + let otaStatus: OtaStatus = this.getFormattedOtaStatus(eventInfo); + this.logError('handleMessage, otaStatus: ' + JSON.stringify(otaStatus)); + if (this.isTerminalState(otaStatus)) { globalThis.lastVersionName = await VersionUtils.obtainNewVersionName(eventInfo?.taskBody); + this.logError('handleMessage, lastVersionName: ' + globalThis.lastVersionName); } let versionDigest: string = eventInfo?.taskBody?.versionDigestInfo?.versionDigest ?? ''; await this.notifyUpdateStatus(otaStatus, context, versionDigest, eventInfo?.eventId); @@ -311,17 +319,18 @@ export class OtaUpdateManager { private async notifyUpdateStatus(otaStatus: OtaStatus, context: common.Context, verDigest?: string, eventId?: update.EventId): Promise { - this.log('notifyUpdateStatus:' + JSON.stringify(otaStatus)); + this.logError('notifyUpdateStatus:' + JSON.stringify(otaStatus)); this.refreshState(otaStatus); if (!this.otaStatusHolder.isStatusChangedAndRefresh(otaStatus, eventId)) { - LogUtils.warn('UpdateManager', 'notifyUpdateStatus is repeating, abandon.'); + this.logError('notifyUpdateStatus is repeating, abandon.'); return; } if (!globalThis.cachedNewVersionInfo && !this.isTerminalState(otaStatus)) { await this.getNewVersion(); } + this.logError('createInstance'); await StateManager.createInstance(otaStatus).notify(context, eventId); } @@ -341,7 +350,7 @@ export class OtaUpdateManager { * @param otaStatus 状态数据 */ async onReceivedUpdateServiceMessage(eventInfo: update.EventInfo): Promise { - this.log('receives from onReceivedUpdateServiceMessage:' + JSON.stringify(eventInfo)); + this.logError('receives from onReceivedUpdateServiceMessage:' + JSON.stringify(eventInfo)); let message: Message = { context: globalThis.extensionContext, eventInfo: eventInfo, @@ -355,7 +364,7 @@ export class OtaUpdateManager { * @param otaStatus 状态数据 */ async onReceivedUpdatePageMessage(otaStatus: OtaStatus): Promise { - this.log('receives from onReceivedUpdatePageMessage:' + JSON.stringify(otaStatus)); + this.logError('receives from onReceivedUpdatePageMessage:' + JSON.stringify(otaStatus)); this.notifyUpdateStatus(otaStatus, globalThis.abilityContext); } @@ -367,12 +376,14 @@ export class OtaUpdateManager { */ public async handleWant(want: Want, context: common.Context): Promise { let action: string = want?.action ?? ''; + this.logError('handleWant, action: ' + action); if (await NotificationManager.handleAction(action, context)) { return; } let eventInfo = this.wantParser(want); + this.logError('handleWant, eventInfo: ' + JSON.stringify(eventInfo)); if (!eventInfo?.eventId) { - this.log('eventInfo?.eventId is null'); + this.logError('eventInfo?.eventId is null'); return; } await this.onReceivedUpdateServiceMessage(eventInfo); @@ -397,7 +408,7 @@ export class OtaUpdateManager { } private log(message: string): void { - LogUtils.log('UpdateManager', message); + LogUtils.info('UpdateManager', message); } private logError(message: string): void { diff --git a/feature/ota/src/main/ets/manager/StateManager.ets b/feature/ota/src/main/ets/manager/StateManager.ets index a98abf07f8e54c76fe54687c52e0602ce6573dbe..4c058763f6af8795e525af39855573bba0838539 100644 --- a/feature/ota/src/main/ets/manager/StateManager.ets +++ b/feature/ota/src/main/ets/manager/StateManager.ets @@ -90,6 +90,8 @@ export namespace StateManager { */ export function createInstance(status: OtaStatus | number): BaseState { let state: number = (typeof status === 'number') ? status : status?.status; + LogUtils.error('createInstance, state: ', state.toString()); + let stateObject: BaseState = null; switch (state) { case UpdateState.DOWNLOAD_CANCEL: // fall through @@ -577,10 +579,11 @@ export class UpgradeSuccess extends BaseState { } async notify(context?: common.Context): Promise { + LogUtils.error('StateManager', 'UpgradeSuccess'); AppStorage.Set('installStatusRefresh', JSON.stringify(this.otaStatus)); await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); let versionName = globalThis.lastVersionName; - LogUtils.log('StateManager', "UpgradeSuccess versionName is " + versionName); + LogUtils.error('StateManager', "UpgradeSuccess versionName is " + versionName); await UpgradeAdapter.getInstance().getNotifyInstance()?.showUpgradeSuccess(versionName, context); } } diff --git a/product/oh/base/src/main/ets/ServiceExtAbility/service.ts b/product/oh/base/src/main/ets/ServiceExtAbility/service.ts index cc0fe000bc0cb47360e4c6ea11d24bcf66cea681..c55312064ab68db94abd52e6f23e50702a76a462 100644 --- a/product/oh/base/src/main/ets/ServiceExtAbility/service.ts +++ b/product/oh/base/src/main/ets/ServiceExtAbility/service.ts @@ -30,12 +30,15 @@ export default class ServiceExtAbility extends Extension { private startIdArray: number[] = []; onCreate(want: Want): void { - LogUtils.log(ServiceExtAbility.TAG, 'onCreate:' + JSON.stringify(want)); + if (want == undefined || want == null) { + LogUtils.error(ServiceExtAbility.TAG, "want is null !!!!"); + } + LogUtils.error(ServiceExtAbility.TAG, 'onCreate:' + JSON.stringify(want)); globalThis.extensionContext = this.context; // when start ServiceExtAbility ,set context } async onRequest(want: Want, startId: number): Promise { - LogUtils.log(ServiceExtAbility.TAG, `onRequest, want: ${want.abilityName}`); + LogUtils.error(ServiceExtAbility.TAG, `onRequest, want: ${want.abilityName}`); this.startIdArray.push(startId); globalThis.extensionContext = this.context; await OtaUpdateManager.getInstance().handleWant(want, globalThis.extensionContext); @@ -43,7 +46,7 @@ export default class ServiceExtAbility extends Extension { } onConnect(want: Want): rpc.RemoteObject { - LogUtils.log(ServiceExtAbility.TAG, `onConnect , want: ${want.abilityName}`); + LogUtils.error(ServiceExtAbility.TAG, `onConnect , want: ${want.abilityName}`); return null; } @@ -53,6 +56,7 @@ export default class ServiceExtAbility extends Extension { } private stopSelf(startId: number): void { + LogUtils.error(ServiceExtAbility.TAG, 'stopSelf, startId: ' + startId); this.startIdArray.splice(this.startIdArray.indexOf(startId), 1); LogUtils.info(ServiceExtAbility.TAG, 'stopSelf length ' + this.startIdArray.length); if (this.startIdArray.length === 0 && this.isTerminal()) {