Merge "Expose mirror of wallpaper surface in WindowManagerGlobal." into sc-v2-dev

This commit is contained in:
Brian Isganitis
2021-10-19 23:47:17 +00:00
committed by Android (Google) Code Review
4 changed files with 39 additions and 0 deletions

View File

@@ -346,6 +346,14 @@ interface IWindowManager
*/ */
Bitmap screenshotWallpaper(); Bitmap screenshotWallpaper();
/**
* Mirrors the wallpaper for the given display.
*
* @param displayId ID of the display for the wallpaper.
* @return A SurfaceControl for the parent of the mirrored wallpaper.
*/
SurfaceControl mirrorWallpaperSurface(int displayId);
/** /**
* Registers a wallpaper visibility listener. * Registers a wallpaper visibility listener.
* @return Current visibility. * @return Current visibility.

View File

@@ -18,6 +18,7 @@ package android.view;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentCallbacks2; import android.content.ComponentCallbacks2;
@@ -709,6 +710,16 @@ public final class WindowManagerGlobal {
} }
} }
} }
/** @hide */
@Nullable
public SurfaceControl mirrorWallpaperSurface(int displayId) {
try {
return getWindowManagerService().mirrorWallpaperSurface(displayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
} }
final class WindowLeaked extends AndroidRuntimeException { final class WindowLeaked extends AndroidRuntimeException {

View File

@@ -801,6 +801,18 @@ class WallpaperController {
wallpaperBuffer.getHardwareBuffer(), wallpaperBuffer.getColorSpace()); wallpaperBuffer.getHardwareBuffer(), wallpaperBuffer.getColorSpace());
} }
/**
* Mirrors the visible wallpaper if it's available.
*
* @return A SurfaceControl for the parent of the mirrored wallpaper.
*/
SurfaceControl mirrorWallpaperSurface() {
final WindowState wallpaperWindowState = getTopVisibleWallpaper();
return wallpaperWindowState != null
? SurfaceControl.mirrorSurface(wallpaperWindowState.getSurfaceControl())
: null;
}
WindowState getTopVisibleWallpaper() { WindowState getTopVisibleWallpaper() {
mTmpTopWallpaper = null; mTmpTopWallpaper = null;

View File

@@ -3792,6 +3792,14 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
@Override
public SurfaceControl mirrorWallpaperSurface(int displayId) {
synchronized (mGlobalLock) {
final DisplayContent dc = mRoot.getDisplayContent(displayId);
return dc.mWallpaperController.mirrorWallpaperSurface();
}
}
/** /**
* Takes a snapshot of the screen. In landscape mode this grabs the whole screen. * Takes a snapshot of the screen. In landscape mode this grabs the whole screen.
* In portrait mode, it grabs the upper region of the screen based on the vertical dimension * In portrait mode, it grabs the upper region of the screen based on the vertical dimension