Split ConfigurationController and ConfigurationForwarder
This will enable to create several ConfigurationForwarder(s) to propagate config changes from different sources (e.g. different windows/displays), and avoid injecting ConfigurationController for cases where we only need to propagate the config to other classes.
Bug: 374266535
Test: Compilation - trivial interface split
Flag: NONE trivial interface split
Change-Id: I30e409bbba3913e24bbf528051527565d24a056c
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
index 8ae11ab..811b47d 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -43,7 +43,7 @@
import com.android.systemui.dump.DumpManager;
import com.android.systemui.process.ProcessWrapper;
import com.android.systemui.res.R;
-import com.android.systemui.statusbar.policy.ConfigurationController;
+import com.android.systemui.statusbar.phone.ConfigurationForwarder;
import com.android.systemui.util.NotificationChannels;
import java.lang.reflect.InvocationTargetException;
@@ -454,13 +454,13 @@
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
if (mServicesStarted) {
- ConfigurationController configController = mSysUIComponent.getConfigurationController();
+ ConfigurationForwarder configForwarder = mSysUIComponent.getConfigurationForwarder();
if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP,
- configController.getClass().getSimpleName() + ".onConfigurationChanged()");
+ configForwarder.getClass().getSimpleName() + ".onConfigurationChanged()");
}
- configController.onConfigurationChanged(newConfig);
+ configForwarder.onConfigurationChanged(newConfig);
Trace.endSection();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
index 3fe6669..17f1961 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
@@ -29,6 +29,7 @@
import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule;
+import com.android.systemui.statusbar.phone.ConfigurationForwarder;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.wm.shell.back.BackAnimation;
import com.android.wm.shell.bubbles.Bubbles;
@@ -125,13 +126,20 @@
BootCompleteCacheImpl provideBootCacheImpl();
/**
- * Creates a ContextComponentHelper.
+ * Creates a ConfigurationController.
*/
@SysUISingleton
@GlobalConfig
ConfigurationController getConfigurationController();
/**
+ * Creates a ConfigurationForwarder.
+ */
+ @SysUISingleton
+ @GlobalConfig
+ ConfigurationForwarder getConfigurationForwarder();
+
+ /**
* Creates a ContextComponentHelper.
*/
@SysUISingleton
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationForwarder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationForwarder.kt
new file mode 100644
index 0000000..3fd46fc
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationForwarder.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.phone
+
+import android.content.res.Configuration
+
+/**
+ * Used to forward a configuration change to other components.
+ *
+ * This is commonly used to propagate configs to [ConfigurationController]. Note that there could be
+ * different configuration forwarder, for example each display, window or group of classes (e.g.
+ * shade window classes).
+ */
+interface ConfigurationForwarder {
+ /** Should be called when a new configuration is received. */
+ fun onConfigurationChanged(newConfiguration: Configuration)
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java
index cec77c1..1bb4e8c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java
@@ -16,16 +16,15 @@
import android.content.res.Configuration;
+import com.android.systemui.statusbar.phone.ConfigurationForwarder;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
/**
* Common listener for configuration or subsets of configuration changes (like density or
* font scaling), providing easy static dependence on these events.
*/
-public interface ConfigurationController extends CallbackController<ConfigurationListener> {
-
- /** Alert controller of a change in the configuration. */
- void onConfigurationChanged(Configuration newConfiguration);
+public interface ConfigurationController extends CallbackController<ConfigurationListener>,
+ ConfigurationForwarder {
/** Alert controller of a change in between light and dark themes. */
void notifyThemeChanged();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
index b81af86..c7bd5a1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
@@ -37,6 +37,7 @@
import com.android.systemui.statusbar.connectivity.NetworkControllerImpl;
import com.android.systemui.statusbar.connectivity.WifiPickerTrackerFactory;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
+import com.android.systemui.statusbar.phone.ConfigurationForwarder;
import com.android.systemui.statusbar.policy.BatteryControllerLogger;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
@@ -186,6 +187,13 @@
DevicePostureControllerImpl devicePostureControllerImpl);
/** */
+ @Binds
+ @SysUISingleton
+ @GlobalConfig
+ ConfigurationForwarder provideGlobalConfigurationForwarder(
+ @GlobalConfig ConfigurationController configurationController);
+
+ /** */
@Provides
@SysUISingleton
@GlobalConfig
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/policy/FakeConfigurationController.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/policy/FakeConfigurationController.kt
index 6be13be..3219127 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/policy/FakeConfigurationController.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/policy/FakeConfigurationController.kt
@@ -23,7 +23,7 @@
listeners -= listener
}
- override fun onConfigurationChanged(newConfiguration: Configuration?) {
+ override fun onConfigurationChanged(newConfiguration: Configuration) {
listeners.forEach { it.onConfigChanged(newConfiguration) }
}
@@ -36,7 +36,7 @@
}
fun notifyConfigurationChanged() {
- onConfigurationChanged(newConfiguration = null)
+ onConfigurationChanged(newConfiguration = Configuration())
}
fun notifyLayoutDirectionChanged(isRtl: Boolean) {