Loading services/core/java/com/android/server/policy/AccessibilityShortcutController.java +5 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading services/tests/servicestests/src/com/android/server/policy/AccessibilityShortcutControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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(); } Loading Loading
services/core/java/com/android/server/policy/AccessibilityShortcutController.java +5 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading
services/tests/servicestests/src/com/android/server/policy/AccessibilityShortcutControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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(); } Loading