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

Commit a00cb4b8 authored by Rahul Sabnis's avatar Rahul Sabnis Committed by android-build-merger
Browse files

Merge "Refactor methods to access/modify BluetoothDevice alias and name" am: 67bef6ab

am: 90a45d63

Change-Id: I96a1cffd308983a131ad00c2ba1da050a32900d1
parents 49960bdd 90a45d63
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8357,6 +8357,7 @@ package android.bluetooth {
    method public int describeContents();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean fetchUuidsWithSdp();
    method public String getAddress();
    method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH) public String getAlias();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public android.bluetooth.BluetoothClass getBluetoothClass();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getBondState();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public String getName();
@@ -8368,6 +8369,7 @@ package android.bluetooth {
    field public static final String ACTION_ACL_CONNECTED = "android.bluetooth.device.action.ACL_CONNECTED";
    field public static final String ACTION_ACL_DISCONNECTED = "android.bluetooth.device.action.ACL_DISCONNECTED";
    field public static final String ACTION_ACL_DISCONNECT_REQUESTED = "android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED";
    field public static final String ACTION_ALIAS_CHANGED = "android.bluetooth.action.ALIAS_CHANGED";
    field public static final String ACTION_BOND_STATE_CHANGED = "android.bluetooth.device.action.BOND_STATE_CHANGED";
    field public static final String ACTION_CLASS_CHANGED = "android.bluetooth.device.action.CLASS_CHANGED";
    field public static final String ACTION_FOUND = "android.bluetooth.device.action.FOUND";
+1 −0
Original line number Diff line number Diff line
@@ -1264,6 +1264,7 @@ package android.bluetooth {
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isInSilenceMode();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean setAlias(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMetadata(int, @NonNull byte[]);
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int);
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSilenceMode(boolean);
+13 −28
Original line number Diff line number Diff line
@@ -173,13 +173,10 @@ public final class BluetoothDevice implements Parcelable {
     * changed.
     * <p>Always contains the extra field {@link #EXTRA_DEVICE}.
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @UnsupportedAppUsage
    public static final String ACTION_ALIAS_CHANGED =
            "android.bluetooth.device.action.ALIAS_CHANGED";
            "android.bluetooth.action.ALIAS_CHANGED";

    /**
     * Broadcast Action: Indicates a change in the bond state of a remote
@@ -1048,10 +1045,11 @@ public final class BluetoothDevice implements Parcelable {
     * Get the Bluetooth alias of the remote device.
     * <p>Alias is the locally modified name of a remote device.
     *
     * @return the Bluetooth alias, or null if no alias or there was a problem
     * @hide
     * @return the Bluetooth alias, the friendly device name if no alias, or
     * null if there was a problem
     */
    @UnsupportedAppUsage(publicAlternatives = "Use {@link #getName()} instead.")
    @Nullable
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public String getAlias() {
        final IBluetooth service = sService;
        if (service == null) {
@@ -1059,7 +1057,11 @@ public final class BluetoothDevice implements Parcelable {
            return null;
        }
        try {
            return service.getRemoteAlias(this);
            String alias = service.getRemoteAlias(this);
            if (alias == null) {
                return getName();
            }
            return alias;
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
@@ -1076,8 +1078,9 @@ public final class BluetoothDevice implements Parcelable {
     * @return true on success, false on error
     * @hide
     */
    @UnsupportedAppUsage
    public boolean setAlias(String alias) {
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public boolean setAlias(@NonNull String alias) {
        final IBluetooth service = sService;
        if (service == null) {
            Log.e(TAG, "BT not enabled. Cannot set Remote Device name");
@@ -1091,24 +1094,6 @@ public final class BluetoothDevice implements Parcelable {
        return false;
    }

    /**
     * Get the Bluetooth alias of the remote device.
     * If Alias is null, get the Bluetooth name instead.
     *
     * @return the Bluetooth alias, or null if no alias or there was a problem
     * @hide
     * @see #getAlias()
     * @see #getName()
     */
    @UnsupportedAppUsage(publicAlternatives = "Use {@link #getName()} instead.")
    public String getAliasName() {
        String name = getAlias();
        if (name == null) {
            name = getName();
        }
        return name;
    }

    /**
     * Get the most recent identified battery level of this Bluetooth device
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class BluetoothDeviceFilterUtils {

    @UnsupportedAppUsage
    public static String getDeviceDisplayNameInternal(@NonNull BluetoothDevice device) {
        return firstNotEmpty(device.getAliasName(), device.getAddress());
        return firstNotEmpty(device.getAlias(), device.getAddress());
    }

    @UnsupportedAppUsage
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@
    <protected-broadcast android:name="android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.UUID" />
    <protected-broadcast android:name="android.bluetooth.device.action.MAS_INSTANCE" />
    <protected-broadcast android:name="android.bluetooth.device.action.ALIAS_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.action.ALIAS_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.FOUND" />
    <protected-broadcast android:name="android.bluetooth.device.action.CLASS_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.ACL_CONNECTED" />
Loading