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

Commit bcdfca90 authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

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

am: 24ad4cfc

Change-Id: I25df75f9cee3ebe0471fa7f9b3375d849ee31339
parents a43b3827 24ad4cfc
Loading
Loading
Loading
Loading
+91 −76
Original line number Original line 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
     * We don't have a stored preference for whether or not the given A2DP sink device supports
     * optional codecs.
     * optional codecs.
     * @hide */
     *
     * @hide
     */
    public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1;
    public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1;


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


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


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


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


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


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


    final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
    private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
            new IBluetoothStateChangeCallback.Stub() {
            new IBluetoothStateChangeCallback.Stub() {
                public void onBluetoothStateChange(boolean up) {
                public void onBluetoothStateChange(boolean up) {
                    if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + 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
     * Create a BluetoothA2dp proxy object for interacting with the local
     * Bluetooth A2DP service.
     * Bluetooth A2DP service.
     *
     */
     */
    /*package*/ BluetoothA2dp(Context context, ServiceListener l) {
    /*package*/ BluetoothA2dp(Context context, ServiceListener l) {
        mContext = context;
        mContext = context;
@@ -261,10 +274,12 @@ public final class BluetoothA2dp implements BluetoothProfile {
        }
        }
    }
    }


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

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

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


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


    final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
    private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
            new IBluetoothStateChangeCallback.Stub() {
            new IBluetoothStateChangeCallback.Stub() {
                public void onBluetoothStateChange(boolean up) {
                public void onBluetoothStateChange(boolean up) {
                    if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + 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
     * Create a BluetoothA2dp proxy object for interacting with the local
     * Bluetooth A2DP service.
     * Bluetooth A2DP service.
     *
     */
     */
    /*package*/ BluetoothA2dpSink(Context context, ServiceListener l) {
    /*package*/ BluetoothA2dpSink(Context context, ServiceListener l) {
        mContext = context;
        mContext = context;
@@ -212,9 +212,11 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
        }
        }
    }
    }


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

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

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



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


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


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

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Original line Diff line number Diff line
@@ -20,9 +20,9 @@ package android.bluetooth;
 * Bluetooth Assigned Numbers.
 * Bluetooth Assigned Numbers.
 * <p>
 * <p>
 * For now we only include Company ID values.
 * 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 {
public class BluetoothAssignedNumbers {


Loading