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

Commit f752202b authored by Adam Cohen's avatar Adam Cohen
Browse files

Plumbing to allow keyguard to be shown with user switcher (issue 7175023)

-> Also reduced calls to lockNow, and moved this call in ActivityManagerService

Change-Id: I9ba34ca902f7c0f71fa4ec302104688ca8d11f55
parent 17f36d15
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IRemoteCallback;
import android.os.IRemoteCallback;
import android.view.IApplicationToken;
import android.view.IApplicationToken;
import android.view.IDisplayContentChangeListener;
import android.view.IDisplayContentChangeListener;
@@ -209,9 +210,9 @@ interface IWindowManager
    boolean hasNavigationBar();
    boolean hasNavigationBar();


    /**
    /**
     * Lock the device immediately.
     * Lock the device immediately with the specified options (can be null).
     */
     */
    void lockNow();
    void lockNow(in Bundle options);


    /**
    /**
     * Gets the token for the focused window.
     * Gets the token for the focused window.
+2 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
import android.view.animation.Animation;
import android.view.animation.Animation;
@@ -1096,7 +1097,7 @@ public interface WindowManagerPolicy {
    /**
    /**
     * Lock the device now.
     * Lock the device now.
     */
     */
    public void lockNow();
    public void lockNow(Bundle options);


    /**
    /**
     * Set the last used input method window state. This state is used to make IME transition
     * Set the last used input method window state. This state is used to make IME transition
+21 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -98,6 +99,26 @@ public class LockPatternUtils {
     */
     */
    public static final int MIN_PATTERN_REGISTER_FAIL = MIN_LOCK_PATTERN_SIZE;
    public static final int MIN_PATTERN_REGISTER_FAIL = MIN_LOCK_PATTERN_SIZE;


    /**
     * Tells the keyguard to show the user switcher when the keyguard is created.
     */
    public static final String KEYGUARD_SHOW_USER_SWITCHER = "showuserswitcher";

    /**
     * Tells the keyguard to show the security challenge when the keyguard is created.
     */
    public static final String KEYGUARD_SHOW_SECURITY_CHALLENGE = "showsecuritychallenge";

    /**
     * Options used to lock the device upon user switch.
     */
    public static final Bundle USER_SWITCH_LOCK_OPTIONS = new Bundle();

    static {
        USER_SWITCH_LOCK_OPTIONS.putBoolean(KEYGUARD_SHOW_USER_SWITCHER, true);
        USER_SWITCH_LOCK_OPTIONS.putBoolean(KEYGUARD_SHOW_SECURITY_CHALLENGE, true);
    }

    /**
    /**
     * The bit in LOCK_BIOMETRIC_WEAK_FLAGS to be used to indicate whether liveliness should
     * The bit in LOCK_BIOMETRIC_WEAK_FLAGS to be used to indicate whether liveliness should
     * be used
     * be used
+19 −4
Original line number Original line Diff line number Diff line
@@ -4047,21 +4047,36 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        }
    }
    }


    Runnable mScreenLockTimeout = new Runnable() {
    class ScreenLockTimeout implements Runnable {
        Bundle options;

        @Override
        public void run() {
        public void run() {
            synchronized (this) {
            synchronized (this) {
                if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard");
                if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard");
                if (mKeyguardMediator != null) {
                if (mKeyguardMediator != null) {
                    mKeyguardMediator.doKeyguardTimeout();
                    mKeyguardMediator.doKeyguardTimeout(options);
                }
                }
                mLockScreenTimerActive = false;
                mLockScreenTimerActive = false;
                options = null;
            }
        }

        public void setLockOptions(Bundle options) {
            this.options = options;
        }
        }
    }
    }
    };


    public void lockNow() {
    ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();

    public void lockNow(Bundle options) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
        mHandler.removeCallbacks(mScreenLockTimeout);
        mHandler.removeCallbacks(mScreenLockTimeout);
        if (options != null) {
            // In case multiple calls are made to lockNow, we don't wipe out the options
            // until the runnable actually executes.
            mScreenLockTimeout.setLockOptions(options);
        }
        mHandler.post(mScreenLockTimeout);
        mHandler.post(mScreenLockTimeout);
    }
    }


+0 −6
Original line number Original line Diff line number Diff line
@@ -119,12 +119,6 @@ public class KeyguardMultiUserSelectorView extends FrameLayout implements View.O
                public void run() {
                public void run() {
                    try {
                    try {
                        ActivityManagerNative.getDefault().switchUser(avatar.getUserInfo().id);
                        ActivityManagerNative.getDefault().switchUser(avatar.getUserInfo().id);
                        WindowManagerGlobal.getWindowManagerService().lockNow();
                        // Set the new active user, and make it appear active
                        avatar.resetPressedState();
                        mCallback.showSecurityView();
                        mActiveUserAvatar = avatar;
                        mActiveUserAvatar.setActive(true, false, 0, null);
                    } catch (RemoteException re) {
                    } catch (RemoteException re) {
                        Log.e(TAG, "Couldn't switch user " + re);
                        Log.e(TAG, "Couldn't switch user " + re);
                    }
                    }
Loading