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

Commit d55cee19 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add new internal API: enableOptionalCodecs()/disableOptionalCodecs()"

parents 9c63d28a 6319d47c
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -610,6 +610,51 @@ public final class BluetoothA2dp implements BluetoothProfile {
        }
    }

    /**
     * Enables the optional codecs.
     *
     * @hide
     */
    public void enableOptionalCodecs() {
        if (DBG) Log.d(TAG, "enableOptionalCodecs");
        enableDisableOptionalCodecs(true);
    }

    /**
     * Disables the optional codecs.
     *
     * @hide
     */
    public void disableOptionalCodecs() {
        if (DBG) Log.d(TAG, "disableOptionalCodecs");
        enableDisableOptionalCodecs(false);
    }

    /**
     * Enables or disables the optional codecs.
     *
     * @param enable if true, enable the optional codecs, other disable them
     */
    private void enableDisableOptionalCodecs(boolean enable) {
        try {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled()) {
                if (enable) {
                    mService.enableOptionalCodecs();
                } else {
                    mService.disableOptionalCodecs();
                }
            }
            if (mService == null) Log.w(TAG, "Proxy not attached to service");
            return;
        } catch (RemoteException e) {
            Log.e(TAG, "Error talking to BT service in enableDisableOptionalCodecs()", e);
            return;
        } finally {
            mServiceLock.readLock().unlock();
        }
    }

    /**
     * Helper for converting a state to a string.
     *
+21 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public final class BluetoothCodecConfig implements Parcelable {
    public static final int CHANNEL_MODE_STEREO = 0x1 << 1;

    private final int mCodecType;
    private final int mCodecPriority;
    private int mCodecPriority;
    private final int mSampleRate;
    private final int mBitsPerSample;
    private final int mChannelMode;
@@ -279,6 +279,15 @@ public final class BluetoothCodecConfig implements Parcelable {
        return mCodecType;
    }

    /**
     * Checks whether the codec is mandatory.
     *
     * @return true if the codec is mandatory, otherwise false.
     */
    public boolean isMandatoryCodec() {
        return mCodecType == SOURCE_CODEC_TYPE_SBC;
    }

    /**
     * Gets the codec selection priority.
     * The codec selection priority is relative to other codecs: larger value
@@ -290,6 +299,17 @@ public final class BluetoothCodecConfig implements Parcelable {
        return mCodecPriority;
    }

    /**
     * Sets the codec selection priority.
     * The codec selection priority is relative to other codecs: larger value
     * means higher priority. If 0, reset to default.
     *
     * @param codecPriority the codec priority
     */
    public void setCodecPriority(int codecPriority) {
        mCodecPriority = codecPriority;
    }

    /**
     * Gets the codec sample rate. The value can be a bitmask with all
     * supported sample rates:
+2 −0
Original line number Diff line number Diff line
@@ -40,4 +40,6 @@ interface IBluetoothA2dp {
    boolean isA2dpPlaying(in BluetoothDevice device);
    BluetoothCodecStatus getCodecStatus();
    oneway void setCodecConfigPreference(in BluetoothCodecConfig codecConfig);
    oneway void enableOptionalCodecs();
    oneway void disableOptionalCodecs();
}