Adjuvo / SenseGlove-Unity

The latest stable Unity SDK for the SenseGlove.
MIT License
35 stars 10 forks source link

App crashing on Oculus Quest 2 #35

Open nitish3693 opened 1 year ago

nitish3693 commented 1 year ago

When using the Senseglove integration with the new API Target 32 (new Minimum Requirement for the Oculus Store) the app is crashing due to Bluetooth permissions.

2023-09-11 15:29:18.380  4961-5195  AndroidRuntime          pid-4961                             E  FATAL EXCEPTION: Thread-6
                                                                                                    Process: com.ExtendRobotics.AMAS.quest, PID: 4961
                                                                                                    java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@264482b9: AdapterService getBondedDevices
                                                                                                        at android.os.Parcel.createExceptionOrNull(Parcel.java:2426)
                                                                                                        at android.os.Parcel.createException(Parcel.java:2410)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2393)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2335)
                                                                                                        at android.bluetooth.IBluetooth$Stub$Proxy.getBondedDevices(IBluetooth.java:3077)
                                                                                                        at android.bluetooth.BluetoothAdapter.getBondedDevices(BluetoothAdapter.java:2491)
                                                                                                        at com.senseglove.sgconnect.BluetoothPorts.GetSGDevices(BluetoothPorts.java:64)
                                                                                                        at com.senseglove.sgconnect.DeviceScanner.UpdateConnections(DeviceScanner.java:212)
                                                                                                        at com.senseglove.sgconnect.DeviceScanner.RunScanner(DeviceScanner.java:147)
                                                                                                        at com.senseglove.sgconnect.DeviceScanner$1.run(DeviceScanner.java:54)
                                                                                                        at java.lang.Thread.run(Thread.java:920)

Setup :

Unity : 2021.3.14f1

atakanhr commented 1 year ago

Same error UNITY 2022.3.9f1

04:31:24.783
AndroidRuntime
FATAL EXCEPTION: Thread-6
04:31:24.783
AndroidRuntime
Process: com.DefaultCompany.HapticHand2022Test, PID: 9743
04:31:24.783
AndroidRuntime
java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@26545bbe: AdapterService getBondedDevices
04:31:24.783
AndroidRuntime
at android.os.Parcel.createExceptionOrNull(Parcel.java:2426)
04:31:24.783
AndroidRuntime
at android.os.Parcel.createException(Parcel.java:2410)
04:31:24.783
AndroidRuntime
at android.os.Parcel.readException(Parcel.java:2393)
04:31:24.783
AndroidRuntime
at android.os.Parcel.readException(Parcel.java:2335)
04:31:24.783
AndroidRuntime
at android.bluetooth.IBluetooth$Stub$Proxy.getBondedDevices(IBluetooth.java:3077)
04:31:24.783
AndroidRuntime
at android.bluetooth.BluetoothAdapter.getBondedDevices(BluetoothAdapter.java:2491)
04:31:24.783
AndroidRuntime
at com.senseglove.sgconnect.BluetoothPorts.GetSGDevices(BluetoothPorts.java:64)
04:31:24.783
AndroidRuntime
at com.senseglove.sgconnect.DeviceScanner.UpdateConnections(DeviceScanner.java:212)
04:31:24.783
AndroidRuntime
at com.senseglove.sgconnect.DeviceScanner.RunScanner(DeviceScanner.java:147)
04:31:24.783
AndroidRuntime
at com.senseglove.sgconnect.DeviceScanner$1.run(DeviceScanner.java:54)
04:31:24.783
AndroidRuntime
at java.lang.Thread.run(Thread.java:920)

For hotfix added permission to android manifest. And get bruteforce permission.

#if UNITY_ANDROID
        if (!Permission.HasUserAuthorizedPermission(Permission.CoarseLocation)
            || !Permission.HasUserAuthorizedPermission(Permission.FineLocation)
            || !Permission.HasUserAuthorizedPermission("android.permission.BLUETOOTH_SCAN")
            || !Permission.HasUserAuthorizedPermission("android.permission.BLUETOOTH_ADVERTISE")
            || !Permission.HasUserAuthorizedPermission("android.permission.BLUETOOTH_CONNECT"))
        {
            Permission.RequestUserPermissions(new string[]
            {
                Permission.CoarseLocation,
                Permission.FineLocation,
                "android.permission.BLUETOOTH_SCAN",
                "android.permission.BLUETOOTH_ADVERTISE",
                "android.permission.BLUETOOTH_CONNECT"
            });
        }
        else
        {
            SceneManager.LoadScene(1);
        }
MaxLammers commented 1 year ago

Looking into this issue.

LauraKatarina commented 11 months ago

Adding the Bluetooth permission to the android manifest didn't work for us as the oculus XR plugin deletes all Bluetooth permissions from the manifest when building the application. For someone facing the same issue here's our solution: Adding the script as described here: https://communityforums.atmeta.com/t5/Quest-Development/SecurityException-when-accessing-Bluetooth-API/td-p/850586 with all needed permissions. Then giving the application Bluetooth and Location permissions in the Meta Quest settings.