Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 19 | import static android.app.NotificationManager.IMPORTANCE_HIGH; |
| 20 | |
| 21 | import static junit.framework.Assert.assertFalse; |
| 22 | import static junit.framework.Assert.assertTrue; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 23 | import static junit.framework.TestCase.fail; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 24 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 25 | import static org.mockito.ArgumentMatchers.any; |
| 26 | import static org.mockito.ArgumentMatchers.anyBoolean; |
| 27 | import static org.mockito.ArgumentMatchers.anyInt; |
| 28 | import static org.mockito.ArgumentMatchers.anyString; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 29 | import static org.mockito.ArgumentMatchers.eq; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 30 | import static org.mockito.Mockito.doAnswer; |
| 31 | import static org.mockito.Mockito.mock; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 32 | import static org.mockito.Mockito.never; |
| 33 | import static org.mockito.Mockito.times; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 34 | import static org.mockito.Mockito.verify; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 35 | import static org.mockito.Mockito.when; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 36 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 37 | import android.app.Notification; |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 38 | import android.app.StatusBarManager; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 39 | import android.app.trust.TrustManager; |
| 40 | import android.hardware.fingerprint.FingerprintManager; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 41 | import android.metrics.LogMaker; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 42 | import android.os.Binder; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 43 | import android.os.Handler; |
| 44 | import android.os.HandlerThread; |
| 45 | import android.os.IPowerManager; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 46 | import android.os.PowerManager; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 47 | import android.os.RemoteException; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 48 | import android.os.UserHandle; |
| 49 | import android.service.notification.StatusBarNotification; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 50 | import android.support.test.filters.SmallTest; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 51 | import android.support.test.metricshelper.MetricsAsserts; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 52 | import android.testing.AndroidTestingRunner; |
| 53 | import android.testing.TestableLooper; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 54 | import android.testing.TestableLooper.RunWithLooper; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 55 | import android.util.DisplayMetrics; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 56 | import android.util.SparseArray; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 57 | import android.view.ViewGroup.LayoutParams; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 58 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 59 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 60 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 61 | import com.android.internal.logging.testing.FakeMetricsLogger; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 62 | import com.android.internal.statusbar.IStatusBarService; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 63 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 64 | import com.android.systemui.R; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 65 | import com.android.systemui.SysuiTestCase; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 66 | import com.android.systemui.UiOffloadThread; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 67 | import com.android.systemui.assist.AssistManager; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 68 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 69 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 70 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 71 | import com.android.systemui.statusbar.CommandQueue; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 72 | import com.android.systemui.statusbar.KeyguardIndicationController; |
| 73 | import com.android.systemui.statusbar.NotificationData; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 74 | import com.android.systemui.statusbar.NotificationData.Entry; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 75 | import com.android.systemui.statusbar.NotificationListener; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 76 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 77 | import com.android.systemui.statusbar.NotificationLogger; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 78 | import com.android.systemui.statusbar.StatusBarState; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 79 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 80 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 81 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
| 82 | import com.android.systemui.statusbar.policy.KeyguardMonitorImpl; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 83 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 84 | |
| 85 | import org.junit.Before; |
| 86 | import org.junit.Test; |
| 87 | import org.junit.runner.RunWith; |
| 88 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 89 | import java.io.ByteArrayOutputStream; |
| 90 | import java.io.PrintWriter; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 91 | import java.util.ArrayList; |
| 92 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 93 | @SmallTest |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 94 | @RunWith(AndroidTestingRunner.class) |
| 95 | @RunWithLooper |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 96 | public class StatusBarTest extends SysuiTestCase { |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 97 | |
| 98 | StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 99 | UnlockMethodCache mUnlockMethodCache; |
| 100 | KeyguardIndicationController mKeyguardIndicationController; |
| 101 | NotificationStackScrollLayout mStackScroller; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 102 | TestableStatusBar mStatusBar; |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 103 | FakeMetricsLogger mMetricsLogger; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 104 | HeadsUpManager mHeadsUpManager; |
| 105 | NotificationData mNotificationData; |
| 106 | PowerManager mPowerManager; |
| 107 | SystemServicesProxy mSystemServicesProxy; |
Jorim Jaggi | fd3b1a1 | 2017-06-06 17:04:19 -0700 | [diff] [blame] | 108 | NotificationPanelView mNotificationPanelView; |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 109 | ScrimController mScrimController; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 110 | IStatusBarService mBarService; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 111 | NotificationListener mNotificationListener; |
| 112 | NotificationLogger mNotificationLogger; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 113 | ArrayList<Entry> mNotificationList; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 114 | FingerprintUnlockController mFingerprintUnlockController; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 115 | private DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
| 116 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 117 | @Before |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 118 | public void setup() throws Exception { |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 119 | mContext.setTheme(R.style.Theme_SystemUI_Light); |
| 120 | mDependency.injectMockDependency(AssistManager.class); |
| 121 | mDependency.injectMockDependency(DeviceProvisionedController.class); |
| 122 | mDependency.injectTestDependency(KeyguardMonitor.class, mock(KeyguardMonitorImpl.class)); |
| 123 | CommandQueue commandQueue = mock(CommandQueue.class); |
| 124 | when(commandQueue.asBinder()).thenReturn(new Binder()); |
| 125 | mContext.putComponent(CommandQueue.class, commandQueue); |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 126 | mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class)); |
| 127 | mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class)); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 128 | mStatusBarKeyguardViewManager = mock(StatusBarKeyguardViewManager.class); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 129 | mUnlockMethodCache = mock(UnlockMethodCache.class); |
| 130 | mKeyguardIndicationController = mock(KeyguardIndicationController.class); |
| 131 | mStackScroller = mock(NotificationStackScrollLayout.class); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 132 | when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0)); |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 133 | mMetricsLogger = new FakeMetricsLogger(); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 134 | mHeadsUpManager = mock(HeadsUpManager.class); |
| 135 | mNotificationData = mock(NotificationData.class); |
| 136 | mSystemServicesProxy = mock(SystemServicesProxy.class); |
Jorim Jaggi | fd3b1a1 | 2017-06-06 17:04:19 -0700 | [diff] [blame] | 137 | mNotificationPanelView = mock(NotificationPanelView.class); |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 138 | when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0)); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 139 | mNotificationList = mock(ArrayList.class); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 140 | mScrimController = mock(ScrimController.class); |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 141 | mFingerprintUnlockController = mock(FingerprintUnlockController.class); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 142 | IPowerManager powerManagerService = mock(IPowerManager.class); |
| 143 | HandlerThread handlerThread = new HandlerThread("TestThread"); |
| 144 | handlerThread.start(); |
| 145 | mPowerManager = new PowerManager(mContext, powerManagerService, |
| 146 | new Handler(handlerThread.getLooper())); |
| 147 | when(powerManagerService.isInteractive()).thenReturn(true); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 148 | mBarService = mock(IStatusBarService.class); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 149 | mNotificationListener = mock(NotificationListener.class); |
| 150 | mNotificationLogger = new NotificationLogger(mNotificationListener, mDependency.get( |
| 151 | UiOffloadThread.class)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 152 | |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 153 | mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 154 | mStatusBar = new TestableStatusBar(mStatusBarKeyguardViewManager, mUnlockMethodCache, |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 155 | mKeyguardIndicationController, mStackScroller, mHeadsUpManager, |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 156 | mNotificationData, mPowerManager, mSystemServicesProxy, mNotificationPanelView, |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 157 | mBarService, mNotificationListener, mNotificationLogger, mScrimController, |
| 158 | mFingerprintUnlockController); |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 159 | mStatusBar.mContext = mContext; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 160 | mStatusBar.mComponents = mContext.getComponents(); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 161 | doAnswer(invocation -> { |
| 162 | OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0]; |
| 163 | onDismissAction.onDismiss(); |
| 164 | return null; |
| 165 | }).when(mStatusBarKeyguardViewManager).dismissWithAction(any(), any(), anyBoolean()); |
| 166 | |
| 167 | doAnswer(invocation -> { |
| 168 | Runnable runnable = (Runnable) invocation.getArguments()[0]; |
| 169 | runnable.run(); |
| 170 | return null; |
| 171 | }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 172 | |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 173 | mNotificationLogger.setUpWithPresenter(mStatusBar, mStackScroller); |
| 174 | |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 175 | when(mStackScroller.getActivatedChild()).thenReturn(null); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 176 | TestableLooper.get(this).setMessageHandler(m -> { |
| 177 | if (m.getCallback() == mStatusBar.mNotificationLogger.getVisibilityReporter()) { |
| 178 | return false; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 179 | } |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 180 | return true; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 181 | }); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 184 | @Test |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 185 | public void testSetBouncerShowing_noCrash() { |
| 186 | mStatusBar.mCommandQueue = mock(CommandQueue.class); |
| 187 | mStatusBar.setBouncerShowing(true); |
| 188 | } |
| 189 | |
| 190 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 191 | public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { |
| 192 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 193 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); |
| 194 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 195 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 196 | } |
| 197 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 198 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 199 | public void executeRunnableDismissingKeyguard_nullRunnable_showing() { |
| 200 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 201 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 202 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 203 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 206 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 207 | public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { |
| 208 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 209 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 210 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 211 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 214 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 215 | public void lockscreenStateMetrics_notShowing() { |
| 216 | // uninteresting state, except that fingerprint must be non-zero |
| 217 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 218 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 219 | // interesting state |
| 220 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 221 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 222 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(false); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 223 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 224 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 225 | MetricsAsserts.assertHasLog("missing hidden insecure lockscreen log", |
| 226 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 227 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 228 | .setType(MetricsEvent.TYPE_CLOSE) |
| 229 | .setSubtype(0)); |
| 230 | } |
| 231 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 232 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 233 | public void lockscreenStateMetrics_notShowing_secure() { |
| 234 | // uninteresting state, except that fingerprint must be non-zero |
| 235 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 236 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 237 | // interesting state |
| 238 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 239 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 240 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 241 | |
| 242 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 243 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 244 | MetricsAsserts.assertHasLog("missing hidden secure lockscreen log", |
| 245 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 246 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 247 | .setType(MetricsEvent.TYPE_CLOSE) |
| 248 | .setSubtype(1)); |
| 249 | } |
| 250 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 251 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 252 | public void lockscreenStateMetrics_isShowing() { |
| 253 | // uninteresting state, except that fingerprint must be non-zero |
| 254 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 255 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 256 | // interesting state |
| 257 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 258 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 259 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(false); |
| 260 | |
| 261 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 262 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 263 | MetricsAsserts.assertHasLog("missing insecure lockscreen showing", |
| 264 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 265 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 266 | .setType(MetricsEvent.TYPE_OPEN) |
| 267 | .setSubtype(0)); |
| 268 | } |
| 269 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 270 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 271 | public void lockscreenStateMetrics_isShowing_secure() { |
| 272 | // uninteresting state, except that fingerprint must be non-zero |
| 273 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 274 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 275 | // interesting state |
| 276 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 277 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 278 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 279 | |
| 280 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 281 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 282 | MetricsAsserts.assertHasLog("missing secure lockscreen showing log", |
| 283 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 284 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 285 | .setType(MetricsEvent.TYPE_OPEN) |
| 286 | .setSubtype(1)); |
| 287 | } |
| 288 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 289 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 290 | public void lockscreenStateMetrics_isShowingBouncer() { |
| 291 | // uninteresting state, except that fingerprint must be non-zero |
| 292 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 293 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 294 | // interesting state |
| 295 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 296 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); |
| 297 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 298 | |
| 299 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 300 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 301 | MetricsAsserts.assertHasLog("missing bouncer log", |
| 302 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 303 | new LogMaker(MetricsEvent.BOUNCER) |
| 304 | .setType(MetricsEvent.TYPE_OPEN) |
| 305 | .setSubtype(1)); |
| 306 | } |
| 307 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 308 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 309 | public void onActivatedMetrics() { |
| 310 | ActivatableNotificationView view = mock(ActivatableNotificationView.class); |
| 311 | mStatusBar.onActivated(view); |
| 312 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 313 | MetricsAsserts.assertHasLog("missing lockscreen note tap log", |
| 314 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 315 | new LogMaker(MetricsEvent.ACTION_LS_NOTE) |
| 316 | .setType(MetricsEvent.TYPE_ACTION)); |
| 317 | } |
| 318 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 319 | @Test |
| 320 | public void testShouldPeek_nonSuppressedGroupSummary() { |
| 321 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 322 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 323 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); |
| 324 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 325 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 326 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 327 | |
| 328 | Notification n = new Notification.Builder(getContext(), "a") |
| 329 | .setGroup("a") |
| 330 | .setGroupSummary(true) |
| 331 | .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) |
| 332 | .build(); |
| 333 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 334 | UserHandle.of(0), null, 0); |
| 335 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 336 | |
| 337 | assertTrue(mStatusBar.shouldPeek(entry, sbn)); |
| 338 | } |
| 339 | |
| 340 | @Test |
| 341 | public void testShouldPeek_suppressedGroupSummary() { |
| 342 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 343 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 344 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); |
| 345 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 346 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 347 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 348 | |
| 349 | Notification n = new Notification.Builder(getContext(), "a") |
| 350 | .setGroup("a") |
| 351 | .setGroupSummary(true) |
| 352 | .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN) |
| 353 | .build(); |
| 354 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 355 | UserHandle.of(0), null, 0); |
| 356 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 357 | |
| 358 | assertFalse(mStatusBar.shouldPeek(entry, sbn)); |
| 359 | } |
| 360 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 361 | @Test |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 362 | public void testShouldPeek_suppressedScreenOn_dozing() { |
| 363 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 364 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 365 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 366 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 367 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 368 | |
| 369 | mStatusBar.mDozing = true; |
| 370 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); |
| 371 | when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); |
| 372 | |
| 373 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 374 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 375 | UserHandle.of(0), null, 0); |
| 376 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 377 | |
| 378 | assertTrue(mStatusBar.shouldPeek(entry, sbn)); |
| 379 | } |
| 380 | |
| 381 | @Test |
| 382 | public void testShouldPeek_suppressedScreenOn_noDoze() { |
| 383 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 384 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 385 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 386 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 387 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 388 | |
| 389 | mStatusBar.mDozing = false; |
| 390 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(true); |
| 391 | when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(false); |
| 392 | |
| 393 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 394 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 395 | UserHandle.of(0), null, 0); |
| 396 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 397 | assertFalse(mStatusBar.shouldPeek(entry, sbn)); |
| 398 | } |
| 399 | @Test |
| 400 | public void testShouldPeek_suppressedScreenOff_dozing() { |
| 401 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 402 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 403 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 404 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 405 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 406 | |
| 407 | mStatusBar.mDozing = true; |
| 408 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); |
| 409 | when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); |
| 410 | |
| 411 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 412 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 413 | UserHandle.of(0), null, 0); |
| 414 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 415 | assertFalse(mStatusBar.shouldPeek(entry, sbn)); |
| 416 | } |
| 417 | |
| 418 | @Test |
| 419 | public void testShouldPeek_suppressedScreenOff_noDoze() { |
| 420 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 421 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 422 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 423 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 424 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 425 | |
| 426 | mStatusBar.mDozing = false; |
| 427 | when(mNotificationData.shouldSuppressScreenOn(any())).thenReturn(false); |
| 428 | when(mNotificationData.shouldSuppressScreenOff(any())).thenReturn(true); |
| 429 | |
| 430 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 431 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 432 | UserHandle.of(0), null, 0); |
| 433 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 434 | assertTrue(mStatusBar.shouldPeek(entry, sbn)); |
| 435 | } |
| 436 | |
| 437 | |
| 438 | @Test |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 439 | public void testLogHidden() { |
| 440 | try { |
| 441 | mStatusBar.handleVisibleToUserChanged(false); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 442 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 443 | verify(mBarService, times(1)).onPanelHidden(); |
| 444 | verify(mBarService, never()).onPanelRevealed(anyBoolean(), anyInt()); |
| 445 | } catch (RemoteException e) { |
| 446 | fail(); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | @Test |
| 451 | public void testPanelOpenForPeek() { |
| 452 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); |
| 453 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 454 | when(mNotificationList.size()).thenReturn(5); |
| 455 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(true); |
| 456 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 457 | |
| 458 | try { |
| 459 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 460 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 461 | verify(mBarService, never()).onPanelHidden(); |
| 462 | verify(mBarService, times(1)).onPanelRevealed(false, 1); |
| 463 | } catch (RemoteException e) { |
| 464 | fail(); |
| 465 | } |
| 466 | TestableLooper.get(this).processAllMessages(); |
| 467 | } |
| 468 | |
| 469 | @Test |
| 470 | public void testPanelOpenAndClear() { |
| 471 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 472 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 473 | when(mNotificationList.size()).thenReturn(5); |
| 474 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(false); |
| 475 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 476 | |
| 477 | try { |
| 478 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 479 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 480 | verify(mBarService, never()).onPanelHidden(); |
| 481 | verify(mBarService, times(1)).onPanelRevealed(true, 5); |
| 482 | } catch (RemoteException e) { |
| 483 | fail(); |
| 484 | } |
| 485 | TestableLooper.get(this).processAllMessages(); |
| 486 | } |
| 487 | |
| 488 | @Test |
| 489 | public void testPanelOpenAndNoClear() { |
| 490 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 491 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 492 | when(mNotificationList.size()).thenReturn(5); |
| 493 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(false); |
| 494 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 495 | |
| 496 | try { |
| 497 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 498 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 499 | verify(mBarService, never()).onPanelHidden(); |
| 500 | verify(mBarService, times(1)).onPanelRevealed(false, 5); |
| 501 | } catch (RemoteException e) { |
| 502 | fail(); |
| 503 | } |
| 504 | TestableLooper.get(this).processAllMessages(); |
| 505 | } |
| 506 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 507 | @Test |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 508 | public void testDisableExpandStatusBar() { |
| 509 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 510 | mStatusBar.setUserSetupForTest(true); |
| 511 | when(mStatusBar.isDeviceProvisioned()).thenReturn(true); |
| 512 | |
| 513 | mStatusBar.disable(StatusBarManager.DISABLE_NONE, |
| 514 | StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); |
| 515 | verify(mNotificationPanelView).setQsExpansionEnabled(false); |
| 516 | mStatusBar.animateExpandNotificationsPanel(); |
| 517 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 518 | mStatusBar.animateExpandSettingsPanel(null); |
| 519 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 520 | |
| 521 | mStatusBar.disable(StatusBarManager.DISABLE_NONE, StatusBarManager.DISABLE2_NONE, false); |
| 522 | verify(mNotificationPanelView).setQsExpansionEnabled(true); |
| 523 | mStatusBar.animateExpandNotificationsPanel(); |
| 524 | verify(mNotificationPanelView).expand(anyBoolean()); |
| 525 | mStatusBar.animateExpandSettingsPanel(null); |
| 526 | verify(mNotificationPanelView).expand(anyBoolean()); |
| 527 | } |
| 528 | |
| 529 | @Test |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 530 | public void testDump_DoesNotCrash() { |
| 531 | mStatusBar.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); |
| 532 | } |
| 533 | |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 534 | @Test |
| 535 | @RunWithLooper(setAsMainLooper = true) |
| 536 | public void testUpdateKeyguardState_DoesNotCrash() { |
| 537 | mStatusBar.mStatusBarWindow = mock(StatusBarWindowView.class); |
| 538 | mStatusBar.mState = StatusBarState.KEYGUARD; |
| 539 | mStatusBar.mDozeScrimController = mock(DozeScrimController.class); |
| 540 | mStatusBar.mNotificationIconAreaController = mock(NotificationIconAreaController.class); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 541 | mStatusBar.mLockscreenUserManager = mock(NotificationLockscreenUserManager.class); |
| 542 | when(mStatusBar.mLockscreenUserManager.getCurrentProfiles()).thenReturn( |
| 543 | new SparseArray<>()); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 544 | mStatusBar.updateKeyguardState(false, false); |
| 545 | } |
| 546 | |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 547 | @Test |
| 548 | public void testFingerprintNotification_UpdatesScrims() { |
| 549 | mStatusBar.mStatusBarWindowManager = mock(StatusBarWindowManager.class); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 550 | mStatusBar.mDozeScrimController = mock(DozeScrimController.class); |
| 551 | mStatusBar.notifyFpAuthModeChanged(); |
| 552 | verify(mScrimController).transitionTo(any(), any()); |
| 553 | } |
| 554 | |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 555 | @Test |
| 556 | public void testFingerprintUnlock_UpdatesScrims() { |
| 557 | // Simulate unlocking from AoD with fingerprint. |
| 558 | when(mFingerprintUnlockController.getMode()) |
| 559 | .thenReturn(FingerprintUnlockController.MODE_WAKE_AND_UNLOCK); |
| 560 | mStatusBar.updateScrimController(); |
| 561 | verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); |
| 562 | } |
| 563 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 564 | static class TestableStatusBar extends StatusBar { |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 565 | public TestableStatusBar(StatusBarKeyguardViewManager man, |
| 566 | UnlockMethodCache unlock, KeyguardIndicationController key, |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 567 | NotificationStackScrollLayout stack, HeadsUpManager hum, NotificationData nd, |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 568 | PowerManager pm, SystemServicesProxy ssp, NotificationPanelView panelView, |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 569 | IStatusBarService barService, NotificationListener notificationListener, |
| 570 | NotificationLogger notificationLogger, ScrimController scrimController, |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 571 | FingerprintUnlockController fingerprintUnlockController) { |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 572 | mStatusBarKeyguardViewManager = man; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 573 | mUnlockMethodCache = unlock; |
| 574 | mKeyguardIndicationController = key; |
| 575 | mStackScroller = stack; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 576 | mHeadsUpManager = hum; |
| 577 | mNotificationData = nd; |
| 578 | mUseHeadsUp = true; |
| 579 | mPowerManager = pm; |
| 580 | mSystemServicesProxy = ssp; |
Jorim Jaggi | fd3b1a1 | 2017-06-06 17:04:19 -0700 | [diff] [blame] | 581 | mNotificationPanel = panelView; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 582 | mBarService = barService; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame^] | 583 | mNotificationListener = notificationListener; |
| 584 | mNotificationLogger = notificationLogger; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 585 | mWakefulnessLifecycle = createAwakeWakefulnessLifecycle(); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 586 | mScrimController = scrimController; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 587 | mFingerprintUnlockController = fingerprintUnlockController; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | private WakefulnessLifecycle createAwakeWakefulnessLifecycle() { |
| 591 | WakefulnessLifecycle wakefulnessLifecycle = new WakefulnessLifecycle(); |
| 592 | wakefulnessLifecycle.dispatchStartedWakingUp(); |
| 593 | wakefulnessLifecycle.dispatchFinishedWakingUp(); |
| 594 | return wakefulnessLifecycle; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 595 | } |
| 596 | |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 597 | @Override |
| 598 | protected void updateTheme() { |
| 599 | // Do nothing for now, until we have more mocking and StatusBar is smaller. |
| 600 | } |
| 601 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 602 | public void setBarStateForTest(int state) { |
| 603 | mState = state; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 604 | } |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 605 | |
| 606 | public void setUserSetupForTest(boolean userSetup) { |
| 607 | mUserSetup = userSetup; |
| 608 | } |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 609 | } |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 610 | } |