Merge "Make logging optional when checking for heads up" into tm-qpr-dev
This commit is contained in:
@@ -36,6 +36,19 @@ public interface NotificationInterruptStateProvider {
|
|||||||
*/
|
*/
|
||||||
boolean shouldHeadsUp(NotificationEntry entry);
|
boolean shouldHeadsUp(NotificationEntry entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of whether this entry should peek (from shouldHeadsUp(entry)), but only
|
||||||
|
* optionally logs the status.
|
||||||
|
*
|
||||||
|
* This method should be used in cases where the caller needs to check whether a notification
|
||||||
|
* qualifies for a heads up, but is not necessarily guaranteed to make the heads-up happen.
|
||||||
|
*
|
||||||
|
* @param entry the entry to check
|
||||||
|
* @param log whether or not to log the results of this check
|
||||||
|
* @return true if the entry should heads up, false otherwise
|
||||||
|
*/
|
||||||
|
boolean checkHeadsUp(NotificationEntry entry, boolean log);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the notification should appear as a bubble with a fly-out on top of the screen.
|
* Whether the notification should appear as a bubble with a fly-out on top of the screen.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -137,11 +137,11 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
public boolean shouldBubbleUp(NotificationEntry entry) {
|
public boolean shouldBubbleUp(NotificationEntry entry) {
|
||||||
final StatusBarNotification sbn = entry.getSbn();
|
final StatusBarNotification sbn = entry.getSbn();
|
||||||
|
|
||||||
if (!canAlertCommon(entry)) {
|
if (!canAlertCommon(entry, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertAwakeCommon(entry)) {
|
if (!canAlertAwakeCommon(entry, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,10 +163,15 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldHeadsUp(NotificationEntry entry) {
|
public boolean shouldHeadsUp(NotificationEntry entry) {
|
||||||
|
return checkHeadsUp(entry, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkHeadsUp(NotificationEntry entry, boolean log) {
|
||||||
if (mStatusBarStateController.isDozing()) {
|
if (mStatusBarStateController.isDozing()) {
|
||||||
return shouldHeadsUpWhenDozing(entry);
|
return shouldHeadsUpWhenDozing(entry, log);
|
||||||
} else {
|
} else {
|
||||||
return shouldHeadsUpWhenAwake(entry);
|
return shouldHeadsUpWhenAwake(entry, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,61 +268,61 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldHeadsUpWhenAwake(NotificationEntry entry) {
|
private boolean shouldHeadsUpWhenAwake(NotificationEntry entry, boolean log) {
|
||||||
StatusBarNotification sbn = entry.getSbn();
|
StatusBarNotification sbn = entry.getSbn();
|
||||||
|
|
||||||
if (!mUseHeadsUp) {
|
if (!mUseHeadsUp) {
|
||||||
mLogger.logNoHeadsUpFeatureDisabled();
|
if (log) mLogger.logNoHeadsUpFeatureDisabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertCommon(entry)) {
|
if (!canAlertCommon(entry, log)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertHeadsUpCommon(entry)) {
|
if (!canAlertHeadsUpCommon(entry, log)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertAwakeCommon(entry)) {
|
if (!canAlertAwakeCommon(entry, log)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSnoozedPackage(sbn)) {
|
if (isSnoozedPackage(sbn)) {
|
||||||
mLogger.logNoHeadsUpPackageSnoozed(entry);
|
if (log) mLogger.logNoHeadsUpPackageSnoozed(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inShade = mStatusBarStateController.getState() == SHADE;
|
boolean inShade = mStatusBarStateController.getState() == SHADE;
|
||||||
if (entry.isBubble() && inShade) {
|
if (entry.isBubble() && inShade) {
|
||||||
mLogger.logNoHeadsUpAlreadyBubbled(entry);
|
if (log) mLogger.logNoHeadsUpAlreadyBubbled(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.shouldSuppressPeek()) {
|
if (entry.shouldSuppressPeek()) {
|
||||||
mLogger.logNoHeadsUpSuppressedByDnd(entry);
|
if (log) mLogger.logNoHeadsUpSuppressedByDnd(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getImportance() < NotificationManager.IMPORTANCE_HIGH) {
|
if (entry.getImportance() < NotificationManager.IMPORTANCE_HIGH) {
|
||||||
mLogger.logNoHeadsUpNotImportant(entry);
|
if (log) mLogger.logNoHeadsUpNotImportant(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inUse = mPowerManager.isScreenOn() && !isDreaming();
|
boolean inUse = mPowerManager.isScreenOn() && !isDreaming();
|
||||||
|
|
||||||
if (!inUse) {
|
if (!inUse) {
|
||||||
mLogger.logNoHeadsUpNotInUse(entry);
|
if (log) mLogger.logNoHeadsUpNotInUse(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < mSuppressors.size(); i++) {
|
for (int i = 0; i < mSuppressors.size(); i++) {
|
||||||
if (mSuppressors.get(i).suppressAwakeHeadsUp(entry)) {
|
if (mSuppressors.get(i).suppressAwakeHeadsUp(entry)) {
|
||||||
mLogger.logNoHeadsUpSuppressedBy(entry, mSuppressors.get(i));
|
if (log) mLogger.logNoHeadsUpSuppressedBy(entry, mSuppressors.get(i));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mLogger.logHeadsUp(entry);
|
if (log) mLogger.logHeadsUp(entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,37 +333,37 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
* @param entry the entry to check
|
* @param entry the entry to check
|
||||||
* @return true if the entry should ambient pulse, false otherwise
|
* @return true if the entry should ambient pulse, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean shouldHeadsUpWhenDozing(NotificationEntry entry) {
|
private boolean shouldHeadsUpWhenDozing(NotificationEntry entry, boolean log) {
|
||||||
if (!mAmbientDisplayConfiguration.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) {
|
if (!mAmbientDisplayConfiguration.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) {
|
||||||
mLogger.logNoPulsingSettingDisabled(entry);
|
if (log) mLogger.logNoPulsingSettingDisabled(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBatteryController.isAodPowerSave()) {
|
if (mBatteryController.isAodPowerSave()) {
|
||||||
mLogger.logNoPulsingBatteryDisabled(entry);
|
if (log) mLogger.logNoPulsingBatteryDisabled(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertCommon(entry)) {
|
if (!canAlertCommon(entry, log)) {
|
||||||
mLogger.logNoPulsingNoAlert(entry);
|
if (log) mLogger.logNoPulsingNoAlert(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canAlertHeadsUpCommon(entry)) {
|
if (!canAlertHeadsUpCommon(entry, log)) {
|
||||||
mLogger.logNoPulsingNoAlert(entry);
|
if (log) mLogger.logNoPulsingNoAlert(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.shouldSuppressAmbient()) {
|
if (entry.shouldSuppressAmbient()) {
|
||||||
mLogger.logNoPulsingNoAmbientEffect(entry);
|
if (log) mLogger.logNoPulsingNoAmbientEffect(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) {
|
if (entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) {
|
||||||
mLogger.logNoPulsingNotImportant(entry);
|
if (log) mLogger.logNoPulsingNotImportant(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mLogger.logPulsing(entry);
|
if (log) mLogger.logPulsing(entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,18 +371,22 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
* Common checks between regular & AOD heads up and bubbles.
|
* Common checks between regular & AOD heads up and bubbles.
|
||||||
*
|
*
|
||||||
* @param entry the entry to check
|
* @param entry the entry to check
|
||||||
|
* @param log whether or not to log the results of these checks
|
||||||
* @return true if these checks pass, false if the notification should not alert
|
* @return true if these checks pass, false if the notification should not alert
|
||||||
*/
|
*/
|
||||||
private boolean canAlertCommon(NotificationEntry entry) {
|
private boolean canAlertCommon(NotificationEntry entry, boolean log) {
|
||||||
for (int i = 0; i < mSuppressors.size(); i++) {
|
for (int i = 0; i < mSuppressors.size(); i++) {
|
||||||
if (mSuppressors.get(i).suppressInterruptions(entry)) {
|
if (mSuppressors.get(i).suppressInterruptions(entry)) {
|
||||||
mLogger.logNoAlertingSuppressedBy(entry, mSuppressors.get(i), /* awake */ false);
|
if (log) {
|
||||||
|
mLogger.logNoAlertingSuppressedBy(entry, mSuppressors.get(i),
|
||||||
|
/* awake */ false);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
|
if (mKeyguardNotificationVisibilityProvider.shouldHideNotification(entry)) {
|
||||||
mLogger.keyguardHideNotification(entry);
|
if (log) mLogger.keyguardHideNotification(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,19 +397,20 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
* Common checks for heads up notifications on regular and AOD displays.
|
* Common checks for heads up notifications on regular and AOD displays.
|
||||||
*
|
*
|
||||||
* @param entry the entry to check
|
* @param entry the entry to check
|
||||||
|
* @param log whether or not to log the results of these checks
|
||||||
* @return true if these checks pass, false if the notification should not alert
|
* @return true if these checks pass, false if the notification should not alert
|
||||||
*/
|
*/
|
||||||
private boolean canAlertHeadsUpCommon(NotificationEntry entry) {
|
private boolean canAlertHeadsUpCommon(NotificationEntry entry, boolean log) {
|
||||||
StatusBarNotification sbn = entry.getSbn();
|
StatusBarNotification sbn = entry.getSbn();
|
||||||
|
|
||||||
// Don't alert notifications that are suppressed due to group alert behavior
|
// Don't alert notifications that are suppressed due to group alert behavior
|
||||||
if (sbn.isGroup() && sbn.getNotification().suppressAlertingDueToGrouping()) {
|
if (sbn.isGroup() && sbn.getNotification().suppressAlertingDueToGrouping()) {
|
||||||
mLogger.logNoAlertingGroupAlertBehavior(entry);
|
if (log) mLogger.logNoAlertingGroupAlertBehavior(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.hasJustLaunchedFullScreenIntent()) {
|
if (entry.hasJustLaunchedFullScreenIntent()) {
|
||||||
mLogger.logNoAlertingRecentFullscreen(entry);
|
if (log) mLogger.logNoAlertingRecentFullscreen(entry);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,12 +423,14 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
|
|||||||
* @param entry the entry to check
|
* @param entry the entry to check
|
||||||
* @return true if these checks pass, false if the notification should not alert
|
* @return true if these checks pass, false if the notification should not alert
|
||||||
*/
|
*/
|
||||||
private boolean canAlertAwakeCommon(NotificationEntry entry) {
|
private boolean canAlertAwakeCommon(NotificationEntry entry, boolean log) {
|
||||||
StatusBarNotification sbn = entry.getSbn();
|
StatusBarNotification sbn = entry.getSbn();
|
||||||
|
|
||||||
for (int i = 0; i < mSuppressors.size(); i++) {
|
for (int i = 0; i < mSuppressors.size(); i++) {
|
||||||
if (mSuppressors.get(i).suppressAwakeInterruptions(entry)) {
|
if (mSuppressors.get(i).suppressAwakeInterruptions(entry)) {
|
||||||
mLogger.logNoAlertingSuppressedBy(entry, mSuppressors.get(i), /* awake */ true);
|
if (log) {
|
||||||
|
mLogger.logNoAlertingSuppressedBy(entry, mSuppressors.get(i), /* awake */ true);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user