From 6c107eb5beefa705bb88ab558348b93a58f07ab4 Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Tue, 15 Mar 2022 18:31:09 +0800 Subject: [PATCH 1/4] permissionState Signed-off-by: fanchenxuan --- .../GrantAbility/common/components/dialog.ets | 28 ++++++------------- .../GrantAbility/common/utils/constant.ets | 6 ++++ 2 files changed, 14 insertions(+), 20 deletions(-) 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 c5475146e..8b816b481 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 @@ -163,18 +163,12 @@ export struct privacyDialog { }) } - getgrantGroups() { - var acManager = abilityAccessCtrl.createAtManager() - var num =0 - this.reqPerms.forEach(async (permission, idx) => { - var flag = await acManager.getPermissionFlags(this.accessTokenId, permission) - if(flag == this.userFixedFlag) { + getgrantGroups(stateGroup) { + this.reqPerms.forEach((permission, idx) => { + if(stateGroup[idx] == Constants.PASS_OPER) { console.log(TAG + "permission has been fixed:" + permission) - var ret = await acManager.verifyAccessToken(this.accessTokenId, permission) - if(ret == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { - this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; - } - }else { + this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; + }else if(stateGroup[idx] == Constants.DYNAMIC_OPER) { var group = getPermissionGroup(permission) if(!group) { console.log(TAG + "permission not find:" + permission) @@ -185,15 +179,8 @@ 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 } aboutToAppear() { @@ -214,8 +201,9 @@ export struct privacyDialog { return } console.log(TAG + "request permission=" + JSON.stringify(this.reqPerms) + ", tokenId = " + this.accessTokenId) + console.log(TAG + "permission state=" + JSON.stringify(want.parameters['ohos.user.grant.permission.state'])); this.result = new Array(this.reqPerms.length).fill(-1); - this.getgrantGroups(); + this.getgrantGroups(want.parameters['ohos.user.grant.permission.state']); this.getApplicationName(want.parameters['ohos.aafwk.param.callerUid']) }) } diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets index ca3480021..2042b6faa 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets @@ -48,4 +48,10 @@ export default class Constants { static RESULT_SUCCESS = 1 static RESULT_FAILURE = 0 + + // + static SETTING_OPER = -1 + static PASS_OPER = 0 + static DYNAMIC_OPER = 1 + static INVALID_OPER = 2 } \ No newline at end of file -- Gitee From c132626e9a0457c583fe0877089665e0b59d1afc Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Fri, 18 Mar 2022 16:34:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanchenxuan --- .../com.ohos.permissionmanager/build.gradle | 15 +++++++++++++++ .../com.ohos.permissionmanager/gradle.properties | 15 +++++++++++++++ .../src/main/resources/base/element/string.json | 4 ++-- .../main/resources/base/media/ic_call_logs.svg | 1 - .../src/main/resources/base/media/ic_exercise.svg | 1 - .../src/main/resources/base/media/ic_forward.svg | 1 - .../com.ohos.permissionmanager/settings.gradle | 15 +++++++++++++++ 7 files changed, 47 insertions(+), 5 deletions(-) diff --git a/frameworks/com.ohos.permissionmanager/build.gradle b/frameworks/com.ohos.permissionmanager/build.gradle index f1b1a556a..35a87ae70 100644 --- a/frameworks/com.ohos.permissionmanager/build.gradle +++ b/frameworks/com.ohos.permissionmanager/build.gradle @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'com.huawei.ohos.app' diff --git a/frameworks/com.ohos.permissionmanager/gradle.properties b/frameworks/com.ohos.permissionmanager/gradle.properties index be492496f..eff9877ed 100644 --- a/frameworks/com.ohos.permissionmanager/gradle.properties +++ b/frameworks/com.ohos.permissionmanager/gradle.properties @@ -1,3 +1,18 @@ +# +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Project-wide Gradle settings. # IDE (e.g. DevEco Studio) users: # Gradle settings configured through the IDE *will override* diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json index f505eefa0..bccb54162 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json @@ -46,7 +46,7 @@ }, { "name": "authority_message", - "value": "近7天的应用访问权限" + "value": "近 7 天的应用访问权限" }, { "name": "other_permissions", @@ -78,7 +78,7 @@ }, { "name": "location_info_message", - "value": "系统定位服务开关开启时,已允许19个应用获取此设备的位置。" + "value": "系统定位服务开关开启时,已允许 19 个应用获取此设备的位置。" }, { "name": "description_grantability", diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg index 42f8ad97c..792777f91 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg @@ -1,5 +1,4 @@ - diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg index b488a4243..e31feee74 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg @@ -1,5 +1,4 @@ - - diff --git a/frameworks/com.ohos.permissionmanager/settings.gradle b/frameworks/com.ohos.permissionmanager/settings.gradle index 4bc3f8f55..e34e79a3b 100644 --- a/frameworks/com.ohos.permissionmanager/settings.gradle +++ b/frameworks/com.ohos.permissionmanager/settings.gradle @@ -1 +1,16 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + include ':entry', ':permissionmanager' -- Gitee From 5f746af3547d7236ff332dc60ad590f019a6e3d8 Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Fri, 18 Mar 2022 16:37:04 +0800 Subject: [PATCH 3/4] Revert "permissionState" This reverts commit 6c107eb5beefa705bb88ab558348b93a58f07ab4. Signed-off-by: fanchenxuan --- .../GrantAbility/common/components/dialog.ets | 28 +++++++++++++------ .../GrantAbility/common/utils/constant.ets | 6 ---- 2 files changed, 20 insertions(+), 14 deletions(-) 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 8b816b481..c5475146e 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 @@ -163,12 +163,18 @@ export struct privacyDialog { }) } - getgrantGroups(stateGroup) { - this.reqPerms.forEach((permission, idx) => { - if(stateGroup[idx] == Constants.PASS_OPER) { + getgrantGroups() { + var acManager = abilityAccessCtrl.createAtManager() + var num =0 + this.reqPerms.forEach(async (permission, idx) => { + var flag = await acManager.getPermissionFlags(this.accessTokenId, permission) + if(flag == this.userFixedFlag) { console.log(TAG + "permission has been fixed:" + permission) - this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; - }else if(stateGroup[idx] == Constants.DYNAMIC_OPER) { + var ret = await acManager.verifyAccessToken(this.accessTokenId, permission) + if(ret == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; + } + }else { var group = getPermissionGroup(permission) if(!group) { console.log(TAG + "permission not find:" + permission) @@ -179,8 +185,15 @@ 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 } aboutToAppear() { @@ -201,9 +214,8 @@ export struct privacyDialog { return } console.log(TAG + "request permission=" + JSON.stringify(this.reqPerms) + ", tokenId = " + this.accessTokenId) - console.log(TAG + "permission state=" + JSON.stringify(want.parameters['ohos.user.grant.permission.state'])); this.result = new Array(this.reqPerms.length).fill(-1); - this.getgrantGroups(want.parameters['ohos.user.grant.permission.state']); + this.getgrantGroups(); this.getApplicationName(want.parameters['ohos.aafwk.param.callerUid']) }) } diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets index 2042b6faa..ca3480021 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/GrantAbility/common/utils/constant.ets @@ -48,10 +48,4 @@ export default class Constants { static RESULT_SUCCESS = 1 static RESULT_FAILURE = 0 - - // - static SETTING_OPER = -1 - static PASS_OPER = 0 - static DYNAMIC_OPER = 1 - static INVALID_OPER = 2 } \ No newline at end of file -- Gitee From aaadc8ceabea8732c3e90a032334baaa4d1ac0e5 Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Tue, 22 Mar 2022 16:18:40 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanchenxuan --- .../src/main/resources/base/element/string.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json index bccb54162..7d352989d 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json @@ -44,10 +44,6 @@ "name": "authority_tertiary_description", "value": "个应用获取此权限" }, - { - "name": "authority_message", - "value": "近 7 天的应用访问权限" - }, { "name": "other_permissions", "value": "其它权限" @@ -76,10 +72,6 @@ "name": "banned", "value": "已禁止" }, - { - "name": "location_info_message", - "value": "系统定位服务开关开启时,已允许 19 个应用获取此设备的位置。" - }, { "name": "description_grantability", "value": "eTS_Empty Ability" -- Gitee