Fix the looper that KeyguardUpdateMonitor is using.
Bug: 139051615
Test: atest SystemUITests && atest SystemUIGoogleTests
Change-Id: Ic4dd5978001c208504c137cee41f363d7e70b1b5
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index f9452e2..d8f039c 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -30,6 +30,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.Preconditions;
+import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.clock.ClockManager;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.appops.AppOpsController;
@@ -145,6 +146,11 @@
private static final String TAG = "Dependency";
/**
+ * Key for getting a the main looper.
+ */
+ public static final String MAIN_LOOPER_NAME = "main_looper";
+
+ /**
* Key for getting a background Looper for background work.
*/
public static final String BG_LOOPER_NAME = "background_looper";
@@ -177,6 +183,10 @@
*/
public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>(BG_LOOPER_NAME);
/**
+ * Key for getting a mainer Looper.
+ */
+ public static final DependencyKey<Looper> MAIN_LOOPER = new DependencyKey<>(MAIN_LOOPER_NAME);
+ /**
* Key for getting a background Handler for background work.
*/
public static final DependencyKey<Handler> BG_HANDLER = new DependencyKey<>(BG_HANDLER_NAME);
@@ -215,6 +225,7 @@
@Inject Lazy<UserSwitcherController> mUserSwitcherController;
@Inject Lazy<UserInfoController> mUserInfoController;
@Inject Lazy<KeyguardMonitor> mKeyguardMonitor;
+ @Inject Lazy<KeyguardUpdateMonitor> mKeyguardUpdateMonitor;
@Inject Lazy<BatteryController> mBatteryController;
@Inject Lazy<NightDisplayListener> mNightDisplayListener;
@Inject Lazy<ManagedProfileController> mManagedProfileController;
@@ -291,6 +302,7 @@
@Inject Lazy<PrivacyItemController> mPrivacyItemController;
@Inject @Named(BG_LOOPER_NAME) Lazy<Looper> mBgLooper;
@Inject @Named(BG_HANDLER_NAME) Lazy<Handler> mBgHandler;
+ @Inject @Named(MAIN_LOOPER_NAME) Lazy<Looper> mMainLooper;
@Inject @Named(MAIN_HANDLER_NAME) Lazy<Handler> mMainHandler;
@Inject @Named(TIME_TICK_HANDLER_NAME) Lazy<Handler> mTimeTickHandler;
@Nullable
@@ -318,6 +330,7 @@
mProviders.put(TIME_TICK_HANDLER, mTimeTickHandler::get);
mProviders.put(BG_LOOPER, mBgLooper::get);
mProviders.put(BG_HANDLER, mBgHandler::get);
+ mProviders.put(MAIN_LOOPER, mMainLooper::get);
mProviders.put(MAIN_HANDLER, mMainHandler::get);
mProviders.put(ActivityStarter.class, mActivityStarter::get);
mProviders.put(ActivityStarterDelegate.class, mActivityStarterDelegate::get);
@@ -344,6 +357,8 @@
mProviders.put(KeyguardMonitor.class, mKeyguardMonitor::get);
+ mProviders.put(KeyguardUpdateMonitor.class, mKeyguardUpdateMonitor::get);
+
mProviders.put(UserSwitcherController.class, mUserSwitcherController::get);
mProviders.put(UserInfoController.class, mUserInfoController::get);
diff --git a/packages/SystemUI/src/com/android/systemui/DependencyProvider.java b/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
index 3e2010e..d46a86c 100644
--- a/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
@@ -19,6 +19,7 @@
import static com.android.systemui.Dependency.BG_HANDLER_NAME;
import static com.android.systemui.Dependency.BG_LOOPER_NAME;
import static com.android.systemui.Dependency.MAIN_HANDLER_NAME;
+import static com.android.systemui.Dependency.MAIN_LOOPER_NAME;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
import android.annotation.Nullable;
@@ -87,6 +88,14 @@
return thread.getLooper();
}
+ /** Main Looper */
+ @Singleton
+ @Provides
+ @Named(MAIN_LOOPER_NAME)
+ public Looper provideMainLooper() {
+ return Looper.getMainLooper();
+ }
+
@Singleton
@Provides
@Named(BG_HANDLER_NAME)
@@ -97,8 +106,8 @@
@Singleton
@Provides
@Named(MAIN_HANDLER_NAME)
- public Handler provideMainHandler() {
- return new Handler(Looper.getMainLooper());
+ public Handler provideMainHandler(@Named(MAIN_LOOPER_NAME) Looper mainLooper) {
+ return new Handler(mainLooper);
}
@Singleton
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java
index 6a59fa1..0f99674 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactory.java
@@ -51,8 +51,8 @@
@NonNull ClassLoader cl, @NonNull String className)
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
Application app = super.instantiateApplicationCompat(cl, className);
- if (app instanceof ContextProvider) {
- ((ContextProvider) app).setContextAvailableCallback(
+ if (app instanceof ContextInitializer) {
+ ((ContextInitializer) app).setContextAvailableCallback(
context -> {
SystemUIFactory.createFromConfig(context);
SystemUIFactory.getInstance().getRootComponent().inject(
@@ -71,8 +71,8 @@
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
ContentProvider contentProvider = super.instantiateProviderCompat(cl, className);
- if (contentProvider instanceof ContextProvider) {
- ((ContextProvider) contentProvider).setContextAvailableCallback(
+ if (contentProvider instanceof ContextInitializer) {
+ ((ContextInitializer) contentProvider).setContextAvailableCallback(
context -> {
SystemUIFactory.createFromConfig(context);
SystemUIFactory.getInstance().getRootComponent().inject(
@@ -96,11 +96,17 @@
return super.instantiateServiceCompat(cl, className, intent);
}
- interface ContextAvailableCallback {
+ /**
+ * A callback that receives a Context when one is ready.
+ */
+ public interface ContextAvailableCallback {
void onContextAvailable(Context context);
}
- interface ContextProvider {
+ /**
+ * Implemented in classes that get started by the system before a context is available.
+ */
+ public interface ContextInitializer {
void setContextAvailableCallback(ContextAvailableCallback callback);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
index aafc67e..351ca42 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -49,7 +49,7 @@
* Application class for SystemUI.
*/
public class SystemUIApplication extends Application implements SysUiServiceProvider,
- SystemUIAppComponentFactory.ContextProvider {
+ SystemUIAppComponentFactory.ContextInitializer {
public static final String TAG = "SystemUIService";
private static final boolean DEBUG = false;
@@ -182,7 +182,7 @@
o = ((SystemUI.Injector) o).apply(this);
}
mServices[i] = (SystemUI) o;
- } catch(ClassNotFoundException ex){
+ } catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
} catch (IllegalAccessException ex) {
throw new RuntimeException(ex);
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 45142b0..0e5bdaf 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -136,7 +136,7 @@
return new KeyguardBouncer(context, callback, lockPatternUtils, container,
dismissCallbackRegistry, falsingManager,
expansionCallback, UnlockMethodCache.getInstance(context),
- KeyguardUpdateMonitor.getInstance(context), bypassController,
+ Dependency.get(KeyguardUpdateMonitor.class), bypassController,
new Handler(Looper.getMainLooper()));
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/SystemUIModule.java
index 5d103eb..3395014 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIModule.java
@@ -46,7 +46,7 @@
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
return null;
}
- return new KeyguardLiftController(context, statusBarStateController, asyncSensorManager);
+ return new KeyguardLiftController(statusBarStateController, asyncSensorManager);
}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerImpl.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerImpl.java
index fba0d50..c2b0fe4 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerImpl.java
@@ -154,7 +154,7 @@
updateConfiguration();
Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
- KeyguardUpdateMonitor.getInstance(context).registerCallback(mKeyguardUpdateCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).registerCallback(mKeyguardUpdateCallback);
}
private void updateConfiguration() {
@@ -556,7 +556,7 @@
mSensorManager.unregisterListener(mSensorEventListener);
mContext.getContentResolver().unregisterContentObserver(mSettingsObserver);
Dependency.get(StatusBarStateController.class).removeCallback(mStatusBarStateListener);
- KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mKeyguardUpdateCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).removeCallback(mKeyguardUpdateCallback);
}
public Uri reportRejectedTouch() {
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
index efac147..c9f5b79 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingManagerProxy.java
@@ -114,7 +114,7 @@
mInternalFalsingManager = new BrightLineFalsingManager(
new FalsingDataProvider(context.getResources().getDisplayMetrics()),
Dependency.get(AsyncSensorManager.class),
- KeyguardUpdateMonitor.getInstance(context),
+ Dependency.get(KeyguardUpdateMonitor.class),
mDeviceConfig
);
}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
index e5a54b8..abd41d4 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java
@@ -19,6 +19,7 @@
import android.content.Context;
import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.systemui.Dependency;
/**
* Controls removing Keyguard authorization when the phone goes to sleep.
@@ -28,7 +29,7 @@
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
public DozeAuthRemover(Context context) {
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
index 86d4a48..c367286 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
@@ -29,8 +29,8 @@
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.dock.DockManager;
-import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
+import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.AsyncSensorManager;
@@ -104,7 +104,7 @@
DozeMachine machine, Handler handler, AlarmManager alarmManager,
DozeParameters params) {
return new DozeUi(context, alarmManager, machine, wakeLock, host, handler, params,
- KeyguardUpdateMonitor.getInstance(context));
+ Dependency.get(KeyguardUpdateMonitor.class));
}
public static DozeHost getHost(DozeService service) {
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
index c09e284..8fe9f92 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -23,6 +23,7 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
@@ -112,7 +113,7 @@
}
log("init");
if (sRegisterKeyguardCallback) {
- KeyguardUpdateMonitor.getInstance(context).registerCallback(sKeyguardCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).registerCallback(sKeyguardCallback);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
index 1f3403b..6f8665a 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
@@ -82,7 +82,7 @@
mGlobalActions.showDialog(mKeyguardMonitor.isShowing(),
mDeviceProvisionedController.isDeviceProvisioned(),
mPanelExtension.get());
- KeyguardUpdateMonitor.getInstance(mContext).requestFaceAuth();
+ Dependency.get(KeyguardUpdateMonitor.class).requestFaceAuth();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
index 48f32cf..abfcbc1 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
@@ -49,7 +49,9 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.StatusBarState;
@@ -72,7 +74,8 @@
*/
public class KeyguardSliceProvider extends SliceProvider implements
NextAlarmController.NextAlarmChangeCallback, ZenModeController.Callback,
- NotificationMediaManager.MediaListener, StatusBarStateController.StateListener {
+ NotificationMediaManager.MediaListener, StatusBarStateController.StateListener,
+ SystemUIAppComponentFactory.ContextInitializer {
private static final StyleSpan BOLD_STYLE = new StyleSpan(Typeface.BOLD);
public static final String KEYGUARD_SLICE_URI = "content://com.android.systemui.keyguard/main";
@@ -93,6 +96,7 @@
@VisibleForTesting
static final int ALARM_VISIBILITY_HOURS = 12;
+ private static final Object sInstanceLock = new Object();
private static KeyguardSliceProvider sInstance;
protected final Uri mSliceUri;
@@ -130,6 +134,7 @@
protected boolean mDozing;
private int mStatusBarState;
private boolean mMediaIsVisible;
+ private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback;
/**
* Receiver responsible for time ticking and updating the date format.
@@ -310,7 +315,11 @@
@Override
public boolean onCreateSliceProvider() {
- synchronized (this) {
+ if (mContextAvailableCallback != null) {
+ mContextAvailableCallback.onContextAvailable(getContext());
+ Dependency.initDependencies(getContext());
+ }
+ synchronized (KeyguardSliceProvider.sInstanceLock) {
KeyguardSliceProvider oldInstance = KeyguardSliceProvider.sInstance;
if (oldInstance != null) {
oldInstance.onDestroy();
@@ -335,7 +344,7 @@
@VisibleForTesting
protected void onDestroy() {
- synchronized (this) {
+ synchronized (KeyguardSliceProvider.sInstanceLock) {
mNextAlarmController.removeCallback(this);
mZenModeController.removeCallback(this);
mMediaWakeLock.setAcquired(false);
@@ -345,6 +354,7 @@
getKeyguardUpdateMonitor().removeCallback(mKeyguardUpdateMonitorCallback);
getContext().unregisterReceiver(mIntentReceiver);
}
+ KeyguardSliceProvider.sInstance = null;
}
}
@@ -449,9 +459,8 @@
updateNextAlarm();
}
- @VisibleForTesting
- protected KeyguardUpdateMonitor getKeyguardUpdateMonitor() {
- return KeyguardUpdateMonitor.getInstance(getContext());
+ private KeyguardUpdateMonitor getKeyguardUpdateMonitor() {
+ return Dependency.get(KeyguardUpdateMonitor.class);
}
/**
@@ -530,4 +539,10 @@
notifyChange();
}
}
+
+ @Override
+ public void setContextAvailableCallback(
+ SystemUIAppComponentFactory.ContextAvailableCallback callback) {
+ mContextAvailableCallback = callback;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 4016b59..dc026e7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -710,7 +710,7 @@
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
- mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mLockPatternUtils = new LockPatternUtils(mContext);
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
@@ -846,7 +846,7 @@
playSounds(true);
}
}
- KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedGoingToSleep(why);
+ mUpdateMonitor.dispatchStartedGoingToSleep(why);
notifyStartedGoingToSleep();
}
@@ -891,7 +891,7 @@
}
}
- KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why);
+ mUpdateMonitor.dispatchFinishedGoingToSleep(why);
}
private long getLockTimeout(int userId) {
@@ -1004,7 +1004,7 @@
if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence);
notifyStartedWakingUp();
}
- KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedWakingUp();
+ mUpdateMonitor.dispatchStartedWakingUp();
maybeSendUserPresentBroadcast();
Trace.endSection();
}
@@ -1047,7 +1047,7 @@
* if there is a secure lock pattern.
*/
public void onDreamingStarted() {
- KeyguardUpdateMonitor.getInstance(mContext).dispatchDreamingStarted();
+ mUpdateMonitor.dispatchDreamingStarted();
synchronized (this) {
if (mDeviceInteractive
&& mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
@@ -1060,7 +1060,7 @@
* A dream stopped.
*/
public void onDreamingStopped() {
- KeyguardUpdateMonitor.getInstance(mContext).dispatchDreamingStopped();
+ mUpdateMonitor.dispatchDreamingStopped();
synchronized (this) {
if (mDeviceInteractive) {
cancelDoKeyguardLaterLocked();
@@ -1456,11 +1456,11 @@
public boolean isSecure(int userId) {
return mLockPatternUtils.isSecure(userId)
- || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure();
+ || mUpdateMonitor.isSimPinSecure();
}
public void setSwitchingUser(boolean switching) {
- KeyguardUpdateMonitor.getInstance(mContext).setSwitchingUser(switching);
+ mUpdateMonitor.setSwitchingUser(switching);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 9178fda..6556ed0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -142,7 +142,7 @@
Dependency.get(AccessibilityController.class),
UnlockMethodCache.getInstance(context),
Dependency.get(StatusBarStateController.class),
- KeyguardUpdateMonitor.getInstance(context));
+ Dependency.get(KeyguardUpdateMonitor.class));
}
/**
@@ -649,7 +649,7 @@
@Override
public void onBiometricHelp(int msgId, String helpString,
BiometricSourceType biometricSourceType) {
- KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
if (!updateMonitor.isUnlockingWithBiometricAllowed()) {
return;
}
@@ -674,7 +674,7 @@
@Override
public void onBiometricError(int msgId, String errString,
BiometricSourceType biometricSourceType) {
- KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
if (shouldSuppressBiometricError(msgId, biometricSourceType, updateMonitor)) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
index 107b24c..289277e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
@@ -281,7 +281,7 @@
if (userId == UserHandle.USER_ALL) {
userId = mCurrentUserId;
}
- return KeyguardUpdateMonitor.getInstance(mContext).isUserInLockdown(userId);
+ return Dependency.get(KeyguardUpdateMonitor.class).isUserInLockdown(userId);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/OperatorNameView.java b/packages/SystemUI/src/com/android/systemui/statusbar/OperatorNameView.java
index 2a5ccdb..843c37f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/OperatorNameView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/OperatorNameView.java
@@ -70,7 +70,7 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mKeyguardUpdateMonitor.registerCallback(mCallback);
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this);
Dependency.get(NetworkController.class).addCallback(this);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index ab9162a..b6f82a1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -278,7 +278,7 @@
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
getContext().registerReceiverAsUser(mDevicePolicyReceiver,
UserHandle.ALL, filter, null, null);
- KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).registerCallback(mUpdateMonitorCallback);
mUnlockMethodCache.addListener(this);
}
@@ -290,7 +290,7 @@
mRightExtension.destroy();
mLeftExtension.destroy();
getContext().unregisterReceiver(mDevicePolicyReceiver);
- KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).removeCallback(mUpdateMonitorCallback);
}
private void initAccessibility() {
@@ -817,7 +817,7 @@
@Override
public Intent getIntent() {
- KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
boolean canSkipBouncer = updateMonitor.getUserCanSkipBouncer(
KeyguardUpdateMonitor.getCurrentUser());
boolean secure = mUnlockMethodCache.isMethodSecure();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt
index f4635d1..f7bb97b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt
@@ -16,23 +16,22 @@
package com.android.systemui.statusbar.phone
-import android.content.Context
import android.hardware.Sensor
import android.hardware.TriggerEvent
import android.hardware.TriggerEventListener
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
+import com.android.systemui.Dependency
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.util.Assert
import com.android.systemui.util.AsyncSensorManager
class KeyguardLiftController constructor(
- context: Context,
private val statusBarStateController: StatusBarStateController,
private val asyncSensorManager: AsyncSensorManager
) : StatusBarStateController.StateListener, KeyguardUpdateMonitorCallback() {
- private val keyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context)
+ private val keyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor::class.java)
private val pickupSensor = asyncSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE)
private var isListening = false
private var bouncerVisible = false
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
index ecfc45b..62d855d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
@@ -42,6 +42,7 @@
import com.android.internal.telephony.IccCardConstants;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.dock.DockManager;
@@ -182,7 +183,7 @@
super(context, attrs);
mContext = context;
mUnlockMethodCache = UnlockMethodCache.getInstance(context);
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mAccessibilityController = accessibilityController;
mConfigurationController = configurationController;
mStatusBarStateController = statusBarStateController;
@@ -509,7 +510,7 @@
}
private int getState() {
- KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
if ((mUnlockMethodCache.canSkipBouncer() || !mKeyguardShowing
|| mKeyguardMonitor.isKeyguardGoingAway()) && !mSimLocked) {
return STATE_LOCK_OPEN;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
index dcb349b..e34c639 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
@@ -75,7 +75,7 @@
mH = h;
mWallpaperManager = (WallpaperManager) ctx.getSystemService(Context.WALLPAPER_SERVICE);
mCurrentUserId = ActivityManager.getCurrentUser();
- mUpdateMonitor = KeyguardUpdateMonitor.getInstance(ctx);
+ mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
IWallpaperManager service = IWallpaperManager.Stub.asInterface(
ServiceManager.getService(Context.WALLPAPER_SERVICE));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 248bc75..a58ba85 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -421,7 +421,7 @@
});
mThemeResId = context.getThemeResId();
mKeyguardBypassController = bypassController;
- mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
dynamicPrivacyController.addListener(this);
mBottomAreaShadeAlphaAnimator = ValueAnimator.ofFloat(1f, 0);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 5733d4b..8c95b84 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -198,7 +198,7 @@
mContext = scrimBehind.getContext();
mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer();
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mKeyguardVisibilityCallback = new KeyguardVisibilityCallback();
mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
mScrimBehindAlphaResValue = mContext.getResources().getFloat(R.dimen.scrim_behind_alpha);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 1c85724..fe96ef7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -701,7 +701,7 @@
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController);
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index ccb85fa..50c3561 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -193,7 +193,7 @@
mViewMediatorCallback = callback;
mLockPatternUtils = lockPatternUtils;
mStatusBarWindowController = Dependency.get(StatusBarWindowController.class);
- KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback);
+ Dependency.get(KeyguardUpdateMonitor.class).registerCallback(mUpdateMonitorCallback);
mStatusBarStateController.addCallback(this);
Dependency.get(ConfigurationController.class).addCallback(this);
mGesturalNav = QuickStepContract.isGesturalMode(
@@ -395,7 +395,7 @@
} else {
showBouncerOrKeyguard(hideBouncerWhenShowing);
}
- KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
+ Dependency.get(KeyguardUpdateMonitor.class).sendKeyguardReset();
updateStates();
}
}
@@ -533,7 +533,7 @@
mShowing, mKeyguardMonitor.isSecure(), mKeyguardMonitor.isOccluded());
launchPendingWakeupAction();
- if (KeyguardUpdateMonitor.getInstance(mContext).needsSlowUnlockTransition()) {
+ if (Dependency.get(KeyguardUpdateMonitor.class).needsSlowUnlockTransition()) {
fadeoutDuration = KEYGUARD_DISMISS_DURATION_LOCKED;
}
long uptimeMillis = SystemClock.uptimeMillis();
@@ -785,7 +785,7 @@
updateLockIcon();
}
- KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) {
updateMonitor.onKeyguardVisibilityChanged(showing && !occluded);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
index a870590..d8b2239 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
@@ -240,7 +240,7 @@
public void onDensityOrFontScaleChanged() {
MessagingMessage.dropCache();
MessagingGroup.dropCache();
- if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) {
+ if (!Dependency.get(KeyguardUpdateMonitor.class).isSwitchingUser()) {
updateNotificationsOnDensityOrFontScaleChanged();
} else {
mReinflateNotificationsOnUserSwitched = true;
@@ -249,7 +249,7 @@
@Override
public void onUiModeChanged() {
- if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) {
+ if (!Dependency.get(KeyguardUpdateMonitor.class).isSwitchingUser()) {
updateNotificationOnUiModeChanged();
} else {
mDispatchUiModeChangeOnUserSwitched = true;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
index 24ecd14..c76f93e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
@@ -28,6 +28,7 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.DejankUtils;
+import com.android.systemui.Dependency;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -57,8 +58,8 @@
private UnlockMethodCache(Context ctx) {
mLockPatternUtils = new LockPatternUtils(ctx);
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(ctx);
- KeyguardUpdateMonitor.getInstance(ctx).registerCallback(mCallback);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
+ Dependency.get(KeyguardUpdateMonitor.class).registerCallback(mCallback);
update(true /* updateAlways */);
if (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB) {
// Watch for interesting updates
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java
index f2c0434..353d6a4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EmergencyCryptkeeperText.java
@@ -32,6 +32,7 @@
import com.android.internal.telephony.TelephonyIntents;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import java.util.List;
@@ -66,7 +67,7 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mKeyguardUpdateMonitor.registerCallback(mCallback);
getContext().registerReceiver(mReceiver,
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardMonitorImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardMonitorImpl.java
index 87ed14a..a950626 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardMonitorImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardMonitorImpl.java
@@ -23,6 +23,7 @@
import com.android.internal.util.Preconditions;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import com.android.systemui.settings.CurrentUserTracker;
import java.util.ArrayList;
@@ -61,7 +62,7 @@
@Inject
public KeyguardMonitorImpl(Context context) {
mContext = context;
- mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
mUserTracker = new CurrentUserTracker(mContext) {
@Override
public void onUserSwitched(int newUserId) {