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

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

Merge changes I2861d51d,Ifcc6971f

* changes:
  BluetoothHeadset APIs now no longer return BluetoothStatusCodes#ERROR_BLUETOOTH_NOT_ENABLED.
  Update BluetoothHeadset#connectAudio and BluetoothHeadset#disconnectAudio to support additional error codes for GTS
parents 20d9d331 fc0cd8b2
Loading
Loading
Loading
Loading
+41 −35
Original line number Diff line number Diff line
@@ -969,7 +969,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(value = {
            BluetoothStatusCodes.SUCCESS,
            BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
            BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
            BluetoothStatusCodes.ERROR_TIMEOUT,
            BluetoothStatusCodes.ERROR_UNKNOWN,
@@ -981,7 +980,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
    @IntDef(value = {
            BluetoothStatusCodes.ALLOWED,
            BluetoothStatusCodes.NOT_ALLOWED,
            BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
            BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
            BluetoothStatusCodes.ERROR_TIMEOUT,
            BluetoothStatusCodes.ERROR_UNKNOWN,
@@ -1014,9 +1012,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
        } else if (!isEnabled()) {
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
        }
        } else if (isEnabled()) {
            try {
                final SynchronousResultReceiver recv = new SynchronousResultReceiver();
                service.setAudioRouteAllowed(allowed, mAttributionSource, recv);
@@ -1029,6 +1025,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                e.rethrowFromSystemServer();
            }
        }

        Log.e(TAG, "setAudioRouteAllowed: Bluetooth disabled, but profile service still bound");
        return BluetoothStatusCodes.ERROR_UNKNOWN;
    }

@@ -1053,9 +1052,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
        } else if (!isEnabled()) {
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
        }
        } else if (isEnabled()) {
            try {
                final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver();
                service.getAudioRouteAllowed(mAttributionSource, recv);
@@ -1068,6 +1065,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                e.rethrowFromSystemServer();
            }
        }

        Log.e(TAG, "getAudioRouteAllowed: Bluetooth disabled, but profile service still bound");
        return BluetoothStatusCodes.ERROR_UNKNOWN;
    }

@@ -1118,11 +1118,11 @@ public final class BluetoothHeadset implements BluetoothProfile {
     * can be identified with {@link BluetoothAdapter#getActiveDevices(int)}.
     * <p>
     * If this function returns {@link BluetoothStatusCodes#SUCCESS}, the intent
     * {@link #ACTION_AUDIO_STATE_CHANGED} will be broadcasted twice. First with {@link #EXTRA_STATE}
     * set to {@link #STATE_AUDIO_CONNECTING}. This will be followed by a broadcast with
     * {@link #EXTRA_STATE} set to either {@link #STATE_AUDIO_CONNECTED} if the audio connection is
     * established or {@link #STATE_AUDIO_DISCONNECTED} if there was a failure in establishing the
     * audio connection.
     * {@link #ACTION_AUDIO_STATE_CHANGED} will be broadcasted twice. First with
     * {@link #EXTRA_STATE} set to {@link #STATE_AUDIO_CONNECTING}. This will be followed by a
     * broadcast with {@link #EXTRA_STATE} set to either {@link #STATE_AUDIO_CONNECTED} if the audio
     * connection is established or {@link #STATE_AUDIO_DISCONNECTED} if there was a failure in
     * establishing the audio connection.
     *
     * @return whether the connection was successfully initiated or an error code on failure
     * @hide
@@ -1140,6 +1140,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
        if (service == null) {
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
        } else if (isEnabled()) {
            try {
                final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver();
@@ -1153,6 +1154,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
                return BluetoothStatusCodes.ERROR_TIMEOUT;
            }
        }

        Log.e(TAG, "connectAudio: Bluetooth disabled, but profile service still bound");
        return defaultValue;
    }

@@ -1192,6 +1195,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
        if (service == null) {
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
        } else if (isEnabled()) {
            try {
                final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver();
@@ -1205,6 +1209,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
                return BluetoothStatusCodes.ERROR_TIMEOUT;
            }
        }

        Log.e(TAG, "disconnectAudio: Bluetooth disabled, but profile service still bound");
        return defaultValue;
    }