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

Commit 995cc086 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7230642 from f57e4c9bcec5b60bf4af93c91eeeb7017dd2149f to sc-release

Change-Id: I504cba4c0186b758fc869bc2e6b4e5082e52406a
parents 98bdd6e7 98788331
Loading
Loading
Loading
Loading
+21 −11
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.app.PropertyInvalidatedCache;
import android.companion.AssociationRequest;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.Build;
@@ -1231,8 +1232,7 @@ 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.
     * Get the locally modifiable name (alias) of the remote Bluetooth device.
     *
     * @return the Bluetooth alias, the friendly device name if no alias, or
     * null if there was a problem
@@ -1258,25 +1258,35 @@ public final class BluetoothDevice implements Parcelable {
    }

    /**
     * Set the Bluetooth alias of the remote device.
     * <p>Alias is the locally modified name of a remote device.
     * <p>This methoid overwrites the alias. The changed
     * alias is saved in the local storage so that the change
     * is preserved over power cycle.
     * Sets the locally modifiable name (alias) of the remote Bluetooth device. This method
     * overwrites the previously stored alias. The new alias is saved in local
     * storage so that the change is preserved over power cycles.
     *
     * @return true on success, false on error
     * @hide
     * <p>This method requires the calling app to be associated with Companion Device Manager (see
     * {@link android.companion.CompanionDeviceManager#associate(AssociationRequest,
     * android.companion.CompanionDeviceManager.Callback, Handler)}) and have the {@link
     * android.Manifest.permission#BLUETOOTH} permission. Alternatively, if the caller has the
     * {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} permission, they can bypass the
     * Companion Device Manager association requirement.
     *
     * @param alias is the new locally modifiable name for the remote Bluetooth device which must be
     *              non-null and not the empty string.
     * @return {@code true} if the alias is successfully set, {@code false} on error
     * @throws IllegalArgumentException if the alias is {@code null} or the empty string
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public boolean setAlias(@NonNull String alias) {
        if (alias == null || alias.isEmpty()) {
            throw new IllegalArgumentException("Cannot set the alias to null or the empty string");
        }
        final IBluetooth service = sService;
        if (service == null) {
            Log.e(TAG, "BT not enabled. Cannot set Remote Device name");
            return false;
        }
        try {
            return service.setRemoteAlias(this, alias);
            BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
            return service.setRemoteAlias(this, alias, adapter.getOpPackageName());
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
+1 −1
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ public final class ScanFilter implements Parcelable {
         * @throws IllegalArgumentException If the {@code deviceAddress} is invalid.
         */
        public Builder setDeviceAddress(String deviceAddress) {
            return setDeviceAddress(mDeviceAddress, BluetoothDevice.ADDRESS_TYPE_PUBLIC);
            return setDeviceAddress(deviceAddress, BluetoothDevice.ADDRESS_TYPE_PUBLIC);
        }

        /**
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />