Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2dd6f2ee authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Revert^2 "Change CoreStartable @Dependencies to Injected Map"

This reverts commit e152ceab.

Reason for revert: Restore, with proper fix.

Bug: 333758389
Test: CarLauncherTests in Treehugger
Flag: NA
Change-Id: I9bed6217eb4db85bc52210b04952bf463fde2803
parent 2bd7c360
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -33,12 +33,23 @@ import java.io.PrintWriter;
 *  abstract fun bind(impl: FoobarStartable): CoreStartable
 *  </pre>
 *
 * If your CoreStartable depends on different CoreStartables starting before it, use a
 * {@link com.android.systemui.startable.Dependencies} annotation to list out those dependencies.
 * If your CoreStartable depends on different CoreStartables starting before it, you can specify
 * another map binding listing out its dependencies:
 *  <pre>
 *  &#64;Provides
 *  &#64;IntoMap
 *  &#64;Dependencies  // Important! com.android.systemui.startable.Dependencies.
 *  &#64;ClassKey(FoobarStartable::class)
 *  fun providesDeps(): Set&lt;Class&lt;out CoreStartable&gt;&gt; {
 *      return setOf(OtherStartable::class.java)
 *  }
 *  </pre>
 *
 *
 * @see SystemUIApplication#startSystemUserServicesIfNeeded()
 */
public interface CoreStartable extends Dumpable {
    String STARTABLE_DEPENDENCIES = "startable_dependencies";

    /** Main entry point for implementations. Called shortly after SysUI startup. */
    void start();
+9 −10
Original line number Diff line number Diff line
@@ -44,16 +44,15 @@ import com.android.systemui.dagger.SysUIComponent;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.process.ProcessWrapper;
import com.android.systemui.res.R;
import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.NotificationChannels;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringJoiner;
import java.util.TreeMap;

@@ -307,9 +306,9 @@ public class SystemUIApplication extends Application implements
                Map.Entry<Class<?>, Provider<CoreStartable>> entry = queue.removeFirst();

                Class<?> cls = entry.getKey();
                Dependencies dep = cls.getAnnotation(Dependencies.class);
                Class<?>[] deps = (dep == null ? null : dep.value());
                if (deps == null || startedStartables.containsAll(Arrays.asList(deps))) {
                Set<Class<? extends CoreStartable>> deps =
                        mSysUIComponent.getStartableDependencies().get(cls);
                if (deps == null || startedStartables.containsAll(deps)) {
                    String clsName = cls.getName();
                    int i = serviceIndex;  // Copied to make lambda happy.
                    timeInitialization(
@@ -331,12 +330,12 @@ public class SystemUIApplication extends Application implements
            while (!nextQueue.isEmpty()) {
                Map.Entry<Class<?>, Provider<CoreStartable>> entry = nextQueue.removeFirst();
                Class<?> cls = entry.getKey();
                Dependencies dep = cls.getAnnotation(Dependencies.class);
                Class<?>[] deps = (dep == null ? null : dep.value());
                Set<Class<? extends CoreStartable>> deps =
                        mSysUIComponent.getStartableDependencies().get(cls);
                StringJoiner stringJoiner = new StringJoiner(", ");
                for (int i = 0; deps != null && i < deps.length; i++) {
                    if (!startedStartables.contains(deps[i])) {
                        stringJoiner.add(deps[i].getName());
                for (Class<? extends CoreStartable> c : deps) {
                    if (!startedStartables.contains(c)) {
                        stringJoiner.add(c.getName());
                    }
                }
                Log.e(TAG, "Failed to start " + cls.getName()
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.dagger.qualifiers.PerUser;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.people.PeopleProvider;
import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -47,6 +48,7 @@ import dagger.Subcomponent;

import java.util.Map;
import java.util.Optional;
import java.util.Set;

import javax.inject.Provider;

@@ -159,6 +161,11 @@ public interface SysUIComponent {
     */
    @PerUser Map<Class<?>, Provider<CoreStartable>> getPerUserStartables();

    /**
     * Returns {@link CoreStartable} dependencies if there are any.
     */
    @Dependencies Map<Class<?>, Set<Class<? extends CoreStartable>>> getStartableDependencies();

    /**
     * Member injection into the supplied argument.
     */
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.BootCompleteCache;
import com.android.systemui.BootCompleteCacheImpl;
import com.android.systemui.CameraProtectionModule;
import com.android.systemui.CoreStartable;
import com.android.systemui.SystemUISecondaryUserService;
import com.android.systemui.accessibility.AccessibilityModule;
import com.android.systemui.accessibility.data.repository.AccessibilityRepositoryModule;
@@ -105,6 +106,7 @@ import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolatorImpl;
import com.android.systemui.shared.condition.Monitor;
import com.android.systemui.smartspace.dagger.SmartspaceModule;
import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
@@ -162,11 +164,14 @@ import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
import dagger.multibindings.Multibinds;

import kotlinx.coroutines.CoroutineScope;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;

import javax.inject.Named;
@@ -270,6 +275,10 @@ import javax.inject.Named;
        })
public abstract class SystemUIModule {

    @Multibinds
    @Dependencies
    abstract Map<Class<?>, Set<Class<? extends CoreStartable>>> startableDependencyMap();

    @Binds
    abstract BootCompleteCache bindBootCompleteCache(BootCompleteCacheImpl bootCompleteCache);

+3 −5
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@
package com.android.systemui.startable

import com.android.systemui.CoreStartable
import kotlin.reflect.KClass
import java.lang.annotation.Documented
import javax.inject.Qualifier

/**
 * Allows a [CoreStartable] to declare that it must be started after its dependencies.
@@ -24,7 +25,4 @@ import kotlin.reflect.KClass
 * This creates a partial, topological ordering. See [com.android.systemui.SystemUIApplication] for
 * how this ordering is enforced at runtime.
 */
@MustBeDocumented
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class Dependencies(vararg val value: KClass<*> = [])
@Qualifier @Documented @Retention(AnnotationRetention.RUNTIME) annotation class Dependencies()
Loading