From 73e63e1500f65ee2dce5f92039372149acb8cfba Mon Sep 17 00:00:00 2001 From: "apang.men" Date: Mon, 10 Feb 2025 17:46:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=93=9D=E7=89=99=E6=9D=83=E9=99=90=E4=B8=80=E7=9B=B4=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: apang.men --- permission_handler/pubspec.yaml | 5 +---- .../permissionhandler/PermissionManager.ets | 19 +++++++++++++++++-- .../permissionhandler/PermissionUtils.ets | 3 ++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/permission_handler/pubspec.yaml b/permission_handler/pubspec.yaml index cbe10b9..47ae10c 100644 --- a/permission_handler/pubspec.yaml +++ b/permission_handler/pubspec.yaml @@ -28,10 +28,7 @@ dependencies: permission_handler_apple: ^9.1.1 permission_handler_windows: ^0.1.3 permission_handler_ohos: - git: - url: https://gitee.com/openharmony-sig/flutter_permission_handler.git - ref: master - path: permission_handler_ohos + path: ../permission_handler_ohos permission_handler_platform_interface: ^3.11.0 dev_dependencies: diff --git a/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets b/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets index 7b8e3df..4bd1b7b 100644 --- a/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets +++ b/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionManager.ets @@ -177,7 +177,17 @@ export class PermissionManager { } } else { - this.requestResults?.set(permission, PermissionUtils.toPermissionStatus(authResult)); + // this.requestResults?.set(permission, PermissionUtils.toPermissionStatus(authResult)); + let hasDialog: boolean | null = null; + if (result.dialogShownResults != undefined) { + hasDialog = result.dialogShownResults[i]; + } + if (authResult == -1 && hasDialog == false) { + //用户已经拒绝,需要打开设置页面进行授权 + this.requestResults?.set(permission, PermissionConstants.PERMISSION_STATUS_NEVER_ASK_AGAIN); + } else { + this.requestResults?.set(permission, PermissionUtils.toPermissionStatus(authResult)); + } } PermissionUtils.updatePermissionShouldShowStatus(permission); } @@ -257,7 +267,12 @@ export class PermissionManager { Log.d(PermissionConstants.LOG_TAG, "Bluetooth permission missing in manifest"); successCallback.onSuccess(PermissionConstants.PERMISSION_STATUS_DENIED); } else { - successCallback.onSuccess(PermissionConstants.PERMISSION_STATUS_GRANTED); + // successCallback.onSuccess(PermissionConstants.PERMISSION_STATUS_GRANTED); + this.checkPermission( { + onSuccess: (permissionStatus: number) => { + successCallback.onSuccess(permissionStatus == -1 ? 0 : 1); + } + } as ESObject ,'ohos.permission.ACCESS_BLUETOOTH'); } }); } diff --git a/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionUtils.ets b/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionUtils.ets index 7d895a8..f74fa16 100644 --- a/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionUtils.ets +++ b/permission_handler_ohos/ohos/src/main/ets/com/baseflow/permissionhandler/PermissionUtils.ets @@ -76,8 +76,9 @@ export default class PermissionUtils { case 'ohos.permission.DISCOVER_BLUETOOTH': return PermissionConstants.PERMISSION_GROUP_BLUETOOTH_ADVERTISE; case 'ohos.permission.MANAGE_BLUETOOTH': - case 'ohos.permission.ACCESS_BLUETOOTH': return PermissionConstants.PERMISSION_GROUP_BLUETOOTH_CONNECT; + case 'ohos.permission.ACCESS_BLUETOOTH': + return PermissionConstants.PERMISSION_GROUP_BLUETOOTH; case 'ohos.permission.NOTIFICATION_CONTROLLER': return PermissionConstants.PERMISSION_GROUP_NOTIFICATION; case 'ohos.permission.NEARBY_WIFI_DEVICES': -- Gitee From 7548ad6efc449e2a8039f7acf8af9cdc6a9546ac Mon Sep 17 00:00:00 2001 From: "apang.men" Date: Mon, 10 Feb 2025 18:37:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9pubspec.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: apang.men --- permission_handler/pubspec.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/permission_handler/pubspec.yaml b/permission_handler/pubspec.yaml index 47ae10c..2aee260 100644 --- a/permission_handler/pubspec.yaml +++ b/permission_handler/pubspec.yaml @@ -28,7 +28,11 @@ dependencies: permission_handler_apple: ^9.1.1 permission_handler_windows: ^0.1.3 permission_handler_ohos: - path: ../permission_handler_ohos + git: + url: https://gitee.com/openharmony-sig/flutter_permission_handler.git + ref: master + path: permission_handler_ohos + permission_handler_platform_interface: ^3.11.0 dev_dependencies: -- Gitee