Loading core/java/android/window/SnapshotDrawerUtils.java +9 −7 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import android.app.ActivityManager; import android.app.ActivityThread; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.GraphicBuffer; import android.graphics.Paint; import android.graphics.PixelFormat; Loading @@ -68,6 +67,7 @@ import android.view.WindowManager; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.DecorView; import com.android.window.flags.Flags; /** * Utils class to help draw a snapshot on a surface. Loading Loading @@ -181,7 +181,8 @@ public class SnapshotDrawerUtils { // We consider nearly matched dimensions as there can be rounding errors and the user // won't notice very minute differences from scaling one dimension more than the other boolean aspectRatioMismatch = !isAspectRatioMatch(mFrame, mSnapshotW, mSnapshotH); boolean aspectRatioMismatch = !isAspectRatioMatch(mFrame, mSnapshotW, mSnapshotH) && !Flags.drawSnapshotAspectRatioMatch(); // Keep a reference to it such that it doesn't get destroyed when finalized. SurfaceControl childSurfaceControl = new SurfaceControl.Builder(session) Loading Loading @@ -382,8 +383,8 @@ public class SnapshotDrawerUtils { } final SnapshotSurface drawSurface = new SnapshotSurface( rootSurface, snapshot, lp.getTitle()); final WindowManager.LayoutParams attrs = info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams attrs = Flags.drawSnapshotAspectRatioMatch() ? info.mainWindowLayoutParams : info.topOpaqueWindowLayoutParams; final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo; final ActivityManager.TaskDescription taskDescription = getOrCreateTaskDescription(runningTaskInfo); Loading @@ -400,7 +401,8 @@ public class SnapshotDrawerUtils { public static WindowManager.LayoutParams createLayoutParameters(StartingWindowInfo info, CharSequence title, @WindowManager.LayoutParams.WindowType int windowType, int pixelFormat, IBinder token) { final WindowManager.LayoutParams attrs = info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams attrs = Flags.drawSnapshotAspectRatioMatch() ? info.mainWindowLayoutParams : info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams mainWindowParams = info.mainWindowLayoutParams; final InsetsState topWindowInsetsState = info.topOpaqueWindowInsetsState; if (attrs == null || mainWindowParams == null || topWindowInsetsState == null) { Loading Loading @@ -527,7 +529,7 @@ public class SnapshotDrawerUtils { void drawStatusBarBackground(Canvas c, @Nullable Rect alreadyDrawnFrame, int statusBarHeight) { if (statusBarHeight > 0 && Color.alpha(mStatusBarColor) != 0 if (statusBarHeight > 0 && alpha(mStatusBarColor) != 0 && (alreadyDrawnFrame == null || c.getWidth() > alreadyDrawnFrame.right)) { final int rightInset = (int) (mSystemBarInsets.right * mScale); final int left = alreadyDrawnFrame != null ? alreadyDrawnFrame.right : 0; Loading @@ -541,7 +543,7 @@ public class SnapshotDrawerUtils { getNavigationBarRect(c.getWidth(), c.getHeight(), mSystemBarInsets, navigationBarRect, mScale); final boolean visible = isNavigationBarColorViewVisible(); if (visible && Color.alpha(mNavigationBarColor) != 0 if (visible && alpha(mNavigationBarColor) != 0 && !navigationBarRect.isEmpty()) { c.drawRect(navigationBarRect, mNavigationBarPaint); } Loading core/java/android/window/flags/windowing_frontend.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -172,3 +172,14 @@ flag { bug: "238206323" is_fixed_read_only: true } flag { name: "draw_snapshot_aspect_ratio_match" namespace: "windowing_frontend" description: "The aspect ratio should always match when drawing snapshot" bug: "341020277" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } } No newline at end of file services/core/java/com/android/server/wm/Task.java +9 −7 Original line number Diff line number Diff line Loading @@ -3624,6 +3624,7 @@ class Task extends TaskFragment { // If the developer has persist a different configuration, we need to override it to the // starting window because persisted configuration does not effect to Task. info.taskInfo.configuration.setTo(activity.getConfiguration()); if (!Flags.drawSnapshotAspectRatioMatch()) { final ActivityRecord topFullscreenActivity = getTopFullscreenActivity(); if (topFullscreenActivity != null) { final WindowState mainWindow = topFullscreenActivity.findMainWindow(false); Loading @@ -3633,6 +3634,7 @@ class Task extends TaskFragment { info.topOpaqueWindowLayoutParams = mainWindow.getAttrs(); } } } return info; } Loading Loading
core/java/android/window/SnapshotDrawerUtils.java +9 −7 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import android.app.ActivityManager; import android.app.ActivityThread; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.GraphicBuffer; import android.graphics.Paint; import android.graphics.PixelFormat; Loading @@ -68,6 +67,7 @@ import android.view.WindowManager; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.DecorView; import com.android.window.flags.Flags; /** * Utils class to help draw a snapshot on a surface. Loading Loading @@ -181,7 +181,8 @@ public class SnapshotDrawerUtils { // We consider nearly matched dimensions as there can be rounding errors and the user // won't notice very minute differences from scaling one dimension more than the other boolean aspectRatioMismatch = !isAspectRatioMatch(mFrame, mSnapshotW, mSnapshotH); boolean aspectRatioMismatch = !isAspectRatioMatch(mFrame, mSnapshotW, mSnapshotH) && !Flags.drawSnapshotAspectRatioMatch(); // Keep a reference to it such that it doesn't get destroyed when finalized. SurfaceControl childSurfaceControl = new SurfaceControl.Builder(session) Loading Loading @@ -382,8 +383,8 @@ public class SnapshotDrawerUtils { } final SnapshotSurface drawSurface = new SnapshotSurface( rootSurface, snapshot, lp.getTitle()); final WindowManager.LayoutParams attrs = info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams attrs = Flags.drawSnapshotAspectRatioMatch() ? info.mainWindowLayoutParams : info.topOpaqueWindowLayoutParams; final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo; final ActivityManager.TaskDescription taskDescription = getOrCreateTaskDescription(runningTaskInfo); Loading @@ -400,7 +401,8 @@ public class SnapshotDrawerUtils { public static WindowManager.LayoutParams createLayoutParameters(StartingWindowInfo info, CharSequence title, @WindowManager.LayoutParams.WindowType int windowType, int pixelFormat, IBinder token) { final WindowManager.LayoutParams attrs = info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams attrs = Flags.drawSnapshotAspectRatioMatch() ? info.mainWindowLayoutParams : info.topOpaqueWindowLayoutParams; final WindowManager.LayoutParams mainWindowParams = info.mainWindowLayoutParams; final InsetsState topWindowInsetsState = info.topOpaqueWindowInsetsState; if (attrs == null || mainWindowParams == null || topWindowInsetsState == null) { Loading Loading @@ -527,7 +529,7 @@ public class SnapshotDrawerUtils { void drawStatusBarBackground(Canvas c, @Nullable Rect alreadyDrawnFrame, int statusBarHeight) { if (statusBarHeight > 0 && Color.alpha(mStatusBarColor) != 0 if (statusBarHeight > 0 && alpha(mStatusBarColor) != 0 && (alreadyDrawnFrame == null || c.getWidth() > alreadyDrawnFrame.right)) { final int rightInset = (int) (mSystemBarInsets.right * mScale); final int left = alreadyDrawnFrame != null ? alreadyDrawnFrame.right : 0; Loading @@ -541,7 +543,7 @@ public class SnapshotDrawerUtils { getNavigationBarRect(c.getWidth(), c.getHeight(), mSystemBarInsets, navigationBarRect, mScale); final boolean visible = isNavigationBarColorViewVisible(); if (visible && Color.alpha(mNavigationBarColor) != 0 if (visible && alpha(mNavigationBarColor) != 0 && !navigationBarRect.isEmpty()) { c.drawRect(navigationBarRect, mNavigationBarPaint); } Loading
core/java/android/window/flags/windowing_frontend.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -172,3 +172,14 @@ flag { bug: "238206323" is_fixed_read_only: true } flag { name: "draw_snapshot_aspect_ratio_match" namespace: "windowing_frontend" description: "The aspect ratio should always match when drawing snapshot" bug: "341020277" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } } No newline at end of file
services/core/java/com/android/server/wm/Task.java +9 −7 Original line number Diff line number Diff line Loading @@ -3624,6 +3624,7 @@ class Task extends TaskFragment { // If the developer has persist a different configuration, we need to override it to the // starting window because persisted configuration does not effect to Task. info.taskInfo.configuration.setTo(activity.getConfiguration()); if (!Flags.drawSnapshotAspectRatioMatch()) { final ActivityRecord topFullscreenActivity = getTopFullscreenActivity(); if (topFullscreenActivity != null) { final WindowState mainWindow = topFullscreenActivity.findMainWindow(false); Loading @@ -3633,6 +3634,7 @@ class Task extends TaskFragment { info.topOpaqueWindowLayoutParams = mainWindow.getAttrs(); } } } return info; } Loading