question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BleScanException: Scan failed because feature unsupported on api 23+ due to CALLBACK_TYPE_FIRST_MATCH | CALLBACK_TYPE_MATCH_LOST

See original GitHub issue

Summary

Starting a scan with CALLBACK_TYPE_FIRST_MATCH | CALLBACK_TYPE_MATCH_LOST errors with SCAN_FAILED_FEATURE_UNSUPPORTED or SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES

Testing on API < 21 works without problems, and while looking at the code in ScanSetupBuilderImplApi18 it is working because the behavior is being emulated.

ScanSetupBuilderImplApi21 also emulates said behavior, although I cannot test it.

ScanSetupBuilderImplApi23 does NOT emulate callbacks, on the basis that they are natively available.

Thing is all my available Android API 23+ test devices are old or just plain cheap and their Bluetooth chips likely do not support said behavior, which would make sense given the thrown errors.

I think ScanSetupBuilderImplApi23 should retry on error with the emulated behavior, or at least give access to it outside of the library, so it can be implemented without having to copy the same functionality.

Thoughts?

Library version

1.9.1

Preconditions

ScanSettings.Builder()
                .setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH or ScanSettings.CALLBACK_TYPE_MATCH_LOST)
                .build()

Steps to reproduce actual result

Minimum code snippet reproducing the issue

client
        .scanBleDevices(
            ScanSettings.Builder()
                .setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH or ScanSettings.CALLBACK_TYPE_MATCH_LOST)
                .setScanMode(ScanSettings.SCAN_MODE_BALANCED)
                .build(),
            *filters
        )
        .subscribe()

Logs from the application running with setting

2019-04-12 13:05:19.540 10603-10636/[..] D/RxBle#ClientOperationQueue: QUEUED   ScanOperationApi21(158477343)
2019-04-12 13:05:19.541 10603-10627/[..] D/RxBle#ClientOperationQueue: STARTED  ScanOperationApi21(158477343)
2019-04-12 13:05:19.542 10603-10627/[..] I/RxBle#ClientOperationQueue: RUNNING  ScanOperationApi21{ANY_MUST_MATCH -> nativeFilters=[BluetoothLeScanFilter [mDeviceName=null, MAC=null, mUuid=null, mUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=-1, mManufacturerData=null, mManufacturerDataMask=null]]}
2019-04-12 13:05:19.549 10603-10637/[..] I/RxBle#QueueOperation: Scan operation is requested to start.
2019-04-12 13:05:19.549 10603-10637/[..] D/RxBle#ScanOperationApi21: No library side filtering —> debug logs of scanned devices disabled
2019-04-12 13:05:19.557 10603-10627/[..] D/RxBle#ClientOperationQueue: FINISHED ScanOperationApi21(158477343) in 16 ms
2019-04-12 13:05:19.598 10603-10637/[..] I/RxBle#CancellableDisposable: Scan operation is requested to stop.
2019-04-12 13:05:19.601 10603-10637/[..] D/BluetoothLeScanner: could not find callback wrapper
2019-04-12 13:05:19.601 10603-10603/[..] W/System.err: io.reactivex.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | com.polidea.rxandroidble2.exceptions.BleScanException: Scan failed because feature unsupported (code 8)
2019-04-12 13:05:19.602 10603-10603/[..] W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
2019-04-12 13:05:19.602 10603-10603/[..] W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
2019-04-12 13:05:19.602 10603-10603/[..] W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:77)
2019-04-12 13:05:19.602 10603-10603/[..] W/System.err:     at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:281)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at android.os.Looper.loop(Looper.java:154)
2019-04-12 13:05:19.603 10603-10603/[..] W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6126)
2019-04-12 13:05:19.604 10603-10603/[..] W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2019-04-12 13:05:19.604 10603-10603/[..] W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
2019-04-12 13:05:19.604 10603-10603/[..] W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
2019-04-12 13:05:19.604 10603-10603/[..] W/System.err: Caused by: com.polidea.rxandroidble2.exceptions.BleScanException: Scan failed because feature unsupported (code 8)
2019-04-12 13:05:19.605 10603-10603/[..] W/System.err:     at com.polidea.rxandroidble2.internal.operations.ScanOperationApi21$1.onScanFailed(ScanOperationApi21.java:92)
2019-04-12 13:05:19.605 10603-10603/[..] W/System.err:     at android.bluetooth.le.BluetoothLeScanner$1.run(BluetoothLeScanner.java:461)
2019-04-12 13:05:19.605 10603-10603/[..] W/System.err: 	... 7 more

Actual result

com.polidea.rxandroidble2.exceptions.BleScanException: Scan failed because feature unsupported (code 8)

Expected result

Library emulates behavior (on error) in API 23 just like pre API 23

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dariuszseweryncommented, Sep 20, 2019

Ok, so I consider this case closed. The fix should be available in 1.11.0-SNAPSHOT in several minutes and will be available once the stable version is released as well

1reaction
dariuszseweryncommented, Apr 16, 2019

As far as I am concerned the OS will count every try to run a scan, whether it was successful or not

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scan failed because feature unsupported on api 23+ due to ...
BleScanException : Scan failed because feature unsupported on api 23+ due to CALLBACK_TYPE_FIRST_MATCH | CALLBACK_TYPE_MATCH_LOST #561.
Read more >
com.polidea.rxandroidble2.exceptions.BleScanException ...
This seem to be an Android bug and/or excessive scans being performed in other places on the phone. Quick googling shows that it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found