Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0328dfc authored by William Escande's avatar William Escande
Browse files

API Review: add `UNBOND` in `EXTRA_REASON` name

> Can you make EXTRA_REASON an 'unsupported app usage' alias for
> EXTRA_UNBOUND_REASON (which is in the public API)?
> And add a max target SDK to the @UnsupportedAppUsage annotation.

Bug: 221851154
Test: Build + TH
Tag: #refactor
Ignore-AOSP-First: Merge conflict
Change-Id: I7aa94fc5cf78f275e8e3da665e1ec8b6f1611dcc
parent 9dbe2df3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ final class BondStateMachine extends StateMachine {
        intent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, newState);
        intent.putExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, oldState);
        if (newState == BluetoothDevice.BOND_NONE) {
            intent.putExtra(BluetoothDevice.EXTRA_REASON, reason);
            intent.putExtra(BluetoothDevice.EXTRA_UNBOND_REASON, reason);
        }
        mAdapterService.sendBroadcastAsUser(intent, UserHandle.ALL, BLUETOOTH_CONNECT,
                Utils.getTempAllowlistBroadcastOptions());
+3 −3
Original line number Diff line number Diff line
@@ -361,10 +361,10 @@ public class BondStateMachineTest {
        Assert.assertEquals(oldState, intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE,
                                                          -1));
        if (newState == BOND_NONE) {
            Assert.assertEquals(TEST_BOND_REASON, intent.getIntExtra(BluetoothDevice.EXTRA_REASON,
                                                              -1));
            Assert.assertEquals(TEST_BOND_REASON,
                    intent.getIntExtra(BluetoothDevice.EXTRA_UNBOND_REASON, -1));
        } else {
            Assert.assertEquals(-1, intent.getIntExtra(BluetoothDevice.EXTRA_REASON, -1));
            Assert.assertEquals(-1, intent.getIntExtra(BluetoothDevice.EXTRA_UNBOND_REASON, -1));
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ package android.bluetooth {
    field public static final String EXTRA_PAIRING_INITIATOR = "android.bluetooth.device.extra.PAIRING_INITIATOR";
    field public static final int EXTRA_PAIRING_INITIATOR_BACKGROUND = 2; // 0x2
    field public static final int EXTRA_PAIRING_INITIATOR_FOREGROUND = 1; // 0x1
    field public static final String EXTRA_REASON = "android.bluetooth.device.extra.REASON";
    field public static final String EXTRA_UNBOND_REASON = "android.bluetooth.device.extra.REASON";
    field public static final int METADATA_COMPANION_APP = 4; // 0x4
    field public static final int METADATA_DEVICE_TYPE = 17; // 0x11
    field public static final int METADATA_ENHANCED_SETTINGS_UI_URI = 16; // 0x10
+15 −5
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
     * #EXTRA_BOND_STATE} and {@link #EXTRA_PREVIOUS_BOND_STATE}.
     */
    // Note: When EXTRA_BOND_STATE is BOND_NONE then this will also
    // contain a hidden extra field EXTRA_REASON with the result code.
    // contain a hidden extra field EXTRA_UNBOND_REASON with the result code.
    @RequiresLegacyBluetoothPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
@@ -379,8 +379,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
    public static final int BOND_BONDED = 12;

    /**
     * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}
     * intents for unbond reason.
     * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST} intents for unbond reason.
     * Possible value are :
     *  - {@link #UNBOND_REASON_AUTH_FAILED}
     *  - {@link #UNBOND_REASON_AUTH_REJECTED}
@@ -392,11 +391,22 @@ public final class BluetoothDevice implements Parcelable, Attributable {
     *  - {@link #UNBOND_REASON_REMOTE_AUTH_CANCELED}
     *  - {@link #UNBOND_REASON_REMOVED}
     *
     * {@hide}
     * Note: Can be added as a hidden extra field for {@link #ACTION_BOND_STATE_CHANGED} when the
     * {@link #EXTRA_BOND_STATE} is {@link #BOND_NONE}
     *
     * @hide
     */
    @SystemApi
    @SuppressLint("ActionValue")
    public static final String EXTRA_REASON = "android.bluetooth.device.extra.REASON";
    public static final String EXTRA_UNBOND_REASON = "android.bluetooth.device.extra.REASON";

    /**
     * Use {@link EXTRA_UNBOND_REASON} instead
     * @hide
     */
    @UnsupportedAppUsage
    public static final String EXTRA_REASON = EXTRA_UNBOND_REASON;


    /**
     * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}