summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHidHost.java
diff options
context:
space:
mode:
authorRahul Sabnis <rahulsabnis@google.com>2020-02-25 11:33:43 -0800
committerRahul Sabnis <rahulsabnis@google.com>2020-03-02 19:13:19 +0000
commitd87b6b0457b2b31f682623c28f289404ed349281 (patch)
tree6e080c67f34c57c3df70c92a0e1934c7033c387a /framework/java/android/bluetooth/BluetoothHidHost.java
parentc3389265edab7bf009a17e30fcd4069d06bd1230 (diff)
Add missing RequiresPermission annotations in BluetoothHidHost and
BluetoothMap APIs, disallow null device input for setConnectionPolicy, getConnectionPolicy, and getConnectionState in BluetoothHidHost, and BluetoothMap implements AutoCloseable, its close() method is public, and utilizes a CloseGuard. Bug: 149238030 Test: Manual Merged-In: I8add9e26afcaf1a988c15e3cc7f8c446491f0686 Change-Id: I8add9e26afcaf1a988c15e3cc7f8c446491f0686
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHidHost.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHidHost.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHidHost.java b/framework/java/android/bluetooth/BluetoothHidHost.java
index 26e3e271bf..e9e1f68669 100644
--- a/framework/java/android/bluetooth/BluetoothHidHost.java
+++ b/framework/java/android/bluetooth/BluetoothHidHost.java
@@ -18,7 +18,6 @@ package android.bluetooth;
import android.Manifest;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
@@ -330,6 +329,7 @@ public final class BluetoothHidHost implements BluetoothProfile {
* {@inheritDoc}
*/
@Override
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public @NonNull List<BluetoothDevice> getConnectedDevices() {
if (VDBG) log("getConnectedDevices()");
final IBluetoothHidHost service = getService();
@@ -370,8 +370,12 @@ public final class BluetoothHidHost implements BluetoothProfile {
* {@inheritDoc}
*/
@Override
- public int getConnectionState(@Nullable BluetoothDevice device) {
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public int getConnectionState(@NonNull BluetoothDevice device) {
if (VDBG) log("getState(" + device + ")");
+ if (device == null) {
+ throw new IllegalArgumentException("device must not be null");
+ }
final IBluetoothHidHost service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {
@@ -416,9 +420,12 @@ public final class BluetoothHidHost implements BluetoothProfile {
*/
@SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
- public boolean setConnectionPolicy(@Nullable BluetoothDevice device,
+ public boolean setConnectionPolicy(@NonNull BluetoothDevice device,
@ConnectionPolicy int connectionPolicy) {
if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")");
+ if (device == null) {
+ throw new IllegalArgumentException("device must not be null");
+ }
final IBluetoothHidHost service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN
@@ -465,8 +472,11 @@ public final class BluetoothHidHost implements BluetoothProfile {
*/
@SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public @ConnectionPolicy int getConnectionPolicy(@Nullable BluetoothDevice device) {
+ public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) {
if (VDBG) log("getConnectionPolicy(" + device + ")");
+ if (device == null) {
+ throw new IllegalArgumentException("device must not be null");
+ }
final IBluetoothHidHost service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {