Merge "Showing the notification icon properly now when the pulse is suppressed" into qt-r1-dev
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user