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

Commit 67ae5512 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Keep activities stopped while the lock screen is up."

parents cbba37c6 ff5b158f
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1015,6 +1015,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case SET_LOCK_SCREEN_SHOWN_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            setLockScreenShown(data.readInt() != 0);
            reply.writeNoException();
            return true;
        }

        case SET_DEBUG_APP_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String pn = data.readString();
@@ -2912,6 +2919,17 @@ class ActivityManagerProxy implements IActivityManager
        data.recycle();
        reply.recycle();
    }
    public void setLockScreenShown(boolean shown) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(shown ? 1 : 0);
        mRemote.transact(SET_LOCK_SCREEN_SHOWN_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    public void setDebugApp(
        String packageName, boolean waitForDebugger, boolean persistent)
        throws RemoteException
+3 −1
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ public interface IActivityManager extends IInterface {
    // Note: probably don't want to allow applications access to these.
    public void goingToSleep() throws RemoteException;
    public void wakingUp() throws RemoteException;
    public void setLockScreenShown(boolean shown) throws RemoteException;

    public void unhandledBack() throws RemoteException;
    public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException;
@@ -588,4 +589,5 @@ public interface IActivityManager extends IInterface {
    int GET_CURRENT_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+144;
    int TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+145;
    int NAVIGATE_UP_TO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+146;
    int SET_LOCK_SCREEN_SHOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+147;
}
+12 −0
Original line number Diff line number Diff line
@@ -567,6 +567,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        synchronized (KeyguardViewMediator.this) {
            if (mHidden != isHidden) {
                mHidden = isHidden;
                updateActivityLockScreenState();
                adjustUserActivityLocked();
                adjustStatusBarLocked();
            }
@@ -1162,6 +1163,14 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        }
    }

    private void updateActivityLockScreenState() {
        try {
            ActivityManagerNative.getDefault().setLockScreenShown(
                    mShowing && !mHidden);
        } catch (RemoteException e) {
        }
    }

    /**
     * Handle message sent by {@link #showLocked}.
     * @see #SHOW
@@ -1173,6 +1182,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,

            mKeyguardViewManager.show();
            mShowing = true;
            updateActivityLockScreenState();
            adjustUserActivityLocked();
            adjustStatusBarLocked();
            try {
@@ -1207,6 +1217,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,

            mKeyguardViewManager.hide();
            mShowing = false;
            updateActivityLockScreenState();
            adjustUserActivityLocked();
            adjustStatusBarLocked();
        }
@@ -1324,6 +1335,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            if (DEBUG) Log.d(TAG, "handleVerifyUnlock");
            mKeyguardViewManager.verifyUnlock();
            mShowing = true;
            updateActivityLockScreenState();
        }
    }

+64 −11
Original line number Diff line number Diff line
@@ -696,6 +696,16 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    boolean mSleeping = false;
    /**
     * State of external calls telling us if the device is asleep.
     */
    boolean mWentToSleep = false;
    /**
     * State of external call telling us if the lock screen is shown.
     */
    boolean mLockScreenShown = false;
    /**
     * Set if we are shutting down the system, similar to sleeping.
     */
@@ -6656,10 +6666,18 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    public void goingToSleep() {
        if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires permission "
                    + android.Manifest.permission.DEVICE_POWER);
        }
        synchronized(this) {
            mSleeping = true;
            mWentToSleep = true;
            mWindowManager.setEventDispatching(false);
            if (!mSleeping) {
                mSleeping = true;
                mMainStack.stopIfSleepingLocked();
                // Initialize the wake times of all processes.
@@ -6669,6 +6687,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                mHandler.sendMessageDelayed(nmsg, POWER_CHECK_DELAY);
            }
        }
    }
    public boolean shutdown(int timeout) {
        if (checkCallingPermission(android.Manifest.permission.SHUTDOWN)
@@ -6726,14 +6745,42 @@ public final class ActivityManagerService extends ActivityManagerNative
        Binder.restoreCallingIdentity(origId);
    }
    public void wakingUp() {
        synchronized(this) {
            mWindowManager.setEventDispatching(true);
    private void comeOutOfSleepIfNeededLocked() {
        if (!mWentToSleep && !mLockScreenShown) {
            if (mSleeping) {
                mSleeping = false;
                mMainStack.awakeFromSleepingLocked();
                mMainStack.resumeTopActivityLocked(null);
            }
        }
    }
    public void wakingUp() {
        if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires permission "
                    + android.Manifest.permission.DEVICE_POWER);
        }
        synchronized(this) {
            mWentToSleep = false;
            mWindowManager.setEventDispatching(true);
            comeOutOfSleepIfNeededLocked();
        }
    }
    public void setLockScreenShown(boolean shown) {
        if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires permission "
                    + android.Manifest.permission.DEVICE_POWER);
        }
        synchronized(this) {
            mLockScreenShown = shown;
            comeOutOfSleepIfNeededLocked();
        }
    }
    public void stopAppSwitches() {
        if (checkCallingPermission(android.Manifest.permission.STOP_APP_SWITCHES)
@@ -8815,7 +8862,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
            }
        }
        pw.println("  mSleeping=" + mSleeping + " mShuttingDown=" + mShuttingDown);
        if (mSleeping || mWentToSleep || mLockScreenShown) {
            pw.println("  mSleeping=" + mSleeping + " mWentToSleep=" + mWentToSleep
                    + " mLockScreenShown " + mLockScreenShown);
        }
        if (mShuttingDown) {
            pw.println("  mShuttingDown=" + mShuttingDown);
        }
        if (mDebugApp != null || mOrigDebugApp != null || mDebugTransient
                || mOrigWaitForDebugger) {
            pw.println("  mDebugApp=" + mDebugApp + "/orig=" + mOrigDebugApp