diff --git a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts index 25c840bbad487fe2255b445365dab9ccf012edaa..bb946503f6ad0c9227708c0fd828c588fed5eb36 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 e89538bc2894f4230787748d3c8edb2688d50069..63734fbb87d0f90b085307a25b6d8b9b5fdd9118 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 caf768a8d568190dc854dc3d824416b4805cb47a..18fc6b708e1ca6f32d7da1b0ae416f54aba93748 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 94608f41f4f94e01cfa252537d84e1701a2498ed..391a54153a6c09e8e5473256a4a9bd7c1594a003 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",