From ca8912b0dd8bcd1e037c794a49d2f261a0345701 Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Thu, 21 Nov 2024 09:20:24 +0800 Subject: [PATCH] =?UTF-8?q?fuzz=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanchenxuan --- .../ets/GlobalExtAbility/GlobalExtAbility.ts | 2 +- .../src/main/ets/MainAbility/MainAbility.ts | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/permissionmanager/src/main/ets/GlobalExtAbility/GlobalExtAbility.ts b/permissionmanager/src/main/ets/GlobalExtAbility/GlobalExtAbility.ts index 739c631..182e84f 100644 --- a/permissionmanager/src/main/ets/GlobalExtAbility/GlobalExtAbility.ts +++ b/permissionmanager/src/main/ets/GlobalExtAbility/GlobalExtAbility.ts @@ -79,7 +79,7 @@ export default class GlobalExtensionAbility extends extension { try { let flag = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION; let bundleInfo = bundleManager.getBundleInfoForSelfSync(flag); - let atManager =abilityAccessCtrl.createAtManager(); + let atManager = abilityAccessCtrl.createAtManager(); let status = atManager.verifyAccessTokenSync(bundleInfo.appInfo.accessTokenId, 'ohos.permission.MICROPHONE_CONTROL'); if (status === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { diff --git a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts index 381413d..5a35a15 100644 --- a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts +++ b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts @@ -26,11 +26,6 @@ export default class MainAbility extends UIAbility { onCreate(want, launchParam): void { console.log(TAG + 'MainAbility onCreate, ability name is ' + want.abilityName + '.'); - if (!this.permissionCheck()) { - this.context.terminateSelf(); - return; - } - globalThis.bundleName = want.parameters.bundleName; GlobalContext.store('bundleName', want.parameters.bundleName); GlobalContext.store('context', this.context); @@ -41,6 +36,11 @@ export default class MainAbility extends UIAbility { console.log(TAG + 'MainAbility onWindowStageCreate.'); globalThis.windowStage = windowStage; globalThis.refresh = false; + if (!this.permissionCheck()) { + windowStage.loadContent('pages/transition'); + this.context.terminateSelf(); + return; + } if (globalThis.bundleName) { globalThis.currentApp = globalThis.bundleName; @@ -82,14 +82,6 @@ export default class MainAbility extends UIAbility { console.log(TAG + 'MainAbility onNewWant. want: ' + JSON.stringify(want)); console.log(TAG + 'MainAbility onNewWant. bundleName: ' + JSON.stringify(want.parameters.bundleName)); - if (!this.permissionCheck()) { - this.context.terminateSelf(); - return; - } - - if (globalThis.currentApp === undefined) { - this.context.terminateSelf(); - } let bundleName = want.parameters.bundleName ? want.parameters.bundleName : 'all'; if (globalThis.currentApp === 'all') { if (globalThis.currentApp !== bundleName) { @@ -151,7 +143,7 @@ export default class MainAbility extends UIAbility { try { let flag = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION; let bundleInfo = bundleManager.getBundleInfoForSelfSync(flag); - let atManager =abilityAccessCtrl.createAtManager(); + let atManager = abilityAccessCtrl.createAtManager(); let status = atManager.verifyAccessTokenSync(bundleInfo.appInfo.accessTokenId, 'ohos.permission.GET_INSTALLED_BUNDLE_LIST'); if (status === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {