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
This commit is contained in:
@@ -53,7 +53,16 @@ import java.util.Objects;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,10 +44,22 @@ import android.os.ServiceManager;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user