Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21c3f18d authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Tuning performance for back to home transition.

Basically revert 8b1aed02, shell transiiton will capture task snapshot
once onTransitionReady signal send to shell, or capture in
RecentsTransitionHandler#getSnapshotsForPausingTasks, so the capture
action shouldn't related to display anymore, therefore doesn't need to
trigger capture task snapshot during prepare transition.
TaskStackChangeListeners#onTaskStackChanged shall ask
RecentsModel#onTaskStackChangedBackground to load task thumbnail.

Bug: 307389404
Test: open app -> back to -> enter overview -> launch app. Verify on
perfetto that capture snapshot won't happen while prepare transition,
and capture snapshot should only happen once.

Change-Id: Ic54b95570a7e1fe832c7faa84f17b3d0de95ee97
parent 2ef3c463
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -259,12 +259,10 @@ interface IActivityTaskManager {
     * @param taskId the id of the task to retrieve the sAutoapshots for
     * @param isLowResolution if set, if the snapshot needs to be loaded from disk, this will load
     *                          a reduced resolution of it, which is much faster
     * @param takeSnapshotIfNeeded if set, call {@link #takeTaskSnapshot} to trigger the snapshot
                                   if no cache exists.
     * @return a graphic buffer representing a screenshot of a task
     */
    android.window.TaskSnapshot getTaskSnapshot(
            int taskId, boolean isLowResolution, boolean takeSnapshotIfNeeded);
            int taskId, boolean isLowResolution);

    /**
     * Requests for a new snapshot to be taken for the task with the given id, storing it in the
+1 −3
Original line number Diff line number Diff line
@@ -129,9 +129,7 @@ object PipUtils {
    @JvmStatic
    fun getTaskSnapshot(taskId: Int, isLowResolution: Boolean): TaskSnapshot? {
        return if (taskId <= 0) null else try {
            ActivityTaskManager.getService().getTaskSnapshot(
                taskId, isLowResolution, false /* takeSnapshotIfNeeded */
            )
            ActivityTaskManager.getService().getTaskSnapshot(taskId, isLowResolution)
        } catch (e: RemoteException) {
            Log.e(TAG, "Failed to get task snapshot, taskId=$taskId", e)
            null
+2 −4
Original line number Diff line number Diff line
@@ -137,14 +137,12 @@ public class ActivityManagerWrapper {
    }

    /**
     * @return a {@link ThumbnailData} with {@link TaskSnapshot} for the given {@param taskId}.
     *         The snapshot will be triggered if no cached {@link TaskSnapshot} exists.
     * @return the task snapshot for the given {@param taskId}.
     */
    public @NonNull ThumbnailData getTaskThumbnail(int taskId, boolean isLowResolution) {
        TaskSnapshot snapshot = null;
        try {
            snapshot = getService().getTaskSnapshot(taskId, isLowResolution,
                    true /* takeSnapshotIfNeeded */);
            snapshot = getService().getTaskSnapshot(taskId, isLowResolution);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to retrieve task snapshot", e);
        }
+4 −9
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import static android.view.WindowManager.TRANSIT_PIP;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT;
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_DREAM;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
@@ -3825,8 +3826,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

    @Override
    public TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution,
            boolean takeSnapshotIfNeeded) {
    public TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution) {
        mAmInternal.enforceCallingPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
        final long ident = Binder.clearCallingIdentity();
        try {
@@ -3840,12 +3840,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                }
            }
            // Don't call this while holding the lock as this operation might hit the disk.
            TaskSnapshot taskSnapshot = mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
            return mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
                    task.mUserId, true /* restoreFromDisk */, isLowResolution);
            if (taskSnapshot == null && takeSnapshotIfNeeded) {
                taskSnapshot = takeTaskSnapshot(taskId, false /* updateCache */);
            }
            return taskSnapshot;
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
@@ -7064,8 +7060,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        @Override
        public TaskSnapshot getTaskSnapshotBlocking(
                int taskId, boolean isLowResolution) {
            return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution,
                    false /* takeSnapshotIfNeeded */);
            return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution);
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -1444,7 +1444,7 @@ public class RecentTasksTest extends WindowTestsBase {
        });
        assertSecurityException(expectCallable,
                () -> mAtm.startActivityFromRecents(0, new Bundle()));
        assertSecurityException(expectCallable, () -> mAtm.getTaskSnapshot(0, true, false));
        assertSecurityException(expectCallable, () -> mAtm.getTaskSnapshot(0, true));
        assertSecurityException(expectCallable, () -> mAtm.registerTaskStackListener(null));
        assertSecurityException(expectCallable,
                () -> mAtm.unregisterTaskStackListener(null));