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

Commit 4ed9a0c0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[flexi] Add LockscreenFrontScrim" into main

parents ab1ab2ef 8d9a4de3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.keyguard.ui.composable.LockscreenScene
import com.android.systemui.keyguard.ui.composable.LockscreenSceneBlueprintModule
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenFrontScrimViewModel
import com.android.systemui.scene.ui.composable.Scene
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationLockscreenScrimViewModel
import dagger.Binds
@@ -61,6 +62,7 @@ interface LockscreenSceneModule {
        fun providesLockscreenContent(
            viewModelFactory: LockscreenContentViewModel.Factory,
            notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory,
            lockscreenFrontScrimViewModelFactory: LockscreenFrontScrimViewModel.Factory,
            blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
            clockInteractor: KeyguardClockInteractor,
            interactionJankMonitor: InteractionJankMonitor,
@@ -68,6 +70,7 @@ interface LockscreenSceneModule {
            return LockscreenContent(
                viewModelFactory,
                notificationScrimViewModelFactory,
                lockscreenFrontScrimViewModelFactory,
                blueprints,
                clockInteractor,
                interactionJankMonitor,
+8 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.transition.KeyguardTransitionAnimationCallback
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenFrontScrimViewModel
import com.android.systemui.lifecycle.rememberViewModel
import com.android.systemui.notifications.ui.composable.NotificationLockscreenScrim
import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys
@@ -46,6 +47,7 @@ import com.android.systemui.statusbar.notification.stack.ui.viewmodel.Notificati
class LockscreenContent(
    private val viewModelFactory: LockscreenContentViewModel.Factory,
    private val notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory,
    private val lockscreenFrontScrimViewModelFactory: LockscreenFrontScrimViewModel.Factory,
    private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
    private val clockInteractor: KeyguardClockInteractor,
    private val interactionJankMonitor: InteractionJankMonitor,
@@ -65,13 +67,16 @@ class LockscreenContent(
                )
            }
        val notificationLockscreenScrimViewModel =
            rememberViewModel("LockscreenContent-scrimViewModel") {
            rememberViewModel("LockscreenContent-notificationScrimViewModel") {
                notificationScrimViewModelFactory.create()
            }
        val lockscreenFrontScrimViewModel =
            rememberViewModel("LockscreenContent-frontScrimViewModel") {
                lockscreenFrontScrimViewModelFactory.create()
            }

        // Ensure clock events are connected. This is a no-op if they are already registered.
        clockInteractor.clockEventController.registerListeners()

        if (!viewModel.isContentVisible) {
            // If the content isn't supposed to be visible, show a large empty box as it's needed
            // for scene transition animations (can't just skip rendering everything or shared
@@ -93,6 +98,7 @@ class LockscreenContent(
                modifier.sysuiResTag("keyguard_root_view").element(LockscreenElementKeys.Root),
            )
            NotificationLockscreenScrim(notificationLockscreenScrimViewModel)
            LockscreenFrontScrim(lockscreenFrontScrimViewModel)
        }
    }
}
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.ui.composable

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import com.android.systemui.keyguard.ui.viewmodel.LockscreenFrontScrimViewModel

/** A full-screen scrim that is used to dim AOD UI. */
@Composable
fun LockscreenFrontScrim(viewModel: LockscreenFrontScrimViewModel, modifier: Modifier = Modifier) {
    val animatedAlpha: Float by animateFloatAsState(viewModel.alpha)
    Box(modifier.fillMaxSize().graphicsLayer { alpha = animatedAlpha }.background(Color.Black))
}
+16 −1
Original line number Diff line number Diff line
@@ -43,7 +43,9 @@ import com.android.systemui.biometrics.AuthController;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.flags.DisableSceneContainer;
import com.android.systemui.flags.EnableSceneContainer;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.domain.interactor.AodDimInteractor;
import com.android.systemui.keyguard.domain.interactor.DozeInteractor;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.shade.NotificationShadeWindowViewController;
@@ -99,6 +101,7 @@ public class DozeServiceHostTest extends SysuiTestCase {
    @Mock private DozeHost.Callback mCallback;
    @Mock private DozeInteractor mDozeInteractor;
    @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
    @Mock private AodDimInteractor mAodDimInteractor;

    private KosmosJavaAdapter mKosmos;

@@ -114,7 +117,8 @@ public class DozeServiceHostTest extends SysuiTestCase {
                mNotificationWakeUpCoordinator, mAuthController,
                mShadeLockscreenInteractor, mDozeInteractor,
                mKosmos.getDeviceEntryFingerprintAuthInteractor(),
                mKosmos.getTestScope(), mContext, mAmbientDisplayConfiguration);
                mKosmos.getTestScope(), mContext, mAmbientDisplayConfiguration,
                mAodDimInteractor);

        mDozeServiceHost.initialize(
                mCentralSurfaces,
@@ -243,6 +247,7 @@ public class DozeServiceHostTest extends SysuiTestCase {
        mDozeServiceHost.onSlpiTap(100, -2);
        verify(mDozeInteractor, never()).setLastTapToWakePosition(any());
    }

    @Test
    public void dozeTimeTickSentToDozeInteractor() {
        // WHEN dozeTimeTick
@@ -251,4 +256,14 @@ public class DozeServiceHostTest extends SysuiTestCase {
        // THEN dozeInteractor's dozeTimeTick is updated
        verify(mDozeInteractor).dozeTimeTick();
    }

    @Test
    @EnableSceneContainer
    public void setAodDimmingScrim() {
        // WHEN set aodDimmingScrim
        mDozeServiceHost.setAodDimmingScrim(.54f);

        // THEN interactor's dim amount is updated
        verify(mAodDimInteractor).setDimAmount(eq(.54f));
    }
}
+9 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.doze.dagger.BrightnessSensor;
import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.doze.dagger.WrappedService;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.util.kotlin.JavaAdapterKt;
@@ -216,6 +217,9 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
        stopListeningForWallpaperSupportsAmbientMode();
        setLightSensorEnabled(false);
        mDevicePostureController.removeCallback(mDevicePostureCallback);
        if (SceneContainerFlag.isEnabled()) {
            mDozeHost.setAodDimmingScrim(0f);
        }
    }

    @Override
@@ -281,9 +285,12 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
            return -1;
        }
        int wallpaperScrimOpacity = -1;
        if (mWallpaperSupportsAmbientMode && sensorValue < mSensorToWallpaperScrimOpacity.length) {
        if (!SceneContainerFlag.isEnabled()) {
            if (mWallpaperSupportsAmbientMode && sensorValue
                    < mSensorToWallpaperScrimOpacity.length) {
                wallpaperScrimOpacity = mSensorToWallpaperScrimOpacity[sensorValue];
            }
        }
        return max(wallpaperScrimOpacity, mSensorToScrimOpacity[sensorValue]);
    }

Loading