summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author wilsonshih <wilsonshih@google.com> 2023-12-26 05:44:14 +0000
committer wilsonshih <wilsonshih@google.com> 2024-02-20 10:55:23 +0000
commitfb5f9153d89df28e89e48b2d92f09eee249ea5b3 (patch)
treebbf684863ded9e2e311914b7b8eba6a5670f587a
parent4f7007cfcf87b54d853ea8a446d8400ce02d5cb5 (diff)
Do not capture letterbox for activity snapshot.
Similar to activity window, there should draw splash screen/snapshot starting window based on activity's bounds, so when capture activity snapshot, the bounds should limit to activity's bounds instead of task bounds. While creating the windowless starting window, offset the surface position based on activity's configuration. Also request to draw letterbox when using windowless snapshot. Bug: 317736686 Test: enable activity snapshot & predictive back, verify when playing cross activity animation, the windowless surface should be place at the same position of activity. Change-Id: Ic3d717ef9901c30b3af7258f352d1ed21ca5bb3e
-rw-r--r--services/core/java/com/android/server/wm/AbsAppSnapshotController.java16
-rw-r--r--services/core/java/com/android/server/wm/ActivitySnapshotController.java7
-rw-r--r--services/core/java/com/android/server/wm/BackNavigationController.java34
-rw-r--r--services/core/java/com/android/server/wm/Letterbox.java2
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotController.java5
5 files changed, 41 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java
index e5c743cc69e4..fd4b06148c5f 100644
--- a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java
+++ b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java
@@ -147,6 +147,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
@Nullable
protected abstract ActivityRecord findAppTokenForSnapshot(TYPE source);
protected abstract boolean use16BitFormat();
+ protected abstract Rect getLetterboxInsets(ActivityRecord topActivity);
/**
* This is different than {@link #recordSnapshotInner(TYPE)} because it doesn't store
@@ -309,7 +310,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
final WindowState mainWindow = result.second;
final Rect contentInsets = getSystemBarInsets(mainWindow.getFrame(),
mainWindow.getInsetsStateWithVisibilityOverride());
- final Rect letterboxInsets = activity.getLetterboxInsets();
+ final Rect letterboxInsets = getLetterboxInsets(activity);
InsetUtils.addInsets(contentInsets, letterboxInsets);
builder.setIsRealSnapshot(true);
builder.setId(System.currentTimeMillis());
@@ -335,22 +336,27 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
final Configuration taskConfig = activity.getTask().getConfiguration();
final int displayRotation = taskConfig.windowConfiguration.getDisplayRotation();
final Rect outCrop = new Rect();
+ final Point taskSize = new Point();
final Transition.ChangeInfo changeInfo = mCurrentChangeInfo;
if (changeInfo != null && changeInfo.mRotation != displayRotation) {
// For example, the source is closing and display rotation changes at the same time.
// The snapshot should record the state in previous rotation.
outCrop.set(changeInfo.mAbsoluteBounds);
+ taskSize.set(changeInfo.mAbsoluteBounds.right, changeInfo.mAbsoluteBounds.bottom);
builder.setRotation(changeInfo.mRotation);
builder.setOrientation(changeInfo.mAbsoluteBounds.height()
>= changeInfo.mAbsoluteBounds.width()
? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE);
} else {
- outCrop.set(taskConfig.windowConfiguration.getBounds());
+ final Configuration srcConfig = source.getConfiguration();
+ outCrop.set(srcConfig.windowConfiguration.getBounds());
+ final Rect taskBounds = taskConfig.windowConfiguration.getBounds();
+ taskSize.set(taskBounds.width(), taskBounds.height());
builder.setRotation(displayRotation);
- builder.setOrientation(taskConfig.orientation);
+ builder.setOrientation(srcConfig.orientation);
}
outCrop.offsetTo(0, 0);
- builder.setTaskSize(new Point(outCrop.right, outCrop.bottom));
+ builder.setTaskSize(taskSize);
return outCrop;
}
@@ -438,7 +444,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
return null;
}
final Rect contentInsets = new Rect(systemBarInsets);
- final Rect letterboxInsets = topActivity.getLetterboxInsets();
+ final Rect letterboxInsets = getLetterboxInsets(topActivity);
InsetUtils.addInsets(contentInsets, letterboxInsets);
// Note, the app theme snapshot is never translucent because we enforce a non-translucent
// color above
diff --git a/services/core/java/com/android/server/wm/ActivitySnapshotController.java b/services/core/java/com/android/server/wm/ActivitySnapshotController.java
index f83003d4e278..62fb4bfc74d7 100644
--- a/services/core/java/com/android/server/wm/ActivitySnapshotController.java
+++ b/services/core/java/com/android/server/wm/ActivitySnapshotController.java
@@ -21,6 +21,7 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
+import android.graphics.Rect;
import android.os.Environment;
import android.os.SystemProperties;
import android.os.Trace;
@@ -617,6 +618,12 @@ class ActivitySnapshotController extends AbsAppSnapshotController<ActivityRecord
return mPersistInfoProvider.use16BitFormat();
}
+ @Override
+ protected Rect getLetterboxInsets(ActivityRecord topActivity) {
+ // Do not capture letterbox for ActivityRecord
+ return Letterbox.EMPTY_RECT;
+ }
+
@NonNull
private SparseArray<UserSavedFile> getUserFiles(int userId) {
if (mUserSavedFiles.get(userId) == null) {
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java
index 38ee4564396e..b51f89931128 100644
--- a/services/core/java/com/android/server/wm/BackNavigationController.java
+++ b/services/core/java/com/android/server/wm/BackNavigationController.java
@@ -35,6 +35,7 @@ import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_PREDICT_BACK;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.ResourceId;
import android.graphics.Point;
import android.graphics.Rect;
@@ -1065,8 +1066,9 @@ class BackNavigationController {
if (mOpenActivities != null) {
for (int i = mOpenActivities.length - 1; i >= 0; --i) {
- if (mOpenActivities[i].mLaunchTaskBehind) {
- restoreLaunchBehind(mOpenActivities[i]);
+ final ActivityRecord resetActivity = mOpenActivities[i];
+ if (resetActivity.mLaunchTaskBehind) {
+ restoreLaunchBehind(resetActivity);
}
}
}
@@ -1233,8 +1235,7 @@ class BackNavigationController {
represent.allowEnterPip);
}
- void createStartingSurface(@NonNull WindowContainer closeWindow,
- ActivityRecord[] visibleOpenActivities) {
+ void createStartingSurface(ActivityRecord[] visibleOpenActivities) {
if (mAdaptors[0].mSwitchType == DIALOG_CLOSE) {
return;
}
@@ -1253,12 +1254,15 @@ class BackNavigationController {
return;
}
final TaskSnapshot snapshot = getSnapshot(mainOpen, visibleOpenActivities);
+ // If there is only one adaptor, attach the windowless window to top activity,
+ // because fixed rotation only applies on activity.
+ // Note that embedded activity won't use fixed rotation.
+ final Configuration openConfig = mAdaptors.length == 1
+ ? mainActivity.getConfiguration() : openTask.getConfiguration();
mRequestedStartingSurfaceId = openTask.mAtmService.mTaskOrganizerController
.addWindowlessStartingSurface(openTask, mainActivity,
- // Choose configuration from closeWindow, because the configuration
- // of opening target may not update before resume, so the starting
- // surface should occlude it entirely.
- mRemoteAnimationTarget.leash, snapshot, closeWindow.getConfiguration(),
+ mAdaptors.length == 1 ? mainActivity.getSurfaceControl()
+ : mRemoteAnimationTarget.leash, snapshot, openConfig,
new IWindowlessStartingSurfaceCallback.Stub() {
// Once the starting surface has been created in shell, it will call
// onSurfaceAdded to pass the created surface to core, so if a
@@ -1290,10 +1294,7 @@ class BackNavigationController {
if (mStartingSurface != null && mStartingSurface.isValid()) {
SurfaceControl.Transaction transaction = reparentTransaction != null
? reparentTransaction : mAdaptors[0].mTarget.getPendingTransaction();
- if (mAdaptors.length == 1) {
- transaction.reparent(mStartingSurface,
- mAdaptors[0].mTarget.getSurfaceControl());
- } else {
+ if (mAdaptors.length != 1) {
// More than one opening window, reparent starting surface to leaf task.
final WindowContainer wc = mAdaptors[0].mTarget;
final Task task = wc.asActivityRecord() != null
@@ -1499,16 +1500,15 @@ class BackNavigationController {
/**
* Apply preview strategy on the opening target
- * @param closeWindow The close window, where it's configuration should cover all
- * open target(s).
+ *
* @param openAnimationAdaptor The animator who can create starting surface.
* @param visibleOpenActivities The visible activities in opening targets.
*/
- private void applyPreviewStrategy(@NonNull WindowContainer closeWindow,
+ private void applyPreviewStrategy(
@NonNull BackWindowAnimationAdaptorWrapper openAnimationAdaptor,
@NonNull ActivityRecord[] visibleOpenActivities) {
if (isSupportWindowlessSurface() && mShowWindowlessSurface && !mIsLaunchBehind) {
- openAnimationAdaptor.createStartingSurface(closeWindow, visibleOpenActivities);
+ openAnimationAdaptor.createStartingSurface(visibleOpenActivities);
} else {
for (int i = visibleOpenActivities.length - 1; i >= 0; --i) {
setLaunchBehind(visibleOpenActivities[i]);
@@ -1539,7 +1539,7 @@ class BackNavigationController {
}
mCloseTarget.mTransitionController.mSnapshotController
.mActivitySnapshotController.clearOnBackPressedActivities();
- applyPreviewStrategy(mCloseTarget, mOpenAnimAdaptor, openingActivities);
+ applyPreviewStrategy(mOpenAnimAdaptor, openingActivities);
final IBackAnimationFinishedCallback callback = makeAnimationFinishedCallback();
final RemoteAnimationTarget[] targets = getAnimationTargets();
diff --git a/services/core/java/com/android/server/wm/Letterbox.java b/services/core/java/com/android/server/wm/Letterbox.java
index e66321ae8219..362d4efa0825 100644
--- a/services/core/java/com/android/server/wm/Letterbox.java
+++ b/services/core/java/com/android/server/wm/Letterbox.java
@@ -49,7 +49,7 @@ import java.util.function.Supplier;
*/
public class Letterbox {
- private static final Rect EMPTY_RECT = new Rect();
+ static final Rect EMPTY_RECT = new Rect();
private static final Point ZERO_POINT = new Point(0, 0);
private final Supplier<SurfaceControl.Builder> mSurfaceControlFactory;
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 8b622d28b651..4218f8f88a07 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -270,6 +270,11 @@ class TaskSnapshotController extends AbsAppSnapshotController<Task, TaskSnapshot
return source.getTaskDescription();
}
+ @Override
+ protected Rect getLetterboxInsets(ActivityRecord topActivity) {
+ return topActivity.getLetterboxInsets();
+ }
+
void getClosingTasksInner(Task task, ArraySet<Task> outClosingTasks) {
// Since RecentsAnimation will handle task snapshot while switching apps with the
// best capture timing (e.g. IME window capture),