Loading src/com/android/bluetooth/btservice/AdapterService.java +26 −0 Original line number Diff line number Diff line Loading @@ -1123,6 +1123,13 @@ public class AdapterService extends Service { return service.getBondState(device); } public boolean isBondingInitiatedLocally(BluetoothDevice device) { // don't check caller, may be called from system UI AdapterService service = getService(); if (service == null) return false; return service.isBondingInitiatedLocally(device); } public int getConnectionState(BluetoothDevice device) { AdapterService service = getService(); if (service == null) return 0; Loading Loading @@ -1599,6 +1606,8 @@ public class AdapterService extends Service { return false; } deviceProp.setBondingInitiatedLocally(true); // Pairing is unreliable while scanning, so cancel discovery // Note, remove this when native stack improves cancelDiscoveryNative(); Loading Loading @@ -1878,6 +1887,12 @@ public class AdapterService extends Service { boolean cancelBondProcess(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); byte[] addr = Utils.getBytesFromAddress(device.getAddress()); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp != null) { deviceProp.setBondingInitiatedLocally(false); } return cancelBondNative(addr); } Loading @@ -1887,6 +1902,8 @@ public class AdapterService extends Service { if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDED) { return false; } deviceProp.setBondingInitiatedLocally(false); Message msg = mBondStateMachine.obtainMessage(BondStateMachine.REMOVE_BOND); msg.obj = device; mBondStateMachine.sendMessage(msg); Loading @@ -1902,6 +1919,15 @@ public class AdapterService extends Service { return deviceProp.getBondState(); } boolean isBondingInitiatedLocally(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp == null) { return false; } return deviceProp.isBondingInitiatedLocally(); } int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); byte[] addr = Utils.getBytesFromAddress(device.getAddress()); Loading src/com/android/bluetooth/btservice/RemoteDevices.java +19 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ final class RemoteDevices { private String mAlias; private int mBondState; private BluetoothDevice mDevice; private boolean isBondingInitiatedLocally; DeviceProperties() { mBondState = BluetoothDevice.BOND_NONE; Loading Loading @@ -217,6 +218,24 @@ final class RemoteDevices { return mBondState; } } /** * @param isBondingInitiatedLocally wether bonding is initiated locally */ void setBondingInitiatedLocally(boolean isBondingInitiatedLocally) { synchronized (mObject) { this.isBondingInitiatedLocally = isBondingInitiatedLocally; } } /** * @return the isBondingInitiatedLocally */ boolean isBondingInitiatedLocally() { synchronized (mObject) { return isBondingInitiatedLocally; } } } private void sendUuidIntent(BluetoothDevice device) { Loading Loading
src/com/android/bluetooth/btservice/AdapterService.java +26 −0 Original line number Diff line number Diff line Loading @@ -1123,6 +1123,13 @@ public class AdapterService extends Service { return service.getBondState(device); } public boolean isBondingInitiatedLocally(BluetoothDevice device) { // don't check caller, may be called from system UI AdapterService service = getService(); if (service == null) return false; return service.isBondingInitiatedLocally(device); } public int getConnectionState(BluetoothDevice device) { AdapterService service = getService(); if (service == null) return 0; Loading Loading @@ -1599,6 +1606,8 @@ public class AdapterService extends Service { return false; } deviceProp.setBondingInitiatedLocally(true); // Pairing is unreliable while scanning, so cancel discovery // Note, remove this when native stack improves cancelDiscoveryNative(); Loading Loading @@ -1878,6 +1887,12 @@ public class AdapterService extends Service { boolean cancelBondProcess(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); byte[] addr = Utils.getBytesFromAddress(device.getAddress()); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp != null) { deviceProp.setBondingInitiatedLocally(false); } return cancelBondNative(addr); } Loading @@ -1887,6 +1902,8 @@ public class AdapterService extends Service { if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDED) { return false; } deviceProp.setBondingInitiatedLocally(false); Message msg = mBondStateMachine.obtainMessage(BondStateMachine.REMOVE_BOND); msg.obj = device; mBondStateMachine.sendMessage(msg); Loading @@ -1902,6 +1919,15 @@ public class AdapterService extends Service { return deviceProp.getBondState(); } boolean isBondingInitiatedLocally(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp == null) { return false; } return deviceProp.isBondingInitiatedLocally(); } int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); byte[] addr = Utils.getBytesFromAddress(device.getAddress()); Loading
src/com/android/bluetooth/btservice/RemoteDevices.java +19 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ final class RemoteDevices { private String mAlias; private int mBondState; private BluetoothDevice mDevice; private boolean isBondingInitiatedLocally; DeviceProperties() { mBondState = BluetoothDevice.BOND_NONE; Loading Loading @@ -217,6 +218,24 @@ final class RemoteDevices { return mBondState; } } /** * @param isBondingInitiatedLocally wether bonding is initiated locally */ void setBondingInitiatedLocally(boolean isBondingInitiatedLocally) { synchronized (mObject) { this.isBondingInitiatedLocally = isBondingInitiatedLocally; } } /** * @return the isBondingInitiatedLocally */ boolean isBondingInitiatedLocally() { synchronized (mObject) { return isBondingInitiatedLocally; } } } private void sendUuidIntent(BluetoothDevice device) { Loading