Merge "Fix NSWC goingAway flag"

This commit is contained in:
TreeHugger Robot
2020-02-19 20:17:05 +00:00
committed by Android (Google) Code Review
7 changed files with 70 additions and 29 deletions

View File

@@ -80,7 +80,8 @@ import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.Dependency;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIFactory;
@@ -144,7 +145,7 @@ import dagger.Lazy;
* directly to the keyguard UI is posted to a {@link android.os.Handler} to ensure it is taken on the UI
* thread of the keyguard.
*/
public class KeyguardViewMediator extends SystemUI {
public class KeyguardViewMediator extends SystemUI implements Dumpable {
private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
private static final long KEYGUARD_DONE_PENDING_TIMEOUT_MS = 3000;
@@ -222,10 +223,10 @@ public class KeyguardViewMediator extends SystemUI {
private final FalsingManager mFalsingManager;
/** High level access to the power manager for WakeLocks */
private PowerManager mPM;
private final PowerManager mPM;
/** TrustManager for letting it know when we change visibility */
private TrustManager mTrustManager;
private final TrustManager mTrustManager;
/**
* Used to keep the device awake while to ensure the keyguard finishes opening before
@@ -283,7 +284,7 @@ public class KeyguardViewMediator extends SystemUI {
// the properties of the keyguard
private KeyguardUpdateMonitor mUpdateMonitor;
private final KeyguardUpdateMonitor mUpdateMonitor;
/**
* Last SIM state reported by the telephony system.
@@ -610,6 +611,7 @@ public class KeyguardViewMediator extends SystemUI {
@Override
public void keyguardGone() {
Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardGone");
mNotificationShadeWindowController.setKeyguardGoingAway(false);
mKeyguardDisplayManager.hide();
Trace.endSection();
}
@@ -696,7 +698,9 @@ public class KeyguardViewMediator extends SystemUI {
NotificationShadeWindowController notificationShadeWindowController,
Lazy<StatusBarKeyguardViewManager> statusBarKeyguardViewManagerLazy,
DismissCallbackRegistry dismissCallbackRegistry,
@UiBackground Executor uiBgExecutor) {
KeyguardUpdateMonitor keyguardUpdateMonitor, DumpController dumpController,
@UiBackground Executor uiBgExecutor, PowerManager powerManager,
TrustManager trustManager) {
super(context);
mFalsingManager = falsingManager;
mLockPatternUtils = lockPatternUtils;
@@ -705,6 +709,10 @@ public class KeyguardViewMediator extends SystemUI {
mStatusBarKeyguardViewManagerLazy = statusBarKeyguardViewManagerLazy;
mDismissCallbackRegistry = dismissCallbackRegistry;
mUiBgExecutor = uiBgExecutor;
mUpdateMonitor = keyguardUpdateMonitor;
mPM = powerManager;
mTrustManager = trustManager;
dumpController.registerDumpable(this);
mShowHomeOverLockscreen = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_SYSTEMUI,
NAV_BAR_HANDLE_SHOW_OVER_LOCKSCREEN,
@@ -731,9 +739,6 @@ public class KeyguardViewMediator extends SystemUI {
}
private void setupLocked() {
mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mTrustManager = mContext.getSystemService(TrustManager.class);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
@@ -754,8 +759,6 @@ public class KeyguardViewMediator extends SystemUI {
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure, unless Keyguard

View File

@@ -16,9 +16,13 @@
package com.android.systemui.keyguard.dagger;
import android.app.trust.TrustManager;
import android.content.Context;
import android.os.PowerManager;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.DumpController;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.keyguard.DismissCallbackRegistry;
@@ -54,6 +58,10 @@ public class KeyguardModule {
NotificationShadeWindowController notificationShadeWindowController,
Lazy<StatusBarKeyguardViewManager> statusBarKeyguardViewManagerLazy,
DismissCallbackRegistry dismissCallbackRegistry,
KeyguardUpdateMonitor updateMonitor,
DumpController dumpController,
PowerManager powerManager,
TrustManager trustManager,
@UiBackground Executor uiBgExecutor) {
return new KeyguardViewMediator(
context,
@@ -63,6 +71,10 @@ public class KeyguardModule {
notificationShadeWindowController,
statusBarKeyguardViewManagerLazy,
dismissCallbackRegistry,
uiBgExecutor);
updateMonitor,
dumpController,
uiBgExecutor,
powerManager,
trustManager);
}
}

View File

@@ -40,6 +40,7 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -101,7 +102,8 @@ public class NotificationShadeWindowController implements Callback, Dumpable,
IActivityManager activityManager, DozeParameters dozeParameters,
StatusBarStateController statusBarStateController,
ConfigurationController configurationController,
KeyguardBypassController keyguardBypassController, SysuiColorExtractor colorExtractor) {
KeyguardBypassController keyguardBypassController, SysuiColorExtractor colorExtractor,
DumpController dumpController) {
mContext = context;
mWindowManager = windowManager;
mActivityManager = activityManager;
@@ -111,6 +113,7 @@ public class NotificationShadeWindowController implements Callback, Dumpable,
mLpChanged = new LayoutParams();
mKeyguardBypassController = keyguardBypassController;
mColorExtractor = colorExtractor;
dumpController.registerDumpable(this);
mLockScreenDisplayTimeout = context.getResources()
.getInteger(R.integer.config_lockScreenDisplayTimeout);
@@ -594,7 +597,7 @@ public class NotificationShadeWindowController implements Callback, Dumpable,
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("StatusBarWindowController:");
pw.println(TAG + ":");
pw.println(" mKeyguardDisplayMode=" + mKeyguardDisplayMode);
pw.println(mCurrentState);
}

View File

@@ -203,7 +203,8 @@ public class BubbleControllerTest extends SysuiTestCase {
// Bubbles get added to status bar window view
mNotificationShadeWindowController = new NotificationShadeWindowController(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardBypassController, mColorExtractor);
mConfigurationController, mKeyguardBypassController, mColorExtractor,
mDumpController);
mNotificationShadeWindowController.setNotificationShadeView(
mSuperStatusBarViewFactory.getNotificationShadeWindowView());
mNotificationShadeWindowController.attach();

View File

@@ -197,7 +197,8 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
// Bubbles get added to status bar window view
mNotificationShadeWindowController = new NotificationShadeWindowController(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardBypassController, mColorExtractor);
mConfigurationController, mKeyguardBypassController, mColorExtractor,
mDumpController);
mNotificationShadeWindowController.setNotificationShadeView(
mSuperStatusBarViewFactory.getNotificationShadeWindowView());
mNotificationShadeWindowController.attach();

View File

@@ -18,24 +18,30 @@ package com.android.systemui.keyguard;
import static android.view.WindowManagerPolicyConstants.OFF_BECAUSE_OF_USER;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import androidx.test.filters.SmallTest;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.DumpController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.concurrency.FakeExecutor;
@@ -60,6 +66,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
private @Mock NotificationShadeWindowController mNotificationShadeWindowController;
private @Mock BroadcastDispatcher mBroadcastDispatcher;
private @Mock DismissCallbackRegistry mDismissCallbackRegistry;
private @Mock DumpController mDumpController;
private @Mock PowerManager mPowerManager;
private @Mock TrustManager mTrustManager;
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
private FalsingManagerFake mFalsingManager;
@@ -69,24 +78,33 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
mFalsingManager = new FalsingManagerFake();
mDependency.injectTestDependency(FalsingManager.class, mFalsingManager);
mDependency.injectTestDependency(KeyguardUpdateMonitor.class, mUpdateMonitor);
when(mLockPatternUtils.getDevicePolicyManager()).thenReturn(mDevicePolicyManager);
when(mPowerManager.newWakeLock(anyInt(), any())).thenReturn(mock(WakeLock.class));
TestableLooper.get(this).runWithLooper(() -> {
mViewMediator = new KeyguardViewMediator(
mContext, mFalsingManager, mLockPatternUtils, mBroadcastDispatcher,
mNotificationShadeWindowController, () -> mStatusBarKeyguardViewManager,
mDismissCallbackRegistry, mUiBgExecutor);
});
mViewMediator = new KeyguardViewMediator(
mContext, mFalsingManager, mLockPatternUtils, mBroadcastDispatcher,
mNotificationShadeWindowController, () -> mStatusBarKeyguardViewManager,
mDismissCallbackRegistry, mUpdateMonitor, mDumpController, mUiBgExecutor,
mPowerManager, mTrustManager);
mViewMediator.start();
}
@Test
public void testOnGoingToSleep_UpdatesKeyguardGoingAway() {
mViewMediator.start();
mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER);
verify(mUpdateMonitor).setKeyguardGoingAway(false);
verify(mNotificationShadeWindowController, never()).setKeyguardGoingAway(anyBoolean());
}
@Test
public void testRegisterDumpable() {
verify(mDumpController).registerDumpable(eq(mViewMediator));
verify(mNotificationShadeWindowController, never()).setKeyguardGoingAway(anyBoolean());
}
@Test
public void testKeyguardGone_notGoingaway() {
mViewMediator.mViewMediatorCallback.keyguardGone();
verify(mNotificationShadeWindowController).setKeyguardGoingAway(eq(false));
}
}

View File

@@ -32,6 +32,7 @@ import android.view.WindowManager;
import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.systemui.DumpController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -58,6 +59,7 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase {
@Mock private KeyguardBypassController mKeyguardBypassController;
@Mock private SysuiColorExtractor mColorExtractor;
@Mock ColorExtractor.GradientColors mGradientColors;
@Mock private DumpController mDumpController;
private NotificationShadeWindowController mNotificationShadeWindowController;
@@ -69,7 +71,8 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase {
mNotificationShadeWindowController = new NotificationShadeWindowController(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardBypassController, mColorExtractor);
mConfigurationController, mKeyguardBypassController, mColorExtractor,
mDumpController);
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
mNotificationShadeWindowController.attach();