Merge "Do Not Merge. Don't connect to non keyboard HID devices." into honeycomb

This commit is contained in:
Jaikumar Ganesh
2011-01-25 18:42:12 -08:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 1 deletions

View File

@ -648,7 +648,8 @@ class BluetoothEventLoop {
} else { } else {
Log.i(TAG, "Rejecting incoming A2DP / AVRCP connection from " + address); Log.i(TAG, "Rejecting incoming A2DP / AVRCP connection from " + address);
} }
} else if (BluetoothUuid.isInputDevice(uuid) && !isOtherInputDeviceConnected(address)) { } else if (BluetoothUuid.isInputDevice(uuid) && !isOtherInputDeviceConnected(address) &&
isKeyboard(address)) {
BluetoothInputDevice inputDevice = new BluetoothInputDevice(mContext); BluetoothInputDevice inputDevice = new BluetoothInputDevice(mContext);
authorized = inputDevice.getInputDevicePriority(device) > authorized = inputDevice.getInputDevicePriority(device) >
BluetoothInputDevice.PRIORITY_OFF; BluetoothInputDevice.PRIORITY_OFF;
@ -667,6 +668,17 @@ class BluetoothEventLoop {
return authorized; return authorized;
} }
private boolean isKeyboard(String address) {
BluetoothClass btClass = new BluetoothClass(mBluetoothService.getRemoteClass(address));
int btDeviceClass = btClass.getDeviceClass();
if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD ||
btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
return true;
}
log("Incoming Connect: Input device class: " + btDeviceClass + " Not a keyboard");
return false;
}
private boolean isOtherInputDeviceConnected(String address) { private boolean isOtherInputDeviceConnected(String address) {
List<BluetoothDevice> devices = List<BluetoothDevice> devices =
mBluetoothService.lookupInputDevicesMatchingStates(new int[] { mBluetoothService.lookupInputDevicesMatchingStates(new int[] {

View File

@ -1729,6 +1729,15 @@ public class BluetoothService extends IBluetooth.Stub {
getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_OFF) { getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_OFF) {
return false; return false;
} }
BluetoothClass btClass = new BluetoothClass(getRemoteClass(device.getAddress()));
int btDeviceClass = btClass.getDeviceClass();
if (btDeviceClass != BluetoothClass.Device.PERIPHERAL_KEYBOARD &&
btDeviceClass != BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
log("Input device btDeviceClass: " + btDeviceClass + " Not a keyboard");
return false;
}
BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress());
if (state != null) { if (state != null) {
Message msg = new Message(); Message msg = new Message();