From b22e317871bb55b58e067e7a0329a4e896a2c62c Mon Sep 17 00:00:00 2001 From: huangxiaoyao <976125628@qq.com> Date: Tue, 19 Mar 2024 17:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3tokenId=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangxiaoyao <976125628@qq.com> --- .../example/ohos/entry/src/main/module.json5 | 2 ++ .../ets/com/baseflow/permissionhandler/PermissionManager.ets | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/permission_handler_ohos/example/ohos/entry/src/main/module.json5 b/permission_handler_ohos/example/ohos/entry/src/main/module.json5 index c762b55..2e59d7e 100644 --- a/permission_handler_ohos/example/ohos/entry/src/main/module.json5 +++ b/permission_handler_ohos/example/ohos/entry/src/main/module.json5 @@ -51,6 +51,8 @@ {"name": "ohos.permission.READ_CALENDAR"}, {"name": "ohos.permission.WRITE_CALENDAR"}, {"name": "ohos.permission.CAMERA"}, + {"name": "ohos.permission.READ_CONTACTS"}, + {"name": "ohos.permission.WRITE_CONTACTS"}, {"name": "ohos.permission.LOCATION_IN_BACKGROUND"}, {"name": "ohos.permission.LOCATION"}, {"name": "ohos.permission.APPROXIMATELY_LOCATION"}, diff --git a/permission_handler_ohos/ohos/permissionhandler/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets b/permission_handler_ohos/ohos/permissionhandler/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets index 1e354d5..1f49d03 100644 --- a/permission_handler_ohos/ohos/permissionhandler/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets +++ b/permission_handler_ohos/ohos/permissionhandler/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets @@ -98,6 +98,10 @@ export class PermissionManager { successCallback.onSuccess(PermissionConstants.PERMISSION_STATUS_GRANTED); return; } + if (this.tokenId == null || this.tokenId == undefined) { + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION) + this.tokenId = bundleInfo.appInfo.accessTokenId; + } let status: abilityAccessCtrl.GrantStatus = this.atManager.verifyAccessTokenSync(this.tokenId, name as Permissions); if (status != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { successCallback.onSuccess(PermissionConstants.PERMISSION_STATUS_DENIED); -- Gitee