smartdevicelink / sdl_java_suite

SmartDeviceLink libraries for Android, Java SE, and Java EE
BSD 3-Clause "New" or "Revised" License
187 stars 171 forks source link

Android 12 + 13: "This application is missing permissions: android.permission.BLUETOOTH" while permissions are granted #1841

Closed zmukash closed 1 year ago

zmukash commented 1 year ago

Bug Summary

On a Android 11 device my App works as expected because the android.permission.BLUETOOTH can be granted. With Android 12 the Bluetooth permissions changed and the SdlBroadcastReceiver throws an error shown below. I checked and the BLUETOOTH_CONNECT permissions is granted as well as the BLUETOOTH_SCAN permission (in Android 12 + 13). Also Location permissions are granted and bluetooth and location services are turned on

Reproduction Steps

  1. Follow SDL Installation Guide
  2. Try on Android 12 + 13

Expected Behavior: Run Normally Observed Behavior: Error shown above

Which projects have you seen this bug on?

Android

Android Version(s)

12+13

Android Device(s)

One Plus Nord, Google Pixel 3a XL, Samsung A51

sdl_java_suite Version

5.6.1

Testing Environment(s)

Ford Car + Manticore (when using another connected bluetooth API it shows the same error when intent "android.bluetooth.device.action.ACL_CONNECTED" is received)

Relevant log output

-----------------------------------
      Integration Validator Results: 
    -----------------------------------
    ✕ This application is missing permissions: 
       - android.permission.BLUETOOTH

    ✓ SdlRouterService checks were not performed yet due to supplied flags

    ✕ SdlBroadcastReceiver checks were not performed yet due to failing permission check

    Please see the guides for how to fix these issues at www.smartdevicelink.com
        at com.smartdevicelink.transport.SdlBroadcastReceiver.queryForConnectedService(SdlBroadcastReceiver.java:502)
        at XXX.MainActivity.connectSdl(MainActivity.java:504)
        at XXX.MainActivity.onCreate(MainActivity.java:294)
        at android.app.Activity.performCreate(Activity.java:8129)
        at android.app.Activity.performCreate(Activity.java:8109)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1344)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3749)
            ... 12 more
joeygrover commented 1 year ago

Closing as not an issue.

While Android 12+ introduced new bluetooth permissions for specific API/events, your app still needs to include the specific bluetooth permission android.permission.BLUETOOTH in the manifest as used with older Android versions.

zmukash commented 1 year ago

Closing was the correct decision. Just wanted to leave a comment for my Bugfix for others. Apparently OnePlus (and sometimes other Manufacturers) seem to have incorrect implementations of the Bluetooth Spec. I had exactly the same issue as described in the post below and the solution was to change

<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> to

<uses-permission android:name="android.permission.BLUETOOTH" tools:remove="android:maxSdkVersion" />

which overwrites an already merged manifest line which would leave out the permission after a once defined maxSdkVersion. This solution was taken from Stackoverflow - Solution by Manuel B.