android - 'App is scanning too frequently' with ScanSettings.SCAN_MODE_OPPORTUNISTIC -
we found issue on samsung s8, android 7.0 (upd. happens on android 7.0: samsung s7, nexus 5x), tells, after couple of tests, app scanning frequently:
08-14 12:44:20.693 25329-25329/com.my.app d/bluetoothadapter: startlescan(): null 08-14 12:44:20.695 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.696 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.698 25329-25329/com.my.app d/bluetoothlescanner: start scan 08-14 12:44:20.699 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.700 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.700 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.701 25329-25329/com.my.app d/bluetoothadapter: state_on 08-14 12:44:20.703 4079-4093/? d/btgatt.gattservice: registerclient() - uuid=dbaafee1-caf1-4482-9025-b712f000eeab 08-14 12:44:20.807 4079-4204/? d/btgatt.gattservice: onclientregistered() - uuid=dbaafee1-caf1-4482-9025-b712f000eeab, clientif=5, status=0 08-14 12:44:20.808 25329-25342/com.my.app d/bluetoothlescanner: onclientregistered() - status=0 clientif=5 mclientif=0 08-14 12:44:20.809 4079-7185/? d/btgatt.gattservice: start scan filters 08-14 12:44:20.811 4079-7185/? d/btgatt.gattservice: getscansettings 08-14 12:44:20.812 4079-7185/? d/btgatt.gattservice: foreground application = true 08-14 12:44:20.812 4079-7185/? d/btgatt.gattservice: not background application 08-14 12:44:20.817 4079-7185/? e/btgatt.gattservice: app 'com.my.app' scanning
the problem lies in 6 state_on call results, it's part of undocumented ble behavior change, first mentioned in dp4 release notes:
we’ve changed ble scanning behavior starting in dp4. we’ll prevent applications starting , stopping scans more 5 times in 30 seconds. long running scans, we’ll convert them opportunistic scans.
what don't these 6 scans in less 30s if set scansettings.setscanmode(scansettings.scan_mode_opportunistic)
.
the code is:
list<scanfilter> filters = new arraylist<>(); scansettings scansettings = new scansettings.builder() .setscanmode(scansettings.scan_mode_opportunistic) .build(); bluetoothadapter.getbluetoothlescanner().startscan(filters, scansettings, recoderscancallback); //events log happen before log printed log.i("test", " started!"); return recoderscancallback.scanresultobservable().map((scanresult record) -> { //never gets here log.i("test", " result!"); });
recorderscancallback derived scancallback. cannot use rxandroidble#rxbleclient.scanblesettings(scansettings) because our code freeze , use 1.1.0 version of lib.
why scansettings.setscanmode not alter results of search?
Comments
Post a Comment