summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java22
-rwxr-xr-xservices/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java3
2 files changed, 12 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 2d806d374b70..81cca50a4d29 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -3296,8 +3296,8 @@ public class NotificationManagerService extends SystemService {
@Nullable ITransientNotification callback, int duration, boolean isUiContext,
int displayId, @Nullable ITransientNotificationCallback textCallback) {
if (DBG) {
- Slog.i(TAG, "enqueueToast pkg=" + pkg + " token=" + token
- + " duration=" + duration + " displayId=" + displayId);
+ Slog.i(TAG, "enqueueToast pkg=" + pkg + " token=" + token + " duration=" + duration
+ + " isUiContext=" + isUiContext + " displayId=" + displayId);
}
if (pkg == null || (text == null && callback == null)
@@ -3308,15 +3308,6 @@ public class NotificationManagerService extends SystemService {
}
final int callingUid = Binder.getCallingUid();
- checkCallerIsSameApp(pkg);
- final boolean isSystemToast = isCallerSystemOrPhone()
- || PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
- boolean isAppRenderedToast = (callback != null);
- if (!checkCanEnqueueToast(pkg, callingUid, displayId, isAppRenderedToast,
- isSystemToast)) {
- return;
- }
-
if (!isUiContext && displayId == Display.DEFAULT_DISPLAY
&& mUm.isVisibleBackgroundUsersSupported()) {
// When the caller is a visible background user using a non-UI context (like the
@@ -3333,6 +3324,15 @@ public class NotificationManagerService extends SystemService {
}
}
+ checkCallerIsSameApp(pkg);
+ final boolean isSystemToast = isCallerSystemOrPhone()
+ || PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
+ boolean isAppRenderedToast = (callback != null);
+ if (!checkCanEnqueueToast(pkg, callingUid, displayId, isAppRenderedToast,
+ isSystemToast)) {
+ return;
+ }
+
synchronized (mToastQueue) {
int callingPid = Binder.getCallingPid();
final long callingId = Binder.clearCallingIdentity();
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 3888b9b14c15..dc954a2433c5 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -197,7 +197,6 @@ import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
-import android.testing.TestableContext;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestablePermissions;
@@ -254,7 +253,6 @@ import org.mockito.ArgumentMatcher;
import org.mockito.ArgumentMatchers;
import org.mockito.InOrder;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -6909,6 +6907,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
public void testTextToastsCallStatusBar_visibleBgUsers_nonUiContext_defaultDisplay()
throws Exception {
mockIsVisibleBackgroundUsersSupported(true);
+ mockIsUserVisible(SECONDARY_DISPLAY_ID, true);
mockDisplayAssignedToUser(SECONDARY_DISPLAY_ID);
allowTestPackageToToast();