Loading core/java/android/app/Notification.java +5 −5 Original line number Diff line number Diff line Loading @@ -1219,11 +1219,11 @@ public class Notification implements Parcelable public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName"; /** * This is set on the notification shown by the activity manager about all apps * running in the background. It indicates that the notification should be shown * only if any of the given apps do not already have a {@link #FLAG_FOREGROUND_SERVICE} * notification currently visible to the user. This is a string array of all * package names of the apps. * This is set on the notifications shown by system_server about apps running foreground * services. It indicates that the notification should be shown * only if any of the given apps do not already have a properly tagged * {@link #FLAG_FOREGROUND_SERVICE} notification currently visible to the user. * This is a string array of all package names of the apps. * @hide */ public static final String EXTRA_FOREGROUND_APPS = "android.foregroundApps"; Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +8 −3 Original line number Diff line number Diff line Loading @@ -641,10 +641,15 @@ public class NotificationData { // this is a foreground-service disclosure for a user that does not need to show one return true; } if (mFsc.isSystemAlertNotification(sbn) && !mFsc.isSystemAlertWarningNeeded( sbn.getUserId(), sbn.getPackageName())) { if (mFsc.isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!mFsc.isSystemAlertWarningNeeded(sbn.getUserId(), apps[0])) { return true; } } } return false; } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +6 −6 Original line number Diff line number Diff line Loading @@ -363,16 +363,16 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, zenDescription = mContext.getString(R.string.interruption_level_priority); } if (DndTile.isVisible(mContext) && !DndTile.isCombinedIcon(mContext) && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_silent; volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); } else if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_vibrate; volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate); } else if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_silent; volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); } if (zenVisible) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -226,12 +226,21 @@ public class NotificationDataTest extends SysuiTestCase { public void testSuppressSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"}); sbn.getNotification().extras = bundle; assertTrue(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testDoNotSuppressSystemAlertNotification() { StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"}); sbn.getNotification().extras = bundle; when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); Loading @@ -248,6 +257,22 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testDoNotSuppressMalformedSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); // missing extra assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {}); sbn.getNotification().extras = bundle; // extra missing values assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testShouldFilterHiddenNotifications() { // setup Loading services/core/java/com/android/server/wm/AlertWindowNotification.java +5 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import com.android.internal.R; import com.android.server.policy.IconUtilities; Loading Loading @@ -109,6 +111,8 @@ class AlertWindowNotification { final String message = context.getString(R.string.alert_windows_notification_message, appName); Bundle extras = new Bundle(); extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {mPackageName}); final Notification.Builder builder = new Notification.Builder(context, mNotificationTag) .setOngoing(true) .setContentTitle( Loading @@ -118,6 +122,7 @@ class AlertWindowNotification { .setColor(context.getColor(R.color.system_notification_accent_color)) .setStyle(new Notification.BigTextStyle().bigText(message)) .setLocalOnly(true) .addExtras(extras) .setContentIntent(getContentIntent(context, mPackageName)); if (aInfo != null) { Loading Loading
core/java/android/app/Notification.java +5 −5 Original line number Diff line number Diff line Loading @@ -1219,11 +1219,11 @@ public class Notification implements Parcelable public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName"; /** * This is set on the notification shown by the activity manager about all apps * running in the background. It indicates that the notification should be shown * only if any of the given apps do not already have a {@link #FLAG_FOREGROUND_SERVICE} * notification currently visible to the user. This is a string array of all * package names of the apps. * This is set on the notifications shown by system_server about apps running foreground * services. It indicates that the notification should be shown * only if any of the given apps do not already have a properly tagged * {@link #FLAG_FOREGROUND_SERVICE} notification currently visible to the user. * This is a string array of all package names of the apps. * @hide */ public static final String EXTRA_FOREGROUND_APPS = "android.foregroundApps"; Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +8 −3 Original line number Diff line number Diff line Loading @@ -641,10 +641,15 @@ public class NotificationData { // this is a foreground-service disclosure for a user that does not need to show one return true; } if (mFsc.isSystemAlertNotification(sbn) && !mFsc.isSystemAlertWarningNeeded( sbn.getUserId(), sbn.getPackageName())) { if (mFsc.isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!mFsc.isSystemAlertWarningNeeded(sbn.getUserId(), apps[0])) { return true; } } } return false; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +6 −6 Original line number Diff line number Diff line Loading @@ -363,16 +363,16 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, zenDescription = mContext.getString(R.string.interruption_level_priority); } if (DndTile.isVisible(mContext) && !DndTile.isCombinedIcon(mContext) && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_silent; volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); } else if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_vibrate; volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate); } else if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { volumeVisible = true; volumeIconId = R.drawable.stat_sys_ringer_silent; volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); } if (zenVisible) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -226,12 +226,21 @@ public class NotificationDataTest extends SysuiTestCase { public void testSuppressSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"}); sbn.getNotification().extras = bundle; assertTrue(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testDoNotSuppressSystemAlertNotification() { StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"}); sbn.getNotification().extras = bundle; when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); Loading @@ -248,6 +257,22 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testDoNotSuppressMalformedSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); // missing extra assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); StatusBarNotification sbn = mRow.getEntry().notification; Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {}); sbn.getNotification().extras = bundle; // extra missing values assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testShouldFilterHiddenNotifications() { // setup Loading
services/core/java/com/android/server/wm/AlertWindowNotification.java +5 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import com.android.internal.R; import com.android.server.policy.IconUtilities; Loading Loading @@ -109,6 +111,8 @@ class AlertWindowNotification { final String message = context.getString(R.string.alert_windows_notification_message, appName); Bundle extras = new Bundle(); extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {mPackageName}); final Notification.Builder builder = new Notification.Builder(context, mNotificationTag) .setOngoing(true) .setContentTitle( Loading @@ -118,6 +122,7 @@ class AlertWindowNotification { .setColor(context.getColor(R.color.system_notification_accent_color)) .setStyle(new Notification.BigTextStyle().bigText(message)) .setLocalOnly(true) .addExtras(extras) .setContentIntent(getContentIntent(context, mPackageName)); if (aInfo != null) { Loading