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

ScanError.toString-impl com.juul.kable.InternalException - Unsupported error code 100 #850

Open
mjordan-gpfw opened this issue Jan 31, 2025 · 1 comment · May be fixed by #851
Open

ScanError.toString-impl com.juul.kable.InternalException - Unsupported error code 100 #850

mjordan-gpfw opened this issue Jan 31, 2025 · 1 comment · May be fixed by #851
Milestone

Comments

@mjordan-gpfw
Copy link

Description
We're seeing this exception thrown in production when trying to scan for ble devices.

com.juul.kable.scan.ScanError.toString-impl (ScanError.java:21)
com.juul.kable.BluetoothLeScannerAndroidScanner$advertisements$1$callback$1.onScanFailed (BluetoothLeScannerAndroidScanner.kt:69)
android.bluetooth.le.BluetoothLeScanner$1.run (BluetoothLeScanner.java:657)
android.os.Handler.handleCallback (Handler.java:958)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loopOnce (Looper.java:224)
android.os.Looper.loop (Looper.java:318)
android.app.ActivityThread.main (ActivityThread.java:8777)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:561)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1013)

Environment
100% Xiaomi devices - 20+ different models. Mostly Redmi Note 13 Pro 5G, Poco X6 5G, and Xiaomi 13
Android OS Versions: 13 and 14 (our min is Android 11, but only see issues on 13/14)

@twyatt
Copy link
Member

twyatt commented Jan 31, 2025

Thanks for reporting!

I had hoped that the error codes defined in ScanCallback would be exhaustive:

ScanCallback constant Value
SCAN_FAILED_ALREADY_STARTED 1
SCAN_FAILED_APPLICATION_REGISTRATION_FAILED 2
SCAN_FAILED_INTERNAL_ERROR 3
SCAN_FAILED_FEATURE_UNSUPPORTED 4
SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES 5
SCAN_FAILED_SCANNING_TOO_FREQUENTLY 6

...but apparently not. Even worse, I looked for a while, and could not find in the Android source, where onScanFailed is called from (nor what possible values it might receive — beyond what is listed in ScanCallback, e.g. 100, as you are hitting).

Internally, it appears that Android just defaults to Unknown as the display of any error besides what is known, hinting that any error code is possible. Which is super not helpful if you're trying to decide how you should handle such an error case.

Unless you can track down what error code 100 means, I'll just have to change Kable to not throw the InternalException and instead propagate an IllegalStateException with "Unknown" error code — not much else I think I can do from Kable to be more helpful, unfortunately. 😢

@twyatt twyatt added this to the 0.36.0 milestone Feb 5, 2025
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.

2 participants