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

Commit 14a657c9 authored by Winson Chung's avatar Winson Chung
Browse files

Mirror task visibility on task org leash

- Depending on the navigation mode, the task is either visible or not
  when entering PIP, and if it is not visible, initially hide the leash
  so that SysUI can control it's visibilty to prevent a flash

Bug: 156941210
Test: Introduce artificial delay on sysui taskAppeared() and verify that
      we don't see the task when entering pip in gesture nav (and that
      it still works in 3 button)

Change-Id: I291afd209af118ac178f8a6421d7df25974315f0
parent ef5ab039
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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.
+5 −0
Original line number Diff line number Diff line
@@ -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) {}
+1 −0
Original line number Diff line number Diff line
@@ -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;
        }
+10 −0
Original line number Diff line number Diff line
@@ -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);