Remove Dependency#get from ExtensionControllerImpl
Also deprecate Dependency#get.
Test: Updated existing tests
Change-Id: Ibdca61a4971e786c21f5a8bab215bc7a0b8ce7cb
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 443e389..f51004a 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -531,10 +531,18 @@
sDependency.destroyDependency(cls, destroy);
}
+ /**
+ * @deprecated see docs/dagger.md
+ */
+ @Deprecated
public static <T> T get(Class<T> cls) {
return sDependency.getDependency(cls);
}
+ /**
+ * @deprecated see docs/dagger.md
+ */
+ @Deprecated
public static <T> T get(DependencyKey<T> cls) {
return sDependency.getDependency(cls);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ExtensionControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ExtensionControllerImpl.java
index 2305db0..fd030d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ExtensionControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ExtensionControllerImpl.java
@@ -19,7 +19,6 @@
import android.os.Handler;
import android.util.ArrayMap;
-import com.android.systemui.Dependency;
import com.android.systemui.plugins.Plugin;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.shared.plugins.PluginManager;
@@ -49,12 +48,24 @@
public static final int SORT_ORDER_DEFAULT = 4;
private final Context mDefaultContext;
+ private final LeakDetector mLeakDetector;
+ private final PluginManager mPluginManager;
+ private final TunerService mTunerService;
+ private final ConfigurationController mConfigurationController;
/**
*/
@Inject
- public ExtensionControllerImpl(Context context) {
+ public ExtensionControllerImpl(Context context,
+ LeakDetector leakDetector,
+ PluginManager pluginManager,
+ TunerService tunerService,
+ ConfigurationController configurationController) {
mDefaultContext = context;
+ mLeakDetector = leakDetector;
+ mPluginManager = pluginManager;
+ mTunerService = tunerService;
+ mConfigurationController = configurationController;
}
@Override
@@ -168,14 +179,14 @@
@Override
public void clearItem(boolean isDestroyed) {
if (isDestroyed && mItem != null) {
- Dependency.get(LeakDetector.class).trackGarbage(mItem);
+ mLeakDetector.trackGarbage(mItem);
}
mItem = null;
}
private void notifyChanged() {
if (mItem != null) {
- Dependency.get(LeakDetector.class).trackGarbage(mItem);
+ mLeakDetector.trackGarbage(mItem);
}
mItem = null;
for (int i = 0; i < mProducers.size(); i++) {
@@ -216,7 +227,7 @@
public PluginItem(String action, Class<P> cls, PluginConverter<T, P> converter) {
mConverter = converter;
- Dependency.get(PluginManager.class).addPluginListener(action, this, cls);
+ mPluginManager.addPluginListener(action, this, cls);
}
@Override
@@ -244,7 +255,7 @@
@Override
public void destroy() {
- Dependency.get(PluginManager.class).removePluginListener(this);
+ mPluginManager.removePluginListener(this);
}
@Override
@@ -260,7 +271,7 @@
public TunerItem(TunerFactory<T> factory, String... setting) {
mFactory = factory;
- Dependency.get(TunerService.class).addTunable(this, setting);
+ mTunerService.addTunable(this, setting);
}
@Override
@@ -270,7 +281,7 @@
@Override
public void destroy() {
- Dependency.get(TunerService.class).removeTunable(this);
+ mTunerService.removeTunable(this);
}
@Override
@@ -298,7 +309,7 @@
mSupplier = supplier;
mUiMode = mDefaultContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_TYPE_MASK;
- Dependency.get(ConfigurationController.class).addCallback(this);
+ mConfigurationController.addCallback(this);
}
@Override
@@ -318,7 +329,7 @@
@Override
public void destroy() {
- Dependency.get(ConfigurationController.class).removeCallback(this);
+ mConfigurationController.removeCallback(this);
}
@Override