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

Commit 8552807a authored by Dave Mankoff's avatar Dave Mankoff
Browse files

5/N Reduce number of accessors of root component.

Ensure that only the code that actually needs the root component asks
for it.

This also fixes ContentProvider injection (a bit). They no longer have
to manually run injection on themselves, as long as they implement
SystemUIAppComponentFactory.ContextInitializer properly and define
an inject(MyClass) method in the root component.

Bug: 162923491
Test: manual && atest SystemUITests
Change-Id: I507859f5f8d89bdde5b10e78b54c5cfbf28737bc
parent 4f548215
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
-keep class com.android.systemui.CarSystemUIFactory
-keep class com.android.car.notification.headsup.animationhelper.**

-keep class com.android.systemui.CarGlobalRootComponent { *; }

-include ../SystemUI/proguard.flags
+3 −1
Original line number Diff line number Diff line
@@ -42,3 +42,5 @@
}

-keep class com.android.wm.shell.*

-keep class com.android.systemui.dagger.GlobalRootComponent { *; }
 No newline at end of file
+15 −2
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@ import androidx.annotation.Nullable;
import androidx.core.app.AppComponentFactory;

import com.android.systemui.dagger.ContextComponentHelper;
import com.android.systemui.dagger.GlobalRootComponent;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.inject.Inject;

@@ -81,8 +85,17 @@ public class SystemUIAppComponentFactory extends AppComponentFactory {
            ((ContextInitializer) contentProvider).setContextAvailableCallback(
                    context -> {
                        SystemUIFactory.createFromConfig(context);
                        SystemUIFactory.getInstance().getRootComponent().inject(
                                contentProvider);
                        GlobalRootComponent rootComponent =
                                SystemUIFactory.getInstance().getRootComponent();
                        try {
                            Method injectMethod = rootComponent.getClass()
                                    .getMethod("inject", contentProvider.getClass());
                            injectMethod.invoke(rootComponent, contentProvider);
                        } catch (NoSuchMethodException
                                | IllegalAccessException
                                | InvocationTargetException e) {
                            // no-op
                        }
                    }
            );
        }
+0 −23
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.systemui.dagger;

import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;

import android.content.ContentProvider;
import android.content.Context;

import com.android.systemui.BootCompleteCacheImpl;
@@ -26,14 +23,12 @@ import com.android.systemui.Dependency;
import com.android.systemui.InitController;
import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.onehanded.dagger.OneHandedModule;
import com.android.systemui.pip.phone.dagger.PipModule;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.InjectionInflationController;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.BindsInstance;
@@ -106,13 +101,6 @@ public interface GlobalRootComponent {
    @Singleton
    DumpManager createDumpManager();

    /**
     * FragmentCreator generates all Fragments that need injection.
     */
    @Singleton
    FragmentService.FragmentCreator createFragmentCreator();


    /**
     * Creates a InitController.
     */
@@ -124,22 +112,11 @@ public interface GlobalRootComponent {
     */
    InjectionInflationController.ViewInstanceCreator.Factory createViewInstanceCreatorFactory();

    /**
     * Whether notification long press is allowed.
     */
    @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
    boolean allowNotificationLongPressName();

    /**
     * Member injection into the supplied argument.
     */
    void inject(SystemUIAppComponentFactory factory);

    /**
     * Member injection into the supplied argument.
     */
    void inject(ContentProvider contentProvider);

    /**
     * Member injection into the supplied argument.
     */
+3 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.BootCompleteCacheImpl;
import com.android.systemui.assist.AssistModule;
import com.android.systemui.doze.dagger.DozeComponent;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -74,7 +75,8 @@ import dagger.Provides;
                NotificationRowComponent.class,
                DozeComponent.class,
                ExpandableNotificationRowComponent.class,
                NotificationShelfComponent.class})
                NotificationShelfComponent.class,
                FragmentService.FragmentCreator.class})
public abstract class SystemUIModule {

    @Binds
Loading