diff --git a/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts b/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts index b16a6a131f777648387145ed1f776a43a3a7a037..76d4824f1ee3075f22b28f51233c7f9b2d0ba586 100644 --- a/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts +++ b/permissionmanager/src/main/ets/SecurityExtAbility/SecurityExtAbility.ts @@ -76,6 +76,7 @@ export default class SecurityExtensionAbility extends extension { const win = await window.createWindow({ ctx: this.context, name, windowType }); let storage: LocalStorage = new LocalStorage({ 'want': want, 'win': win }); await win.bindDialogTarget(want.parameters['ohos.ability.params.token'].value, () => { + win.off('windowSizeChange'); win.destroyWindow(); let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: string = want.parameters['ohos.aafwk.param.callerBundleName']; @@ -91,10 +92,21 @@ export default class SecurityExtensionAbility extends extension { win.setWindowBackgroundColor(BG_COLOR); await win.showWindow(); console.info(TAG + 'showWindow end.'); + this.listenWindowChange(win, rect); dialogSet.add(callerToken); GlobalContext.store('dialogSet', dialogSet); } catch (err) { console.error(TAG + `window create failed! err: ${JSON.stringify(err)}`); } } + + listenWindowChange(win: window.Window, rect) { + try { + win.on('windowSizeChange', () => { + win.resize(rect.width, rect.height); + }) + } catch (err) { + console.error(TAG + `listen windowSizeChange failed. code: ${err.code}, message: ${err.message}`); + } + } }; diff --git a/permissionmanager/src/main/ets/pages/securityDialog.ets b/permissionmanager/src/main/ets/pages/securityDialog.ets index 43dc4aee12df3ccbbc3b7bcf48f80fe766fb21be..b706a7d828378c89c48ad233e57e588b37b73b50 100644 --- a/permissionmanager/src/main/ets/pages/securityDialog.ets +++ b/permissionmanager/src/main/ets/pages/securityDialog.ets @@ -28,7 +28,6 @@ import { Param, WantInfo } from '../common/model/typedef'; import { GlobalContext } from '../common/utils/globalContext'; let storage = LocalStorage.getShared(); -const TAG = 'PermissionManager_Log:'; const RESOURCE_TYPE: number = 10003; @Entry(storage) @@ -61,15 +60,7 @@ struct SecurityDialog { value: $r('app.string.cancel'), buttonStyle: ButtonStyleMode.TEXTUAL, action: () => { - this.dialogController?.close(); - this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); - let callerToken: string = this.want.parameters['ohos.aafwk.param.callerBundleName']; - dialogSet.delete(callerToken); - GlobalContext.store('dialogSet', dialogSet); - if (dialogSet.size === 0) { - this.context.terminateSelf(); - } + this.cancelHandel(); } }, { @@ -84,14 +75,7 @@ struct SecurityDialog { }), autoCancel: false, cancel: () => { - this.win.destroyWindow(); - let dialogSet: Set = GlobalContext.load('dialogSet'); - let callerToken: string = this.want.parameters['ohos.aafwk.param.callerBundleName']; - dialogSet.delete(callerToken); - GlobalContext.store('dialogSet', dialogSet); - if (dialogSet.size === 0) { - this.context.terminateSelf(); - } + this.cancelHandel(); } }); @@ -237,6 +221,11 @@ struct SecurityDialog { }).finally(() => { data.reclaim(); reply.reclaim(); + try { + this.win.off('windowSizeChange'); + } catch (err) { + Log.error(`Failed to enable the listener for windowSizeChange. code: ${err.code}, message: ${err.message}`); + } this.win.destroyWindow(); let dialogSet: Set = GlobalContext.load('dialogSet'); let callerToken: string = this.want.parameters['ohos.aafwk.param.callerBundleName']; @@ -247,4 +236,21 @@ struct SecurityDialog { } }) } + + cancelHandel() { + this.dialogController?.close(); + try { + this.win.off('windowSizeChange'); + } catch (err) { + Log.error(`Failed to enable the listener for windowSizeChange. code: ${err.code}, message: ${err.message}`); + } + this.win.destroyWindow(); + let dialogSet: Set = GlobalContext.load('dialogSet'); + let callerToken: string = this.want.parameters['ohos.aafwk.param.callerBundleName']; + dialogSet.delete(callerToken); + GlobalContext.store('dialogSet', dialogSet); + if (dialogSet.size === 0) { + this.context.terminateSelf(); + } + } }