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

Commit 067e5f68 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add new wallpaper features for insets and offsets.

Issue #17394151: WallpaperService / Engines need to get notified
of WindowInsets

Issue #17394203 Wallpapers need a system API to be shifted in order
to support burn in protection

Adds a new API on WallpaperManager to set additional offsets to
make wallpapers extend beyond the display size.

Insets are now reported to wallpapers, to use as they may.  This
includes information about the above offsets, so they can place
their content within the visible area.  And to help with this, also
expose the stable offsets APIs in WindowInsets which is also very
useful information for the wallpaper.

Another new API on WallpaperManager to set a raw offset to apply
to the wallpaper window, forcing it to move on the screen regardless
of what the wallpaper is drawing.

Fix wallpapers when used with overscan enabled, so they still extend
out across the entire screen.  Conveniently, the above new window
insets information is very useful for this case as well!

And a new wallpaper test app for all this stuff.

Change-Id: I287ee36581283dd34607609fcd3170d99d120d8e
parent 8232d822
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -27275,6 +27275,7 @@ package android.service.wallpaper {
    method public android.view.SurfaceHolder getSurfaceHolder();
    method public boolean isPreview();
    method public boolean isVisible();
    method public void onApplyWindowInsets(android.view.WindowInsets);
    method public android.os.Bundle onCommand(java.lang.String, int, int, int, android.os.Bundle, boolean);
    method public void onCreate(android.view.SurfaceHolder);
    method public void onDesiredSizeChanged(int, int);
@@ -34989,12 +34990,18 @@ package android.view {
  public final class WindowInsets {
    ctor public WindowInsets(android.view.WindowInsets);
    method public android.view.WindowInsets consumeStableInsets();
    method public android.view.WindowInsets consumeSystemWindowInsets();
    method public int getStableInsetBottom();
    method public int getStableInsetLeft();
    method public int getStableInsetRight();
    method public int getStableInsetTop();
    method public int getSystemWindowInsetBottom();
    method public int getSystemWindowInsetLeft();
    method public int getSystemWindowInsetRight();
    method public int getSystemWindowInsetTop();
    method public boolean hasInsets();
    method public boolean hasStableInsets();
    method public boolean hasSystemWindowInsets();
    method public boolean isConsumed();
    method public boolean isRound();
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.graphics.Rect;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.app.IWallpaperManagerCallback;
@@ -72,6 +73,11 @@ interface IWallpaperManager {
     */
    int getHeightHint();

    /**
     * Sets extra padding that we would like the wallpaper to have outside of the display.
     */
    void setDisplayPadding(in Rect padding);

    /**
     * Returns the name of the wallpaper. Private API.
     */
+43 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -950,6 +951,48 @@ public class WallpaperManager {
        }
    }

    /**
     * Specify extra padding that the wallpaper should have outside of the display.
     * That is, the given padding supplies additional pixels the wallpaper should extend
     * outside of the display itself.
     * @param padding The number of pixels the wallpaper should extend beyond the display,
     * on its left, top, right, and bottom sides.
     * @hide
     */
    @SystemApi
    public void setDisplayPadding(Rect padding) {
        try {
            if (sGlobals.mService == null) {
                Log.w(TAG, "WallpaperService not running");
            } else {
                sGlobals.mService.setDisplayPadding(padding);
            }
        } catch (RemoteException e) {
            // Ignore
        }
    }

    /**
     * Apply a raw offset to the wallpaper window.  Should only be used in
     * combination with {@link #setDisplayPadding(android.graphics.Rect)} when you
     * have ensured that the wallpaper will extend outside of the display area so that
     * it can be moved without leaving part of the display uncovered.
     * @param x The offset, in pixels, to apply to the left edge.
     * @param y The offset, in pixels, to apply to the top edge.
     * @hide
     */
    @SystemApi
    public void setDisplayOffset(IBinder windowToken, int x, int y) {
        try {
            //Log.v(TAG, "Sending new wallpaper display offsets from app...");
            WindowManagerGlobal.getWindowSession().setWallpaperDisplayOffset(
                    windowToken, x, y);
            //Log.v(TAG, "...app returning after sending display offset!");
        } catch (RemoteException e) {
            // Ignore.
        }
    }

    /**
     * Set the position of the current wallpaper within any larger space, when
     * that wallpaper is visible behind the given window.  The X and Y offsets
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.wallpaper;

import android.graphics.Rect;
import android.view.MotionEvent;
import android.os.Bundle;

@@ -24,6 +25,7 @@ import android.os.Bundle;
 */
oneway interface IWallpaperEngine {
    void setDesiredSize(int width, int height);
    void setDisplayPadding(in Rect padding);
    void setVisibility(boolean visible);
    void dispatchPointer(in MotionEvent event);
    void dispatchWallpaperCommand(String action, int x, int y,
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.wallpaper;

import android.graphics.Rect;
import android.service.wallpaper.IWallpaperConnection;

/**
@@ -24,5 +25,5 @@ import android.service.wallpaper.IWallpaperConnection;
oneway interface IWallpaperService {
    void attach(IWallpaperConnection connection,
    		IBinder windowToken, int windowType, boolean isPreview,
    		int reqWidth, int reqHeight);
    		int reqWidth, int reqHeight, in Rect padding);
}
Loading