summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/values/config.xml14
-rw-r--r--packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractor.kt67
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractor.kt31
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/kotlin/Utils.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerBaseTest.java13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java67
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractorKosmos.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/DevicePostureRepositoryKosmos.kt22
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractorKosmos.kt29
10 files changed, 210 insertions, 62 deletions
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index e181d079fc6d..45243eeb9007 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -718,6 +718,20 @@
<item>26</item> <!-- MOUTH_COVERING_DETECTED -->
</integer-array>
+ <!-- Which face help messages to surface when fingerprint is enrolled and device is unfolded.
+ Message ids correspond with the acquired ids in BiometricFaceConstants -->
+ <integer-array name="config_face_help_msgs_when_fingerprint_enrolled_unfolded">
+ <item>3</item> <!-- TOO_DARK -->
+ <item>4</item> <!-- TOO_CLOSE -->
+ <item>5</item> <!-- TOO_FAR -->
+ <item>6</item> <!-- TOO_HIGH -->
+ <item>7</item> <!-- TOO_LOW -->
+ <item>8</item> <!-- TOO_RIGHT -->
+ <item>9</item> <!-- TOO_LEFT -->
+ <item>25</item> <!-- DARK_GLASSES -->
+ <item>26</item> <!-- MOUTH_COVERING_DETECTED -->
+ </integer-array>
+
<!-- Which device wake-ups will trigger passive auth. These values correspond with
PowerManager#WakeReason. -->
<integer-array name="config_face_auth_wake_up_triggers">
diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractor.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractor.kt
index 846013cef326..e6dfbb650928 100644
--- a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractor.kt
@@ -30,17 +30,20 @@ import com.android.systemui.deviceentry.shared.model.FingerprintFailureMessage
import com.android.systemui.deviceentry.shared.model.FingerprintLockoutMessage
import com.android.systemui.deviceentry.shared.model.FingerprintMessage
import com.android.systemui.deviceentry.shared.model.HelpFaceAuthenticationStatus
+import com.android.systemui.keyguard.domain.interactor.DevicePostureInteractor
+import com.android.systemui.keyguard.shared.model.DevicePosture
import com.android.systemui.keyguard.shared.model.ErrorFingerprintAuthenticationStatus
import com.android.systemui.res.R
-import com.android.systemui.util.kotlin.Utils.Companion.toTriple
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.filterNot
import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
@@ -59,6 +62,7 @@ constructor(
faceAuthInteractor: DeviceEntryFaceAuthInteractor,
private val biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
faceHelpMessageDeferralInteractor: FaceHelpMessageDeferralInteractor,
+ devicePostureInteractor: DevicePostureInteractor,
) {
private val faceHelp: Flow<HelpFaceAuthenticationStatus> =
faceAuthInteractor.authenticationStatus.filterIsInstance<HelpFaceAuthenticationStatus>()
@@ -71,9 +75,18 @@ constructor(
* The acquisition message ids to show message when both fingerprint and face are enrolled and
* enabled for device entry.
*/
- private val coExFaceAcquisitionMsgIdsToShow: Set<Int> =
+ private val coExFaceAcquisitionMsgIdsToShowDefault: Set<Int> =
resources.getIntArray(R.array.config_face_help_msgs_when_fingerprint_enrolled).toSet()
+ /**
+ * The acquisition message ids to show message when both fingerprint and face are enrolled and
+ * enabled for device entry and the device is unfolded.
+ */
+ private val coExFaceAcquisitionMsgIdsToShowUnfolded: Set<Int> =
+ resources
+ .getIntArray(R.array.config_face_help_msgs_when_fingerprint_enrolled_unfolded)
+ .toSet()
+
private fun ErrorFingerprintAuthenticationStatus.shouldSuppressError(): Boolean {
return isCancellationError() || isPowerPressedError()
}
@@ -122,6 +135,17 @@ constructor(
}
}
+ val coExFaceAcquisitionMsgIdsToShow: Flow<Set<Int>> =
+ devicePostureInteractor.posture.map { devicePosture ->
+ when (devicePosture) {
+ DevicePosture.OPENED -> coExFaceAcquisitionMsgIdsToShowUnfolded
+ DevicePosture.UNKNOWN, // Devices without posture support (non-foldable) use UNKNOWN
+ DevicePosture.CLOSED,
+ DevicePosture.HALF_OPENED,
+ DevicePosture.FLIPPED -> coExFaceAcquisitionMsgIdsToShowDefault
+ }
+ }
+
val fingerprintMessage: Flow<FingerprintMessage> =
merge(
fingerprintErrorMessage,
@@ -129,25 +153,38 @@ constructor(
fingerprintHelpMessage,
)
+ private val filterConditionForFaceHelpMessages:
+ Flow<(HelpFaceAuthenticationStatus) -> Boolean> =
+ combine(
+ biometricSettingsInteractor.fingerprintAndFaceEnrolledAndEnabled,
+ biometricSettingsInteractor.faceAuthCurrentlyAllowed,
+ ::Pair
+ )
+ .flatMapLatest { (faceAndFingerprintEnrolled, faceAuthCurrentlyAllowed) ->
+ if (faceAndFingerprintEnrolled && faceAuthCurrentlyAllowed) {
+ // Show only some face help messages if fingerprint is also enrolled
+ coExFaceAcquisitionMsgIdsToShow.map { msgIdsToShow ->
+ { helpStatus: HelpFaceAuthenticationStatus ->
+ msgIdsToShow.contains(helpStatus.msgId)
+ }
+ }
+ } else if (faceAuthCurrentlyAllowed) {
+ // Show all face help messages if only face is enrolled and currently allowed
+ flowOf { _: HelpFaceAuthenticationStatus -> true }
+ } else {
+ flowOf { _: HelpFaceAuthenticationStatus -> false }
+ }
+ }
+
private val faceHelpMessage: Flow<FaceMessage> =
faceHelp
.filterNot {
// Message deferred to potentially show at face timeout error instead
faceHelpMessageDeferralInteractor.shouldDefer(it.msgId)
}
- .sample(biometricSettingsInteractor.fingerprintAndFaceEnrolledAndEnabled, ::Pair)
- .filter { (faceAuthHelpStatus, fingerprintAndFaceEnrolledAndEnabled) ->
- if (fingerprintAndFaceEnrolledAndEnabled) {
- // Show only some face help messages if fingerprint is also enrolled
- coExFaceAcquisitionMsgIdsToShow.contains(faceAuthHelpStatus.msgId)
- } else {
- // Show all face help messages if only face is enrolled
- true
- }
- }
- .sample(biometricSettingsInteractor.faceAuthCurrentlyAllowed, ::toTriple)
- .filter { (_, _, faceAuthCurrentlyAllowed) -> faceAuthCurrentlyAllowed }
- .map { (status, _, _) -> FaceMessage(status.msg) }
+ .sample(filterConditionForFaceHelpMessages, ::Pair)
+ .filter { (helpMessage, filterCondition) -> filterCondition(helpMessage) }
+ .map { (status, _) -> FaceMessage(status.msg) }
private val faceFailureMessage: Flow<FaceMessage> =
faceFailure
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractor.kt
new file mode 100644
index 000000000000..e48cddb33aa4
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractor.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.domain.interactor
+
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.keyguard.data.repository.DevicePostureRepository
+import javax.inject.Inject
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+
+/** DevicePosture business logic. */
+@ExperimentalCoroutinesApi
+@SysUISingleton
+class DevicePostureInteractor
+@Inject
+constructor(devicePostureRepository: DevicePostureRepository) {
+ val posture = devicePostureRepository.currentDevicePosture
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 1963d641702a..0d2b3e10711d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -97,6 +97,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
+import com.android.systemui.deviceentry.domain.interactor.BiometricMessageInteractor;
import com.android.systemui.dock.DockManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.KeyguardIndication;
@@ -120,7 +121,6 @@ import com.android.systemui.util.wakelock.WakeLock;
import java.io.PrintWriter;
import java.text.NumberFormat;
-import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
@@ -181,6 +181,7 @@ public class KeyguardIndicationController {
private BroadcastReceiver mBroadcastReceiver;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private KeyguardInteractor mKeyguardInteractor;
+ private final BiometricMessageInteractor mBiometricMessageInteractor;
private String mPersistentUnlockMessage;
private String mAlignmentIndication;
private boolean mForceIsDismissible;
@@ -209,7 +210,7 @@ public class KeyguardIndicationController {
private boolean mBatteryPresent = true;
protected long mChargingTimeRemaining;
private Pair<String, BiometricSourceType> mBiometricErrorMessageToShowOnScreenOn;
- private final Set<Integer> mCoExFaceAcquisitionMsgIdsToShow;
+ private Set<Integer> mCoExFaceAcquisitionMsgIdsToShow;
private final FaceHelpMessageDeferral mFaceAcquiredMessageDeferral;
private boolean mInited;
@@ -227,6 +228,10 @@ public class KeyguardIndicationController {
mIsActiveDreamLockscreenHosted = isLockscreenHosted;
updateDeviceEntryIndication(false);
};
+ @VisibleForTesting
+ final Consumer<Set<Integer>> mCoExAcquisitionMsgIdsToShowCallback =
+ (Set<Integer> coExFaceAcquisitionMsgIdsToShow) -> mCoExFaceAcquisitionMsgIdsToShow =
+ coExFaceAcquisitionMsgIdsToShow;
private final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() {
@Override
public void onScreenTurnedOn() {
@@ -286,7 +291,8 @@ public class KeyguardIndicationController {
BouncerMessageInteractor bouncerMessageInteractor,
FeatureFlags flags,
IndicationHelper indicationHelper,
- KeyguardInteractor keyguardInteractor
+ KeyguardInteractor keyguardInteractor,
+ BiometricMessageInteractor biometricMessageInteractor
) {
mContext = context;
mBroadcastDispatcher = broadcastDispatcher;
@@ -315,14 +321,9 @@ public class KeyguardIndicationController {
mFeatureFlags = flags;
mIndicationHelper = indicationHelper;
mKeyguardInteractor = keyguardInteractor;
+ mBiometricMessageInteractor = biometricMessageInteractor;
mFaceAcquiredMessageDeferral = faceHelpMessageDeferral.create();
- mCoExFaceAcquisitionMsgIdsToShow = new HashSet<>();
- int[] msgIds = context.getResources().getIntArray(
- com.android.systemui.res.R.array.config_face_help_msgs_when_fingerprint_enrolled);
- for (int msgId : msgIds) {
- mCoExFaceAcquisitionMsgIdsToShow.add(msgId);
- }
mHandler = new Handler(mainLooper) {
@Override
@@ -369,7 +370,7 @@ public class KeyguardIndicationController {
mIndicationArea = indicationArea;
mTopIndicationView = indicationArea.findViewById(R.id.keyguard_indication_text);
mLockScreenIndicationView = indicationArea.findViewById(
- R.id.keyguard_indication_text_bottom);
+ R.id.keyguard_indication_text_bottom);
mInitialTextColorState = mTopIndicationView != null
? mTopIndicationView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
if (mRotateTextViewController != null) {
@@ -401,6 +402,10 @@ public class KeyguardIndicationController {
collectFlow(mIndicationArea, mKeyguardInteractor.isActiveDreamLockscreenHosted(),
mIsActiveDreamLockscreenHostedCallback);
}
+
+ collectFlow(mIndicationArea,
+ mBiometricMessageInteractor.getCoExFaceAcquisitionMsgIdsToShow(),
+ mCoExAcquisitionMsgIdsToShowCallback);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/util/kotlin/Utils.kt b/packages/SystemUI/src/com/android/systemui/util/kotlin/Utils.kt
index a88be065d722..405b57a1a04d 100644
--- a/packages/SystemUI/src/com/android/systemui/util/kotlin/Utils.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/kotlin/Utils.kt
@@ -28,6 +28,8 @@ class Utils {
fun <A, B, C, D> toQuad(a: A, b: B, c: C, d: D) = Quad(a, b, c, d)
fun <A, B, C, D> toQuad(a: A, bcd: Triple<B, C, D>) =
Quad(a, bcd.first, bcd.second, bcd.third)
+ fun <A, B, C, D> toQuad(abc: Triple<A, B, C>, d: D) =
+ Quad(abc.first, abc.second, abc.third, d)
fun <A, B, C, D, E> toQuint(a: A, b: B, c: C, d: D, e: E) = Quint(a, b, c, d, e)
fun <A, B, C, D, E> toQuint(a: A, bcde: Quad<B, C, D, E>) =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerBaseTest.java
index 2bd0d7963593..fe066ca2c318 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerBaseTest.java
@@ -32,6 +32,8 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static java.util.Collections.emptySet;
+
import android.app.AlarmManager;
import android.app.Instrumentation;
import android.app.admin.DevicePolicyManager;
@@ -62,6 +64,7 @@ import com.android.systemui.biometrics.FaceHelpMessageDeferralFactory;
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor;
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
import com.android.systemui.broadcast.BroadcastDispatcher;
+import com.android.systemui.deviceentry.domain.interactor.BiometricMessageInteractor;
import com.android.systemui.dock.DockManager;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.keyguard.KeyguardIndication;
@@ -81,6 +84,8 @@ import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;
import com.android.systemui.util.wakelock.WakeLockFake;
+import kotlinx.coroutines.flow.StateFlow;
+
import org.junit.After;
import org.junit.Before;
import org.mockito.ArgumentCaptor;
@@ -143,6 +148,8 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {
@Mock
protected AlternateBouncerInteractor mAlternateBouncerInteractor;
@Mock
+ protected BiometricMessageInteractor mBiometricMessageInteractor;
+ @Mock
protected ScreenLifecycle mScreenLifecycle;
@Mock
protected AuthController mAuthController;
@@ -226,6 +233,8 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {
when(mDevicePolicyResourcesManager.getString(anyString(), any(), anyString()))
.thenReturn(mDisclosureWithOrganization);
when(mUserTracker.getUserId()).thenReturn(mCurrentUserId);
+ when(mBiometricMessageInteractor.getCoExFaceAcquisitionMsgIdsToShow())
+ .thenReturn(mock(StateFlow.class));
when(mFaceHelpMessageDeferralFactory.create()).thenReturn(mFaceHelpMessageDeferral);
@@ -269,10 +278,12 @@ public class KeyguardIndicationControllerBaseTest extends SysuiTestCase {
mock(BouncerMessageInteractor.class),
mFlags,
mIndicationHelper,
- KeyguardInteractorFactory.create(mFlags).getKeyguardInteractor()
+ KeyguardInteractorFactory.create(mFlags).getKeyguardInteractor(),
+ mBiometricMessageInteractor
);
mController.init();
mController.setIndicationArea(mIndicationArea);
+ mController.mCoExAcquisitionMsgIdsToShowCallback.accept(emptySet());
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
mStatusBarStateListener = mStatusBarStateListenerCaptor.getValue();
verify(mBroadcastDispatcher).registerReceiver(mBroadcastReceiverCaptor.capture(), any());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
index 1504d4c1f033..1b1d70743aa7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
@@ -68,6 +68,7 @@ import android.os.RemoteException;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
@@ -88,8 +89,8 @@ import java.util.List;
import java.util.Set;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@RunWith(AndroidJUnit4.class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class KeyguardIndicationControllerTest extends KeyguardIndicationControllerBaseTest {
@Test
public void afterFaceLockout_skipShowingFaceNotRecognized() {
@@ -131,14 +132,11 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
@Test
public void onAlignmentStateChanged_showsSlowChargingIndication() {
- mInstrumentation.runOnMainSync(() -> {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
-
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
- });
- mInstrumentation.waitForIdleSync();
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
mTestableLooper.processAllMessages();
verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
@@ -149,14 +147,11 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
@Test
public void onAlignmentStateChanged_showsNotChargingIndication() {
- mInstrumentation.runOnMainSync(() -> {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
-
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
- });
- mInstrumentation.waitForIdleSync();
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
mTestableLooper.processAllMessages();
verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
@@ -168,15 +163,12 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
@FlakyTest(bugId = 279944472)
@Test
public void onAlignmentStateChanged_whileDozing_showsSlowChargingIndication() {
- mInstrumentation.runOnMainSync(() -> {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
- mStatusBarStateListener.onDozingChanged(true);
-
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
- });
- mInstrumentation.waitForIdleSync();
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+ mStatusBarStateListener.onDozingChanged(true);
+
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
mTestableLooper.processAllMessages();
assertThat(mTextView.getText()).isEqualTo(
@@ -187,15 +179,12 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
@Test
public void onAlignmentStateChanged_whileDozing_showsNotChargingIndication() {
- mInstrumentation.runOnMainSync(() -> {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
- mStatusBarStateListener.onDozingChanged(true);
-
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
- });
- mInstrumentation.waitForIdleSync();
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+ mStatusBarStateListener.onDozingChanged(true);
+
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
mTestableLooper.processAllMessages();
assertThat(mTextView.getText()).isEqualTo(
@@ -642,6 +631,12 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll
@Test
public void sendFaceHelpMessages_fingerprintEnrolled() {
createController();
+ mController.mCoExAcquisitionMsgIdsToShowCallback.accept(
+ Set.of(
+ BiometricFaceConstants.FACE_ACQUIRED_MOUTH_COVERING_DETECTED,
+ BiometricFaceConstants.FACE_ACQUIRED_DARK_GLASSES_DETECTED
+ )
+ );
// GIVEN unlocking with fingerprint is possible and allowed
fingerprintUnlockIsPossibleAndAllowed();
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractorKosmos.kt
index 3ea46872ebcf..77d39f066e08 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/BiometricMessageInteractorKosmos.kt
@@ -18,6 +18,7 @@ package com.android.systemui.deviceentry.domain.interactor
import android.content.res.mainResources
import com.android.systemui.biometrics.domain.interactor.fingerprintPropertyInteractor
+import com.android.systemui.keyguard.domain.interactor.devicePostureInteractor
import com.android.systemui.kosmos.Kosmos
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -31,5 +32,6 @@ val Kosmos.biometricMessageInteractor by
faceAuthInteractor = deviceEntryFaceAuthInteractor,
biometricSettingsInteractor = deviceEntryBiometricSettingsInteractor,
faceHelpMessageDeferralInteractor = faceHelpMessageDeferralInteractor,
+ devicePostureInteractor = devicePostureInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/DevicePostureRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/DevicePostureRepositoryKosmos.kt
new file mode 100644
index 000000000000..9bbb34c970d0
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/DevicePostureRepositoryKosmos.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.data.repository
+
+import com.android.systemui.kosmos.Kosmos
+
+val Kosmos.devicePostureRepository: DevicePostureRepository by
+ Kosmos.Fixture { FakeDevicePostureRepository() }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractorKosmos.kt
new file mode 100644
index 000000000000..75eb3c9ad7ad
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/DevicePostureInteractorKosmos.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.domain.interactor
+
+import com.android.systemui.keyguard.data.repository.devicePostureRepository
+import com.android.systemui.kosmos.Kosmos
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+
+@ExperimentalCoroutinesApi
+val Kosmos.devicePostureInteractor by
+ Kosmos.Fixture {
+ DevicePostureInteractor(
+ devicePostureRepository = devicePostureRepository,
+ )
+ }