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

Commit 66f0b708 authored by Matthew Ng's avatar Matthew Ng
Browse files

Added back the recents button to activity over lockscreen

When recents button is pressed, check if keyguard is up and then wait
for dismiss before going to recents. Forces only the back button to be
shown when bouncer is shown.

Fixes: ag/63879974
Test: open maps, navigate, turn off screen then back on
Change-Id: Ia7cec13af5bad261a9eb187df57fe62a5f96326e
parent eb8acafc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -75,6 +75,12 @@ public interface ViewMediatorCallback {
     */
    void playTrustedSound();

    /**
     * When the bouncer is shown or hides
     * @param shown
     */
    void onBouncerVisiblityChanged(boolean shown);

    /**
     * @return true if the screen is on
     */
+15 −9
Original line number Diff line number Diff line
@@ -612,6 +612,13 @@ public class KeyguardViewMediator extends SystemUI {
            resetStateLocked();
        }

        @Override
        public void onBouncerVisiblityChanged(boolean shown) {
            synchronized (KeyguardViewMediator.this) {
                adjustStatusBarLocked(shown);
            }
        }

        @Override
        public void playTrustedSound() {
            KeyguardViewMediator.this.playTrustedSound();
@@ -1862,6 +1869,10 @@ public class KeyguardViewMediator extends SystemUI {
    }

    private void adjustStatusBarLocked() {
        adjustStatusBarLocked(false /* forceHideHomeRecentsButtons */);
    }

    private void adjustStatusBarLocked(boolean forceHideHomeRecentsButtons) {
        if (mStatusBarManager == null) {
            mStatusBarManager = (StatusBarManager)
                    mContext.getSystemService(Context.STATUS_BAR_SERVICE);
@@ -1872,19 +1883,14 @@ public class KeyguardViewMediator extends SystemUI {
            // Disable aspects of the system/status/navigation bars that must not be re-enabled by
            // windows that appear on top, ever
            int flags = StatusBarManager.DISABLE_NONE;
            if (mShowing) {
                // Permanently disable components not available when keyguard is enabled
                // (like recents). Temporary enable/disable (e.g. the "back" button) are
                // done in KeyguardHostView.
                flags |= StatusBarManager.DISABLE_RECENT;
            }
            if (isShowingAndNotOccluded()) {
                flags |= StatusBarManager.DISABLE_HOME;
            if (forceHideHomeRecentsButtons || isShowingAndNotOccluded()) {
                flags |= StatusBarManager.DISABLE_HOME | StatusBarManager.DISABLE_RECENT;
            }

            if (DEBUG) {
                Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mOccluded=" + mOccluded
                        + " isSecure=" + isSecure() + " --> flags=0x" + Integer.toHexString(flags));
                        + " isSecure=" + isSecure() + " force=" + forceHideHomeRecentsButtons
                        +  " --> flags=0x" + Integer.toHexString(flags));
            }

            mStatusBarManager.disable(flags);
+41 −8
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASO

import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.KeyguardManager;
import android.app.trust.TrustManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -32,6 +34,7 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask.Status;
import android.os.Handler;
import android.os.SystemClock;
import android.util.ArraySet;
@@ -225,6 +228,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        }
    };

    private TrustManager mTrustManager;
    protected Context mContext;
    protected Handler mHandler;
    TaskStackListenerImpl mTaskStackListener;
@@ -271,6 +275,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        // Initialize the static configuration resources
        mDummyStackView = new TaskStackView(mContext);
        reloadResources();

        mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
    }

    public void onBootCompleted() {
@@ -309,8 +315,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
     * {@link Recents#onBusEvent(ScreenPinningRequestEvent)}.
     */
    public void onStartScreenPinning(Context context, int taskId) {
        SystemUIApplication app = (SystemUIApplication) context;
        StatusBar statusBar = app.getComponent(StatusBar.class);
        final StatusBar statusBar = getStatusBar();
        if (statusBar != null) {
            statusBar.showScreenPinningRequest(taskId, false);
        }
@@ -350,8 +355,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
            if (forceVisible || !ssp.isRecentsActivityVisible(isHomeStackVisible)) {
                ActivityManager.RunningTaskInfo runningTask =
                        ActivityManagerWrapper.getInstance().getRunningTask();
                startRecentsActivity(runningTask, isHomeStackVisible.value || fromHome, animate,
                        growTarget);
                startRecentsActivityAndDismissKeyguardIfNeeded(runningTask,
                        isHomeStackVisible.value || fromHome, animate, growTarget);
            }
        } catch (ActivityNotFoundException e) {
            Log.e(TAG, "Failed to launch RecentsActivity", e);
@@ -442,8 +447,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
                // Otherwise, start the recents activity
                ActivityManager.RunningTaskInfo runningTask =
                        ActivityManagerWrapper.getInstance().getRunningTask();
                startRecentsActivity(runningTask, isHomeStackVisible.value, true /* animate */,
                        growTarget);
                startRecentsActivityAndDismissKeyguardIfNeeded(runningTask,
                        isHomeStackVisible.value, true /* animate */, growTarget);

                // Only close the other system windows if we are actually showing recents
                ActivityManagerWrapper.getInstance().closeSystemWindows(
@@ -462,6 +467,12 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
            return;
        }

        // Skip preloading recents when keyguard is showing
        final StatusBar statusBar = getStatusBar();
        if (statusBar != null && statusBar.isKeyguardShowing()) {
            return;
        }

        // Preload only the raw task list into a new load plan (which will be consumed by the
        // RecentsActivity) only if there is a task to animate to.  Post this to ensure that we
        // don't block the touch feedback on the nav bar button which triggers this.
@@ -942,9 +953,27 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
    }

    /**
     * Shows the recents activity
     * Shows the recents activity after dismissing the keyguard if visible
     */
    protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask,
    protected void startRecentsActivityAndDismissKeyguardIfNeeded(
            final ActivityManager.RunningTaskInfo runningTask, final boolean isHomeStackVisible,
            final boolean animate, final int growTarget) {
        // Preload only if device for current user is unlocked
        final StatusBar statusBar = getStatusBar();
        if (statusBar != null && statusBar.isKeyguardShowing()) {
            statusBar.executeRunnableDismissingKeyguard(() -> {
                    // Flush trustmanager before checking device locked per user when preloading
                    mTrustManager.reportKeyguardShowingChanged();
                    mHandler.post(() -> startRecentsActivity(runningTask, isHomeStackVisible,
                            animate, growTarget));
                }, null,  true /* dismissShade */, false /* afterKeyguardGone */,
                true /* deferred */);
        } else {
            startRecentsActivity(runningTask, isHomeStackVisible, animate, growTarget);
        }
    }

    private void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask,
            boolean isHomeStackVisible, boolean animate, int growTarget) {
        RecentsTaskLoader loader = Recents.getTaskLoader();
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
@@ -1033,6 +1062,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        return result;
    }

    private StatusBar getStatusBar() {
        return ((SystemUIApplication) mContext).getComponent(StatusBar.class);
    }

    /**
     * Starts the recents activity.
     */
+3 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.phone;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Handler;
import android.os.UserHandle;
@@ -122,6 +121,8 @@ public class KeyguardBouncer {

        // Split up the work over multiple frames.
        DejankUtils.postAfterTraversal(mShowRunnable);

        mCallback.onBouncerVisiblityChanged(true /* shown */);
    }

    private final Runnable mShowRunnable = new Runnable() {
@@ -182,6 +183,7 @@ public class KeyguardBouncer {
            mDismissCallbackRegistry.notifyDismissCancelled();
        }
        mFalsingManager.onBouncerHidden();
        mCallback.onBouncerVisiblityChanged(false /* shown */);
        cancelShowRunnable();
        if (mKeyguardView != null) {
            mKeyguardView.cancelDismissAction();