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

Commit 450c6035 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge changes from topic "bt-fix-checkstyle-errors" am: 838ab94a am:...

Merge "Merge changes from topic "bt-fix-checkstyle-errors" am: 838ab94a am: 8ae54621 am: 24ad4cfc" into oc-mr1-dev-plus-aosp
parents 3a839d7f bcdfca90
Loading
Loading
Loading
Loading
+91 −76
Original line number Diff line number Diff line
@@ -139,42 +139,55 @@ public final class BluetoothA2dp implements BluetoothProfile {
    /**
     * We don't have a stored preference for whether or not the given A2DP sink device supports
     * optional codecs.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1;

    /**
     * The given A2DP sink device does not support optional codecs.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0;

    /**
     * The given A2DP sink device does support optional codecs.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_SUPPORTED = 1;

    /**
     * We don't have a stored preference for whether optional codecs should be enabled or disabled
     * for the given A2DP device.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_PREF_UNKNOWN = -1;

    /**
     * Optional codecs should be disabled for the given A2DP device.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_PREF_DISABLED = 0;

    /**
     * Optional codecs should be enabled for the given A2DP device.
     *  @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_PREF_ENABLED = 1;

    private Context mContext;
    private ServiceListener mServiceListener;
    private final ReentrantReadWriteLock mServiceLock = new ReentrantReadWriteLock();
    @GuardedBy("mServiceLock") private IBluetoothA2dp mService;
    @GuardedBy("mServiceLock")
    private IBluetoothA2dp mService;
    private BluetoothAdapter mAdapter;

    final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
    private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
            new IBluetoothStateChangeCallback.Stub() {
                public void onBluetoothStateChange(boolean up) {
                    if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
@@ -204,10 +217,10 @@ public final class BluetoothA2dp implements BluetoothProfile {
                    }
                }
            };

    /**
     * Create a BluetoothA2dp proxy object for interacting with the local
     * Bluetooth A2DP service.
     *
     */
    /*package*/ BluetoothA2dp(Context context, ServiceListener l) {
        mContext = context;
@@ -261,10 +274,12 @@ public final class BluetoothA2dp 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.
     *
@@ -283,16 +298,14 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * permission.
     *
     * @param device Remote Bluetooth Device
     * @return false on immediate error,
     *               true otherwise
     * @return false on immediate error, true otherwise
     * @hide
     */
    public boolean connect(BluetoothDevice device) {
        if (DBG) log("connect(" + device + ")");
        try {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled() &&
                isValidDevice(device)) {
            if (mService != null && isEnabled() && isValidDevice(device)) {
                return mService.connect(device);
            }
            if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -327,16 +340,14 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * permission.
     *
     * @param device Remote Bluetooth Device
     * @return false on immediate error,
     *               true otherwise
     * @return false on immediate error, true otherwise
     * @hide
     */
    public boolean disconnect(BluetoothDevice device) {
        if (DBG) log("disconnect(" + device + ")");
        try {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled() &&
                isValidDevice(device)) {
            if (mService != null && isEnabled() && isValidDevice(device)) {
                return mService.disconnect(device);
            }
            if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -352,6 +363,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<BluetoothDevice> getConnectedDevices() {
        if (VDBG) log("getConnectedDevices()");
        try {
@@ -372,6 +384,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
        if (VDBG) log("getDevicesMatchingStates()");
        try {
@@ -392,6 +405,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public int getConnectionState(BluetoothDevice device) {
        if (VDBG) log("getState(" + device + ")");
        try {
@@ -431,8 +445,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled()
                    && isValidDevice(device)) {
                if (priority != BluetoothProfile.PRIORITY_OFF &&
                    priority != BluetoothProfile.PRIORITY_ON) {
                if (priority != BluetoothProfile.PRIORITY_OFF
                        && priority != BluetoothProfile.PRIORITY_ON) {
                    return false;
                }
                return mService.setPriority(device, priority);
@@ -577,6 +591,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * This function checks if the remote device is an AVCRP
     * target and thus whether we should send volume keys
     * changes or not.
     *
     * @hide
     */
    public boolean shouldSendVolumeKeys(BluetoothDevice device) {
@@ -692,7 +707,6 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * @param device The device to check
     * @return one of OPTIONAL_CODECS_SUPPORT_UNKNOWN, OPTIONAL_CODECS_NOT_SUPPORTED, or
     * OPTIONAL_CODECS_SUPPORTED.
     *
     * @hide
     */
    public int supportsOptionalCodecs(BluetoothDevice device) {
@@ -717,7 +731,6 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * @param device The device in question.
     * @return one of OPTIONAL_CODECS_PREF_UNKNOWN, OPTIONAL_CODECS_PREF_ENABLED, or
     * OPTIONAL_CODECS_PREF_DISABLED.
     *
     * @hide
     */
    public int getOptionalCodecsEnabled(BluetoothDevice device) {
@@ -747,9 +760,9 @@ public final class BluetoothA2dp implements BluetoothProfile {
     */
    public void setOptionalCodecsEnabled(BluetoothDevice device, int value) {
        try {
            if (value != BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN &&
                    value != BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED &&
                    value != BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
            if (value != BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN
                    && value != BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED
                    && value != BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
                Log.e(TAG, "Invalid value passed to setOptionalCodecsEnabled: " + value);
                return;
            }
@@ -772,6 +785,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
     * Helper for converting a state to a string.
     *
     * For debug use only - strings are not internationalized.
     *
     * @hide
     */
    public static String stateToString(int state) {
@@ -807,6 +821,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
                mServiceListener.onServiceConnected(BluetoothProfile.A2DP, BluetoothA2dp.this);
            }
        }

        public void onServiceDisconnected(ComponentName className) {
            if (DBG) Log.d(TAG, "Proxy object disconnected");
            try {
+69 −66
Original line number Diff line number Diff line
@@ -120,15 +120,15 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * This extra represents the current audio configuration of the A2DP source device.
     * {@see BluetoothAudioConfig}
     */
    public static final String EXTRA_AUDIO_CONFIG
            = "android.bluetooth.a2dp-sink.profile.extra.AUDIO_CONFIG";
    public static final String EXTRA_AUDIO_CONFIG =
            "android.bluetooth.a2dp-sink.profile.extra.AUDIO_CONFIG";

    private Context mContext;
    private ServiceListener mServiceListener;
    private IBluetoothA2dpSink mService;
    private BluetoothAdapter mAdapter;

    final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
    private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
            new IBluetoothStateChangeCallback.Stub() {
                public void onBluetoothStateChange(boolean up) {
                    if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
@@ -156,10 +156,10 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
                    }
                }
            };

    /**
     * Create a BluetoothA2dp proxy object for interacting with the local
     * Bluetooth A2DP service.
     *
     */
    /*package*/ BluetoothA2dpSink(Context context, ServiceListener l) {
        mContext = context;
@@ -212,9 +212,11 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
        }
    }

    @Override
    public void finalize() {
        close();
    }

    /**
     * Initiate connection to a profile of the remote bluetooth device.
     *
@@ -233,14 +235,12 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * permission.
     *
     * @param device Remote Bluetooth Device
     * @return false on immediate error,
     *               true otherwise
     * @return false on immediate error, true otherwise
     * @hide
     */
    public boolean connect(BluetoothDevice device) {
        if (DBG) log("connect(" + device + ")");
        if (mService != null && isEnabled() &&
            isValidDevice(device)) {
        if (mService != null && isEnabled() && isValidDevice(device)) {
            try {
                return mService.connect(device);
            } catch (RemoteException e) {
@@ -274,14 +274,12 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * permission.
     *
     * @param device Remote Bluetooth Device
     * @return false on immediate error,
     *               true otherwise
     * @return false on immediate error, true otherwise
     * @hide
     */
    public boolean disconnect(BluetoothDevice device) {
        if (DBG) log("disconnect(" + device + ")");
        if (mService != null && isEnabled() &&
            isValidDevice(device)) {
        if (mService != null && isEnabled() && isValidDevice(device)) {
            try {
                return mService.disconnect(device);
            } catch (RemoteException e) {
@@ -296,6 +294,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<BluetoothDevice> getConnectedDevices() {
        if (VDBG) log("getConnectedDevices()");
        if (mService != null && isEnabled()) {
@@ -313,6 +312,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
        if (VDBG) log("getDevicesMatchingStates()");
        if (mService != null && isEnabled()) {
@@ -330,6 +330,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
    /**
     * {@inheritDoc}
     */
    @Override
    public int getConnectionState(BluetoothDevice device) {
        if (VDBG) log("getState(" + device + ")");
        if (mService != null && isEnabled()
@@ -390,8 +391,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
        if (DBG) log("setPriority(" + device + ", " + priority + ")");
        if (mService != null && isEnabled()
                && isValidDevice(device)) {
            if (priority != BluetoothProfile.PRIORITY_OFF &&
                priority != BluetoothProfile.PRIORITY_ON){
            if (priority != BluetoothProfile.PRIORITY_OFF
                    && priority != BluetoothProfile.PRIORITY_ON) {
                return false;
            }
            try {
@@ -458,6 +459,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * Helper for converting a state to a string.
     *
     * For debug use only - strings are not internationalized.
     *
     * @hide
     */
    public static String stateToString(int state) {
@@ -489,6 +491,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
                        BluetoothA2dpSink.this);
            }
        }

        public void onServiceDisconnected(ComponentName className) {
            if (DBG) Log.d(TAG, "Proxy object disconnected");
            mService = null;
+23 −19
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.util.Arrays;
 * Record of energy and activity information from controller and
 * underlying bt stack state.Timestamp the record with system
 * time
 *
 * @hide
 */
public final class BluetoothActivityEnergyInfo implements Parcelable {
@@ -86,6 +87,8 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
                }
            };


    @Override
    @SuppressWarnings("unchecked")
    public void writeToParcel(Parcel out, int flags) {
        out.writeLong(mTimestamp);
@@ -97,6 +100,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
        out.writeTypedArray(mUidTraffic, flags);
    }

    @Override
    public int describeContents() {
        return 0;
    }
@@ -131,6 +135,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {

    /**
     * product of current(mA), voltage(V) and time(ms)
     *
     * @return energy used
     */
    public long getControllerEnergyUsed() {
@@ -156,8 +161,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
     * @return if the record is valid
     */
    public boolean isValid() {
        return ((mControllerTxTimeMs >=0) &&
                (mControllerRxTimeMs >=0) &&
                (mControllerIdleTimeMs >=0));
        return ((mControllerTxTimeMs >= 0) && (mControllerRxTimeMs >= 0)
                && (mControllerIdleTimeMs >= 0));
    }
}
+273 −223

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@ package android.bluetooth;
 * Bluetooth Assigned Numbers.
 * <p>
 * For now we only include Company ID values.
 * @see <a href="https://www.bluetooth.org/technical/assignednumbers/identifiers.htm">
 * The Official Bluetooth SIG Member Website | Company Identifiers</a>
 *
 * @see <a href="https://www.bluetooth.org/technical/assignednumbers/identifiers.htm"> The Official
 * Bluetooth SIG Member Website | Company Identifiers</a>
 */
public class BluetoothAssignedNumbers {

Loading