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

Commit 7f9f37d1 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Protect spy by holding lock

Another thread could access mDisplayContent during setup spy.
That might cause some unexpected error such as:
CannotStubVoidMethodWithReturnValue, WrongTypeOfReturnValue.

Bug: 129331490
Test: atest TaskPositioningControllerTests

Change-Id: I60c7fac1139362957f43254dd0d1740ace28445d
parent aecff3d7
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
import android.platform.test.annotations.Presubmit;
import android.view.InputChannel;

import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;

import org.junit.Before;
@@ -60,11 +61,10 @@ public class TaskPositioningControllerTests extends WindowTestsBase {
        mWindow.mInputChannel = new InputChannel();
        synchronized (mWm.mGlobalLock) {
            mWm.mWindowMap.put(mWindow.mClient.asBinder(), mWindow);
        }

            spyOn(mDisplayContent);
            doReturn(mock(InputMonitor.class)).when(mDisplayContent).getInputMonitor();
        }
    }

    @Test
    public void testStartAndFinishPositioning() {
@@ -88,6 +88,7 @@ public class TaskPositioningControllerTests extends WindowTestsBase {
        assertNull(mTarget.getDragWindowHandleLocked());
    }

    @FlakyTest(bugId = 129331490)
    @Test
    public void testHandleTapOutsideTask() {
        synchronized (mWm.mGlobalLock) {