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

Commit 3e8712f0 authored by Alex Dadukin's avatar Alex Dadukin
Browse files

Add audio policies classes to SystemMediaRoute2Provider

To rollout the changes in controllable and safe way new classes are
hidden using a feature flag.

Bug: b/255495104
Test: manually
Change-Id: Iebe3a61cd5a033266225e46e6bcc31cb3b53bb74
parent f2de79eb
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -53,7 +53,16 @@ import java.util.Objects;
            return new NoOpBluetoothRouteController();
        }

        MediaFeatureFlagManager flagManager = MediaFeatureFlagManager.getInstance();
        boolean isUsingLegacyController = flagManager.getBoolean(
                MediaFeatureFlagManager.FEATURE_AUDIO_STRATEGIES_IS_USING_LEGACY_CONTROLLER,
                true);

        if (isUsingLegacyController) {
            return new LegacyBluetoothRouteController(context, btAdapter, listener);
        } else {
            return new AudioPoliciesBluetoothRouteController(context, btAdapter, listener);
        }
    }

    /**
+16 −4
Original line number Diff line number Diff line
@@ -44,10 +44,22 @@ import android.os.ServiceManager;
        IAudioService audioService = IAudioService.Stub.asInterface(
                ServiceManager.getService(Context.AUDIO_SERVICE));

        MediaFeatureFlagManager flagManager = MediaFeatureFlagManager.getInstance();
        boolean isUsingLegacyController = flagManager.getBoolean(
                MediaFeatureFlagManager.FEATURE_AUDIO_STRATEGIES_IS_USING_LEGACY_CONTROLLER,
                true);

        if (isUsingLegacyController) {
            return new LegacyDeviceRouteController(context,
                    audioManager,
                    audioService,
                    onDeviceRouteChangedListener);
        } else {
            return new AudioPoliciesDeviceRouteController(context,
                    audioManager,
                    audioService,
                    onDeviceRouteChangedListener);
        }
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import java.lang.annotation.Target;
    private static final String NAMESPACE_MEDIA_BETTER_TOGETHER = "media_better_together";

    @StringDef(prefix = "FEATURE_", value = {
        FEATURE_IS_USING_LEGACY_BLUETOOTH_CONTROLLER
            FEATURE_AUDIO_STRATEGIES_IS_USING_LEGACY_CONTROLLER
    })
    @Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
    @Retention(RetentionPolicy.SOURCE)
@@ -43,7 +43,7 @@ import java.lang.annotation.Target;
     * 'Audio Strategies'-aware controller.
     */
    /* package */ static final @MediaFeatureFlag String
            FEATURE_IS_USING_LEGACY_BLUETOOTH_CONTROLLER =
            FEATURE_AUDIO_STRATEGIES_IS_USING_LEGACY_CONTROLLER =
            "BluetoothRouteController__enable_legacy_bluetooth_routes_controller";

    private static final MediaFeatureFlagManager sInstance = new MediaFeatureFlagManager();
@@ -52,7 +52,7 @@ import java.lang.annotation.Target;
        // Empty to prevent instantiation.
    }

    /* package */ MediaFeatureFlagManager getInstance() {
    /* package */ static MediaFeatureFlagManager getInstance() {
        return sInstance;
    }