Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07990398 authored by Wu Ahan's avatar Wu Ahan
Browse files

Remove unnecessary parts of screen off unlock workaround

This removes unnecessary parts of I4192a2c813ec0bbb241f8547817c773890d89243

Flag: EXEMPT refactor
Bug: 384986206
Bug: 422837350
Test: Manually
Test: atest SystemUITests
Change-Id: Ie47f45cc1cdbade840db17008264e294275bf104
parent 15cce63c
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -17,13 +17,3 @@ flag {
    bug: "373600589"
}
flag {
    name: "udfps_screen_off_unlock_flicker"
    namespace: "biometrics_framework"
    description: "Controls the fix of flicker of udfps screen-off unlock"
    bug: "384986206"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+0 −110
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -31,8 +30,6 @@ import static org.mockito.Mockito.when;
import android.graphics.Point;
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.PowerManager;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;

@@ -40,20 +37,14 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.biometrics.shared.model.FingerprintSensorType;
import com.android.systemui.biometrics.shared.model.SensorStrength;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.flags.DisableSceneContainer;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.domain.interactor.DozeInteractor;
import com.android.systemui.keyguard.shared.model.ErrorFingerprintAuthenticationStatus;
import com.android.systemui.keyguard.shared.model.FailFingerprintAuthenticationStatus;
import com.android.systemui.keyguard.shared.model.HelpFingerprintAuthenticationStatus;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.shade.NotificationShadeWindowViewController;
import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor;
@@ -75,7 +66,6 @@ import org.mockito.MockitoAnnotations;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;

@SmallTest
@@ -261,104 +251,4 @@ public class DozeServiceHostTest extends SysuiTestCase {
        // THEN dozeInteractor's dozeTimeTick is updated
        verify(mDozeInteractor).dozeTimeTick();
    }

    @Test
    @DisableFlags(Flags.FLAG_NEW_DOZING_KEYGUARD_STATES)
    @EnableFlags(Flags.FLAG_UDFPS_SCREEN_OFF_UNLOCK_FLICKER)
    public void testCollectingUsUdfpsPulseEvents_shouldNotCollect() {
        // Should not collect pulse events if not usudfps.
        mKosmos.getFingerprintPropertyRepository().setProperties(
                0,
                SensorStrength.STRONG,
                FingerprintSensorType.UDFPS_OPTICAL,
                new HashMap<>()
        );
        mKosmos.getTestScope().getTestScheduler().runCurrent();
        when(mAmbientDisplayConfiguration.screenOffUdfpsEnabled(anyInt())).thenReturn(true);
        mDozeServiceHost.startDozing();
        assertFalse(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());
        mDozeServiceHost.stopDozing();

        // Should not collect pulse events if feature disabled.
        mKosmos.getFingerprintPropertyRepository().setProperties(
                0,
                SensorStrength.STRONG,
                FingerprintSensorType.UDFPS_ULTRASONIC,
                new HashMap<>()
        );
        mKosmos.getTestScope().getTestScheduler().runCurrent();
        when(mAmbientDisplayConfiguration.screenOffUdfpsEnabled(anyInt())).thenReturn(false);
        mDozeServiceHost.startDozing();
        assertFalse(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());
        mDozeServiceHost.stopDozing();
    }

    @Test
    @DisableFlags({
            Flags.FLAG_UDFPS_SCREEN_OFF_UNLOCK_FLICKER,
            Flags.FLAG_NEW_DOZING_KEYGUARD_STATES
    })
    public void testCollectingUsUdfpsPulseEvents_shouldNotCollect_flagDisabled() {
        // Should not collect pulse events if the bug flag is disabled.
        mKosmos.getFingerprintPropertyRepository().setProperties(
                0,
                SensorStrength.STRONG,
                FingerprintSensorType.UDFPS_ULTRASONIC,
                new HashMap<>()
        );
        mKosmos.getTestScope().getTestScheduler().runCurrent();
        when(mAmbientDisplayConfiguration.screenOffUdfpsEnabled(anyInt())).thenReturn(true);
        mDozeServiceHost.startDozing();
        assertFalse(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());
        mDozeServiceHost.stopDozing();
    }

    @Test
    @DisableFlags(Flags.FLAG_NEW_DOZING_KEYGUARD_STATES)
    @EnableFlags(Flags.FLAG_UDFPS_SCREEN_OFF_UNLOCK_FLICKER)
    public void testCollectingUsUdfpsPulseEvents() {
        mKosmos.getFingerprintPropertyRepository().setProperties(
                0,
                SensorStrength.STRONG,
                FingerprintSensorType.UDFPS_ULTRASONIC,
                new HashMap<>());
        mKosmos.getTestScope().getTestScheduler().runCurrent();

        when(mAmbientDisplayConfiguration.screenOffUdfpsEnabled(anyInt())).thenReturn(true);
        assertFalse(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());
        DozeHost.Callback cb = mock(DozeHost.Callback.class);
        mDozeServiceHost.addCallback(cb);
        mDozeServiceHost.startDozing();

        // Should collect pulse events if usudfps and feature enabled.
        assertTrue(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());

        // Send events that will trigger callback.
        mKosmos.getDeviceEntryFingerprintAuthRepository().setAuthenticationStatus(
                new HelpFingerprintAuthenticationStatus(-1, "Test help"));
        mKosmos.getTestScope().getTestScheduler().runCurrent();

        // Callback should be invoked.
        verify(cb).onUltrasonicUdfpsPulseWhileScreenOff(
                any(HelpFingerprintAuthenticationStatus.class));

        mKosmos.getDeviceEntryFingerprintAuthRepository().setAuthenticationStatus(
                FailFingerprintAuthenticationStatus.INSTANCE);
        mKosmos.getTestScope().getTestScheduler().runCurrent();

        verify(cb).onUltrasonicUdfpsPulseWhileScreenOff(
                FailFingerprintAuthenticationStatus.INSTANCE);

        mKosmos.getDeviceEntryFingerprintAuthRepository().setAuthenticationStatus(
                new ErrorFingerprintAuthenticationStatus(
                        -1, "Test error", System.nanoTime()));
        mKosmos.getTestScope().getTestScheduler().runCurrent();

        verify(cb).onUltrasonicUdfpsPulseWhileScreenOff(
                any(ErrorFingerprintAuthenticationStatus.class));

        mDozeServiceHost.stopDozing();
        assertFalse(mDozeServiceHost.isCollectingUsUdfpsScreenOffPulseEvents());
        mDozeServiceHost.removeCallback(cb);
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -31,10 +31,6 @@ enum class FingerprintSensorType {
        return (this == UDFPS_OPTICAL) || (this == UDFPS_ULTRASONIC)
    }

    fun isUltrasonic(): Boolean {
        return this == UDFPS_ULTRASONIC
    }

    fun isPowerButton(): Boolean {
        return this == POWER_BUTTON
    }
+0 −22
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
@@ -81,25 +80,4 @@ constructor(
                started = SharingStarted.Eagerly,
                initialValue = fingerprintPropertyRepository.sensorType.value.isUdfps(),
            )

    /** True if it is ultrasonic udfps sensor, otherwise false. */
    val isUltrasonic: StateFlow<Boolean> =
        fingerprintPropertyRepository.sensorType
            .map { it.isUltrasonic() }
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.Eagerly,
                initialValue = fingerprintPropertyRepository.sensorType.value.isUltrasonic(),
            )

    /** Device entry fingerprint auth events that should turn on the display. */
    val fingerprintPulseEventsForDeviceEntry: Flow<FingerprintAuthenticationStatus> =
        repository.authenticationStatus.filter {
            when (it) {
                is HelpFingerprintAuthenticationStatus,
                is FailFingerprintAuthenticationStatus,
                is ErrorFingerprintAuthenticationStatus -> true
                else -> false
            }
        }
}
+0 −13
Original line number Diff line number Diff line
@@ -100,14 +100,6 @@ public interface DozeHost {
     * wake-up gestures. */
    boolean isAlwaysOnSuppressed();

    /**
     * Whether we are collecting the usudfps authentication pulse events.
     * @return true if collecting the events, otherwise false.
     */
    default boolean isCollectingUsUdfpsScreenOffPulseEvents() {
        return false;
    }

    interface Callback {
        /**
         * Called when a high priority notification is added.
@@ -137,11 +129,6 @@ public interface DozeHost {
         */
        default void onSideFingerprintAcquisitionStarted() {}

        /**
         * Called when ultrasonic fingerprint auth events want the screen on to show info.
         */
        default void onUltrasonicUdfpsPulseWhileScreenOff(FingerprintAuthenticationStatus state) {}

        /**
         * Called when fingerprint auth events want the screen on to show info.
         */
Loading