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

Commit 9f96cbb9 authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

Add applyWallpaper to TorusEngine

Flag: EXEMPT no logic changes
Bug: 344909219
Test: presubmit

Change-Id: Id85f9fa66398ae9966b2d066866a1759e130b68c
parent e4b9eea5
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.google.android.torus.core.engine

import android.app.WallpaperManager
import android.app.wallpaper.WallpaperDescription
import android.service.wallpaper.WallpaperService.Engine
import com.google.android.torus.core.wallpaper.LiveWallpaper

/**
@@ -25,8 +27,8 @@ import com.google.android.torus.core.wallpaper.LiveWallpaper
 */
interface TorusEngine {
    /**
     * Called when the engine is created. You should load the assets and initialize the
     * resources here.
     * Called when the engine is created. You should load the assets and initialize the resources
     * here.
     *
     * IMPORTANT: When this function is called, the surface used to render the engine has to be
     * ready.
@@ -37,13 +39,18 @@ interface TorusEngine {
    fun create(isFirstActiveInstance: Boolean = true)

    /**
     * Called when the [TorusEngine] resumes.
     * Called when the event [Engine.onApplyWallpaper] is called.
     *
     * @see Engine.onApplyWallpaper
     */
    fun applyWallpaper(which: Int): WallpaperDescription? {
        return null
    }

    /** Called when the [TorusEngine] resumes. */
    fun resume()

    /**
     * Called when the [TorusEngine] is paused.
     */
    /** Called when the [TorusEngine] is paused. */
    fun pause()

    /**
@@ -62,8 +69,8 @@ interface TorusEngine {
    fun destroy(isLastActiveInstance: Boolean = true)

    /**
     * Called when the engine changes its destination flag. The destination indicates whether
     * the wallpaper is drawn on home screen, lock screen, or both. It is a combination of
     * Called when the engine changes its destination flag. The destination indicates whether the
     * wallpaper is drawn on home screen, lock screen, or both. It is a combination of
     * [WallpaperManager.FLAG_LOCK] and/or [WallpaperManager.FLAG_SYSTEM]
     */
    fun onWallpaperFlagsChanged(which: Int) {}
+5 −0
Original line number Diff line number Diff line
@@ -284,6 +284,11 @@ abstract class LiveWallpaper : WallpaperService() {
            if (wallpaperEngine is TorusTouchListener) setTouchEventsEnabled(true)
        }

        override fun onApplyWallpaper(which: Int): WallpaperDescription? {
            super.onApplyWallpaper(which)
            return wallpaperEngine.applyWallpaper(which)
        }

        override fun onSurfaceCreated(holder: SurfaceHolder) {
            super.onSurfaceCreated(holder)