From 8277c314ca4b6dfa1363b245776394c357e95009 Mon Sep 17 00:00:00 2001 From: Heemin Seog Date: Mon, 27 Apr 2020 10:12:14 -0700 Subject: Make SystemUI config extendable Bug: 155085702 Test: manual Change-Id: I22e9ecb01993f0dd7be47c10071223bc5348f014 --- packages/CarSystemUI/res/values/config.xml | 45 +++++++++------------- .../com/android/systemui/CarSystemUIFactory.java | 26 +++++++++++++ .../com/android/systemui/SystemUIApplication.java | 6 +-- .../src/com/android/systemui/SystemUIFactory.java | 11 ++++++ 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/packages/CarSystemUI/res/values/config.xml b/packages/CarSystemUI/res/values/config.xml index 050db3218a1d..67066d7c426f 100644 --- a/packages/CarSystemUI/res/values/config.xml +++ b/packages/CarSystemUI/res/values/config.xml @@ -92,35 +92,28 @@ com.android.vending - - - com.android.systemui.util.NotificationChannels - com.android.systemui.keyguard.KeyguardViewMediator - - - - - com.android.systemui.usb.StorageNotification - com.android.systemui.power.PowerUI - com.android.systemui.media.RingtonePlayer - - - - @string/config_systemUIVendorServiceComponent - com.android.systemui.util.leak.GarbageMonitor$Service - - - com.android.systemui.ScreenDecorations - com.android.systemui.biometrics.AuthController - - com.android.systemui.SizeCompatModeActivityController - - com.android.systemui.theme.ThemeOverlayController - com.android.systemui.toast.ToastUI + + + com.android.systemui.recents.Recents + com.android.systemui.volume.VolumeUI + com.android.systemui.stackdivider.Divider + com.android.systemui.statusbar.phone.StatusBar + com.android.systemui.keyboard.KeyboardUI + com.android.systemui.pip.PipUI + com.android.systemui.shortcut.ShortcutKeyDispatcher + com.android.systemui.LatencyTester + com.android.systemui.globalactions.GlobalActionsComponent + com.android.systemui.SliceBroadcastRelayHandler + com.android.systemui.statusbar.notification.InstantAppNotifier + com.android.systemui.accessibility.WindowMagnification + com.android.systemui.accessibility.SystemActions + + + + com.android.systemui.car.navigationbar.CarNavigationBar com.android.systemui.car.voicerecognition.ConnectedDeviceVoiceRecognitionNotifier com.android.systemui.car.window.SystemUIOverlayWindowManager com.android.systemui.car.volume.VolumeUI - com.android.systemui.car.sideloaded.SideLoadedAppController diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java index 2bd5fe228f41..1a1b93b33caf 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java @@ -17,9 +17,13 @@ package com.android.systemui; import android.content.Context; +import android.content.res.Resources; import com.android.systemui.dagger.SystemUIRootComponent; +import java.util.HashSet; +import java.util.Set; + /** * Class factory to provide car specific SystemUI components. */ @@ -31,4 +35,26 @@ public class CarSystemUIFactory extends SystemUIFactory { .contextHolder(new ContextHolder(context)) .build(); } + + @Override + public String[] getSystemUIServiceComponents(Resources resources) { + Set names = new HashSet<>(); + + for (String s : super.getSystemUIServiceComponents(resources)) { + names.add(s); + } + + for (String s : resources.getStringArray(R.array.config_systemUIServiceComponentsExclude)) { + names.remove(s); + } + + for (String s : resources.getStringArray(R.array.config_systemUIServiceComponentsInclude)) { + names.add(s); + } + + String[] finalNames = new String[names.size()]; + names.toArray(finalNames); + + return finalNames; + } } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index cbdae4e6fe63..c84701c9512e 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -139,7 +139,7 @@ public class SystemUIApplication extends Application implements */ public void startServicesIfNeeded() { - String[] names = getResources().getStringArray(R.array.config_systemUIServiceComponents); + String[] names = SystemUIFactory.getInstance().getSystemUIServiceComponents(getResources()); startServicesIfNeeded(/* metricsPrefix= */ "StartServices", names); } @@ -150,8 +150,8 @@ public class SystemUIApplication extends Application implements *

This method must only be called from the main thread.

*/ void startSecondaryUserServicesIfNeeded() { - String[] names = - getResources().getStringArray(R.array.config_systemUIServiceComponentsPerUser); + String[] names = SystemUIFactory.getInstance().getSystemUIServiceComponentsPerUser( + getResources()); startServicesIfNeeded(/* metricsPrefix= */ "StartSecondaryServices", names); } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index fb40774a1f5c..be82a2d5325b 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -18,6 +18,7 @@ package com.android.systemui; import android.annotation.NonNull; import android.content.Context; +import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import android.util.Log; @@ -120,6 +121,16 @@ public class SystemUIFactory { return mRootComponent; } + /** Returns the list of system UI components that should be started. */ + public String[] getSystemUIServiceComponents(Resources resources) { + return resources.getStringArray(R.array.config_systemUIServiceComponents); + } + + /** Returns the list of system UI components that should be started per user. */ + public String[] getSystemUIServiceComponentsPerUser(Resources resources) { + return resources.getStringArray(R.array.config_systemUIServiceComponentsPerUser); + } + /** * Creates an instance of ScreenshotNotificationSmartActionsProvider. * This method is overridden in vendor specific implementation of Sys UI. -- cgit v1.2.3-59-g8ed1b