diff options
author | William Escande <wescande@google.com> | 2022-03-08 12:19:43 +0100 |
---|---|---|
committer | William Escande <wescande@google.com> | 2022-03-08 23:11:12 +0100 |
commit | 4c28ea22dc8647f38961b5be8d195698d02186d6 (patch) | |
tree | a12566f98008d336df722fac37ef7538d840f067 /framework/java/android/bluetooth/BluetoothSap.java | |
parent | 0be69f7313948a287e4c814817cf37397bd45fe4 (diff) |
Fix after API_review
* isMandatoryCodec is now public
* SCAN_FAILED_OUT_OF_HARDWARE/SCANNING_TOO_FREQUENTLY is now public with a
IntDef (method using the value are changed accordingly)
* Update doc for EXTRA_BATTERY_LEVEL and EXTRA_PAIRING_INITIATOR and
ACTION_CONNECTION_STATE_CHANGED
* Add Autoclosable to BluetoothSap to remove the NotCloseable
* BluetoothClass.Device.PERI* are now public
Bug: 222725037
Fix: 221851154
Test: Build + TH
Tag: #refactor
CTS-Coverage-Bug: 222539659
Ignore-AOSP-First: merge conflict resolution
Change-Id: Ia6aa778d6bdc0319266c52a84633ee593eaa7eb0
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothSap.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothSap.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/framework/java/android/bluetooth/BluetoothSap.java b/framework/java/android/bluetooth/BluetoothSap.java index 7a6ba025c2..50c0edf442 100644 --- a/framework/java/android/bluetooth/BluetoothSap.java +++ b/framework/java/android/bluetooth/BluetoothSap.java @@ -34,6 +34,7 @@ import android.content.Context; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; +import android.util.CloseGuard; import android.util.Log; import com.android.modules.utils.SynchronousResultReceiver; @@ -56,17 +57,18 @@ import java.util.concurrent.TimeoutException; * @hide */ @SystemApi -@SuppressLint("NotCloseable") -public final class BluetoothSap implements BluetoothProfile { +public final class BluetoothSap implements BluetoothProfile, AutoCloseable { private static final String TAG = "BluetoothSap"; 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 profile. * - * <p>This intent will have 4 extras: + * <p>This intent will have 3 extras: * <ul> * <li> {@link #EXTRA_STATE} - The current state of the profile. </li> * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li> @@ -129,15 +131,19 @@ public final class BluetoothSap implements BluetoothProfile { mAdapter = adapter; mAttributionSource = adapter.getAttributionSource(); mProfileConnector.connect(context, listener); + mCloseGuard = new CloseGuard(); + mCloseGuard.open("close"); } - @SuppressLint("GenericException") - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); + /** + * + * @hide + */ + protected void finalize() { + if (mCloseGuard != null) { + mCloseGuard.warnIfOpen(); } + close(); } /** |