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
diff --git a/services/core/java/com/android/server/media/BluetoothRouteController.java b/services/core/java/com/android/server/media/BluetoothRouteController.java
index d4a1184..66985e0 100644
--- a/services/core/java/com/android/server/media/BluetoothRouteController.java
+++ b/services/core/java/com/android/server/media/BluetoothRouteController.java
@@ -53,7 +53,16 @@
return new NoOpBluetoothRouteController();
}
- return new LegacyBluetoothRouteController(context, btAdapter, listener);
+ 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);
+ }
}
/**
diff --git a/services/core/java/com/android/server/media/DeviceRouteController.java b/services/core/java/com/android/server/media/DeviceRouteController.java
index d7893ee..3875c84 100644
--- a/services/core/java/com/android/server/media/DeviceRouteController.java
+++ b/services/core/java/com/android/server/media/DeviceRouteController.java
@@ -44,10 +44,22 @@
IAudioService audioService = IAudioService.Stub.asInterface(
ServiceManager.getService(Context.AUDIO_SERVICE));
- return new LegacyDeviceRouteController(context,
- audioManager,
- audioService,
- onDeviceRouteChangedListener);
+ 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);
+ }
}
/**
diff --git a/services/core/java/com/android/server/media/MediaFeatureFlagManager.java b/services/core/java/com/android/server/media/MediaFeatureFlagManager.java
index 723cda0..70ee38f 100644
--- a/services/core/java/com/android/server/media/MediaFeatureFlagManager.java
+++ b/services/core/java/com/android/server/media/MediaFeatureFlagManager.java
@@ -32,7 +32,7 @@
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 @@
* '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 @@
// Empty to prevent instantiation.
}
- /* package */ MediaFeatureFlagManager getInstance() {
+ /* package */ static MediaFeatureFlagManager getInstance() {
return sInstance;
}