Android Question Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource

Filippo

Expert
Licensed User
Longtime User
Hi,

in the Firabase have some users with this error message(see title). Most of the phones are Samsung, one of them is a Samsung Galaxy A13(Android 12).
To be able to reproduce the same error, I even bought a new Samsung Galaxy A13 today also with Android 12.

Result ..., I still can not reproduce the error.

Does anyone perhaps still have a tip?

1669035372306.png

Fatal Exception: java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource { uid = 10356, packageName = fg.speedpilot_lite, attributionTag = null, token = android.os.BinderProxy@590c703, next = null }: disable
at android.os.Parcel.createExceptionOrNull(Parcel.java:2437)
at android.os.Parcel.createException(Parcel.java:2421)
at android.os.Parcel.readException(Parcel.java:2404)
at android.os.Parcel.readException(Parcel.java:2346)
at android.bluetooth.IBluetoothManager$Stub$Proxy.disable(IBluetoothManager.java:1046)
at android.bluetooth.BluetoothAdapter.disable(BluetoothAdapter.java:2277)
at anywheresoftware.b4a.objects.Serial$BluetoothAdmin.Disable(Serial.java:399)
at fg.speedpilot_lite.clsbleorbt._vvvvvvvvvvvvvvvvvvvvvvvv3(clsbleorbt.java:153)
at fg.speedpilot_lite.main._activity_pause(main.java:635)
at java.lang.reflect.Method.invoke(Method.java)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at fg.speedpilot_lite.main.onPause(main.java:275)
at android.app.Activity.performPause(Activity.java:8485)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1530)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5629)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5590)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5542)
at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:47)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8751)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
 

jahswant

Well-Known Member
Licensed User
Longtime User

UPDATE your application and add the new permission.
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User

UPDATE your application and add the new permission.
I have already done all that.
All my test devices with Android 8, 10, 12 work without problems.
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
In my app, when I exit, I use the "ExitApplication" function.
Is it possible that the problem is caused by this function?
In the Google Play console I found this crash report:
Exception java.lang.SecurityException:
at android.os.Parcel.createExceptionOrNull (Parcel.java:2437)
at android.os.Parcel.createException (Parcel.java:2421)
at android.os.Parcel.readException (Parcel.java:2404)
at android.os.Parcel.readException (Parcel.java:2346)
at android.bluetooth.IBluetoothManager$Stub$Proxy.disable (IBluetoothManager.java:1046)
at android.bluetooth.BluetoothAdapter.disable (BluetoothAdapter.java:2277)
at anywheresoftware.b4a.objects.Serial$BluetoothAdmin.Disable (Serial.java:399)
at fg.speedpilot_lite.clsbleorbt._vvvvvvvvvvvvvvvvvvvvvvvv3 (clsbleorbt.java:153)
at fg.speedpilot_lite.main._activity_pause (main.java:635)
at java.lang.reflect.Method.invoke

B4X:
Main-Activity:
Sub Activity_Pause (UserClosed As Boolean)   

    If UserClosed Then 

        'Bluetooth verbindung aufheben
        If Starter.bluetooth.IsInitialized Then Starter.bluetooth.DestroyConnection

        CallSub(Starter, "Service_Stop") 'StopService(Starter)
        
        ExitApplication
    End If
End Sub

Bluetooth-Class:
Public Sub DestroyConnection
'    Log("DestroyConnection")
    if ble.IsConnected Then
        ble.DestroyConnection
    End If
    If admin.IsInitialized Then
        admin.Disable
    End If
End Sub
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
I believe that the problem has to do with the "ExitApplication" function, because the app does not exit properly.
Here is the log output with and without "ExitApplication":

'logs without "ExitApplication"

** Activity (main) Pause, UserClosed = true **
admin.Disable
Starter: Service_Stop
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **


'logs with "ExitApplication"

** Activity (main) Pause, UserClosed = true **
admin.Disable
Starter: Service_Stop
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
Hi Filippo,
I am also facing the same problem, do you have any solution to solve this problem? If yes please share the solution with me. Thanks!
Hi,

you have to check if admin is enabled, if yes, then it can be deactivated.

B4X:
    If admin.IsInitialized And admin.IsEnabled Then
        admin.Disable
    End If
 
Upvote 0
Top