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

Commit c7d2e428 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Enable LiveWallpaper to listen to COMMAND_LOCKSCREEN_LAYOUT_CHANGED

Bug: 364534860
Flag: EXEMPT only change in Magic Portrait
Test: manual test

Change-Id: I6b8a78c191e2250f350d7fef25214423c783e46e
parent 654c4e1a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ abstract class LiveWallpaper : WallpaperService() {
        const val COMMAND_KEYGUARD_GOING_AWAY = "android.wallpaper.keyguardgoingaway"
        const val COMMAND_GOING_TO_SLEEP = "android.wallpaper.goingtosleep"
        const val COMMAND_PREVIEW_INFO = "android.wallpaper.previewinfo"
        const val COMMAND_LOCKSCREEN_LAYOUT_CHANGED = "android.wallpaper.lockscreen_layout_changed"
        const val WALLPAPER_FLAG_NOT_FOUND = -1
    }

@@ -385,6 +386,11 @@ abstract class LiveWallpaper : WallpaperService() {
                }
                COMMAND_KEYGUARD_GOING_AWAY -> onKeyguardGoingAway()
                COMMAND_PREVIEW_INFO -> onPreviewInfoReceived(extras)
                COMMAND_LOCKSCREEN_LAYOUT_CHANGED -> {
                    if (extras != null) {
                        onLockscreenLayoutChanged(extras)
                    }
                }
            }

            if (resultRequested) return extras
@@ -442,5 +448,11 @@ abstract class LiveWallpaper : WallpaperService() {
                (wallpaperEngine as LiveWallpaperEventListener).onPreviewInfoReceived(extras)
            }
        }

        fun onLockscreenLayoutChanged(extras: Bundle) {
            if (wallpaperEngine is LiveWallpaperEventListener) {
                (wallpaperEngine as LiveWallpaperEventListener).onLockscreenLayoutChanged(extras)
            }
        }
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -108,4 +108,21 @@ interface LiveWallpaperEventListener {
     * See [WallpaperService.shouldZoomOutWallpaper].
     */
    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
     */
    fun onLockscreenLayoutChanged(extras: Bundle) {}
}