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

Commit 88336c62 authored by Steve McKay's avatar Steve McKay
Browse files

Silently ignore illegal call to start.

BUG: 70518185
Test: Passing
Change-Id: I079a482bb808a42e433bc4b7ddb3947334a543bd
parent b4ef260f
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -73,17 +73,24 @@ public final class ContentLock {
        }
    }

    /**
     * Returns true if locked.
     */
    synchronized boolean isLocked() {
        return mLocks > 0;
    }

    /**
     * Allows other selection code to perform a precondition check asserting the state is locked.
     */
    final void checkLocked() {
        checkState(mLocks > 0);
        checkState(isLocked());
    }

    /**
     * Allows other selection code to perform a precondition check asserting the state is unlocked.
     */
    final void checkUnlocked() {
        checkState(mLocks == 0);
        checkState(!isLocked());
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -78,7 +78,13 @@ public final class GestureSelectionHelper extends ScrollHost implements OnItemTo
     */
    public void start() {
        checkState(!mStarted);
        checkState(mLastStartedItemPos > -1);
        // See: b/70518185. It appears start() is being called via onLongPress
        // even though we never received an intial handleInterceptedDownEvent
        // where we would usually initialize mLastStartedItemPos.
        if (mLastStartedItemPos < 0){
          Log.w(TAG, "Illegal state. Can't start without valid mLastStartedItemPos.");
          return;
        }

        // Partner code in MotionInputHandler ensures items
        // are selected and range established prior to
+3 −4
Original line number Diff line number Diff line
@@ -80,11 +80,10 @@ public class GestureSelectionHelperTest {

    @Test
    public void testNoStartOnIllegalPosition() {
        mView.mNextPosition = -1;
        mHelper.onInterceptTouchEvent(null, DOWN);
        try {
        mHelper.start();
            fail("Should have thrown.");
        } catch (Exception expected) {}
        assertFalse(mLock.isLocked());
    }

    @Test