Loading core/java/android/bluetooth/BluetoothDeviceProfileState.java +2 −2 Original line number Diff line number Diff line Loading @@ -1048,12 +1048,12 @@ public final class BluetoothDeviceProfileState extends StateMachine { break; case CONNECT_HID_INCOMING: if (!accept) { ret = mService.allowIncomingHidConnect(mDevice, false); ret = mService.allowIncomingProfileConnect(mDevice, false); sendMessage(TRANSITION_TO_STABLE); updateIncomingAllowedTimer(); } else { writeTimerValue(0); ret = mService.allowIncomingHidConnect(mDevice, true); ret = mService.allowIncomingProfileConnect(mDevice, true); } break; default: Loading core/java/android/bluetooth/BluetoothInputDevice.java +0 −22 Original line number Diff line number Diff line Loading @@ -308,28 +308,6 @@ public final class BluetoothInputDevice implements BluetoothProfile { return BluetoothProfile.PRIORITY_OFF; } /** * Allow or disallow incoming connection * @param device Input device * @param allow true / false * @return Success or Failure of the operation * @hide */ public boolean allowIncomingConnect(BluetoothDevice device, boolean allow) { if (DBG) log("allowIncomingConnect(" + device + ", " + allow + ")"); if (mService == null || !isEnabled() || !isValidDevice(device)) { return false; } try { mService.allowIncomingHidConnect(device, allow); } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); return false; } return true; } private boolean isEnabled() { if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true; return false; Loading core/java/android/bluetooth/IBluetooth.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ interface IBluetooth int addRfcommServiceRecord(in String serviceName, in ParcelUuid uuid, int channel, IBinder b); void removeServiceRecord(int handle); boolean allowIncomingProfileConnect(in BluetoothDevice device, boolean value); boolean connectHeadset(String address); boolean disconnectHeadset(String address); Loading @@ -98,7 +99,6 @@ interface IBluetooth int getInputDeviceConnectionState(in BluetoothDevice device); boolean setInputDevicePriority(in BluetoothDevice device, int priority); int getInputDevicePriority(in BluetoothDevice device); boolean allowIncomingHidConnect(in BluetoothDevice device, boolean value); boolean isTetheringOn(); void setBluetoothTethering(boolean value); Loading core/java/android/server/BluetoothEventLoop.java +16 −17 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ class BluetoothEventLoop { private final BluetoothAdapter mAdapter; private final BluetoothAdapterStateMachine mBluetoothState; private BluetoothA2dp mA2dp; private BluetoothInputDevice mInputDevice; private final Context mContext; // The WakeLock is used for bringing up the LCD during a pairing request // from remote device when Android is in Suspend state. Loading Loading @@ -134,15 +133,11 @@ class BluetoothEventLoop { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (profile == BluetoothProfile.A2DP) { mA2dp = (BluetoothA2dp) proxy; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = (BluetoothInputDevice) proxy; } } public void onServiceDisconnected(int profile) { if (profile == BluetoothProfile.A2DP) { mA2dp = null; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = null; } } }; Loading Loading @@ -803,21 +798,25 @@ class BluetoothEventLoop { "Incoming A2DP / AVRCP connection from " + address); mA2dp.allowIncomingConnect(device, authorized); } } else if (mInputDevice != null && BluetoothUuid.isInputDevice(uuid)) { } else if (BluetoothUuid.isInputDevice(uuid)) { // We can have more than 1 input device connected. authorized = mInputDevice.getPriority(device) > BluetoothInputDevice.PRIORITY_OFF; authorized = mBluetoothService.getInputDevicePriority(device) > BluetoothInputDevice.PRIORITY_OFF; if (authorized) { Log.i(TAG, "First check pass for incoming HID connection from " + address); // notify profile state change mBluetoothService.notifyIncomingHidConnection(address); } else { Log.i(TAG, "Rejecting incoming HID connection from " + address); mBluetoothService.allowIncomingHidConnect(device, authorized); mBluetoothService.allowIncomingProfileConnect(device, authorized); } } else if (BluetoothUuid.isBnep(uuid) && mBluetoothService.allowIncomingTethering()){ authorized = true; } else if (BluetoothUuid.isBnep(uuid)) { // PAN doesn't go to the state machine, accept or reject from here authorized = mBluetoothService.allowIncomingTethering(); mBluetoothService.allowIncomingProfileConnect(device, authorized); } else { Log.i(TAG, "Rejecting incoming " + deviceUuid + " connection from " + address); mBluetoothService.allowIncomingProfileConnect(device, authorized); } log("onAgentAuthorize(" + objectPath + ", " + deviceUuid + ") = " + authorized); } Loading core/java/android/server/BluetoothService.java +12 −3 Original line number Diff line number Diff line Loading @@ -2113,7 +2113,16 @@ public class BluetoothService extends IBluetooth.Stub { } } public boolean allowIncomingHidConnect(BluetoothDevice device, boolean allow) { /** * Handle incoming profile acceptance for profiles handled by Bluetooth Service, * currently PAN and HID. This also is the catch all for all rejections for profiles * that is not supported. * * @param device - Bluetooth Device * @param allow - true / false * @return */ public boolean allowIncomingProfileConnect(BluetoothDevice device, boolean allow) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); String address = device.getAddress(); Loading @@ -2123,11 +2132,11 @@ public class BluetoothService extends IBluetooth.Stub { Integer data = getAuthorizationAgentRequestData(address); if (data == null) { Log.w(TAG, "allowIncomingHidConnect(" + device + Log.w(TAG, "allowIncomingProfileConnect(" + device + ") called but no native data available"); return false; } if (DBG) log("allowIncomingHidConnect: " + device + " : " + allow + " : " + data); if (DBG) log("allowIncomingProfileConnect: " + device + " : " + allow + " : " + data); return setAuthorizationNative(address, allow, data.intValue()); } Loading Loading
core/java/android/bluetooth/BluetoothDeviceProfileState.java +2 −2 Original line number Diff line number Diff line Loading @@ -1048,12 +1048,12 @@ public final class BluetoothDeviceProfileState extends StateMachine { break; case CONNECT_HID_INCOMING: if (!accept) { ret = mService.allowIncomingHidConnect(mDevice, false); ret = mService.allowIncomingProfileConnect(mDevice, false); sendMessage(TRANSITION_TO_STABLE); updateIncomingAllowedTimer(); } else { writeTimerValue(0); ret = mService.allowIncomingHidConnect(mDevice, true); ret = mService.allowIncomingProfileConnect(mDevice, true); } break; default: Loading
core/java/android/bluetooth/BluetoothInputDevice.java +0 −22 Original line number Diff line number Diff line Loading @@ -308,28 +308,6 @@ public final class BluetoothInputDevice implements BluetoothProfile { return BluetoothProfile.PRIORITY_OFF; } /** * Allow or disallow incoming connection * @param device Input device * @param allow true / false * @return Success or Failure of the operation * @hide */ public boolean allowIncomingConnect(BluetoothDevice device, boolean allow) { if (DBG) log("allowIncomingConnect(" + device + ", " + allow + ")"); if (mService == null || !isEnabled() || !isValidDevice(device)) { return false; } try { mService.allowIncomingHidConnect(device, allow); } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); return false; } return true; } private boolean isEnabled() { if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true; return false; Loading
core/java/android/bluetooth/IBluetooth.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ interface IBluetooth int addRfcommServiceRecord(in String serviceName, in ParcelUuid uuid, int channel, IBinder b); void removeServiceRecord(int handle); boolean allowIncomingProfileConnect(in BluetoothDevice device, boolean value); boolean connectHeadset(String address); boolean disconnectHeadset(String address); Loading @@ -98,7 +99,6 @@ interface IBluetooth int getInputDeviceConnectionState(in BluetoothDevice device); boolean setInputDevicePriority(in BluetoothDevice device, int priority); int getInputDevicePriority(in BluetoothDevice device); boolean allowIncomingHidConnect(in BluetoothDevice device, boolean value); boolean isTetheringOn(); void setBluetoothTethering(boolean value); Loading
core/java/android/server/BluetoothEventLoop.java +16 −17 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ class BluetoothEventLoop { private final BluetoothAdapter mAdapter; private final BluetoothAdapterStateMachine mBluetoothState; private BluetoothA2dp mA2dp; private BluetoothInputDevice mInputDevice; private final Context mContext; // The WakeLock is used for bringing up the LCD during a pairing request // from remote device when Android is in Suspend state. Loading Loading @@ -134,15 +133,11 @@ class BluetoothEventLoop { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (profile == BluetoothProfile.A2DP) { mA2dp = (BluetoothA2dp) proxy; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = (BluetoothInputDevice) proxy; } } public void onServiceDisconnected(int profile) { if (profile == BluetoothProfile.A2DP) { mA2dp = null; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = null; } } }; Loading Loading @@ -803,21 +798,25 @@ class BluetoothEventLoop { "Incoming A2DP / AVRCP connection from " + address); mA2dp.allowIncomingConnect(device, authorized); } } else if (mInputDevice != null && BluetoothUuid.isInputDevice(uuid)) { } else if (BluetoothUuid.isInputDevice(uuid)) { // We can have more than 1 input device connected. authorized = mInputDevice.getPriority(device) > BluetoothInputDevice.PRIORITY_OFF; authorized = mBluetoothService.getInputDevicePriority(device) > BluetoothInputDevice.PRIORITY_OFF; if (authorized) { Log.i(TAG, "First check pass for incoming HID connection from " + address); // notify profile state change mBluetoothService.notifyIncomingHidConnection(address); } else { Log.i(TAG, "Rejecting incoming HID connection from " + address); mBluetoothService.allowIncomingHidConnect(device, authorized); mBluetoothService.allowIncomingProfileConnect(device, authorized); } } else if (BluetoothUuid.isBnep(uuid) && mBluetoothService.allowIncomingTethering()){ authorized = true; } else if (BluetoothUuid.isBnep(uuid)) { // PAN doesn't go to the state machine, accept or reject from here authorized = mBluetoothService.allowIncomingTethering(); mBluetoothService.allowIncomingProfileConnect(device, authorized); } else { Log.i(TAG, "Rejecting incoming " + deviceUuid + " connection from " + address); mBluetoothService.allowIncomingProfileConnect(device, authorized); } log("onAgentAuthorize(" + objectPath + ", " + deviceUuid + ") = " + authorized); } Loading
core/java/android/server/BluetoothService.java +12 −3 Original line number Diff line number Diff line Loading @@ -2113,7 +2113,16 @@ public class BluetoothService extends IBluetooth.Stub { } } public boolean allowIncomingHidConnect(BluetoothDevice device, boolean allow) { /** * Handle incoming profile acceptance for profiles handled by Bluetooth Service, * currently PAN and HID. This also is the catch all for all rejections for profiles * that is not supported. * * @param device - Bluetooth Device * @param allow - true / false * @return */ public boolean allowIncomingProfileConnect(BluetoothDevice device, boolean allow) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); String address = device.getAddress(); Loading @@ -2123,11 +2132,11 @@ public class BluetoothService extends IBluetooth.Stub { Integer data = getAuthorizationAgentRequestData(address); if (data == null) { Log.w(TAG, "allowIncomingHidConnect(" + device + Log.w(TAG, "allowIncomingProfileConnect(" + device + ") called but no native data available"); return false; } if (DBG) log("allowIncomingHidConnect: " + device + " : " + allow + " : " + data); if (DBG) log("allowIncomingProfileConnect: " + device + " : " + allow + " : " + data); return setAuthorizationNative(address, allow, data.intValue()); } Loading