Loading core/java/android/bluetooth/BluetoothDevice.java +5 −1 Original line number Diff line number Diff line Loading @@ -287,9 +287,13 @@ public final class BluetoothDevice implements Parcelable { /** A bond attempt failed because of repeated attempts * @hide */ public static final int UNBOND_REASON_REPEATED_ATTEMPTS = 7; /** A bond attempt failed because we received an Authentication Cancel * by remote end * @hide */ public static final int UNBOND_REASON_REMOTE_AUTH_CANCELED = 8; /** An existing bond was explicitly revoked * @hide */ public static final int UNBOND_REASON_REMOVED = 8; public static final int UNBOND_REASON_REMOVED = 9; /** The user will be prompted to enter a pin * @hide */ Loading core/java/android/server/BluetoothEventLoop.java +21 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BluetoothEventLoop { private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; private static final int EVENT_RESTART_BLUETOOTH = 2; private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 3; private static final int EVENT_AGENT_CANCEL = 4; private static final int CREATE_DEVICE_ALREADY_EXISTS = 1; private static final int CREATE_DEVICE_SUCCESS = 0; Loading Loading @@ -90,6 +91,22 @@ class BluetoothEventLoop { mBluetoothService.setPairingConfirmation(address, true); } break; case EVENT_AGENT_CANCEL: // Set the Bond State to BOND_NONE. // We always have only 1 device in BONDING state. String[] devices = mBluetoothService.getBondState().listInState(BluetoothDevice.BOND_BONDING); if (devices.length == 0) { break; } else if (devices.length > 1) { Log.e(TAG, " There is more than one device in the Bonding State"); break; } address = devices[0]; mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_REMOTE_AUTH_CANCELED); break; } } }; Loading Loading @@ -544,6 +561,10 @@ class BluetoothEventLoop { private void onAgentCancel() { Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_AGENT_CANCEL), 1500); return; } Loading core/java/android/server/BluetoothService.java +1 −1 Original line number Diff line number Diff line Loading @@ -571,7 +571,7 @@ public class BluetoothService extends IBluetooth.Stub { return state.intValue(); } private synchronized String[] listInState(int state) { /*package*/ synchronized String[] listInState(int state) { ArrayList<String> result = new ArrayList<String>(mState.size()); for (Map.Entry<String, Integer> e : mState.entrySet()) { if (e.getValue().intValue() == state) { Loading Loading
core/java/android/bluetooth/BluetoothDevice.java +5 −1 Original line number Diff line number Diff line Loading @@ -287,9 +287,13 @@ public final class BluetoothDevice implements Parcelable { /** A bond attempt failed because of repeated attempts * @hide */ public static final int UNBOND_REASON_REPEATED_ATTEMPTS = 7; /** A bond attempt failed because we received an Authentication Cancel * by remote end * @hide */ public static final int UNBOND_REASON_REMOTE_AUTH_CANCELED = 8; /** An existing bond was explicitly revoked * @hide */ public static final int UNBOND_REASON_REMOVED = 8; public static final int UNBOND_REASON_REMOVED = 9; /** The user will be prompted to enter a pin * @hide */ Loading
core/java/android/server/BluetoothEventLoop.java +21 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BluetoothEventLoop { private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; private static final int EVENT_RESTART_BLUETOOTH = 2; private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 3; private static final int EVENT_AGENT_CANCEL = 4; private static final int CREATE_DEVICE_ALREADY_EXISTS = 1; private static final int CREATE_DEVICE_SUCCESS = 0; Loading Loading @@ -90,6 +91,22 @@ class BluetoothEventLoop { mBluetoothService.setPairingConfirmation(address, true); } break; case EVENT_AGENT_CANCEL: // Set the Bond State to BOND_NONE. // We always have only 1 device in BONDING state. String[] devices = mBluetoothService.getBondState().listInState(BluetoothDevice.BOND_BONDING); if (devices.length == 0) { break; } else if (devices.length > 1) { Log.e(TAG, " There is more than one device in the Bonding State"); break; } address = devices[0]; mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_REMOTE_AUTH_CANCELED); break; } } }; Loading Loading @@ -544,6 +561,10 @@ class BluetoothEventLoop { private void onAgentCancel() { Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_AGENT_CANCEL), 1500); return; } Loading
core/java/android/server/BluetoothService.java +1 −1 Original line number Diff line number Diff line Loading @@ -571,7 +571,7 @@ public class BluetoothService extends IBluetooth.Stub { return state.intValue(); } private synchronized String[] listInState(int state) { /*package*/ synchronized String[] listInState(int state) { ArrayList<String> result = new ArrayList<String>(mState.size()); for (Map.Entry<String, Integer> e : mState.entrySet()) { if (e.getValue().intValue() == state) { Loading