Merge changes Ib28636e6,I93ebc433

* changes:
  WallpaperManagerService does not properly propagate setDimensionHints()
  ImageWallpaper : get bitmap width before calc screen offset
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 724679f..f9debce 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -282,6 +282,13 @@
                 updateWallpaperLocked();
             }
 
+            if (mBackground == null) {
+                // If we somehow got to this point after we have last flushed
+                // the wallpaper, well we really need it to draw again.  So
+                // seems like we need to reload it.  Ouch.
+                updateWallpaperLocked();
+            }
+
             SurfaceHolder sh = getSurfaceHolder();
             final Rect frame = sh.getSurfaceFrame();
             final int dw = frame.width();
@@ -303,13 +310,6 @@
             mLastXTranslation = xPixels;
             mLastYTranslation = yPixels;
 
-            if (mBackground == null) {
-                // If we somehow got to this point after we have last flushed
-                // the wallpaper, well we really need it to draw again.  So
-                // seems like we need to reload it.  Ouch.
-                updateWallpaperLocked();
-            }
-
             if (mIsHwAccelerated) {
                 if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) {
                     drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels);
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 4925a4e..cca6536 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -169,6 +169,7 @@
     WallpaperConnection mWallpaperConnection;
     long mLastDiedTime;
     boolean mWallpaperUpdating;
+    boolean mDesiredDimensionChanging;
     
     class WallpaperConnection extends IWallpaperConnection.Stub
             implements ServiceConnection {
@@ -213,6 +214,13 @@
         
         public void attachEngine(IWallpaperEngine engine) {
             mEngine = engine;
+             if (engine != null && mDesiredDimensionChanging) {
+                 try {
+                     engine.setDesiredSize(mWidth, mHeight);
+                     mDesiredDimensionChanging = false;
+                 } catch (RemoteException e) {
+                 }
+             }
         }
         
         public ParcelFileDescriptor setWallpaper(String name) {
@@ -395,6 +403,7 @@
 
         synchronized (mLock) {
             if (width != mWidth || height != mHeight) {
+                boolean desiredDimensionPropagated = false;
                 mWidth = width;
                 mHeight = height;
                 saveSettingsLocked();
@@ -403,11 +412,15 @@
                         try {
                             mWallpaperConnection.mEngine.setDesiredSize(
                                     width, height);
+                            desiredDimensionPropagated = true;
                         } catch (RemoteException e) {
                         }
                         notifyCallbacksLocked();
                     }
                 }
+                if (!desiredDimensionPropagated) {
+                    mDesiredDimensionChanging = true;
+                }
             }
         }
     }