Merge "Add a SysPropBooleanFlag for the lockscreen-lwp project." into udc-dev

This commit is contained in:
Lucas Dupin
2023-04-04 20:51:30 +00:00
committed by Android (Google) Code Review
10 changed files with 78 additions and 54 deletions

View File

@@ -243,4 +243,11 @@ interface IWallpaperManager {
* @hide
*/
boolean lockScreenWallpaperExists();
/**
* Temporary method for project b/197814683.
* Return true if the lockscreen wallpaper always uses a WallpaperService, not a static image.
* @hide
*/
boolean isLockscreenLiveWallpaperEnabled();
}

View File

@@ -142,9 +142,6 @@ public class WallpaperManager {
private static final @NonNull RectF LOCAL_COLOR_BOUNDS =
new RectF(0, 0, 1, 1);
/** Temporary feature flag for project b/197814683 */
private final boolean mLockscreenLiveWallpaper;
/** {@hide} */
private static final String PROP_WALLPAPER = "ro.config.wallpaper";
/** {@hide} */
@@ -306,6 +303,7 @@ public class WallpaperManager {
private final Context mContext;
private final boolean mWcgEnabled;
private final ColorManagementProxy mCmProxy;
private Boolean mIsLockscreenLiveWallpaperEnabled = null;
/**
* Special drawable that draws a wallpaper as fast as possible. Assumes
@@ -794,8 +792,6 @@ public class WallpaperManager {
mWcgEnabled = context.getResources().getConfiguration().isScreenWideColorGamut()
&& context.getResources().getBoolean(R.bool.config_enableWcgMode);
mCmProxy = new ColorManagementProxy(context);
mLockscreenLiveWallpaper = context.getResources()
.getBoolean(R.bool.config_independentLockscreenLiveWallpaper);
}
// no-op constructor called just by DisabledWallpaperManager
@@ -803,7 +799,6 @@ public class WallpaperManager {
mContext = null;
mCmProxy = null;
mWcgEnabled = false;
mLockscreenLiveWallpaper = false;
}
/**
@@ -827,7 +822,19 @@ public class WallpaperManager {
*/
@TestApi
public boolean isLockscreenLiveWallpaperEnabled() {
return mLockscreenLiveWallpaper;
if (sGlobals == null) {
mIsLockscreenLiveWallpaperEnabled = SystemProperties.getBoolean(
"persist.wm.debug.lockscreen_live_wallpaper", false);
}
if (mIsLockscreenLiveWallpaperEnabled == null) {
try {
mIsLockscreenLiveWallpaperEnabled =
sGlobals.mService.isLockscreenLiveWallpaperEnabled();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return mIsLockscreenLiveWallpaperEnabled;
}
/**

View File

@@ -6310,10 +6310,6 @@
-->
<integer name="config_deviceStateRearDisplay">-1</integer>
<!-- Whether the lock screen is allowed to run its own live wallpaper,
different from the home screen wallpaper. -->
<bool name="config_independentLockscreenLiveWallpaper">false</bool>
<!-- Device state that corresponds to concurrent display mode where the default display
is the internal display. Public API for the feature is provided through Jetpack
WindowManager.

View File

@@ -4960,7 +4960,6 @@
<java-symbol type="string" name="concurrent_display_notification_power_save_content"/>
<java-symbol type="string" name="device_state_notification_turn_off_button"/>
<java-symbol type="string" name="device_state_notification_settings_button"/>
<java-symbol type="bool" name="config_independentLockscreenLiveWallpaper"/>
<java-symbol type="integer" name="config_deviceStateConcurrentRearDisplay" />
<java-symbol type="string" name="config_rearDisplayPhysicalAddress" />

View File

@@ -513,6 +513,11 @@ object Flags {
sysPropBooleanFlag(
1116, "persist.wm.debug.enable_move_floating_window_in_tabletop", default = true)
// TODO(b/273443374): Tracking Bug
@Keep
@JvmField val LOCKSCREEN_LIVE_WALLPAPER =
sysPropBooleanFlag(1117, "persist.wm.debug.lockscreen_live_wallpaper", default = false)
// 1200 - predictive back
@Keep
@JvmField

View File

@@ -125,6 +125,8 @@ public class ImageWallpaper extends WallpaperService {
private int mBitmapUsages = 0;
private final Object mLock = new Object();
private boolean mIsLockscreenLiveWallpaperEnabled;
CanvasEngine() {
super();
setFixedSizeAllowed(true);
@@ -167,8 +169,10 @@ public class ImageWallpaper extends WallpaperService {
Log.d(TAG, "onCreate");
}
mWallpaperManager = getDisplayContext().getSystemService(WallpaperManager.class);
mIsLockscreenLiveWallpaperEnabled = mWallpaperManager
.isLockscreenLiveWallpaperEnabled();
mSurfaceHolder = surfaceHolder;
Rect dimensions = mWallpaperManager.isLockscreenLiveWallpaperEnabled()
Rect dimensions = mIsLockscreenLiveWallpaperEnabled
? mWallpaperManager.peekBitmapDimensions(getSourceFlag())
: mWallpaperManager.peekBitmapDimensions();
int width = Math.max(MIN_SURFACE_WIDTH, dimensions.width());
@@ -319,7 +323,7 @@ public class ImageWallpaper extends WallpaperService {
boolean loadSuccess = false;
Bitmap bitmap;
try {
bitmap = mWallpaperManager.isLockscreenLiveWallpaperEnabled()
bitmap = mIsLockscreenLiveWallpaperEnabled
? mWallpaperManager.getBitmapAsUser(
mUserTracker.getUserId(), false, getSourceFlag())
: mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
@@ -333,7 +337,7 @@ public class ImageWallpaper extends WallpaperService {
// be loaded, we will go into a cycle. Don't do a build where the
// default wallpaper can't be loaded.
Log.w(TAG, "Unable to load wallpaper!", exception);
if (mWallpaperManager.isLockscreenLiveWallpaperEnabled()) {
if (mIsLockscreenLiveWallpaperEnabled) {
mWallpaperManager.clearWallpaper(getWallpaperFlags(), mUserTracker.getUserId());
} else {
mWallpaperManager.clearWallpaper(
@@ -341,7 +345,7 @@ public class ImageWallpaper extends WallpaperService {
}
try {
bitmap = mWallpaperManager.isLockscreenLiveWallpaperEnabled()
bitmap = mIsLockscreenLiveWallpaperEnabled
? mWallpaperManager.getBitmapAsUser(
mUserTracker.getUserId(), false, getSourceFlag())
: mWallpaperManager.getBitmapAsUser(mUserTracker.getUserId(), false);
@@ -365,7 +369,7 @@ public class ImageWallpaper extends WallpaperService {
mBitmap.recycle();
}
mBitmap = bitmap;
mWideColorGamut = mWallpaperManager.isLockscreenLiveWallpaperEnabled()
mWideColorGamut = mIsLockscreenLiveWallpaperEnabled
? mWallpaperManager.wallpaperSupportsWcg(getSourceFlag())
: mWallpaperManager.wallpaperSupportsWcg(WallpaperManager.FLAG_SYSTEM);

View File

@@ -29,6 +29,7 @@ import static com.android.server.wallpaper.WallpaperUtils.makeWallpaperIdLocked;
import android.annotation.Nullable;
import android.app.WallpaperColors;
import android.app.WallpaperManager;
import android.app.WallpaperManager.SetWallpaperFlags;
import android.app.backup.WallpaperBackupHelper;
import android.content.ComponentName;
@@ -75,17 +76,17 @@ class WallpaperDataParser {
private final WallpaperCropper mWallpaperCropper;
private final Context mContext;
// Temporary feature flag. TODO(b/197814683) remove
private final boolean mEnableSeparateLockScreenEngine;
private final boolean mIsLockscreenLiveWallpaperEnabled;
WallpaperDataParser(Context context, WallpaperDisplayHelper wallpaperDisplayHelper,
WallpaperCropper wallpaperCropper, boolean enableSeparateLockScreenEngine) {
WallpaperCropper wallpaperCropper) {
mContext = context;
mWallpaperDisplayHelper = wallpaperDisplayHelper;
mWallpaperCropper = wallpaperCropper;
mImageWallpaper = ComponentName.unflattenFromString(
context.getResources().getString(R.string.image_wallpaper_component));
mEnableSeparateLockScreenEngine = enableSeparateLockScreenEngine;
mIsLockscreenLiveWallpaperEnabled = context.getSystemService(WallpaperManager.class)
.isLockscreenLiveWallpaperEnabled();
}
private JournaledFile makeJournaledFile(int userId) {
@@ -135,8 +136,9 @@ class WallpaperDataParser {
* If null, a new object will be created.
* @param lockWallpaper the lock wallpaper object to reuse to do the modifications.
* If null, a new object will be created.
* @param which The wallpaper(s) to load. If {@link #mEnableSeparateLockScreenEngine} is false,
* this flag has no effect and both wallpapers will always be loaded.
* @param which The wallpaper(s) to load. Only has effect if
* {@link WallpaperManager#isLockscreenLiveWallpaperEnabled} is true,
* otherwise both wallpaper will always be loaded.
* @return a {@link WallpaperLoadingResult} object containing the wallpaper data.
* This object will contain the {@code wallpaper} and
* {@code lockWallpaper} provided as parameters, if they are not null.
@@ -148,11 +150,13 @@ class WallpaperDataParser {
File file = journal.chooseForRead();
boolean migrateFromOld = wallpaper == null;
boolean loadSystem = !mEnableSeparateLockScreenEngine || (which & FLAG_SYSTEM) != 0;
boolean loadLock = !mEnableSeparateLockScreenEngine || (which & FLAG_LOCK) != 0;
boolean separateLockscreenEngine = mIsLockscreenLiveWallpaperEnabled;
boolean loadSystem = !separateLockscreenEngine || (which & FLAG_SYSTEM) != 0;
boolean loadLock = !separateLockscreenEngine || (which & FLAG_LOCK) != 0;
// don't reuse the wallpaper objects in the new version
if (mEnableSeparateLockScreenEngine) {
if (separateLockscreenEngine) {
wallpaper = null;
lockWallpaper = null;
}
@@ -184,7 +188,8 @@ class WallpaperDataParser {
if (type == XmlPullParser.START_TAG) {
String tag = parser.getName();
if (("wp".equals(tag) && loadSystem)
|| ("kwp".equals(tag) && mEnableSeparateLockScreenEngine && loadLock)) {
|| ("kwp".equals(tag) && mIsLockscreenLiveWallpaperEnabled
&& loadLock)) {
if ("kwp".equals(tag) && lockWallpaper == null) {
lockWallpaper = new WallpaperData(userId, FLAG_LOCK);
@@ -213,7 +218,7 @@ class WallpaperDataParser {
Slog.v(TAG, "mNextWallpaperComponent:"
+ wallpaper.nextWallpaperComponent);
}
} else if ("kwp".equals(tag) && !mEnableSeparateLockScreenEngine) {
} else if ("kwp".equals(tag) && !mIsLockscreenLiveWallpaperEnabled) {
// keyguard-specific wallpaper for this user (legacy code)
if (lockWallpaper == null) {
lockWallpaper = new WallpaperData(userId, FLAG_LOCK);

View File

@@ -88,6 +88,7 @@ import android.os.ResultReceiver;
import android.os.SELinux;
import android.os.ShellCallback;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
@@ -179,8 +180,7 @@ 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. */
@VisibleForTesting
final boolean mEnableSeparateLockScreenEngine;
private final boolean mIsLockscreenLiveWallpaperEnabled;
/** Tracks wallpaper being migrated from system+lock to lock when setting static wp. */
WallpaperDestinationChangeHandler mPendingMigrationViaStatic;
@@ -230,7 +230,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
// Handles static wallpaper changes generated by WallpaperObserver events when
// mEnableSeparateLockScreenEngine is true.
// enableSeparateLockScreenEngine() is true.
private void updateWallpapers(int event, String path) {
// System and system+lock changes happen on the system wallpaper input file;
// lock-only changes happen on the dedicated lock wallpaper input file
@@ -381,7 +381,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
// Handles static wallpaper changes generated by WallpaperObserver events when
// mEnableSeparateLockScreenEngine is false.
// enableSeparateLockScreenEngine() is false.
// TODO(b/266818039) Remove this method
private void updateWallpapersLegacy(int event, String path) {
final boolean moved = (event == MOVED_TO);
@@ -498,7 +498,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return;
}
if (mEnableSeparateLockScreenEngine) {
if (mIsLockscreenLiveWallpaperEnabled) {
updateWallpapers(event, path);
} else {
updateWallpapersLegacy(event, path);
@@ -1600,15 +1600,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
mActivityManager = mContext.getSystemService(ActivityManager.class);
mMonitor = new MyPackageMonitor();
mColorsChangedListeners = new SparseArray<>();
mEnableSeparateLockScreenEngine = mContext.getResources().getBoolean(
R.bool.config_independentLockscreenLiveWallpaper);
mWallpaperDataParser = new WallpaperDataParser(mContext, mWallpaperDisplayHelper,
mWallpaperCropper, mEnableSeparateLockScreenEngine);
if (DEBUG) {
Slog.v(TAG, "Separate lock screen engine enabled: " + mEnableSeparateLockScreenEngine);
}
mWallpaperCropper);
mIsLockscreenLiveWallpaperEnabled =
SystemProperties.getBoolean("persist.wm.debug.lockscreen_live_wallpaper", false);
LocalServices.addService(WallpaperManagerInternal.class, new LocalService());
}
@@ -2794,7 +2790,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
Os.rename(sysWP.wallpaperFile.getAbsolutePath(), lockWP.wallpaperFile.getAbsolutePath());
Os.rename(sysWP.cropFile.getAbsolutePath(), lockWP.cropFile.getAbsolutePath());
mLockWallpaperMap.put(userId, lockWP);
if (mEnableSeparateLockScreenEngine) {
if (mIsLockscreenLiveWallpaperEnabled) {
SELinux.restorecon(lockWP.wallpaperFile);
mLastLockWallpaper = lockWP;
}
@@ -2858,7 +2854,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
@VisibleForTesting
void setWallpaperComponent(ComponentName name, @SetWallpaperFlags int which, int userId) {
if (mEnableSeparateLockScreenEngine) {
if (mIsLockscreenLiveWallpaperEnabled) {
setWallpaperComponentInternal(name, which, userId);
} else {
setWallpaperComponentInternalLegacy(name, which, userId);
@@ -3192,7 +3188,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
Slog.w(TAG, msg);
return false;
}
if (mEnableSeparateLockScreenEngine) {
if (mIsLockscreenLiveWallpaperEnabled) {
maybeDetachLastWallpapers(wallpaper);
} else if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null
&& !wallpaper.equals(mFallbackWallpaper)) {
@@ -3201,7 +3197,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
wallpaper.wallpaperComponent = componentName;
wallpaper.connection = newConn;
newConn.mReply = reply;
if (mEnableSeparateLockScreenEngine) {
if (mIsLockscreenLiveWallpaperEnabled) {
updateCurrentWallpapers(wallpaper);
} else if (wallpaper.userId == mCurrentUserId && !wallpaper.equals(
mFallbackWallpaper)) {
@@ -3221,8 +3217,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return true;
}
// Updates tracking of the currently bound wallpapers. Assumes mEnableSeparateLockScreenEngine
// is true.
// Updates tracking of the currently bound wallpapers.
// Assumes isLockscreenLiveWallpaperEnabled is true.
private void updateCurrentWallpapers(WallpaperData newWallpaper) {
if (newWallpaper.userId != mCurrentUserId || newWallpaper.equals(mFallbackWallpaper)) {
return;
@@ -3237,7 +3233,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
}
// Detaches previously bound wallpapers if no longer in use. Assumes
// mEnableSeparateLockScreenEngine is true.
// isLockscreenLiveWallpaperEnabled is true.
private void maybeDetachLastWallpapers(WallpaperData newWallpaper) {
if (newWallpaper.userId != mCurrentUserId || newWallpaper.equals(mFallbackWallpaper)) {
return;
@@ -3389,6 +3385,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return (wallpaper != null) ? wallpaper.allowBackup : false;
}
@Override
public boolean isLockscreenLiveWallpaperEnabled() {
return mIsLockscreenLiveWallpaperEnabled;
}
private void onDisplayReadyInternal(int displayId) {
synchronized (mLock) {
if (mLastWallpaper == null) {
@@ -3476,8 +3477,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
WallpaperDataParser.WallpaperLoadingResult result = mWallpaperDataParser.loadSettingsLocked(
userId, keepDimensionHints, wallpaperData, lockWallpaperData, which);
boolean updateSystem = !mEnableSeparateLockScreenEngine || (which & FLAG_SYSTEM) != 0;
boolean updateLock = !mEnableSeparateLockScreenEngine || (which & FLAG_LOCK) != 0;
boolean updateSystem = !mIsLockscreenLiveWallpaperEnabled || (which & FLAG_SYSTEM) != 0;
boolean updateLock = !mIsLockscreenLiveWallpaperEnabled || (which & FLAG_LOCK) != 0;
if (updateSystem) mWallpaperMap.put(userId, result.getSystemWallpaperData());
if (updateLock) {

View File

@@ -46,6 +46,7 @@ import android.os.Debug;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.ArraySet;
import android.util.MathUtils;
import android.util.Slog;
@@ -56,7 +57,6 @@ import android.view.WindowManager;
import android.view.animation.Animation;
import android.window.ScreenCapture;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLogImpl;
import com.android.internal.protolog.common.ProtoLog;
@@ -122,7 +122,7 @@ class WallpaperController {
private boolean mShouldOffsetWallpaperCenter;
final boolean mEnableSeparateLockScreenEngine;
final boolean mIsLockscreenLiveWallpaperEnabled;
private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
if ((w.mAttrs.type == TYPE_WALLPAPER)) {
@@ -259,8 +259,8 @@ class WallpaperController {
mShouldOffsetWallpaperCenter =
resources.getBoolean(
com.android.internal.R.bool.config_offsetWallpaperToCenterOfLargestDisplay);
mEnableSeparateLockScreenEngine =
resources.getBoolean(R.bool.config_independentLockscreenLiveWallpaper);
mIsLockscreenLiveWallpaperEnabled =
SystemProperties.getBoolean("persist.wm.debug.lockscreen_live_wallpaper", false);
}
void resetLargestDisplay(Display display) {

View File

@@ -76,7 +76,7 @@ class WallpaperWindowToken extends WindowToken {
return;
}
mShowWhenLocked = showWhenLocked;
if (mDisplayContent.mWallpaperController.mEnableSeparateLockScreenEngine) {
if (mDisplayContent.mWallpaperController.mIsLockscreenLiveWallpaperEnabled) {
// Move the window token to the front (private) or back (showWhenLocked). This is
// possible
// because the DisplayArea underneath TaskDisplayArea only contains TYPE_WALLPAPER