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

Commit 01771fec authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Listen to change of notification stack bottom to pass correct bounds to magic...

Listen to change of notification stack bottom to pass correct bounds to magic portrait shape effects

Bug: 364534860
Flag: com.android.systemui.magic_portrait_wallpapers
Test: atest WallpaperRepositoryImplTest

Change-Id: Ic3e59c8fb5916eacb3b3f030dc126abaf4b5b1a3
parent 0045818f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -284,6 +284,14 @@ public class WallpaperManager {
     */
    public static final String COMMAND_UNFREEZE = "android.wallpaper.unfreeze";

    /**
     * Command for {@link #sendWallpaperCommand}: in sendWallpaperCommand put extra to this command
     * to give the bounds of space between the bottom of notifications and the top of shortcuts
     * @hide
     */
    public static final String COMMAND_LOCKSCREEN_LAYOUT_CHANGED =
            "android.wallpaper.lockscreen_layout_changed";

    /**
     * Extra passed back from setWallpaper() giving the new wallpaper's assigned ID.
     * @hide
+8 −0
Original line number Diff line number Diff line
@@ -1483,3 +1483,11 @@ flag {
       purpose: PURPOSE_BUGFIX
   }
}

flag {
   name: "magic_portrait_wallpapers"
   namespace: "systemui"
   description: "Magic Portrait related changes in systemui"
   bug: "370863642"
}
+7 −0
Original line number Diff line number Diff line
@@ -17,10 +17,17 @@
package com.android.systemui.wallpapers.data.repository

import android.app.WallpaperInfo
import android.view.View
import kotlinx.coroutines.flow.MutableStateFlow

/** Fake implementation of the wallpaper repository. */
class FakeWallpaperRepository : WallpaperRepository {
    override val wallpaperInfo = MutableStateFlow<WallpaperInfo?>(null)
    override val wallpaperSupportsAmbientMode = MutableStateFlow(false)
    override var rootView: View? = null
    private val _notificationStackAbsoluteBottom = MutableStateFlow(0F)

    override fun setNotificationStackAbsoluteBottom(bottom: Float) {
        _notificationStackAbsoluteBottom.value = bottom
    }
}
+16 −3
Original line number Diff line number Diff line
@@ -68,11 +68,16 @@ interface KeyguardClockRepository {

    val previewClock: Flow<ClockController>

    /** top of notifications without bcsmartspace in small clock settings */
    val notificationDefaultTop: StateFlow<Float>

    val clockEventController: ClockEventController

    val shouldForceSmallClock: Boolean

    fun setClockSize(size: ClockSize)

    fun setNotificationDefaultTop(top: Float)
}

@SysUISingleton
@@ -108,7 +113,7 @@ constructor(
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.WhileSubscribed(),
                initialValue = getClockSize()
                initialValue = getClockSize(),
            )

    override val currentClockId: Flow<ClockId> =
@@ -138,7 +143,7 @@ constructor(
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.WhileSubscribed(),
                initialValue = clockRegistry.createCurrentClock()
                initialValue = clockRegistry.createCurrentClock(),
            )

    override val previewClock: Flow<ClockController> =
@@ -149,6 +154,14 @@ constructor(
            clockRegistry.createCurrentClock()
        }

    private val _notificationDefaultTop: MutableStateFlow<Float> = MutableStateFlow(0F)

    override val notificationDefaultTop: StateFlow<Float> = _notificationDefaultTop.asStateFlow()

    override fun setNotificationDefaultTop(top: Float) {
        _notificationDefaultTop.value = top
    }

    override val shouldForceSmallClock: Boolean
        get() =
            featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE) &&
@@ -160,7 +173,7 @@ constructor(
            secureSettings.getIntForUser(
                Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
                /* defaultValue= */ 1,
                UserHandle.USER_CURRENT
                UserHandle.USER_CURRENT,
            )
        )
    }
+19 −7
Original line number Diff line number Diff line
@@ -269,6 +269,9 @@ interface KeyguardRepository {
     */
    val isEncryptedOrLockdown: Flow<Boolean>

    /** The top of shortcut in screen, used by wallpaper to find remaining space in lockscreen */
    val shortcutAbsoluteTop: StateFlow<Float>

    /**
     * Returns `true` if the keyguard is showing; `false` otherwise.
     *
@@ -339,6 +342,8 @@ interface KeyguardRepository {
     * otherwise.
     */
    fun isShowKeyguardWhenReenabled(): Boolean

    fun setShortcutAbsoluteTop(top: Float)
}

/** Encapsulates application state for the keyguard. */
@@ -503,7 +508,7 @@ constructor(
                trySendWithFailureLogging(
                    statusBarStateController.dozeAmount,
                    TAG,
                    "initial dozeAmount"
                    "initial dozeAmount",
                )

                awaitClose { statusBarStateController.removeCallback(callback) }
@@ -521,7 +526,7 @@ constructor(
            object : DozeTransitionCallback {
                override fun onDozeTransition(
                    oldState: DozeMachine.State,
                    newState: DozeMachine.State
                    newState: DozeMachine.State,
                ) {
                    trySendWithFailureLogging(
                        DozeTransitionModel(
@@ -529,7 +534,7 @@ constructor(
                            to = dozeMachineStateToModel(newState),
                        ),
                        TAG,
                        "doze transition model"
                        "doze transition model",
                    )
                }
            }
@@ -541,7 +546,7 @@ constructor(
                to = dozeMachineStateToModel(dozeTransitionListener.newState),
            ),
            TAG,
            "initial doze transition model"
            "initial doze transition model",
        )

        awaitClose { dozeTransitionListener.removeCallback(callback) }
@@ -579,7 +584,7 @@ constructor(
                            trySendWithFailureLogging(
                                statusBarStateIntToObject(state),
                                TAG,
                                "state"
                                "state",
                            )
                        }
                    }
@@ -590,7 +595,7 @@ constructor(
            .stateIn(
                scope,
                SharingStarted.Eagerly,
                statusBarStateIntToObject(statusBarStateController.state)
                statusBarStateIntToObject(statusBarStateController.state),
            )

    private val _biometricUnlockState: MutableStateFlow<BiometricUnlockModel> =
@@ -610,7 +615,7 @@ constructor(
            trySendWithFailureLogging(
                authController.fingerprintSensorLocation,
                TAG,
                "AuthController.Callback#onFingerprintLocationChanged"
                "AuthController.Callback#onFingerprintLocationChanged",
            )
        }

@@ -635,6 +640,9 @@ constructor(
    private val _isActiveDreamLockscreenHosted = MutableStateFlow(false)
    override val isActiveDreamLockscreenHosted = _isActiveDreamLockscreenHosted.asStateFlow()

    private val _shortcutAbsoluteTop = MutableStateFlow(0F)
    override val shortcutAbsoluteTop = _shortcutAbsoluteTop.asStateFlow()

    init {
        val callback =
            object : KeyguardStateController.Callback {
@@ -721,6 +729,10 @@ constructor(
        }
    }

    override fun setShortcutAbsoluteTop(top: Float) {
        _shortcutAbsoluteTop.value = top
    }

    private fun dozeMachineStateToModel(state: DozeMachine.State): DozeStateModel {
        return when (state) {
            DozeMachine.State.UNINITIALIZED -> DozeStateModel.UNINITIALIZED
Loading