From 65c67aa0896dd2966a8cbf7bad899715c0665028 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Fri, 21 Jan 2022 16:45:08 -0500 Subject: [PATCH] Remove config_additionalSystemUIServiceComponents Also removes @AdditionaStartable and its associated logic. Bug: 205725937 Test: manual Change-Id: I1ba01928b19313e71060d4e4de22b62c8f20207f --- packages/SystemUI/res/values/config.xml | 6 ---- .../android/systemui/SystemUIApplication.java | 32 ++++++++----------- .../com/android/systemui/SystemUIFactory.java | 13 ++------ .../dagger/ContextComponentHelper.java | 4 --- .../dagger/ContextComponentResolver.java | 14 -------- .../dagger/SystemUICoreStartableModule.kt | 11 ------- .../qualifiers/AdditionalStartable.java | 30 ----------------- .../com/android/systemui/dump/DumpHandler.kt | 12 +++---- .../tv/TVSystemUICoreStartableModule.kt | 7 ---- 9 files changed, 21 insertions(+), 108 deletions(-) diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 34751d8fcf903..bb1ffa8fec386 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -292,12 +292,6 @@ com.android.systemui.SystemUIFactory - - - - -1dp -1dp diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 3026ae87ad3ab..23ca923957b6e 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -184,8 +184,8 @@ public class SystemUIApplication extends Application implements */ public void startServicesIfNeeded() { - final String[] additionalNames = SystemUIFactory.getInstance() - .getAdditionalSystemUIServiceComponents(getResources()); + final String vendorComponent = SystemUIFactory.getInstance() + .getVendorComponent(getResources()); // Sort the startables so that we get a deterministic ordering. // TODO: make #start idempotent and require users of CoreStartable to call it. @@ -193,7 +193,7 @@ public class SystemUIApplication extends Application implements Comparator.comparing(Class::getName)); sortedStartables.putAll(SystemUIFactory.getInstance().getStartableComponents()); startServicesIfNeeded( - sortedStartables, "StartServices", additionalNames); + sortedStartables, "StartServices", vendorComponent); } /** @@ -208,17 +208,17 @@ public class SystemUIApplication extends Application implements Comparator.comparing(Class::getName)); sortedStartables.putAll(SystemUIFactory.getInstance().getStartableComponentsPerUser()); startServicesIfNeeded( - sortedStartables, "StartSecondaryServices", new String[]{}); + sortedStartables, "StartSecondaryServices", null); } private void startServicesIfNeeded( Map, Provider> startables, String metricsPrefix, - String[] services) { + String vendorComponent) { if (mServicesStarted) { return; } - mServices = new CoreStartable[startables.size() + services.length]; + mServices = new CoreStartable[startables.size() + (vendorComponent == null ? 0 : 1)]; if (!mBootCompleteCache.isBootComplete()) { // check to see if maybe it was already completed long before we began @@ -251,14 +251,11 @@ public class SystemUIApplication extends Application implements i++; } - // Loop over any "additional" startables that are defined in an xml overlay. - final int N = services.length; - for (i = 0; i < N; i++) { - int j = i; // Copied to make lambda happy. - String clsName = services[i]; + if (vendorComponent != null) { timeInitialization( - clsName, - () -> mServices[j + startables.size()] = startAdditionalStartable(clsName), + vendorComponent, + () -> mServices[mServices.length - 1] = + startAdditionalStartable(vendorComponent), log, metricsPrefix); } @@ -294,12 +291,9 @@ public class SystemUIApplication extends Application implements CoreStartable startable; if (DEBUG) Log.d(TAG, "loading: " + clsName); try { - startable = mComponentHelper.resolveAdditionalCoreStartable(clsName); - if (startable == null) { - Constructor constructor = Class.forName(clsName).getConstructor( - Context.class); - startable = (CoreStartable) constructor.newInstance(this); - } + Constructor constructor = Class.forName(clsName).getConstructor( + Context.class); + startable = (CoreStartable) constructor.newInstance(this); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index 582ec2d14d5b2..11fffd053143e 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -32,7 +32,6 @@ import com.android.systemui.navigationbar.gestural.BackGestureTfClassifierProvid import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider; import com.android.wm.shell.transition.ShellTransitions; -import java.util.Arrays; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; @@ -203,16 +202,8 @@ public class SystemUIFactory { /** * Returns the list of additional system UI components that should be started. */ - public String[] getAdditionalSystemUIServiceComponents(Resources resources) { - String[] results = resources.getStringArray( - R.array.config_additionalSystemUIServiceComponents); - String vendorComponent = resources.getString( - R.string.config_systemUIVendorServiceComponent); - - results = Arrays.copyOf(results, results.length + 1); - results[results.length - 1] = vendorComponent; - - return results; + public String getVendorComponent(Resources resources) { + return resources.getString(R.string.config_systemUIVendorServiceComponent); } /** diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentHelper.java b/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentHelper.java index 973f6ca388302..e868d43a6a8e5 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentHelper.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentHelper.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.Service; import android.content.BroadcastReceiver; -import com.android.systemui.CoreStartable; import com.android.systemui.recents.RecentsImplementation; /** @@ -36,9 +35,6 @@ public interface ContextComponentHelper { /** Turns a classname into an instance of the class or returns null. */ Service resolveService(String className); - /** Turns a classname into an instance of the class or returns null. */ - CoreStartable resolveAdditionalCoreStartable(String className); - /** Turns a classname into an instance of the class or returns null. */ BroadcastReceiver resolveBroadcastReceiver(String className); } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentResolver.java b/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentResolver.java index 99481dac7257d..3607e2578bc56 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentResolver.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/ContextComponentResolver.java @@ -20,8 +20,6 @@ import android.app.Activity; import android.app.Service; import android.content.BroadcastReceiver; -import com.android.systemui.CoreStartable; -import com.android.systemui.dagger.qualifiers.AdditionalStartable; import com.android.systemui.recents.RecentsImplementation; import java.util.Map; @@ -36,20 +34,16 @@ import javax.inject.Provider; public class ContextComponentResolver implements ContextComponentHelper { private final Map, Provider> mActivityCreators; private final Map, Provider> mServiceCreators; - private final Map, Provider> mAdditionalStartableCreators; private final Map, Provider> mRecentsCreators; private final Map, Provider> mBroadcastReceiverCreators; @Inject ContextComponentResolver(Map, Provider> activityCreators, Map, Provider> serviceCreators, - Map, Provider> startableCreators, - @AdditionalStartable Map, Provider> additionalStartableCreators, Map, Provider> recentsCreators, Map, Provider> broadcastReceiverCreators) { mActivityCreators = activityCreators; mServiceCreators = serviceCreators; - mAdditionalStartableCreators = additionalStartableCreators; mRecentsCreators = recentsCreators; mBroadcastReceiverCreators = broadcastReceiverCreators; } @@ -86,14 +80,6 @@ public class ContextComponentResolver implements ContextComponentHelper { return resolve(className, mServiceCreators); } - /** - * Looks up the SystemUI class name to see if Dagger has an instance of it. - */ - @Override - public CoreStartable resolveAdditionalCoreStartable(String className) { - return resolve(className, mAdditionalStartableCreators); - } - private T resolve(String className, Map, Provider> creators) { try { Class clazz = Class.forName(className); diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt b/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt index 1fd59ac8403aa..f78929f75b04e 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt @@ -25,9 +25,7 @@ import com.android.systemui.accessibility.SystemActions import com.android.systemui.accessibility.WindowMagnification import com.android.systemui.biometrics.AuthController import com.android.systemui.clipboardoverlay.ClipboardListener -import com.android.systemui.dagger.qualifiers.AdditionalStartable import com.android.systemui.dagger.qualifiers.PerUser -import com.android.systemui.dreams.DreamOverlayRegistrant import com.android.systemui.globalactions.GlobalActionsComponent import com.android.systemui.keyboard.KeyboardUI import com.android.systemui.keyguard.KeyguardViewMediator @@ -200,13 +198,4 @@ abstract class SystemUICoreStartableModule { @IntoMap @ClassKey(WMShell::class) abstract fun bindWMShell(sysui: WMShell): CoreStartable - - /** Inject into DreamOverlay. */ - @Binds - @IntoMap - @ClassKey(DreamOverlayRegistrant::class) - @AdditionalStartable - abstract fun bindDreamOverlayRegistrant( - dreamOverlayRegistrant: DreamOverlayRegistrant - ): CoreStartable } \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/AdditionalStartable.java b/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/AdditionalStartable.java index 9247ce3eabdf8..e69de29bb2d1d 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/AdditionalStartable.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/AdditionalStartable.java @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2019 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.dagger.qualifiers; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Qualifier; - -@Qualifier -@Documented -@Retention(RUNTIME) -public @interface AdditionalStartable { -} diff --git a/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt b/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt index b5c475f1e4b7c..e4a7406687d2b 100644 --- a/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/dump/DumpHandler.kt @@ -176,12 +176,12 @@ class DumpHandler @Inject constructor( pw.println("SystemUiServiceComponents configuration:") pw.print("vendor component: ") pw.println(context.resources.getString(R.string.config_systemUIVendorServiceComponent)) - val services: Array = startables.keys.stream() - .map({ cls -> cls!!.simpleName }) - .toArray() as Array - val additionalServices = context.resources.getStringArray( - R.array.config_additionalSystemUIServiceComponents) - dumpServiceList(pw, "global", services + additionalServices) + val services: MutableList = startables.keys + .map({ cls: Class<*> -> cls.simpleName }) + .toMutableList() + + services.add(context.resources.getString(R.string.config_systemUIVendorServiceComponent)) + dumpServiceList(pw, "global", services.toTypedArray()) dumpServiceList(pw, "per-user", R.array.config_systemUIServiceComponentsPerUser) } diff --git a/packages/SystemUI/src/com/android/systemui/tv/TVSystemUICoreStartableModule.kt b/packages/SystemUI/src/com/android/systemui/tv/TVSystemUICoreStartableModule.kt index 3b20b1bd4f2d9..ad8dc825dbcbb 100644 --- a/packages/SystemUI/src/com/android/systemui/tv/TVSystemUICoreStartableModule.kt +++ b/packages/SystemUI/src/com/android/systemui/tv/TVSystemUICoreStartableModule.kt @@ -19,7 +19,6 @@ package com.android.systemui.tv import com.android.systemui.CoreStartable import com.android.systemui.SliceBroadcastRelayHandler import com.android.systemui.accessibility.WindowMagnification -import com.android.systemui.dagger.qualifiers.AdditionalStartable import com.android.systemui.dagger.qualifiers.PerUser import com.android.systemui.globalactions.GlobalActionsComponent import com.android.systemui.keyboard.KeyboardUI @@ -42,18 +41,12 @@ import dagger.Binds import dagger.Module import dagger.multibindings.ClassKey import dagger.multibindings.IntoMap -import dagger.multibindings.Multibinds /** * Collection of {@link CoreStartable}s that should be run on TV. */ @Module abstract class TVSystemUICoreStartableModule { - /** Ensure that AdditionalStartables exists. */ - @Multibinds - @AdditionalStartable - abstract fun bindEmptyAdditionalStartables(): Map, CoreStartable> - /** Inject into GlobalActionsComponent. */ @Binds @IntoMap