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

Commit e330564d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12969164 from 2571238a to 25Q2-release

Change-Id: I449b4bc5d956577b16fe165b37eb0166f85d1302
parents f2a34dbd 2571238a
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.google.android.torus.core.wallpaper

import android.app.WallpaperColors
import android.app.wallpaper.WallpaperDescription
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -133,7 +134,11 @@ abstract class LiveWallpaper : WallpaperService() {
     * well). You can track the lifecycle when *any* Engine is active using the
     * is{First/Last}ActiveInstance parameters of the create/destroy methods.
     */
    abstract fun getWallpaperEngine(context: Context, surfaceHolder: SurfaceHolder): TorusEngine
    abstract fun getWallpaperEngine(
        context: Context,
        surfaceHolder: SurfaceHolder,
        wallpaperDescription: WallpaperDescription? = null,
    ): TorusEngine

    /**
     * returns a new instance of [LiveWallpaperEngineWrapper]. Caution: This function should not be
@@ -145,6 +150,12 @@ abstract class LiveWallpaper : WallpaperService() {
        return wrapper
    }

    override fun onCreateEngine(description: WallpaperDescription): Engine? {
        val wrapper = LiveWallpaperEngineWrapper(description)
        wakeStateChangeListeners.add(WeakReference(wrapper))
        return wrapper
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        super.onConfigurationChanged(newConfig)

@@ -242,7 +253,9 @@ abstract class LiveWallpaper : WallpaperService() {
     * engine is created. Also, wrapping our [TorusEngine] inside [WallpaperService.Engine] allow us
     * to reuse [TorusEngine] in other places, like Activities.
     */
    private inner class LiveWallpaperEngineWrapper : WallpaperService.Engine() {
    private inner class LiveWallpaperEngineWrapper(
        private val wallpaperDescription: WallpaperDescription? = null
    ) : WallpaperService.Engine() {
        private lateinit var wallpaperEngine: TorusEngine

        override fun onCreate(surfaceHolder: SurfaceHolder) {
@@ -261,7 +274,7 @@ abstract class LiveWallpaper : WallpaperService() {
                    this@LiveWallpaper
                }

            wallpaperEngine = getWallpaperEngine(context, surfaceHolder)
            wallpaperEngine = getWallpaperEngine(context, surfaceHolder, wallpaperDescription)
            numEngines++

            /*
+38 −13
Original line number Diff line number Diff line
@@ -110,19 +110,44 @@ interface LiveWallpaperEventListener {
    fun shouldZoomOutWallpaper() = false

    /**
     * React to COMMAND_LOCKSCREEN_LAYOUT_CHANGED from SystemUI. Current usage is to show the
     * remaining space in lockscreen to bound the position for wallpaper shape effects. We also pass
     * the bottom of smartspace as a reference.
     *
     * @param extras contains the necessary value from lockscreen layout currently for magic
     *   portrait, it contains
     * - "screenLeft": the left of the screen
     * - "screenRight": the left of the screen
     * - "smartspaceBottom": the bottom of the smartspace date and weather part, not bc smartspace
     * - "shortCutTop": the top of the shortcut in locksreen
     * - "notificationBottom": the bottom of notifications in lockscreen With smartspaceBottom,
     *   screenLeft, screenRight, shortCutTop, we can get the remaining space bounds in lockscreen
     *   without notifications. And with notificationBottom, we have bounds with notifications
     * React to COMMAND_LOCKSCREEN_LAYOUT_CHANGED from SystemUI to give wallpaper focal area on
     * lockscreen
     *
     * @param extras contains the wallpaper focal area bounds from lockscreen
     *
     * For handheld,
     *
     * when there's notification, the focal area should be below notification stack, and above
     * shortcut, and horizontally constrained by screen width. i.e. (screenLeft,
     * notificationStackBottom, screenRight, shortcutTop)
     *
     * when there's no notification, the only difference is the top of focal area, which is below
     * smartspace. i.e. (screenLeft, smartspaceBottom, screenRight, shortcutTop)
     *
     * For tablet portrait, we have the similar logic with handheld, but we have its width
     * constrained by a maxFocalAreaWidth, which is 500dp. i.e. left = screenCenterX -
     * maxFocalAreaWidth / 2, top = smartspaceBottom or notificationStackBottom, right =
     * screenCenterX + maxFocalAreaWidth / 2, bottom = shortcutTop.
     *
     * For tablet landscape, focal area is always in the center of screen, and we need to have a top
     * margin as margin from the shortcut top to the screen bottom to make focal area vertically
     * symmetric i.e. left = screenCenterX - maxFocalAreaWidth / 2, top =
     * shortcutMarginToScreenBottom, right = screenCenterX + maxFocalAreaWidth / 2, bottom =
     * shortcutTop
     *
     * For foldable fold mode, we have the same logic with handheld.
     *
     * For foldable unfold portrait, we have same logic with tablet portrait.
     *
     * For foldable unfold landscape, when there's notification, focal area is in left half screen,
     * top to bottom of smartspace, bottom to top of shortcut, left and right is constrained by half
     * screen width, i.e. (screenLeft, smartspaceBottom, screenCenterX, shortcutTop)
     *
     * when there's no notification, focal area is in right half screen, top to bottom of
     * smartspace, bottom to top of shortcut, left and right is constrained by half screen width.
     * i.e. (screenCenterX, smartspaceBottom, screenRight, shortcutTop)
     */
    // TODO: when smartspace is moved from below small clock to the right of the clock, we need to
    // change all smartspace bottom mentioned above to small clock bottom
    fun onLockscreenLayoutChanged(extras: Bundle) {}
}
+7 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.google.android.wallpaper.weathereffects

import android.app.wallpaper.WallpaperDescription
import android.content.Context
import android.view.SurfaceHolder
import com.google.android.torus.core.engine.TorusEngine
@@ -35,7 +36,11 @@ class WeatherWallpaperService @Inject constructor(): LiveWallpaper() {
        WallpaperEffectsDebugApplication.graph.inject(this)
    }

    override fun getWallpaperEngine(context: Context, surfaceHolder: SurfaceHolder): TorusEngine {
    override fun getWallpaperEngine(
        context: Context,
        surfaceHolder: SurfaceHolder,
        wallpaperDescription: WallpaperDescription?,
    ): TorusEngine {
        return WeatherEngine(surfaceHolder, applicationScope, interactor, context)
    }
}