Loading framework/java/android/bluetooth/BluetoothA2dp.java +8 −9 Original line number Original line Diff line number Diff line Loading @@ -105,10 +105,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * Intent used to broadcast the change in the Audio Codec state of the * Intent used to broadcast the change in the Audio Codec state of the * A2DP Source profile. * A2DP Source profile. * * * <p>This intent will have 3 extras: * <p>This intent will have 2 extras: * <ul> * <ul> * <li> {@link #EXTRA_CODEC_CONFIG} - The current codec configuration. </li> * <li> {@link BluetoothCodecStatus#EXTRA_CODEC_STATUS} - The codec status. </li> * <li> {@link #EXTRA_PREVIOUS_CODEC_CONFIG} - The previous codec configuration. </li> * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently * connected, otherwise it is not included.</li> * connected, otherwise it is not included.</li> * </ul> * </ul> Loading Loading @@ -564,24 +563,24 @@ public final class BluetoothA2dp implements BluetoothProfile { } } /** /** * Gets the current codec configuration. * Gets the current codec status (configuration and capability). * * * @return the current codec configuration * @return the current codec status * @hide * @hide */ */ public BluetoothCodecConfig getCodecConfig() { public BluetoothCodecStatus getCodecStatus() { if (DBG) Log.d(TAG, "getCodecConfig"); if (DBG) Log.d(TAG, "getCodecStatus"); try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); if (mService != null && isEnabled()) { if (mService != null && isEnabled()) { return mService.getCodecConfig(); return mService.getCodecStatus(); } } if (mService == null) { if (mService == null) { Log.w(TAG, "Proxy not attached to service"); Log.w(TAG, "Proxy not attached to service"); } } return null; return null; } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Error talking to BT service in getCodecConfig()", e); Log.e(TAG, "Error talking to BT service in getCodecStatus()", e); return null; return null; } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); Loading framework/java/android/bluetooth/BluetoothCodecConfig.java +115 −28 Original line number Original line Diff line number Diff line Loading @@ -29,24 +29,6 @@ import java.util.Objects; * {@hide} * {@hide} */ */ public final class BluetoothCodecConfig implements Parcelable { public final class BluetoothCodecConfig implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the current codec configuration of the A2DP * profile. */ public static final String EXTRA_CODEC_CONFIG = "android.bluetooth.codec.extra.CODEC_CONFIG"; /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the previous codec configuration of the A2DP * profile. */ public static final String EXTRA_PREVIOUS_CODEC_CONFIG = "android.bluetooth.codec.extra.PREVIOUS_CODEC_CONFIG"; // Add an entry for each source codec here. // Add an entry for each source codec here. // NOTE: The values should be same as those listed in the following file: // NOTE: The values should be same as those listed in the following file: // hardware/libhardware/include/hardware/bt_av.h // hardware/libhardware/include/hardware/bt_av.h Loading Loading @@ -128,13 +110,93 @@ public final class BluetoothCodecConfig implements Parcelable { mCodecSpecific2, mCodecSpecific3, mCodecSpecific4); mCodecSpecific2, mCodecSpecific3, mCodecSpecific4); } } /** * Checks whether the object contains valid codec configuration. * * @return true if the object contains valid codec configuration, * otherwise false. */ public boolean isValid() { return (mSampleRate != SAMPLE_RATE_NONE) && (mBitsPerSample != BITS_PER_SAMPLE_NONE) && (mChannelMode != CHANNEL_MODE_NONE); } /** * Adds capability string to an existing string. * * @param prevStr the previous string with the capabilities. Can be * a null pointer. * @param capStr the capability string to append to prevStr argument. * @return the result string in the form "prevStr|capStr". */ private static String appendCapabilityToString(String prevStr, String capStr) { if (prevStr == null) { return capStr; } return prevStr + "|" + capStr; } @Override @Override public String toString() { public String toString() { return "{mCodecType:" + mCodecType + String sampleRateStr = null; if (mSampleRate == SAMPLE_RATE_NONE) { sampleRateStr = appendCapabilityToString(sampleRateStr, "NONE"); } if ((mSampleRate & SAMPLE_RATE_44100) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "44100"); } if ((mSampleRate & SAMPLE_RATE_48000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "48000"); } if ((mSampleRate & SAMPLE_RATE_88200) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "88200"); } if ((mSampleRate & SAMPLE_RATE_96000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "96000"); } if ((mSampleRate & SAMPLE_RATE_176400) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "176400"); } if ((mSampleRate & SAMPLE_RATE_192000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "192000"); } String bitsPerSampleStr = null; if (mBitsPerSample == BITS_PER_SAMPLE_NONE) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "NONE"); } if ((mBitsPerSample & BITS_PER_SAMPLE_16) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "16"); } if ((mBitsPerSample & BITS_PER_SAMPLE_24) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "24"); } if ((mBitsPerSample & BITS_PER_SAMPLE_32) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "32"); } String channelModeStr = null; if (mChannelMode == CHANNEL_MODE_NONE) { channelModeStr = appendCapabilityToString(channelModeStr, "NONE"); } if ((mChannelMode & CHANNEL_MODE_MONO) != 0) { channelModeStr = appendCapabilityToString(channelModeStr, "MONO"); } if ((mChannelMode & CHANNEL_MODE_STEREO) != 0) { channelModeStr = appendCapabilityToString(channelModeStr, "STEREO"); } return "{codecName:" + getCodecName() + ",mCodecType:" + mCodecType + ",mCodecPriority:" + mCodecPriority + ",mCodecPriority:" + mCodecPriority + ",mSampleRate:" + String.format("0x%x", mSampleRate) + ",mSampleRate:" + String.format("0x%x", mSampleRate) + "(" + sampleRateStr + ")" + ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) + ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) + "(" + bitsPerSampleStr + ")" + ",mChannelMode:" + String.format("0x%x", mChannelMode) + ",mChannelMode:" + String.format("0x%x", mChannelMode) + "(" + channelModeStr + ")" + ",mCodecSpecific1:" + mCodecSpecific1 + ",mCodecSpecific1:" + mCodecSpecific1 + ",mCodecSpecific2:" + mCodecSpecific2 + ",mCodecSpecific2:" + mCodecSpecific2 + ",mCodecSpecific3:" + mCodecSpecific3 + ",mCodecSpecific3:" + mCodecSpecific3 + Loading Loading @@ -181,7 +243,32 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec type. * Gets the codec name. * * @return the codec name */ public String getCodecName() { switch (mCodecType) { case SOURCE_CODEC_TYPE_SBC: return "SBC"; case SOURCE_CODEC_TYPE_AAC: return "AAC"; case SOURCE_CODEC_TYPE_APTX: return "aptX"; case SOURCE_CODEC_TYPE_APTX_HD: return "aptX HD"; case SOURCE_CODEC_TYPE_LDAC: return "LDAC"; case SOURCE_CODEC_TYPE_INVALID: return "INVALID CODEC"; default: break; } return "UNKNOWN CODEC(" + mCodecType + ")"; } /** * Gets the codec type. * See {@link android.bluetooth.BluetoothCodecConfig#SOURCE_CODEC_TYPE_SBC}. * See {@link android.bluetooth.BluetoothCodecConfig#SOURCE_CODEC_TYPE_SBC}. * * * @return the codec type * @return the codec type Loading @@ -191,7 +278,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec selection priority. * Gets the codec selection priority. * The codec selection priority is relative to other codecs: larger value * The codec selection priority is relative to other codecs: larger value * means higher priority. If 0, reset to default. * means higher priority. If 0, reset to default. * * Loading @@ -202,7 +289,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec sample rate. The value can be a bitmask with all * Gets the codec sample rate. The value can be a bitmask with all * supported sample rates: * supported sample rates: * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_44100} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_44100} or Loading @@ -219,7 +306,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec bits per sample. The value can be a bitmask with all * Gets the codec bits per sample. The value can be a bitmask with all * bits per sample supported: * bits per sample supported: * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_16} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_16} or Loading @@ -233,7 +320,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec channel mode. The value can be a bitmask with all * Gets the codec channel mode. The value can be a bitmask with all * supported channel modes: * supported channel modes: * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_MONO} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_MONO} or Loading @@ -246,7 +333,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value1. * Gets a codec specific value1. * * * @return a codec specific value1. * @return a codec specific value1. */ */ Loading @@ -255,7 +342,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value2. * Gets a codec specific value2. * * * @return a codec specific value2 * @return a codec specific value2 */ */ Loading @@ -264,7 +351,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value3. * Gets a codec specific value3. * * * @return a codec specific value3 * @return a codec specific value3 */ */ Loading @@ -273,7 +360,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value4. * Gets a codec specific value4. * * * @return a codec specific value4 * @return a codec specific value4 */ */ Loading framework/java/android/bluetooth/BluetoothCodecStatus.aidl 0 → 100644 +19 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.bluetooth; parcelable BluetoothCodecStatus; framework/java/android/bluetooth/BluetoothCodecStatus.java 0 → 100644 +134 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.bluetooth; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays; import java.util.Objects; /** * Represents the codec status (configuration and capability) for a Bluetooth * A2DP source device. * * {@see BluetoothA2dp} * * {@hide} */ public final class BluetoothCodecStatus implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the current codec status of the A2DP * profile. */ public static final String EXTRA_CODEC_STATUS = "android.bluetooth.codec.extra.CODEC_STATUS"; private final BluetoothCodecConfig mCodecConfig; private final BluetoothCodecConfig[] mCodecsLocalCapabilities; private final BluetoothCodecConfig[] mCodecsSelectableCapabilities; public BluetoothCodecStatus(BluetoothCodecConfig codecConfig, BluetoothCodecConfig[] codecsLocalCapabilities, BluetoothCodecConfig[] codecsSelectableCapabilities) { mCodecConfig = codecConfig; mCodecsLocalCapabilities = codecsLocalCapabilities; mCodecsSelectableCapabilities = codecsSelectableCapabilities; } @Override public boolean equals(Object o) { if (o instanceof BluetoothCodecStatus) { BluetoothCodecStatus other = (BluetoothCodecStatus)o; return (Objects.equals(other.mCodecConfig, mCodecConfig) && Objects.equals(other.mCodecsLocalCapabilities, mCodecsLocalCapabilities) && Objects.equals(other.mCodecsSelectableCapabilities, mCodecsSelectableCapabilities)); } return false; } @Override public int hashCode() { return Objects.hash(mCodecConfig, mCodecsLocalCapabilities, mCodecsLocalCapabilities); } @Override public String toString() { return "{mCodecConfig:" + mCodecConfig + ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities) + ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities) + "}"; } public int describeContents() { return 0; } public static final Parcelable.Creator<BluetoothCodecStatus> CREATOR = new Parcelable.Creator<BluetoothCodecStatus>() { public BluetoothCodecStatus createFromParcel(Parcel in) { final BluetoothCodecConfig codecConfig = in.readTypedObject(BluetoothCodecConfig.CREATOR); final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR); final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR); return new BluetoothCodecStatus(codecConfig, codecsLocalCapabilities, codecsSelectableCapabilities); } public BluetoothCodecStatus[] newArray(int size) { return new BluetoothCodecStatus[size]; } }; public void writeToParcel(Parcel out, int flags) { out.writeTypedObject(mCodecConfig, 0); out.writeTypedArray(mCodecsLocalCapabilities, 0); out.writeTypedArray(mCodecsSelectableCapabilities, 0); } /** * Gets the current codec configuration. * * @return the current codec configuration */ public BluetoothCodecConfig getCodecConfig() { return mCodecConfig; } /** * Gets the codecs local capabilities. * * @return an array with the codecs local capabilities */ public BluetoothCodecConfig[] getCodecsLocalCapabilities() { return mCodecsLocalCapabilities; } /** * Gets the codecs selectable capabilities. * * @return an array with the codecs selectable capabilities */ public BluetoothCodecConfig[] getCodecsSelectableCapabilities() { return mCodecsSelectableCapabilities; } } framework/java/android/bluetooth/IBluetoothA2dp.aidl +2 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.bluetooth; package android.bluetooth; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; /** /** Loading @@ -37,6 +38,6 @@ interface IBluetoothA2dp { oneway void adjustAvrcpAbsoluteVolume(int direction); oneway void adjustAvrcpAbsoluteVolume(int direction); oneway void setAvrcpAbsoluteVolume(int volume); oneway void setAvrcpAbsoluteVolume(int volume); boolean isA2dpPlaying(in BluetoothDevice device); boolean isA2dpPlaying(in BluetoothDevice device); BluetoothCodecConfig getCodecConfig(); BluetoothCodecStatus getCodecStatus(); oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig); oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig); } } Loading
framework/java/android/bluetooth/BluetoothA2dp.java +8 −9 Original line number Original line Diff line number Diff line Loading @@ -105,10 +105,9 @@ public final class BluetoothA2dp implements BluetoothProfile { * Intent used to broadcast the change in the Audio Codec state of the * Intent used to broadcast the change in the Audio Codec state of the * A2DP Source profile. * A2DP Source profile. * * * <p>This intent will have 3 extras: * <p>This intent will have 2 extras: * <ul> * <ul> * <li> {@link #EXTRA_CODEC_CONFIG} - The current codec configuration. </li> * <li> {@link BluetoothCodecStatus#EXTRA_CODEC_STATUS} - The codec status. </li> * <li> {@link #EXTRA_PREVIOUS_CODEC_CONFIG} - The previous codec configuration. </li> * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently * connected, otherwise it is not included.</li> * connected, otherwise it is not included.</li> * </ul> * </ul> Loading Loading @@ -564,24 +563,24 @@ public final class BluetoothA2dp implements BluetoothProfile { } } /** /** * Gets the current codec configuration. * Gets the current codec status (configuration and capability). * * * @return the current codec configuration * @return the current codec status * @hide * @hide */ */ public BluetoothCodecConfig getCodecConfig() { public BluetoothCodecStatus getCodecStatus() { if (DBG) Log.d(TAG, "getCodecConfig"); if (DBG) Log.d(TAG, "getCodecStatus"); try { try { mServiceLock.readLock().lock(); mServiceLock.readLock().lock(); if (mService != null && isEnabled()) { if (mService != null && isEnabled()) { return mService.getCodecConfig(); return mService.getCodecStatus(); } } if (mService == null) { if (mService == null) { Log.w(TAG, "Proxy not attached to service"); Log.w(TAG, "Proxy not attached to service"); } } return null; return null; } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Error talking to BT service in getCodecConfig()", e); Log.e(TAG, "Error talking to BT service in getCodecStatus()", e); return null; return null; } finally { } finally { mServiceLock.readLock().unlock(); mServiceLock.readLock().unlock(); Loading
framework/java/android/bluetooth/BluetoothCodecConfig.java +115 −28 Original line number Original line Diff line number Diff line Loading @@ -29,24 +29,6 @@ import java.util.Objects; * {@hide} * {@hide} */ */ public final class BluetoothCodecConfig implements Parcelable { public final class BluetoothCodecConfig implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the current codec configuration of the A2DP * profile. */ public static final String EXTRA_CODEC_CONFIG = "android.bluetooth.codec.extra.CODEC_CONFIG"; /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the previous codec configuration of the A2DP * profile. */ public static final String EXTRA_PREVIOUS_CODEC_CONFIG = "android.bluetooth.codec.extra.PREVIOUS_CODEC_CONFIG"; // Add an entry for each source codec here. // Add an entry for each source codec here. // NOTE: The values should be same as those listed in the following file: // NOTE: The values should be same as those listed in the following file: // hardware/libhardware/include/hardware/bt_av.h // hardware/libhardware/include/hardware/bt_av.h Loading Loading @@ -128,13 +110,93 @@ public final class BluetoothCodecConfig implements Parcelable { mCodecSpecific2, mCodecSpecific3, mCodecSpecific4); mCodecSpecific2, mCodecSpecific3, mCodecSpecific4); } } /** * Checks whether the object contains valid codec configuration. * * @return true if the object contains valid codec configuration, * otherwise false. */ public boolean isValid() { return (mSampleRate != SAMPLE_RATE_NONE) && (mBitsPerSample != BITS_PER_SAMPLE_NONE) && (mChannelMode != CHANNEL_MODE_NONE); } /** * Adds capability string to an existing string. * * @param prevStr the previous string with the capabilities. Can be * a null pointer. * @param capStr the capability string to append to prevStr argument. * @return the result string in the form "prevStr|capStr". */ private static String appendCapabilityToString(String prevStr, String capStr) { if (prevStr == null) { return capStr; } return prevStr + "|" + capStr; } @Override @Override public String toString() { public String toString() { return "{mCodecType:" + mCodecType + String sampleRateStr = null; if (mSampleRate == SAMPLE_RATE_NONE) { sampleRateStr = appendCapabilityToString(sampleRateStr, "NONE"); } if ((mSampleRate & SAMPLE_RATE_44100) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "44100"); } if ((mSampleRate & SAMPLE_RATE_48000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "48000"); } if ((mSampleRate & SAMPLE_RATE_88200) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "88200"); } if ((mSampleRate & SAMPLE_RATE_96000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "96000"); } if ((mSampleRate & SAMPLE_RATE_176400) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "176400"); } if ((mSampleRate & SAMPLE_RATE_192000) != 0) { sampleRateStr = appendCapabilityToString(sampleRateStr, "192000"); } String bitsPerSampleStr = null; if (mBitsPerSample == BITS_PER_SAMPLE_NONE) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "NONE"); } if ((mBitsPerSample & BITS_PER_SAMPLE_16) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "16"); } if ((mBitsPerSample & BITS_PER_SAMPLE_24) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "24"); } if ((mBitsPerSample & BITS_PER_SAMPLE_32) != 0) { bitsPerSampleStr = appendCapabilityToString(bitsPerSampleStr, "32"); } String channelModeStr = null; if (mChannelMode == CHANNEL_MODE_NONE) { channelModeStr = appendCapabilityToString(channelModeStr, "NONE"); } if ((mChannelMode & CHANNEL_MODE_MONO) != 0) { channelModeStr = appendCapabilityToString(channelModeStr, "MONO"); } if ((mChannelMode & CHANNEL_MODE_STEREO) != 0) { channelModeStr = appendCapabilityToString(channelModeStr, "STEREO"); } return "{codecName:" + getCodecName() + ",mCodecType:" + mCodecType + ",mCodecPriority:" + mCodecPriority + ",mCodecPriority:" + mCodecPriority + ",mSampleRate:" + String.format("0x%x", mSampleRate) + ",mSampleRate:" + String.format("0x%x", mSampleRate) + "(" + sampleRateStr + ")" + ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) + ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) + "(" + bitsPerSampleStr + ")" + ",mChannelMode:" + String.format("0x%x", mChannelMode) + ",mChannelMode:" + String.format("0x%x", mChannelMode) + "(" + channelModeStr + ")" + ",mCodecSpecific1:" + mCodecSpecific1 + ",mCodecSpecific1:" + mCodecSpecific1 + ",mCodecSpecific2:" + mCodecSpecific2 + ",mCodecSpecific2:" + mCodecSpecific2 + ",mCodecSpecific3:" + mCodecSpecific3 + ",mCodecSpecific3:" + mCodecSpecific3 + Loading Loading @@ -181,7 +243,32 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec type. * Gets the codec name. * * @return the codec name */ public String getCodecName() { switch (mCodecType) { case SOURCE_CODEC_TYPE_SBC: return "SBC"; case SOURCE_CODEC_TYPE_AAC: return "AAC"; case SOURCE_CODEC_TYPE_APTX: return "aptX"; case SOURCE_CODEC_TYPE_APTX_HD: return "aptX HD"; case SOURCE_CODEC_TYPE_LDAC: return "LDAC"; case SOURCE_CODEC_TYPE_INVALID: return "INVALID CODEC"; default: break; } return "UNKNOWN CODEC(" + mCodecType + ")"; } /** * Gets the codec type. * See {@link android.bluetooth.BluetoothCodecConfig#SOURCE_CODEC_TYPE_SBC}. * See {@link android.bluetooth.BluetoothCodecConfig#SOURCE_CODEC_TYPE_SBC}. * * * @return the codec type * @return the codec type Loading @@ -191,7 +278,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec selection priority. * Gets the codec selection priority. * The codec selection priority is relative to other codecs: larger value * The codec selection priority is relative to other codecs: larger value * means higher priority. If 0, reset to default. * means higher priority. If 0, reset to default. * * Loading @@ -202,7 +289,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec sample rate. The value can be a bitmask with all * Gets the codec sample rate. The value can be a bitmask with all * supported sample rates: * supported sample rates: * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_44100} or * {@link android.bluetooth.BluetoothCodecConfig#SAMPLE_RATE_44100} or Loading @@ -219,7 +306,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec bits per sample. The value can be a bitmask with all * Gets the codec bits per sample. The value can be a bitmask with all * bits per sample supported: * bits per sample supported: * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_16} or * {@link android.bluetooth.BluetoothCodecConfig#BITS_PER_SAMPLE_16} or Loading @@ -233,7 +320,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns the codec channel mode. The value can be a bitmask with all * Gets the codec channel mode. The value can be a bitmask with all * supported channel modes: * supported channel modes: * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_NONE} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_MONO} or * {@link android.bluetooth.BluetoothCodecConfig#CHANNEL_MODE_MONO} or Loading @@ -246,7 +333,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value1. * Gets a codec specific value1. * * * @return a codec specific value1. * @return a codec specific value1. */ */ Loading @@ -255,7 +342,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value2. * Gets a codec specific value2. * * * @return a codec specific value2 * @return a codec specific value2 */ */ Loading @@ -264,7 +351,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value3. * Gets a codec specific value3. * * * @return a codec specific value3 * @return a codec specific value3 */ */ Loading @@ -273,7 +360,7 @@ public final class BluetoothCodecConfig implements Parcelable { } } /** /** * Returns a codec specific value4. * Gets a codec specific value4. * * * @return a codec specific value4 * @return a codec specific value4 */ */ Loading
framework/java/android/bluetooth/BluetoothCodecStatus.aidl 0 → 100644 +19 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.bluetooth; parcelable BluetoothCodecStatus;
framework/java/android/bluetooth/BluetoothCodecStatus.java 0 → 100644 +134 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.bluetooth; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays; import java.util.Objects; /** * Represents the codec status (configuration and capability) for a Bluetooth * A2DP source device. * * {@see BluetoothA2dp} * * {@hide} */ public final class BluetoothCodecStatus implements Parcelable { /** * Extra for the codec configuration intents of the individual profiles. * * This extra represents the current codec status of the A2DP * profile. */ public static final String EXTRA_CODEC_STATUS = "android.bluetooth.codec.extra.CODEC_STATUS"; private final BluetoothCodecConfig mCodecConfig; private final BluetoothCodecConfig[] mCodecsLocalCapabilities; private final BluetoothCodecConfig[] mCodecsSelectableCapabilities; public BluetoothCodecStatus(BluetoothCodecConfig codecConfig, BluetoothCodecConfig[] codecsLocalCapabilities, BluetoothCodecConfig[] codecsSelectableCapabilities) { mCodecConfig = codecConfig; mCodecsLocalCapabilities = codecsLocalCapabilities; mCodecsSelectableCapabilities = codecsSelectableCapabilities; } @Override public boolean equals(Object o) { if (o instanceof BluetoothCodecStatus) { BluetoothCodecStatus other = (BluetoothCodecStatus)o; return (Objects.equals(other.mCodecConfig, mCodecConfig) && Objects.equals(other.mCodecsLocalCapabilities, mCodecsLocalCapabilities) && Objects.equals(other.mCodecsSelectableCapabilities, mCodecsSelectableCapabilities)); } return false; } @Override public int hashCode() { return Objects.hash(mCodecConfig, mCodecsLocalCapabilities, mCodecsLocalCapabilities); } @Override public String toString() { return "{mCodecConfig:" + mCodecConfig + ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities) + ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities) + "}"; } public int describeContents() { return 0; } public static final Parcelable.Creator<BluetoothCodecStatus> CREATOR = new Parcelable.Creator<BluetoothCodecStatus>() { public BluetoothCodecStatus createFromParcel(Parcel in) { final BluetoothCodecConfig codecConfig = in.readTypedObject(BluetoothCodecConfig.CREATOR); final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR); final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR); return new BluetoothCodecStatus(codecConfig, codecsLocalCapabilities, codecsSelectableCapabilities); } public BluetoothCodecStatus[] newArray(int size) { return new BluetoothCodecStatus[size]; } }; public void writeToParcel(Parcel out, int flags) { out.writeTypedObject(mCodecConfig, 0); out.writeTypedArray(mCodecsLocalCapabilities, 0); out.writeTypedArray(mCodecsSelectableCapabilities, 0); } /** * Gets the current codec configuration. * * @return the current codec configuration */ public BluetoothCodecConfig getCodecConfig() { return mCodecConfig; } /** * Gets the codecs local capabilities. * * @return an array with the codecs local capabilities */ public BluetoothCodecConfig[] getCodecsLocalCapabilities() { return mCodecsLocalCapabilities; } /** * Gets the codecs selectable capabilities. * * @return an array with the codecs selectable capabilities */ public BluetoothCodecConfig[] getCodecsSelectableCapabilities() { return mCodecsSelectableCapabilities; } }
framework/java/android/bluetooth/IBluetoothA2dp.aidl +2 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.bluetooth; package android.bluetooth; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; /** /** Loading @@ -37,6 +38,6 @@ interface IBluetoothA2dp { oneway void adjustAvrcpAbsoluteVolume(int direction); oneway void adjustAvrcpAbsoluteVolume(int direction); oneway void setAvrcpAbsoluteVolume(int volume); oneway void setAvrcpAbsoluteVolume(int volume); boolean isA2dpPlaying(in BluetoothDevice device); boolean isA2dpPlaying(in BluetoothDevice device); BluetoothCodecConfig getCodecConfig(); BluetoothCodecStatus getCodecStatus(); oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig); oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig); } }