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

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

Merge "Silently ignore illegal call to start." into pi-dev

parents f2788e31 88336c62
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