Merge "Wakeup the screen for full screen intents" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-11-23 17:33:13 +00:00
committed by Android (Google) Code Review
3 changed files with 47 additions and 10 deletions

View File

@@ -1987,7 +1987,7 @@ public class StatusBar extends SystemUI implements
} }
} }
public void maybeEscalateHeadsUp() { private void maybeEscalateHeadsUp() {
mHeadsUpManager.getAllEntries().forEach(entry -> { mHeadsUpManager.getAllEntries().forEach(entry -> {
final StatusBarNotification sbn = entry.getSbn(); final StatusBarNotification sbn = entry.getSbn();
final Notification notification = sbn.getNotification(); final Notification notification = sbn.getNotification();
@@ -1998,6 +1998,7 @@ public class StatusBar extends SystemUI implements
try { try {
EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION,
sbn.getKey()); sbn.getKey());
wakeUpForFullScreenIntent();
notification.fullScreenIntent.send(); notification.fullScreenIntent.send();
entry.notifyFullScreenIntentLaunched(); entry.notifyFullScreenIntentLaunched();
} catch (PendingIntent.CanceledException e) { } catch (PendingIntent.CanceledException e) {
@@ -2007,6 +2008,17 @@ public class StatusBar extends SystemUI implements
mHeadsUpManager.releaseAllImmediately(); mHeadsUpManager.releaseAllImmediately();
} }
void wakeUpForFullScreenIntent() {
if (isGoingToSleep() || mDozing) {
mPowerManager.wakeUp(
SystemClock.uptimeMillis(),
PowerManager.WAKE_REASON_APPLICATION,
"com.android.systemui:full_screen_intent");
mWakeUpComingFromTouch = false;
mWakeUpTouchLocation = null;
}
}
void makeExpandedVisible(boolean force) { void makeExpandedVisible(boolean force) {
if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible);
if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) { if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) {
@@ -3536,7 +3548,7 @@ public class StatusBar extends SystemUI implements
DejankUtils.startDetectingBlockingIpcs(tag); DejankUtils.startDetectingBlockingIpcs(tag);
updateRevealEffect(false /* wakingUp */); updateRevealEffect(false /* wakingUp */);
updateNotificationPanelTouchState(); updateNotificationPanelTouchState();
notifyHeadsUpGoingToSleep(); maybeEscalateHeadsUp();
dismissVolumeDialog(); dismissVolumeDialog();
mWakeUpCoordinator.setFullyAwake(false); mWakeUpCoordinator.setFullyAwake(false);
mBypassHeadsUpNotifier.setFullyAwake(false); mBypassHeadsUpNotifier.setFullyAwake(false);
@@ -4081,10 +4093,6 @@ public class StatusBar extends SystemUI implements
} }
} }
protected void notifyHeadsUpGoingToSleep() {
maybeEscalateHeadsUp();
}
/** /**
* @return Whether the security bouncer from Keyguard is showing. * @return Whether the security bouncer from Keyguard is showing.
*/ */

View File

@@ -41,6 +41,8 @@ import android.text.TextUtils;
import android.util.EventLog; import android.util.EventLog;
import android.view.View; import android.view.View;
import androidx.annotation.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.statusbar.NotificationVisibility; import com.android.internal.statusbar.NotificationVisibility;
@@ -593,7 +595,8 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
} }
} }
private void handleFullScreenIntent(NotificationEntry entry) { @VisibleForTesting
void handleFullScreenIntent(NotificationEntry entry) {
if (mNotificationInterruptStateProvider.shouldLaunchFullScreenIntentWhenAdded(entry)) { if (mNotificationInterruptStateProvider.shouldLaunchFullScreenIntentWhenAdded(entry)) {
if (shouldSuppressFullScreenIntent(entry)) { if (shouldSuppressFullScreenIntent(entry)) {
mLogger.logFullScreenIntentSuppressedByDnD(entry.getKey()); mLogger.logFullScreenIntentSuppressedByDnD(entry.getKey());
@@ -617,6 +620,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
try { try {
EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION,
entry.getKey()); entry.getKey());
mStatusBar.wakeUpForFullScreenIntent();
fullscreenIntent.send(); fullscreenIntent.send();
entry.notifyFullScreenIntentLaunched(); entry.notifyFullScreenIntentLaunched();
mMetricsLogger.count("note_fullscreen", 1); mMetricsLogger.count("note_fullscreen", 1);

View File

@@ -34,6 +34,7 @@ import static org.mockito.Mockito.when;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
@@ -62,7 +63,6 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider; import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider;
import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -114,6 +114,8 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
@Mock @Mock
private KeyguardStateController mKeyguardStateController; private KeyguardStateController mKeyguardStateController;
@Mock @Mock
private NotificationInterruptStateProvider mNotificationInterruptStateProvider;
@Mock
private Handler mHandler; private Handler mHandler;
@Mock @Mock
private BubblesManager mBubblesManager; private BubblesManager mBubblesManager;
@@ -133,7 +135,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
@Mock @Mock
private OnUserInteractionCallback mOnUserInteractionCallback; private OnUserInteractionCallback mOnUserInteractionCallback;
@Mock @Mock
private NotificationActivityStarter mNotificationActivityStarter; private StatusBarNotificationActivityStarter mNotificationActivityStarter;
@Mock @Mock
private ActivityLaunchAnimator mActivityLaunchAnimator; private ActivityLaunchAnimator mActivityLaunchAnimator;
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
@@ -209,7 +211,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
mock(NotificationLockscreenUserManager.class), mock(NotificationLockscreenUserManager.class),
mShadeController, mShadeController,
mKeyguardStateController, mKeyguardStateController,
mock(NotificationInterruptStateProvider.class), mNotificationInterruptStateProvider,
mock(LockPatternUtils.class), mock(LockPatternUtils.class),
mock(StatusBarRemoteInputCallback.class), mock(StatusBarRemoteInputCallback.class),
mActivityIntentHelper, mActivityIntentHelper,
@@ -365,4 +367,27 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
// Notification should not be cancelled. // Notification should not be cancelled.
verify(mEntryManager, never()).performRemoveNotification(eq(sbn), any(), anyInt()); verify(mEntryManager, never()).performRemoveNotification(eq(sbn), any(), anyInt());
} }
@Test
public void testOnFullScreenIntentWhenDozing_wakeUpDevice() {
// GIVEN entry that can has a full screen intent that can show
Notification.Builder nb = new Notification.Builder(mContext, "a")
.setContentTitle("foo")
.setSmallIcon(android.R.drawable.sym_def_app_icon)
.setFullScreenIntent(mock(PendingIntent.class), true);
StatusBarNotification sbn = new StatusBarNotification("pkg", "pkg", 0,
"tag" + System.currentTimeMillis(), 0, 0,
nb.build(), new UserHandle(0), null, 0);
NotificationEntry entry = mock(NotificationEntry.class);
when(entry.getImportance()).thenReturn(NotificationManager.IMPORTANCE_HIGH);
when(entry.getSbn()).thenReturn(sbn);
when(mNotificationInterruptStateProvider.shouldLaunchFullScreenIntentWhenAdded(eq(entry)))
.thenReturn(true);
// WHEN
mNotificationActivityStarter.handleFullScreenIntent(entry);
// THEN display should try wake up for the full screen intent
verify(mStatusBar).wakeUpForFullScreenIntent();
}
} }