|
|
|
@ -12,7 +12,7 @@ class PermissionsController extends GetxController { |
|
|
|
|
|
|
|
// 是否正在请求权限 |
|
|
|
final RxBool isRequestingPermission = false.obs; |
|
|
|
|
|
|
|
|
|
|
|
// Android版本信息(用于权限组显示判断) |
|
|
|
final RxInt androidSdkVersion = 0.obs; |
|
|
|
|
|
|
|
@ -22,7 +22,7 @@ class PermissionsController extends GetxController { |
|
|
|
_initAndroidVersion(); |
|
|
|
checkAllPermissions(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 初始化Android版本信息 |
|
|
|
Future<void> _initAndroidVersion() async { |
|
|
|
if (Platform.isAndroid) { |
|
|
|
@ -36,7 +36,7 @@ class PermissionsController extends GetxController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 检查是否应该显示蓝牙权限组 |
|
|
|
bool shouldShowBluetoothPermissions() { |
|
|
|
if (Platform.isAndroid) { |
|
|
|
@ -48,7 +48,7 @@ class PermissionsController extends GetxController { |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 检查是否应该显示存储权限组 |
|
|
|
bool shouldShowStoragePermissions() { |
|
|
|
if (Platform.isAndroid) { |
|
|
|
@ -109,22 +109,22 @@ class PermissionsController extends GetxController { |
|
|
|
/// 获取平台特定的权限列表 |
|
|
|
Future<List<Permission>> _getPlatformPermissions() async { |
|
|
|
final bluetoothPermissions = await _getBluetoothPermissions(); |
|
|
|
|
|
|
|
|
|
|
|
if (Platform.isIOS) { |
|
|
|
final List<Permission> permissions = [ |
|
|
|
Permission.calendarFullAccess, |
|
|
|
Permission.location, |
|
|
|
Permission.contacts, |
|
|
|
...bluetoothPermissions, |
|
|
|
//...bluetoothPermissions, |
|
|
|
Permission.notification, |
|
|
|
Permission.microphone, |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
// iOS系统不添加存储权限(根据shouldShowStoragePermissions方法) |
|
|
|
if (shouldShowStoragePermissions()) { |
|
|
|
permissions.add(Permission.storage); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return permissions; |
|
|
|
} else if (Platform.isAndroid) { |
|
|
|
final List<Permission> permissions = [ |
|
|
|
@ -138,12 +138,12 @@ class PermissionsController extends GetxController { |
|
|
|
Permission.scheduleExactAlarm, |
|
|
|
Permission.microphone, |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
// 只在Android 10及以下版本添加存储权限 |
|
|
|
if (shouldShowStoragePermissions()) { |
|
|
|
permissions.add(Permission.storage); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return permissions; |
|
|
|
} |
|
|
|
return []; |
|
|
|
|