diff --git a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts index 3adc385..14ed32d 100644 --- a/permissionmanager/src/main/ets/MainAbility/MainAbility.ts +++ b/permissionmanager/src/main/ets/MainAbility/MainAbility.ts @@ -183,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/ets/pages/securityDialog.ets b/permissionmanager/src/main/ets/pages/securityDialog.ets index 8627b65..6cf7814 100644 --- a/permissionmanager/src/main/ets/pages/securityDialog.ets +++ b/permissionmanager/src/main/ets/pages/securityDialog.ets @@ -112,7 +112,7 @@ struct SecurityDialog { radius: $r('sys.float.ohos_id_corner_radius_default_m') }) .padding(Constants.PADDING_10) - if(this.index === 1) { + if (this.index === 1) { Image(this.securityParams[this.index].icon) .width(Constants.IMAGE_LENGTH_20) .height(Constants.IMAGE_LENGTH_20)