summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/Dependency.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/Dependency.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/Dependency.java63
1 files changed, 26 insertions, 37 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 6c36bc98996b..15bea2484d7f 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -16,7 +16,6 @@ package com.android.systemui;
import android.annotation.Nullable;
import android.app.INotificationManager;
-import android.content.Context;
import android.content.res.Configuration;
import android.hardware.SensorPrivacyManager;
import android.hardware.display.NightDisplayListener;
@@ -114,7 +113,6 @@ import com.android.systemui.util.leak.LeakReporter;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.util.HashMap;
import java.util.function.Consumer;
import javax.inject.Inject;
@@ -138,9 +136,7 @@ import dagger.Subcomponent;
* they have no clients they should not have any registered resources like bound
* services, registered receivers, etc.
*/
-public class Dependency extends SystemUI {
- private static final String TAG = "Dependency";
-
+public class Dependency {
/**
* Key for getting a background Looper for background work.
*/
@@ -305,8 +301,20 @@ public class Dependency extends SystemUI {
public Dependency() {
}
- @Override
- public void start() {
+
+ /**
+ * Initialize Depenency.
+ */
+ public static void initDependencies(SystemUIRootComponent rootComponent) {
+ if (sDependency != null) {
+ return;
+ }
+ sDependency = new Dependency();
+ rootComponent.createDependency().createSystemUI(sDependency);
+ sDependency.start();
+ }
+
+ protected void start() {
// TODO: Think about ways to push these creation rules out of Dependency to cut down
// on imports.
mProviders.put(TIME_TICK_HANDLER, mTimeTickHandler::get);
@@ -486,10 +494,14 @@ public class Dependency extends SystemUI {
sDependency = this;
}
- @Override
- public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- super.dump(fd, pw, args);
+ static void staticDump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ sDependency.dump(fd, pw, args);
+ }
+ /**
+ * {@see SystemUI.dump}
+ */
+ public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
// Make sure that the DumpController gets added to mDependencies, as they are only added
// with Dependency#get.
getDependency(DumpController.class);
@@ -509,9 +521,11 @@ public class Dependency extends SystemUI {
.forEach(o -> ((Dumpable) o).dump(fd, pw, args));
}
- @Override
+ protected static void staticOnConfigurationChanged(Configuration newConfig) {
+ sDependency.onConfigurationChanged(newConfig);
+ }
+
protected synchronized void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
mDependencies.values().stream().filter(obj -> obj instanceof ConfigurationChangedReceiver)
.forEach(o -> ((ConfigurationChangedReceiver) o).onConfigurationChanged(newConfig));
}
@@ -565,20 +579,6 @@ public class Dependency extends SystemUI {
}
/**
- * Used in separate processes (like tuner settings) to init the dependencies.
- */
- public static void initDependencies(Context context) {
- if (sDependency != null) return;
- Dependency d = new Dependency();
- SystemUIFactory.getInstance().getRootComponent()
- .createDependency()
- .createSystemUI(d);
- d.mContext = context;
- d.mComponents = new HashMap<>();
- d.start();
- }
-
- /**
* Used in separate process teardown to ensure the context isn't leaked.
*
* TODO: Remove once PreferenceFragment doesn't reference getActivity()
@@ -629,15 +629,4 @@ public class Dependency extends SystemUI {
public interface DependencyInjector {
void createSystemUI(Dependency dependency);
}
-
- public static class DependencyCreator implements Injector {
- @Override
- public SystemUI apply(Context context) {
- Dependency dependency = new Dependency();
- SystemUIFactory.getInstance().getRootComponent()
- .createDependency()
- .createSystemUI(dependency);
- return dependency;
- }
- }
}