У меня есть приложение, которое использует Bluetooth
для подключения к другому устройству. Приложение работает хорошо, за исключением случаев, когда оно выходит на передний план из фона. Когда входной канал создан, приложение задерживается на некоторое время (~ 5 секунд) и затем подключается. Нет задержки при первом подключении к устройству, но только когда я выхожу на передний план после его фонового изображения. Я не могу найти причину этого. Я хотел бы получить любую обратную связь.
Ниже приведен выход при первом подключении к Bluetooth
02-04 14:49:08.270 D/InputMethodManager(21997): prepareNavigationBarInfo() DecorView@a864988[RemoteActivity]
02-04 14:49:08.271 D/InputMethodManager(21997): getNavigationBarColor() -855310
02-04 14:49:08.300 D/InputMethodManager(21997): prepareNavigationBarInfo() DecorView@a864988[RemoteActivity]
02-04 14:49:08.300 D/InputMethodManager(21997): getNavigationBarColor() -855310
02-04 14:49:08.301 V/InputMethodManager(21997): Starting input: tba=com.interactive.Restomod ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
02-04 14:49:08.302 D/InputMethodManager(21997): startInputInner - Id : 0
02-04 14:49:08.302 I/InputMethodManager(21997): startInputInner - mService.startInputOrWindowGainedFocus
02-04 14:49:08.323 I/active.Restomo(21997): NativeAlloc concurrent copying GC freed 1625(199KB) AllocSpace objects, 2(40KB) LOS objects, 49% free, 2MB/4MB, paused 276us total 104.407ms
02-04 14:49:08.333 D/InputTransport(21997): Input channel constructed: fd=79
02-04 14:49:08.382 D/Mono (21997): DllImport searching in: '__Internal' ('(null)').
02-04 14:49:08.382 D/Mono (21997): Searching for 'java_interop_jnienv_call_byte_method_a'.
02-04 14:49:08.382 D/Mono (21997): Probing 'java_interop_jnienv_call_byte_method_a'.
02-04 14:49:08.382 D/Mono (21997): Found as 'java_interop_jnienv_call_byte_method_a'.
02-04 14:49:08.426 D/BluetoothAdapter(21997): STATE_ON
02-04 14:49:08.431 D/BluetoothGatt(21997): connect() - device: 00:60:37:59:DE:79, auto: false
02-04 14:49:08.432 D/BluetoothAdapter(21997): isSecureModeEnabled
02-04 14:49:08.433 D/BluetoothGatt(21997): registerApp()
02-04 14:49:08.433 D/BluetoothGatt(21997): registerApp() - UUID=42b82bb2-dca0-4a30-a189-0145b4a4c7af
02-04 14:49:08.438 D/InputMethodManager(21997): prepareNavigationBarInfo() DecorView@a864988[RemoteActivity]
02-04 14:49:08.438 D/InputMethodManager(21997): getNavigationBarColor() -855310
02-04 14:49:08.438 V/InputMethodManager(21997): Starting input: tba=com.interactive.Restomod ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
02-04 14:49:08.438 D/InputMethodManager(21997): startInputInner - Id : 0
02-04 14:49:08.440 D/BluetoothGatt(21997): onClientRegistered() - status=0 clientIf=10
02-04 14:49:08.463 D/BluetoothGatt(21997): onClientConnectionState() - status=0 clientIf=10 device=00:60:37:59:DE:79
02-04 14:49:08.480 D/BluetoothGatt(21997): configureMTU() - device: 00:60:37:59:DE:79 mtu: 46
02-04 14:49:08.486 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
Thread started: #17
02-04 14:49:08.515 D/BluetoothGatt(21997): discoverServices() - device: 00:60:37:59:DE:79
02-04 14:49:08.540 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:49:08.562 D/BluetoothGatt(21997): onSearchComplete() = Device=00:60:37:59:DE:79 Status=0
02-04 14:49:08.863 D/BluetoothAdapter(21997): STATE_ON
02-04 14:49:08.868 D/BluetoothGatt(21997): connect() - device: 00:60:37:59:DE:79, auto: false
02-04 14:49:08.868 D/BluetoothAdapter(21997): isSecureModeEnabled
02-04 14:49:08.873 D/BluetoothGatt(21997): registerApp()
02-04 14:49:08.874 D/BluetoothGatt(21997): registerApp() - UUID=660de611-0d74-49e3-9585-329191f068b9
02-04 14:49:08.879 D/BluetoothGatt(21997): onClientRegistered() - status=0 clientIf=11
02-04 14:49:08.889 D/BluetoothGatt(21997): onClientConnectionState() - status=0 clientIf=11 device=00:60:37:59:DE:79
02-04 14:49:08.895 D/BluetoothGatt(21997): configureMTU() - device: 00:60:37:59:DE:79 mtu: 46
02-04 14:49:08.897 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:49:08.897 D/BluetoothGatt(21997): discoverServices() - device: 00:60:37:59:DE:79
02-04 14:49:08.918 D/BluetoothGatt(21997): onSearchComplete() = Device=00:60:37:59:DE:79 Status=0
02-04 14:49:08.989 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:49:09.280 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00001 enable: true
02-04 14:49:09.442 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00002 enable: true
02-04 14:49:09.623 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00003 enable: true
02-04 14:49:09.802 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00004 enable: true
02-04 14:49:09.983 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00005 enable: true
02-04 14:49:10.164 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00006 enable: true
02-04 14:49:10.348 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00007 enable: true
02-04 14:49:10.531 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00009 enable: true
02-04 14:49:10.711 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000a enable: true
02-04 14:49:11.027 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000c enable: true
02-04 14:49:11.300 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000e enable: true
02-04 14:49:11.560 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00010 enable: true
Ниже приведен мой вывод, когда я go в фоновом режиме, а затем подключить до Bluetooth
. Время между созданием канала и onClientConnectionState () всегда отличается и занимает целых 5 секунд
02-04 14:55:52.855 D/InputMethodManager(21997): getNavigationBarColor() -855310
02-04 14:55:52.865 D/InputMethodManager(21997): prepareNavigationBarInfo() DecorView@a864988[RemoteActivity]
02-04 14:55:52.866 D/InputMethodManager(21997): getNavigationBarColor() -855310
02-04 14:55:52.866 V/InputMethodManager(21997): Starting input: tba=com.interactive.Restomod ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
02-04 14:55:52.866 D/InputMethodManager(21997): startInputInner - Id : 0
02-04 14:55:52.867 I/InputMethodManager(21997): startInputInner - mService.startInputOrWindowGainedFocus
02-04 14:55:52.875 D/InputTransport(21997): Input channel constructed: fd=81
02-04 14:55:53.576 D/BluetoothGatt(21997): onClientConnectionState() - status=0 clientIf=8 device=00:60:37:59:DE:79
02-04 14:55:53.588 D/BluetoothGatt(21997): configureMTU() - device: 00:60:37:59:DE:79 mtu: 46
02-04 14:55:53.994 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:55:53.995 D/BluetoothGatt(21997): discoverServices() - device: 00:60:37:59:DE:79
02-04 14:55:54.022 D/BluetoothGatt(21997): onSearchComplete() = Device=00:60:37:59:DE:79 Status=0
02-04 14:55:54.039 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-40882af10001 enable: true
02-04 14:55:54.042 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-40882af10003 enable: true
02-04 14:55:55.126 D/BluetoothAdapter(21997): STATE_ON
02-04 14:55:55.132 D/BluetoothGatt(21997): connect() - device: 00:60:37:59:DE:79, auto: false
02-04 14:55:55.133 D/BluetoothAdapter(21997): isSecureModeEnabled
02-04 14:55:55.135 D/BluetoothGatt(21997): registerApp()
02-04 14:55:55.135 D/BluetoothGatt(21997): registerApp() - UUID=fe782919-d927-483b-8430-e37c38fb3a6d
02-04 14:55:55.143 D/BluetoothGatt(21997): onClientRegistered() - status=0 clientIf=10
02-04 14:55:55.154 D/BluetoothGatt(21997): onClientConnectionState() - status=0 clientIf=10 device=00:60:37:59:DE:79
02-04 14:55:55.160 D/BluetoothGatt(21997): configureMTU() - device: 00:60:37:59:DE:79 mtu: 46
02-04 14:55:55.163 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:55:55.164 D/BluetoothGatt(21997): discoverServices() - device: 00:60:37:59:DE:79
02-04 14:55:55.176 D/BluetoothGatt(21997): onSearchComplete() = Device=00:60:37:59:DE:79 Status=0
02-04 14:55:55.252 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:55:55.458 D/BluetoothAdapter(21997): STATE_ON
02-04 14:55:55.462 D/BluetoothGatt(21997): connect() - device: 00:60:37:59:DE:79, auto: false
02-04 14:55:55.462 D/BluetoothAdapter(21997): isSecureModeEnabled
02-04 14:55:55.463 D/BluetoothGatt(21997): registerApp()
02-04 14:55:55.464 D/BluetoothGatt(21997): registerApp() - UUID=5c4177a2-153e-46bb-b27a-18be57023ed5
02-04 14:55:55.471 D/BluetoothGatt(21997): onClientRegistered() - status=0 clientIf=11
02-04 14:55:55.483 D/BluetoothGatt(21997): onClientConnectionState() - status=0 clientIf=11 device=00:60:37:59:DE:79
02-04 14:55:55.489 D/BluetoothGatt(21997): configureMTU() - device: 00:60:37:59:DE:79 mtu: 46
02-04 14:55:55.493 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:55:55.493 D/BluetoothGatt(21997): discoverServices() - device: 00:60:37:59:DE:79
02-04 14:55:55.507 D/BluetoothGatt(21997): onSearchComplete() = Device=00:60:37:59:DE:79 Status=0
02-04 14:55:55.566 D/BluetoothGatt(21997): onConfigureMTU() - Device=00:60:37:59:DE:79 mtu=46 status=0
02-04 14:55:55.840 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00001 enable: true
02-04 14:55:56.026 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00002 enable: true
02-04 14:55:56.205 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00003 enable: true
02-04 14:55:56.381 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00004 enable: true
02-04 14:55:56.561 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00005 enable: true
02-04 14:55:56.745 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00006 enable: true
02-04 14:55:56.972 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00007 enable: true
02-04 14:55:57.151 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00009 enable: true
02-04 14:55:57.378 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000a enable: true
02-04 14:55:57.646 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000c enable: true
02-04 14:55:57.920 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf0000e enable: true
02-04 14:55:58.187 D/BluetoothGatt(21997): setCharacteristicNotification() - uuid: 49646561-7346-6c6f-6174-43882bf00010 enable: true