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

Commit c0c09850 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Do not allow custom animation of untrusted Toast" into main

parents 750ed031 87fc3909
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1006,6 +1006,10 @@ public class DisplayPolicy {
                        AccessibilityManager.FLAG_CONTENT_TEXT);
                // Toasts can't be clickable
                attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
                // Do not allow untrusted toast to customize animation.
                if (!win.mSession.mCanAddInternalSystemWindow) {
                    attrs.windowAnimations = R.style.Animation_Toast;
                }
                break;

            case TYPE_BASE_APPLICATION:
+11 −0
Original line number Diff line number Diff line
@@ -293,6 +293,17 @@ public class DisplayPolicyTests extends WindowTestsBase {
        assertFalse(wpc.isShowingUiWhileDozing());
    }

    @Test
    public void testNonSystemToastAnimation() {
        final WindowState win = newWindowBuilder("Toast",
                WindowManager.LayoutParams.TYPE_TOAST).build();
        win.mAttrs.windowAnimations = android.R.style.Animation_InputMethod;
        setFieldValue(win.mSession, "mCanAddInternalSystemWindow", false);
        mDisplayContent.getDisplayPolicy().adjustWindowParamsLw(win, win.mAttrs);

        assertEquals(android.R.style.Animation_Toast, win.mAttrs.windowAnimations);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testMainAppWindowDisallowFitSystemWindowTypes() {
        final DisplayPolicy policy = mDisplayContent.getDisplayPolicy();