Merge "Attempt to use snapshot starting window for task trampoline" into tm-dev

This commit is contained in:
Riddle Hsu
2022-04-29 10:38:08 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 9 deletions

View File

@@ -2447,6 +2447,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
private int getStartingWindowType(boolean newTask, boolean taskSwitch, boolean processRunning, private int getStartingWindowType(boolean newTask, boolean taskSwitch, boolean processRunning,
boolean allowTaskSnapshot, boolean activityCreated, boolean activityAllDrawn, boolean allowTaskSnapshot, boolean activityCreated, boolean activityAllDrawn,
TaskSnapshot snapshot) { TaskSnapshot snapshot) {
// A special case that a new activity is launching to an existing task which is moving to
// front. If the launching activity is the one that started the task, it could be a
// trampoline that will be always created and finished immediately. Then give a chance to
// see if the snapshot is usable for the current running activity so the transition will
// look smoother, instead of showing a splash screen on the second launch.
if (!newTask && taskSwitch && processRunning && !activityCreated && task.intent != null
&& mActivityComponent.equals(task.intent.getComponent())) {
final ActivityRecord topAttached = task.getActivity(ActivityRecord::attachedToProcess);
if (topAttached != null && topAttached.isSnapshotCompatible(snapshot)) {
return STARTING_WINDOW_TYPE_SNAPSHOT;
}
}
final boolean isActivityHome = isActivityTypeHome(); final boolean isActivityHome = isActivityTypeHome();
if ((newTask || !processRunning || (taskSwitch && !activityCreated)) if ((newTask || !processRunning || (taskSwitch && !activityCreated))
&& !isActivityHome) { && !isActivityHome) {

View File

@@ -26,6 +26,7 @@ import static android.window.StartingWindowInfo.TYPE_PARAMETER_PROCESS_RUNNING;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH; import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN; import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;
import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SNAPSHOT;
import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SPLASH_SCREEN; import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SPLASH_SCREEN;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -114,7 +115,7 @@ public class StartingSurfaceController {
if (allowTaskSnapshot) { if (allowTaskSnapshot) {
parameter |= TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT; parameter |= TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT;
} }
if (activityCreated) { if (activityCreated || startingWindowType == STARTING_WINDOW_TYPE_SNAPSHOT) {
parameter |= TYPE_PARAMETER_ACTIVITY_CREATED; parameter |= TYPE_PARAMETER_ACTIVITY_CREATED;
} }
if (isSolidColor) { if (isSolidColor) {
@@ -138,7 +139,6 @@ public class StartingSurfaceController {
final WindowState topFullscreenOpaqueWindow; final WindowState topFullscreenOpaqueWindow;
final Task task; final Task task;
synchronized (mService.mGlobalLock) { synchronized (mService.mGlobalLock) {
final WindowState mainWindow = activity.findMainWindow();
task = activity.getTask(); task = activity.getTask();
if (task == null) { if (task == null) {
Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find task for activity=" Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find task for activity="
@@ -153,9 +153,9 @@ public class StartingSurfaceController {
return null; return null;
} }
topFullscreenOpaqueWindow = topFullscreenActivity.getTopFullscreenOpaqueWindow(); topFullscreenOpaqueWindow = topFullscreenActivity.getTopFullscreenOpaqueWindow();
if (mainWindow == null || topFullscreenOpaqueWindow == null) { if (topFullscreenOpaqueWindow == null) {
Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for activity=" Slog.w(TAG, "TaskSnapshotSurface.create: no opaque window in "
+ activity); + topFullscreenActivity);
return null; return null;
} }
if (topFullscreenActivity.getWindowConfiguration().getRotation() if (topFullscreenActivity.getWindowConfiguration().getRotation()

View File

@@ -56,6 +56,7 @@ import static android.view.SurfaceControl.METADATA_TASK_ID;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED; import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
@@ -3525,10 +3526,13 @@ class Task extends TaskFragment {
mAtmService.mKeyguardController.isDisplayOccluded(DEFAULT_DISPLAY); mAtmService.mKeyguardController.isDisplayOccluded(DEFAULT_DISPLAY);
info.startingWindowTypeParameter = activity.mStartingData.mTypeParams; info.startingWindowTypeParameter = activity.mStartingData.mTypeParams;
final WindowState mainWindow = activity.findMainWindow(); if ((info.startingWindowTypeParameter
if (mainWindow != null) { & StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_CREATED) != 0) {
info.mainWindowLayoutParams = mainWindow.getAttrs(); final WindowState topMainWin = getWindow(w -> w.mAttrs.type == TYPE_BASE_APPLICATION);
info.requestedVisibilities.set(mainWindow.getRequestedVisibilities()); if (topMainWin != null) {
info.mainWindowLayoutParams = topMainWin.getAttrs();
info.requestedVisibilities.set(topMainWin.getRequestedVisibilities());
}
} }
// If the developer has persist a different configuration, we need to override it to the // 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. // starting window because persisted configuration does not effect to Task.