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

Commit 1e51061a authored by Iris Yang's avatar Iris Yang Committed by Automerger Merge Worker
Browse files

Merge "Take the snapshot if the thumbnail cache returns empty." into tm-qpr-dev am: 483981c6

parents dcde4b82 483981c6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -263,9 +263,12 @@ 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);
    android.window.TaskSnapshot getTaskSnapshot(
            int taskId, boolean isLowResolution, boolean takeSnapshotIfNeeded);

    /**
     * @param taskId the id of the task to take a snapshot of
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class PipUtils {
        if (taskId <= 0) return null;
        try {
            return ActivityTaskManager.getService().getTaskSnapshot(
                    taskId, isLowResolution);
                    taskId, isLowResolution, false /* takeSnapshotIfNeeded */);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to get task snapshot, taskId=" + taskId, e);
            return null;
+4 −2
Original line number Diff line number Diff line
@@ -137,12 +137,14 @@ public class ActivityManagerWrapper {
    }

    /**
     * @return the task snapshot for the given {@param taskId}.
     * @return a {@link ThumbnailData} with {@link TaskSnapshot} for the given {@param taskId}.
     *         The snapshot will be triggered if no cached {@link TaskSnapshot} exists.
     */
    public @NonNull ThumbnailData getTaskThumbnail(int taskId, boolean isLowResolution) {
        TaskSnapshot snapshot = null;
        try {
            snapshot = getService().getTaskSnapshot(taskId, isLowResolution);
            snapshot = getService().getTaskSnapshot(taskId, isLowResolution,
                    true /* takeSnapshotIfNeeded */);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to retrieve task snapshot", e);
        }
+10 −4
Original line number Diff line number Diff line
@@ -3660,7 +3660,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

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

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