DonkeyRepublic / lockkit-android

Donkey Lock Kit for Android
https://developer.donkey.bike/tomp/lockkit/docs/android/
3 stars 0 forks source link

Bluetooth permissions are not handled consistently on Android 12 #3

Closed mattijsf closed 2 years ago

mattijsf commented 2 years ago

On Android 12 when BLUETOOTH_CONNECT | BLUETOOTH_SCAN permissions are not requested, the SDK throws an error when interacting the the SDK lock / unlock APIs:

When build with compileSdkVersion 31 & targetSdkVersion 31:

LockError.LocationPermission (message: DonkeyErrorLocationPermission: Ga naar instellingen en schakel locatievoorzieningen in om je huidige locatie te bepalen.)

When build with compileSdkVersion 31 & targetSdkVersion 30:

LockError.FatalError (message: DonkeyErrorFatalError: Bluetooth cannot start (code 0))

With these build configurations running on an Android 12 device causes a different error (depending on the targetSdkVersion) when attempting to unlock a bike. In both cases I would expect some BluetoothUnauthorized type of error, similar to the LockError.BluetoothUnauthorized on LockKit iOS.

Sidenote: On iOS the SDK is also prompting for bluetooth permissions in case these are not requested. It would be nice if the Android SDK could follow this behavior on Android 12+ devices.

Nonda95 commented 2 years ago

@mattijsf it should be resolved in v1.2.0-SNAPSHOT — we introduced LockError.BluetoothUnauthorized for this case.

Unfortunately prompting for Bluetooth permissions is tied to Activity. That means we would need to introduce a transparent activity or create a possibility to provide an Activity to the library just for this use case. With this new LockError.BluetoothUnauthorized error, requesting Bluetooth permissions in the app itself should be fairly simple.

Nonda95 commented 2 years ago

LockError.BluetoothUnauthorized is included in today's v1.2.0 stable release. Feel free to reopen this issue if it's not behaving correctly