Merge "Exclude system notifications from visual suppression" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f9e4ccfe87
@@ -59,7 +59,6 @@ public class SystemNotificationChannels {
|
|||||||
VIRTUAL_KEYBOARD,
|
VIRTUAL_KEYBOARD,
|
||||||
context.getString(R.string.notification_channel_virtual_keyboard),
|
context.getString(R.string.notification_channel_virtual_keyboard),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
keyboard.setBypassDnd(true);
|
|
||||||
keyboard.setBlockableSystem(true);
|
keyboard.setBlockableSystem(true);
|
||||||
channelsList.add(keyboard);
|
channelsList.add(keyboard);
|
||||||
|
|
||||||
@@ -76,7 +75,6 @@ public class SystemNotificationChannels {
|
|||||||
SECURITY,
|
SECURITY,
|
||||||
context.getString(R.string.notification_channel_security),
|
context.getString(R.string.notification_channel_security),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
security.setBypassDnd(true);
|
|
||||||
channelsList.add(security);
|
channelsList.add(security);
|
||||||
|
|
||||||
final NotificationChannel car = new NotificationChannel(
|
final NotificationChannel car = new NotificationChannel(
|
||||||
@@ -84,7 +82,6 @@ public class SystemNotificationChannels {
|
|||||||
context.getString(R.string.notification_channel_car_mode),
|
context.getString(R.string.notification_channel_car_mode),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
car.setBlockableSystem(true);
|
car.setBlockableSystem(true);
|
||||||
car.setBypassDnd(true);
|
|
||||||
channelsList.add(car);
|
channelsList.add(car);
|
||||||
|
|
||||||
channelsList.add(newAccountChannel(context));
|
channelsList.add(newAccountChannel(context));
|
||||||
@@ -93,7 +90,6 @@ public class SystemNotificationChannels {
|
|||||||
DEVELOPER,
|
DEVELOPER,
|
||||||
context.getString(R.string.notification_channel_developer),
|
context.getString(R.string.notification_channel_developer),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
developer.setBypassDnd(true);
|
|
||||||
developer.setBlockableSystem(true);
|
developer.setBlockableSystem(true);
|
||||||
channelsList.add(developer);
|
channelsList.add(developer);
|
||||||
|
|
||||||
@@ -101,21 +97,18 @@ public class SystemNotificationChannels {
|
|||||||
UPDATES,
|
UPDATES,
|
||||||
context.getString(R.string.notification_channel_updates),
|
context.getString(R.string.notification_channel_updates),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
updates.setBypassDnd(true);
|
|
||||||
channelsList.add(updates);
|
channelsList.add(updates);
|
||||||
|
|
||||||
final NotificationChannel network = new NotificationChannel(
|
final NotificationChannel network = new NotificationChannel(
|
||||||
NETWORK_STATUS,
|
NETWORK_STATUS,
|
||||||
context.getString(R.string.notification_channel_network_status),
|
context.getString(R.string.notification_channel_network_status),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
network.setBypassDnd(true);
|
|
||||||
channelsList.add(network);
|
channelsList.add(network);
|
||||||
|
|
||||||
final NotificationChannel networkAlertsChannel = new NotificationChannel(
|
final NotificationChannel networkAlertsChannel = new NotificationChannel(
|
||||||
NETWORK_ALERTS,
|
NETWORK_ALERTS,
|
||||||
context.getString(R.string.notification_channel_network_alerts),
|
context.getString(R.string.notification_channel_network_alerts),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
networkAlertsChannel.setBypassDnd(true);
|
|
||||||
networkAlertsChannel.setBlockableSystem(true);
|
networkAlertsChannel.setBlockableSystem(true);
|
||||||
channelsList.add(networkAlertsChannel);
|
channelsList.add(networkAlertsChannel);
|
||||||
|
|
||||||
@@ -124,42 +117,36 @@ public class SystemNotificationChannels {
|
|||||||
context.getString(R.string.notification_channel_network_available),
|
context.getString(R.string.notification_channel_network_available),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
networkAvailable.setBlockableSystem(true);
|
networkAvailable.setBlockableSystem(true);
|
||||||
networkAvailable.setBypassDnd(true);
|
|
||||||
channelsList.add(networkAvailable);
|
channelsList.add(networkAvailable);
|
||||||
|
|
||||||
final NotificationChannel vpn = new NotificationChannel(
|
final NotificationChannel vpn = new NotificationChannel(
|
||||||
VPN,
|
VPN,
|
||||||
context.getString(R.string.notification_channel_vpn),
|
context.getString(R.string.notification_channel_vpn),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
vpn.setBypassDnd(true);
|
|
||||||
channelsList.add(vpn);
|
channelsList.add(vpn);
|
||||||
|
|
||||||
final NotificationChannel deviceAdmin = new NotificationChannel(
|
final NotificationChannel deviceAdmin = new NotificationChannel(
|
||||||
DEVICE_ADMIN,
|
DEVICE_ADMIN,
|
||||||
context.getString(R.string.notification_channel_device_admin),
|
context.getString(R.string.notification_channel_device_admin),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
deviceAdmin.setBypassDnd(true);
|
|
||||||
channelsList.add(deviceAdmin);
|
channelsList.add(deviceAdmin);
|
||||||
|
|
||||||
final NotificationChannel alertsChannel = new NotificationChannel(
|
final NotificationChannel alertsChannel = new NotificationChannel(
|
||||||
ALERTS,
|
ALERTS,
|
||||||
context.getString(R.string.notification_channel_alerts),
|
context.getString(R.string.notification_channel_alerts),
|
||||||
NotificationManager.IMPORTANCE_DEFAULT);
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
alertsChannel.setBypassDnd(true);
|
|
||||||
channelsList.add(alertsChannel);
|
channelsList.add(alertsChannel);
|
||||||
|
|
||||||
final NotificationChannel retail = new NotificationChannel(
|
final NotificationChannel retail = new NotificationChannel(
|
||||||
RETAIL_MODE,
|
RETAIL_MODE,
|
||||||
context.getString(R.string.notification_channel_retail_mode),
|
context.getString(R.string.notification_channel_retail_mode),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
retail.setBypassDnd(true);
|
|
||||||
channelsList.add(retail);
|
channelsList.add(retail);
|
||||||
|
|
||||||
final NotificationChannel usb = new NotificationChannel(
|
final NotificationChannel usb = new NotificationChannel(
|
||||||
USB,
|
USB,
|
||||||
context.getString(R.string.notification_channel_usb),
|
context.getString(R.string.notification_channel_usb),
|
||||||
NotificationManager.IMPORTANCE_MIN);
|
NotificationManager.IMPORTANCE_MIN);
|
||||||
usb.setBypassDnd(true);
|
|
||||||
channelsList.add(usb);
|
channelsList.add(usb);
|
||||||
|
|
||||||
NotificationChannel foregroundChannel = new NotificationChannel(
|
NotificationChannel foregroundChannel = new NotificationChannel(
|
||||||
@@ -167,7 +154,6 @@ public class SystemNotificationChannels {
|
|||||||
context.getString(R.string.notification_channel_foreground_service),
|
context.getString(R.string.notification_channel_foreground_service),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
foregroundChannel.setBlockableSystem(true);
|
foregroundChannel.setBlockableSystem(true);
|
||||||
foregroundChannel.setBypassDnd(true);
|
|
||||||
channelsList.add(foregroundChannel);
|
channelsList.add(foregroundChannel);
|
||||||
|
|
||||||
NotificationChannel heavyWeightChannel = new NotificationChannel(
|
NotificationChannel heavyWeightChannel = new NotificationChannel(
|
||||||
@@ -179,19 +165,16 @@ public class SystemNotificationChannels {
|
|||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
||||||
.build());
|
.build());
|
||||||
heavyWeightChannel.setBypassDnd(true);
|
|
||||||
channelsList.add(heavyWeightChannel);
|
channelsList.add(heavyWeightChannel);
|
||||||
|
|
||||||
NotificationChannel systemChanges = new NotificationChannel(SYSTEM_CHANGES,
|
NotificationChannel systemChanges = new NotificationChannel(SYSTEM_CHANGES,
|
||||||
context.getString(R.string.notification_channel_system_changes),
|
context.getString(R.string.notification_channel_system_changes),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
systemChanges.setBypassDnd(true);
|
|
||||||
channelsList.add(systemChanges);
|
channelsList.add(systemChanges);
|
||||||
|
|
||||||
NotificationChannel dndChanges = new NotificationChannel(DO_NOT_DISTURB,
|
NotificationChannel dndChanges = new NotificationChannel(DO_NOT_DISTURB,
|
||||||
context.getString(R.string.notification_channel_do_not_disturb),
|
context.getString(R.string.notification_channel_do_not_disturb),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
dndChanges.setBypassDnd(true);
|
|
||||||
channelsList.add(dndChanges);
|
channelsList.add(dndChanges);
|
||||||
|
|
||||||
nm.createNotificationChannels(channelsList);
|
nm.createNotificationChannels(channelsList);
|
||||||
@@ -208,12 +191,10 @@ public class SystemNotificationChannels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static NotificationChannel newAccountChannel(Context context) {
|
private static NotificationChannel newAccountChannel(Context context) {
|
||||||
final NotificationChannel acct = new NotificationChannel(
|
return new NotificationChannel(
|
||||||
ACCOUNT,
|
ACCOUNT,
|
||||||
context.getString(R.string.notification_channel_account),
|
context.getString(R.string.notification_channel_account),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
acct.setBypassDnd(true);
|
|
||||||
return acct;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemNotificationChannels() {}
|
private SystemNotificationChannels() {}
|
||||||
|
|||||||
@@ -179,11 +179,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
private NotificationGuts mGuts;
|
private NotificationGuts mGuts;
|
||||||
private NotificationData.Entry mEntry;
|
private NotificationData.Entry mEntry;
|
||||||
private StatusBarNotification mStatusBarNotification;
|
private StatusBarNotification mStatusBarNotification;
|
||||||
/**
|
|
||||||
* Whether or not this row represents a system notification. Note that if this is {@code null},
|
|
||||||
* that means we were either unable to retrieve the info or have yet to retrieve the info.
|
|
||||||
*/
|
|
||||||
private Boolean mIsSystemNotification;
|
|
||||||
private String mAppName;
|
private String mAppName;
|
||||||
private boolean mIsHeadsUp;
|
private boolean mIsHeadsUp;
|
||||||
private boolean mLastChronometerRunning = true;
|
private boolean mLastChronometerRunning = true;
|
||||||
@@ -426,7 +421,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
* once per notification as the packageInfo can't technically change for a notification row.
|
* once per notification as the packageInfo can't technically change for a notification row.
|
||||||
*/
|
*/
|
||||||
private void cacheIsSystemNotification() {
|
private void cacheIsSystemNotification() {
|
||||||
if (mIsSystemNotification == null) {
|
if (mEntry != null && mEntry.mIsSystemNotification == null) {
|
||||||
if (mSystemNotificationAsyncTask.getStatus() == AsyncTask.Status.PENDING) {
|
if (mSystemNotificationAsyncTask.getStatus() == AsyncTask.Status.PENDING) {
|
||||||
// Run async task once, only if it hasn't already been executed. Note this is
|
// Run async task once, only if it hasn't already been executed. Note this is
|
||||||
// executed in serial - no need to parallelize this small task.
|
// executed in serial - no need to parallelize this small task.
|
||||||
@@ -445,16 +440,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
|
|
||||||
// If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once
|
// If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once
|
||||||
// again, but in-place on the main thread this time. This should rarely ever get called.
|
// again, but in-place on the main thread this time. This should rarely ever get called.
|
||||||
if (mIsSystemNotification == null) {
|
if (mEntry != null && mEntry.mIsSystemNotification == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Retrieving isSystemNotification on main thread");
|
Log.d(TAG, "Retrieving isSystemNotification on main thread");
|
||||||
}
|
}
|
||||||
mSystemNotificationAsyncTask.cancel(true /* mayInterruptIfRunning */);
|
mSystemNotificationAsyncTask.cancel(true /* mayInterruptIfRunning */);
|
||||||
mIsSystemNotification = isSystemNotification(mContext, mStatusBarNotification);
|
mEntry.mIsSystemNotification = isSystemNotification(mContext, mStatusBarNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNonblockable && mIsSystemNotification != null) {
|
if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) {
|
||||||
if (mIsSystemNotification) {
|
if (mEntry.mIsSystemNotification) {
|
||||||
if (mEntry.channel != null
|
if (mEntry.channel != null
|
||||||
&& !mEntry.channel.isBlockableSystem()) {
|
&& !mEntry.channel.isBlockableSystem()) {
|
||||||
isNonblockable = true;
|
isNonblockable = true;
|
||||||
@@ -2875,7 +2870,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
mIsSystemNotification = result;
|
if (mEntry != null) {
|
||||||
|
mEntry.mIsSystemNotification = result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ public class NotificationData {
|
|||||||
public ArraySet<Integer> mActiveAppOps = new ArraySet<>(3);
|
public ArraySet<Integer> mActiveAppOps = new ArraySet<>(3);
|
||||||
public CharSequence headsUpStatusBarText;
|
public CharSequence headsUpStatusBarText;
|
||||||
public CharSequence headsUpStatusBarTextPublic;
|
public CharSequence headsUpStatusBarTextPublic;
|
||||||
|
/**
|
||||||
|
* Whether or not this row represents a system notification. Note that if this is
|
||||||
|
* {@code null}, that means we were either unable to retrieve the info or have yet to
|
||||||
|
* retrieve the info.
|
||||||
|
*/
|
||||||
|
public Boolean mIsSystemNotification;
|
||||||
|
|
||||||
public Entry(StatusBarNotification n) {
|
public Entry(StatusBarNotification n) {
|
||||||
this.key = n.getKey();
|
this.key = n.getKey();
|
||||||
@@ -435,31 +441,31 @@ public class NotificationData {
|
|||||||
return Ranking.VISIBILITY_NO_OVERRIDE;
|
return Ranking.VISIBILITY_NO_OVERRIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSuppressFullScreenIntent(StatusBarNotification sbn) {
|
public boolean shouldSuppressFullScreenIntent(Entry entry) {
|
||||||
return shouldSuppressVisualEffect(sbn, SUPPRESSED_EFFECT_FULL_SCREEN_INTENT);
|
return shouldSuppressVisualEffect(entry, SUPPRESSED_EFFECT_FULL_SCREEN_INTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSuppressPeek(StatusBarNotification sbn) {
|
public boolean shouldSuppressPeek(Entry entry) {
|
||||||
return shouldSuppressVisualEffect(sbn, SUPPRESSED_EFFECT_PEEK);
|
return shouldSuppressVisualEffect(entry, SUPPRESSED_EFFECT_PEEK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSuppressStatusBar(StatusBarNotification sbn) {
|
public boolean shouldSuppressStatusBar(Entry entry) {
|
||||||
return shouldSuppressVisualEffect(sbn, SUPPRESSED_EFFECT_STATUS_BAR);
|
return shouldSuppressVisualEffect(entry, SUPPRESSED_EFFECT_STATUS_BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSuppressAmbient(StatusBarNotification sbn) {
|
public boolean shouldSuppressAmbient(Entry entry) {
|
||||||
return shouldSuppressVisualEffect(sbn, SUPPRESSED_EFFECT_AMBIENT);
|
return shouldSuppressVisualEffect(entry, SUPPRESSED_EFFECT_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSuppressNotificationList(StatusBarNotification sbn) {
|
public boolean shouldSuppressNotificationList(Entry entry) {
|
||||||
return shouldSuppressVisualEffect(sbn, SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
return shouldSuppressVisualEffect(entry, SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSuppressVisualEffect(StatusBarNotification sbn, int effect) {
|
private boolean shouldSuppressVisualEffect(Entry entry, int effect) {
|
||||||
if (isExemptFromDndVisualSuppression(sbn)) {
|
if (isExemptFromDndVisualSuppression(entry)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String key = sbn.getKey();
|
String key = entry.key;
|
||||||
if (mRankingMap != null) {
|
if (mRankingMap != null) {
|
||||||
getRanking(key, mTmpRanking);
|
getRanking(key, mTmpRanking);
|
||||||
return (mTmpRanking.getSuppressedVisualEffects() & effect) != 0;
|
return (mTmpRanking.getSuppressedVisualEffects() & effect) != 0;
|
||||||
@@ -467,11 +473,15 @@ public class NotificationData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isExemptFromDndVisualSuppression(StatusBarNotification sbn) {
|
protected boolean isExemptFromDndVisualSuppression(Entry entry) {
|
||||||
if ((sbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
|
if ((entry.notification.getNotification().flags
|
||||||
|
& Notification.FLAG_FOREGROUND_SERVICE) != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sbn.getNotification().isMediaNotification()) {
|
if (entry.notification.getNotification().isMediaNotification()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (entry.mIsSystemNotification != null && entry.mIsSystemNotification) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -564,9 +574,8 @@ public class NotificationData {
|
|||||||
final int N = mEntries.size();
|
final int N = mEntries.size();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
Entry entry = mEntries.valueAt(i);
|
Entry entry = mEntries.valueAt(i);
|
||||||
StatusBarNotification sbn = entry.notification;
|
|
||||||
|
|
||||||
if (shouldFilterOut(sbn)) {
|
if (shouldFilterOut(entry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,10 +587,10 @@ public class NotificationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sbn
|
|
||||||
* @return true if this notification should NOT be shown right now
|
* @return true if this notification should NOT be shown right now
|
||||||
*/
|
*/
|
||||||
public boolean shouldFilterOut(StatusBarNotification sbn) {
|
public boolean shouldFilterOut(Entry entry) {
|
||||||
|
final StatusBarNotification sbn = entry.notification;
|
||||||
if (!(mEnvironment.isDeviceProvisioned() ||
|
if (!(mEnvironment.isDeviceProvisioned() ||
|
||||||
showNotificationEvenIfUnprovisioned(sbn))) {
|
showNotificationEvenIfUnprovisioned(sbn))) {
|
||||||
return true;
|
return true;
|
||||||
@@ -598,11 +607,11 @@ public class NotificationData {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEnvironment.isDozing() && shouldSuppressAmbient(sbn)) {
|
if (mEnvironment.isDozing() && shouldSuppressAmbient(entry)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mEnvironment.isDozing() && shouldSuppressNotificationList(sbn)) {
|
if (!mEnvironment.isDozing() && shouldSuppressNotificationList(entry)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,12 +300,12 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
|
|||||||
updateNotifications();
|
updateNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSuppressFullScreenIntent(StatusBarNotification sbn) {
|
private boolean shouldSuppressFullScreenIntent(NotificationData.Entry entry) {
|
||||||
if (mPresenter.isDeviceInVrMode()) {
|
if (mPresenter.isDeviceInVrMode()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mNotificationData.shouldSuppressFullScreenIntent(sbn);
|
return mNotificationData.shouldSuppressFullScreenIntent(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inflateViews(NotificationData.Entry entry, ViewGroup parent) {
|
private void inflateViews(NotificationData.Entry entry, ViewGroup parent) {
|
||||||
@@ -692,7 +692,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
|
|||||||
NotificationData.Entry shadeEntry = createNotificationViews(notification);
|
NotificationData.Entry shadeEntry = createNotificationViews(notification);
|
||||||
boolean isHeadsUped = shouldPeek(shadeEntry);
|
boolean isHeadsUped = shouldPeek(shadeEntry);
|
||||||
if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) {
|
if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) {
|
||||||
if (shouldSuppressFullScreenIntent(notification)) {
|
if (shouldSuppressFullScreenIntent(shadeEntry)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + key);
|
Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + key);
|
||||||
}
|
}
|
||||||
@@ -848,7 +848,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNotificationData.shouldFilterOut(sbn)) {
|
if (mNotificationData.shouldFilterOut(entry)) {
|
||||||
if (DEBUG) Log.d(TAG, "No peeking: filtered notification: " + sbn.getKey());
|
if (DEBUG) Log.d(TAG, "No peeking: filtered notification: " + sbn.getKey());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -862,13 +862,13 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mPresenter.isDozing() && mNotificationData.shouldSuppressPeek(sbn)) {
|
if (!mPresenter.isDozing() && mNotificationData.shouldSuppressPeek(entry)) {
|
||||||
if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey());
|
if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peeking triggers an ambient display pulse, so disable peek is ambient is active
|
// Peeking triggers an ambient display pulse, so disable peek is ambient is active
|
||||||
if (mPresenter.isDozing() && mNotificationData.shouldSuppressAmbient(sbn)) {
|
if (mPresenter.isDozing() && mNotificationData.shouldSuppressAmbient(entry)) {
|
||||||
if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey());
|
if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,8 +156,7 @@ public class NotificationIconAreaController implements DarkReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// showAmbient == show in shade but not shelf
|
// showAmbient == show in shade but not shelf
|
||||||
if (!showAmbient && mEntryManager.getNotificationData().shouldSuppressStatusBar(
|
if (!showAmbient && mEntryManager.getNotificationData().shouldSuppressStatusBar(entry)) {
|
||||||
entry.notification)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,19 +51,16 @@ public class NotificationChannels extends SystemUI {
|
|||||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
||||||
.build());
|
.build());
|
||||||
batteryChannel.setBlockableSystem(true);
|
batteryChannel.setBlockableSystem(true);
|
||||||
batteryChannel.setBypassDnd(true);
|
|
||||||
|
|
||||||
final NotificationChannel alerts = new NotificationChannel(
|
final NotificationChannel alerts = new NotificationChannel(
|
||||||
ALERTS,
|
ALERTS,
|
||||||
context.getString(R.string.notification_channel_alerts),
|
context.getString(R.string.notification_channel_alerts),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
alerts.setBypassDnd(true);
|
|
||||||
|
|
||||||
final NotificationChannel general = new NotificationChannel(
|
final NotificationChannel general = new NotificationChannel(
|
||||||
GENERAL,
|
GENERAL,
|
||||||
context.getString(R.string.notification_channel_general),
|
context.getString(R.string.notification_channel_general),
|
||||||
NotificationManager.IMPORTANCE_MIN);
|
NotificationManager.IMPORTANCE_MIN);
|
||||||
general.setBypassDnd(true);
|
|
||||||
|
|
||||||
final NotificationChannel storage = new NotificationChannel(
|
final NotificationChannel storage = new NotificationChannel(
|
||||||
STORAGE,
|
STORAGE,
|
||||||
@@ -71,7 +68,6 @@ public class NotificationChannels extends SystemUI {
|
|||||||
isTv(context)
|
isTv(context)
|
||||||
? NotificationManager.IMPORTANCE_DEFAULT
|
? NotificationManager.IMPORTANCE_DEFAULT
|
||||||
: NotificationManager.IMPORTANCE_LOW);
|
: NotificationManager.IMPORTANCE_LOW);
|
||||||
storage.setBypassDnd(true);
|
|
||||||
|
|
||||||
final NotificationChannel hint = new NotificationChannel(
|
final NotificationChannel hint = new NotificationChannel(
|
||||||
HINTS,
|
HINTS,
|
||||||
@@ -119,7 +115,6 @@ public class NotificationChannels extends SystemUI {
|
|||||||
|
|
||||||
screenshotChannel.setSound(Uri.parse(""), // silent
|
screenshotChannel.setSound(Uri.parse(""), // silent
|
||||||
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
|
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
|
||||||
screenshotChannel.setBypassDnd(true);
|
|
||||||
screenshotChannel.setBlockableSystem(true);
|
screenshotChannel.setBlockableSystem(true);
|
||||||
|
|
||||||
if (legacySS != null) {
|
if (legacySS != null) {
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"});
|
bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[] {"something"});
|
||||||
sbn.getNotification().extras = bundle;
|
sbn.getNotification().extras = bundle;
|
||||||
|
|
||||||
assertTrue(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertTrue(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -223,17 +223,17 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
||||||
when(mFsc.isSystemAlertNotification(any())).thenReturn(true);
|
when(mFsc.isSystemAlertNotification(any())).thenReturn(true);
|
||||||
|
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
|
|
||||||
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
||||||
when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
|
when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
|
|
||||||
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false);
|
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false);
|
||||||
when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
|
when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -241,7 +241,7 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true);
|
||||||
|
|
||||||
// missing extra
|
// missing extra
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
|
|
||||||
StatusBarNotification sbn = mRow.getEntry().notification;
|
StatusBarNotification sbn = mRow.getEntry().notification;
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
@@ -249,7 +249,7 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
sbn.getNotification().extras = bundle;
|
sbn.getNotification().extras = bundle;
|
||||||
|
|
||||||
// extra missing values
|
// extra missing values
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification));
|
assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -262,11 +262,13 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
// test should filter out hidden notifications:
|
// test should filter out hidden notifications:
|
||||||
// hidden
|
// hidden
|
||||||
when(mMockStatusBarNotification.getKey()).thenReturn(TEST_HIDDEN_NOTIFICATION_KEY);
|
when(mMockStatusBarNotification.getKey()).thenReturn(TEST_HIDDEN_NOTIFICATION_KEY);
|
||||||
assertTrue(mNotificationData.shouldFilterOut(mMockStatusBarNotification));
|
NotificationData.Entry entry = new NotificationData.Entry(mMockStatusBarNotification);
|
||||||
|
assertTrue(mNotificationData.shouldFilterOut(entry));
|
||||||
|
|
||||||
// not hidden
|
// not hidden
|
||||||
when(mMockStatusBarNotification.getKey()).thenReturn("not hidden");
|
when(mMockStatusBarNotification.getKey()).thenReturn("not hidden");
|
||||||
assertFalse(mNotificationData.shouldFilterOut(mMockStatusBarNotification));
|
entry = new NotificationData.Entry(mMockStatusBarNotification);
|
||||||
|
assertFalse(mNotificationData.shouldFilterOut(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -276,9 +278,10 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
TEST_EXEMPT_DND_VISUAL_SUPPRESSION_KEY);
|
TEST_EXEMPT_DND_VISUAL_SUPPRESSION_KEY);
|
||||||
Notification n = mMockStatusBarNotification.getNotification();
|
Notification n = mMockStatusBarNotification.getNotification();
|
||||||
n.flags = Notification.FLAG_FOREGROUND_SERVICE;
|
n.flags = Notification.FLAG_FOREGROUND_SERVICE;
|
||||||
|
NotificationData.Entry entry = new NotificationData.Entry(mMockStatusBarNotification);
|
||||||
|
|
||||||
assertTrue(mNotificationData.isExemptFromDndVisualSuppression(mMockStatusBarNotification));
|
assertTrue(mNotificationData.isExemptFromDndVisualSuppression(entry));
|
||||||
assertFalse(mNotificationData.shouldSuppressAmbient(mMockStatusBarNotification));
|
assertFalse(mNotificationData.shouldSuppressAmbient(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -291,9 +294,22 @@ public class NotificationDataTest extends SysuiTestCase {
|
|||||||
nb.setStyle(new Notification.MediaStyle().setMediaSession(mock(MediaSession.Token.class)));
|
nb.setStyle(new Notification.MediaStyle().setMediaSession(mock(MediaSession.Token.class)));
|
||||||
n = nb.build();
|
n = nb.build();
|
||||||
when(mMockStatusBarNotification.getNotification()).thenReturn(n);
|
when(mMockStatusBarNotification.getNotification()).thenReturn(n);
|
||||||
|
NotificationData.Entry entry = new NotificationData.Entry(mMockStatusBarNotification);
|
||||||
|
|
||||||
assertTrue(mNotificationData.isExemptFromDndVisualSuppression(mMockStatusBarNotification));
|
assertTrue(mNotificationData.isExemptFromDndVisualSuppression(entry));
|
||||||
assertFalse(mNotificationData.shouldSuppressAmbient(mMockStatusBarNotification));
|
assertFalse(mNotificationData.shouldSuppressAmbient(entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsExemptFromDndVisualSuppression_system() {
|
||||||
|
initStatusBarNotification(false);
|
||||||
|
when(mMockStatusBarNotification.getKey()).thenReturn(
|
||||||
|
TEST_EXEMPT_DND_VISUAL_SUPPRESSION_KEY);
|
||||||
|
NotificationData.Entry entry = new NotificationData.Entry(mMockStatusBarNotification);
|
||||||
|
entry.mIsSystemNotification = true;
|
||||||
|
|
||||||
|
assertTrue(mNotificationData.isExemptFromDndVisualSuppression(entry));
|
||||||
|
assertFalse(mNotificationData.shouldSuppressAmbient(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initStatusBarNotification(boolean allowDuringSetup) {
|
private void initStatusBarNotification(boolean allowDuringSetup) {
|
||||||
|
|||||||
Reference in New Issue
Block a user