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

Commit c6778954 authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

keyguardGoingAway wallpaperCommand

Trigger a wallpaper command when
ActivityTaskManagerService#keyguardgoingAway is called.

This command is not sent if the user has chosen "None" in the screen
lock settings, (in this case pressing the power button goes to home
directly).

Otherwise, this command is always sent after exiting the keyguard,
at the moment when the launcher appears. In case there is a bouncer,
this command is sent after the bouncer finishes hiding. If not, the
command is sent right after the user swipes to go home from lock screen.

Bug: 216838820
Test: manual (put a log in onCommand and verify it's properly called)
Change-Id: I0eed455c16bb6ec92a3789d89d7197d20ca15ee1
parent 0c7f2a54
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -230,6 +230,16 @@ public class WallpaperManager {
     */
    public static final String COMMAND_WAKING_UP = "android.wallpaper.wakingup";

    /**
     * Command for {@link #sendWallpaperCommand}: reported by System UI when the device keyguard
     * starts going away.
     * This command is triggered by {@link android.app.IActivityTaskManager#keyguardGoingAway(int)}.
     *
     * @hide
     */
    public static final String COMMAND_KEYGUARD_GOING_AWAY =
            "android.wallpaper.keyguardgoingaway";

    /**
     * Command for {@link #sendWallpaperCommand}: reported by System UI when the device is going to
     * sleep. The x and y arguments are a location (possibly very roughly) corresponding to the
+3 −0
Original line number Diff line number Diff line
@@ -33,4 +33,7 @@ public abstract class WallpaperManagerInternal {

    /** Notifies when the screen starts turning on and is not yet visible to the user. */
    public abstract void onScreenTurningOn(int displayId);

    /** Notifies when the keyguard is going away. Sent right after the bouncer is gone. */
    public abstract void onKeyguardGoingAway();
}
+44 −0
Original line number Diff line number Diff line
@@ -1617,6 +1617,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        public void onScreenTurningOn(int displayId) {
            notifyScreenTurningOn(displayId);
        }

        @Override
        public void onKeyguardGoingAway() {
            notifyKeyguardGoingAway();
        }
    }

    void initialize() {
@@ -2654,6 +2659,45 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        }
    }

    /**
     * Propagate a keyguard going away event to the wallpaper engine.
     */
    private void notifyKeyguardGoingAway() {
        synchronized (mLock) {
            if (mIsLockscreenLiveWallpaperEnabled) {
                for (WallpaperData data : getActiveWallpapers()) {
                    data.connection.forEachDisplayConnector(displayConnector -> {
                        if (displayConnector.mEngine != null) {
                            try {
                                displayConnector.mEngine.dispatchWallpaperCommand(
                                        WallpaperManager.COMMAND_KEYGUARD_GOING_AWAY,
                                        -1, -1, -1, new Bundle());
                            } catch (RemoteException e) {
                                Slog.w(TAG, "Failed to notify that the keyguard is going away", e);
                            }
                        }
                    });
                }
                return;
            }

            final WallpaperData data = mWallpaperMap.get(mCurrentUserId);
            if (data != null && data.connection != null) {
                data.connection.forEachDisplayConnector(displayConnector -> {
                    if (displayConnector.mEngine != null) {
                        try {
                            displayConnector.mEngine.dispatchWallpaperCommand(
                                    WallpaperManager.COMMAND_KEYGUARD_GOING_AWAY,
                                    -1, -1, -1, new Bundle());
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        }
    }

    @Override
    public boolean setLockWallpaperCallback(IWallpaperManagerCallback cb) {
        checkPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW);
+10 −0
Original line number Diff line number Diff line
@@ -276,6 +276,7 @@ import com.android.server.sdksandbox.SdkSandboxManagerLocal;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.uri.NeededUriGrants;
import com.android.server.uri.UriGrantsManagerInternal;
import com.android.server.wallpaper.WallpaperManagerInternal;

import java.io.BufferedReader;
import java.io.File;
@@ -365,6 +366,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    private ComponentName mSysUiServiceComponent;
    private PermissionPolicyInternal mPermissionPolicyInternal;
    private StatusBarManagerInternal mStatusBarManagerInternal;
    private WallpaperManagerInternal mWallpaperManagerInternal;
    @VisibleForTesting
    final ActivityTaskManagerInternal mInternal;
    private PowerManagerInternal mPowerManagerInternal;
@@ -3553,6 +3555,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                mRootWindowContainer.forAllDisplays(displayContent -> {
                    mKeyguardController.keyguardGoingAway(displayContent.getDisplayId(), flags);
                });
                getWallpaperManagerInternal().onKeyguardGoingAway();
            }
        } finally {
            Binder.restoreCallingIdentity(token);
@@ -5224,6 +5227,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mStatusBarManagerInternal;
    }

    WallpaperManagerInternal getWallpaperManagerInternal() {
        if (mWallpaperManagerInternal == null) {
            mWallpaperManagerInternal = LocalServices.getService(WallpaperManagerInternal.class);
        }
        return mWallpaperManagerInternal;
    }

    AppWarnings getAppWarningsLocked() {
        return mAppWarnings;
    }