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

Commit fe762344 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

The big keyguard transition refactor (1/n)

The heart of this change are two things:
1) Instead of using the force hide mechanism to hide windows behind
Keyguard, we actually make the activities invisible in activity manager.
2) When Keyguard is going away, we change the visibilities in activity
manager and run an app transition.

At the very core we move the responsibility of hiding activities to
ActivityStack, which checks whether Keyguard is showing, and then
hides all non-show-when-locked activities. For that, we need to check
whether any window of an activity has SHOW_WHEN_LOCKED set. We
introduce a callback from WM -> AM in case these Keyguard flags have
changed.

Furthermore, we decide whether to occlude Keyguard in KeyguardController,
which just checks whether the top activity has SHOW_WHEN_LOCKED set. When
this state changes, we prepare an occlude/unocclude app transition, and
in PWM we just inform the Keyguard about the animation so SysUI can play
along this animations in a mostly synchronized manner.

Since we now use an app transition when unlocking the phone, we get
lockscreen launch animations for free - window manager automatically
waits until the activity is drawn, or directly executes the transition
if there is nothing to animate. Thus, we can remove all the infrastructure
around "waitingForActivityDrawn".

The logic to show/hide non-app windows is moved to policy, and we add the
ability to run animations on non-app windows when executing an app
transition.

Test:
1) runtest frameworks-services -c com.android.server.wm.AppTransitionTests
2) Manually test unlocking Keyguard:
2a) Without security
2b) With security
2c) With security but trusted
2d) Portrait while activity behind is in landscape
3) Test launching things from Keyguard
3a) Without security
3b) With security
3c) Launch camera without security
3d) Launch camera with security
3e) Launch camera with securtiy and trusted
3f) Launch voice affordance
4) Set no notifications on lockscreen, drag down, make sure you get
the correct animation
5) Test clicking "emergency" on bouncer
5b) Test "Emergency info" on emergency dialer
5c) Test clicking edit button on emergency info, should show pattern on
Keyguard

Bug: 32057734
Change-Id: Icada03cca74d6a612c1f988845f4d4f601087558
parent 0863156e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.IIntentSender;
import android.content.Intent;
@@ -179,4 +180,13 @@ public abstract class ActivityManagerInternal {
     * (-1).
     */
    public abstract int getUidProcessState(int uid);

    /**
     * Called when Keyguard flags might have changed.
     *
     * @param callback Callback to run after activity visibilities have been reevaluated. This can
     *                 be used from window manager so that when the callback is called, it's
     *                 guaranteed that all apps have their visibility updated accordingly.
     */
    public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback);
}
+2 −21
Original line number Diff line number Diff line
@@ -1555,8 +1555,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        case SET_LOCK_SCREEN_SHOWN_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final boolean showing = data.readInt() != 0;
            final boolean occluded = data.readInt() != 0;
            setLockScreenShown(showing, occluded);
            setLockScreenShown(showing);
            reply.writeNoException();
            return true;
        }
@@ -2337,13 +2336,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            keyguardWaitingForActivityDrawn();
            reply.writeNoException();
            return true;
        }

        case KEYGUARD_GOING_AWAY_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            keyguardGoingAway(data.readInt());
@@ -5035,13 +5027,12 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
        return pfd;
    }
    public void setLockScreenShown(boolean showing, boolean occluded) throws RemoteException
    public void setLockScreenShown(boolean showing) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(showing ? 1 : 0);
        data.writeInt(occluded ? 1 : 0);
        mRemote.transact(SET_LOCK_SCREEN_SHOWN_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
@@ -6060,16 +6051,6 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void keyguardWaitingForActivityDrawn() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        mRemote.transact(KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    public void keyguardGoingAway(int flags)
            throws RemoteException {
        Parcel data = Parcel.obtain();
+1 −5
Original line number Diff line number Diff line
@@ -357,8 +357,7 @@ public interface IActivityManager extends IInterface {
    public void killPackageDependents(final String packageName, int userId) throws RemoteException;
    public void forceStopPackage(final String packageName, int userId) throws RemoteException;

    // Note: probably don't want to allow applications access to these.
    public void setLockScreenShown(boolean showing, boolean occluded) throws RemoteException;
    public void setLockScreenShown(boolean showing) throws RemoteException;

    public void unhandledBack() throws RemoteException;
    public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException;
@@ -518,8 +517,6 @@ public interface IActivityManager extends IInterface {

    public void showBootMessage(CharSequence msg, boolean always) throws RemoteException;

    public void keyguardWaitingForActivityDrawn() throws RemoteException;

    /**
     * Notify the system that the keyguard is going away.
     *
@@ -1017,7 +1014,6 @@ public interface IActivityManager extends IInterface {
    int NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+228;
    int START_ACTIVITY_FROM_RECENTS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 229;
    int NOTIFY_ENTER_ANIMATION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+230;
    int KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+231;
    int START_ACTIVITY_AS_CALLER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+232;
    int ADD_APP_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+233;
    int GET_APP_TASK_THUMBNAIL_SIZE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+234;
+0 −10
Original line number Diff line number Diff line
@@ -213,16 +213,6 @@ interface IWindowManager
    void dismissKeyguard();
    void keyguardGoingAway(int flags);

    /**
     * Called to tell WindowManager whether the keyguard is animating in. While this property
     * is true, WindowManager won't assume that the keyguard is opaque (eg. WindowAnimator won't
     * force-hide windows just because keyguard is visible and WallpaperController won't occlude
     * app windows with the system wallpaper.
     *
     * <p>Requires CONTROL_KEYGUARD permission</p>
     */
    void setKeyguardAnimatingIn(boolean animating);

    // Requires INTERACT_ACROSS_USERS_FULL permission
    void setSwitchingUser(boolean switching);

+14 −3
Original line number Diff line number Diff line
@@ -99,19 +99,30 @@ public abstract class WindowManagerInternal {

        /**
         * Called when a pending app transition gets cancelled.
         *
         * @param transit transition type indicating what kind of transition got cancelled
         */
        public void onAppTransitionCancelledLocked() {}
        public void onAppTransitionCancelledLocked(int transit) {}

        /**
         * Called when an app transition gets started
         *
         * @param transit transition type indicating what kind of transition gets run, must be one
         *                of AppTransition.TRANSIT_* values
         * @param openToken the token for the opening app
         * @param closeToken the token for the closing app
         * @param openAnimation the animation for the opening app
         * @param closeAnimation the animation for the closing app
         */
        public void onAppTransitionStartingLocked(IBinder openToken, IBinder closeToken,
                Animation openAnimation, Animation closeAnimation) {}
         *
         * @return Return any bit set of {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_LAYOUT},
         * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_CONFIG},
         * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_WALLPAPER},
         * or {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_ANIM}.
         */
        public int onAppTransitionStartingLocked(int transit, IBinder openToken, IBinder closeToken,
                Animation openAnimation, Animation closeAnimation) {
            return 0;
        }

        /**
         * Called when an app transition is finished running.
Loading