Loading core/java/android/bluetooth/BluetoothA2dp.java +91 −76 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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. * * Loading @@ -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"); Loading Loading @@ -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"); Loading @@ -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 { Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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; } } Loading @@ -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) { Loading Loading @@ -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 { Loading core/java/android/bluetooth/BluetoothA2dpSink.java +69 −66 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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. * * Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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()) { Loading @@ -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()) { Loading @@ -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() Loading Loading @@ -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 { Loading Loading @@ -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) { Loading Loading @@ -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; Loading core/java/android/bluetooth/BluetoothActivityEnergyInfo.java +23 −19 Original line number Original line Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); Loading @@ -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; } } Loading Loading @@ -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() { Loading @@ -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)); } } } } core/java/android/bluetooth/BluetoothAdapter.java +273 −223 File changed.Preview size limit exceeded, changes collapsed. Show changes core/java/android/bluetooth/BluetoothAssignedNumbers.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -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 Loading
core/java/android/bluetooth/BluetoothA2dp.java +91 −76 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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. * * Loading @@ -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"); Loading Loading @@ -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"); Loading @@ -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 { Loading @@ -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 { Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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) { Loading Loading @@ -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; } } Loading @@ -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) { Loading Loading @@ -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 { Loading
core/java/android/bluetooth/BluetoothA2dpSink.java +69 −66 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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. * * Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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()) { Loading @@ -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()) { Loading @@ -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() Loading Loading @@ -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 { Loading Loading @@ -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) { Loading Loading @@ -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; Loading
core/java/android/bluetooth/BluetoothActivityEnergyInfo.java +23 −19 Original line number Original line Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); Loading @@ -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; } } Loading Loading @@ -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() { Loading @@ -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)); } } } }
core/java/android/bluetooth/BluetoothAdapter.java +273 −223 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/java/android/bluetooth/BluetoothAssignedNumbers.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -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