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

Crashes (NoSuchMethodException for hidden APIs) on Android 11 #10

Open
Volatile-Memory opened this issue Sep 8, 2020 · 5 comments · May be fixed by #17
Open

Crashes (NoSuchMethodException for hidden APIs) on Android 11 #10

Volatile-Memory opened this issue Sep 8, 2020 · 5 comments · May be fixed by #17

Comments

@Volatile-Memory
Copy link

/** Extensions which expose hidden API **/

NoSuchMethodException

@raghavk92
Copy link
Owner

@rostopira any idea why this is happening? ......I don't have a android 11 device currently at my place.

@AchimStuy
Copy link

I have a Pixel 2 with Android 11 and can confirm the bug. From analyzing source code the exception is thrown in BluetoothController.onServiceConnected.
So I guess, it's from the overall architecture, that devices must be paired within the app. @raghavk92 Why did you architect it that way? Why can't I use a device paired formerly via default Android bluetooth mechanism? Using already paired devices might make this method call redundant.

Please excuse, if I'm wrong. That's just results from looking 5 minutes at the code. But I'm really interested in using the app and might also work on it.

@cuongnv
Copy link

cuongnv commented Jan 27, 2021

@AchimStuy you are right, devices must be paired within in App.
@Computr0n :
to solve this issue on Android 11, you should check your Bluetooth is discovering or not. If not, start discover it and you can use normally.
Dont you setScanMode (it's deprecated and removed from Android 11)

 if(!btAdapter.isDiscovering){
                context.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE))            
}

@raghavk92
Copy link
Owner

@AchimStuy I didnt work on this part of the code. Its a collaborative project between me and rostopira. I think this part of the code was written by rostopira . @rostopira Could you see if you can rectify this issue. I am a bit busy this month so won't be able to work on this . If I am able to next month and I get a bit free I can take a look at that part of the code.

@cuongnv Are you trying to say that the paring should not happen within app? It should happen in the settings app because the sets a mode function is deprecated in Android 11? Just wanted to confirm this.

@AchimStuy If you are interested in working on this app and have the google Pixel as you mentioned you are welcome to correct this issue but just check that your new changes didn't break functionality on android 9 and 10 devices. I don't have a Android 11 device yet so that is also an issue. I'll see if I can get hands-on an Android 11 device.

@AchimStuy
Copy link

So I investigated a little bit on the issue:

Pairing must be done within the app, because we need the HID-Profile added to the Android device's Bluetooth class. This is done in BluetoothHidDevice.registerApp. But (citing from the docs) "the app will be automatically unregistered if it is not foreground." So we lose the HID profile as soon as the user switches to the settings app to pair his device.

The NoSuchMethodException could be fixed by calling BluetoothAdapter.startDiscovery. Then I get some IndexOutOfBoundsExceptions in BluetoothController, lines 153 and 164, because I have no paired devices yet.

How can I pair devices within the app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants