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

Commit 70cc5d66 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in DesktopModeWindowDecor#setAnimatingTaskResizeOrReposition" into main

parents fa1b7cfd d11c1826
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1877,7 +1877,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    }

    void setAnimatingTaskResizeOrReposition(boolean animatingTaskResizeOrReposition) {
        if (mRelayoutParams.mLayoutResId == R.layout.desktop_mode_app_handle) return;
        if (!isAppHeader(mWindowDecorViewHolder)) return;
        final boolean inFullImmersive =
                mDesktopUserRepositories.getProfile(mTaskInfo.userId)
                        .isTaskInFullImmersiveState(mTaskInfo.taskId);
+18 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import static com.google.common.truth.Truth.assertThat;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;

import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.argThat;
@@ -1753,6 +1754,23 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
        verifyHandleMenuCreated(TEST_URI3);
    }

    @Test
    public void setAnimatingTaskResizeOrReposition_returnsWhenViewHolderIsNull() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
        final DesktopModeWindowDecoration decor =
                spy(createWindowDecoration(taskInfo, true /* relayout */));

        // Close the decor to close the view holder and set it to null
        decor.close();

        // Verify returns when view holder is null
        try {
            decor.setAnimatingTaskResizeOrReposition(true /* animatingTaskResizeOrReposition */);
        } catch (NullPointerException e) {
            fail("Attempted to access view holder after window decor is closed");
        }
    }


    private void verifyHandleMenuCreated(@Nullable Uri uri) {
        verify(mMockHandleMenuFactory).create(any(), any(), any(), any(), any(), anyInt(),