From bde0df5d4ccfb4025cca09db306d4287c22445a9 Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Tue, 3 Sep 2024 20:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=905.0release=E3=80=91=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=9B=B4=E6=96=B0=E5=8F=8A=E9=94=99=E8=AF=AF=E6=8D=95?= =?UTF-8?q?=E6=8D=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanchenxuan --- .../src/main/ets/MainAbility/MainAbility.ts | 79 +++++++++++-------- .../main/resources/base/element/string.json | 2 +- .../main/resources/zh_TW/element/string.json | 4 +- .../main/resources/zz_ZX/element/string.json | 2 +- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts index 25c840b..bb94650 100644 --- a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts +++ b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts @@ -81,13 +81,13 @@ export default class MainAbility extends UIAbility { if (globalThis.currentApp === 'all') { if (globalThis.currentApp !== bundleName) { console.log(TAG + 'MainAbility onNewWant. all -> app'); - globalThis.windowStage.setUIContent(this.context, 'pages/transition', null); + globalThis.windowStage?.setUIContent(this.context, 'pages/transition', null); globalThis.currentApp = bundleName; GlobalContext.store('bundleName', bundleName); this.getSperifiedApplication(bundleName); } else { if (globalThis.refresh === true) { - globalThis.windowStage.setUIContent(this.context, 'pages/transition', null); + globalThis.windowStage?.setUIContent(this.context, 'pages/transition', null); this.getAllApplications(); globalThis.refresh = false; } @@ -95,13 +95,13 @@ export default class MainAbility extends UIAbility { } else { if (bundleName === 'all') { console.log(TAG + 'MainAbility onNewWant. app -> all'); - globalThis.windowStage.setUIContent(this.context, 'pages/transition', null); + globalThis.windowStage?.setUIContent(this.context, 'pages/transition', null); globalThis.currentApp = 'all'; this.getAllApplications(); } else { if (globalThis.currentApp !== bundleName) { console.log(TAG + 'MainAbility onNewWant. app -> app'); - globalThis.windowStage.setUIContent(this.context, 'pages/transition', null); + globalThis.windowStage?.setUIContent(this.context, 'pages/transition', null); globalThis.currentApp = bundleName; GlobalContext.store('bundleName', bundleName); this.getSperifiedApplication(bundleName); @@ -112,9 +112,14 @@ export default class MainAbility extends UIAbility { } onWindowStageDestroy(): void { - bundleMonitor.off('add'); - bundleMonitor.off('remove'); - console.log(TAG + 'MainAbility onWindowStageDestroy.'); + try { + bundleMonitor.off('add'); + bundleMonitor.off('remove'); + bundleMonitor.off('update'); + console.log(TAG + 'MainAbility onWindowStageDestroy.'); + } catch (err) { + console.log(`errData is errCode:${err.code} message:${err.message}`); + } } onBackground(): void { @@ -164,7 +169,7 @@ export default class MainAbility extends UIAbility { initialGroups.push(info); } let storage: LocalStorage = new LocalStorage({ 'initialGroups': initialGroups }); - globalThis.windowStage.loadContent('pages/authority-management', storage); + globalThis.windowStage?.loadContent('pages/authority-management', storage); }).catch((error) => { console.error(TAG + 'bundle.getAllBundleInfo failed. Cause: ' + JSON.stringify(error)); }); @@ -178,33 +183,37 @@ export default class MainAbility extends UIAbility { const flag = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; - bundleManager.getBundleInfo(bundleName, flag).then(bundleInfo => { - let reqPermissions: Array = []; - bundleInfo.reqPermissionDetails.forEach(item => { - reqPermissions.push(item.name); - }); + try { + bundleManager.getBundleInfo(bundleName, flag).then(bundleInfo => { + let reqPermissions: Array = []; + bundleInfo.reqPermissionDetails.forEach(item => { + reqPermissions.push(item.name); + }); - let info = { - 'bundleName': bundleInfo.name, - 'api': bundleInfo.targetVersion, - 'tokenId': bundleInfo.appInfo.accessTokenId, - 'icon': '', - 'iconId': bundleInfo.appInfo.iconId, - 'iconResource': bundleInfo.appInfo.iconResource, - 'label': '', - 'labelId': bundleInfo.appInfo.labelId, - 'labelResource': bundleInfo.appInfo.labelResource, - 'permissions': reqPermissions, - 'groupId': [], - 'zhTag': '', - 'indexTag': '', - 'language': '' - }; - GlobalContext.store('applicationInfo', info); - globalThis.windowStage.setUIContent(this.context, 'pages/application-secondary', null); - }).catch(() => { - console.log(TAG + 'MainAbility getSperifiedApplication failed.'); - this.context.terminateSelf(); - }); + let info = { + 'bundleName': bundleInfo.name, + 'api': bundleInfo.targetVersion, + 'tokenId': bundleInfo.appInfo.accessTokenId, + 'icon': '', + 'iconId': bundleInfo.appInfo.iconId, + 'iconResource': bundleInfo.appInfo.iconResource, + 'label': '', + 'labelId': bundleInfo.appInfo.labelId, + 'labelResource': bundleInfo.appInfo.labelResource, + 'permissions': reqPermissions, + 'groupId': [], + 'zhTag': '', + 'indexTag': '', + 'language': '' + }; + GlobalContext.store('applicationInfo', info); + globalThis.windowStage?.setUIContent(this.context, 'pages/application-secondary', null); + }).catch((error) => { + console.log(TAG + 'Special branch getBundleInfo failed:' + JSON.stringify(error)); + this.context.terminateSelf(); + }); + } catch (error) { + console.error(TAG + 'Special branch failed: ' + JSON.stringify(error)); + } } }; diff --git a/permissionmanager/src/main/resources/base/element/string.json b/permissionmanager/src/main/resources/base/element/string.json index e89538b..63734fb 100644 --- a/permissionmanager/src/main/resources/base/element/string.json +++ b/permissionmanager/src/main/resources/base/element/string.json @@ -130,7 +130,7 @@ }, { "name":"get_the_exact_position", - "value":"Allow this app to access your precise location. When disabled, this app can only access your approximate location. Some apps that don't support this feature may fail to get any location." + "value":"Allow this app to access your precise location. When this is off, this app can only access your approximate location. Some apps that don't support this feature may fail to get any location." }, { "name":"close_exact_position", diff --git a/permissionmanager/src/main/resources/zh_TW/element/string.json b/permissionmanager/src/main/resources/zh_TW/element/string.json index caf768a..18fc6b7 100644 --- a/permissionmanager/src/main/resources/zh_TW/element/string.json +++ b/permissionmanager/src/main/resources/zh_TW/element/string.json @@ -30,7 +30,7 @@ }, { "name":"close_exact_position", - "value":"停用精確位置後,應用程式取得的位置會有所偏差" + "value":"停用精確位置後,應用程式取得的位置會有所偏差。" }, { "name":"precise_location", @@ -58,7 +58,7 @@ }, { "name":"per_use_query", - "value":"每次使用前詢問" + "value":"每次使用時詢問" }, { "name":"pasteBoard_desc", diff --git a/permissionmanager/src/main/resources/zz_ZX/element/string.json b/permissionmanager/src/main/resources/zz_ZX/element/string.json index 94608f4..391a541 100644 --- a/permissionmanager/src/main/resources/zz_ZX/element/string.json +++ b/permissionmanager/src/main/resources/zz_ZX/element/string.json @@ -26,7 +26,7 @@ }, { "name":"get_the_exact_position", - "value":"[TS_950720]_Allow this app to access your precise location. When disabled, this app can only access your approximate location. Some apps that don't support this feature may fail to get any location." + "value":"[TS_950720]_Allow this app to access your precise location. When this is off, this app can only access your approximate location. Some apps that don't support this feature may fail to get any location." }, { "name":"close_exact_position", -- Gitee