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

Commit 118954ee authored by Florence Yang's avatar Florence Yang Committed by Kateryna Ivanova
Browse files

Setup TorusEngine with WallpaperDescription

Receive and pass WallpaperDescription through LiveWallpaper in order to
use new Bundle Asset Management API from Picker / WP Manager.

Flag: EXEMPT in MagicPortrait
Bug: 344909219
Test: presubmit, m out/soong/.intermediates/frameworks/libs/systemui/weathereffects/WeatherEffectsDebug/android_common/kapt/kapt-sources.jar
Change-Id: I69574bcbadf18b1810c309be61289434ba0eed72
parent 66f97f4a
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++

            /*
+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)
    }
}