Loading core/java/android/app/WallpaperManager.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -321,6 +321,14 @@ public class WallpaperManager { public static final String COMMAND_LOCKSCREEN_TAP = public static final String COMMAND_LOCKSCREEN_TAP = "android.wallpaper.lockscreen_tap"; "android.wallpaper.lockscreen_tap"; /** * Command for {@link #sendWallpaperCommand}: reported when the surface control that could be * used to transform the wallpaper is available * @hide */ public static final String COMMAND_TRANSFORM_SURFACE_CONTROL = "android.wallpaper.transform_surface_control"; /** /** * Extra passed back from setWallpaper() giving the new wallpaper's assigned ID. * Extra passed back from setWallpaper() giving the new wallpaper's assigned ID. * @hide * @hide Loading core/java/android/app/wallpaper.aconfig +10 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,16 @@ flag { } } } } flag { name: "enable_wallpaper_transform_surface_control_command" namespace: "systemui" description: "Enables sending SurfaceControl to onCommand that could be used to transform the wallpaper" bug: "399077623" metadata { purpose: PURPOSE_BUGFIX } } flag { flag { name: "accurate_wallpaper_downsampling" name: "accurate_wallpaper_downsampling" namespace: "systemui" namespace: "systemui" Loading core/java/android/service/wallpaper/WallpaperService.java +39 −4 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,9 @@ package android.service.wallpaper; import static android.app.Flags.FLAG_LIVE_WALLPAPER_CONTENT_HANDLING; import static android.app.Flags.FLAG_LIVE_WALLPAPER_CONTENT_HANDLING; import static android.app.Flags.liveWallpaperContentHandling; import static android.app.Flags.liveWallpaperContentHandling; import static android.app.Flags.enableWallpaperTransformSurfaceControlCommand; import static android.app.WallpaperManager.COMMAND_FREEZE; import static android.app.WallpaperManager.COMMAND_FREEZE; import static android.app.WallpaperManager.COMMAND_TRANSFORM_SURFACE_CONTROL; import static android.app.WallpaperManager.COMMAND_UNFREEZE; import static android.app.WallpaperManager.COMMAND_UNFREEZE; import static android.app.WallpaperManager.SetWallpaperFlags; import static android.app.WallpaperManager.SetWallpaperFlags; import static android.graphics.Matrix.MSCALE_X; import static android.graphics.Matrix.MSCALE_X; Loading Loading @@ -374,11 +376,16 @@ public abstract class WallpaperService extends Service { private float mPreviousWallpaperDimAmount = mWallpaperDimAmount; private float mPreviousWallpaperDimAmount = mWallpaperDimAmount; private float mDefaultDimAmount = 0.05f; private float mDefaultDimAmount = 0.05f; SurfaceControl mBbqSurfaceControl; SurfaceControl mBbqSurfaceControl; // Surface control that could be used to apply transformation to the wallpaper // The hiearchy is the following: // mSurfaceControl <- mTransformSurfaceControl <- mBbqSurfaceControl SurfaceControl mTransformSurfaceControl; BLASTBufferQueue mBlastBufferQueue; BLASTBufferQueue mBlastBufferQueue; IBinder mBbqApplyToken = new Binder(); IBinder mBbqApplyToken = new Binder(); private SurfaceControl mScreenshotSurfaceControl; private SurfaceControl mScreenshotSurfaceControl; private Point mScreenshotSize = new Point(); private Point mScreenshotSize = new Point(); private final boolean mEnableTransformSurfaceControlCommand; private final boolean mDisableDrawWakeLock; private final boolean mDisableDrawWakeLock; final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { Loading Loading @@ -568,6 +575,7 @@ public abstract class WallpaperService extends Service { public Engine(Supplier<Long> clockFunction, Handler handler) { public Engine(Supplier<Long> clockFunction, Handler handler) { mClockFunction = clockFunction; mClockFunction = clockFunction; mHandler = handler; mHandler = handler; mEnableTransformSurfaceControlCommand = enableWallpaperTransformSurfaceControlCommand(); mDisableDrawWakeLock = CompatChanges.isChangeEnabled(DISABLE_DRAW_WAKE_LOCK_WALLPAPER) mDisableDrawWakeLock = CompatChanges.isChangeEnabled(DISABLE_DRAW_WAKE_LOCK_WALLPAPER) && disableDrawWakeLock(); && disableDrawWakeLock(); } } Loading Loading @@ -1331,11 +1339,20 @@ public abstract class WallpaperService extends Service { (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); mSurfaceControl.setTransformHint(transformHint); mSurfaceControl.setTransformHint(transformHint); if (mBbqSurfaceControl == null) { if (mBbqSurfaceControl == null) { if (mEnableTransformSurfaceControlCommand) { mTransformSurfaceControl = new SurfaceControl.Builder() .setName("Wallpaper Transform wrapper") .setHidden(false) .setParent(mSurfaceControl) .setCallsite("Wallpaper#relayout") .build(); } mBbqSurfaceControl = new SurfaceControl.Builder() mBbqSurfaceControl = new SurfaceControl.Builder() .setName("Wallpaper BBQ wrapper") .setName("Wallpaper BBQ wrapper") .setHidden(false) .setHidden(false) .setBLASTLayer() .setBLASTLayer() .setParent(mSurfaceControl) .setParent(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mSurfaceControl) .setCallsite("Wallpaper#relayout") .setCallsite("Wallpaper#relayout") .build(); .build(); SurfaceControl.Transaction transaction = SurfaceControl.Transaction transaction = Loading @@ -1348,6 +1365,10 @@ public abstract class WallpaperService extends Service { } } transaction.setDefaultFrameRateCompatibility(mBbqSurfaceControl, transaction.setDefaultFrameRateCompatibility(mBbqSurfaceControl, frameRateCompat).apply(); frameRateCompat).apply(); if (mEnableTransformSurfaceControlCommand) { // TODO: b/406967924 - remove after creating public APIs sendTransformSurfaceControl(); } } } // Propagate transform hint from WM, so we can use the right hint for the // Propagate transform hint from WM, so we can use the right hint for the // first frame. // first frame. Loading Loading @@ -1551,6 +1572,12 @@ public abstract class WallpaperService extends Service { } } } } private void sendTransformSurfaceControl() { final Bundle extras = new Bundle(); extras.putParcelable(COMMAND_TRANSFORM_SURFACE_CONTROL, mTransformSurfaceControl); onCommand(COMMAND_TRANSFORM_SURFACE_CONTROL, 0, 0, 0, extras, false); } private void resizePreview(Rect position) { private void resizePreview(Rect position) { if (position != null) { if (position != null) { mSurfaceHolder.setFixedSize(position.width(), position.height()); mSurfaceHolder.setFixedSize(position.width(), position.height()); Loading Loading @@ -2218,7 +2245,8 @@ public abstract class WallpaperService extends Service { if (mScreenshotSurfaceControl != null) { if (mScreenshotSurfaceControl != null) { new SurfaceControl.Transaction() new SurfaceControl.Transaction() .remove(mScreenshotSurfaceControl) .remove(mScreenshotSurfaceControl) .show(mBbqSurfaceControl) .show(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mBbqSurfaceControl) .apply(); .apply(); mScreenshotSurfaceControl = null; mScreenshotSurfaceControl = null; } } Loading Loading @@ -2315,7 +2343,8 @@ public abstract class WallpaperService extends Service { // Place on top everything else. // Place on top everything else. t.setLayer(mScreenshotSurfaceControl, Integer.MAX_VALUE); t.setLayer(mScreenshotSurfaceControl, Integer.MAX_VALUE); t.show(mScreenshotSurfaceControl); t.show(mScreenshotSurfaceControl); t.hide(mBbqSurfaceControl); t.hide(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mBbqSurfaceControl); t.apply(); t.apply(); return true; return true; Loading Loading @@ -2388,10 +2417,16 @@ public abstract class WallpaperService extends Service { mBlastBufferQueue.destroy(); mBlastBufferQueue.destroy(); mBlastBufferQueue = null; mBlastBufferQueue = null; } } final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); if (mBbqSurfaceControl != null) { if (mBbqSurfaceControl != null) { new SurfaceControl.Transaction().remove(mBbqSurfaceControl).apply(); t.remove(mBbqSurfaceControl); mBbqSurfaceControl = null; mBbqSurfaceControl = null; } } if (mTransformSurfaceControl != null) { t.remove(mTransformSurfaceControl); mTransformSurfaceControl = null; } t.apply(); mCreated = false; mCreated = false; } } Loading Loading
core/java/android/app/WallpaperManager.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -321,6 +321,14 @@ public class WallpaperManager { public static final String COMMAND_LOCKSCREEN_TAP = public static final String COMMAND_LOCKSCREEN_TAP = "android.wallpaper.lockscreen_tap"; "android.wallpaper.lockscreen_tap"; /** * Command for {@link #sendWallpaperCommand}: reported when the surface control that could be * used to transform the wallpaper is available * @hide */ public static final String COMMAND_TRANSFORM_SURFACE_CONTROL = "android.wallpaper.transform_surface_control"; /** /** * Extra passed back from setWallpaper() giving the new wallpaper's assigned ID. * Extra passed back from setWallpaper() giving the new wallpaper's assigned ID. * @hide * @hide Loading
core/java/android/app/wallpaper.aconfig +10 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,16 @@ flag { } } } } flag { name: "enable_wallpaper_transform_surface_control_command" namespace: "systemui" description: "Enables sending SurfaceControl to onCommand that could be used to transform the wallpaper" bug: "399077623" metadata { purpose: PURPOSE_BUGFIX } } flag { flag { name: "accurate_wallpaper_downsampling" name: "accurate_wallpaper_downsampling" namespace: "systemui" namespace: "systemui" Loading
core/java/android/service/wallpaper/WallpaperService.java +39 −4 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,9 @@ package android.service.wallpaper; import static android.app.Flags.FLAG_LIVE_WALLPAPER_CONTENT_HANDLING; import static android.app.Flags.FLAG_LIVE_WALLPAPER_CONTENT_HANDLING; import static android.app.Flags.liveWallpaperContentHandling; import static android.app.Flags.liveWallpaperContentHandling; import static android.app.Flags.enableWallpaperTransformSurfaceControlCommand; import static android.app.WallpaperManager.COMMAND_FREEZE; import static android.app.WallpaperManager.COMMAND_FREEZE; import static android.app.WallpaperManager.COMMAND_TRANSFORM_SURFACE_CONTROL; import static android.app.WallpaperManager.COMMAND_UNFREEZE; import static android.app.WallpaperManager.COMMAND_UNFREEZE; import static android.app.WallpaperManager.SetWallpaperFlags; import static android.app.WallpaperManager.SetWallpaperFlags; import static android.graphics.Matrix.MSCALE_X; import static android.graphics.Matrix.MSCALE_X; Loading Loading @@ -374,11 +376,16 @@ public abstract class WallpaperService extends Service { private float mPreviousWallpaperDimAmount = mWallpaperDimAmount; private float mPreviousWallpaperDimAmount = mWallpaperDimAmount; private float mDefaultDimAmount = 0.05f; private float mDefaultDimAmount = 0.05f; SurfaceControl mBbqSurfaceControl; SurfaceControl mBbqSurfaceControl; // Surface control that could be used to apply transformation to the wallpaper // The hiearchy is the following: // mSurfaceControl <- mTransformSurfaceControl <- mBbqSurfaceControl SurfaceControl mTransformSurfaceControl; BLASTBufferQueue mBlastBufferQueue; BLASTBufferQueue mBlastBufferQueue; IBinder mBbqApplyToken = new Binder(); IBinder mBbqApplyToken = new Binder(); private SurfaceControl mScreenshotSurfaceControl; private SurfaceControl mScreenshotSurfaceControl; private Point mScreenshotSize = new Point(); private Point mScreenshotSize = new Point(); private final boolean mEnableTransformSurfaceControlCommand; private final boolean mDisableDrawWakeLock; private final boolean mDisableDrawWakeLock; final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { Loading Loading @@ -568,6 +575,7 @@ public abstract class WallpaperService extends Service { public Engine(Supplier<Long> clockFunction, Handler handler) { public Engine(Supplier<Long> clockFunction, Handler handler) { mClockFunction = clockFunction; mClockFunction = clockFunction; mHandler = handler; mHandler = handler; mEnableTransformSurfaceControlCommand = enableWallpaperTransformSurfaceControlCommand(); mDisableDrawWakeLock = CompatChanges.isChangeEnabled(DISABLE_DRAW_WAKE_LOCK_WALLPAPER) mDisableDrawWakeLock = CompatChanges.isChangeEnabled(DISABLE_DRAW_WAKE_LOCK_WALLPAPER) && disableDrawWakeLock(); && disableDrawWakeLock(); } } Loading Loading @@ -1331,11 +1339,20 @@ public abstract class WallpaperService extends Service { (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); mSurfaceControl.setTransformHint(transformHint); mSurfaceControl.setTransformHint(transformHint); if (mBbqSurfaceControl == null) { if (mBbqSurfaceControl == null) { if (mEnableTransformSurfaceControlCommand) { mTransformSurfaceControl = new SurfaceControl.Builder() .setName("Wallpaper Transform wrapper") .setHidden(false) .setParent(mSurfaceControl) .setCallsite("Wallpaper#relayout") .build(); } mBbqSurfaceControl = new SurfaceControl.Builder() mBbqSurfaceControl = new SurfaceControl.Builder() .setName("Wallpaper BBQ wrapper") .setName("Wallpaper BBQ wrapper") .setHidden(false) .setHidden(false) .setBLASTLayer() .setBLASTLayer() .setParent(mSurfaceControl) .setParent(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mSurfaceControl) .setCallsite("Wallpaper#relayout") .setCallsite("Wallpaper#relayout") .build(); .build(); SurfaceControl.Transaction transaction = SurfaceControl.Transaction transaction = Loading @@ -1348,6 +1365,10 @@ public abstract class WallpaperService extends Service { } } transaction.setDefaultFrameRateCompatibility(mBbqSurfaceControl, transaction.setDefaultFrameRateCompatibility(mBbqSurfaceControl, frameRateCompat).apply(); frameRateCompat).apply(); if (mEnableTransformSurfaceControlCommand) { // TODO: b/406967924 - remove after creating public APIs sendTransformSurfaceControl(); } } } // Propagate transform hint from WM, so we can use the right hint for the // Propagate transform hint from WM, so we can use the right hint for the // first frame. // first frame. Loading Loading @@ -1551,6 +1572,12 @@ public abstract class WallpaperService extends Service { } } } } private void sendTransformSurfaceControl() { final Bundle extras = new Bundle(); extras.putParcelable(COMMAND_TRANSFORM_SURFACE_CONTROL, mTransformSurfaceControl); onCommand(COMMAND_TRANSFORM_SURFACE_CONTROL, 0, 0, 0, extras, false); } private void resizePreview(Rect position) { private void resizePreview(Rect position) { if (position != null) { if (position != null) { mSurfaceHolder.setFixedSize(position.width(), position.height()); mSurfaceHolder.setFixedSize(position.width(), position.height()); Loading Loading @@ -2218,7 +2245,8 @@ public abstract class WallpaperService extends Service { if (mScreenshotSurfaceControl != null) { if (mScreenshotSurfaceControl != null) { new SurfaceControl.Transaction() new SurfaceControl.Transaction() .remove(mScreenshotSurfaceControl) .remove(mScreenshotSurfaceControl) .show(mBbqSurfaceControl) .show(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mBbqSurfaceControl) .apply(); .apply(); mScreenshotSurfaceControl = null; mScreenshotSurfaceControl = null; } } Loading Loading @@ -2315,7 +2343,8 @@ public abstract class WallpaperService extends Service { // Place on top everything else. // Place on top everything else. t.setLayer(mScreenshotSurfaceControl, Integer.MAX_VALUE); t.setLayer(mScreenshotSurfaceControl, Integer.MAX_VALUE); t.show(mScreenshotSurfaceControl); t.show(mScreenshotSurfaceControl); t.hide(mBbqSurfaceControl); t.hide(mEnableTransformSurfaceControlCommand ? mTransformSurfaceControl : mBbqSurfaceControl); t.apply(); t.apply(); return true; return true; Loading Loading @@ -2388,10 +2417,16 @@ public abstract class WallpaperService extends Service { mBlastBufferQueue.destroy(); mBlastBufferQueue.destroy(); mBlastBufferQueue = null; mBlastBufferQueue = null; } } final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); if (mBbqSurfaceControl != null) { if (mBbqSurfaceControl != null) { new SurfaceControl.Transaction().remove(mBbqSurfaceControl).apply(); t.remove(mBbqSurfaceControl); mBbqSurfaceControl = null; mBbqSurfaceControl = null; } } if (mTransformSurfaceControl != null) { t.remove(mTransformSurfaceControl); mTransformSurfaceControl = null; } t.apply(); mCreated = false; mCreated = false; } } Loading