diff options
| author | 2019-07-26 10:11:22 -0700 | |
|---|---|---|
| committer | 2019-07-26 10:11:22 -0700 | |
| commit | 9b653e220ace608019d248b74be02da31f42fc09 (patch) | |
| tree | e1ef7ab941a3a8c03b38c71ae2e5bf490ce0c3ae | |
| parent | 0b23789274567290f520a08958c729d5901ee20c (diff) | |
| parent | a1001b430f953d743ae5d0c6390c5ba25e6369da (diff) | |
Merge "Showing the notification icon properly now when the pulse is suppressed" into qt-r1-dev
am: a1001b430f
Change-Id: I68131f995f959f09d22ae638411c47ba74fe7ce4
6 files changed, 48 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java index ae6dac59b2f5..07dd2cd77043 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java @@ -77,8 +77,10 @@ public interface DozeHost { interface Callback { /** * Called when a high priority notification is added. + * @param onPulseSuppressedListener A listener that is invoked if the pulse is being + * supressed. */ - default void onNotificationAlerted() {} + default void onNotificationAlerted(Runnable onPulseSuppressedListener) {} /** * Called when battery state or power save mode changes. diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java index 8ef01e8d608e..2ca85c074a89 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java @@ -106,22 +106,31 @@ public class DozeTriggers implements DozeMachine.Part { mDockManager = dockManager; } - private void onNotification() { + private void onNotification(Runnable onPulseSuppressedListener) { if (DozeMachine.DEBUG) { Log.d(TAG, "requestNotificationPulse"); } if (!sWakeDisplaySensorState) { Log.d(TAG, "Wake display false. Pulse denied."); + runIfNotNull(onPulseSuppressedListener); return; } mNotificationPulseTime = SystemClock.elapsedRealtime(); if (!mConfig.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) { + runIfNotNull(onPulseSuppressedListener); return; } - requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */); + requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */, + onPulseSuppressedListener); DozeLog.traceNotificationPulse(mContext); } + private static void runIfNotNull(Runnable runnable) { + if (runnable != null) { + runnable.run(); + } + } + private void proximityCheckThenCall(IntConsumer callback, boolean alreadyPerformedProxCheck, int reason) { @@ -158,10 +167,11 @@ public class DozeTriggers implements DozeMachine.Part { if (isWakeDisplay) { onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState()); } else if (isLongPress) { - requestPulse(pulseReason, sensorPerformedProxCheck); + requestPulse(pulseReason, sensorPerformedProxCheck, null /* onPulseSupressedListener */); } else if (isWakeLockScreen) { if (wakeEvent) { - requestPulse(pulseReason, sensorPerformedProxCheck); + requestPulse(pulseReason, sensorPerformedProxCheck, + null /* onPulseSupressedListener */); } } else { proximityCheckThenCall((result) -> { @@ -340,7 +350,8 @@ public class DozeTriggers implements DozeMachine.Part { } } - private void requestPulse(final int reason, boolean performedProxCheck) { + private void requestPulse(final int reason, boolean performedProxCheck, + Runnable onPulseSuppressedListener) { Assert.isMainThread(); mDozeHost.extendPulse(reason); @@ -357,6 +368,7 @@ public class DozeTriggers implements DozeMachine.Part { DozeLog.tracePulseDropped(mContext, mPulsePending, mMachine.getState(), mDozeHost.isPulsingBlocked()); } + runIfNotNull(onPulseSuppressedListener); return; } @@ -365,6 +377,7 @@ public class DozeTriggers implements DozeMachine.Part { if (result == ProximityCheck.RESULT_NEAR) { // in pocket, abort pulse mPulsePending = false; + runIfNotNull(onPulseSuppressedListener); } else { // not in pocket, continue pulsing continuePulseRequest(reason); @@ -482,7 +495,8 @@ public class DozeTriggers implements DozeMachine.Part { public void onReceive(Context context, Intent intent) { if (PULSE_ACTION.equals(intent.getAction())) { if (DozeMachine.DEBUG) Log.d(TAG, "Received pulse intent"); - requestPulse(DozeLog.PULSE_REASON_INTENT, false /* performedProxCheck */); + requestPulse(DozeLog.PULSE_REASON_INTENT, false, /* performedProxCheck */ + null /* onPulseSupressedListener */); } if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { mMachine.requestState(DozeMachine.State.FINISH); @@ -532,8 +546,8 @@ public class DozeTriggers implements DozeMachine.Part { private DozeHost.Callback mHostCallback = new DozeHost.Callback() { @Override - public void onNotificationAlerted() { - onNotification(); + public void onNotificationAlerted(Runnable onPulseSuppressedListener) { + onNotification(onPulseSuppressedListener); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index d71857082229..fe8854168288 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -179,6 +179,7 @@ public final class NotificationEntry { private boolean mSensitive = true; private Runnable mOnSensitiveChangedListener; private boolean mAutoHeadsUp; + private boolean mPulseSupressed; public NotificationEntry(StatusBarNotification n) { this(n, null); @@ -915,6 +916,14 @@ public final class NotificationEntry { mOnSensitiveChangedListener = listener; } + public boolean isPulseSuppressed() { + return mPulseSupressed; + } + + public void setPulseSuppressed(boolean suppressed) { + mPulseSupressed = suppressed; + } + /** Information about a suggestion that is being edited. */ public static class EditedSuggestionInfo { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 21de8a59836e..ba3406999388 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -78,6 +78,7 @@ public class NotificationIconAreaController implements DarkReceiver, private int mAodIconTint; private boolean mFullyHidden; private boolean mAodIconsVisible; + private boolean mIsPulsing; public NotificationIconAreaController(Context context, StatusBar statusBar, StatusBarStateController statusBarStateController, @@ -265,7 +266,9 @@ public class NotificationIconAreaController implements DarkReceiver, if (!showAmbient && entry.shouldSuppressStatusBar()) { return false; } - if (hidePulsing && entry.showingPulsing()) { + if (hidePulsing && entry.showingPulsing() + && (!mWakeUpCoordinator.getNotificationsFullyHidden() + || !entry.isPulseSuppressed())) { return false; } return true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 31fcf6fb3c48..f85751e71c63 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1580,7 +1580,8 @@ public class StatusBar extends SystemUI implements DemoMode, public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) { mEntryManager.updateNotifications(); if (isDozing() && isHeadsUp) { - mDozeServiceHost.fireNotificationPulse(); + entry.setPulseSuppressed(false); + mDozeServiceHost.fireNotificationPulse(entry); if (mPulsing) { mDozeScrimController.cancelPendingPulseTimeout(); } @@ -3931,9 +3932,13 @@ public class StatusBar extends SystemUI implements DemoMode, } } - public void fireNotificationPulse() { + public void fireNotificationPulse(NotificationEntry entry) { + Runnable pulseSupressedListener = () -> { + entry.setPulseSuppressed(true); + mNotificationIconAreaController.updateAodNotificationIcons(); + }; for (Callback callback : mCallbacks) { - callback.onNotificationAlerted(); + callback.onNotificationAlerted(pulseSupressedListener); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java index eb8ef09d0635..d4642238d8fd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java @@ -95,13 +95,13 @@ public class DozeTriggersTest extends SysuiTestCase { mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE); clearInvocations(mMachine); - mHost.callback.onNotificationAlerted(); + mHost.callback.onNotificationAlerted(null /* pulseSuppressedListener */); mSensors.getMockProximitySensor().sendProximityResult(false); /* Near */ verify(mMachine, never()).requestState(any()); verify(mMachine, never()).requestPulse(anyInt()); - mHost.callback.onNotificationAlerted(); + mHost.callback.onNotificationAlerted(null /* pulseSuppressedListener */); mSensors.getMockProximitySensor().sendProximityResult(true); /* Far */ verify(mMachine).requestPulse(anyInt()); |