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

Commit 7192297b authored by Phil Weaver's avatar Phil Weaver
Browse files

Make a11y shortcut toast appear for all users.

Setting flag to make the toast appear for all users.

Bug: 35209951
Test: Verified manually on guest users, added automated check
that the flag is set.

Change-Id: I91d1f32acebe1197356289b23142d33c5a8bbd23
parent 806456f0
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -140,8 +140,11 @@ public class AccessibilityShortcutController {
            String toastMessage = String.format(toastMessageFormatString,
                    serviceInfo.getResolveInfo()
                            .loadLabel(mContext.getPackageManager()).toString());
            mFrameworkObjectProvider.makeToastFromText(mContext, toastMessage, Toast.LENGTH_LONG)
                    .show();
            Toast warningToast = mFrameworkObjectProvider.makeToastFromText(
                    mContext, toastMessage, Toast.LENGTH_LONG);
            warningToast.getWindowParams().privateFlags |=
                    WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
            warningToast.show();

            mFrameworkObjectProvider.getAccessibilityManagerInstance(mContext)
                    .performAccessibilityShortcut();
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class AccessibilityShortcutControllerTest {
    private @Mock Toast mToast;

    private MockContentResolver mContentResolver;
    private WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();

    @Before
    public void setUp() throws Exception {
@@ -119,6 +120,9 @@ public class AccessibilityShortcutControllerTest {
        when(mAlertDialogBuilder.setOnCancelListener(anyObject())).thenReturn(mAlertDialogBuilder);
        when(mAlertDialogBuilder.create()).thenReturn(mAlertDialog);

        mLayoutParams.privateFlags = 0;
        when(mToast.getWindowParams()).thenReturn(mLayoutParams);

        Window window = mock(Window.class);
        Whitebox.setInternalState(window, "mWindowAttributes", new WindowManager.LayoutParams());
        when(mAlertDialog.getWindow()).thenReturn(window);
@@ -183,6 +187,9 @@ public class AccessibilityShortcutControllerTest {
        accessibilityShortcutController.performAccessibilityShortcut();
        accessibilityShortcutController.performAccessibilityShortcut();
        verify(mToast).show();
        assertEquals(WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
                mLayoutParams.privateFlags
                        & WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS);
        verify(mAccessibilityManagerService, times(1)).performAccessibilityShortcut();
    }