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

Commit 81e10a70 authored by wilsonshih's avatar wilsonshih
Browse files

Support wallpaper on secondary displays.(3/N)

The launchers which running on secondary displays can set the desired
wallpaper dimensions and paddings on correct display.
Preset reasonable wallpaper size for newly added displays.
Add some error handling between the binder calls.

Note: We still only save/load wallpaper info for default display, as most of
time secondary displays are not fixed.

Bug: 115486823
Test: atest WallpaperManagerTest
Test: atest WmTests
Test: atest ActivityManagerMultiDisplayTests

Change-Id: Ifd1a96fa185f2d75825c6fe8d3db69466b31c5c8
parent 96a62ff0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -189,10 +189,10 @@ Landroid/app/IUiModeManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/app
Landroid/app/IUiModeManager;->disableCarMode(I)V
Landroid/app/IUserSwitchObserver$Stub;-><init>()V
Landroid/app/IWallpaperManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/app/IWallpaperManager;
Landroid/app/IWallpaperManager;->getHeightHint()I
Landroid/app/IWallpaperManager;->getHeightHint(I)I
Landroid/app/IWallpaperManager;->getWallpaper(Ljava/lang/String;Landroid/app/IWallpaperManagerCallback;ILandroid/os/Bundle;I)Landroid/os/ParcelFileDescriptor;
Landroid/app/IWallpaperManager;->getWallpaperInfo(I)Landroid/app/WallpaperInfo;
Landroid/app/IWallpaperManager;->getWidthHint()I
Landroid/app/IWallpaperManager;->getWidthHint(I)I
Landroid/app/IWallpaperManager;->hasNamedWallpaper(Ljava/lang/String;)Z
Landroid/app/IWallpaperManager;->setWallpaperComponent(Landroid/content/ComponentName;)V
Landroid/app/IWallpaperManagerCallback$Stub;-><init>()V
+7 −7
Original line number Diff line number Diff line
@@ -87,24 +87,24 @@ interface IWallpaperManager {

    /**
     * Sets the dimension hint for the wallpaper. These hints indicate the desired
     * minimum width and height for the wallpaper.
     * minimum width and height for the wallpaper in a particular display.
     */
    void setDimensionHints(in int width, in int height, in String callingPackage);
    void setDimensionHints(in int width, in int height, in String callingPackage, int displayId);

    /**
     * Returns the desired minimum width for the wallpaper.
     * Returns the desired minimum width for the wallpaper in a particular display.
     */
    int getWidthHint();
    int getWidthHint(int displayId);

    /**
     * Returns the desired minimum height for the wallpaper.
     * Returns the desired minimum height for the wallpaper in a particular display.
     */
    int getHeightHint();
    int getHeightHint(int displayId);

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

    /**
     * Returns the name of the wallpaper. Private API.
+5 −4
Original line number Diff line number Diff line
@@ -1485,7 +1485,7 @@ public class WallpaperManager {
            throw new RuntimeException(new DeadSystemException());
        }
        try {
            return sGlobals.mService.getWidthHint();
            return sGlobals.mService.getWidthHint(mContext.getDisplayId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1511,7 +1511,7 @@ public class WallpaperManager {
            throw new RuntimeException(new DeadSystemException());
        }
        try {
            return sGlobals.mService.getHeightHint();
            return sGlobals.mService.getHeightHint(mContext.getDisplayId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1572,7 +1572,7 @@ public class WallpaperManager {
                throw new RuntimeException(new DeadSystemException());
            } else {
                sGlobals.mService.setDimensionHints(minimumWidth, minimumHeight,
                        mContext.getOpPackageName());
                        mContext.getOpPackageName(), mContext.getDisplayId());
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -1597,7 +1597,8 @@ public class WallpaperManager {
                Log.w(TAG, "WallpaperService not running");
                throw new RuntimeException(new DeadSystemException());
            } else {
                sGlobals.mService.setDisplayPadding(padding, mContext.getOpPackageName());
                sGlobals.mService.setDisplayPadding(padding, mContext.getOpPackageName(),
                        mContext.getDisplayId());
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+22 −18
Original line number Diff line number Diff line
@@ -208,7 +208,6 @@ public abstract class WallpaperService extends Service {
        private final Supplier<Long> mClockFunction;
        private final Handler mHandler;

        DisplayManager mDisplayManager;
        Display mDisplay;
        private int mDisplayState;

@@ -1015,14 +1014,6 @@ public abstract class WallpaperService extends Service {
                return;
            }

            mDisplayManager = getSystemService(DisplayManager.class);
            mDisplay = mDisplayManager.getDisplay(wrapper.mDisplayId);
            if (mDisplay == null) {
                // TODO(b/115486823) Ignore this engine.
                Log.e(TAG, "Attaching to a non-existent display: " + wrapper.mDisplayId);
                return;
            }

            mIWallpaperEngine = wrapper;
            mCaller = wrapper.mCaller;
            mConnection = wrapper.mConnection;
@@ -1034,13 +1025,16 @@ public abstract class WallpaperService extends Service {
            mWindow.setSession(mSession);

            mLayout.packageName = getPackageName();
            mDisplayManager.registerDisplayListener(mDisplayListener, mCaller.getHandler());
            mIWallpaperEngine.mDisplayManager.registerDisplayListener(mDisplayListener,
                    mCaller.getHandler());
            mDisplay = mIWallpaperEngine.mDisplay;
            mDisplayState = mDisplay.getState();

            if (DEBUG) Log.v(TAG, "onCreate(): " + this);
            onCreate(mSurfaceHolder);

            mInitializing = false;

            mReportedVisible = false;
            updateSurface(false, false, false);
        }
@@ -1202,8 +1196,8 @@ public abstract class WallpaperService extends Service {
            
            mDestroyed = true;

            if (mDisplayManager != null) {
                mDisplayManager.unregisterDisplayListener(mDisplayListener);
            if (mIWallpaperEngine.mDisplayManager != null) {
                mIWallpaperEngine.mDisplayManager.unregisterDisplayListener(mDisplayListener);
            }

            if (mVisible) {
@@ -1272,7 +1266,9 @@ public abstract class WallpaperService extends Service {
        int mReqWidth;
        int mReqHeight;
        final Rect mDisplayPadding = new Rect();
        int mDisplayId;
        final int mDisplayId;
        final DisplayManager mDisplayManager;
        final Display mDisplay;

        Engine mEngine;

@@ -1290,6 +1286,14 @@ public abstract class WallpaperService extends Service {
            mDisplayPadding.set(padding);
            mDisplayId = displayId;

            // Create a display context before onCreateEngine.
            mDisplayManager = getSystemService(DisplayManager.class);
            mDisplay = mDisplayManager.getDisplay(mDisplayId);

            if (mDisplay == null) {
                // Ignore this engine.
                throw new IllegalArgumentException("Cannot find display with id" + mDisplayId);
            }
            Message msg = mCaller.obtainMessage(DO_ATTACH);
            mCaller.sendMessage(msg);
        }
+212 −113

File changed.

Preview size limit exceeded, changes collapsed.