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

Commit 0e2d587c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5262136 from 4fcdce138f03b70754dc9549ee8eeeeb2c447e52 to qt-release

Change-Id: I22092058c57d872ad4755a4b1b3260e866138ee5
parents 80f372f2 7d12e69a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * {@inheritDoc}
     */
    @Override
    public int getConnectionState(BluetoothDevice device) {
    public @BtProfileState int getConnectionState(BluetoothDevice device) {
        if (VDBG) log("getState(" + device + ")");
        try {
            mServiceLock.readLock().lock();
@@ -689,7 +689,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * @hide
     */
    @UnsupportedAppUsage
    public BluetoothCodecStatus getCodecStatus(BluetoothDevice device) {
    public @Nullable BluetoothCodecStatus getCodecStatus(BluetoothDevice device) {
        if (DBG) Log.d(TAG, "getCodecStatus(" + device + ")");
        try {
            mServiceLock.readLock().lock();
+31 −8
Original line number Diff line number Diff line
@@ -1899,6 +1899,20 @@ public final class BluetoothAdapter {
        return 0;
    }

    /**
     * Return true if Hearing Aid Profile is supported.
     *
     * @return true if phone supports Hearing Aid Profile
     */
    private boolean isHearingAidProfileSupported() {
        try {
            return mManagerService.isHearingAidProfileSupported();
        } catch (RemoteException e) {
            Log.e(TAG, "remote expection when calling isHearingAidProfileSupported", e);
            return false;
        }
    }

    /**
     * Get the maximum number of connected audio devices.
     *
@@ -2051,6 +2065,11 @@ public final class BluetoothAdapter {
                            supportedProfiles.add(i);
                        }
                    }
                } else {
                    // Bluetooth is disabled. Just fill in known supported Profiles
                    if (isHearingAidProfileSupported()) {
                        supportedProfiles.add(BluetoothProfile.HEARING_AID);
                    }
                }
            }
        } catch (RemoteException e) {
@@ -2468,15 +2487,16 @@ public final class BluetoothAdapter {
     * Get the profile proxy object associated with the profile.
     *
     * <p>Profile can be one of {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP},
     * {@link BluetoothProfile#GATT}, or {@link BluetoothProfile#GATT_SERVER}. Clients must
     * implement {@link BluetoothProfile.ServiceListener} to get notified of the connection status
     * and to get the proxy object.
     * {@link BluetoothProfile#GATT}, {@link BluetoothProfile#HEARING_AID}, or {@link
     * BluetoothProfile#GATT_SERVER}. Clients must implement {@link
     * BluetoothProfile.ServiceListener} to get notified of the connection status and to get the
     * proxy object.
     *
     * @param context Context of the application
     * @param listener The service Listener for connection callbacks.
     * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEADSET},
     * {@link BluetoothProfile#A2DP}. {@link BluetoothProfile#GATT} or
     * {@link BluetoothProfile#GATT_SERVER}.
     * {@link BluetoothProfile#A2DP}, {@link BluetoothProfile#GATT}, {@link
     * BluetoothProfile#HEARING_AID} or {@link BluetoothProfile#GATT_SERVER}.
     * @return true on success, false on error
     */
    public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener listener,
@@ -2525,8 +2545,11 @@ public final class BluetoothAdapter {
            BluetoothHidDevice hidDevice = new BluetoothHidDevice(context, listener);
            return true;
        } else if (profile == BluetoothProfile.HEARING_AID) {
            if (isHearingAidProfileSupported()) {
                BluetoothHearingAid hearingAid = new BluetoothHearingAid(context, listener);
                return true;
            }
            return false;
        } else {
            return false;
        }
@@ -3253,7 +3276,7 @@ public final class BluetoothAdapter {
     * @hide
     */
    @SystemApi
    public abstract class MetadataListener {
    public abstract static class MetadataListener {
        /**
         * Callback triggered if the metadata of {@link BluetoothDevice} registered in
         * {@link #registerMetadataListener}.
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.bluetooth;

import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
@@ -42,7 +43,7 @@ public final class BluetoothCodecStatus implements Parcelable {
    public static final String EXTRA_CODEC_STATUS =
            "android.bluetooth.codec.extra.CODEC_STATUS";

    private final BluetoothCodecConfig mCodecConfig;
    private final @Nullable BluetoothCodecConfig mCodecConfig;
    private final BluetoothCodecConfig[] mCodecsLocalCapabilities;
    private final BluetoothCodecConfig[] mCodecsSelectableCapabilities;

@@ -140,7 +141,7 @@ public final class BluetoothCodecStatus implements Parcelable {
     * @return the current codec configuration
     */
    @UnsupportedAppUsage
    public BluetoothCodecConfig getCodecConfig() {
    public @Nullable BluetoothCodecConfig getCodecConfig() {
        return mCodecConfig;
    }

+86 −0
Original line number Diff line number Diff line
@@ -531,6 +531,28 @@ public final class BluetoothDevice implements Parcelable {
    public static final String ACTION_CONNECTION_ACCESS_CANCEL =
            "android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL";

    /**
     * Intent to broadcast silence mode changed.
     * Alway contains the extra field {@link #EXTRA_DEVICE}
     * Alway contains the extra field {@link #EXTRA_SILENCE_ENABLED}
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @SystemApi
    public static final String ACTION_SILENCE_MODE_CHANGED =
            "android.bluetooth.device.action.SILENCE_MODE_CHANGED";

    /**
     * Used as an extra field in {@link #ACTION_SILENCE_MODE_CHANGED} intent,
     * contains whether device is in silence mode as boolean.
     *
     * @hide
     */
    @SystemApi
    public static final String EXTRA_SILENCE_ENABLED =
            "android.bluetooth.device.extra.SILENCE_ENABLED";

    /**
     * Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REQUEST} intent.
     *
@@ -1591,6 +1613,70 @@ public final class BluetoothDevice implements Parcelable {
        return ACCESS_UNKNOWN;
    }

    /**
     * Set the Bluetooth device silence mode.
     *
     * When the {@link BluetoothDevice} enters silence mode, and the {@link BluetoothDevice}
     * is an active device (for A2DP or HFP), the active device for that profile
     * will be set to null.
     * If the {@link BluetoothDevice} exits silence mode while the A2DP or HFP
     * active device is null, the {@link BluetoothDevice} will be set as the
     * active device for that profile.
     * If the {@link BluetoothDevice} is disconnected, it exits silence mode.
     * If the {@link BluetoothDevice} is set as the active device for A2DP or
     * HFP, while silence mode is enabled, then the device will exit silence mode.
     * If the {@link BluetoothDevice} is in silence mode, AVRCP position change
     * event and HFP AG indicators will be disabled.
     * If the {@link BluetoothDevice} is not connected with A2DP or HFP, it cannot
     * enter silence mode.
     *
     * <p> Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
     *
     * @param silence true to enter silence mode, false to exit
     * @return true on success, false on error.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean setSilenceMode(boolean silence) {
        final IBluetooth service = sService;
        if (service == null) {
            return false;
        }
        try {
            if (getSilenceMode() == silence) {
                return true;
            }
            return service.setSilenceMode(this, silence);
        } catch (RemoteException e) {
            Log.e(TAG, "setSilenceMode fail", e);
            return false;
        }
    }

    /**
     * Get the device silence mode status
     *
     * <p> Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
     *
     * @return true on device in silence mode, otherwise false.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean getSilenceMode() {
        final IBluetooth service = sService;
        if (service == null) {
            return false;
        }
        try {
            return service.getSilenceMode(this);
        } catch (RemoteException e) {
            Log.e(TAG, "getSilenceMode fail", e);
            return false;
        }
    }

    /**
     * Sets whether the phonebook access is allowed to this device.
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
+29 −52
Original line number Diff line number Diff line
@@ -39,15 +39,14 @@ import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * This class provides the public APIs to control the Bluetooth Hearing Aid
 * profile.
 * This class provides the public APIs to control the Hearing Aid profile.
 *
 * <p>BluetoothHearingAid is a proxy object for controlling the Bluetooth Hearing Aid
 * Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
 * the BluetoothHearingAid proxy object.
 *
 * <p> Each method is protected with its appropriate permission.
 * @hide
 * <p> Android only supports one set of connected Bluetooth Hearing Aid device at a time. Each
 * method is protected with its appropriate permission.
 */
public final class BluetoothHearingAid implements BluetoothProfile {
    private static final String TAG = "BluetoothHearingAid";
@@ -56,7 +55,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {

    /**
     * Intent used to broadcast the change in connection state of the Hearing Aid
     * profile.
     * profile. Please note that in the binaural case, there will be two different LE devices for
     * the left and right side and each device will have their own connection state changes.S
     *
     * <p>This intent will have 3 extras:
     * <ul>
@@ -76,27 +76,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
    public static final String ACTION_CONNECTION_STATE_CHANGED =
            "android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED";

    /**
     * Intent used to broadcast the change in the Playing state of the Hearing Aid
     * profile.
     *
     * <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>
     * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
     * </ul>
     *
     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
     * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING},
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
     * receive.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_PLAYING_STATE_CHANGED =
            "android.bluetooth.hearingaid.profile.action.PLAYING_STATE_CHANGED";

    /**
     * Intent used to broadcast the selection of a connected device as active.
     *
@@ -108,6 +87,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
     * receive.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @UnsupportedAppUsage
@@ -115,32 +96,38 @@ public final class BluetoothHearingAid implements BluetoothProfile {
            "android.bluetooth.hearingaid.profile.action.ACTIVE_DEVICE_CHANGED";

    /**
     * Hearing Aid device is streaming music. This state can be one of
     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
     * {@link #ACTION_PLAYING_STATE_CHANGED} intent.
     * This device represents Left Hearing Aid.
     *
     * @hide
     */
    public static final int STATE_PLAYING = 10;
    public static final int SIDE_LEFT = IBluetoothHearingAid.SIDE_LEFT;

    /**
     * Hearing Aid device is NOT streaming music. This state can be one of
     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
     * {@link #ACTION_PLAYING_STATE_CHANGED} intent.
     * This device represents Right Hearing Aid.
     *
     * @hide
     */
    public static final int STATE_NOT_PLAYING = 11;

    /** This device represents Left Hearing Aid. */
    public static final int SIDE_LEFT = IBluetoothHearingAid.SIDE_LEFT;

    /** This device represents Right Hearing Aid. */
    public static final int SIDE_RIGHT = IBluetoothHearingAid.SIDE_RIGHT;

    /** This device is Monaural. */
    /**
     * This device is Monaural.
     *
     * @hide
     */
    public static final int MODE_MONAURAL = IBluetoothHearingAid.MODE_MONAURAL;

    /** This device is Binaural (should receive only left or right audio). */
    /**
     * This device is Binaural (should receive only left or right audio).
     *
     * @hide
     */
    public static final int MODE_BINAURAL = IBluetoothHearingAid.MODE_BINAURAL;

    /** Can't read ClientID for this device */
    /**
     * Indicates the HiSyncID could not be read and is unavailable.
     *
     * @hide
     */
    public static final long HI_SYNC_ID_INVALID = IBluetoothHearingAid.HI_SYNC_ID_INVALID;

    private Context mContext;
@@ -236,12 +223,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
        }
    }

    @Override
    public void finalize() {
        // The empty finalize needs to be kept or the
        // cts signature tests would fail.
    }

    /**
     * Initiate connection to a profile of the remote bluetooth device.
     *
@@ -538,10 +519,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
                return "connected";
            case STATE_DISCONNECTING:
                return "disconnecting";
            case STATE_PLAYING:
                return "playing";
            case STATE_NOT_PLAYING:
                return "not playing";
            default:
                return "<unknown state " + state + ">";
        }
Loading