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

Commit 0b4290ca authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Introduce NICViewModel#isDozing and #isVisible" into main

parents e9438760 e85bd5b6
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ package com.android.systemui.deviceentry.data.repository

import com.android.internal.widget.LockPatternUtils
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
@@ -51,7 +51,7 @@ interface DeviceEntryRepository {
     * When this is `false`, an automatically-triggered face unlock shouldn't automatically dismiss
     * the lockscreen.
     */
    fun isBypassEnabled(): Boolean
    val isBypassEnabled: StateFlow<Boolean>
}

/** Encapsulates application state for device entry. */
@@ -68,7 +68,7 @@ constructor(
) : DeviceEntryRepository {

    override val isUnlocked =
        ConflatedCallbackFlow.conflatedCallbackFlow {
        conflatedCallbackFlow {
                val callback =
                    object : KeyguardStateController.Callback {
                        override fun onUnlockedChanged() {
@@ -112,7 +112,24 @@ constructor(
        }
    }

    override fun isBypassEnabled() = keyguardBypassController.bypassEnabled
    override val isBypassEnabled: StateFlow<Boolean> =
        conflatedCallbackFlow {
                val listener =
                    object : KeyguardBypassController.OnBypassStateChangedListener {
                        override fun onBypassStateChanged(isEnabled: Boolean) {
                            trySend(isEnabled)
                        }
                    }
                keyguardBypassController.registerOnBypassStateChangedListener(listener)
                awaitClose {
                    keyguardBypassController.unregisterOnBypassStateChangedListener(listener)
                }
            }
            .stateIn(
                applicationScope,
                SharingStarted.Eagerly,
                initialValue = keyguardBypassController.bypassEnabled,
            )

    companion object {
        private const val TAG = "DeviceEntryRepositoryImpl"
+1 −1
Original line number Diff line number Diff line
@@ -106,5 +106,5 @@ constructor(
     * authentication challenge via face unlock or fingerprint sensor can automatically bypass the
     * lock screen.
     */
    fun isBypassEnabled() = repository.isBypassEnabled()
    val isBypassEnabled: StateFlow<Boolean> = repository.isBypassEnabled
}
+27 −29
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICA
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -51,7 +52,6 @@ import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.launch
import javax.inject.Inject

/**
 * Hooks up business logic that manipulates the state of the [SceneInteractor] for the system UI
@@ -142,7 +142,7 @@ constructor(
                                // When the device becomes unlocked in Lockscreen, go to Gone if
                                // bypass is enabled.
                                renderedScenes.contains(SceneKey.Lockscreen) ->
                                    if (deviceEntryInteractor.isBypassEnabled()) {
                                    if (deviceEntryInteractor.isBypassEnabled.value) {
                                        SceneKey.Gone to
                                            "device unlocked in Lockscreen scene with bypass"
                                    } else {
@@ -179,8 +179,7 @@ constructor(
        }

        applicationScope.launch {
            powerInteractor.isAsleep
                .collect { isAsleep ->
            powerInteractor.isAsleep.collect { isAsleep ->
                if (isAsleep) {
                    switchToScene(
                        targetSceneKey = SceneKey.Lockscreen,
@@ -194,8 +193,7 @@ constructor(
                            switchToScene(
                                targetSceneKey = SceneKey.Gone,
                                loggingReason =
                                        "device is starting to wake up while auth method is" +
                                                " none",
                                    "device is starting to wake up while auth method is" + " none",
                            )
                        }
                        authMethod.isSecure && isUnlocked -> {
+12 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar;

import android.view.View;

import androidx.annotation.Nullable;

import com.android.app.animation.Interpolators;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
@@ -113,7 +115,16 @@ public class CrossFadeHelper {
        fadeIn(view, ANIMATION_DURATION_LENGTH, 0);
    }

    public static void fadeIn(final View view, Runnable endRunnable) {
        fadeIn(view, ANIMATION_DURATION_LENGTH, /* delay= */ 0, endRunnable);
    }

    public static void fadeIn(final View view, long duration, int delay) {
        fadeIn(view, duration, delay, /* endRunnable= */ null);
    }

    public static void fadeIn(final View view, long duration, int delay,
            @Nullable Runnable endRunnable) {
        view.animate().cancel();
        if (view.getVisibility() == View.INVISIBLE) {
            view.setAlpha(0.0f);
@@ -124,7 +135,7 @@ public class CrossFadeHelper {
                .setDuration(duration)
                .setStartDelay(delay)
                .setInterpolator(Interpolators.ALPHA_IN)
                .withEndAction(null);
                .withEndAction(endRunnable);
        if (view.hasOverlappingRendering() && view.getLayerType() != View.LAYER_TYPE_HARDWARE) {
            view.animate().withLayer();
        }
+7 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.Interpolator;

import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;

import com.android.app.animation.Interpolators;
@@ -959,12 +960,17 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    }

    public void setDozing(boolean dozing, boolean fade, long delay) {
        setDozing(dozing, fade, delay, /* onChildCompleted= */ null);
    }

    public void setDozing(boolean dozing, boolean fade, long delay,
            @Nullable Runnable endRunnable) {
        mDozer.setDozing(f -> {
            mDozeAmount = f;
            updateDecorColor();
            updateIconColor();
            updateAllowAnimation();
        }, dozing, fade, delay, this);
        }, dozing, fade, delay, this, endRunnable);
    }

    private void updateAllowAnimation() {
Loading