From 4029fa6039a3305b093d8db0a24fb8e4dedd351a Mon Sep 17 00:00:00 2001 From: Selim Gurun Date: Tue, 17 Oct 2017 17:01:38 -0700 Subject: [PATCH] Add SystemApis annotations There are some number of places where bluetooth APIs are used via reflection from GMSCore. Add proper annotations. Bug: 67052734 Test: Manual - and using make update-api Change-Id: Ib6e3aa1ff5b6f9cdc78367f9be13ed00542d6f65 (cherry picked from commit 64bd35ef2cb40bbf9476a3bf63a763d5a32cc73b) --- api/system-current.txt | 10 ++++++++++ core/java/android/bluetooth/BluetoothAdapter.java | 2 ++ core/java/android/bluetooth/BluetoothDevice.java | 8 ++++++++ core/java/android/bluetooth/BluetoothHeadset.java | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 3a71189a46145..6ee98a7c0b9ba 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -615,6 +615,7 @@ package android.bluetooth { public final class BluetoothAdapter { method public boolean disableBLE(); method public boolean enableBLE(); + method public boolean enableNoAutoConnect(); method public boolean isBleScanAlwaysAvailable(); method public boolean isLeEnabled(); field public static final java.lang.String ACTION_BLE_STATE_CHANGED = "android.bluetooth.adapter.action.BLE_STATE_CHANGED"; @@ -622,8 +623,17 @@ package android.bluetooth { } public final class BluetoothDevice implements android.os.Parcelable { + method public boolean cancelBondProcess(); method public boolean isConnected(); method public boolean isEncrypted(); + method public boolean removeBond(); + method public boolean setPhonebookAccessPermission(int); + } + + public final class BluetoothHeadset implements android.bluetooth.BluetoothProfile { + method public boolean connect(android.bluetooth.BluetoothDevice); + method public boolean disconnect(android.bluetooth.BluetoothDevice); + method public boolean setPriority(android.bluetooth.BluetoothDevice, int); } } diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 158aebb478ac5..c7be0f36ecefc 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -2425,6 +2425,8 @@ public final class BluetoothAdapter { * * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean enableNoAutoConnect() { if (isEnabled()) { if (DBG) { diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index d982bb7ffb43c..ad7a93cd6bbd4 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -1098,6 +1098,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess() { final IBluetooth service = sService; if (service == null) { @@ -1125,6 +1127,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond() { final IBluetooth service = sService; if (service == null) { @@ -1174,6 +1178,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected() { final IBluetooth service = sService; if (service == null) { @@ -1197,6 +1202,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted() { final IBluetooth service = sService; if (service == null) { @@ -1444,6 +1450,8 @@ public final class BluetoothDevice implements Parcelable { * @return Whether the value has been successfully set. * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int value) { final IBluetooth service = sService; if (service == null) { diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java index 90ae0e6313dcd..838d3153d54cf 100644 --- a/core/java/android/bluetooth/BluetoothHeadset.java +++ b/core/java/android/bluetooth/BluetoothHeadset.java @@ -16,8 +16,10 @@ package android.bluetooth; +import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; import android.os.Binder; @@ -416,6 +418,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); final IBluetoothHeadset service = mService; @@ -456,6 +460,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); final IBluetoothHeadset service = mService; @@ -543,6 +549,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return true if priority is set, false on error * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPriority(BluetoothDevice device, int priority) { if (DBG) log("setPriority(" + device + ", " + priority + ")"); final IBluetoothHeadset service = mService;