From 47248401d18c4d1353660585238333e5e49745de Mon Sep 17 00:00:00 2001 From: li-li-wang Date: Mon, 31 Mar 2025 11:46:38 +0800 Subject: [PATCH] fix 5.1 difference Signed-off-by: li-li-wang --- AppScope/app.json | 4 +-- AppScope/app.json5 | 4 +-- build-profile.json5 | 6 ++--- .../SecurityExtAbility/SecurityExtAbility.ts | 21 ++++++---------- .../main/ets/common/utils/globalContext.ts | 2 +- .../src/main/ets/pages/securityDialog.ets | 25 +++++++------------ 6 files changed, 24 insertions(+), 38 deletions(-) diff --git a/AppScope/app.json b/AppScope/app.json index cb1e2bf..ae2906b 100644 --- a/AppScope/app.json +++ b/AppScope/app.json @@ -4,8 +4,8 @@ "app": { "bundleName": "com.ohos.permissionmanager", "vendor": "example", - "versionCode": 1000076, - "versionName": "1.7.6", + "versionCode": 1000075, + "versionName": "1.7.5", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 14, diff --git a/AppScope/app.json5 b/AppScope/app.json5 index fb84c46..5c5d8f5 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.permissionmanager", "vendor": "example", - "versionCode": 1000076, - "versionName": "1.7.6", + "versionCode": 1000075, + "versionName": "1.7.5", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 14, diff --git a/build-profile.json5 b/build-profile.json5 index 399ad9a..bbc94bb 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -19,9 +19,9 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 18, - "compatibleSdkVersion": 18, - "targetSdkVersion": 18, + "compileSdkVersion": 16, + "compatibleSdkVersion": 16, + "targetSdkVersion": 16, "runtimeOS": "OpenHarmony" } ] diff --git a/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts b/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts index 1f0f912..bdb8160 100644 --- a/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts +++ b/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts @@ -68,16 +68,14 @@ export default class SecurityExtensionAbility extends extension { private async createWindow(name: string, windowType, rect, want): Promise { console.info(TAG + 'create securityWindow'); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); if (!dialogSet) { - dialogSet = new Set(); + dialogSet = new Set(); console.info(TAG + 'new dialogSet'); GlobalContext.store('dialogSet', dialogSet); } let callerToken: number = want.parameters['ohos.caller.uid']; - let windId: number = want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - if (dialogSet.has(token)) { + if (dialogSet.has(callerToken)) { console.info(TAG + 'window already exists'); return; } @@ -86,20 +84,15 @@ export default class SecurityExtensionAbility extends extension { let storage: LocalStorage = new LocalStorage({ 'want': want, 'win': win }); await win.bindDialogTarget(want.parameters['ohos.ability.params.token'].value, () => { win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: number = want.parameters['ohos.caller.uid']; - let windId: number = want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - dialogSet.delete(token); + dialogSet.delete(callerToken); GlobalContext.store('dialogSet', dialogSet); if (dialogSet.size === 0) { this.context.terminateSelf(); } }); - try { - await win.setFollowParentWindowLayoutEnabled(true); - } catch(error) { - console.error(TAG + `setFollowParentWindowLayoutEnabled error: ${JSON.stringify(error)}`); + if (deviceInfo.deviceType !== 'wearable') { await win.moveWindowTo(rect.left, rect.top); await win.resize(rect.width, rect.height); }; @@ -107,7 +100,7 @@ export default class SecurityExtensionAbility extends extension { win.setWindowBackgroundColor(BG_COLOR); await win.showWindow(); console.info(TAG + 'showWindow end.'); - dialogSet.add(token); + dialogSet.add(callerToken); GlobalContext.store('dialogSet', dialogSet); } catch (err) { console.error(TAG + `window create failed! err: ${JSON.stringify(err)}`); diff --git a/permissionmanager/src/main/ets/common/utils/globalContext.ts b/permissionmanager/src/main/ets/common/utils/globalContext.ts index c3c9266..06bcf12 100644 --- a/permissionmanager/src/main/ets/common/utils/globalContext.ts +++ b/permissionmanager/src/main/ets/common/utils/globalContext.ts @@ -20,7 +20,7 @@ export class GlobalContext { bundleName: string; globalState: string; windowNum: number; - dialogSet: Set; + dialogSet: Set; public static getContext(): GlobalContext { if (!GlobalContext.instance) { diff --git a/permissionmanager/src/main/ets/pages/securityDialog.ets b/permissionmanager/src/main/ets/pages/securityDialog.ets index 61abd38..c8b2858 100644 --- a/permissionmanager/src/main/ets/pages/securityDialog.ets +++ b/permissionmanager/src/main/ets/pages/securityDialog.ets @@ -263,11 +263,9 @@ struct SecurityDialog { action: () => { this.dialogController?.close(); this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: number = this.want.parameters['ohos.caller.uid']; - let windId: number = this.want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - dialogSet.delete(token); + dialogSet.delete(callerToken); GlobalContext.store('dialogSet', dialogSet); if (dialogSet.size === 0) { this.context.terminateSelf(); @@ -287,16 +285,15 @@ struct SecurityDialog { autoCancel: false, cancel: () => { this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: number = this.want.parameters['ohos.caller.uid']; - let windId: number = this.want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - dialogSet.delete(token); + dialogSet.delete(callerToken); GlobalContext.store('dialogSet', dialogSet); if (dialogSet.size === 0) { this.context.terminateSelf(); } }, + offset: { dx: 0, dy: 0 - this.want.parameters['ohos.dialog.offset'] + 'px' } }); @Builder @@ -348,11 +345,9 @@ struct SecurityDialog { onCancel() { Log.info('Callback when the first button is clicked'); this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: number = this.want.parameters['ohos.caller.uid']; - let windId: number = this.want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - dialogSet.delete(token); + dialogSet.delete(callerToken); GlobalContext.store('dialogSet', dialogSet); if (dialogSet.size === 0) { this.context.terminateSelf(); @@ -423,11 +418,9 @@ struct SecurityDialog { data.reclaim(); reply.reclaim(); this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); + let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: number = this.want.parameters['ohos.caller.uid']; - let windId: number = this.want.parameters['ohos.ability.params.windowId']; - let token: String = String(callerToken) + '_' + String(windId); - dialogSet.delete(token); + dialogSet.delete(callerToken); GlobalContext.store('dialogSet', dialogSet); if (dialogSet.size === 0) { this.context.terminateSelf(); -- Gitee