Merge "Wire display context for text toasts" into tm-dev am: ca6ef9125d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18660549 Change-Id: I8a1ebd412bf0207e32b8697ef284f22b55d4a161 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -242,7 +242,8 @@ oneway interface IStatusBar
|
|||||||
* Displays a text toast.
|
* Displays a text toast.
|
||||||
*/
|
*/
|
||||||
void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
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}.
|
* Cancels toast with token {@code token} in {@code packageName}.
|
||||||
|
|||||||
@@ -398,11 +398,11 @@ public class CommandQueue extends IStatusBar.Stub implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IStatusBar#showToast(int, String, IBinder, CharSequence, IBinder, int,
|
* @see IStatusBar#showToast(int, String, IBinder, CharSequence, IBinder, int,
|
||||||
* ITransientNotificationCallback)
|
* ITransientNotificationCallback, int)
|
||||||
*/
|
*/
|
||||||
default void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
default void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
||||||
IBinder windowToken, int duration,
|
IBinder windowToken, int duration,
|
||||||
@Nullable ITransientNotificationCallback callback) { }
|
@Nullable ITransientNotificationCallback callback, int displayId) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IStatusBar#hideToast(String, IBinder) (String, IBinder)
|
* @see IStatusBar#hideToast(String, IBinder) (String, IBinder)
|
||||||
@@ -944,7 +944,8 @@ public class CommandQueue extends IStatusBar.Stub implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
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) {
|
synchronized (mLock) {
|
||||||
SomeArgs args = SomeArgs.obtain();
|
SomeArgs args = SomeArgs.obtain();
|
||||||
args.arg1 = packageName;
|
args.arg1 = packageName;
|
||||||
@@ -954,6 +955,7 @@ public class CommandQueue extends IStatusBar.Stub implements
|
|||||||
args.arg5 = callback;
|
args.arg5 = callback;
|
||||||
args.argi1 = uid;
|
args.argi1 = uid;
|
||||||
args.argi2 = duration;
|
args.argi2 = duration;
|
||||||
|
args.argi3 = displayId;
|
||||||
mHandler.obtainMessage(MSG_SHOW_TOAST, args).sendToTarget();
|
mHandler.obtainMessage(MSG_SHOW_TOAST, args).sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1600,9 +1602,10 @@ public class CommandQueue extends IStatusBar.Stub implements
|
|||||||
(ITransientNotificationCallback) args.arg5;
|
(ITransientNotificationCallback) args.arg5;
|
||||||
int uid = args.argi1;
|
int uid = args.argi1;
|
||||||
int duration = args.argi2;
|
int duration = args.argi2;
|
||||||
|
int displayId = args.argi3;
|
||||||
for (Callbacks callbacks : mCallbacks) {
|
for (Callbacks callbacks : mCallbacks) {
|
||||||
callbacks.showToast(uid, packageName, token, text, windowToken, duration,
|
callbacks.showToast(uid, packageName, token, text, windowToken, duration,
|
||||||
callback);
|
callback, displayId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.app.INotificationManager;
|
|||||||
import android.app.ITransientNotificationCallback;
|
import android.app.ITransientNotificationCallback;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -106,10 +107,15 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks {
|
|||||||
@Override
|
@Override
|
||||||
@MainThread
|
@MainThread
|
||||||
public void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
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 = () -> {
|
Runnable showToastRunnable = () -> {
|
||||||
UserHandle userHandle = UserHandle.getUserHandleForUid(uid);
|
UserHandle userHandle = UserHandle.getUserHandleForUid(uid);
|
||||||
Context context = mContext.createContextAsUser(userHandle, 0);
|
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,
|
mToast = mToastFactory.createToast(mContext /* sysuiContext */, text, packageName,
|
||||||
userHandle.getIdentifier(), mOrientation);
|
userHandle.getIdentifier(), mOrientation);
|
||||||
|
|
||||||
@@ -118,7 +124,7 @@ public class ToastUI extends CoreStartable implements CommandQueue.Callbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
mPresenter = new ToastPresenter(context, mIAccessibilityManager,
|
mPresenter = new ToastPresenter(displayContext, mIAccessibilityManager,
|
||||||
mNotificationManager, packageName);
|
mNotificationManager, packageName);
|
||||||
// Set as trusted overlay so touches can pass through toasts
|
// Set as trusted overlay so touches can pass through toasts
|
||||||
mPresenter.getLayoutParams().setTrustedOverlay();
|
mPresenter.getLayoutParams().setTrustedOverlay();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -122,6 +123,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
mContextSpy = spy(mContext);
|
mContextSpy = spy(mContext);
|
||||||
when(mContextSpy.getPackageManager()).thenReturn(mPackageManager);
|
when(mContextSpy.getPackageManager()).thenReturn(mPackageManager);
|
||||||
doReturn(mContextSpy).when(mContextSpy).createContextAsUser(any(), anyInt());
|
doReturn(mContextSpy).when(mContextSpy).createContextAsUser(any(), anyInt());
|
||||||
|
doReturn(mContextSpy).when(mContextSpy).createDisplayContext(any());
|
||||||
mToastUI = new ToastUI(
|
mToastUI = new ToastUI(
|
||||||
mContextSpy,
|
mContextSpy,
|
||||||
mCommandQueue,
|
mCommandQueue,
|
||||||
@@ -144,7 +146,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_addsCorrectViewToWindowManager() {
|
public void testShowToast_addsCorrectViewToWindowManager() {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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());
|
verify(mWindowManager).addView(mViewCaptor.capture(), any());
|
||||||
View view = mViewCaptor.getValue();
|
View view = mViewCaptor.getValue();
|
||||||
@@ -154,7 +156,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_addsViewWithCorrectLayoutParamsToWindowManager() {
|
public void testShowToast_addsViewWithCorrectLayoutParamsToWindowManager() {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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());
|
verify(mWindowManager).addView(any(), mParamsCaptor.capture());
|
||||||
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
||||||
@@ -170,7 +172,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_forAndroidPackage_addsAllUserFlag() throws Exception {
|
public void testShowToast_forAndroidPackage_addsAllUserFlag() throws Exception {
|
||||||
mToastUI.showToast(ANDROID_UID, "android", TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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());
|
verify(mWindowManager).addView(any(), mParamsCaptor.capture());
|
||||||
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
||||||
@@ -183,7 +185,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_forSystemUiPackage_addsAllUserFlag() throws Exception {
|
public void testShowToast_forSystemUiPackage_addsAllUserFlag() throws Exception {
|
||||||
mToastUI.showToast(SYSTEMUI_UID, "com.android.systemui", TOKEN_1, TEXT, WINDOW_TOKEN_1,
|
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());
|
verify(mWindowManager).addView(any(), mParamsCaptor.capture());
|
||||||
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
ViewGroup.LayoutParams params = mParamsCaptor.getValue();
|
||||||
@@ -196,7 +198,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_callsCallback() throws Exception {
|
public void testShowToast_callsCallback() throws Exception {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
||||||
mCallback);
|
mCallback, Display.DEFAULT_DISPLAY);
|
||||||
|
|
||||||
verify(mCallback).onToastShown();
|
verify(mCallback).onToastShown();
|
||||||
}
|
}
|
||||||
@@ -216,7 +218,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
mAccessibilityManager).sendAccessibilityEvent(any(), anyInt());
|
mAccessibilityManager).sendAccessibilityEvent(any(), anyInt());
|
||||||
|
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
||||||
null);
|
null, Display.DEFAULT_DISPLAY);
|
||||||
|
|
||||||
eventParcel.setDataPosition(0);
|
eventParcel.setDataPosition(0);
|
||||||
assertThat(eventParcel.dataSize()).isGreaterThan(0);
|
assertThat(eventParcel.dataSize()).isGreaterThan(0);
|
||||||
@@ -231,14 +233,14 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
public void testShowToast_accessibilityManagerClientIsRemoved() throws Exception {
|
public void testShowToast_accessibilityManagerClientIsRemoved() throws Exception {
|
||||||
when(mContextSpy.getUserId()).thenReturn(USER_ID);
|
when(mContextSpy.getUserId()).thenReturn(USER_ID);
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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));
|
verify(mAccessibilityManager).removeClient(any(), eq(USER_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHideToast_removesView() throws Exception {
|
public void testHideToast_removesView() throws Exception {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
View view = verifyWmAddViewAndAttachToParent();
|
View view = verifyWmAddViewAndAttachToParent();
|
||||||
@@ -254,7 +256,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testHideToast_finishesToken() throws Exception {
|
public void testHideToast_finishesToken() throws Exception {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
verifyWmAddViewAndAttachToParent();
|
verifyWmAddViewAndAttachToParent();
|
||||||
@@ -270,7 +272,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testHideToast_callsCallback() throws RemoteException {
|
public void testHideToast_callsCallback() throws RemoteException {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
verifyWmAddViewAndAttachToParent();
|
verifyWmAddViewAndAttachToParent();
|
||||||
@@ -286,7 +288,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testHideToast_whenNotCurrentToastToken_doesNotHideToast() throws RemoteException {
|
public void testHideToast_whenNotCurrentToastToken_doesNotHideToast() throws RemoteException {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
verifyWmAddViewAndAttachToParent();
|
verifyWmAddViewAndAttachToParent();
|
||||||
@@ -302,7 +304,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testHideToast_whenNotCurrentToastPackage_doesNotHideToast() throws RemoteException {
|
public void testHideToast_whenNotCurrentToastPackage_doesNotHideToast() throws RemoteException {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
verifyWmAddViewAndAttachToParent();
|
verifyWmAddViewAndAttachToParent();
|
||||||
@@ -318,12 +320,12 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_afterShowToast_hidesCurrentToast() throws RemoteException {
|
public void testShowToast_afterShowToast_hidesCurrentToast() throws RemoteException {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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;
|
final SystemUIToast toast = mToastUI.mToast;
|
||||||
|
|
||||||
View view = verifyWmAddViewAndAttachToParent();
|
View view = verifyWmAddViewAndAttachToParent();
|
||||||
mToastUI.showToast(UID_2, PACKAGE_NAME_2, TOKEN_2, TEXT, WINDOW_TOKEN_2, Toast.LENGTH_LONG,
|
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) {
|
if (toast.getOutAnimation() != null) {
|
||||||
assertThat(toast.getOutAnimation().isRunning()).isTrue();
|
assertThat(toast.getOutAnimation().isRunning()).isTrue();
|
||||||
@@ -338,7 +340,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShowToast_logs() {
|
public void testShowToast_logs() {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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());
|
verify(mToastLogger).logOnShowToast(UID_1, PACKAGE_NAME_1, TEXT, TOKEN_1.toString());
|
||||||
}
|
}
|
||||||
@@ -354,7 +356,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
|
|
||||||
// WHEN the package posts a toast
|
// WHEN the package posts a toast
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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
|
// THEN the view can have unlimited lines
|
||||||
assertThat(((TextView) mToastUI.mToast.getView()
|
assertThat(((TextView) mToastUI.mToast.getView()
|
||||||
@@ -373,7 +375,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
|
|
||||||
// WHEN the package posts a toast
|
// WHEN the package posts a toast
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
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
|
// THEN the view is limited to 2 lines
|
||||||
assertThat(((TextView) mToastUI.mToast.getView()
|
assertThat(((TextView) mToastUI.mToast.getView()
|
||||||
@@ -384,7 +386,7 @@ public class ToastUITest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testHideToast_logs() {
|
public void testHideToast_logs() {
|
||||||
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
mToastUI.showToast(UID_1, PACKAGE_NAME_1, TOKEN_1, TEXT, WINDOW_TOKEN_1, Toast.LENGTH_LONG,
|
||||||
mCallback);
|
mCallback, Display.DEFAULT_DISPLAY);
|
||||||
verifyWmAddViewAndAttachToParent();
|
verifyWmAddViewAndAttachToParent();
|
||||||
mToastUI.hideToast(PACKAGE_NAME_1, TOKEN_1);
|
mToastUI.hideToast(PACKAGE_NAME_1, TOKEN_1);
|
||||||
verify(mToastLogger).logOnHideToast(PACKAGE_NAME_1, TOKEN_1.toString());
|
verify(mToastLogger).logOnHideToast(PACKAGE_NAME_1, TOKEN_1.toString());
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ public class TextToastRecord extends ToastRecord {
|
|||||||
Slog.w(TAG, "StatusBar not available to show text toast for package " + pkg);
|
Slog.w(TAG, "StatusBar not available to show text toast for package " + pkg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback);
|
mStatusBar.showToast(uid, pkg, token, text, windowToken, getDuration(), mCallback,
|
||||||
|
displayId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,11 +144,11 @@ public interface StatusBarManagerInternal {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.android.internal.statusbar.IStatusBar#showToast(String, IBinder, CharSequence,
|
* @see com.android.internal.statusbar.IStatusBar#showToast(String, IBinder, CharSequence,
|
||||||
* IBinder, int, ITransientNotificationCallback)
|
* IBinder, int, ITransientNotificationCallback, int)
|
||||||
*/
|
*/
|
||||||
void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
||||||
IBinder windowToken, int duration,
|
IBinder windowToken, int duration,
|
||||||
@Nullable ITransientNotificationCallback textCallback);
|
@Nullable ITransientNotificationCallback textCallback, int displayId);
|
||||||
|
|
||||||
/** @see com.android.internal.statusbar.IStatusBar#hideToast(String, IBinder) */
|
/** @see com.android.internal.statusbar.IStatusBar#hideToast(String, IBinder) */
|
||||||
void hideToast(String packageName, IBinder token);
|
void hideToast(String packageName, IBinder token);
|
||||||
|
|||||||
@@ -631,10 +631,11 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
|||||||
@Override
|
@Override
|
||||||
public void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
public void showToast(int uid, String packageName, IBinder token, CharSequence text,
|
||||||
IBinder windowToken, int duration,
|
IBinder windowToken, int duration,
|
||||||
@Nullable ITransientNotificationCallback callback) {
|
@Nullable ITransientNotificationCallback callback, int displayId) {
|
||||||
if (mBar != null) {
|
if (mBar != null) {
|
||||||
try {
|
try {
|
||||||
mBar.showToast(uid, packageName, token, text, windowToken, duration, callback);
|
mBar.showToast(uid, packageName, token, text, windowToken, duration, callback,
|
||||||
|
displayId);
|
||||||
} catch (RemoteException ex) { }
|
} catch (RemoteException ex) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6227,13 +6227,13 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
// first time trying to show the toast, showToast gets called
|
// first time trying to show the toast, showToast gets called
|
||||||
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
||||||
verify(mStatusBar, times(1))
|
verify(mStatusBar, times(1))
|
||||||
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(), anyInt());
|
||||||
|
|
||||||
// second time trying to show the same toast, showToast isn't called again (total number of
|
// second time trying to show the same toast, showToast isn't called again (total number of
|
||||||
// invocations stays at one)
|
// invocations stays at one)
|
||||||
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
||||||
verify(mStatusBar, times(1))
|
verify(mStatusBar, times(1))
|
||||||
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -6255,7 +6255,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
|
|
||||||
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
||||||
verify(mStatusBar, times(0))
|
verify(mStatusBar, times(0))
|
||||||
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -6277,7 +6277,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
|
|
||||||
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
||||||
verify(mStatusBar, times(1))
|
verify(mStatusBar, times(1))
|
||||||
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -6297,7 +6297,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
INotificationManager nmService = (INotificationManager) mService.mService;
|
INotificationManager nmService = (INotificationManager) mService.mService;
|
||||||
|
|
||||||
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
nmService.enqueueTextToast(testPackage, token, "Text", 2000, 0, null);
|
||||||
verify(mStatusBar).showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
verify(mStatusBar).showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(),
|
||||||
|
anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -6326,7 +6327,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
|
|
||||||
// but never shown
|
// but never shown
|
||||||
verify(mStatusBar, times(0))
|
verify(mStatusBar, times(0))
|
||||||
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
.showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(), anyInt());
|
||||||
|
|
||||||
// and removed when rate limited
|
// and removed when rate limited
|
||||||
verify(mWindowManagerInternal)
|
verify(mWindowManagerInternal)
|
||||||
@@ -6417,7 +6418,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
// enqueue toast -> no toasts enqueued
|
// enqueue toast -> no toasts enqueued
|
||||||
((INotificationManager) mService.mService).enqueueTextToast(testPackage, new Binder(),
|
((INotificationManager) mService.mService).enqueueTextToast(testPackage, new Binder(),
|
||||||
"Text", 2000, 0, null);
|
"Text", 2000, 0, null);
|
||||||
verify(mStatusBar).showToast(anyInt(), any(), any(), any(), any(), anyInt(), any());
|
verify(mStatusBar).showToast(anyInt(), any(), any(), any(), any(), anyInt(), any(),
|
||||||
|
anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user