diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/components/dialog.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/components/dialog.ets index c5475146e375c29b557fa396563bbfdd7e716fa4..e76848bc46f77a125dc19f2114c1ed8bb31705da 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/components/dialog.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/components/dialog.ets @@ -116,16 +116,7 @@ export struct privacyDialog { if (this.initStatus == Constants.INIT_NEED_TO_TERMINATED) { ret = Constants.RESULT_FAILURE } - console.log(TAG + "code:" + ret + ", result=" + JSON.stringify(this.result)) - featureAbility.terminateSelfWithResult({ - resultCode: ret, - want: { - parameters: { - "ohos.user.grant.permission": this.reqPerms, - "ohos.user.grant.permission.result": this.result - } - } - }) + this.answer(ret, this.reqPerms) } verify() { @@ -187,10 +178,27 @@ export struct privacyDialog { } num ++ if(num == this.reqPerms.length) { - if(this.grantGroups.length == 0) { - this.initStatus = Constants.INIT_NEED_TO_TERMINATED - }else { - this.initStatus = Constants.INIT_NEED_TO_VERIFY + this.initStatus = Constants.INIT_NEED_TO_VERIFY + } + }) + } + + answer(ret, reqPerms) { + console.log(TAG + "code:" + ret + ", perms="+ JSON.stringify(reqPerms) +", result=" + JSON.stringify(this.result)) + var perms = [] + var results = [] + reqPerms.forEach(perm => { + perms.push(perm) + }) + this.result.forEach(result => { + results.push(result) + }) + featureAbility.terminateSelfWithResult({ + resultCode: ret, + want: { + parameters: { + "ohos.user.grant.permission": perms, + "ohos.user.grant.permission.result": results } } }) diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/application-secondary.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/application-secondary.ets index 4ec9944b51a76858c80b306f7202d1bfb49821b3..baea56ee824a811e93de44bf8d5ee0e4831e6a18 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/application-secondary.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/application-secondary.ets @@ -23,18 +23,19 @@ var TAG = 'PermissionManager_MainAbility:' const allowedStatus = 0; // Status: Allowed const bannedStatus = 1; // Status: Banned + class AllowedObj { groupName: string; - permission: string; - constructor(groupName: string, permission: string) { + permission: string[]; + constructor(groupName: string, permission: string[]) { this.groupName = groupName; this.permission = permission; } } // Class Allowed class BannedObj { groupName: string; - permission: string; - constructor(groupName: string, permission: string) { + permission: string[]; + constructor(groupName: string, permission: string[]) { this.groupName = groupName; this.permission = permission; } @@ -134,28 +135,39 @@ struct appNamePlusPage { * Initialize permission status information and group permission information */ async initialPermissions() { - var reqGroups = this.routerData.permissions; - if (!reqGroups.length) { + var reqPermissions = this.routerData.permissions; + var reqGroupIds = this.routerData.groupId; + + if (!reqGroupIds.length) { this.allowedListItem = []; this.bannedListItem = []; return; } - var ids = this.routerData.groupId; - for (var i = 0; i < reqGroups.length; i++) { - var isGranted = true; - var reqPermissions = groups[ids[i]].permissions; - for (var j = 0; j < reqPermissions.length; j++) { - var res = await abilityAccessCtrl.createAtManager().verifyAccessToken( - this.routerData.tokenId, reqPermissions[j]); + + for (let i = 0; i < reqGroupIds.length; i++) { + let id = reqGroupIds[i]; + let groupName = groups[id].groupName; + let groupReqPermissons = []; + for (let j = 0; j < reqPermissions.length; j++) { + let permission = reqPermissions[j]; + if (groups[id].permissions.indexOf(permission) != -1) { + groupReqPermissons.push(permission) + } + } + let isGranted = true; + for (let i = 0; i < groupReqPermissons.length; i++) { + let permission = groupReqPermissons[i] + let res = await abilityAccessCtrl.createAtManager().verifyAccessToken( + this.routerData.tokenId, permission); if (res != 0) { isGranted = false; - break; } } + if (isGranted) { - this.allowedListItem.push(new AllowedObj(groups[ids[i]].groupName, reqPermissions)); + this.allowedListItem.push(new AllowedObj(groupName, groupReqPermissons)); } else { - this.bannedListItem.push(new BannedObj(groups[ids[i]].groupName, reqPermissions)); + this.bannedListItem.push(new BannedObj(groupName, groupReqPermissons)); } } } @@ -164,6 +176,7 @@ struct appNamePlusPage { * Lifecycle function, triggered once when this page is displayed */ onPageShow() { + console.log(TAG + 'onPageShow') this.initialPermissions(); } @@ -171,6 +184,7 @@ struct appNamePlusPage { * Lifecycle function, triggered once when this page disappears */ onPageHide() { + console.log(TAG + 'onPageHide') setTimeout(()=> { this.allowedListItem = []; this.bannedListItem = []; diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/authority-management.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/authority-management.ets index 318e24e6aef581d3613e8f22408b8f31ae95f096..9b89c86beeb5ee665307d1ab43324ebdb070f178 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/authority-management.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/pages/authority-management.ets @@ -241,7 +241,7 @@ struct authorityManagementPage { var icon: string = permissionGroup.icon; var bundleNames: string[] = []; for (let j = 0; j < this_.allApplicationPermissions.length; j++) { - if (this_.allApplicationPermissions[j].permissions.indexOf(permissionGroup.name) != -1) { + if (this_.allApplicationPermissions[j].permissions.indexOf(this_.allUserPermissions[i]) != -1) { bundleNames.push(this_.allApplicationPermissions[j].bundleName); } } @@ -363,7 +363,7 @@ struct authorityManagementPage { 'tokenId': info.appInfo.accessTokenId, 'iconId': info.appInfo.iconId, 'labelId': info.appInfo.labelId, - 'permissions': dePermissions, + 'permissions': reqUserPermissions, 'groupId': groupIds }; allApplicationPermissions.push(ap);