Skip to content

Commit

Permalink
修正 BLUETOOTH_SCAN 权限对 targetSdk 版本检查
Browse files Browse the repository at this point in the history
修正 READ_MEDIA_VIDEO、WRITE_EXTERNAL_STORAGE 权限不能同时申请的问题
  • Loading branch information
getActivity committed Apr 9, 2024
1 parent 2e54b24 commit 9aa3e1c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* project address: [Github](https://github.com/getActivity/XXPermissions)

* [Click here to download demo apk directly](https://github.com/getActivity/XXPermissions/releases/download/18.62/XXPermissions.apk)
* [Click here to download demo apk directly](https://github.com/getActivity/XXPermissions/releases/download/18.63/XXPermissions.apk)

![](picture/en/demo_request_permission_activity.jpg) ![](picture/en/demo_request_single_permission.jpg) ![](picture/en/demo_request_group_permission.jpg)

Expand Down Expand Up @@ -55,7 +55,7 @@ android {
dependencies {
// Permission request framework:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:18.62'
implementation 'com.github.getActivity:XXPermissions:18.63'
}
```

Expand Down Expand Up @@ -217,7 +217,7 @@ XXPermissions.setInterceptor(new OnPermissionInterceptor() {});

| Adaptation details | [XXPermissions](https://github.com/getActivity/XXPermissions) | [AndPermission](https://github.com/yanzhenjie/AndPermission) | [PermissionX](https://github.com/guolindev/PermissionX) | [AndroidUtilCode-PermissionUtils](https://github.com/Blankj/AndroidUtilCode) | [PermissionsDispatcher](https://github.com/permissions-dispatcher/PermissionsDispatcher) | [RxPermissions](https://github.com/tbruyelle/RxPermissions) | [EasyPermissions](https://github.com/googlesamples/easypermissions) |
|:-------------------------------------------------------------:| :----------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: |
| Corresponding version | 18.62 | 2.0.3 | 1.7.1 | 1.31.0 | 4.9.2 | 0.12 | 3.0.0 |
| Corresponding version | 18.63 | 2.0.3 | 1.7.1 | 1.31.0 | 4.9.2 | 0.12 | 3.0.0 |
| Number of issues | [![](https://img.shields.io/github/issues/getActivity/XXPermissions.svg)](https://github.com/getActivity/XXPermissions/issues) | [![](https://img.shields.io/github/issues/yanzhenjie/AndPermission.svg)](https://github.com/yanzhenjie/AndPermission/issues) | [![](https://img.shields.io/github/issues/guolindev/PermissionX.svg)](https://github.com/guolindev/PermissionX/issues) | [![](https://img.shields.io/github/issues/Blankj/AndroidUtilCode.svg)](https://github.com/Blankj/AndroidUtilCode/issues) | [![](https://img.shields.io/github/issues/permissions-dispatcher/PermissionsDispatcher.svg)](https://github.com/permissions-dispatcher/PermissionsDispatcher/issues) | [![](https://img.shields.io/github/issues/tbruyelle/RxPermissions.svg)](https://github.com/tbruyelle/RxPermissions/issues) | [![](https://img.shields.io/github/issues/googlesamples/easypermissions.svg)](https://github.com/googlesamples/easypermissions/issues) |
| Framework volume | 85 KB | 127 KB | 97 KB | 500 KB | 99 KB | 28 KB | 48 KB |
| Framework Maintenance Status | **In maintenance** | stop maintenance | **In maintenance** | stop maintenance | stop maintenance | stop maintenance | stop maintenance |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* 博文地址:[一句代码搞定权限请求,从未如此简单](https://www.jianshu.com/p/c69ff8a445ed)

* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/XXPermissions/releases/download/18.62/XXPermissions.apk)
* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/XXPermissions/releases/download/18.63/XXPermissions.apk)

![](picture/zh/download_demo_apk_qr_code.png)

Expand Down Expand Up @@ -61,7 +61,7 @@ android {
dependencies {
// 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:18.62'
implementation 'com.github.getActivity:XXPermissions:18.63'
}
```

Expand Down Expand Up @@ -223,7 +223,7 @@ XXPermissions.setInterceptor(new OnPermissionInterceptor() {});

| 适配细节 | [XXPermissions](https://github.com/getActivity/XXPermissions) | [AndPermission](https://github.com/yanzhenjie/AndPermission) | [PermissionX](https://github.com/guolindev/PermissionX) | [AndroidUtilCode-PermissionUtils](https://github.com/Blankj/AndroidUtilCode) | [PermissionsDispatcher](https://github.com/permissions-dispatcher/PermissionsDispatcher) | [RxPermissions](https://github.com/tbruyelle/RxPermissions) | [EasyPermissions](https://github.com/googlesamples/easypermissions) |
| :--------: | :------------: | :------------: | :------------: | :------------: | :------------: | :------------: | :------------: |
| 对应版本 | 18.62 | 2.0.3 | 1.7.1 | 1.31.0 | 4.9.2 | 0.12 | 3.0.0 |
| 对应版本 | 18.63 | 2.0.3 | 1.7.1 | 1.31.0 | 4.9.2 | 0.12 | 3.0.0 |
| issues 数 | [![](https://img.shields.io/github/issues/getActivity/XXPermissions.svg)](https://github.com/getActivity/XXPermissions/issues) | [![](https://img.shields.io/github/issues/yanzhenjie/AndPermission.svg)](https://github.com/yanzhenjie/AndPermission/issues) | [![](https://img.shields.io/github/issues/guolindev/PermissionX.svg)](https://github.com/guolindev/PermissionX/issues) | [![](https://img.shields.io/github/issues/Blankj/AndroidUtilCode.svg)](https://github.com/Blankj/AndroidUtilCode/issues) | [![](https://img.shields.io/github/issues/permissions-dispatcher/PermissionsDispatcher.svg)](https://github.com/permissions-dispatcher/PermissionsDispatcher/issues) | [![](https://img.shields.io/github/issues/tbruyelle/RxPermissions.svg)](https://github.com/tbruyelle/RxPermissions/issues) | [![](https://img.shields.io/github/issues/googlesamples/easypermissions.svg)](https://github.com/googlesamples/easypermissions/issues) |
| 框架体积 | 85 KB | 127 KB | 97 KB | 500 KB | 99 KB | 28 KB | 48 KB |
| 框架维护状态 |**维护中**| 停止维护 | 停止维护 | 停止维护 | 停止维护 | 停止维护 | 停止维护 |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.hjq.permissions.demo"
minSdkVersion 16
targetSdkVersion 34
versionCode 1862
versionName "18.62"
versionCode 1863
versionName "18.63"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh/strings_permission.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="common_permission_contacts">通讯录权限</string>
<string name="common_permission_location">定位权限</string>
<string name="common_permission_location_background">后台定位权限</string>
<string name="common_permission_nearby_devices">附近的设备权限</string>
<string name="common_permission_nearby_devices">附近设备权限</string>
<string name="common_permission_microphone">麦克风权限</string>
<string name="common_permission_phone">电话权限</string>
<string name="common_permission_call_logs">通话记录权限</string>
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {

defaultConfig {
minSdkVersion 14
versionCode 1862
versionName "18.62"
versionCode 1863
versionName "18.63"
}

// 使用 JDK 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ static void checkStoragePermission(@NonNull Context context, @NonNull List<Strin
PermissionUtils.containsPermission(requestPermissions, Permission.READ_MEDIA_VIDEO) ||
PermissionUtils.containsPermission(requestPermissions, Permission.READ_MEDIA_AUDIO)) {

if (PermissionUtils.containsPermission(requestPermissions, Permission.READ_EXTERNAL_STORAGE) ||
PermissionUtils.containsPermission(requestPermissions, Permission.WRITE_EXTERNAL_STORAGE)) {
// 检测是否有旧版的存储权限,有的话直接抛出异常,请不要自己动态申请这两个权限
if (PermissionUtils.containsPermission(requestPermissions, Permission.READ_EXTERNAL_STORAGE)) {
// 检测是否有旧版的存储权限,有的话直接抛出异常,请不要自己动态申请这个权限
// 框架会在 Android 13 以下的版本上自动添加并申请这两个权限
throw new IllegalArgumentException("If you have applied for media permissions, " +
"do not apply for the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions");
Expand Down Expand Up @@ -485,6 +484,10 @@ static void checkTargetSdkVersion(@NonNull Context context, @NonNull List<String
// READ_MEDIA_VISUAL_USER_SELECTED 这个权限比较特殊,不需要调高 targetSdk 的版本才能申请,但是需要和 READ_MEDIA_IMAGES 和 READ_MEDIA_VIDEO 组合使用
// 这个权限不能单独申请,只能和 READ_MEDIA_IMAGES、READ_MEDIA_VIDEO 一起申请,否则会有问题,所以这个权限的 targetSdk 最低要求为 33 及以上
targetSdkMinVersion = AndroidVersion.ANDROID_13;
} else if (PermissionUtils.equalsPermission(permission, Permission.BLUETOOTH_SCAN)) {
// 部分厂商修改了蓝牙权限机制,在 targetSdk 不满足条件的情况下(小于 31),仍需要让应用申请这个权限
// issue 地址:https://github.com/getActivity/XXPermissions/issues/123
targetSdkMinVersion = AndroidVersion.ANDROID_6;
} else {
targetSdkMinVersion = Permission.getPermissionFromAndroidVersion(permission);
}
Expand Down

0 comments on commit 9aa3e1c

Please sign in to comment.