Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35185d54 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents f322436d e1a74223
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -1987,7 +1987,7 @@ public class StatusBar extends SystemUI implements
        }
    }

    public void maybeEscalateHeadsUp() {
    private void maybeEscalateHeadsUp() {
        mHeadsUpManager.getAllEntries().forEach(entry -> {
            final StatusBarNotification sbn = entry.getSbn();
            final Notification notification = sbn.getNotification();
@@ -1998,6 +1998,7 @@ public class StatusBar extends SystemUI implements
                try {
                    EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION,
                            sbn.getKey());
                    wakeUpForFullScreenIntent();
                    notification.fullScreenIntent.send();
                    entry.notifyFullScreenIntentLaunched();
                } catch (PendingIntent.CanceledException e) {
@@ -2007,6 +2008,17 @@ public class StatusBar extends SystemUI implements
        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) {
        if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible);
        if (!force && (mExpandedVisible || !mCommandQueue.panelsEnabled())) {
@@ -3536,7 +3548,7 @@ public class StatusBar extends SystemUI implements
            DejankUtils.startDetectingBlockingIpcs(tag);
            updateRevealEffect(false /* wakingUp */);
            updateNotificationPanelTouchState();
            notifyHeadsUpGoingToSleep();
            maybeEscalateHeadsUp();
            dismissVolumeDialog();
            mWakeUpCoordinator.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.
     */
+5 −1
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.text.TextUtils;
import android.util.EventLog;
import android.view.View;

import androidx.annotation.VisibleForTesting;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger;
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 (shouldSuppressFullScreenIntent(entry)) {
                mLogger.logFullScreenIntentSuppressedByDnD(entry.getKey());
@@ -617,6 +620,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
                try {
                    EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION,
                            entry.getKey());
                    mStatusBar.wakeUpForFullScreenIntent();
                    fullscreenIntent.send();
                    entry.notifyFullScreenIntentLaunched();
                    mMetricsLogger.count("note_fullscreen", 1);
+28 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.when;

import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
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.NotificationRemoteInputManager;
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.NotificationLaunchAnimatorControllerProvider;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -114,6 +114,8 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
    @Mock
    private KeyguardStateController mKeyguardStateController;
    @Mock
    private NotificationInterruptStateProvider mNotificationInterruptStateProvider;
    @Mock
    private Handler mHandler;
    @Mock
    private BubblesManager mBubblesManager;
@@ -133,7 +135,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
    @Mock
    private OnUserInteractionCallback mOnUserInteractionCallback;
    @Mock
    private NotificationActivityStarter mNotificationActivityStarter;
    private StatusBarNotificationActivityStarter mNotificationActivityStarter;
    @Mock
    private ActivityLaunchAnimator mActivityLaunchAnimator;
    private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
@@ -209,7 +211,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
                        mock(NotificationLockscreenUserManager.class),
                        mShadeController,
                        mKeyguardStateController,
                        mock(NotificationInterruptStateProvider.class),
                        mNotificationInterruptStateProvider,
                        mock(LockPatternUtils.class),
                        mock(StatusBarRemoteInputCallback.class),
                        mActivityIntentHelper,
@@ -365,4 +367,27 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
        // Notification should not be cancelled.
        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();
    }
}