改法如下
--- a/packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
+++ b/packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
@@ -28,6 +28,9 @@ import android.content.Intent;
import android.content.res.Resources;
import android.text.TextUtils;
import android.os.PowerManager;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothUuid;\r
+import android.util.Log;\r
/**
* BluetoothPairingRequest is a receiver for any Bluetooth pairing request. It
@@ -38,11 +41,13 @@ import android.os.PowerManager;
public final class BluetoothPairingRequest extends BroadcastReceiver {
private static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
+ private BluetoothDevice mDevice;
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
+ mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
// convert broadcast intent into activity intent (same action string)
BluetoothDevice device =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@@ -59,6 +64,13 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
BluetoothDevice.ERROR);
pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
}
+ Log.i("fan","type is "+type);
+ if(type==BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION || type==BluetoothDevice.PAIRING_VARIANT_CONSENT) {
+ Log.i("fan","pair no need confirm ");
+ mDevice.setPairingConfirmation(true);
+ return;
+
+ }
pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
713

被折叠的 条评论
为什么被折叠?



