Remove FLAG_SHOW_FOR_ALL_USERS to avoid crash in a11y

Text toasts now return null for getWindowParams() because they are
rendered by sys UI. Removing the flag for now to avoid crash. Working on
a long-term solution for this in the first bug linked.

Bug: 149408635
Bug: 149401510
Test: 1. Settings > Accessibility > Volume key shortcut > Use Volume key
         shortcut
      2. Press vol up and down together and observe no crash

Change-Id: Ie924666e457982986eb282d4cba7ba0beda6faca
This commit is contained in:
Bernardo Rufino
2020-02-14 13:45:20 +00:00
parent 628045a49d
commit 0f64b3cf0a
2 changed files with 4 additions and 5 deletions

View File

@@ -245,8 +245,6 @@ public class AccessibilityShortcutController {
String toastMessage = String.format(toastMessageFormatString, serviceName);
Toast warningToast = mFrameworkObjectProvider.makeToastFromText(
mContext, toastMessage, Toast.LENGTH_LONG);
warningToast.getWindowParams().privateFlags |=
WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
warningToast.show();
}

View File

@@ -362,9 +362,10 @@ public class AccessibilityShortcutControllerTest {
accessibilityShortcutController.performAccessibilityShortcut();
accessibilityShortcutController.performAccessibilityShortcut();
verify(mToast).show();
assertEquals(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
mLayoutParams.privateFlags
& WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
// TODO(b/149408635): Reintroduce assertion
// assertEquals(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
// mLayoutParams.privateFlags
// & WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
verify(mAccessibilityManagerService, times(1)).performAccessibilityShortcut(null);
}