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

Commit e4f7a8e5 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Remove meaningless parameter in IActivityTaskManager#setLockScreenShown"

parents 01085c4d 177261f5
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -277,12 +277,8 @@ interface IActivityTaskManager {
     *
     * @param showingKeyguard True if the keyguard is showing, false otherwise.
     * @param showingAod True if AOD is showing, false otherwise.
     * @param secondaryDisplaysShowing The displayId's of the secondary displays on which the
     * keyguard is showing, or {@code null} if there is no such display. Only meaningful if showing
     * is {@code true}.
     */
    void setLockScreenShown(boolean showingKeyguard, boolean showingAod,
            in int[] secondaryDisplaysShowing);
    void setLockScreenShown(boolean showingKeyguard, boolean showingAod);
    Bundle getAssistContextExtras(int requestType);
    boolean launchAssistIntent(in Intent intent, int requestType, in String hint, int userHandle,
            in Bundle args);
+9 −44
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.keyguard;

import static android.view.Display.DEFAULT_DISPLAY;

import android.annotation.Nullable;
import android.app.Presentation;
import android.content.Context;
import android.graphics.Point;
@@ -32,15 +31,11 @@ import android.view.DisplayInfo;
import android.view.View;
import android.view.WindowManager;

import java.util.function.BooleanSupplier;

// TODO(multi-display): Support multiple external displays
public class KeyguardDisplayManager {
    protected static final String TAG = "KeyguardDisplayManager";
    private static boolean DEBUG = KeyguardConstants.DEBUG;

    private final ViewMediatorCallback mCallback;

    private final MediaRouter mMediaRouter;
    private final DisplayManager mDisplayService;
    private final Context mContext;
@@ -57,7 +52,7 @@ public class KeyguardDisplayManager {
        public void onDisplayAdded(int displayId) {
            final Display display = mDisplayService.getDisplay(displayId);
            if (mShowing) {
                notifyIfChanged(() -> showPresentation(display));
                showPresentation(display);
            }
        }

@@ -76,13 +71,12 @@ public class KeyguardDisplayManager {

        @Override
        public void onDisplayRemoved(int displayId) {
            notifyIfChanged(() -> hidePresentation(displayId));
            hidePresentation(displayId);
        }
    };

    public KeyguardDisplayManager(Context context, ViewMediatorCallback callback) {
    public KeyguardDisplayManager(Context context) {
        mContext = context;
        mCallback = callback;
        mMediaRouter = mContext.getSystemService(MediaRouter.class);
        mDisplayService = mContext.getSystemService(DisplayManager.class);
        mDisplayService.registerDisplayListener(mDisplayListener, null /* handler */);
@@ -138,42 +132,13 @@ public class KeyguardDisplayManager {

    /**
     * @param displayId The id of the display to hide the presentation off.
     * @return {@code true} if the a presentation was removed.
     *         {@code false} if the presentation was not added before.
     */
    private boolean hidePresentation(int displayId) {
    private void hidePresentation(int displayId) {
        final Presentation presentation = mPresentations.get(displayId);
        if (presentation != null) {
            presentation.dismiss();
            mPresentations.remove(displayId);
            return true;
        }
        return false;
    }

    private void notifyIfChanged(BooleanSupplier updateMethod) {
        if (updateMethod.getAsBoolean()) {
            final int[] displayList = getPresentationDisplayIds();
            mCallback.onSecondaryDisplayShowingChanged(displayList);
        }
    }

    /**
     * @return An array of displayId's on which a {@link KeyguardPresentation} is showing on.
     */
    @Nullable
    private int[] getPresentationDisplayIds() {
        final int size = mPresentations.size();
        if (size == 0) return null;

        final int[] displayIds = new int[size];
        for (int i = mPresentations.size() - 1; i >= 0; i--) {
            final Presentation presentation = mPresentations.valueAt(i);
            if (presentation != null) {
                displayIds[i] = presentation.getDisplay().getDisplayId();
            }
        }
        return displayIds;
    }

    public void show() {
@@ -181,7 +146,7 @@ public class KeyguardDisplayManager {
            if (DEBUG) Log.v(TAG, "show");
            mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY,
                    mMediaRouterCallback, MediaRouter.CALLBACK_FLAG_PASSIVE_DISCOVERY);
            notifyIfChanged(() -> updateDisplays(true /* showing */));
            updateDisplays(true /* showing */);
        }
        mShowing = true;
    }
@@ -190,7 +155,7 @@ public class KeyguardDisplayManager {
        if (mShowing) {
            if (DEBUG) Log.v(TAG, "hide");
            mMediaRouter.removeCallback(mMediaRouterCallback);
            notifyIfChanged(() -> updateDisplays(false /* showing */));
            updateDisplays(false /* showing */);
        }
        mShowing = false;
    }
@@ -200,19 +165,19 @@ public class KeyguardDisplayManager {
        @Override
        public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
            if (DEBUG) Log.d(TAG, "onRouteSelected: type=" + type + ", info=" + info);
            notifyIfChanged(() -> updateDisplays(mShowing));
            updateDisplays(mShowing);
        }

        @Override
        public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
            if (DEBUG) Log.d(TAG, "onRouteUnselected: type=" + type + ", info=" + info);
            notifyIfChanged(() -> updateDisplays(mShowing));
            updateDisplays(mShowing);
        }

        @Override
        public void onRoutePresentationDisplayChanged(MediaRouter router, RouteInfo info) {
            if (DEBUG) Log.d(TAG, "onRoutePresentationDisplayChanged: info=" + info);
            notifyIfChanged(() -> updateDisplays(mShowing));
            updateDisplays(mShowing);
        }
    };

+0 −5
Original line number Diff line number Diff line
@@ -95,11 +95,6 @@ public interface ViewMediatorCallback {
     */
    int getBouncerPromptReason();

    /**
     * Invoked when the secondary displays showing a keyguard window changes.
     */
    void onSecondaryDisplayShowingChanged(int[] displayId);

    /**
     * Consumes a message that was enqueued to be displayed on the next time the bouncer shows up.
     * @return Message that should be displayed above the challenge.
+10 −29
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import static com.android.internal.telephony.IccCardConstants.State.ABSENT;
import static com.android.internal.telephony.IccCardConstants.State.PIN_REQUIRED;
import static com.android.internal.telephony.IccCardConstants.State.PUK_REQUIRED;
import static com.android.internal.telephony.IccCardConstants.State.READY;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
@@ -95,7 +94,6 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * Mediates requests related to the keyguard.  This includes queries about the
@@ -247,9 +245,6 @@ public class KeyguardViewMediator extends SystemUI {
    // AOD is enabled and status bar is in AOD state.
    private boolean mAodShowing;

    // display ids of the external display on which we have put a keyguard window
    private int[] mSecondaryDisplaysShowing;

    /** Cached value of #isInputRestricted */
    private boolean mInputRestricted;

@@ -687,13 +682,6 @@ public class KeyguardViewMediator extends SystemUI {
            mCustomMessage = null;
            return message;
        }

        @Override
        public void onSecondaryDisplayShowingChanged(int[] displayIds) {
            synchronized (KeyguardViewMediator.this) {
                setShowingLocked(mShowing, mAodShowing, displayIds, false);
            }
        }
    };

    public void userActivity() {
@@ -722,7 +710,7 @@ public class KeyguardViewMediator extends SystemUI {
        mContext.registerReceiver(mDelayedLockBroadcastReceiver, delayedActionFilter,
                SYSTEMUI_PERMISSION, null /* scheduler */);

        mKeyguardDisplayManager = new KeyguardDisplayManager(mContext, mViewMediatorCallback);
        mKeyguardDisplayManager = new KeyguardDisplayManager(mContext);

        mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);

@@ -738,10 +726,10 @@ public class KeyguardViewMediator extends SystemUI {
            setShowingLocked(!shouldWaitForProvisioning()
                    && !mLockPatternUtils.isLockScreenDisabled(
                            KeyguardUpdateMonitor.getCurrentUser()),
                    mAodShowing, mSecondaryDisplaysShowing, true /* forceCallbacks */);
                    mAodShowing, true /* forceCallbacks */);
        } else {
            // The system's keyguard is disabled or missing.
            setShowingLocked(false, mAodShowing, mSecondaryDisplaysShowing, true);
            setShowingLocked(false, mAodShowing, true);
        }

        mStatusBarKeyguardViewManager =
@@ -1764,12 +1752,10 @@ public class KeyguardViewMediator extends SystemUI {
        playSound(mTrustedSoundId);
    }

    private void updateActivityLockScreenState(boolean showing, boolean aodShowing,
            int[] secondaryDisplaysShowing) {
    private void updateActivityLockScreenState(boolean showing, boolean aodShowing) {
        mUiOffloadThread.submit(() -> {
            try {
                ActivityTaskManager.getService().setLockScreenShown(showing, aodShowing,
                        secondaryDisplaysShowing);
                ActivityTaskManager.getService().setLockScreenShown(showing, aodShowing);
            } catch (RemoteException e) {
            }
        });
@@ -1892,8 +1878,7 @@ public class KeyguardViewMediator extends SystemUI {

            if (!mHiding) {
                // Tell ActivityManager that we canceled the keyguardExitAnimation.
                setShowingLocked(mShowing, mAodShowing, mSecondaryDisplaysShowing,
                        true /* force */);
                setShowingLocked(mShowing, mAodShowing, true /* force */);
                return;
            }
            mHiding = false;
@@ -2163,23 +2148,19 @@ public class KeyguardViewMediator extends SystemUI {
    }

    private void setShowingLocked(boolean showing, boolean aodShowing) {
        setShowingLocked(showing, aodShowing, mSecondaryDisplaysShowing,
                false /* forceCallbacks */);
        setShowingLocked(showing, aodShowing, false /* forceCallbacks */);
    }

    private void setShowingLocked(boolean showing, boolean aodShowing,
            int[] secondaryDisplaysShowing, boolean forceCallbacks) {
    private void setShowingLocked(boolean showing, boolean aodShowing, boolean forceCallbacks) {
        final boolean notifyDefaultDisplayCallbacks = showing != mShowing
                || aodShowing != mAodShowing || forceCallbacks;
        if (notifyDefaultDisplayCallbacks
                || !Arrays.equals(secondaryDisplaysShowing, mSecondaryDisplaysShowing)) {
        if (notifyDefaultDisplayCallbacks) {
            mShowing = showing;
            mAodShowing = aodShowing;
            mSecondaryDisplaysShowing = secondaryDisplaysShowing;
            if (notifyDefaultDisplayCallbacks) {
                notifyDefaultDisplayCallbacks(showing);
            }
            updateActivityLockScreenState(showing, aodShowing, secondaryDisplaysShowing);
            updateActivityLockScreenState(showing, aodShowing);
        }
    }

+1 −4
Original line number Diff line number Diff line
@@ -209,11 +209,8 @@ public class KeyguardServiceDelegate {
            mKeyguardState.reset();
            mHandler.post(() -> {
                try {
                    // There are no longer any keyguard windows on secondary displays, so pass
                    // {@code null}. All that means is that showWhenLocked activities on
                    // external displays now get to show.
                    ActivityTaskManager.getService().setLockScreenShown(true /* keyguardShowing */,
                            false /* aodShowing */, null /* secondaryDisplaysShowing */);
                            false /* aodShowing */);
                } catch (RemoteException e) {
                    // Local call.
                }
Loading