Loading core/java/com/android/internal/statusbar/IStatusBar.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,8 @@ oneway interface IStatusBar * Displays a text toast. */ void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @nullable ITransientNotificationCallback callback); IBinder windowToken, int duration, @nullable ITransientNotificationCallback callback, int displayId); /** * Cancels toast with token {@code token} in {@code packageName}. Loading packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +7 −4 Original line number Diff line number Diff line Loading @@ -398,11 +398,11 @@ public class CommandQueue extends IStatusBar.Stub implements /** * @see IStatusBar#showToast(int, String, IBinder, CharSequence, IBinder, int, * ITransientNotificationCallback) * ITransientNotificationCallback, int) */ default void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { } @Nullable ITransientNotificationCallback callback, int displayId) { } /** * @see IStatusBar#hideToast(String, IBinder) (String, IBinder) Loading Loading @@ -944,7 +944,8 @@ public class CommandQueue extends IStatusBar.Stub implements @Override public void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId) { synchronized (mLock) { SomeArgs args = SomeArgs.obtain(); args.arg1 = packageName; Loading @@ -954,6 +955,7 @@ public class CommandQueue extends IStatusBar.Stub implements args.arg5 = callback; args.argi1 = uid; args.argi2 = duration; args.argi3 = displayId; mHandler.obtainMessage(MSG_SHOW_TOAST, args).sendToTarget(); } } Loading Loading @@ -1600,9 +1602,10 @@ public class CommandQueue extends IStatusBar.Stub implements (ITransientNotificationCallback) args.arg5; int uid = args.argi1; int duration = args.argi2; int displayId = args.argi3; for (Callbacks callbacks : mCallbacks) { callbacks.showToast(uid, packageName, token, text, windowToken, duration, callback); callback, displayId); } break; } Loading packages/SystemUI/src/com/android/systemui/toast/ToastUI.java +8 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.app.INotificationManager; import android.app.ITransientNotificationCallback; import android.content.Context; import android.content.res.Configuration; import android.hardware.display.DisplayManager; import android.os.IBinder; import android.os.ServiceManager; import android.os.UserHandle; Loading Loading @@ -106,10 +107,15 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks { @Override @MainThread public void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId) { Runnable showToastRunnable = () -> { UserHandle userHandle = UserHandle.getUserHandleForUid(uid); Context context = mContext.createContextAsUser(userHandle, 0); DisplayManager mDisplayManager = mContext.getSystemService(DisplayManager.class); Context displayContext = context.createDisplayContext( mDisplayManager.getDisplay(displayId)); mToast = mToastFactory.createToast(mContext /* sysuiContext */, text, packageName, userHandle.getIdentifier(), mOrientation); Loading @@ -118,7 +124,7 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks { } mCallback = callback; mPresenter = new ToastPresenter(context, mIAccessibilityManager, mPresenter = new ToastPresenter(displayContext, mIAccessibilityManager, mNotificationManager, packageName); // Set as trusted overlay so touches can pass through toasts mPresenter.getLayoutParams().setTrustedOverlay(); Loading packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java +20 −18 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.os.RemoteException; import android.os.UserHandle; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -122,6 +123,7 @@ public class ToastUITest extends SysuiTestCase { mContextSpy = spy(mContext); when(mContextSpy.getPackageManager()).thenReturn(mPackageManager); doReturn(mContextSpy).when(mContextSpy).createContextAsUser(any(), anyInt()); doReturn(mContextSpy).when(mContextSpy).createDisplayContext(any()); mToastUI = new ToastUI( mContextSpy, mCommandQueue, Loading @@ -144,7 +146,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_addsCorrectViewToWindowManager() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(mViewCaptor.capture(), any()); View view = mViewCaptor.getValue(); Loading @@ -154,7 +156,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_addsViewWithCorrectLayoutParamsToWindowManager() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -170,7 +172,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_forAndroidPackage_addsAllUserFlag() throws Exception { mToastUI.showToast(ANDROID_UID, "android", TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -183,7 +185,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_forSystemUiPackage_addsAllUserFlag() throws Exception { mToastUI.showToast(SYSTEMUI_UID, "com.android.systemui", TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); Toast.LENGTH_LONG, null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -196,7 +198,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_callsCallback() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verify(mCallback).onToastShown(); } Loading @@ -216,7 +218,7 @@ public class ToastUITest extends SysuiTestCase { mAccessibilityManager).sendAccessibilityEvent(any(), anyInt()); mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); eventParcel.setDataPosition(0); assertThat(eventParcel.dataSize()).isGreaterThan(0); Loading @@ -231,14 +233,14 @@ public class ToastUITest extends SysuiTestCase { public void testShowToast_accessibilityManagerClientIsRemoved() throws Exception { when(mContextSpy.getUserId()).thenReturn(USER_ID); mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mAccessibilityManager).removeClient(any(), eq(USER_ID)); } @Test public void testHideToast_removesView() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; View view = verifyWmAddViewAndAttachToParent(); Loading @@ -254,7 +256,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_finishesToken() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -270,7 +272,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_callsCallback() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -286,7 +288,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_whenNotCurrentToastToken_doesNotHideToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -302,7 +304,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_whenNotCurrentToastPackage_doesNotHideToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -318,12 +320,12 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_afterShowToast_hidesCurrentToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; View view = verifyWmAddViewAndAttachToParent(); mToastUI.showToast(UID_2, PACKAGE_NAME_2, TOKEN_2, TEXT, WINDOW_TOKEN_2, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); if (toast.getOutAnimation() != null) { assertThat(toast.getOutAnimation().isRunning()).isTrue(); Loading @@ -338,7 +340,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_logs() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verify(mToastLogger).logOnShowToast(UID_1, PACKAGE_NAME_1, TEXT, TOKEN_1.toString()); } Loading @@ -354,7 +356,7 @@ public class ToastUITest extends SysuiTestCase { // WHEN the package posts a toast mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); // THEN the view can have unlimited lines assertThat(((TextView) mToastUI.mToast.getView() Loading @@ -373,7 +375,7 @@ public class ToastUITest extends SysuiTestCase { // WHEN the package posts a toast mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); // THEN the view is limited to 2 lines assertThat(((TextView) mToastUI.mToast.getView() Loading @@ -384,7 +386,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_logs() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verifyWmAddViewAndAttachToParent(); mToastUI.hideToast(PACKAGE_NAME_1, TOKEN_1); verify(mToastLogger).logOnHideToast(PACKAGE_NAME_1, TOKEN_1.toString()); Loading services/core/java/com/android/server/notification/toast/TextToastRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ public class TextToastRecord extends ToastRecord { Slog.w(TAG, "StatusBar not available to show text toast for package " + pkg); return false; } mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback); mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback, displayId); return true; } Loading Loading
core/java/com/android/internal/statusbar/IStatusBar.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,8 @@ oneway interface IStatusBar * Displays a text toast. */ void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @nullable ITransientNotificationCallback callback); IBinder windowToken, int duration, @nullable ITransientNotificationCallback callback, int displayId); /** * Cancels toast with token {@code token} in {@code packageName}. Loading
packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +7 −4 Original line number Diff line number Diff line Loading @@ -398,11 +398,11 @@ public class CommandQueue extends IStatusBar.Stub implements /** * @see IStatusBar#showToast(int, String, IBinder, CharSequence, IBinder, int, * ITransientNotificationCallback) * ITransientNotificationCallback, int) */ default void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { } @Nullable ITransientNotificationCallback callback, int displayId) { } /** * @see IStatusBar#hideToast(String, IBinder) (String, IBinder) Loading Loading @@ -944,7 +944,8 @@ public class CommandQueue extends IStatusBar.Stub implements @Override public void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId) { synchronized (mLock) { SomeArgs args = SomeArgs.obtain(); args.arg1 = packageName; Loading @@ -954,6 +955,7 @@ public class CommandQueue extends IStatusBar.Stub implements args.arg5 = callback; args.argi1 = uid; args.argi2 = duration; args.argi3 = displayId; mHandler.obtainMessage(MSG_SHOW_TOAST, args).sendToTarget(); } } Loading Loading @@ -1600,9 +1602,10 @@ public class CommandQueue extends IStatusBar.Stub implements (ITransientNotificationCallback) args.arg5; int uid = args.argi1; int duration = args.argi2; int displayId = args.argi3; for (Callbacks callbacks : mCallbacks) { callbacks.showToast(uid, packageName, token, text, windowToken, duration, callback); callback, displayId); } break; } Loading
packages/SystemUI/src/com/android/systemui/toast/ToastUI.java +8 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.app.INotificationManager; import android.app.ITransientNotificationCallback; import android.content.Context; import android.content.res.Configuration; import android.hardware.display.DisplayManager; import android.os.IBinder; import android.os.ServiceManager; import android.os.UserHandle; Loading Loading @@ -106,10 +107,15 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks { @Override @MainThread public void showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback) { IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId) { Runnable showToastRunnable = () -> { UserHandle userHandle = UserHandle.getUserHandleForUid(uid); Context context = mContext.createContextAsUser(userHandle, 0); DisplayManager mDisplayManager = mContext.getSystemService(DisplayManager.class); Context displayContext = context.createDisplayContext( mDisplayManager.getDisplay(displayId)); mToast = mToastFactory.createToast(mContext /* sysuiContext */, text, packageName, userHandle.getIdentifier(), mOrientation); Loading @@ -118,7 +124,7 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks { } mCallback = callback; mPresenter = new ToastPresenter(context, mIAccessibilityManager, mPresenter = new ToastPresenter(displayContext, mIAccessibilityManager, mNotificationManager, packageName); // Set as trusted overlay so touches can pass through toasts mPresenter.getLayoutParams().setTrustedOverlay(); Loading
packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java +20 −18 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.os.RemoteException; import android.os.UserHandle; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; Loading Loading @@ -122,6 +123,7 @@ public class ToastUITest extends SysuiTestCase { mContextSpy = spy(mContext); when(mContextSpy.getPackageManager()).thenReturn(mPackageManager); doReturn(mContextSpy).when(mContextSpy).createContextAsUser(any(), anyInt()); doReturn(mContextSpy).when(mContextSpy).createDisplayContext(any()); mToastUI = new ToastUI( mContextSpy, mCommandQueue, Loading @@ -144,7 +146,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_addsCorrectViewToWindowManager() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(mViewCaptor.capture(), any()); View view = mViewCaptor.getValue(); Loading @@ -154,7 +156,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_addsViewWithCorrectLayoutParamsToWindowManager() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -170,7 +172,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_forAndroidPackage_addsAllUserFlag() throws Exception { mToastUI.showToast(ANDROID_UID, "android", TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -183,7 +185,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_forSystemUiPackage_addsAllUserFlag() throws Exception { mToastUI.showToast(SYSTEMUI_UID, "com.android.systemui", TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); Toast.LENGTH_LONG, null, Display.DEFAULT_DISPLAY); verify(mWindowManager).addView(any(), mParamsCaptor.capture()); ViewGroup.LayoutParams params = mParamsCaptor.getValue(); Loading @@ -196,7 +198,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_callsCallback() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verify(mCallback).onToastShown(); } Loading @@ -216,7 +218,7 @@ public class ToastUITest extends SysuiTestCase { mAccessibilityManager).sendAccessibilityEvent(any(), anyInt()); mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); eventParcel.setDataPosition(0); assertThat(eventParcel.dataSize()).isGreaterThan(0); Loading @@ -231,14 +233,14 @@ public class ToastUITest extends SysuiTestCase { public void testShowToast_accessibilityManagerClientIsRemoved() throws Exception { when(mContextSpy.getUserId()).thenReturn(USER_ID); mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); verify(mAccessibilityManager).removeClient(any(), eq(USER_ID)); } @Test public void testHideToast_removesView() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; View view = verifyWmAddViewAndAttachToParent(); Loading @@ -254,7 +256,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_finishesToken() throws Exception { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -270,7 +272,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_callsCallback() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -286,7 +288,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_whenNotCurrentToastToken_doesNotHideToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -302,7 +304,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_whenNotCurrentToastPackage_doesNotHideToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; verifyWmAddViewAndAttachToParent(); Loading @@ -318,12 +320,12 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_afterShowToast_hidesCurrentToast() throws RemoteException { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); final SystemUIToast toast = mToastUI.mToast; View view = verifyWmAddViewAndAttachToParent(); mToastUI.showToast(UID_2, PACKAGE_NAME_2, TOKEN_2, TEXT, WINDOW_TOKEN_2, Toast.LENGTH_LONG, null); null, Display.DEFAULT_DISPLAY); if (toast.getOutAnimation() != null) { assertThat(toast.getOutAnimation().isRunning()).isTrue(); Loading @@ -338,7 +340,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testShowToast_logs() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verify(mToastLogger).logOnShowToast(UID_1, PACKAGE_NAME_1, TEXT, TOKEN_1.toString()); } Loading @@ -354,7 +356,7 @@ public class ToastUITest extends SysuiTestCase { // WHEN the package posts a toast mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); // THEN the view can have unlimited lines assertThat(((TextView) mToastUI.mToast.getView() Loading @@ -373,7 +375,7 @@ public class ToastUITest extends SysuiTestCase { // WHEN the package posts a toast mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); // THEN the view is limited to 2 lines assertThat(((TextView) mToastUI.mToast.getView() Loading @@ -384,7 +386,7 @@ public class ToastUITest extends SysuiTestCase { @Test public void testHideToast_logs() { mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG, mCallback); mCallback, Display.DEFAULT_DISPLAY); verifyWmAddViewAndAttachToParent(); mToastUI.hideToast(PACKAGE_NAME_1, TOKEN_1); verify(mToastLogger).logOnHideToast(PACKAGE_NAME_1, TOKEN_1.toString()); Loading
services/core/java/com/android/server/notification/toast/TextToastRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ public class TextToastRecord extends ToastRecord { Slog.w(TAG, "StatusBar not available to show text toast for package " + pkg); return false; } mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback); mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback, displayId); return true; } Loading