Merge "Hook up shell-transitions screenshotting for recents" into tm-dev
This commit is contained in:
@@ -267,6 +267,12 @@ interface IActivityTaskManager {
|
||||
*/
|
||||
android.window.TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution);
|
||||
|
||||
/**
|
||||
* @param taskId the id of the task to take a snapshot of
|
||||
* @return a graphic buffer representing a screenshot of a task
|
||||
*/
|
||||
android.window.TaskSnapshot takeTaskSnapshot(int taskId);
|
||||
|
||||
/**
|
||||
* Return the user id of last resumed activity.
|
||||
*/
|
||||
|
||||
@@ -47,6 +47,7 @@ import android.window.IRemoteTransition;
|
||||
import android.window.IRemoteTransitionFinishedCallback;
|
||||
import android.window.PictureInPictureSurfaceTransaction;
|
||||
import android.window.RemoteTransition;
|
||||
import android.window.TaskSnapshot;
|
||||
import android.window.TransitionFilter;
|
||||
import android.window.TransitionInfo;
|
||||
import android.window.WindowContainerToken;
|
||||
@@ -322,7 +323,16 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
}
|
||||
|
||||
@Override public ThumbnailData screenshotTask(int taskId) {
|
||||
return mWrapped != null ? mWrapped.screenshotTask(taskId) : null;
|
||||
try {
|
||||
final TaskSnapshot snapshot =
|
||||
ActivityTaskManager.getService().takeTaskSnapshot(taskId);
|
||||
if (snapshot != null) {
|
||||
return new ThumbnailData(snapshot);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to screenshot task", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public void setInputConsumerEnabled(boolean enabled) {
|
||||
|
||||
@@ -3599,25 +3599,41 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
mAmInternal.enforceCallingPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return getTaskSnapshot(taskId, isLowResolution, true /* restoreFromDisk */);
|
||||
final Task task;
|
||||
synchronized (mGlobalLock) {
|
||||
task = mRootWindowContainer.anyTaskForId(taskId,
|
||||
MATCH_ATTACHED_TASK_OR_RECENT_TASKS);
|
||||
if (task == null) {
|
||||
Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
|
||||
private TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution,
|
||||
boolean restoreFromDisk) {
|
||||
final Task task;
|
||||
synchronized (mGlobalLock) {
|
||||
task = mRootWindowContainer.anyTaskForId(taskId,
|
||||
MATCH_ATTACHED_TASK_OR_RECENT_TASKS);
|
||||
if (task == null) {
|
||||
Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
|
||||
return null;
|
||||
@Override
|
||||
public TaskSnapshot takeTaskSnapshot(int taskId) {
|
||||
mAmInternal.enforceCallingPermission(READ_FRAME_BUFFER, "takeTaskSnapshot()");
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mGlobalLock) {
|
||||
final Task task = mRootWindowContainer.anyTaskForId(taskId,
|
||||
MATCH_ATTACHED_TASK_OR_RECENT_TASKS);
|
||||
if (task == null || !task.isVisible()) {
|
||||
Slog.w(TAG, "takeTaskSnapshot: taskId=" + taskId + " not found or not visible");
|
||||
return null;
|
||||
}
|
||||
return mWindowManager.mTaskSnapshotController.captureTaskSnapshot(
|
||||
task, false /* snapshotHome */);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
// Don't call this while holding the lock as this operation might hit the disk.
|
||||
return task.getSnapshot(isLowResolution, restoreFromDisk);
|
||||
}
|
||||
|
||||
/** Return the user id of the last resumed activity. */
|
||||
@@ -6559,8 +6575,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
@Override
|
||||
public TaskSnapshot getTaskSnapshotBlocking(
|
||||
int taskId, boolean isLowResolution) {
|
||||
return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution,
|
||||
true /* restoreFromDisk */);
|
||||
return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -967,17 +967,6 @@ class Task extends TaskFragment {
|
||||
|| targetWindowingMode == WINDOWING_MODE_FREEFORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT HOLD THE ACTIVITY MANAGER LOCK WHEN CALLING THIS METHOD!
|
||||
*/
|
||||
TaskSnapshot getSnapshot(boolean isLowResolution, boolean restoreFromDisk) {
|
||||
|
||||
// TODO: Move this to {@link TaskWindowContainerController} once recent tasks are more
|
||||
// synchronized between AM and WM.
|
||||
return mAtmService.mWindowManager.getTaskSnapshot(mTaskId, mUserId, isLowResolution,
|
||||
restoreFromDisk);
|
||||
}
|
||||
|
||||
void touchActiveTime() {
|
||||
lastActiveTime = SystemClock.elapsedRealtime();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user