diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-18 17:46:33 -0700 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-21 04:10:15 +0000 |
commit | ce594994e8aa1b4bf9a6917e18c4f2f3b68c1ddc (patch) | |
tree | 22ff052ac71fcee0d0c6f6c05f96641fdcb38dac /framework/java/android/bluetooth/BluetoothPan.java | |
parent | 8e78d743cfc4b914b5e9862566acec998f8c3544 (diff) |
Add BLUETOOTH_PRIVILEGED permission as a requirement for all new Bluetooth SystemApis and for hidden connect/disconnect APIs.
Hide some APIs that were previously marked as @UnsupportedAppUsage and re-add annotation as changing the permissions for these SystemApis would break the unsupported app contract that was previously there. Therefore, we're choosing to hide them until we have a good story on how to deal with them next release.
Bug: 148689314
Test: Manual
Change-Id: I33ee2c7ccd3827db3d23d6447cf82d9ffc36836a
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothPan.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothPan.java | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/framework/java/android/bluetooth/BluetoothPan.java b/framework/java/android/bluetooth/BluetoothPan.java index 7af770e69e..a80f5b7f36 100644 --- a/framework/java/android/bluetooth/BluetoothPan.java +++ b/framework/java/android/bluetooth/BluetoothPan.java @@ -19,7 +19,6 @@ package android.bluetooth; import android.Manifest; import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; @@ -30,7 +29,6 @@ import android.content.Context; import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; -import android.util.CloseGuard; import android.util.Log; import java.lang.annotation.Retention; @@ -51,11 +49,10 @@ import java.util.List; * @hide */ @SystemApi -public final class BluetoothPan implements BluetoothProfile, AutoCloseable { +public final class BluetoothPan implements BluetoothProfile { private static final String TAG = "BluetoothPan"; private static final boolean DBG = true; private static final boolean VDBG = false; - private CloseGuard mCloseGuard; /** * Intent used to broadcast the change in connection state of the Pan @@ -168,16 +165,13 @@ public final class BluetoothPan implements BluetoothProfile, AutoCloseable { mAdapter = BluetoothAdapter.getDefaultAdapter(); mContext = context; mProfileConnector.connect(context, listener); - mCloseGuard = new CloseGuard(); - mCloseGuard.open("close"); } /** * Closes the connection to the service and unregisters callbacks - * - * @hide */ - public void close() { + @UnsupportedAppUsage + void close() { if (VDBG) log("close()"); mProfileConnector.disconnect(); } @@ -188,9 +182,6 @@ public final class BluetoothPan implements BluetoothProfile, AutoCloseable { /** @hide */ protected void finalize() { - if (mCloseGuard != null) { - mCloseGuard.warnIfOpen(); - } close(); } @@ -204,9 +195,6 @@ public final class BluetoothPan implements BluetoothProfile, AutoCloseable { * the state. Users can get the connection state of the profile * from this intent. * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * * @param device Remote Bluetooth Device * @return false on immediate error, true otherwise * @hide @@ -245,9 +233,6 @@ public final class BluetoothPan implements BluetoothProfile, AutoCloseable { * {@link #STATE_DISCONNECTING} can be used to distinguish between the * two scenarios. * - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} - * permission. - * * @param device Remote Bluetooth Device * @return false on immediate error, true otherwise * @hide @@ -353,7 +338,7 @@ public final class BluetoothPan implements BluetoothProfile, AutoCloseable { @SystemApi @Override @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) - public int getConnectionState(@Nullable BluetoothDevice device) { + public int getConnectionState(@NonNull BluetoothDevice device) { if (VDBG) log("getState(" + device + ")"); final IBluetoothPan service = getService(); if (service != null && isEnabled() && isValidDevice(device)) { |