Can't use dagger to inject DockManager.
The DockManager hasn't been initialized yet.
Fixes: 129268296
Test: Placed on dock
Change-Id: I6c83b79b202de337e0ab408a6215d71662d89205
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
index 294c725..8ad5c7b 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
@@ -39,6 +39,7 @@
import androidx.annotation.VisibleForTesting;
import com.android.internal.colorextraction.ColorExtractor;
+import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManager.DockEventListener;
@@ -72,6 +73,7 @@
private final Map<String, ClockPlugin> mClocks = new ArrayMap<>();
@Nullable private ClockPlugin mCurrentClock;
+ private final Context mContext;
private final ContentResolver mContentResolver;
private final SettingsWrapper mSettingsWrapper;
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
@@ -117,7 +119,7 @@
reload();
}
};
- @Nullable private final DockManager mDockManager;
+ @Nullable private DockManager mDockManager;
/**
* When docked, the DOCKED_CLOCK_FACE setting will be checked for the custom clock face
* to show.
@@ -132,18 +134,16 @@
@Inject
public ClockManager(Context context, InjectionInflationController injectionInflater,
- PluginManager pluginManager, @Nullable DockManager dockManager,
- SysuiColorExtractor colorExtractor) {
- this(context, injectionInflater, pluginManager, dockManager, colorExtractor,
+ PluginManager pluginManager, SysuiColorExtractor colorExtractor) {
+ this(context, injectionInflater, pluginManager, colorExtractor,
context.getContentResolver(), new SettingsWrapper(context.getContentResolver()));
}
ClockManager(Context context, InjectionInflationController injectionInflater,
- PluginManager pluginManager, @Nullable DockManager dockManager,
- SysuiColorExtractor colorExtractor, ContentResolver contentResolver,
- SettingsWrapper settingsWrapper) {
+ PluginManager pluginManager, SysuiColorExtractor colorExtractor,
+ ContentResolver contentResolver, SettingsWrapper settingsWrapper) {
+ mContext = context;
mPluginManager = pluginManager;
- mDockManager = dockManager;
mColorExtractor = colorExtractor;
mContentResolver = contentResolver;
mSettingsWrapper = settingsWrapper;
@@ -323,6 +323,9 @@
mContentResolver.registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.DOCKED_CLOCK_FACE),
false, mContentObserver);
+ if (mDockManager == null) {
+ mDockManager = SysUiServiceProvider.getComponent(mContext, DockManager.class);
+ }
if (mDockManager != null) {
mDockManager.addListener(mDockEventListener);
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 6bb4fb5..47ad0c1 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -31,7 +31,6 @@
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.classifier.FalsingManager;
-import com.android.systemui.dock.DockManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -220,16 +219,6 @@
return SysUiServiceProvider.getComponent(context, StatusBar.class);
}
- /**
- * Provides DockManager.
- */
- @Singleton
- @Provides
- @Nullable
- public DockManager providesDockManager(Context context) {
- return SysUiServiceProvider.getComponent(context, DockManager.class);
- }
-
@Module
protected static class ContextHolder {
private Context mContext;
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockManagerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockManagerTest.java
index 36265d4..46b1833 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockManagerTest.java
@@ -67,8 +67,10 @@
when(mMockInjectionInflationController.injectable(any())).thenReturn(inflater);
mFakeDockManager = new DockManagerFake();
+ getContext().putComponent(DockManager.class, mFakeDockManager);
+
mClockManager = new ClockManager(getContext(), mMockInjectionInflationController,
- mMockPluginManager, mFakeDockManager, mMockColorExtractor, mMockContentResolver,
+ mMockPluginManager, mMockColorExtractor, mMockContentResolver,
mMockSettingsWrapper);
mClockManager.addOnClockChangedListener(mMockListener);