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

Commit c61abd35 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Suppress recent tasks updates while applying a window container...

Merge "Revert "Suppress recent tasks updates while applying a window container transaction"" into main
parents a0b939b3 6840591a
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -1925,8 +1925,6 @@ class RecentTasks {
        if (!mHiddenTasks.isEmpty()) {
        if (!mHiddenTasks.isEmpty()) {
            pw.println("mHiddenTasks=" + mHiddenTasks);
            pw.println("mHiddenTasks=" + mHiddenTasks);
        }
        }
        pw.println("mRecentsUpdatesSuppressed="
                + mTaskNotificationController.areRecentsUpdatesSuppressed());
        if (mTasks.isEmpty()) {
        if (mTasks.isEmpty()) {
            return;
            return;
        }
        }
+0 −40
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.server.wm;
package com.android.server.wm;


import android.annotation.IntDef;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ITaskStackListener;
import android.app.ITaskStackListener;
@@ -199,11 +198,6 @@ class TaskChangeNotificationController {
        l.onLockTaskModeChanged(m.arg1);
        l.onLockTaskModeChanged(m.arg1);
    };
    };


    // Whether notifications related to recent tasks are currently suppressed
    private boolean mSuppressRecentsUpdates;
    // Whether any notifications were called while suppressed, to be notified once not suppressed
    private boolean mRecentsUpdatedWhileSuppressed;

    @FunctionalInterface
    @FunctionalInterface
    public interface TaskStackConsumer {
    public interface TaskStackConsumer {
        void accept(ITaskStackListener t, Message m) throws RemoteException;
        void accept(ITaskStackListener t, Message m) throws RemoteException;
@@ -360,29 +354,6 @@ class TaskChangeNotificationController {
        }
        }
    }
    }


    /**
     * Sets whether to suppress recents task list updates.
     */
    void setSuppressRecentsUpdates(boolean suppress) {
        if (mSuppressRecentsUpdates == suppress) {
            throw new IllegalStateException("Recents updates already suppressed");
        }
        mSuppressRecentsUpdates = suppress;
        if (!suppress) {
            // Notify now if the task list was updated while suppressed
            if (mRecentsUpdatedWhileSuppressed) {
                notifyTaskListUpdated();
            }
        }
    }

    /**
     * Returns whether recents task list updates are suppressed.
     */
    boolean areRecentsUpdatesSuppressed() {
        return mSuppressRecentsUpdates;
    }

    /** Notifies all listeners when the task stack has changed. */
    /** Notifies all listeners when the task stack has changed. */
    void notifyTaskStackChanged() {
    void notifyTaskStackChanged() {
        mTaskSupervisor.getActivityMetricsLogger().logWindowState();
        mTaskSupervisor.getActivityMetricsLogger().logWindowState();
@@ -565,17 +536,6 @@ class TaskChangeNotificationController {
     * Called when any additions or deletions to the recent tasks list have been made.
     * Called when any additions or deletions to the recent tasks list have been made.
     */
     */
    void notifyTaskListUpdated() {
    void notifyTaskListUpdated() {
        if (areRecentsUpdatesSuppressed()) {
            // Defer until updates are no longer suppressed
            mRecentsUpdatedWhileSuppressed = true;
            return;
        }
        queueTaskListUpdated();
        mRecentsUpdatedWhileSuppressed = false;
    }

    /** Queues a task-list-updated notification. */
    void queueTaskListUpdated() {
        final Message msg = mHandler.obtainMessage(NOTIFY_TASK_LIST_UPDATED_LISTENERS_MSG);
        final Message msg = mHandler.obtainMessage(NOTIFY_TASK_LIST_UPDATED_LISTENERS_MSG);
        forAllLocalListeners(mNotifyTaskListUpdated, msg);
        forAllLocalListeners(mNotifyTaskListUpdated, msg);
        msg.sendToTarget();
        msg.sendToTarget();
+0 −2
Original line number Original line Diff line number Diff line
@@ -650,7 +650,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
        mService.mTaskSupervisor.beginDeferResume();
        mService.mTaskSupervisor.beginDeferResume();
        boolean deferResume = true;
        boolean deferResume = true;
        mService.mTaskSupervisor.setDeferRootVisibilityUpdate(true /* deferUpdate */);
        mService.mTaskSupervisor.setDeferRootVisibilityUpdate(true /* deferUpdate */);
        mService.getTaskChangeNotificationController().setSuppressRecentsUpdates(true);
        boolean deferTransitionReady = false;
        boolean deferTransitionReady = false;
        Transition transition = chain.getTransition();
        Transition transition = chain.getTransition();
        if (transition != null && !t.isEmpty() && !chain.isFinishing()) {
        if (transition != null && !t.isEmpty() && !chain.isFinishing()) {
@@ -808,7 +807,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                mService.mTaskSupervisor.endDeferResume();
                mService.mTaskSupervisor.endDeferResume();
            }
            }
            mService.continueWindowLayout();
            mService.continueWindowLayout();
            mService.getTaskChangeNotificationController().setSuppressRecentsUpdates(false);
        }
        }
        return effects;
        return effects;
    }
    }
+0 −24
Original line number Original line Diff line number Diff line
@@ -54,7 +54,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
@@ -1385,29 +1384,6 @@ public class RecentTasksTest extends WindowTestsBase {
        verify(controller, times(4)).notifyTaskListUpdated();
        verify(controller, times(4)).notifyTaskListUpdated();
    }
    }


    @Test
    public void suppressRecentsUpdates() {
        final Task task1 = createTaskBuilder(".Task").build();
        final TaskChangeNotificationController notifier =
                mAtm.getTaskChangeNotificationController();
        clearInvocations(notifier);

        // Enable suppressing recents updates
        notifier.setSuppressRecentsUpdates(true);

        // Add and remove some tasks
        mRecentTasks.add(task1);
        mRecentTasks.removeAllVisibleTasks(TEST_USER_0_ID);

        // Verify nothing was notified
        verify(notifier, never()).queueTaskListUpdated();

        // Disable suppressing recents updates & verify that we update since there were
        // notifications while suppressed
        notifier.setSuppressRecentsUpdates(false);
        verify(notifier, times(1)).queueTaskListUpdated();
    }

    @Test
    @Test
    public void testTaskInfo_expectNoExtras() {
    public void testTaskInfo_expectNoExtras() {
        final Bundle data = new Bundle();
        final Bundle data = new Bundle();
+0 −16
Original line number Original line Diff line number Diff line
@@ -2227,22 +2227,6 @@ public class WindowOrganizerTests extends WindowTestsBase {
        assertFalse(WindowOrganizerController.configurationsAreEqualForOrganizer(config1, config3));
        assertFalse(WindowOrganizerController.configurationsAreEqualForOrganizer(config1, config3));
    }
    }


    @Test
    public void testSuppressRecentsUpdatesWhileApplyingWCT() {
        final TaskChangeNotificationController notifier =
                mWm.mAtmService.getTaskChangeNotificationController();
        clearInvocations(notifier);

        // Create & apply a WCT
        final WindowContainerTransaction t = new WindowContainerTransaction();
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(t);

        // Verify that we've set and restored suppressing the recent task updates while applying
        verify(notifier, times(1)).setSuppressRecentsUpdates(true);
        verify(notifier, times(1)).setSuppressRecentsUpdates(false);
        assertFalse(notifier.areRecentsUpdatesSuppressed());
    }

    private void testSetAlwaysOnTop(WindowContainer wc) {
    private void testSetAlwaysOnTop(WindowContainer wc) {
        final WindowContainerTransaction t = new WindowContainerTransaction();
        final WindowContainerTransaction t = new WindowContainerTransaction();
        t.setAlwaysOnTop(wc.mRemoteToken.toWindowContainerToken(), true);
        t.setAlwaysOnTop(wc.mRemoteToken.toWindowContainerToken(), true);