Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.keyguard; |
| 18 | |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 19 | import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE; |
| 20 | import static android.telephony.SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE; |
| 21 | |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 22 | import static com.google.common.truth.Truth.assertThat; |
| 23 | |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 24 | import static org.mockito.ArgumentMatchers.any; |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 25 | import static org.mockito.ArgumentMatchers.anyBoolean; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 26 | import static org.mockito.ArgumentMatchers.anyInt; |
| 27 | import static org.mockito.ArgumentMatchers.anyString; |
Lucas Dupin | f2c5350 | 2019-10-03 13:56:18 -0700 | [diff] [blame] | 28 | import static org.mockito.ArgumentMatchers.eq; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 29 | import static org.mockito.Mockito.atLeastOnce; |
Lucas Dupin | 8eec268 | 2019-07-01 16:41:17 -0700 | [diff] [blame] | 30 | import static org.mockito.Mockito.clearInvocations; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 31 | import static org.mockito.Mockito.doAnswer; |
| 32 | import static org.mockito.Mockito.never; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 33 | import static org.mockito.Mockito.spy; |
| 34 | import static org.mockito.Mockito.verify; |
| 35 | import static org.mockito.Mockito.when; |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 36 | |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 37 | import android.app.admin.DevicePolicyManager; |
| 38 | import android.app.trust.TrustManager; |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 39 | import android.content.Context; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 40 | import android.content.Intent; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 41 | import android.content.IntentFilter; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 42 | import android.content.pm.PackageManager; |
| 43 | import android.hardware.biometrics.BiometricManager; |
| 44 | import android.hardware.biometrics.BiometricSourceType; |
| 45 | import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; |
| 46 | import android.hardware.face.FaceManager; |
| 47 | import android.hardware.fingerprint.FingerprintManager; |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 48 | import android.os.Bundle; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 49 | import android.os.Handler; |
| 50 | import android.os.UserHandle; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 51 | import android.os.UserManager; |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 52 | import android.telephony.ServiceState; |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 53 | import android.telephony.SubscriptionInfo; |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 54 | import android.telephony.SubscriptionManager; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 55 | import android.test.suitebuilder.annotation.SmallTest; |
| 56 | import android.testing.AndroidTestingRunner; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 57 | import android.testing.TestableContext; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 58 | import android.testing.TestableLooper; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 59 | |
| 60 | import com.android.internal.telephony.IccCardConstants; |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 61 | import com.android.internal.telephony.PhoneConstants; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 62 | import com.android.internal.telephony.TelephonyIntents; |
Lucas Dupin | 64171fe | 2019-10-30 14:28:29 -0700 | [diff] [blame] | 63 | import com.android.systemui.DumpController; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 64 | import com.android.systemui.SysuiTestCase; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 65 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Lucas Dupin | 4befb74 | 2019-07-01 11:31:31 -0700 | [diff] [blame] | 66 | import com.android.systemui.statusbar.phone.KeyguardBypassController; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 67 | |
| 68 | import org.junit.Assert; |
| 69 | import org.junit.Before; |
| 70 | import org.junit.Test; |
| 71 | import org.junit.runner.RunWith; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 72 | import org.mockito.Mock; |
| 73 | import org.mockito.MockitoAnnotations; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 74 | |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 75 | import java.util.ArrayList; |
| 76 | import java.util.List; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 77 | import java.util.concurrent.atomic.AtomicBoolean; |
| 78 | |
| 79 | @SmallTest |
| 80 | @RunWith(AndroidTestingRunner.class) |
Dave Mankoff | e229469 | 2019-08-14 11:53:13 -0400 | [diff] [blame] | 81 | @TestableLooper.RunWithLooper |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 82 | public class KeyguardUpdateMonitorTest extends SysuiTestCase { |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 83 | private static final String TEST_CARRIER = "TEST_CARRIER"; |
| 84 | private static final String TEST_CARRIER_2 = "TEST_CARRIER_2"; |
| 85 | private static final int TEST_CARRIER_ID = 1; |
| 86 | private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24"; |
| 87 | private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(1, "", 0, |
| 88 | TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", |
| 89 | DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID, |
| 90 | TEST_CARRIER_ID, 0); |
| 91 | private static final SubscriptionInfo TEST_SUBSCRIPTION_2 = new SubscriptionInfo(2, "", 0, |
| 92 | TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", |
| 93 | DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID, |
| 94 | TEST_CARRIER_ID, 0); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 95 | @Mock |
Lucas Dupin | 64171fe | 2019-10-30 14:28:29 -0700 | [diff] [blame] | 96 | private DumpController mDumpController; |
| 97 | @Mock |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 98 | private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker; |
| 99 | @Mock |
| 100 | private TrustManager mTrustManager; |
| 101 | @Mock |
| 102 | private FingerprintManager mFingerprintManager; |
| 103 | @Mock |
| 104 | private FaceManager mFaceManager; |
| 105 | @Mock |
| 106 | private BiometricManager mBiometricManager; |
| 107 | @Mock |
| 108 | private PackageManager mPackageManager; |
| 109 | @Mock |
| 110 | private UserManager mUserManager; |
| 111 | @Mock |
| 112 | private DevicePolicyManager mDevicePolicyManager; |
Lucas Dupin | 4befb74 | 2019-07-01 11:31:31 -0700 | [diff] [blame] | 113 | @Mock |
| 114 | private KeyguardBypassController mKeyguardBypassController; |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 115 | @Mock |
| 116 | private SubscriptionManager mSubscriptionManager; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 117 | @Mock |
| 118 | private BroadcastDispatcher mBroadcastDispatcher; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 119 | private TestableLooper mTestableLooper; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 120 | private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 121 | |
| 122 | @Before |
| 123 | public void setup() { |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 124 | MockitoAnnotations.initMocks(this); |
| 125 | TestableContext context = spy(mContext); |
| 126 | when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true); |
| 127 | when(context.getPackageManager()).thenReturn(mPackageManager); |
| 128 | doAnswer(invocation -> { |
| 129 | IBiometricEnabledOnKeyguardCallback callback = invocation.getArgument(0); |
Lucas Dupin | 7d95f15 | 2019-07-17 16:25:54 -0700 | [diff] [blame] | 130 | callback.onChanged(BiometricSourceType.FACE, true /* enabled */, |
| 131 | KeyguardUpdateMonitor.getCurrentUser()); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 132 | return null; |
| 133 | }).when(mBiometricManager).registerEnabledOnKeyguardCallback(any()); |
| 134 | when(mFaceManager.isHardwareDetected()).thenReturn(true); |
| 135 | when(mFaceManager.hasEnrolledTemplates()).thenReturn(true); |
| 136 | when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true); |
| 137 | when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true); |
Kevin Chyn | fdfd2d3 | 2019-03-01 14:52:15 -0800 | [diff] [blame] | 138 | when(mUserManager.isPrimaryUser()).thenReturn(true); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 139 | when(mStrongAuthTracker.isUnlockingWithBiometricAllowed()).thenReturn(true); |
| 140 | context.addMockSystemService(TrustManager.class, mTrustManager); |
| 141 | context.addMockSystemService(FingerprintManager.class, mFingerprintManager); |
| 142 | context.addMockSystemService(BiometricManager.class, mBiometricManager); |
| 143 | context.addMockSystemService(FaceManager.class, mFaceManager); |
| 144 | context.addMockSystemService(UserManager.class, mUserManager); |
| 145 | context.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager); |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 146 | context.addMockSystemService(SubscriptionManager.class, mSubscriptionManager); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 147 | |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 148 | mTestableLooper = TestableLooper.get(this); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 149 | mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(context); |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | @Test |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 153 | public void testReceiversRegistered() { |
| 154 | verify(mBroadcastDispatcher, atLeastOnce()).registerReceiver( |
| 155 | eq(mKeyguardUpdateMonitor.mBroadcastReceiver), |
| 156 | any(IntentFilter.class), any(Handler.class)); |
| 157 | verify(mBroadcastDispatcher, atLeastOnce()).registerReceiver( |
| 158 | eq(mKeyguardUpdateMonitor.mBroadcastAllReceiver), |
| 159 | any(IntentFilter.class), any(Handler.class), eq(UserHandle.ALL)); |
| 160 | } |
| 161 | |
| 162 | @Test |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 163 | public void testIgnoresSimStateCallback_rebroadcast() { |
| 164 | Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 165 | |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 166 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(), intent); |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 167 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 168 | Assert.assertTrue("onSimStateChanged not called", |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 169 | mKeyguardUpdateMonitor.hasSimStateJustChanged()); |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 170 | |
| 171 | intent.putExtra(TelephonyIntents.EXTRA_REBROADCAST_ON_UNLOCK, true); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 172 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(), intent); |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 173 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 174 | Assert.assertFalse("onSimStateChanged should have been skipped", |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 175 | mKeyguardUpdateMonitor.hasSimStateJustChanged()); |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 178 | @Test |
| 179 | public void testTelephonyCapable_BootInitState() { |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 180 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | @Test |
| 184 | public void testTelephonyCapable_SimState_Absent() { |
| 185 | Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
andychou | 695a760 | 2019-05-16 23:14:00 +0800 | [diff] [blame] | 186 | intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, |
| 187 | IccCardConstants.INTENT_VALUE_ICC_ABSENT); |
| 188 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(), |
| 189 | putPhoneInfo(intent, null, false)); |
| 190 | mTestableLooper.processAllMessages(); |
| 191 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); |
| 192 | } |
| 193 | |
| 194 | @Test |
| 195 | public void testTelephonyCapable_SimState_CardIOError() { |
| 196 | Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 197 | intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, |
| 198 | IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); |
| 199 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(), |
| 200 | putPhoneInfo(intent, null, false)); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 201 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 202 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | @Test |
| 206 | public void testTelephonyCapable_SimInvalid_ServiceState_InService() { |
| 207 | // SERVICE_STATE - IN_SERVICE, but SIM_STATE is invalid TelephonyCapable should be False |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 208 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 209 | Bundle data = new Bundle(); |
| 210 | ServiceState state = new ServiceState(); |
| 211 | state.setState(ServiceState.STATE_IN_SERVICE); |
| 212 | state.fillInNotifierBundle(data); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 213 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 214 | , putPhoneInfo(intent, data, false)); |
| 215 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 216 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | @Test |
| 220 | public void testTelephonyCapable_SimValid_ServiceState_PowerOff() { |
| 221 | // Simulate AirplaneMode case, SERVICE_STATE - POWER_OFF, check TelephonyCapable False |
| 222 | // Only receive ServiceState callback IN_SERVICE -> OUT_OF_SERVICE -> POWER_OFF |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 223 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 224 | intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE |
| 225 | , IccCardConstants.INTENT_VALUE_ICC_LOADED); |
| 226 | Bundle data = new Bundle(); |
| 227 | ServiceState state = new ServiceState(); |
| 228 | state.setState(ServiceState.STATE_POWER_OFF); |
| 229 | state.fillInNotifierBundle(data); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 230 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 231 | , putPhoneInfo(intent, data, true)); |
| 232 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 233 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* Normal SIM inserted flow |
| 237 | * ServiceState: ---OutOfServie----->PowerOff->OutOfServie--->InService |
| 238 | * SimState: ----NOT_READY---->READY----------------------LOADED>>> |
| 239 | * Subscription: --------null---->null--->"Chunghwa Telecom"-------->>> |
| 240 | * System: -------------------------------BOOT_COMPLETED------>>> |
| 241 | * TelephonyCapable:(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)------(T)-(T)>> |
| 242 | */ |
| 243 | @Test |
| 244 | public void testTelephonyCapable_BootInitState_ServiceState_OutOfService() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 245 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 246 | Bundle data = new Bundle(); |
| 247 | ServiceState state = new ServiceState(); |
| 248 | state.setState(ServiceState.STATE_OUT_OF_SERVICE); |
| 249 | state.fillInNotifierBundle(data); |
| 250 | intent.putExtras(data); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 251 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 252 | , putPhoneInfo(intent, data, false)); |
| 253 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 254 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | @Test |
| 258 | public void testTelephonyCapable_BootInitState_SimState_NotReady() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 259 | Bundle data = new Bundle(); |
| 260 | ServiceState state = new ServiceState(); |
| 261 | state.setState(ServiceState.STATE_OUT_OF_SERVICE); |
| 262 | state.fillInNotifierBundle(data); |
| 263 | Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 264 | intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE |
| 265 | , IccCardConstants.INTENT_VALUE_ICC_NOT_READY); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 266 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 267 | , putPhoneInfo(intent, data, false)); |
| 268 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 269 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | @Test |
| 273 | public void testTelephonyCapable_BootInitState_SimState_Ready() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 274 | Bundle data = new Bundle(); |
| 275 | ServiceState state = new ServiceState(); |
| 276 | state.setState(ServiceState.STATE_OUT_OF_SERVICE); |
| 277 | state.fillInNotifierBundle(data); |
| 278 | Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 279 | intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE |
| 280 | , IccCardConstants.INTENT_VALUE_ICC_READY); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 281 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 282 | , putPhoneInfo(intent, data, false)); |
| 283 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 284 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | @Test |
| 288 | public void testTelephonyCapable_BootInitState_ServiceState_PowerOff() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 289 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 290 | Bundle data = new Bundle(); |
| 291 | ServiceState state = new ServiceState(); |
| 292 | state.setState(ServiceState.STATE_POWER_OFF); |
| 293 | state.fillInNotifierBundle(data); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 294 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 295 | , putPhoneInfo(intent, data, false)); |
| 296 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 297 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | @Test |
| 301 | public void testTelephonyCapable_SimValid_ServiceState_InService() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 302 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 303 | Bundle data = new Bundle(); |
| 304 | ServiceState state = new ServiceState(); |
| 305 | state.setState(ServiceState.STATE_IN_SERVICE); |
| 306 | state.fillInNotifierBundle(data); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 307 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 308 | , putPhoneInfo(intent, data, true)); |
| 309 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 310 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | @Test |
| 314 | public void testTelephonyCapable_SimValid_SimState_Loaded() { |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 315 | Bundle data = new Bundle(); |
| 316 | ServiceState state = new ServiceState(); |
| 317 | state.setState(ServiceState.STATE_IN_SERVICE); |
| 318 | state.fillInNotifierBundle(data); |
| 319 | Intent intentSimState = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 320 | intentSimState.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE |
| 321 | , IccCardConstants.INTENT_VALUE_ICC_LOADED); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 322 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 323 | , putPhoneInfo(intentSimState, data, true)); |
| 324 | mTestableLooper.processAllMessages(); |
| 325 | // Even SimState Loaded, still need ACTION_SERVICE_STATE_CHANGED turn on mTelephonyCapable |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 326 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isFalse(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 327 | |
| 328 | Intent intentServiceState = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 329 | intentSimState.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE |
| 330 | , IccCardConstants.INTENT_VALUE_ICC_LOADED); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 331 | mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext() |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 332 | , putPhoneInfo(intentServiceState, data, true)); |
| 333 | mTestableLooper.processAllMessages(); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 334 | assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); |
| 335 | } |
| 336 | |
| 337 | @Test |
| 338 | public void testTriesToAuthenticate_whenBouncer() { |
| 339 | mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); |
| 340 | mTestableLooper.processAllMessages(); |
| 341 | |
Kevin Chyn | 8d2694a | 2019-04-11 18:30:40 -0700 | [diff] [blame] | 342 | verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 343 | verify(mFaceManager).isHardwareDetected(); |
| 344 | verify(mFaceManager).hasEnrolledTemplates(anyInt()); |
| 345 | } |
| 346 | |
| 347 | @Test |
| 348 | public void testTriesToAuthenticate_whenKeyguard() { |
| 349 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 350 | mTestableLooper.processAllMessages(); |
| 351 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
Kevin Chyn | 8d2694a | 2019-04-11 18:30:40 -0700 | [diff] [blame] | 352 | verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | @Test |
| 356 | public void skipsAuthentication_whenEncryptedKeyguard() { |
Lucas Dupin | 8eec268 | 2019-07-01 16:41:17 -0700 | [diff] [blame] | 357 | when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( |
| 358 | KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT); |
| 359 | mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 360 | |
| 361 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 362 | mTestableLooper.processAllMessages(); |
| 363 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
Lucas Dupin | 8eec268 | 2019-07-01 16:41:17 -0700 | [diff] [blame] | 364 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 365 | } |
| 366 | |
| 367 | @Test |
| 368 | public void requiresAuthentication_whenEncryptedKeyguard_andBypass() { |
| 369 | testStrongAuthExceptOnBouncer( |
| 370 | KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT); |
| 371 | } |
| 372 | |
| 373 | @Test |
| 374 | public void requiresAuthentication_whenTimeoutKeyguard_andBypass() { |
| 375 | testStrongAuthExceptOnBouncer( |
| 376 | KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT); |
| 377 | } |
| 378 | |
| 379 | private void testStrongAuthExceptOnBouncer(int strongAuth) { |
| 380 | when(mKeyguardBypassController.canBypass()).thenReturn(true); |
| 381 | mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); |
| 382 | when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(strongAuth); |
| 383 | |
| 384 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 385 | mTestableLooper.processAllMessages(); |
| 386 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
| 387 | verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 388 | |
| 389 | // Stop scanning when bouncer becomes visible |
| 390 | mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true /* showingBouncer */); |
| 391 | mTestableLooper.processAllMessages(); |
| 392 | clearInvocations(mFaceManager); |
| 393 | mKeyguardUpdateMonitor.requestFaceAuth(); |
| 394 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | @Test |
| 398 | public void testTriesToAuthenticate_whenAssistant() { |
| 399 | mKeyguardUpdateMonitor.setKeyguardOccluded(true); |
| 400 | mKeyguardUpdateMonitor.setAssistantVisible(true); |
| 401 | |
Kevin Chyn | 8d2694a | 2019-04-11 18:30:40 -0700 | [diff] [blame] | 402 | verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | @Test |
Lucas Dupin | 4befb74 | 2019-07-01 11:31:31 -0700 | [diff] [blame] | 406 | public void testTriesToAuthenticate_whenTrustOnAgentKeyguard_ifBypass() { |
| 407 | mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); |
| 408 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 409 | mTestableLooper.processAllMessages(); |
| 410 | when(mKeyguardBypassController.canBypass()).thenReturn(true); |
| 411 | mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, |
| 412 | KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); |
| 413 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
| 414 | verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 415 | } |
| 416 | |
| 417 | @Test |
| 418 | public void testIgnoresAuth_whenTrustAgentOnKeyguard_withoutBypass() { |
| 419 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 420 | mTestableLooper.processAllMessages(); |
| 421 | mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, |
| 422 | KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */); |
| 423 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
| 424 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 425 | } |
| 426 | |
| 427 | @Test |
Lucas Dupin | 8eec268 | 2019-07-01 16:41:17 -0700 | [diff] [blame] | 428 | public void testIgnoresAuth_whenLockdown() { |
| 429 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 430 | mTestableLooper.processAllMessages(); |
| 431 | when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( |
| 432 | KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN); |
| 433 | |
| 434 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
| 435 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 436 | } |
| 437 | |
| 438 | @Test |
| 439 | public void testIgnoresAuth_whenLockout() { |
| 440 | mKeyguardUpdateMonitor.dispatchStartedWakingUp(); |
| 441 | mTestableLooper.processAllMessages(); |
| 442 | when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( |
| 443 | KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT); |
| 444 | |
| 445 | mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); |
| 446 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); |
| 447 | } |
| 448 | |
| 449 | @Test |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 450 | public void testOnFaceAuthenticated_skipsFaceWhenAuthenticated() { |
| 451 | mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser()); |
| 452 | mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); |
| 453 | mTestableLooper.processAllMessages(); |
| 454 | |
| 455 | verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any()); |
| 456 | } |
| 457 | |
| 458 | @Test |
| 459 | public void testGetUserCanSkipBouncer_whenFace() { |
| 460 | int user = KeyguardUpdateMonitor.getCurrentUser(); |
| 461 | mKeyguardUpdateMonitor.onFaceAuthenticated(user); |
| 462 | assertThat(mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)).isTrue(); |
| 463 | } |
| 464 | |
| 465 | @Test |
| 466 | public void testGetUserCanSkipBouncer_whenFingerprint() { |
| 467 | int user = KeyguardUpdateMonitor.getCurrentUser(); |
| 468 | mKeyguardUpdateMonitor.onFingerprintAuthenticated(user); |
| 469 | assertThat(mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)).isTrue(); |
| 470 | } |
| 471 | |
| 472 | @Test |
| 473 | public void testGetUserCanSkipBouncer_whenTrust() { |
| 474 | int user = KeyguardUpdateMonitor.getCurrentUser(); |
| 475 | mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, user, 0 /* flags */); |
| 476 | assertThat(mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)).isTrue(); |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 477 | } |
| 478 | |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 479 | @Test |
| 480 | public void testGetSubscriptionInfo_whenInGroupedSubWithOpportunistic() { |
| 481 | List<SubscriptionInfo> list = new ArrayList<>(); |
| 482 | list.add(TEST_SUBSCRIPTION); |
| 483 | list.add(TEST_SUBSCRIPTION_2); |
| 484 | when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(list); |
| 485 | mKeyguardUpdateMonitor.mPhoneStateListener.onActiveDataSubscriptionIdChanged( |
| 486 | TEST_SUBSCRIPTION_2.getSubscriptionId()); |
| 487 | mTestableLooper.processAllMessages(); |
| 488 | |
| 489 | List<SubscriptionInfo> listToVerify = mKeyguardUpdateMonitor |
| 490 | .getFilteredSubscriptionInfo(false); |
| 491 | assertThat(listToVerify.size()).isEqualTo(1); |
| 492 | assertThat(listToVerify.get(0)).isEqualTo(TEST_SUBSCRIPTION_2); |
| 493 | } |
| 494 | |
Lucas Dupin | 6c6d573 | 2019-08-27 17:36:05 -0700 | [diff] [blame] | 495 | @Test |
| 496 | public void testIsUserUnlocked() { |
| 497 | // mUserManager will report the user as unlocked on @Before |
| 498 | assertThat(mKeyguardUpdateMonitor.isUserUnlocked(KeyguardUpdateMonitor.getCurrentUser())) |
| 499 | .isTrue(); |
| 500 | // Invalid user should not be unlocked. |
| 501 | int randomUser = 99; |
| 502 | assertThat(mKeyguardUpdateMonitor.isUserUnlocked(randomUser)).isFalse(); |
| 503 | } |
| 504 | |
Lucas Dupin | f2c5350 | 2019-10-03 13:56:18 -0700 | [diff] [blame] | 505 | @Test |
| 506 | public void testTrustUsuallyManaged_whenTrustChanges() { |
| 507 | int user = KeyguardUpdateMonitor.getCurrentUser(); |
| 508 | when(mTrustManager.isTrustUsuallyManaged(eq(user))).thenReturn(true); |
| 509 | mKeyguardUpdateMonitor.onTrustManagedChanged(false /* managed */, user); |
| 510 | assertThat(mKeyguardUpdateMonitor.isTrustUsuallyManaged(user)).isTrue(); |
| 511 | } |
| 512 | |
| 513 | @Test |
| 514 | public void testTrustUsuallyManaged_resetWhenUserIsRemoved() { |
| 515 | int user = KeyguardUpdateMonitor.getCurrentUser(); |
| 516 | when(mTrustManager.isTrustUsuallyManaged(eq(user))).thenReturn(true); |
| 517 | mKeyguardUpdateMonitor.onTrustManagedChanged(false /* managed */, user); |
| 518 | assertThat(mKeyguardUpdateMonitor.isTrustUsuallyManaged(user)).isTrue(); |
| 519 | |
| 520 | mKeyguardUpdateMonitor.handleUserRemoved(user); |
| 521 | assertThat(mKeyguardUpdateMonitor.isTrustUsuallyManaged(user)).isFalse(); |
| 522 | } |
| 523 | |
Bill Lin | ef81cbd | 2018-07-05 17:48:49 +0800 | [diff] [blame] | 524 | private Intent putPhoneInfo(Intent intent, Bundle data, Boolean simInited) { |
| 525 | int subscription = simInited |
| 526 | ? 1/* mock subid=1 */ : SubscriptionManager.DUMMY_SUBSCRIPTION_ID_BASE; |
| 527 | if (data != null) intent.putExtras(data); |
| 528 | intent.putExtra(PhoneConstants.PHONE_NAME_KEY, "Phone"); |
| 529 | intent.putExtra("subscription", subscription); |
| 530 | intent.putExtra("slot", 0/* SLOT 1 */); |
| 531 | return intent; |
| 532 | } |
| 533 | |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 534 | private class TestableKeyguardUpdateMonitor extends KeyguardUpdateMonitor { |
| 535 | AtomicBoolean mSimStateChanged = new AtomicBoolean(false); |
| 536 | |
| 537 | protected TestableKeyguardUpdateMonitor(Context context) { |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 538 | super(context, |
| 539 | TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(), |
| 540 | mBroadcastDispatcher, mDumpController); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 541 | mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker; |
Lucas Dupin | 7ff82b0 | 2018-05-16 12:14:10 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | public boolean hasSimStateJustChanged() { |
| 545 | return mSimStateChanged.getAndSet(false); |
| 546 | } |
| 547 | |
| 548 | @Override |
| 549 | protected void handleSimStateChange(int subId, int slotId, |
| 550 | IccCardConstants.State state) { |
| 551 | mSimStateChanged.set(true); |
| 552 | super.handleSimStateChange(subId, slotId, state); |
| 553 | } |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 554 | } |
| 555 | } |