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
* Updates the documentation for the `Permission.storage` permission regarding its use on Android.
......
part of permission_handler_platform_interface;
/// A special kind of permission used to access a service. Additionally to the
/// actions that normal [Permission]s have, you can also query the status of
/// the related service.
/// A special kind of permission, used to access a service.
///
/// Additionally to the actions that normal [Permission]s have, you can also
/// query the status of the related service.
class PermissionWithService extends Permission {
const PermissionWithService._(int value) : super._(value);
......@@ -24,122 +25,176 @@ class Permission {
/// Integer representation of the [Permission].
final int value;
/// Permission for accessing the device's calendar.
///
/// Android: Calendar
/// iOS: Calendar (Events)
static const calendar = Permission._(0);
/// Permission for accessing the device's camera.
///
/// Android: Camera
/// iOS: Photos (Camera Roll and Camera)
static const camera = Permission._(1);
/// Permission for accessing the device's contacts.
///
/// Android: Contacts
/// iOS: AddressBook
static const contacts = Permission._(2);
/// Permission for accessing the device's location.
///
/// Android: Fine and Coarse Location
/// iOS: CoreLocation (Always and WhenInUse)
static const location = PermissionWithService._(3);
/// Android:
/// When running on Android < Q: Fine and Coarse Location
/// When running on Android Q and above: Background Location Permission
/// iOS: CoreLocation - Always
/// When requesting this permission the user needs to grant permission
/// for the `locationWhenInUse` permission first, clicking on
/// the `Àllow 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.
/// Permission for accessing the device's location when the app is running in
/// the background.
///
/// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - When running on Android Q and above: Background Location Permission
/// - 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);
/// Permission for accessing the device's location when the app is running in
/// the foreground.
///
/// Android: Fine and Coarse Location
/// iOS: CoreLocation - WhenInUse
static const locationWhenInUse = PermissionWithService._(5);
/// Android: None
/// iOS: MPMediaLibrary
/// Permission for accessing the device's media library (iOS 9.3+ only).
static const mediaLibrary = Permission._(6);
/// Android: Microphone
/// iOS: Microphone
/// Permission for accessing the device's microphone.
static const microphone = Permission._(7);
/// Android: Phone
/// iOS: Nothing
/// Permission for accessing the device's phone state (Android only).
static const phone = PermissionWithService._(8);
/// Android:
/// When running on Android TIRAMISU and above: Read image files from external storage
/// When running on Android < TIRAMISU: Nothing
/// iOS: Photos (iOS 14+ read & write access level).
/// Permission for accessing the device's photos.
///
/// Photos can be read and added. If you only want to read them, you can
/// 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);
/// Android: Nothing
/// iOS: Photos
/// iOS 14+ read & write access level
/// Permission for adding photos to the device's photo library (iOS only).
///
/// 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);
/// Android: Nothing
/// iOS: Reminders
/// Permission for accessing the device's reminders (iOS only).
static const reminders = Permission._(11);
/// Permission for accessing the device's sensors.
///
/// Android: Body Sensors
/// iOS: CoreMotion
static const sensors = Permission._(12);
/// Android: Sms
/// iOS: Nothing
/// Permission for sending and reading SMS messages (Android only).
static const sms = Permission._(13);
/// Android: Microphone
/// iOS: Speech
/// Permission for accessing speech recognition.
///
/// **Android:**
/// - Requests access to microphone (identical to requesting
/// [Permission.microphone]).
///
/// **iOS:**
/// - Requests speech access (different from requesting
/// [Permission.microphone]).
static const speech = Permission._(14);
/// Android:
/// On Android < TIRAMISU the `READ_EXTERNAL_STORAGE` and
/// Permission for accessing external storage.
///
/// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - On Android TIRAMISU and higher this permission is deprecrated and always
/// returns `PermissionStatus.denied`, instead use `Permission.photos`,
/// `Permission.video`, `Permission.audio` or
/// `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.
/// On Android TIRAMISU and higher this permission is deprecrated and
/// always returns `PermissionStatus.denied`, instead use
/// `Permission.photos`, `Permission.video`, `Permission.audio` or
/// `Permission.manageExternalStorage`. For more information see our [FAQ](https://pub.dev/packages/permission_handler#faq).
/// iOS: Access to folders like `Documents` or `Downloads`. Implicitly
/// granted.
///
/// **iOS:**
/// - Access to folders like `Documents` or `Downloads`. Implicitly granted.
static const storage = Permission._(15);
/// Android: Ignore Battery Optimizations
/// Permission for accessing ignore battery optimizations (Android only).
static const ignoreBatteryOptimizations = Permission._(16);
/// Android: Notification
/// iOS: Notification
/// Permission for pushing notifications.
static const notification = Permission._(17);
/// Android: Allows an application to access any geographic locations
/// persisted in the user's shared collection.
/// Permission for accessing the device's media library (Android Q+ only).
///
/// Allows an application to access any geographic locations persisted in the
/// user's shared collection.
static const accessMediaLocation = Permission._(18);
/// When running on Android Q and above: Activity Recognition
/// When running on Android < Q: Nothing
/// iOS: Nothing
/// Permission for accessing the activity recognition (Android Q+ only).
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);
/// iOS 13 and above: The authorization state of Core Bluetooth manager.
/// When running < iOS 13 or Android this is always allowed.
static const bluetooth = Permission._(21);
/// Permission for accessing the device's bluetooth adapter state.
///
/// 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
/// scoped storage.
/// iOS: Nothing
/// Permission for accessing the device's external storage. (Android R+ only).
///
/// Allows an application a broad access to external storage in scoped
/// storage.
///
/// You should request the Manage External Storage permission only when
/// 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)
/// or the [MediaStore](https://developer.android.com/training/data-storage/shared/media) APIs) is all your app needs the
/// [PermissionGroup.storage] are the only permissions you need to request.
/// or the [MediaStore](https://developer.android.com/training/data-storage/shared/media) APIs)
/// 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,
/// you have to fill out the Permission Declaration Form upon submitting
......@@ -147,68 +202,59 @@ class Permission {
/// https://support.google.com/googleplay/android-developer/answer/9214102#zippy=
static const manageExternalStorage = Permission._(22);
///Android: Allows an app to create windows shown on top of all other apps
///iOS: Nothing
/// Permission for creating system alert window (Android only).
///
/// Allows an app to create windows shown on top of all other apps.
static const systemAlertWindow = Permission._(23);
///Android: Allows an app to request installing packages.
///iOS: Nothing
/// Permission for requesting installing packages (Android M+ only).
static const requestInstallPackages = Permission._(24);
///Android: Nothing
///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
///websites.
/// Permission for accessing the device's tracking state (iOS only).
///
/// 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
/// websites.
static const appTrackingTransparency = Permission._(25);
///Android: Nothing
///iOS: Notifications that override your ringer
/// Permission for sending critical alerts (iOS only).
///
/// Allow for sending notifications that override the ringer.
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.
///iOS: Nothing
static const accessNotificationPolicy = Permission._(27);
///Android: Allows the user to look for Bluetooth devices
///(e.g. BLE peripherals).
///iOS: Nothing
/// Permission for scanning for Bluetooth devices (Android S+ only).
static const bluetoothScan = Permission._(28);
///Android: Allows the user to make this device discoverable to other
///Bluetooth devices.
///iOS: Nothing
/// Permission for advertising Bluetooth devices (Android S+ only).
///
/// Allows the user to make this device discoverable to other Bluetooth
/// devices.
static const bluetoothAdvertise = Permission._(29);
///Android: Allows the user to connect with already paired Bluetooth devices.
///iOS: Nothing
/// Permission for connecting to Bluetooth devices (Android S+ only).
///
/// Allows the user to connect with already paired Bluetooth devices.
static const bluetoothConnect = Permission._(30);
///Android: Allows the user to connect to nearby devices via Wi-Fi
///iOS: Nothing
/// Permission for connecting to nearby devices via Wi-Fi (Android T+ only).
static const nearbyWifiDevices = Permission._(31);
/// Android:
/// When running on Android TIRAMISU and above: Read video files from external storage
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
/// Permission for accessing the device's video files from external storage (Android T+ only).
static const videos = Permission._(32);
/// Android:
/// When running on Android TIRAMISU and above: Read audio files from external storage
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
/// Permission for accessing the device's audio files from external storage (Android T+ only).
static const audio = Permission._(33);
/// When running on Android S and above: Allows exact alarm functionality
/// When running on Android < S: Nothing
///iOS: Nothing
/// Permission for scheduling exact alarms (Android S+ only).
static const scheduleExactAlarm = Permission._(34);
/// Android:
/// When running on Android TIRAMISU and above: Background Sensors Permission
/// When running on Android < TIRAMISU: Nothing
/// iOS: Nothing
/// Permission for accessing the device's sensors in background (Android T+ only).
static const sensorsAlways = Permission._(35);
/// Returns a list of all possible [PermissionGroup] values.
......
......@@ -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
# 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
version: 3.11.1
version: 3.11.2
dependencies:
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