试图在LG G5上配对,不会将状态更改为BONDED

时间:2018-02-28 11:08:19

标签: android bluetooth bluetooth-lowenergy android-bluetooth pairing

这是我打电话的方法:

     Method method = device.getClass().getMethod("createBond", (Class[]) null);
        method.invoke(device, (Object[]) null);

这是我注册的ACTION_BOND_STATE_CHANGED接收器:

    private final BroadcastReceiver mPairReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
            final int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
            final int prevState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR);

            if (state == BluetoothDevice.BOND_BONDED && prevState == BluetoothDevice.BOND_BONDING) {
                Log.i("", "mPairReceiver Paired");
                connectGatt();
            } else if (state == BluetoothDevice.BOND_NONE && prevState == BluetoothDevice.BOND_BONDED) {
                Log.i("", "mPairReceiver Unpaired");
            }

        }
    }
};

我收到了BONDING事件,然后是NONE事件。如果我从设置中检入蓝牙设备列表,则设备未配对。为什么? 相同的代码适用于LG NExus 5和LeEco与Android 6。 LG G5拥有Android 7

修改

我尝试与设置中的信标配对 - >蓝牙页面,我得到了同样的问题。我输入了代码并说它没有配对。 这就是我想要连接到的: https://nl.aliexpress.com/item/3-pcs-BLE-4-0-Base-Station-Ebeoo-iBeacon-USB/32752285433.html?spm=a2g0s.9042311.0.0.g1aZkv

Logcat如果有帮助:

02-28 12:21:50.863: D/InputTransport(1634): channel '44ead2f com.lge.bluetoothsetting/com.lge.bluetoothsetting.LGBluetoothSettingActivity (server)' : action=ACTION_UP(0), id=0, tooltype=1, deviceId=3, source=0x1002, flags=0x0, edgeFlags=0x0, metaState=0x0, buttonState=0x0, downTime=5327229168000, eventTime=5327286572000, pointerCount=1
02-28 12:21:50.999: W/LGMDMUISystemServiceAdapter(2859): checkBluetoothPairing btPolicy: false
02-28 12:21:51.026: W/LGMDMUISystemServiceAdapter(2859): checkBluetoothPairing btPolicy: false
02-28 12:21:51.036: I/BIO SDSERVICE 2(6741): SDService::[bluetoothReceiver:: onReceive] action: android.bluetooth.device.action.BOND_STATE_CHANGED
02-28 12:21:52.111: D/[SmartSettings][InternalReceiver](28260): event = android.bluetooth.device.action.BOND_STATE_CHANGED
02-28 12:21:53.352: I/TrustAgent.Tracker(2992): [BluetoothConnectionTracker] Bluetooth connect broadast for PsngrBeacon 1656 98:7B:F3:4A:9F:1F
02-28 12:21:53.630: W/LGMDMUISystemServiceAdapter(29920): checkBluetoothPairing btPolicy: false
02-28 12:21:53.640: D/PowerManagerServiceEx(1634): acquireWakeLockInternal: lock=222747315, flags=0x3000001a, tag="LGBluetoothAlertSound", ws=null, historyTag=null, uid=1000, pid=29920
02-28 12:21:53.640: D/PowerManagerServiceEx(1634): applyWakeLockFlagsOnAcquireLocked: wakeLock =FULL_WAKE_LOCK                 'LGBluetoothAlertSound' ACQUIRE_CAUSES_WAKEUP ON_AFTER_RELEASE  com.lge.bluetoothsetting (uid=1000, pid=29920, ws=null) uptime = 0, uid=1000
02-28 12:21:53.645: E/BluetoothSettings(29920): [LGBluetoothAuthorization.java:51:isLockScreenExist()] oooooo [BTUI] ### PAIR_REQUEST : isLockScreen (false)
02-28 12:21:53.646: W/ContextImpl(29920): Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:769 android.content.ContextWrapper.startActivity:356 android.content.ContextWrapper.startActivity:356 com.lge.bluetoothsetting.BluetoothPairingRequest.onReceive:117 android.app.ActivityThread.handleReceiver:3091 
02-28 12:21:53.647: W/ContextImpl(29920): Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:781 android.app.ContextImpl.startActivity:770 android.content.ContextWrapper.startActivity:356 android.content.ContextWrapper.startActivity:356 com.lge.bluetoothsetting.BluetoothPairingRequest.onReceive:117 
02-28 12:21:53.648: I/Timeline(29920): Timeline: Activity_launch_request id:com.lge.bluetoothsetting time:5330082
02-28 12:21:53.651: I/ActivityManager(1634): START u0 {act=android.bluetooth.device.action.PAIRING_REQUEST flg=0x10040000 cmp=com.lge.bluetoothsetting/.BluetoothPairingDialog (has extras)} from uid 1000 on display 0
02-28 12:21:53.667: D/ActivityManager(1634): setTaskToReturnTo : TaskRecord{73fd870 #279 I=com.lge.bluetoothsetting/.BluetoothPairingDialog U=0 StackId=1 sz=0} / mTaskToReturnTo = 0
02-28 12:21:53.667: D/ActivityManager(1634): setTaskToReturnTo : TaskRecord{73fd870 #279 I=com.lge.bluetoothsetting/.BluetoothPairingDialog U=0 StackId=1 sz=0} / mTaskToReturnTo = 0
02-28 12:21:53.669: D/LGImageQualityEnhancementService(2666): activityStarting: com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog
02-28 12:21:53.671: D/InputDispatcher(1634): Focus left window: Window{44ead2f u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.LGBluetoothSettingActivity}
02-28 12:21:53.741: D/LGImageQualityEnhancementService(2666): activityResuming: com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog
02-28 12:21:53.749: I/BIO SDSERVICE 2(6741): SDService::[bluetoothReceiver:: onReceive] action: android.bluetooth.adapter.action.SCAN_MODE_CHANGED
02-28 12:21:53.755: E/BluetoothSettings(29920): [BluetoothPairingDialog.java:149:onCreate()] oooooo onCreate mUserConfirmed : false
02-28 12:21:53.758: E/BluetoothSettings(29920): [BluetoothPairingDialog.java:225:onCreate()] oooooo [BTUI] [1] PAIRING_VARIANT_PIN
02-28 12:21:53.828: D/InputDispatcher(1634): Focus entered window: Window{fbe6b46 u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog}
02-28 12:21:53.900: W/ActivityManager(1634): Sending non-protected broadcast com.lge.systemservice.core.cliptray.EDITOR_CLIPTRAY from system 29920:com.android.settings/1000 pkg com.lge.bluetoothsetting
02-28 12:21:53.901: W/ActivityManager(1634): Sending non-protected broadcast com.lge.systemservice.core.cliptray.EDITOR_CLIPTRAY from system 29920:com.android.settings/1000 pkg com.lge.bluetoothsetting
02-28 12:21:53.909: I/ActivityManager(1634): Displayed com.lge.bluetoothsetting/.BluetoothPairingDialog: +168ms
02-28 12:21:53.912: I/WindowManager(1634): Window{fbe6b46 u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog} start dimming: flags=1800002 effectFlags=0, layer=21025
02-28 12:21:53.928: I/WindowManager(1634): Window{fbe6b46 u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog} start dimming: flags=1800002 effectFlags=0, layer=21025
02-28 12:21:53.929: D/Cliptray Service(2666): packageName : com.lge.bluetoothsetting
02-28 12:21:54.455: D/[SmartSettings][InternalReceiver](28260): event = android.bluetooth.device.action.ACL_CONNECTED
02-28 12:21:54.462: D/[SmartSettings][InternalReceiver](28260): Bluetooth device connected
02-28 12:21:59.823: D/InputTransport(1634): channel 'fbe6b46 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog (server)' : action=ACTION_DOWN(0), id=0, tooltype=1, deviceId=3, source=0x1002, flags=0x0, edgeFlags=0x0, metaState=0x0, buttonState=0x0, downTime=5336238946000, eventTime=5336238946000, pointerCount=1
02-28 12:21:59.890: D/InputTransport(1634): channel 'fbe6b46 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog (server)' : action=ACTION_UP(0), id=0, tooltype=1, deviceId=3, source=0x1002, flags=0x0, edgeFlags=0x0, metaState=0x0, buttonState=0x0, downTime=5336238946000, eventTime=5336313760000, pointerCount=1
02-28 12:21:59.898: D/ActivityManager(1634): setTaskToReturnTo : TaskRecord{73fd870 #279 I=com.lge.bluetoothsetting/.BluetoothPairingDialog U=0 StackId=1 sz=1} / mTaskToReturnTo = 1
02-28 12:21:59.924: D/InputDispatcher(1634): Focus left window: Window{fbe6b46 u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog}
02-28 12:21:59.924: D/InputDispatcher(1634): Focus entered window: Window{44ead2f u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.LGBluetoothSettingActivity}
02-28 12:21:59.935: D/LGImageQualityEnhancementService(2666): activityResuming: com.lge.bluetoothsetting/com.lge.bluetoothsetting.LGBluetoothSettingActivity
02-28 12:22:00.047: W/ActivityManager(1634): Sending non-protected broadcast com.lge.systemservice.core.cliptray.HIDE_CLIPTRAY from system 29920:com.android.settings/1000 pkg com.lge.bluetoothsetting
02-28 12:22:00.617: I/BIO SDSERVICE 2(6741): SDService::[bluetoothReceiver:: onReceive] action: android.bluetooth.adapter.action.SCAN_MODE_CHANGED
02-28 12:22:00.896: W/ActivityManager(1634): Sending non-protected broadcast com.lge.systemservice.core.cliptray.HIDE_CLIPTRAY from system 29920:com.android.settings/1000 pkg com.lge.bluetoothsetting
02-28 12:22:00.902: I/WindowManager(1634): Destroying surface Surface(name=com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog) called by com.android.server.wm.WindowStateAnimator.destroySurface:2180 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:961 com.android.server.wm.WindowState.removeLocked:1517 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2846 com.android.server.wm.WindowManagerService.removeWindowLocked:2801 com.android.server.wm.WindowManagerService.removeWindowLocked:2664 com.android.server.wm.WindowManagerServiceEx.removeWindowLocked:505 com.android.server.wm.WindowManagerService.removeWindow:2659 
02-28 12:22:00.906: D/InputDispatcher(1634): Window went away: Window{fbe6b46 u0 com.lge.bluetoothsetting/com.lge.bluetoothsetting.BluetoothPairingDialog}
02-28 12:22:03.647: D/PowerManagerServiceEx(1634): releaseWakeLockInternal: lock=222747315 [LGBluetoothAlertSound], flags=0x0
02-28 12:22:13.773: D/BluetoothMapService(2859): onReceive: android.bluetooth.device.action.ACL_DISCONNECTED
02-28 12:22:13.778: I/TrustAgent.Tracker(2992): [BluetoothConnectionTracker] Bluetooth disconnect broadast for PsngrBeacon 1656 98:7B:F3:4A:9F:1F
02-28 12:22:13.785: V/BluetoothPbapReceiver(2859): ***********action = android.bluetooth.device.action.ACL_DISCONNECTED
02-28 12:22:13.794: D/HidService(2859): getHidService(): returning com.android.bluetooth.hid.HidService@a095eb9
02-28 12:22:13.794: D/A2dpService(2859): getA2DPService(): returning com.android.bluetooth.a2dp.A2dpService@7cbd38
02-28 12:22:13.794: I/BIO SDSERVICE 2(6741): SDService::[bluetoothReceiver:: onReceive] action: android.bluetooth.device.action.BOND_STATE_CHANGED
02-28 12:22:13.796: V/LGSettingsProvider(1634): call_put(global:bluetooth_input_device_priority_98:7B:F3:4A:9F:1F=-1)  calling package = com.android.bluetooth  callingUserId : 0
02-28 12:22:13.799: V/LGSettingsProvider(1634): call_put(global:bluetooth_a2dp_sink_priority_98:7B:F3:4A:9F:1F=-1)  calling package = com.android.bluetooth  callingUserId : 0
02-28 12:22:13.801: V/LGSettingsProvider(1634): call_put(global:bluetooth_headset_priority_98:7B:F3:4A:9F:1F=-1)  calling package = com.android.bluetooth  callingUserId : 0
02-28 12:22:13.806: V/BluetoothPbapService(2859): action: android.bluetooth.device.action.ACL_DISCONNECTED
02-28 12:22:20.990: D/[SmartSettings][InternalReceiver](28260): event = android.bluetooth.device.action.BOND_STATE_CHANGED

0 个答案:

没有答案