diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/IWallpaperManager.aidl | 14 | ||||
| -rw-r--r-- | core/java/android/app/WallpaperManager.java | 9 | ||||
| -rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 40 |
3 files changed, 34 insertions, 29 deletions
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl index 5ef4be18ef2f..00547b4a5ce4 100644 --- a/core/java/android/app/IWallpaperManager.aidl +++ b/core/java/android/app/IWallpaperManager.aidl @@ -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. diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index bebe79e41e5b..27471cac10e9 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -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(); diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 6f51becfbf03..f6bb762a0bef 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -129,7 +129,7 @@ public abstract class WallpaperService extends Service { Bundle extras; boolean sync; } - + /** * The actual implementation of a wallpaper. A wallpaper service may * have multiple instances running (for example as a real wallpaper @@ -144,7 +144,7 @@ public abstract class WallpaperService extends Service { HandlerCaller mCaller; IWallpaperConnection mConnection; IBinder mWindowToken; - + boolean mInitializing = true; boolean mVisible; boolean mReportedVisible; @@ -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; @@ -419,7 +418,7 @@ public abstract class WallpaperService extends Service { public int getDesiredMinimumHeight() { return mIWallpaperEngine.mReqHeight; } - + /** * Return whether the wallpaper is currently visible to the user, * this is the last value supplied to @@ -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; @@ -1289,7 +1285,15 @@ public abstract class WallpaperService extends Service { mReqHeight = reqHeight; 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); } |
