Remove config_additionalSystemUIServiceComponents

Also removes @AdditionaStartable and its associated logic.

Bug: 205725937
Test: manual
Change-Id: I1ba01928b19313e71060d4e4de22b62c8f20207f
This commit is contained in:
Dave Mankoff
2022-01-21 16:45:08 -05:00
parent f727dbbd9e
commit 65c67aa089
9 changed files with 21 additions and 108 deletions

View File

@@ -292,12 +292,6 @@
<!-- SystemUIFactory component -->
<string name="config_systemUIFactoryComponent" translatable="false">com.android.systemui.SystemUIFactory</string>
<!-- SystemUI Services: The classes of the additional stuff to start. Services here are
specified as an overlay to provide configuration-specific services that
supplement those listed in config_systemUIServiceComponents. -->
<string-array name="config_additionalSystemUIServiceComponents" translatable="false">
</string-array>
<!-- QS tile shape store width. negative implies fill configuration instead of stroke-->
<dimen name="config_qsTileStrokeWidthActive">-1dp</dimen>
<dimen name="config_qsTileStrokeWidthInactive">-1dp</dimen>

View File

@@ -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<Class<?>, Provider<CoreStartable>> 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

View File

@@ -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);
}
/**

View File

@@ -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);
}

View File

@@ -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<Class<?>, Provider<Activity>> mActivityCreators;
private final Map<Class<?>, Provider<Service>> mServiceCreators;
private final Map<Class<?>, Provider<CoreStartable>> mAdditionalStartableCreators;
private final Map<Class<?>, Provider<RecentsImplementation>> mRecentsCreators;
private final Map<Class<?>, Provider<BroadcastReceiver>> mBroadcastReceiverCreators;
@Inject
ContextComponentResolver(Map<Class<?>, Provider<Activity>> activityCreators,
Map<Class<?>, Provider<Service>> serviceCreators,
Map<Class<?>, Provider<CoreStartable>> startableCreators,
@AdditionalStartable Map<Class<?>, Provider<CoreStartable>> additionalStartableCreators,
Map<Class<?>, Provider<RecentsImplementation>> recentsCreators,
Map<Class<?>, Provider<BroadcastReceiver>> 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> T resolve(String className, Map<Class<?>, Provider<T>> creators) {
try {
Class<?> clazz = Class.forName(className);

View File

@@ -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
}

View File

@@ -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 {
}

View File

@@ -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<String> = startables.keys.stream()
.map({ cls -> cls!!.simpleName })
.toArray() as Array<String>
val additionalServices = context.resources.getStringArray(
R.array.config_additionalSystemUIServiceComponents)
dumpServiceList(pw, "global", services + additionalServices)
val services: MutableList<String> = 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)
}

View File

@@ -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<Class<*>, CoreStartable>
/** Inject into GlobalActionsComponent. */
@Binds
@IntoMap