Merge "Mirror task visibility on task org leash" into rvc-dev am: 1298d2b760 am: 376ac8a830 am: bf3f0c2de8 am: a35b850544

Change-Id: I5d7a9bf0c588bb0ec71d6af72091cbcd98b25314
This commit is contained in:
Winson Chung
2020-05-29 21:52:18 +00:00
committed by Automerger Merge Worker
4 changed files with 18 additions and 1 deletions

View File

@@ -27,7 +27,8 @@ import android.window.WindowContainerToken;
oneway interface ITaskOrganizer {
/**
* A callback when the Task is available for the registered organizer. The client is responsible
* for releasing the SurfaceControl in the callback.
* for releasing the SurfaceControl in the callback. For non-root tasks, the leash may initially
* be hidden so it is up to the organizer to show this task.
*
* @param taskInfo The information about the Task that's available
* @param leash A persistent leash for this Task.

View File

@@ -59,6 +59,11 @@ public class TaskOrganizer extends WindowOrganizer {
}
}
/**
* Called when a task with the registered windowing mode can be controlled by this task
* organizer. For non-root tasks, the leash may initially be hidden so it is up to the organizer
* to show this task.
*/
@BinderThread
public void onTaskAppeared(@NonNull ActivityManager.RunningTaskInfo taskInfo,
@NonNull SurfaceControl leash) {}

View File

@@ -340,6 +340,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
final SurfaceControl.Transaction tx =
mSurfaceControlTransactionFactory.getTransaction();
tx.setAlpha(mLeash, 0f);
tx.show(mLeash);
tx.apply();
return;
}

View File

@@ -98,11 +98,14 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
final ITaskOrganizer mTaskOrganizer;
final Consumer<Runnable> mDeferTaskOrgCallbacksConsumer;
private final SurfaceControl.Transaction mTransaction;
TaskOrganizerCallbacks(WindowManagerService wm, ITaskOrganizer taskOrg,
Consumer<Runnable> deferTaskOrgCallbacksConsumer) {
mService = wm;
mDeferTaskOrgCallbacksConsumer = deferTaskOrgCallbacksConsumer;
mTaskOrganizer = taskOrg;
mTransaction = wm.mTransactionFactory.get();
}
IBinder getBinder() {
@@ -110,10 +113,17 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
}
void onTaskAppeared(Task task) {
final boolean visible = task.isVisible();
final RunningTaskInfo taskInfo = task.getTaskInfo();
mDeferTaskOrgCallbacksConsumer.accept(() -> {
try {
SurfaceControl outSurfaceControl = new SurfaceControl(task.getSurfaceControl());
if (!task.mCreatedByOrganizer && !visible) {
// To prevent flashes, we hide the task prior to sending the leash to the
// task org if the task has previously hidden (ie. when entering PIP)
mTransaction.hide(outSurfaceControl);
mTransaction.apply();
}
mTaskOrganizer.onTaskAppeared(taskInfo, outSurfaceControl);
} catch (RemoteException e) {
Slog.e(TAG, "Exception sending onTaskAppeared callback", e);