Revert^2 "5/N Remove PluginInitializer entirely."

12d8e155ab07d6e97aa0d09dcbe0633a8bd490e5

Change-Id: I9b98d1e218d590f1c753a6c257e61c6f99a8e6d8
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java
index 3275d2d..9ea4b57 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java
@@ -73,7 +73,6 @@
     private final boolean mIsDebuggable;
     private final PackageManager mPm;
     private final Class<T> mPluginClass;
-    private final PluginInitializer mInitializer;
     private final Executor mMainExecutor;
     private final Executor mBgExecutor;
 
@@ -87,13 +86,11 @@
             Executor mainExecutor,
             Executor bgExecutor,
             boolean debuggable,
-            PluginInitializer initializer,
             NotificationManager notificationManager,
             PluginEnabler pluginEnabler,
             List<String> privilegedPlugins,
             PluginInstance.Factory pluginInstanceFactory) {
         mPluginClass = pluginClass;
-        mInitializer = initializer;
         mMainExecutor = mainExecutor;
         mBgExecutor = bgExecutor;
         mContext = context;
@@ -376,21 +373,19 @@
         private final PackageManager mPackageManager;
         private final Executor mMainExecutor;
         private final Executor mBgExecutor;
-        private final PluginInitializer mInitializer;
         private final NotificationManager mNotificationManager;
         private final PluginEnabler mPluginEnabler;
         private final List<String> mPrivilegedPlugins;
         private final PluginInstance.Factory mPluginInstanceFactory;
 
         public Factory(Context context, PackageManager packageManager,
-                Executor mainExecutor, Executor bgExecutor, PluginInitializer initializer,
+                Executor mainExecutor, Executor bgExecutor,
                 NotificationManager notificationManager, PluginEnabler pluginEnabler,
                 List<String> privilegedPlugins, PluginInstance.Factory pluginInstanceFactory) {
             mContext = context;
             mPackageManager = packageManager;
             mMainExecutor = mainExecutor;
             mBgExecutor = bgExecutor;
-            mInitializer = initializer;
             mNotificationManager = notificationManager;
             mPluginEnabler = pluginEnabler;
             mPrivilegedPlugins = privilegedPlugins;
@@ -402,7 +397,7 @@
                 boolean allowMultiple, boolean debuggable) {
             return new PluginActionManager<>(mContext, mPackageManager, action, listener,
                     pluginClass, allowMultiple, mMainExecutor, mBgExecutor,
-                    debuggable, mInitializer, mNotificationManager, mPluginEnabler,
+                    debuggable, mNotificationManager, mPluginEnabler,
                     mPrivilegedPlugins, mPluginInstanceFactory);
         }
     }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java
deleted file mode 100644
index 5890f81..0000000
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInitializer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2018 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.shared.plugins;
-
-/**
- * Provides necessary components for initializing {@link PluginManagerImpl}.
- */
-public interface PluginInitializer {
-}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/PluginModule.java b/packages/SystemUI/src/com/android/systemui/dagger/PluginModule.java
index 406981d..67ad3db 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/PluginModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/PluginModule.java
@@ -24,6 +24,7 @@
 import com.android.systemui.plugins.DarkIconDispatcher;
 import com.android.systemui.plugins.FalsingManager;
 import com.android.systemui.plugins.GlobalActions;
+import com.android.systemui.plugins.PluginDependencyProvider;
 import com.android.systemui.plugins.VolumeDialogController;
 import com.android.systemui.plugins.statusbar.StatusBarStateController;
 import com.android.systemui.statusbar.StatusBarStateControllerImpl;
@@ -32,6 +33,7 @@
 
 import dagger.Binds;
 import dagger.Module;
+import dagger.Provides;
 
 /**
  * Module for binding Plugin implementations.
@@ -39,36 +41,40 @@
  * TODO(b/166258224): Many of these should be moved closer to their implementations.
  */
 @Module
-public interface PluginModule {
+public abstract class PluginModule {
+
+    /** */
+    @Provides
+    static ActivityStarter provideActivityStarter(ActivityStarterDelegate delegate,
+            PluginDependencyProvider dependencyProvider) {
+        dependencyProvider.allowPluginDependency(ActivityStarter.class, delegate);
+        return delegate;
+    }
 
     /** */
     @Binds
-    ActivityStarter provideActivityStarter(ActivityStarterDelegate delegate);
+    abstract DarkIconDispatcher provideDarkIconDispatcher(DarkIconDispatcherImpl controllerImpl);
 
     /** */
     @Binds
-    DarkIconDispatcher provideDarkIconDispatcher(DarkIconDispatcherImpl controllerImpl);
+    abstract FalsingManager provideFalsingManager(FalsingManagerProxy falsingManagerImpl);
 
     /** */
     @Binds
-    FalsingManager provideFalsingManager(FalsingManagerProxy falsingManagerImpl);
+    abstract GlobalActions provideGlobalActions(GlobalActionsImpl controllerImpl);
 
     /** */
     @Binds
-    GlobalActions provideGlobalActions(GlobalActionsImpl controllerImpl);
-
-    /** */
-    @Binds
-    GlobalActions.GlobalActionsManager provideGlobalActionsManager(
+    abstract GlobalActions.GlobalActionsManager provideGlobalActionsManager(
             GlobalActionsComponent controllerImpl);
 
     /** */
     @Binds
-    StatusBarStateController provideStatusBarStateController(
+    abstract StatusBarStateController provideStatusBarStateController(
             StatusBarStateControllerImpl controllerImpl);
 
     /** */
     @Binds
-    VolumeDialogController provideVolumeDialogController(VolumeDialogControllerImpl controllerImpl);
-
+    abstract VolumeDialogController provideVolumeDialogController(
+            VolumeDialogControllerImpl controllerImpl);
 }
diff --git a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java b/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java
deleted file mode 100644
index 8effd53..0000000
--- a/packages/SystemUI/src/com/android/systemui/plugins/PluginInitializerImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2018 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.plugins;
-
-import com.android.systemui.shared.plugins.PluginInitializer;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/** */
-@Singleton
-public class PluginInitializerImpl implements PluginInitializer {
-    @Inject
-    public PluginInitializerImpl(PluginDependencyProvider  dependencyProvider) {
-        dependencyProvider.allowPluginDependency(ActivityStarter.class);
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/plugins/PluginsModule.java b/packages/SystemUI/src/com/android/systemui/plugins/PluginsModule.java
index 11c5efc..a0cf44c 100644
--- a/packages/SystemUI/src/com/android/systemui/plugins/PluginsModule.java
+++ b/packages/SystemUI/src/com/android/systemui/plugins/PluginsModule.java
@@ -28,7 +28,6 @@
 import com.android.systemui.dagger.qualifiers.Main;
 import com.android.systemui.shared.plugins.PluginActionManager;
 import com.android.systemui.shared.plugins.PluginEnabler;
-import com.android.systemui.shared.plugins.PluginInitializer;
 import com.android.systemui.shared.plugins.PluginInstance;
 import com.android.systemui.shared.plugins.PluginManager;
 import com.android.systemui.shared.plugins.PluginManagerImpl;
@@ -69,9 +68,6 @@
     @Binds
     abstract PluginEnabler bindsPluginEnablerImpl(PluginEnablerImpl impl);
 
-    @Binds
-    abstract PluginInitializer bindsPluginInitializerImpl(PluginInitializerImpl impl);
-
     @Provides
     @Singleton
     static PluginInstance.Factory providesPluginInstanceFactory(
@@ -89,12 +85,12 @@
     @Singleton
     static PluginActionManager.Factory providePluginInstanceManagerFactory(Context context,
             PackageManager packageManager, @Main Executor mainExecutor,
-            @Named(PLUGIN_THREAD) Executor pluginExecutor, PluginInitializer initializer,
+            @Named(PLUGIN_THREAD) Executor pluginExecutor,
             NotificationManager notificationManager, PluginEnabler pluginEnabler,
             @Named(PLUGIN_PRIVILEGED) List<String> privilegedPlugins,
             PluginInstance.Factory pluginInstanceFactory) {
         return new PluginActionManager.Factory(
-                context, packageManager, mainExecutor, pluginExecutor, initializer,
+                context, packageManager, mainExecutor, pluginExecutor,
                 notificationManager, pluginEnabler, privilegedPlugins, pluginInstanceFactory);
     }
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginActionManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginActionManagerTest.java
index ce36665..05280fa 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginActionManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shared/plugins/PluginActionManagerTest.java
@@ -74,7 +74,6 @@
     private PluginEnabler mMockEnabler;
     ComponentName mTestPluginComponentName =
             new ComponentName(PRIVILEGED_PACKAGE, TestPlugin.class.getName());
-    private PluginInitializer mInitializer;
     private final FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
     NotificationManager mNotificationManager;
     private PluginInstance<TestPlugin> mPluginInstance;
@@ -98,14 +97,13 @@
         mMockListener = mock(PluginListener.class);
         mMockEnabler = mock(PluginEnabler.class);
         mMockVersionInfo = mock(VersionInfo.class);
-        mInitializer = mock(PluginInitializer.class);
         mNotificationManager = mock(NotificationManager.class);
         mMockPlugin = mock(TestPlugin.class);
         mPluginInstance = mock(PluginInstance.class);
         when(mPluginInstance.getComponentName()).thenReturn(mTestPluginComponentName);
         when(mPluginInstance.getPackage()).thenReturn(mTestPluginComponentName.getPackageName());
         mActionManagerFactory = new PluginActionManager.Factory(getContext(), mMockPm,
-                mFakeExecutor, mFakeExecutor, mInitializer, mNotificationManager, mMockEnabler,
+                mFakeExecutor, mFakeExecutor, mNotificationManager, mMockEnabler,
                 new ArrayList<>(), mPluginInstanceFactory);
 
         mPluginActionManager = mActionManagerFactory.create("myAction", mMockListener,
@@ -178,7 +176,7 @@
     public void testNonDebuggable_privileged() throws Exception {
         // Create a version that thinks the build is not debuggable.
         PluginActionManager.Factory factory = new PluginActionManager.Factory(getContext(),
-                mMockPm, mFakeExecutor, mFakeExecutor, mInitializer, mNotificationManager,
+                mMockPm, mFakeExecutor, mFakeExecutor, mNotificationManager,
                 mMockEnabler, Collections.singletonList(PRIVILEGED_PACKAGE),
                 mPluginInstanceFactory);
         mPluginActionManager = factory.create("myAction", mMockListener,
@@ -222,7 +220,7 @@
     @Test
     public void testDisablePrivileged() throws Exception {
         PluginActionManager.Factory factory = new PluginActionManager.Factory(getContext(),
-                mMockPm, mFakeExecutor, mFakeExecutor, mInitializer, mNotificationManager,
+                mMockPm, mFakeExecutor, mFakeExecutor, mNotificationManager,
                 mMockEnabler, Collections.singletonList(PRIVILEGED_PACKAGE),
                 mPluginInstanceFactory);
         mPluginActionManager = factory.create("myAction", mMockListener,