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 | 2c71d16ced544f29d24992ab4d79863803b6d6aa (patch) | |
| tree | b196e52eef41861ad0e6d7048942d7e666aca400 /core/java/android/bluetooth/BluetoothPan.java | |
| parent | 1e377304cb81d2120967646f5762c9a7318b8130 (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 'core/java/android/bluetooth/BluetoothPan.java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothPan.java | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java index 7af770e69efe..a80f5b7f36d4 100644 --- a/core/java/android/bluetooth/BluetoothPan.java +++ b/core/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)) { |
