Dismiss user dialog when keyguard is going away.
Register a keyguard update callback to listen to when keyguard is going away. Dismiss dialog if so. Fixes: 260805106 Test: open userswitcher dialog and authenticate with fingerprint. Change-Id: I36614c86fa681c747cd98401363b763a5f41a8f3
This commit is contained in:
@@ -704,6 +704,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
if (mKeyguardGoingAway) {
|
||||
updateFaceListeningState(BIOMETRIC_ACTION_STOP,
|
||||
FACE_AUTH_STOPPED_KEYGUARD_GOING_AWAY);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onKeyguardGoingAway();
|
||||
}
|
||||
}
|
||||
}
|
||||
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||
}
|
||||
|
||||
@@ -317,4 +317,9 @@ public class KeyguardUpdateMonitorCallback {
|
||||
* Called when the non-strong biometric state changed.
|
||||
*/
|
||||
public void onNonStrongBiometricAllowedChanged(int userId) { }
|
||||
|
||||
/**
|
||||
* Called when keyguard is going away or not going away.
|
||||
*/
|
||||
public void onKeyguardGoingAway() { }
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import android.os.UserManager
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import com.android.internal.util.UserIcons
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.SystemUISecondaryUserService
|
||||
import com.android.systemui.animation.Expandable
|
||||
@@ -90,6 +92,7 @@ constructor(
|
||||
@Application private val applicationScope: CoroutineScope,
|
||||
telephonyInteractor: TelephonyInteractor,
|
||||
broadcastDispatcher: BroadcastDispatcher,
|
||||
keyguardUpdateMonitor: KeyguardUpdateMonitor,
|
||||
@Background private val backgroundDispatcher: CoroutineDispatcher,
|
||||
private val activityManager: ActivityManager,
|
||||
private val refreshUsersScheduler: RefreshUsersScheduler,
|
||||
@@ -286,6 +289,12 @@ constructor(
|
||||
|
||||
val isSimpleUserSwitcher: Boolean
|
||||
get() = repository.isSimpleUserSwitcher()
|
||||
val keyguardUpdateMonitorCallback =
|
||||
object : KeyguardUpdateMonitorCallback() {
|
||||
override fun onKeyguardGoingAway() {
|
||||
dismissDialog()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
refreshUsersScheduler.refreshIfNotPaused()
|
||||
@@ -316,6 +325,7 @@ constructor(
|
||||
onBroadcastReceived(intent, previousSelectedUser)
|
||||
}
|
||||
.launchIn(applicationScope)
|
||||
keyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback)
|
||||
}
|
||||
|
||||
fun addCallback(callback: UserCallback) {
|
||||
|
||||
@@ -29,6 +29,8 @@ import android.os.UserManager
|
||||
import android.provider.Settings
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||
import com.android.systemui.GuestResetOrExitSessionReceiver
|
||||
import com.android.systemui.GuestResumeSessionReceiver
|
||||
import com.android.systemui.R
|
||||
@@ -62,6 +64,7 @@ import com.android.systemui.util.mockito.mock
|
||||
import com.android.systemui.util.mockito.nullable
|
||||
import com.android.systemui.util.mockito.whenever
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import junit.framework.Assert.assertNotNull
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
@@ -72,6 +75,7 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.ArgumentMatchers.anyBoolean
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mock
|
||||
@@ -96,6 +100,7 @@ class UserInteractorTest : SysuiTestCase() {
|
||||
@Mock private lateinit var resumeSessionReceiver: GuestResumeSessionReceiver
|
||||
@Mock private lateinit var resetOrExitSessionReceiver: GuestResetOrExitSessionReceiver
|
||||
@Mock private lateinit var commandQueue: CommandQueue
|
||||
@Mock private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
|
||||
private lateinit var underTest: UserInteractor
|
||||
|
||||
@@ -154,6 +159,7 @@ class UserInteractorTest : SysuiTestCase() {
|
||||
repository = telephonyRepository,
|
||||
),
|
||||
broadcastDispatcher = fakeBroadcastDispatcher,
|
||||
keyguardUpdateMonitor = keyguardUpdateMonitor,
|
||||
backgroundDispatcher = testDispatcher,
|
||||
activityManager = activityManager,
|
||||
refreshUsersScheduler = refreshUsersScheduler,
|
||||
@@ -176,6 +182,18 @@ class UserInteractorTest : SysuiTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `testKeyguardUpdateMonitor_onKeyguardGoingAway`() =
|
||||
testScope.runTest {
|
||||
val argumentCaptor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
||||
verify(keyguardUpdateMonitor).registerCallback(argumentCaptor.capture())
|
||||
|
||||
argumentCaptor.value.onKeyguardGoingAway()
|
||||
|
||||
val lastValue = collectLastValue(underTest.dialogDismissRequests)
|
||||
assertNotNull(lastValue)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `onRecordSelected - user`() =
|
||||
testScope.runTest {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.UserManager
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.systemui.GuestResetOrExitSessionReceiver
|
||||
import com.android.systemui.GuestResumeSessionReceiver
|
||||
import com.android.systemui.SysuiTestCase
|
||||
@@ -80,6 +81,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
|
||||
@Mock private lateinit var resumeSessionReceiver: GuestResumeSessionReceiver
|
||||
@Mock private lateinit var resetOrExitSessionReceiver: GuestResetOrExitSessionReceiver
|
||||
@Mock private lateinit var commandQueue: CommandQueue
|
||||
@Mock private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
|
||||
private lateinit var underTest: StatusBarUserChipViewModel
|
||||
|
||||
@@ -263,6 +265,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
|
||||
repository = FakeTelephonyRepository(),
|
||||
),
|
||||
broadcastDispatcher = fakeBroadcastDispatcher,
|
||||
keyguardUpdateMonitor = keyguardUpdateMonitor,
|
||||
backgroundDispatcher = testDispatcher,
|
||||
activityManager = activityManager,
|
||||
refreshUsersScheduler = refreshUsersScheduler,
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.pm.UserInfo
|
||||
import android.os.UserManager
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.systemui.GuestResetOrExitSessionReceiver
|
||||
import com.android.systemui.GuestResumeSessionReceiver
|
||||
import com.android.systemui.SysuiTestCase
|
||||
@@ -81,6 +82,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
|
||||
@Mock private lateinit var resumeSessionReceiver: GuestResumeSessionReceiver
|
||||
@Mock private lateinit var resetOrExitSessionReceiver: GuestResetOrExitSessionReceiver
|
||||
@Mock private lateinit var commandQueue: CommandQueue
|
||||
@Mock private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
|
||||
private lateinit var underTest: UserSwitcherViewModel
|
||||
|
||||
@@ -165,6 +167,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
|
||||
repository = FakeTelephonyRepository(),
|
||||
),
|
||||
broadcastDispatcher = fakeBroadcastDispatcher,
|
||||
keyguardUpdateMonitor = keyguardUpdateMonitor,
|
||||
backgroundDispatcher = testDispatcher,
|
||||
activityManager = activityManager,
|
||||
refreshUsersScheduler = refreshUsersScheduler,
|
||||
|
||||
Reference in New Issue
Block a user