diff options
10 files changed, 78 insertions, 54 deletions
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl index f4373a67a967..ee242635bfb2 100644 --- a/core/java/android/app/IWallpaperManager.aidl +++ b/core/java/android/app/IWallpaperManager.aidl @@ -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(); } diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index 4d55fee35506..ebd525ec6508 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -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; } /** diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index ef19fc1f5360..baf19bb10460 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -6296,10 +6296,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. diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8855d5b3de25..1d2117830311 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -4956,7 +4956,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" /> diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 4d6aef5050f2..00becfe146d5 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java index 54b30300ba49..cd1ad1ba788f 100644 --- a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java @@ -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); diff --git a/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java b/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java index 799d14944650..53861c854a1b 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperDataParser.java @@ -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); diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 93f039d2f5b4..b1b0c559aad4 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -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) { diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index 0b9ceeaf5d4e..7ceac4fe7f16 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -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) { diff --git a/services/core/java/com/android/server/wm/WallpaperWindowToken.java b/services/core/java/com/android/server/wm/WallpaperWindowToken.java index 17ab551b5c1e..6c38c6fb7ac4 100644 --- a/services/core/java/com/android/server/wm/WallpaperWindowToken.java +++ b/services/core/java/com/android/server/wm/WallpaperWindowToken.java @@ -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 |