googlearchive/android-BluetoothLeGatt

Scanning on Android 9(Pie) is not working but Scanning on Android 8 is working well

shkim3000 opened this issue · 12 comments

Hi,

I cleared permission issue and compile this source successfully.
When I test this on android 9 on Samsung Note8, this apk couldn't find any ble device.
there is no any error or warning. look below

D/BluetoothAdapter: startLeScan(): null
D/BluetoothAdapter: STATE_ON
I/chatty: uid=10324(com.example.android.bluetoothlegatt) identical 1 line
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Start Scan with callback
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=4 mScannerId=0
D/BluetoothAdapter: stopLeScan()
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan with callback

But when I test this on android 8 on LG V20, this apk finds all ble devices well.
look below

D/BluetoothAdapter: startLeScan(): null
D/BluetoothAdapter: isLeEnabled(): ON
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=7 mScannerId=0
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@11da351 time:936821296
I/zygote64: Do partial code cache collection, code=17KB, data=24KB
After code cache collection, code=17KB, data=24KB
Increasing code cache capacity to 128KB
I/zygote64: Do partial code cache collection, code=17KB, data=43KB
After code cache collection, code=17KB, data=43KB
Increasing code cache capacity to 256KB
I/zygote64: Compiler allocated 8MB to compile void android.widget.TextView.(android.content.Context, android.util.AttributeSet, int, int)
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@11da351 time:936821296
I/zygote64: Do full code cache collection, code=125KB, data=99KB
I/zygote64: After code cache collection, code=119KB, data=72KB
I/zygote64: Do partial code cache collection, code=124KB, data=88KB
I/zygote64: After code cache collection, code=124KB, data=88KB
Increasing code cache capacity to 512KB
I/zygote64: Compiler allocated 6MB to compile void android.view.ViewRootImpl.performTraversals()
I/zygote64: Do full code cache collection, code=251KB, data=172KB
I/zygote64: After code cache collection, code=206KB, data=131KB
I/zygote64: Do partial code cache collection, code=250KB, data=167KB
I/zygote64: After code cache collection, code=250KB, data=167KB
Increasing code cache capacity to 1024KB
D/BluetoothAdapter: stopLeScan()
D/BluetoothAdapter: isLeEnabled(): ON
D/BluetoothAdapter: stopLeScan()
D/BluetoothAdapter: scan not started yet
<< found all devices >>

I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
I/AudioManagerEx: AudioManagerEx created
D/BluetoothAdapter: stopLeScan()
D/BluetoothAdapter: scan not started yet
D/PhoneWindow: windowLightStatusBar : false, disable View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
I/zygote64: Compiler allocated 8MB to compile void android.widget.TextView.(android.content.Context, android.util.AttributeSet, int, int)
D/BluetoothGatt: connect() - device: 00:50:D4:00:00:20, auto: false
registerApp()
registerApp() - UUID=ab1140bd-a224-4ada-9ace-3780a4567a0c
D/BluetoothLeService: Trying to create a new connection.
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@89ed9c1 time:936845623
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=7 device=00:50:D4:00:00:20
I/BluetoothLeService: Connected to GATT server.
D/BluetoothGatt: discoverServices() - device: 00:50:D4:00:00:20
I/BluetoothLeService: Attempting to start service discovery:true
D/BluetoothGatt: onConnectionUpdated() - Device=00:50:D4:00:00:20 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onSearchComplete() = Device=00:50:D4:00:00:20 Status=0
D/BluetoothGatt: onConnectionUpdated() - Device=00:50:D4:00:00:20 interval=39 latency=0 timeout=500 status=0
D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection.
D/DeviceControlActivity: Connect request result=true
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@89ed9c1 time:936850696
D/BluetoothGatt: onConnectionUpdated() - Device=00:50:D4:00:00:20 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onConnectionUpdated() - Device=00:50:D4:00:00:20 interval=39 latency=0 timeout=500 status=0
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
D/BluetoothGatt: cancelOpen() - device: 00:50:D4:00:00:20
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=7 device=00:50:D4:00:00:20
I/BluetoothLeService: Disconnected from GATT server.

Because you have location permission, you didn't open it.

if you open the location function,the app will work

It get the coarse_location permission already.
do i need to make it get fine_location permission as well?

two things you must be sure:
1、the app have BLETOOTH and coarse_location permissions
2、the coarse_location function(not permission) you have open ,

made ,no thanks ,no answer

What is coarse_location function?
I couldn't find any information about that.

the "Location" function must be open ( :

Oh thank you.

u are zhong guo ren

i am zhong guo ren

work well after enable location.
thank you

you are wellcome