Finish injecting GarbageMonitor.

Test: QS tile works and dumpsys isn't broken.
Change-Id: I9eecf9ffbbe69be2399d47b15808b6322fc6466b
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java
index d9b4297..ba2dec0 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java
@@ -20,6 +20,7 @@
 import com.android.systemui.power.PowerUI;
 import com.android.systemui.recents.Recents;
 import com.android.systemui.recents.RecentsModule;
+import com.android.systemui.util.leak.GarbageMonitor;
 
 import dagger.Binds;
 import dagger.Module;
@@ -48,4 +49,10 @@
     @IntoMap
     @ClassKey(Recents.class)
     public abstract SystemUI bindRecents(Recents sysui);
+
+    /** Inject into GarbageMonitor.Service. */
+    @Binds
+    @IntoMap
+    @ClassKey(GarbageMonitor.Service.class)
+    public abstract SystemUI bindGarbageMonitorService(GarbageMonitor.Service service);
 }
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java
index c70b2fc..bcbe672 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIRootComponent.java
@@ -23,7 +23,6 @@
 import com.android.systemui.fragments.FragmentService;
 import com.android.systemui.statusbar.phone.StatusBar;
 import com.android.systemui.util.InjectionInflationController;
-import com.android.systemui.util.leak.GarbageMonitor;
 
 import javax.inject.Named;
 import javax.inject.Singleton;
@@ -43,7 +42,7 @@
 public interface SystemUIRootComponent {
 
     /**
-     * Creates a GarbageMonitor.
+     * Creates a ContextComponentHelper.
      */
     @Singleton
     ContextComponentHelper getContextComponentHelper();
@@ -72,12 +71,6 @@
     InjectionInflationController.ViewCreator createViewCreator();
 
     /**
-     * Creates a GarbageMonitor.
-     */
-    @Singleton
-    GarbageMonitor createGarbageMonitor();
-
-    /**
      * Whether notification long press is allowed.
      */
     @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java b/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
index 583f6b3..e84d9a9 100644
--- a/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
@@ -49,7 +49,6 @@
 import com.android.systemui.Dumpable;
 import com.android.systemui.R;
 import com.android.systemui.SystemUI;
-import com.android.systemui.SystemUIFactory;
 import com.android.systemui.plugins.qs.QSTile;
 import com.android.systemui.qs.QSHost;
 import com.android.systemui.qs.tileimpl.QSTileImpl;
@@ -391,9 +390,9 @@
         private boolean dumpInProgress;
 
         @Inject
-        public MemoryTile(QSHost host) {
+        public MemoryTile(QSHost host, GarbageMonitor monitor) {
             super(host);
-            gm = SystemUIFactory.getInstance().getRootComponent().createGarbageMonitor();
+            gm = monitor;
         }
 
         @Override
@@ -535,7 +534,12 @@
 
     /** */
     public static class Service extends SystemUI implements Dumpable {
-        private GarbageMonitor mGarbageMonitor;
+        private final GarbageMonitor mGarbageMonitor;
+
+        @Inject
+        public Service(GarbageMonitor garbageMonitor) {
+            mGarbageMonitor = garbageMonitor;
+        }
 
         @Override
         public void start() {
@@ -543,8 +547,6 @@
                     Settings.Secure.getInt(
                                     mContext.getContentResolver(), FORCE_ENABLE_LEAK_REPORTING, 0)
                             != 0;
-            mGarbageMonitor = SystemUIFactory.getInstance().getRootComponent()
-                   .createGarbageMonitor();
             if (LEAK_REPORTING_ENABLED || forceEnable) {
                 mGarbageMonitor.startLeakMonitor();
             }