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:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user