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
This commit is contained in:
Phil Weaver
2017-02-14 12:36:47 -08:00
parent 806456f097
commit 7192297bc9
2 changed files with 12 additions and 2 deletions

View File

@@ -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();

View File

@@ -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();
}