我有一个Android应用程序用例,我需要“持续”扫描BLE设备。
仅此要求就可能让我成为受虐狂,我想这会让Android成为我的虐待狂。
我知道[我相信]仍然没有正式记录“30秒内不超过5次扫描”和“10分钟内不扫描”、“没有扫描过滤器就没有扫描结果”、背景问题和其他一些问题。
为了缓解这些问题,我使用了类似AltBeacon、Nordic Scanner Compat、SweetBlue和其他一些技巧。
我认为这些都不是这个帖子的问题。
输入我目前的问题。
一般来说,我的应用程序使用PendingIntent开始扫描3.1秒,然后停止(逻辑“暂停”)3.1秒,然后在用户明确退出应用程序后重复(逻辑“恢复”)和硬停止。
下面是一个8.1.0 Nexus 6P的日志,它重新启动并打开蓝牙,启动我的应用程序并开始扫描
我不知道为什么操作系统在开始扫描时调用gatt_api,为什么它在停止时抱怨未找到上下文;也许这些是线索?
2019-07-18 17:51:53.462 13662-13662/? D/AdapterServiceConfig: Adding GattService
2019-07-18 17:51:53.496 13662-13676/? D/BluetoothAdapterService: setProfileServiceState() - Starting service com.android.bluetooth.gatt.GattService
2019-07-18 17:51:53.497 13662-13662/? I/BtGatt.JNI: classInitNative(L871): classInitNative: Success!
2019-07-18 17:51:53.498 13662-13662/? D/BtGatt.DebugUtils: handleDebugAction() action=null
2019-07-18 17:51:53.499 13662-13662/? D/BtGatt.GattService: Received start request. Starting profile...
2019-07-18 17:51:53.499 13662-13662/? I/bt_btif: get_profile_interface: id = gatt
2019-07-18 17:51:53.504 13662-13662/? D/BluetoothAdapterService: processProfileServiceStateChanged() - serviceName=com.android.bluetooth.gatt.GattService isTurningOn=false isTurningOff=false isBleTurningOn=true isBleTurningOff=false
2019-07-18 17:51:53.504 13662-13662/? D/BluetoothAdapterService: GattService is started
2019-07-18 17:51:54.251 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:51:54.251 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=3
2019-07-18 17:51:54.274 4384-4435/? D/BluetoothManagerService: Binding Bluetooth GATT service
2019-07-18 17:51:54.277 4384-4384/? D/BluetoothManagerService: BluetoothServiceConnection: com.android.bluetooth.gatt.GattService
2019-07-18 17:51:54.278 4384-4435/? D/BluetoothManagerService: BluetoothGatt Service is Up
2019-07-18 17:51:54.376 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:51:54.376 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=4
2019-07-18 17:51:54.653 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:51:54.653 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=5
2019-07-18 17:51:54.685 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:51:54.685 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=6
2019-07-18 17:52:00.800 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:52:00.818 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:52:00.818 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=6
2019-07-18 17:52:00.818 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:52:00.836 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:52:00.837 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=1, elapsedMillisSinceBleScannerInternalStartScanFirstTime=0
2019-07-18 17:52:03.942 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:52:03.959 13662-13674/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@2f1237f
2019-07-18 17:52:03.960 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:52:03.966 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(36)={"31:2C:26:FA:91:5E"=null, "0E:06:E5:5D:1F:9D"=null, "0E:05:A0:00:28:E3"=null, "16:05:05:B8:E9:51"=null, "0E:0A:B0:00:13:2E"=null, "0E:0E:A0:05:C9:B4"=null, "74:F0:1C:42:2A:6C"=null, "0E:0C:00:00:0A:14"=null, "0E:0A:00:00:23:38"=null, "0E:05:A0:00:13:AC"=null, "0E:0E:A0:03:CC:16"=null, "0E:0E:A0:02:22:78"=null, "30:8C:FB:D4:BD:B1"=null, "30:8C:FB:7A:55:21"=null, "CD:A3:87:DA:15:D6"=null, "0E:0E:A0:03:C6:D6"=null, "0E:05:A0:00:32:6E"=null, "0E:0E:A0:05:46:FD"=null, "0E:0E:A0:01:0C:DF"=null, "0E:0E:A0:01:14:36"=null, "0E:0E:A0:01:14:56"=null, "0E:0E:A0:03:F7:1A"=null, "0E:0E:43:21:FE:0E"=null, "0E:0E:A0:0E:E2:72"=null, "0E:0E:A0:04:07:1F"=null, "F5:2A:1E:90:43:D7"=null, "0B:F8:B4:90:A2:3A"=null, "0E:0E:A0:00:1E:DF"=null, "0E:05:A0:00:61:B1"=null, "0E:0E:A0:03:DC:D3"=null, "0E:05:A0:00:84:12"=null, "0E:05:A0:00:84:13"=null, "0E:06:E5:59:D8:B3"=null, "0E:0A:A0:01:3D:13"=null, "2F:41:6D:A2:92:C6"=null, "0E:0A:A0:01:3A:69"=null}
2019-07-18 17:52:04.595 13662-13682/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
2019-07-18 17:52:07.076 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:52:07.111 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:52:07.112 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=7
2019-07-18 17:52:07.112 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:52:07.127 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:52:07.127 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=2, elapsedMillisSinceBleScannerInternalStartScanFirstTime=6291
2019-07-18 17:52:10.231 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:52:10.238 13662-13674/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@1377141
2019-07-18 17:52:10.239 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:52:10.242 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(37)={"31:2C:26:FA:91:5E"=null, "0E:0E:A0:00:18:EC"=null, "0E:06:E5:5D:1F:9D"=null, "0E:05:A0:00:28:E3"=null, "16:05:05:B8:E9:51"=null, "0E:0A:B0:00:13:2E"=null, "0E:0E:A0:05:C9:B4"=null, "74:F0:1C:42:2A:6C"=null, "0E:0A:00:00:23:38"=null, "0E:0C:00:00:0A:14"=null, "0E:05:A0:00:13:AC"=null, "0E:0E:A0:02:22:78"=null, "30:8C:FB:D4:BD:B1"=null, "30:8C:FB:7A:55:21"=null, "CD:A3:87:DA:15:D6"=null, "0E:0E:A0:03:C6:D6"=null, "0E:0E:A0:05:46:FD"=null, "0E:0E:A0:03:3B:16"=null, "0E:0E:A0:01:14:36"=null, "CD:31:C7:3B:84:0F"=null, "0E:0E:A0:02:0B:C1"=null, "DA:A3:9B:E8:3B:E8"=null, "0E:0E:A0:02:24:97"=null, "0E:0E:A0:03:F7:1A"=null, "0E:0E:43:21:FE:0E"=null, "0E:0E:A0:0E:E2:72"=null, "0B:F8:B4:90:A2:3A"=null, "F5:2A:1E:90:43:D7"=null, "0E:0E:A0:00:1E:DF"=null, "0E:05:A0:00:61:B1"=null, "0E:0E:A0:03:DC:D3"=null, "0E:05:A0:00:84:12"=null, "0E:05:A0:00:84:13"=null, "0E:0A:A0:01:3D:13"=null, "0E:06:E5:59:D8:B3"=null, "2F:41:6D:A2:92:C6"=null, "0E:0A:A0:01:3A:69"=null}
2019-07-18 17:52:10.483 13662-13682/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
如果=8,那么9,10,…,31,…
。。。
2019-07-18 17:54:43.869 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:54:43.893 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:54:43.893 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=32
2019-07-18 17:54:43.893 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:54:43.912 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:54:43.913 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=27, elapsedMillisSinceBleScannerInternalStartScanFirstTime=163077
2019-07-18 17:54:43.952 13662-13682/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
2019-07-18 17:54:47.021 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:54:47.033 13662-13703/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@e09708f
2019-07-18 17:54:47.036 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:54:47.037 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(37)={"0E:0E:A0:02:0D:1A"=null, "0E:06:E5:5D:1F:9D"=null, "0E:0E:A0:00:18:EC"=null, "16:05:05:B8:E9:51"=null, "0E:0E:FF:F6:BE:30"=null, "74:F0:1C:42:2A:6C"=null, "0E:0C:00:00:0A:14"=null, "0E:0A:00:00:23:38"=null, "0E:0E:A0:03:CC:16"=null, "0E:0E:A0:01:0B:E6"=null, "0E:0E:A0:02:22:78"=null, "30:8C:FB:D4:BD:B1"=null, "30:8C:FB:7A:55:21"=null, "CD:A3:87:DA:15:D6"=null, "0E:05:A0:00:32:6E"=null, "0E:0E:A0:03:28:7B"=null, "0E:0E:A0:01:0C:DF"=null, "CD:31:C7:3B:84:0F"=null, "DA:A3:9B:E8:3B:E8"=null, "0E:0E:A0:01:14:56"=null, "0E:0E:A0:02:24:97"=null, "0E:0E:A0:02:15:F8"=null, "37:AB:CB:F6:2D:70"=null, "0E:0E:43:21:FE:0E"=null, "24:B9:20:97:DC:87"=null, "0E:0E:A0:04:6B:34"=null, "0E:0E:A0:04:07:1F"=null, "0B:F8:B4:90:A2:3A"=null, "F5:2A:1E:90:43:D7"=null, "0E:05:A0:00:61:B0"=null, "0E:0E:A0:03:21:34"=null, "0E:05:A0:00:61:B1"=null, "0E:05:A0:00:84:13"=null, "0E:06:E5:59:D8:B3"=null, "0E:0A:A0:01:3D:13"=null, "2F:41:6D:A2:92:C6"=null, "0E:0A:A0:01:3A:69"=null}
2019-07-18 17:54:47.547 13662-13662/? D/BtGatt.ScanManager: awakened up at time 187337376
2019-07-18 17:54:47.552 13662-13682/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
2019-07-18 17:54:50.143 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:54:50.173 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:54:50.173 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:54:50.173 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:54:50.173 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:54:50.174 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:54:50.174 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:54:50.174 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:54:50.187 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:54:50.188 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=28, elapsedMillisSinceBleScannerInternalStartScanFirstTime=169351
在我第28次调用startScan时(除非另一个应用程序已经扫描),大约170秒,操作系统开始报告gatt_api错误,无法注册gatt客户端,最大客户端达到:32,此时:
...
2019-07-18 17:54:53.291 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:54:53.303 13662-13715/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@7eaaf1c
2019-07-18 17:54:53.304 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:54:53.304 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(0)={}
2019-07-18 17:54:56.410 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:54:56.439 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:54:56.439 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:54:56.439 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:54:56.439 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:54:56.439 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:54:56.439 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:54:56.440 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:54:56.458 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:54:56.458 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=29, elapsedMillisSinceBleScannerInternalStartScanFirstTime=175622
2019-07-18 17:54:59.562 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:54:59.576 13662-13673/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@bef4725
2019-07-18 17:54:59.576 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:54:59.577 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(0)={}
2019-07-18 17:55:02.679 13349-13349/com.myapp V/MyBleScanner: resume: #GATT +mBleScannerInternal.startScan(...)
2019-07-18 17:55:02.697 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:55:02.697 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:55:02.697 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:55:02.697 13662-13697/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
2019-07-18 17:55:02.697 13662-13697/? E/bt_stack: [ERROR:gatt_api.cc(1032)] can't Register GATT client, MAX client reached: 32
2019-07-18 17:55:02.697 13662-13697/? E/bt_btif: Register with GATT stack failed.
2019-07-18 17:55:02.697 13349-13349/com.myapp V/MyBleScanner: resume: #GATT mBleScannerInternal.startScan(...); result=SUCCESS(0)
2019-07-18 17:55:02.707 13349-13349/com.myapp V/MyBleScanner: resume: #GATT -mBleScannerInternal.startScan(...)
2019-07-18 17:55:02.707 13349-13349/com.myapp E/MyBleScanner: resume: #GATT mBleScannerInternalStartScanCount=30, elapsedMillisSinceBleScannerInternalStartScanFirstTime=181871
2019-07-18 17:55:05.810 13349-13349/com.myapp V/MyBleScanner: pause: #GATT +mBleScannerInternal.stopScan(...)
2019-07-18 17:55:05.822 13662-13703/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@82cc0fa
2019-07-18 17:55:05.822 13349-13349/com.myapp V/MyBleScanner: pause: #GATT -mBleScannerInternal.stopScan(...)
2019-07-18 17:55:05.823 13349-13349/com.myapp I/MyBleScanner: pause: #GATT mScannedDevices(0)={}
如果在这里发生泄漏,看起来有某种分配的gatt_,但我只是调用startScan(…,mpendingent)和stopScan(…,mpendingent),使用相同的最终/不可变的PendingIntent成员,因此我非常怀疑代码中的任何内容是否直接导致了“泄漏”。
此时没有应用程序可以扫描BLE设备。不是我的应用程序或SweetBlue Toolbox、BLE Scanner或我尝试过的任何其他第三方BLE扫描应用程序。
为什么会这样?
当手机进入这种状态时,我可以通过关闭手机的蓝牙并再次打开来恢复工作状态。
AltBeacon有一个BluetoothMedic类,据说该类可以检测这种状态,并通过编程关闭和再次打开蓝牙,但我将其作为依赖项添加,并在其onScanFailed回调中设置断点,但它从未被调用,这违背了该类的全部目的,我发现很难相信这是他们已知的问题/
我首先不希望出现这种泄漏,并且能够无限期地每隔3.1秒停止和启动扫描,并可靠地扫描范围内的本地设备。
除此之外,如果我必须这样做,我将不得不通过编程关闭和重新打开蓝牙(是的,每170秒一次……欢迎来到我的地狱,在Android BLE世界),但如果没有工作的startScan返回值或onScanFailed回调,就无法确定扫描零设备是否意味着手机已进入这种不良状态,或者周围确实存在零设备。
我相信这段代码已经运行了一年多,直到最近,最多几个月前,才开始以这种方式运行。
有希望吗?
Android BLE真的^∞很烂。:/
停止/启动扫描肯定有问题。我认为具有完全相同回调/挂起意图的startScan不应启动另一次扫描。
你能在这里发一些代码吗?您的代码似乎没有正确停止扫描。也许由于某种原因,你的吊坠开始时不同?
它能在其他手机上复制吗?
问题没有解决,用1.4.1!“listent”PendingIntent不再广播了,这是真的,但是蓝牙内部扫描仍然没有停止,这是证明:“BtGatt。ScanManager:及时唤醒”。测试设备:Pixel2 with Android 10
发现的问题:BluetoothLeScannerImplOreo-
这样,启动的pendingIntent hashCode()将不同于停止pendingIntent hashCode()!!这太糟糕了!这是一个bug,因为文档澄清了这两个意图必须是相同的,在这个库案例中是完全不同的。
解决方案:将“requestCode”作为额外参数添加到CreateStartingPendingContent(…,@NonNull final int requestCode)和CreateStoppingPendingContent(…,@NonNull final int requestCode)方法中,并将其用于id。final int id=requestCode//回调意图。hashCode();是的,启动和停止的请求代码必须相同。
https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/issues/58#issuecomment-555964455
我最后的结论是,Nordic的Android Scanner Compat库确实创建了一个可停止的PendingIntent,但问题是它调用了PendingIntent。getBroadcast(context,id,intent,pendingent.FLAG\u CANCEL\u CURRENT)
当它应该调用pendingent时。getBroadcast(context,id,intent,PendingIntent.FLAG\u UPDATE\u CURRENT)
我把它固定在我的叉子上,打开了一个问题,并将打开一个公关。
我相信我找到了答案。
今天,我编写了一个独立的应用程序,作为重新处理这个问题的简单测试用例。https://github.com/paulpv/AndroidBleStartScanPendingIntentLeak
想想看,它没有重新编程。
测试应用程序和我的生产应用程序的一大区别是:
我的测试应用程序没有重现问题,但当我将其调整为使用Nordic的Android扫描仪Compat时,我的问题开始重现。
我撤消了我的更改;没有重现。
我重新做了我的更改;重现。
冒烟的枪?
查看他们的代码,我发现:html" target="_blank">https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/blob/master/scanner/src/main/java/no/nordicsemi/android/support/v18/scanner/BluetoothLeScannerImplOreo.java#L111
final PendingIntent pendingIntent = createStartingPendingIntent(nonNullFilters,
nonNullSettings, context, callbackIntent);
scanner.startScan(nativeFilters, nativeSettings, pendingIntent);
他们实例化了他们自己的PendingEvent,它封装了我的…但在他们的代码中没有任何地方可以跟踪他们的PendingEvent,这样他们就可以用相同的PendingEvent成功调用stopScan(PendingEvent)。
https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/blob/master/scanner/src/main/java/no/nordicsemi/android/support/v18/scanner/BluetoothLeScannerImplOreo.java#L126
final PendingIntent pendingIntent = createStoppingPendingIntent(context, callbackIntent);
scanner.stopScan(pendingIntent);
这两个悬而未决的内容不可能匹配,这样操作系统就可以正确地停止扫描。
我通过在我的代码分支中添加日志来证实这一点(搜索“PendingEvent=”near everystartScan和stopScan;注意,它们是不同的实例,以及每个分配的gatt\U中不断增加的数量,如果=
):
2019-07-19 21:14:51.230 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.startScan(...)
2019-07-19 21:14:58.424 16905-16905/com.testapp V/BleScannerImplOreo: #GATT startScanInternal: pendingIntent=PendingIntent{1dfc67: android.os.BinderProxy@e560a14}
2019-07-19 21:14:58.468 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(948)] GATT_Register 3c2e1fd9-d3fd-6897-a113-863aa50df781
2019-07-19 21:14:58.468 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=7
2019-07-19 21:14:58.478 16905-16905/com.testapp V/BleScannerManager: scan: #GATT bleScanner.startScan(...); result=SUCCESS(0)
2019-07-19 21:14:58.479 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.startScan(...)
2019-07-19 21:14:58.481 16905-16905/com.testapp E/BleScannerManager: #GATT bleScannerStartScanCount=1, elapsedMillisSinceBleScannerStartScanFirstTime=0
2019-07-19 21:15:03.521 1447-1447/? D/BtGatt.ScanManager: awakened up at time 614650173
2019-07-19 21:15:08.250 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.stopScan(...)
2019-07-19 21:15:08.255 16905-16905/com.testapp V/BleScannerImplOreo: #GATT stopScanInternal: pendingIntent=PendingIntent{dc4115f: android.os.BinderProxy@84087ac}
2019-07-19 21:15:08.259 1447-1982/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@77d2d25
2019-07-19 21:15:08.260 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.stopScan(...)
2019-07-19 21:15:08.556 1447-1447/? D/BtGatt.ScanManager: awakened up at time 614655208
2019-07-19 21:15:08.570 1447-1554/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
2019-07-19 21:15:20.556 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.startScan(...)
2019-07-19 21:15:20.570 16905-16905/com.testapp V/BleScannerImplOreo: #GATT startScanInternal: pendingIntent=PendingIntent{2ce86d6: android.os.BinderProxy@84087ac}
2019-07-19 21:15:20.575 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(948)] GATT_Register 6b444e39-d61a-1d92-52d6-afd6e901b56b
2019-07-19 21:15:20.575 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=8
2019-07-19 21:15:20.576 16905-16905/com.testapp V/BleScannerManager: scan: #GATT bleScanner.startScan(...); result=SUCCESS(0)
2019-07-19 21:15:20.576 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.startScan(...)
2019-07-19 21:15:20.576 16905-16905/com.testapp E/BleScannerManager: #GATT bleScannerStartScanCount=2, elapsedMillisSinceBleScannerStartScanFirstTime=22097
2019-07-19 21:15:23.264 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.stopScan(...)
2019-07-19 21:15:23.269 16905-16905/com.testapp V/BleScannerImplOreo: #GATT stopScanInternal: pendingIntent=PendingIntent{ebafcb0: android.os.BinderProxy@ebb6729}
2019-07-19 21:15:23.272 1447-1982/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@3abaefa
2019-07-19 21:15:23.272 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.stopScan(...)
2019-07-19 21:15:24.968 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.startScan(...)
2019-07-19 21:15:24.980 16905-16905/com.testapp V/BleScannerImplOreo: #GATT startScanInternal: pendingIntent=PendingIntent{8b1626b: android.os.BinderProxy@ebb6729}
2019-07-19 21:15:24.990 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(948)] GATT_Register 0bbb0b8f-2c63-dfc2-268d-fbfe39360ddf
2019-07-19 21:15:24.990 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=9
2019-07-19 21:15:24.990 16905-16905/com.testapp V/BleScannerManager: scan: #GATT bleScanner.startScan(...); result=SUCCESS(0)
2019-07-19 21:15:24.990 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.startScan(...)
2019-07-19 21:15:24.991 16905-16905/com.testapp E/BleScannerManager: #GATT bleScannerStartScanCount=3, elapsedMillisSinceBleScannerStartScanFirstTime=26511
2019-07-19 21:15:25.019 1447-1554/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
2019-07-19 21:15:25.795 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(948)] GATT_Register 32a50296-06f2-ed4d-f83c-25da059a4a19
2019-07-19 21:15:25.795 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=10
2019-07-19 21:15:26.046 1447-1447/? D/BtGatt.ScanManager: awakened up at time 614672699
2019-07-19 21:15:27.000 16905-16905/com.testapp V/BleScannerManager: scan: #GATT +bleScanner.stopScan(...)
2019-07-19 21:15:27.005 16905-16905/com.testapp V/BleScannerImplOreo: #GATT stopScanInternal: pendingIntent=PendingIntent{40e339d: android.os.BinderProxy@6340012}
2019-07-19 21:15:27.008 1447-1982/? E/BtGatt.ContextMap: Context not found for info com.android.bluetooth.gatt.GattService$PendingIntentInfo@96b43b4
2019-07-19 21:15:27.009 16905-16905/com.testapp V/BleScannerManager: scan: #GATT -bleScanner.stopScan(...)
2019-07-19 21:15:28.679 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(948)] GATT_Register f119757a-00ff-29b4-72e0-952c5e0db695
2019-07-19 21:15:28.679 1447-1941/? I/bt_stack: [INFO:gatt_api.cc(968)] allocated gatt_if=10
2019-07-19 21:15:28.810 1447-1447/? D/BtGatt.ScanManager: awakened up at time 614675462
2019-07-19 21:15:28.822 1447-1554/? E/BtGatt.GattService: Exception: android.app.PendingIntent$CanceledException
看起来我要么在他们的回购协议上打开一个问题,要么自己解决,然后发给他们一份公关。
感谢那些插话的人;你的问题让我找到了正确的方向!
我试图用Ansible(V1.3.3)创建一个playbook,按照Pythonbrew自述文件中的说明在Debian服务器上安装Pythonbrew系统范围。 失败:[devserver]=>{“changed”:true,“cmd”:“pythonbrew install-v2.7.3”,“delta”:“0:00:00.016639”,“end”:“2013-10-11 15:21:40.9
问题内容: 是否有任何方法或库来获取系统范围的(全局)键盘快捷方式以在Java应用程序中执行操作? 问题答案: 没有,但是在Windows中,您可以使用以下命令: 准字型 不幸的是,我对Linux和OSX并没有任何了解,这可能就是为什么它不随Java一起提供的原因。 如果您找到其他平台,请在这里发布:) 只是出于好奇,您在做什么?
问题内容: 在Java中,我们使用System.setProperty()方法来设置一些系统属性。根据本文的介绍,使用系统属性有些棘手。 System.setProperty()可能是一个邪恶的调用。 这是100%线程敌对的 它包含超全局变量 当这些变量在运行时发生神秘变化时,调试非常困难。 我的问题如下。 系统属性的范围如何?它们是针对每个虚拟机专用还是具有“超全局性”,在每个虚拟机实例上共享相
我可以在xml配置中使用而没有任何问题,但如果将其用作如下注释。它会抛出以下错误 原因:组织。springframework。豆。工厂UnsatisfiedDependencyException:创建在类路径资源[BatchConfiguration.class]中定义的名为“step1”的bean时出错:通过索引1为[org.springframework.batch.item.ItemRead
问题内容: 有没有办法总是在任何android应用程序顶部绘制覆盖窗口? 我正在使用Android x86端口并具有系统权限。 @Edit:叠加层下方的视图应接收所有事件。 问题答案: 可以通过创建一个在当前视图中添加视图的方法来做到这一点: 但是您需要以下额外权限: 然后只需在清单中注册服务: 并启动它:
问题内容: 我正在实验室中运行Linux(Debian和Ubuntu)。用户名和组名由NIS和yp处理。我们有一些普通用户,每个人都可以访问该用户来运行实验,然后我们每个人都有自己的用户,此外还有一个共同的组,我们都是该组的成员。 如何使用户/组读取/写入(/可执行)共享驱动器(NFS)上的所有文件和目录?基本上我想要的是 或等效地。 但是运行以上命令只能修复文件夹中的当前文件,而umask仅适用