Commit 0be05e5d by Jeroen Weener Committed by GitHub

Allow querying Bluetooth service status on iOS (platform interface) (#1099)

* Change `Permission.bluetooth` from `Permission` to `PermissionWithService`

* Updates permission documentation
parent 069045be
## 3.11.2
* Changes `Permission.bluetooth` into an instance of `PermissionWithService` instead of `Permission` in order to determine iOS native's `CBManagerStatePoweredOn`.
## 3.11.1 ## 3.11.1
* Updates the documentation for the `Permission.storage` permission regarding its use on Android. * Updates the documentation for the `Permission.storage` permission regarding its use on Android.
......
part of permission_handler_platform_interface; part of permission_handler_platform_interface;
/// A special kind of permission used to access a service. Additionally to the /// A special kind of permission, used to access a service.
/// actions that normal [Permission]s have, you can also query the status of ///
/// the related service. /// Additionally to the actions that normal [Permission]s have, you can also
/// query the status of the related service.
class PermissionWithService extends Permission { class PermissionWithService extends Permission {
const PermissionWithService._(int value) : super._(value); const PermissionWithService._(int value) : super._(value);
...@@ -24,122 +25,176 @@ class Permission { ...@@ -24,122 +25,176 @@ class Permission {
/// Integer representation of the [Permission]. /// Integer representation of the [Permission].
final int value; final int value;
/// Permission for accessing the device's calendar.
///
/// Android: Calendar /// Android: Calendar
/// iOS: Calendar (Events) /// iOS: Calendar (Events)
static const calendar = Permission._(0); static const calendar = Permission._(0);
/// Permission for accessing the device's camera.
///
/// Android: Camera /// Android: Camera
/// iOS: Photos (Camera Roll and Camera) /// iOS: Photos (Camera Roll and Camera)
static const camera = Permission._(1); static const camera = Permission._(1);
/// Permission for accessing the device's contacts.
///
/// Android: Contacts /// Android: Contacts
/// iOS: AddressBook /// iOS: AddressBook
static const contacts = Permission._(2); static const contacts = Permission._(2);
/// Permission for accessing the device's location.
///
/// Android: Fine and Coarse Location /// Android: Fine and Coarse Location
/// iOS: CoreLocation (Always and WhenInUse) /// iOS: CoreLocation (Always and WhenInUse)
static const location = PermissionWithService._(3); static const location = PermissionWithService._(3);
/// Android: /// Permission for accessing the device's location when the app is running in
/// When running on Android < Q: Fine and Coarse Location /// the background.
/// When running on Android Q and above: Background Location Permission ///
/// iOS: CoreLocation - Always /// Depending on the platform and version, the requirements are slightly
/// When requesting this permission the user needs to grant permission /// different:
/// for the `locationWhenInUse` permission first, clicking on ///
/// the `Àllow While Using App` option on the popup. /// **Android:**
/// After allowing the permission the user can request the `locationAlways` /// - When running on Android Q and above: Background Location Permission
/// permission and can click on the `Change To Always Allow` option. /// - When running on Android < Q: Fine and Coarse Location
///
/// **iOS:** CoreLocation - Always
/// - When requesting this permission, the user needs to grant permission for
/// the `locationWhenInUse` permission first, clicking on the
/// `Allow While Using App` option on the popup. After allowing the
/// permission, the user can request the `locationAlways` permission and can
/// click on the `Change To Always Allow` option.
static const locationAlways = PermissionWithService._(4); static const locationAlways = PermissionWithService._(4);
/// Permission for accessing the device's location when the app is running in
/// the foreground.
///
/// Android: Fine and Coarse Location /// Android: Fine and Coarse Location
/// iOS: CoreLocation - WhenInUse /// iOS: CoreLocation - WhenInUse
static const locationWhenInUse = PermissionWithService._(5); static const locationWhenInUse = PermissionWithService._(5);
/// Android: None /// Permission for accessing the device's media library (iOS 9.3+ only).
/// iOS: MPMediaLibrary
static const mediaLibrary = Permission._(6); static const mediaLibrary = Permission._(6);
/// Android: Microphone /// Permission for accessing the device's microphone.
/// iOS: Microphone
static const microphone = Permission._(7); static const microphone = Permission._(7);
/// Android: Phone /// Permission for accessing the device's phone state (Android only).
/// iOS: Nothing
static const phone = PermissionWithService._(8); static const phone = PermissionWithService._(8);
/// Android: /// Permission for accessing the device's photos.
/// When running on Android TIRAMISU and above: Read image files from external storage ///
/// When running on Android < TIRAMISU: Nothing /// Photos can be read and added. If you only want to read them, you can
/// iOS: Photos (iOS 14+ read & write access level). /// use the [photos] permission instead (iOS only).
///
/// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - When running on Android TIRAMISU and above: Read image files from
/// external storage
/// - When running on Android < TIRAMISU: Nothing
///
/// **iOS:**
/// - When running Photos (iOS 14+ read & write access level)
static const photos = Permission._(9); static const photos = Permission._(9);
/// Android: Nothing /// Permission for adding photos to the device's photo library (iOS only).
/// iOS: Photos ///
/// iOS 14+ read & write access level /// Photos can only be added. If you want to read them as well, use the
/// [photos] permission instead.
///
/// iOS: Photos (14+ read & write access level)
static const photosAddOnly = Permission._(10); static const photosAddOnly = Permission._(10);
/// Android: Nothing /// Permission for accessing the device's reminders (iOS only).
/// iOS: Reminders
static const reminders = Permission._(11); static const reminders = Permission._(11);
/// Permission for accessing the device's sensors.
///
/// Android: Body Sensors /// Android: Body Sensors
/// iOS: CoreMotion /// iOS: CoreMotion
static const sensors = Permission._(12); static const sensors = Permission._(12);
/// Android: Sms /// Permission for sending and reading SMS messages (Android only).
/// iOS: Nothing
static const sms = Permission._(13); static const sms = Permission._(13);
/// Android: Microphone /// Permission for accessing speech recognition.
/// iOS: Speech ///
/// **Android:**
/// - Requests access to microphone (identical to requesting
/// [Permission.microphone]).
///
/// **iOS:**
/// - Requests speech access (different from requesting
/// [Permission.microphone]).
static const speech = Permission._(14); static const speech = Permission._(14);
/// Android: /// Permission for accessing external storage.
/// On Android < TIRAMISU the `READ_EXTERNAL_STORAGE` and ///
/// `WRITE_EXTERNAL_STORAGE` permissions are requested (depending on the /// Depending on the platform and version, the requirements are slightly
/// definitions in the AndroidManifest.xml) file. /// different:
/// On Android TIRAMISU and higher this permission is deprecrated and ///
/// always returns `PermissionStatus.denied`, instead use /// **Android:**
/// `Permission.photos`, `Permission.video`, `Permission.audio` or /// - On Android TIRAMISU and higher this permission is deprecrated and always
/// `Permission.manageExternalStorage`. For more information see our [FAQ](https://pub.dev/packages/permission_handler#faq). /// returns `PermissionStatus.denied`, instead use `Permission.photos`,
/// iOS: Access to folders like `Documents` or `Downloads`. Implicitly /// `Permission.video`, `Permission.audio` or
/// granted. /// `Permission.manageExternalStorage`. For more information see our
/// [FAQ](https://pub.dev/packages/permission_handler#faq).
/// - On Android < TIRAMISU the `READ_EXTERNAL_STORAGE` and
/// `WRITE_EXTERNAL_STORAGE` permissions are requested (depending on the
/// definitions in the AndroidManifest.xml) file.
///
/// **iOS:**
/// - Access to folders like `Documents` or `Downloads`. Implicitly granted.
static const storage = Permission._(15); static const storage = Permission._(15);
/// Android: Ignore Battery Optimizations /// Permission for accessing ignore battery optimizations (Android only).
static const ignoreBatteryOptimizations = Permission._(16); static const ignoreBatteryOptimizations = Permission._(16);
/// Android: Notification /// Permission for pushing notifications.
/// iOS: Notification
static const notification = Permission._(17); static const notification = Permission._(17);
/// Android: Allows an application to access any geographic locations /// Permission for accessing the device's media library (Android Q+ only).
/// persisted in the user's shared collection. ///
/// Allows an application to access any geographic locations persisted in the
/// user's shared collection.
static const accessMediaLocation = Permission._(18); static const accessMediaLocation = Permission._(18);
/// When running on Android Q and above: Activity Recognition /// Permission for accessing the activity recognition (Android Q+ only).
/// When running on Android < Q: Nothing
/// iOS: Nothing
static const activityRecognition = Permission._(19); static const activityRecognition = Permission._(19);
/// The unknown only used for return type, never requested /// The unknown only used for return type, never requested.
static const unknown = Permission._(20); static const unknown = Permission._(20);
/// iOS 13 and above: The authorization state of Core Bluetooth manager. /// Permission for accessing the device's bluetooth adapter state.
/// When running < iOS 13 or Android this is always allowed. ///
static const bluetooth = Permission._(21); /// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - Always allowed.
///
/// **iOS:**
/// - iOS 13 and above: The authorization state of Core Bluetooth manager.
/// - iOS below 13: always allowed.
static const bluetooth = PermissionWithService._(21);
/// Android: Allows an application a broad access to external storage in /// Permission for accessing the device's external storage. (Android R+ only).
/// scoped storage. ///
/// iOS: Nothing /// Allows an application a broad access to external storage in scoped
/// storage.
/// ///
/// You should request the Manage External Storage permission only when /// You should request the Manage External Storage permission only when
/// your app cannot effectively make use of the more privacy-friendly APIs. /// your app cannot effectively make use of the more privacy-friendly APIs.
/// For more information: https://developer.android.com/training/data-storage/manage-all-files /// For more information:
/// https://developer.android.com/training/data-storage/manage-all-files
/// ///
/// When the privacy-friendly APIs (i.e. [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider) /// When the privacy-friendly APIs (i.e. [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider)
/// or the [MediaStore](https://developer.android.com/training/data-storage/shared/media) APIs) is all your app needs the /// or the [MediaStore](https://developer.android.com/training/data-storage/shared/media) APIs)
/// [PermissionGroup.storage] are the only permissions you need to request. /// is all your app needs, the [PermissionGroup.storage] are the only
/// permissions you need to request.
/// ///
/// If the usage of the Manage External Storage permission is needed, /// If the usage of the Manage External Storage permission is needed,
/// you have to fill out the Permission Declaration Form upon submitting /// you have to fill out the Permission Declaration Form upon submitting
...@@ -147,68 +202,59 @@ class Permission { ...@@ -147,68 +202,59 @@ class Permission {
/// https://support.google.com/googleplay/android-developer/answer/9214102#zippy= /// https://support.google.com/googleplay/android-developer/answer/9214102#zippy=
static const manageExternalStorage = Permission._(22); static const manageExternalStorage = Permission._(22);
///Android: Allows an app to create windows shown on top of all other apps /// Permission for creating system alert window (Android only).
///iOS: Nothing ///
/// Allows an app to create windows shown on top of all other apps.
static const systemAlertWindow = Permission._(23); static const systemAlertWindow = Permission._(23);
///Android: Allows an app to request installing packages. /// Permission for requesting installing packages (Android M+ only).
///iOS: Nothing
static const requestInstallPackages = Permission._(24); static const requestInstallPackages = Permission._(24);
///Android: Nothing /// Permission for accessing the device's tracking state (iOS only).
///iOS: Allows user to accept that your app collects data about end users and ///
///shares it with other companies for purposes of tracking across apps and /// Allows user to accept that your app collects data about end users and
///websites. /// shares it with other companies for purposes of tracking across apps and
/// websites.
static const appTrackingTransparency = Permission._(25); static const appTrackingTransparency = Permission._(25);
///Android: Nothing /// Permission for sending critical alerts (iOS only).
///iOS: Notifications that override your ringer ///
/// Allow for sending notifications that override the ringer.
static const criticalAlerts = Permission._(26); static const criticalAlerts = Permission._(26);
///Android: Allows the user to access the notification policy of the phone. /// Permission for accessing the device's notification policy (Android M+ only).
///
/// Allows the user to access the notification policy of the phone.
/// EX: Allows app to turn on and off do-not-disturb. /// EX: Allows app to turn on and off do-not-disturb.
///iOS: Nothing
static const accessNotificationPolicy = Permission._(27); static const accessNotificationPolicy = Permission._(27);
///Android: Allows the user to look for Bluetooth devices /// Permission for scanning for Bluetooth devices (Android S+ only).
///(e.g. BLE peripherals).
///iOS: Nothing
static const bluetoothScan = Permission._(28); static const bluetoothScan = Permission._(28);
///Android: Allows the user to make this device discoverable to other /// Permission for advertising Bluetooth devices (Android S+ only).
///Bluetooth devices. ///
///iOS: Nothing /// Allows the user to make this device discoverable to other Bluetooth
/// devices.
static const bluetoothAdvertise = Permission._(29); static const bluetoothAdvertise = Permission._(29);
///Android: Allows the user to connect with already paired Bluetooth devices. /// Permission for connecting to Bluetooth devices (Android S+ only).
///iOS: Nothing ///
/// Allows the user to connect with already paired Bluetooth devices.
static const bluetoothConnect = Permission._(30); static const bluetoothConnect = Permission._(30);
///Android: Allows the user to connect to nearby devices via Wi-Fi /// Permission for connecting to nearby devices via Wi-Fi (Android T+ only).
///iOS: Nothing
static const nearbyWifiDevices = Permission._(31); static const nearbyWifiDevices = Permission._(31);
/// Android: /// Permission for accessing the device's video files from external storage (Android T+ only).
/// When running on Android TIRAMISU and above: Read video files from external storage
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
static const videos = Permission._(32); static const videos = Permission._(32);
/// Android: /// Permission for accessing the device's audio files from external storage (Android T+ only).
/// When running on Android TIRAMISU and above: Read audio files from external storage
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
static const audio = Permission._(33); static const audio = Permission._(33);
/// When running on Android S and above: Allows exact alarm functionality /// Permission for scheduling exact alarms (Android S+ only).
/// When running on Android < S: Nothing
///iOS: Nothing
static const scheduleExactAlarm = Permission._(34); static const scheduleExactAlarm = Permission._(34);
/// Android: /// Permission for accessing the device's sensors in background (Android T+ only).
/// When running on Android TIRAMISU and above: Background Sensors Permission
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
static const sensorsAlways = Permission._(35); static const sensorsAlways = Permission._(35);
/// Returns a list of all possible [PermissionGroup] values. /// Returns a list of all possible [PermissionGroup] values.
......
...@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin. ...@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a # NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 3.11.1 version: 3.11.2
dependencies: dependencies:
flutter: flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment