From 7965f4d70acbbd9b32a7e855b70f336102516eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Thu, 6 Apr 2023 09:55:22 +0000 Subject: [PATCH] Always return the system default wallpaper with openDefaultWallpaper This change is gated by flag. If the lockscreen live wallpaper flag is enabled, never return null with openDefaultWallpaper, otherwise the operation clear(FLAG_LOCK) is compromised. clear will delete the cropFile and create an ImageWallpaper engine, without recreating any crop file. The ImageWallpaper engine will then call getBitmap which returns the cropFile, or, if it does not exist, a bitmap from openDefaultWallpaper. Thus our fallback defense with clear relies on the fact openDefaultWallpaper returns something, which was not the case with FLAG_LOCK Test: manual debugging (call clear(LOCK) by setting wallpapers) Bug: 277098137 Change-Id: Id5b8ce84ceb976e143e4da914f08c99b8c8ff835 --- core/java/android/app/WallpaperManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index ebd525ec6508a..6592019dc0d92 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -303,7 +303,7 @@ public class WallpaperManager { private final Context mContext; private final boolean mWcgEnabled; private final ColorManagementProxy mCmProxy; - private Boolean mIsLockscreenLiveWallpaperEnabled = null; + private static Boolean sIsLockscreenLiveWallpaperEnabled = null; /** * Special drawable that draws a wallpaper as fast as possible. Assumes @@ -823,18 +823,18 @@ public class WallpaperManager { @TestApi public boolean isLockscreenLiveWallpaperEnabled() { if (sGlobals == null) { - mIsLockscreenLiveWallpaperEnabled = SystemProperties.getBoolean( + sIsLockscreenLiveWallpaperEnabled = SystemProperties.getBoolean( "persist.wm.debug.lockscreen_live_wallpaper", false); } - if (mIsLockscreenLiveWallpaperEnabled == null) { + if (sIsLockscreenLiveWallpaperEnabled == null) { try { - mIsLockscreenLiveWallpaperEnabled = + sIsLockscreenLiveWallpaperEnabled = sGlobals.mService.isLockscreenLiveWallpaperEnabled(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } - return mIsLockscreenLiveWallpaperEnabled; + return sIsLockscreenLiveWallpaperEnabled; } /** @@ -2757,7 +2757,7 @@ public class WallpaperManager { public static InputStream openDefaultWallpaper(Context context, @SetWallpaperFlags int which) { final String whichProp; final int defaultResId; - if (which == FLAG_LOCK) { + if (which == FLAG_LOCK && !sIsLockscreenLiveWallpaperEnabled) { /* Factory-default lock wallpapers are not yet supported whichProp = PROP_LOCK_WALLPAPER; defaultResId = com.android.internal.R.drawable.default_lock_wallpaper;