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

Commit 107dabed authored by Issei Suzuki's avatar Issei Suzuki Committed by Android (Google) Code Review
Browse files

Merge "Add ActivityOption to remove keyguard when an activity is launched." into tm-qpr-dev

parents 35201c97 1df71d4e
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import static android.Manifest.permission.CONTROL_KEYGUARD;
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
@@ -362,9 +363,8 @@ public class ActivityOptions extends ComponentOptions {
    private static final String KEY_LAUNCH_INTO_PIP_PARAMS =
            "android.activity.launchIntoPipParams";

    /** See {@link #setDismissKeyguardIfInsecure()}. */
    private static final String KEY_DISMISS_KEYGUARD_IF_INSECURE =
            "android.activity.dismissKeyguardIfInsecure";
    /** See {@link #setDismissKeyguard()}. */
    private static final String KEY_DISMISS_KEYGUARD = "android.activity.dismissKeyguard";

    private static final String KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE =
            "android.activity.ignorePendingIntentCreatorForegroundState";
@@ -465,7 +465,7 @@ public class ActivityOptions extends ComponentOptions {
    private boolean mLaunchedFromBubble;
    private boolean mTransientLaunch;
    private PictureInPictureParams mLaunchIntoPipParams;
    private boolean mDismissKeyguardIfInsecure;
    private boolean mDismissKeyguard;
    private boolean mIgnorePendingIntentCreatorForegroundState;

    /**
@@ -1270,7 +1270,7 @@ public class ActivityOptions extends ComponentOptions {
        mLaunchIntoPipParams = opts.getParcelable(KEY_LAUNCH_INTO_PIP_PARAMS);
        mIsEligibleForLegacyPermissionPrompt =
                opts.getBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE);
        mDismissKeyguardIfInsecure = opts.getBoolean(KEY_DISMISS_KEYGUARD_IF_INSECURE);
        mDismissKeyguard = opts.getBoolean(KEY_DISMISS_KEYGUARD);
        mIgnorePendingIntentCreatorForegroundState = opts.getBoolean(
                KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE);
    }
@@ -1869,24 +1869,24 @@ public class ActivityOptions extends ComponentOptions {
    }

    /**
     * Sets whether the insecure keyguard should go away when this activity launches. In case the
     * keyguard is secure, this option will be ignored.
     * Sets whether the keyguard should go away when this activity launches.
     *
     * @see Activity#setShowWhenLocked(boolean)
     * @see android.R.attr#showWhenLocked
     * @hide
     */
    public void setDismissKeyguardIfInsecure() {
        mDismissKeyguardIfInsecure = true;
    @RequiresPermission(CONTROL_KEYGUARD)
    public void setDismissKeyguard() {
        mDismissKeyguard = true;
    }

    /**
     * @see #setDismissKeyguardIfInsecure()
     * @see #setDismissKeyguard()
     * @return whether the insecure keyguard should go away when the activity launches.
     * @hide
     */
    public boolean getDismissKeyguardIfInsecure() {
        return mDismissKeyguardIfInsecure;
    public boolean getDismissKeyguard() {
        return mDismissKeyguard;
    }

    /**
@@ -2167,8 +2167,8 @@ public class ActivityOptions extends ComponentOptions {
            b.putBoolean(KEY_LEGACY_PERMISSION_PROMPT_ELIGIBLE,
                    mIsEligibleForLegacyPermissionPrompt);
        }
        if (mDismissKeyguardIfInsecure) {
            b.putBoolean(KEY_DISMISS_KEYGUARD_IF_INSECURE, mDismissKeyguardIfInsecure);
        if (mDismissKeyguard) {
            b.putBoolean(KEY_DISMISS_KEYGUARD, mDismissKeyguard);
        }
        if (mIgnorePendingIntentCreatorForegroundState) {
            b.putBoolean(KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE,
+5 −5
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
    private boolean mAsync;
    private BroadcastOptions mBroadcastOptions;
    private boolean mShowSplashScreen;
    private boolean mDismissKeyguardIfInsecure;
    private boolean mDismissKeyguard;

    final boolean mDumping;

@@ -442,8 +442,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
                    mAsync = true;
                } else if (opt.equals("--splashscreen-show-icon")) {
                    mShowSplashScreen = true;
                } else if (opt.equals("--dismiss-keyguard-if-insecure")) {
                    mDismissKeyguardIfInsecure = true;
                } else if (opt.equals("--dismiss-keyguard")) {
                    mDismissKeyguard = true;
                } else {
                    return false;
                }
@@ -588,11 +588,11 @@ final class ActivityManagerShellCommand extends ShellCommand {
                }
                options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON);
            }
            if (mDismissKeyguardIfInsecure) {
            if (mDismissKeyguard) {
                if (options == null) {
                    options = ActivityOptions.makeBasic();
                }
                options.setDismissKeyguardIfInsecure();
                options.setDismissKeyguard();
            }
            if (mWaitOption) {
                result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, null, intent,
+2 −2
Original line number Diff line number Diff line
@@ -873,7 +873,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    boolean mEnteringAnimation;
    boolean mOverrideTaskTransition;
    boolean mDismissKeyguardIfInsecure;
    boolean mDismissKeyguard;

    boolean mAppStopped;
    // A hint to override the window specified rotation animation, or -1 to use the window specified
@@ -1987,7 +1987,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }

            mOverrideTaskTransition = options.getOverrideTaskTransition();
            mDismissKeyguardIfInsecure = options.getDismissKeyguardIfInsecure();
            mDismissKeyguard = options.getDismissKeyguard();
        }

        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
+1 −3
Original line number Diff line number Diff line
@@ -621,9 +621,7 @@ class KeyguardController {
                    mTopTurnScreenOnActivity = top;
                }

                final boolean isKeyguardSecure = controller.mWindowManager.isKeyguardSecure(
                        controller.mService.getCurrentUserId());
                if (top.mDismissKeyguardIfInsecure && mKeyguardShowing && !isKeyguardSecure) {
                if (top.mDismissKeyguard && mKeyguardShowing) {
                    mKeyguardGoingAway = true;
                } else if (top.canShowWhenLocked()) {
                    mTopOccludesActivity = top;
+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.Manifest.permission.CONTROL_KEYGUARD;
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.Manifest.permission.STATUS_BAR_SERVICE;
@@ -297,6 +298,20 @@ public class SafeActivityOptions {
            }
        }

        // Check if the caller is allowed to dismiss keyguard.
        final boolean dismissKeyguard = options.getDismissKeyguard();
        if (aInfo != null && dismissKeyguard) {
            final int controlKeyguardPerm = ActivityTaskManagerService.checkPermission(
                    CONTROL_KEYGUARD, callingPid, callingUid);
            if (controlKeyguardPerm != PERMISSION_GRANTED) {
                final String msg = "Permission Denial: starting " + getIntentString(intent)
                        + " from " + callerApp + " (pid=" + callingPid
                        + ", uid=" + callingUid + ") with dismissKeyguard=true";
                Slog.w(TAG, msg);
                throw new SecurityException(msg);
            }
        }

        // Check permission for remote animations
        final RemoteAnimationAdapter adapter = options.getRemoteAnimationAdapter();
        if (adapter != null && supervisor.mService.checkPermission(