From 356c58a31ab0e605cb51d833398e987d15daccb2 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期三, 25 十一月 2020 16:12:03 +0800 Subject: [PATCH] 蓝牙 --- lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java b/lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java index eb40b1a..9fa6015 100644 --- a/lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java +++ b/lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java @@ -47,7 +47,7 @@ filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); filter.addAction("android.bluetooth.device.action.PAIRING_REQUEST"); - filter.setPriority(1000); +// filter.setPriority(1000); context.registerReceiver(this, filter); } @@ -129,11 +129,12 @@ OpenBluetooth(); } } else if (action.equals("android.bluetooth.device.action.PAIRING_REQUEST")) { - Log.d(TAG, "鍖归厤璇锋眰"); // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); String name = device.getName(); + + Log.d(TAG, "鍖归厤璇锋眰 " + name); if (pin == null && name != null && name.contains("AKS3A_") && name.length() >= 8) { char [] sn = new char[8]; @@ -150,10 +151,11 @@ pin = DEFAULT_BT_PASSWORD; } - Log.d(TAG, "鍖归厤鍚� " + pin); + Log.d(TAG, "钃濈墮Pin " + pin); /*if (device.getName().equals(BLUETOOTH_OBD_NAME) || device.getName().equals(BLUETOOTH_TARGET2_NAME)) */{ try { - ClsUtils.setPairingConfirmation(device.getClass(), device, true); + // 绗笁鏂圭殑绯荤粺闇�瑕佹敞閲婃帀锛屽惁鍒欎細鎶涘紓甯� +// ClsUtils.setPairingConfirmation(device.getClass(), device, true); Log.d(TAG, "isOrderedBroadcast:"+isOrderedBroadcast()+",isInitialStickyBroadcast:"+isInitialStickyBroadcast()); if (isOrderedBroadcast()) { abortBroadcast(); @@ -161,7 +163,7 @@ ClsUtils.setPin(device.getClass(), device, pin); } catch (Exception e) { - Log.e(TAG, e.getMessage()); + } } } else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) { -- Gitblit v1.8.0