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

Commit 95b246d1 authored by Xiaotong Jia's avatar Xiaotong Jia Committed by Android (Google) Code Review
Browse files

Merge "Add implementation of handle external messages from wired headset, dock...

Merge "Add implementation of handle external messages from wired headset, dock and speaker, mute toggle and focus switching." into main
parents 49727b3b 2d783dcc
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -82,13 +82,9 @@ public class AudioRoute {
                }
            }
            if (routeInfo == null) {
                CompletableFuture<Boolean> future = new CompletableFuture<>();
                mScheduledExecutorService.schedule(new Runnable() {
                    @Override
                    public void run() {
                        createRetry(type, bluetoothAddress, audioManager, retryCount - 1);
                    }
                }, RETRY_TIME_DELAY, TimeUnit.MILLISECONDS);
                mScheduledExecutorService.schedule(
                        () -> createRetry(type, bluetoothAddress, audioManager, retryCount - 1),
                        RETRY_TIME_DELAY, TimeUnit.MILLISECONDS);
            } else {
                mAudioRouteFuture.complete(new AudioRoute(type, bluetoothAddress, routeInfo));
            }
@@ -105,6 +101,7 @@ public class AudioRoute {
    public static final int TYPE_BLUETOOTH_SCO = 5;
    public static final int TYPE_BLUETOOTH_HA = 6;
    public static final int TYPE_BLUETOOTH_LE = 7;
    public static final int TYPE_STREAMING = 8;
    @IntDef(prefix = "TYPE", value = {
            TYPE_INVALID,
            TYPE_EARPIECE,
@@ -113,7 +110,8 @@ public class AudioRoute {
            TYPE_DOCK,
            TYPE_BLUETOOTH_SCO,
            TYPE_BLUETOOTH_HA,
            TYPE_BLUETOOTH_LE
            TYPE_BLUETOOTH_LE,
            TYPE_STREAMING
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AudioRouteType {}
@@ -145,6 +143,7 @@ public class AudioRoute {
        DEVICE_TYPE_STRINGS.put(TYPE_BLUETOOTH_SCO, "TYPE_BLUETOOTH_SCO");
        DEVICE_TYPE_STRINGS.put(TYPE_BLUETOOTH_HA, "TYPE_BLUETOOTH_HA");
        DEVICE_TYPE_STRINGS.put(TYPE_BLUETOOTH_LE, "TYPE_BLUETOOTH_LE");
        DEVICE_TYPE_STRINGS.put(TYPE_STREAMING, "TYPE_STREAMING");
    }

    public static final HashMap<Integer, Integer> DEVICE_INFO_TYPETO_AUDIO_ROUTE_TYPE;
@@ -225,6 +224,7 @@ public class AudioRoute {
    void onDestRouteAsPendingRoute(boolean active, PendingAudioRoute pendingAudioRoute,
                                   AudioManager audioManager) {
        if (pendingAudioRoute.isActive() && !active) {
            Log.i(this, "clearCommunicationDevice");
            audioManager.clearCommunicationDevice();
        } else if (active) {
            if (mAudioRouteType == TYPE_BLUETOOTH_SCO) {
+3 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ public interface CallAudioRouteAdapter {
        put(SPEAKER_ON, "SPEAKER_ON");
        put(SPEAKER_OFF, "SPEAKER_OFF");

        put(STREAMING_FORCE_ENABLED, "STREAMING_FORCE_ENABLED");
        put(STREAMING_FORCE_DISABLED, "STREAMING_FORCE_DISABLED");

        put(USER_SWITCH_EARPIECE, "USER_SWITCH_EARPIECE");
        put(USER_SWITCH_BLUETOOTH, "USER_SWITCH_BLUETOOTH");
        put(USER_SWITCH_HEADSET, "USER_SWITCH_HEADSET");
+498 −74

File changed.

Preview size limit exceeded, changes collapsed.

+7 −2
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import android.widget.Button;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IntentForwarderActivity;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.telecom.bluetooth.BluetoothDeviceManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
import com.android.server.telecom.bluetooth.BluetoothStateReceiver;
import com.android.server.telecom.callfiltering.BlockCheckerAdapter;
@@ -607,6 +608,7 @@ public class CallsManager extends Call.ListenerBase
            EmergencyCallDiagnosticLogger emergencyCallDiagnosticLogger,
            CallAudioCommunicationDeviceTracker communicationDeviceTracker,
            CallStreamingNotification callStreamingNotification,
            BluetoothDeviceManager bluetoothDeviceManager,
            FeatureFlags featureFlags,
            IncomingCallFilterGraphProvider incomingCallFilterGraphProvider) {

@@ -632,6 +634,9 @@ public class CallsManager extends Call.ListenerBase
        mDtmfLocalTonePlayer =
                new DtmfLocalTonePlayer(new DtmfLocalTonePlayer.ToneGeneratorProxy());
        CallAudioRouteAdapter callAudioRouteAdapter;
        // TODO: add another flag check when
        // bluetoothDeviceManager.getBluetoothHeadset().isScoManagedByAudio()
        // available and return true
        if (!featureFlags.useRefactoredAudioRouteSwitching()) {
            callAudioRouteAdapter = callAudioRouteStateMachineFactory.create(
                    context,
@@ -646,8 +651,8 @@ public class CallsManager extends Call.ListenerBase
                    featureFlags
            );
        } else {
            callAudioRouteAdapter = new CallAudioRouteController(
                    context, this, new AudioRoute.Factory(), wiredHeadsetManager);
            callAudioRouteAdapter = new CallAudioRouteController(context, this, audioServiceFactory,
                    new AudioRoute.Factory(), wiredHeadsetManager, mBluetoothRouteManager);
        }
        callAudioRouteAdapter.initialize();
        bluetoothStateReceiver.setCallAudioRouteAdapter(callAudioRouteAdapter);
+1 −3
Original line number Diff line number Diff line
@@ -76,9 +76,7 @@ public class PendingAudioRoute {
    public void onMessageReceived(int message) {
        if (message == PENDING_ROUTE_FAILED) {
            // Fallback to base route
            //TODO: Replace getPreferredAudioRouteFromDefault by getBaseRoute when available and
            // make the replaced one private
            mDestRoute = mCallAudioRouteController.getPreferredAudioRouteFromDefault(true);
            mDestRoute = mCallAudioRouteController.getBaseRoute(true);
            mCallAudioRouteController.sendMessageWithSessionInfo(
                    CallAudioRouteAdapter.EXIT_PENDING_ROUTE);
        }
Loading