diff options
4 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/window/ITaskOrganizer.aidl b/core/java/android/window/ITaskOrganizer.aidl index 67465252d38e..abca136c347e 100644 --- a/core/java/android/window/ITaskOrganizer.aidl +++ b/core/java/android/window/ITaskOrganizer.aidl @@ -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. diff --git a/core/java/android/window/TaskOrganizer.java b/core/java/android/window/TaskOrganizer.java index 1f5e53369cd8..502680de9bcf 100644 --- a/core/java/android/window/TaskOrganizer.java +++ b/core/java/android/window/TaskOrganizer.java @@ -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) {} diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java index 3a8476729645..65f2bec18758 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java @@ -354,6 +354,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); tx.setAlpha(mLeash, 0f); + tx.show(mLeash); tx.apply(); return; } diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java index 83105c2f8696..1da1d116b938 100644 --- a/services/core/java/com/android/server/wm/TaskOrganizerController.java +++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java @@ -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); |