Add a SysPropBooleanFlag: wallpaper cropping for foldables

This adds a flag and a public static @hide API in WallpaperManager.

Bug: 270726737
Test: TreeHugger (no logic is changed by this CL)
Change-Id: I3da9acc845f85f64642d523eeffeac6cae76ef8b
This commit is contained in:
Aurélien Pomini
2023-05-09 11:10:01 +00:00
parent 2159c058c4
commit fa746386f1
4 changed files with 44 additions and 0 deletions

View File

@@ -272,4 +272,11 @@ interface IWallpaperManager {
* @hide
*/
boolean isLockscreenLiveWallpaperEnabled();
/**
* Temporary method for project b/270726737.
* Return true if the wallpaper supports different crops for different display dimensions.
* @hide
*/
boolean isMultiCropEnabled();
}

View File

@@ -314,6 +314,7 @@ public class WallpaperManager {
private final boolean mWcgEnabled;
private final ColorManagementProxy mCmProxy;
private static Boolean sIsLockscreenLiveWallpaperEnabled = null;
private static Boolean sIsMultiCropEnabled = null;
/**
* Special drawable that draws a wallpaper as fast as possible. Assumes
@@ -865,6 +866,26 @@ public class WallpaperManager {
return sIsLockscreenLiveWallpaperEnabled;
}
/**
* Temporary method for project b/270726737
* @return true if the wallpaper supports different crops for different display dimensions
* @hide
*/
public static boolean isMultiCropEnabled() {
if (sGlobals == null) {
sIsMultiCropEnabled = SystemProperties.getBoolean(
"persist.wm.debug.wallpaper_multi_crop", false);
}
if (sIsMultiCropEnabled == null) {
try {
sIsMultiCropEnabled = sGlobals.mService.isMultiCropEnabled();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
return sIsMultiCropEnabled;
}
/**
* Indicate whether wcg (Wide Color Gamut) should be enabled.
* <p>

View File

@@ -525,6 +525,13 @@ object Flags {
@JvmField val LOCKSCREEN_LIVE_WALLPAPER =
sysPropBooleanFlag(1117, "persist.wm.debug.lockscreen_live_wallpaper", default = false)
// TODO(b/281648899): Tracking bug
@Keep
@JvmField
val WALLPAPER_MULTI_CROP =
sysPropBooleanFlag(1118, "persist.wm.debug.wallpaper_multi_crop", default = false)
// 1200 - predictive back
@Keep
@JvmField

View File

@@ -181,6 +181,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
private final Object mLock = new Object();
/** True to enable a second engine for lock screen wallpaper when different from system wp. */
private final boolean mIsLockscreenLiveWallpaperEnabled;
/** True to support different crops for different display dimensions */
private final boolean mIsMultiCropEnabled;
/** Tracks wallpaper being migrated from system+lock to lock when setting static wp. */
WallpaperDestinationChangeHandler mPendingMigrationViaStatic;
@@ -1600,6 +1602,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
mIsLockscreenLiveWallpaperEnabled =
SystemProperties.getBoolean("persist.wm.debug.lockscreen_live_wallpaper", false);
mIsMultiCropEnabled =
SystemProperties.getBoolean("persist.wm.debug.wallpaper_multi_crop", false);
LocalServices.addService(WallpaperManagerInternal.class, new LocalService());
}
@@ -3724,6 +3728,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return mIsLockscreenLiveWallpaperEnabled;
}
@Override
public boolean isMultiCropEnabled() {
return mIsMultiCropEnabled;
}
private void onDisplayReadyInternal(int displayId) {
synchronized (mLock) {
if (mLastWallpaper == null) {