Loading android/app/src/com/android/bluetooth/hid/HidHostService.java +17 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.bluetooth.hid; import static com.android.bluetooth.Utils.enforceBluetoothAdminPermission; import static com.android.bluetooth.Utils.enforceBluetoothPermission; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.bluetooth.BluetoothDevice; Loading Loading @@ -339,6 +341,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.connect(device); } Loading @@ -348,6 +351,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.disconnect(device); } Loading @@ -357,7 +361,7 @@ public class HidHostService extends ProfileService { if (service == null) { return BluetoothHidHost.STATE_DISCONNECTED; } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPermission(service); return service.getConnectionState(device); } Loading @@ -367,7 +371,7 @@ public class HidHostService extends ProfileService { if (service == null) { return new ArrayList<>(); } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPermission(service); return getDevicesMatchingConnectionStates(new int[]{BluetoothProfile.STATE_CONNECTED}); } Loading @@ -377,6 +381,7 @@ public class HidHostService extends ProfileService { if (service == null) { return new ArrayList<BluetoothDevice>(0); } enforceBluetoothPermission(service); return service.getDevicesMatchingConnectionStates(states); } Loading @@ -386,6 +391,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.setConnectionPolicy(device, connectionPolicy); } Loading @@ -395,6 +401,7 @@ public class HidHostService extends ProfileService { if (service == null) { return BluetoothProfile.CONNECTION_POLICY_UNKNOWN; } enforceBluetoothPrivilegedPermission(service); return service.getConnectionPolicy(device); } Loading @@ -405,6 +412,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getProtocolMode(device); } Loading @@ -414,6 +422,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.virtualUnplug(device); } Loading @@ -423,6 +432,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setProtocolMode(device, protocolMode); } Loading @@ -433,6 +443,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getReport(device, reportType, reportId, bufferSize); } Loading @@ -442,6 +453,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setReport(device, reportType, report); } Loading @@ -451,6 +463,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.sendData(device, report); } Loading @@ -460,6 +473,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setIdleTime(device, idleTime); } Loading @@ -469,6 +483,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getIdleTime(device); } } Loading @@ -485,8 +500,6 @@ public class HidHostService extends ProfileService { */ public boolean connect(BluetoothDevice device) { if (DBG) Log.d(TAG, "connect: " + device.getAddress()); enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (getConnectionState(device) != BluetoothHidHost.STATE_DISCONNECTED) { Log.e(TAG, "Hid Device not disconnected: " + device); return false; Loading @@ -509,8 +522,6 @@ public class HidHostService extends ProfileService { */ public boolean disconnect(BluetoothDevice device) { if (DBG) Log.d(TAG, "disconnect: " + device.getAddress()); enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); Message msg = mHandler.obtainMessage(MESSAGE_DISCONNECT, device); mHandler.sendMessage(msg); return true; Loading @@ -535,7 +546,6 @@ public class HidHostService extends ProfileService { List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates()"); enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); List<BluetoothDevice> inputDevices = new ArrayList<BluetoothDevice>(); for (BluetoothDevice device : mInputDevices.keySet()) { Loading Loading @@ -566,8 +576,6 @@ public class HidHostService extends ProfileService { * @return true if connectionPolicy is set, false on error */ public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (DBG) { Log.d(TAG, "setConnectionPolicy: " + device.getAddress()); } Loading Loading @@ -597,8 +605,6 @@ public class HidHostService extends ProfileService { * @hide */ public int getConnectionPolicy(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (DBG) { Log.d(TAG, "getConnectionPolicy: " + device.getAddress()); } Loading @@ -608,7 +614,6 @@ public class HidHostService extends ProfileService { /* The following APIs regarding test app for compliance */ boolean getProtocolMode(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "getProtocolMode: " + device.getAddress()); } Loading @@ -624,7 +629,6 @@ public class HidHostService extends ProfileService { } boolean virtualUnplug(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "virtualUnplug: " + device.getAddress()); } Loading @@ -638,7 +642,6 @@ public class HidHostService extends ProfileService { } boolean setProtocolMode(BluetoothDevice device, int protocolMode) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "setProtocolMode: " + device.getAddress()); } Loading @@ -654,7 +657,6 @@ public class HidHostService extends ProfileService { } boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "getReport: " + device.getAddress()); } Loading @@ -674,7 +676,6 @@ public class HidHostService extends ProfileService { } boolean setReport(BluetoothDevice device, byte reportType, String report) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "setReport: " + device.getAddress()); } Loading @@ -694,7 +695,6 @@ public class HidHostService extends ProfileService { } boolean sendData(BluetoothDevice device, String report) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "sendData: " + device.getAddress()); } Loading @@ -707,7 +707,6 @@ public class HidHostService extends ProfileService { } boolean getIdleTime(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) Log.d(TAG, "getIdleTime: " + device.getAddress()); int state = this.getConnectionState(device); if (state != BluetoothHidHost.STATE_CONNECTED) { Loading @@ -719,7 +718,6 @@ public class HidHostService extends ProfileService { } boolean setIdleTime(BluetoothDevice device, byte idleTime) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) Log.d(TAG, "setIdleTime: " + device.getAddress()); int state = this.getConnectionState(device); if (state != BluetoothHidHost.STATE_CONNECTED) { Loading Loading
android/app/src/com/android/bluetooth/hid/HidHostService.java +17 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.bluetooth.hid; import static com.android.bluetooth.Utils.enforceBluetoothAdminPermission; import static com.android.bluetooth.Utils.enforceBluetoothPermission; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.bluetooth.BluetoothDevice; Loading Loading @@ -339,6 +341,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.connect(device); } Loading @@ -348,6 +351,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.disconnect(device); } Loading @@ -357,7 +361,7 @@ public class HidHostService extends ProfileService { if (service == null) { return BluetoothHidHost.STATE_DISCONNECTED; } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPermission(service); return service.getConnectionState(device); } Loading @@ -367,7 +371,7 @@ public class HidHostService extends ProfileService { if (service == null) { return new ArrayList<>(); } enforceBluetoothPrivilegedPermission(service); enforceBluetoothPermission(service); return getDevicesMatchingConnectionStates(new int[]{BluetoothProfile.STATE_CONNECTED}); } Loading @@ -377,6 +381,7 @@ public class HidHostService extends ProfileService { if (service == null) { return new ArrayList<BluetoothDevice>(0); } enforceBluetoothPermission(service); return service.getDevicesMatchingConnectionStates(states); } Loading @@ -386,6 +391,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothPrivilegedPermission(service); return service.setConnectionPolicy(device, connectionPolicy); } Loading @@ -395,6 +401,7 @@ public class HidHostService extends ProfileService { if (service == null) { return BluetoothProfile.CONNECTION_POLICY_UNKNOWN; } enforceBluetoothPrivilegedPermission(service); return service.getConnectionPolicy(device); } Loading @@ -405,6 +412,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getProtocolMode(device); } Loading @@ -414,6 +422,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.virtualUnplug(device); } Loading @@ -423,6 +432,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setProtocolMode(device, protocolMode); } Loading @@ -433,6 +443,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getReport(device, reportType, reportId, bufferSize); } Loading @@ -442,6 +453,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setReport(device, reportType, report); } Loading @@ -451,6 +463,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.sendData(device, report); } Loading @@ -460,6 +473,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.setIdleTime(device, idleTime); } Loading @@ -469,6 +483,7 @@ public class HidHostService extends ProfileService { if (service == null) { return false; } enforceBluetoothAdminPermission(service); return service.getIdleTime(device); } } Loading @@ -485,8 +500,6 @@ public class HidHostService extends ProfileService { */ public boolean connect(BluetoothDevice device) { if (DBG) Log.d(TAG, "connect: " + device.getAddress()); enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (getConnectionState(device) != BluetoothHidHost.STATE_DISCONNECTED) { Log.e(TAG, "Hid Device not disconnected: " + device); return false; Loading @@ -509,8 +522,6 @@ public class HidHostService extends ProfileService { */ public boolean disconnect(BluetoothDevice device) { if (DBG) Log.d(TAG, "disconnect: " + device.getAddress()); enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); Message msg = mHandler.obtainMessage(MESSAGE_DISCONNECT, device); mHandler.sendMessage(msg); return true; Loading @@ -535,7 +546,6 @@ public class HidHostService extends ProfileService { List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates()"); enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); List<BluetoothDevice> inputDevices = new ArrayList<BluetoothDevice>(); for (BluetoothDevice device : mInputDevices.keySet()) { Loading Loading @@ -566,8 +576,6 @@ public class HidHostService extends ProfileService { * @return true if connectionPolicy is set, false on error */ public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (DBG) { Log.d(TAG, "setConnectionPolicy: " + device.getAddress()); } Loading Loading @@ -597,8 +605,6 @@ public class HidHostService extends ProfileService { * @hide */ public int getConnectionPolicy(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission"); if (DBG) { Log.d(TAG, "getConnectionPolicy: " + device.getAddress()); } Loading @@ -608,7 +614,6 @@ public class HidHostService extends ProfileService { /* The following APIs regarding test app for compliance */ boolean getProtocolMode(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "getProtocolMode: " + device.getAddress()); } Loading @@ -624,7 +629,6 @@ public class HidHostService extends ProfileService { } boolean virtualUnplug(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "virtualUnplug: " + device.getAddress()); } Loading @@ -638,7 +642,6 @@ public class HidHostService extends ProfileService { } boolean setProtocolMode(BluetoothDevice device, int protocolMode) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "setProtocolMode: " + device.getAddress()); } Loading @@ -654,7 +657,6 @@ public class HidHostService extends ProfileService { } boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "getReport: " + device.getAddress()); } Loading @@ -674,7 +676,6 @@ public class HidHostService extends ProfileService { } boolean setReport(BluetoothDevice device, byte reportType, String report) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "setReport: " + device.getAddress()); } Loading @@ -694,7 +695,6 @@ public class HidHostService extends ProfileService { } boolean sendData(BluetoothDevice device, String report) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) { Log.d(TAG, "sendData: " + device.getAddress()); } Loading @@ -707,7 +707,6 @@ public class HidHostService extends ProfileService { } boolean getIdleTime(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) Log.d(TAG, "getIdleTime: " + device.getAddress()); int state = this.getConnectionState(device); if (state != BluetoothHidHost.STATE_CONNECTED) { Loading @@ -719,7 +718,6 @@ public class HidHostService extends ProfileService { } boolean setIdleTime(BluetoothDevice device, byte idleTime) { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) Log.d(TAG, "setIdleTime: " + device.getAddress()); int state = this.getConnectionState(device); if (state != BluetoothHidHost.STATE_CONNECTED) { Loading