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

Commit 163b4145 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Enforce mutual exclusivity in setScrollCaptureHint" into sc-dev am: 9ab42eb1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14213269

Change-Id: Ic42d0e67e67531b25fffe06720bfd8917bcbd674
parents 278530fd 9ab42eb1
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -30143,6 +30143,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    public void setScrollCaptureHint(@ScrollCaptureHint int hint) {
    public void setScrollCaptureHint(@ScrollCaptureHint int hint) {
        mPrivateFlags4 &= ~PFLAG4_SCROLL_CAPTURE_HINT_MASK;
        mPrivateFlags4 &= ~PFLAG4_SCROLL_CAPTURE_HINT_MASK;
        // Since include/exclude are mutually exclusive, exclude takes precedence.
        if ((hint & SCROLL_CAPTURE_HINT_EXCLUDE) != 0) {
            hint &= ~SCROLL_CAPTURE_HINT_INCLUDE;
        }
        mPrivateFlags4 |= ((hint << PFLAG4_SCROLL_CAPTURE_HINT_SHIFT)
        mPrivateFlags4 |= ((hint << PFLAG4_SCROLL_CAPTURE_HINT_SHIFT)
                & PFLAG4_SCROLL_CAPTURE_HINT_MASK);
                & PFLAG4_SCROLL_CAPTURE_HINT_MASK);
    }
    }
+12 −0
Original line number Original line Diff line number Diff line
@@ -92,6 +92,18 @@ public class ViewGroupScrollCaptureTest {
                viewGroup.getScrollCaptureHint());
                viewGroup.getScrollCaptureHint());
    }
    }


    /** Make sure the hint flags are saved and loaded correctly. */
    @Test
    public void testSetScrollCaptureHint_mutuallyExclusiveFlags() throws Exception {
        final Context context = getInstrumentation().getContext();
        final MockViewGroup viewGroup = new MockViewGroup(context);

        viewGroup.setScrollCaptureHint(
                View.SCROLL_CAPTURE_HINT_INCLUDE | View.SCROLL_CAPTURE_HINT_EXCLUDE);
        assertEquals("Mutually exclusive flags were not resolved correctly",
                ViewGroup.SCROLL_CAPTURE_HINT_EXCLUDE, viewGroup.getScrollCaptureHint());
    }

    /**
    /**
     * Ensure a ViewGroup with 'scrollCaptureHint=auto', but no ScrollCaptureCallback set dispatches
     * Ensure a ViewGroup with 'scrollCaptureHint=auto', but no ScrollCaptureCallback set dispatches
     * correctly. Verifies that the framework helper is called. Verifies a that non-null callback
     * correctly. Verifies that the framework helper is called. Verifies a that non-null callback