Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BACKGROUND_LOCATION Permission #112

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The full list can be found in `dev.icerock.moko.permissions.Permission` enum.
* Storage write: **Permission.WRITE_STORAGE**
* Fine location: **Permission.LOCATION**
* Coarse location: **Permission.COARSE_LOCATION**
* Background location: **Permission.BACKGROUND_LOCATION**
* Remote notifications: **Permission.REMOTE_NOTIFICATION**
* Audio recording: **Permission.RECORD_AUDIO**
* Bluetooth LE: **Permission.BLUETOOTH_LE**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class PermissionsControllerImpl(
Permission.WRITE_STORAGE -> listOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
Permission.LOCATION -> fineLocationCompat()
Permission.COARSE_LOCATION -> listOf(Manifest.permission.ACCESS_COARSE_LOCATION)
Permission.BACKGROUND_LOCATION -> backgroundLocationCompat()
Permission.REMOTE_NOTIFICATION -> remoteNotificationsPermissions()
Permission.RECORD_AUDIO -> listOf(Manifest.permission.RECORD_AUDIO)
Permission.BLUETOOTH_LE -> allBluetoothPermissions()
Expand Down Expand Up @@ -192,6 +193,22 @@ class PermissionsControllerImpl(
listOf(Manifest.permission.ACCESS_FINE_LOCATION)
}

private fun backgroundLocationCompat() =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
listOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION,
Alex009 marked this conversation as resolved.
Show resolved Hide resolved
)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
listOf(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION,
)
} else {
listOf(Manifest.permission.ACCESS_FINE_LOCATION)
}

/**
* Bluetooth permissions
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum class Permission {
WRITE_STORAGE,
LOCATION,
COARSE_LOCATION,
BACKGROUND_LOCATION,
BLUETOOTH_LE,
REMOTE_NOTIFICATION,
RECORD_AUDIO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PermissionsController : PermissionsControllerProtocol {
Permission.CAMERA -> AVCapturePermissionDelegate(AVMediaTypeVideo, permission)
Permission.GALLERY -> GalleryPermissionDelegate()
Permission.STORAGE, Permission.WRITE_STORAGE -> AlwaysGrantedPermissionDelegate()
Permission.LOCATION, Permission.COARSE_LOCATION ->
Permission.LOCATION, Permission.COARSE_LOCATION, Permission.BACKGROUND_LOCATION ->
Alex009 marked this conversation as resolved.
Show resolved Hide resolved
LocationPermissionDelegate(locationManagerDelegate, permission)

Permission.RECORD_AUDIO -> AVCapturePermissionDelegate(AVMediaTypeAudio, permission)
Expand Down
1 change: 1 addition & 0 deletions sample/android-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
Expand Down
1 change: 1 addition & 0 deletions sample/compose-android-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
Expand Down
Loading