Merge "keyguardGoingAway wallpaperCommand" into udc-dev

This commit is contained in:
Lucas Dupin
2023-05-04 18:35:30 +00:00
committed by Android (Google) Code Review
4 changed files with 67 additions and 0 deletions

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);
@@ -5232,6 +5235,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;
}