diff --git a/api/current.xml b/api/current.xml
index ee8d2eb865116..58c0bf84356c4 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -60831,6 +60831,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
0
+ ? -(int)(availw*mXOffset+.5f) : -(int)(availw/2);
+ int yPixels = availh > 0
+ ? -(int)(availh*mYOffset+.5f) : -(int)(availh/2);
+ c.translate(xPixels, yPixels);
c.drawColor(0xff000000);
background.draw(c);
}
@@ -128,9 +137,6 @@ public class ImageWallpaper extends WallpaperService {
mBounds.left = mBounds.top = 0;
mBounds.right = mBackground.getIntrinsicWidth();
mBounds.bottom = mBackground.getIntrinsicHeight();
- int offx = (getDesiredMinimumWidth() - mBounds.right) / 2;
- int offy = (getDesiredMinimumHeight() - mBounds.bottom) / 2;
- mBounds.offset(offx, offy);
mBackground.setBounds(mBounds);
}
}
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 076cd0c089c04..2abb7779eab26 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -73,7 +73,7 @@ public class BitmapFactory {
public Bitmap.Config inPreferredConfig;
/**
- * If dither is true, the decoder will atttempt to dither the decoded
+ * If dither is true, the decoder will attempt to dither the decoded
* image.
*/
public boolean inDither;
@@ -452,6 +452,10 @@ public class BitmapFactory {
bm = nativeDecodeStream(is, tempStorage, outPadding, opts);
}
+ return finishDecode(bm, outPadding, opts);
+ }
+
+ private static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) {
if (bm == null || opts == null) {
return bm;
}
@@ -487,7 +491,7 @@ public class BitmapFactory {
return bm;
}
-
+
/**
* Decode an input stream into a bitmap. If the input stream is null, or
* cannot be used to decode a bitmap, the function returns null.
@@ -507,7 +511,7 @@ public class BitmapFactory {
/**
* Decode a bitmap from the file descriptor. If the bitmap cannot be decoded
* return null. The position within the descriptor will not be changed when
- * this returns, so the descriptor can be used again as is.
+ * this returns, so the descriptor can be used again as-is.
*
* @param fd The file descriptor containing the bitmap data to decode
* @param outPadding If not null, return the padding rect for the bitmap if
@@ -524,13 +528,15 @@ public class BitmapFactory {
int mappedlength = MemoryFile.getMappedSize(fd);
MemoryFile file = new MemoryFile(fd, mappedlength, "r");
InputStream is = file.getInputStream();
- return decodeStream(is, outPadding, opts);
+ Bitmap bm = decodeStream(is, outPadding, opts);
+ return finishDecode(bm, outPadding, opts);
}
} catch (IOException ex) {
// invalid filedescriptor, no need to call nativeDecodeFileDescriptor()
return null;
}
- return nativeDecodeFileDescriptor(fd, outPadding, opts);
+ Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts);
+ return finishDecode(bm, outPadding, opts);
}
/**
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 193f399244693..33748ae3bdd96 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -663,6 +663,15 @@ public abstract class Drawable {
*/
public static Drawable createFromResourceStream(Resources res, TypedValue value,
InputStream is, String srcName) {
+ return createFromResourceStream(res, value, is, srcName);
+ }
+
+ /**
+ * Create a drawable from an inputstream, using the given resources and
+ * value to determine density information.
+ */
+ public static Drawable createFromResourceStream(Resources res, TypedValue value,
+ InputStream is, String srcName, BitmapFactory.Options opts) {
if (is == null) {
return null;
@@ -683,7 +692,7 @@ public abstract class Drawable {
// an application in compatibility mode, without scaling those down
// to the compatibility density only to have them scaled back up when
// drawn to the screen.
- BitmapFactory.Options opts = new BitmapFactory.Options();
+ if (opts == null) opts = new BitmapFactory.Options();
opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
Bitmap bm = BitmapFactory.decodeResourceStream(res, value, is, pad, opts);
if (bm != null) {
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 9a293a97b89a5..60477427a6b70 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -325,10 +325,10 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
ComponentName realName = name;
if (realName == null) {
// The default component is our static image wallpaper.
- //realName = new ComponentName("android",
- // ImageWallpaper.class.getName());
- clearWallpaperComponentLocked();
- return;
+ realName = new ComponentName("android",
+ ImageWallpaper.class.getName());
+ //clearWallpaperComponentLocked();
+ //return;
}
ServiceInfo si = mContext.getPackageManager().getServiceInfo(realName,
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index ac8007169bcc6..6af85db0a54a8 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -139,6 +139,7 @@ public class WindowManagerService extends IWindowManager.Stub
static final boolean DEBUG_APP_TRANSITIONS = false;
static final boolean DEBUG_STARTING_WINDOW = false;
static final boolean DEBUG_REORDER = false;
+ static final boolean DEBUG_WALLPAPER = false;
static final boolean SHOW_TRANSACTIONS = false;
static final boolean MEASURE_LATENCY = false;
static private LatencyTimer lt;
@@ -1187,19 +1188,26 @@ public class WindowManagerService extends IWindowManager.Stub
while (i > 0) {
i--;
w = (WindowState)localmWindows.get(i);
- if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()) {
+ if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
+ && !w.mDrawPending && !w.mCommitDrawPending) {
visible = true;
break;
}
}
if (!visible) w = null;
- //if (mWallpaperTarget != w) {
- // Log.v(TAG, "New wallpaper target: " + w);
- //}
+ if (DEBUG_WALLPAPER && mWallpaperTarget != w) {
+ Log.v(TAG, "New wallpaper target: " + w);
+ }
mWallpaperTarget = w;
if (visible) {
+ // The window is visible to the compositor... but is it visible
+ // to the user? That is what the wallpaper cares about.
+ visible = !w.mObscured;
+
+ // If the wallpaper target is animating, we may need to copy
+ // its layer adjustment.
mWallpaperAnimLayerAdjustment = w.mAppToken != null
? w.mAppToken.animLayerAdjustment : 0;
@@ -1239,7 +1247,7 @@ public class WindowManagerService extends IWindowManager.Stub
WindowState wallpaper = token.windows.get(curWallpaperIndex);
if (visible) {
- updateWallpaperOffsetLocked(mWallpaperTarget, wallpaper, dw, dh);
+ updateWallpaperOffsetLocked(w, wallpaper, dw, dh);
}
// First, make sure the client has the current visibility
@@ -1247,7 +1255,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (wallpaper.mWallpaperVisible != visible) {
wallpaper.mWallpaperVisible = visible;
try {
- if (DEBUG_VISIBILITY) Log.v(TAG,
+ if (DEBUG_VISIBILITY || DEBUG_WALLPAPER) Log.v(TAG,
"Setting visibility of wallpaper " + wallpaper
+ ": " + visible);
wallpaper.mClient.dispatchAppVisibility(visible);
@@ -1256,8 +1264,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
wallpaper.mAnimLayer = wallpaper.mLayer + mWallpaperAnimLayerAdjustment;
- if (DEBUG_LAYERS) Log.v(TAG, "Wallpaper win " + wallpaper
- + " anim layer: " + wallpaper.mAnimLayer);
+ if (DEBUG_LAYERS || DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper win "
+ + wallpaper + " anim layer: " + wallpaper.mAnimLayer);
// First, if this window is at the current index, then all
// is well.
@@ -1279,6 +1287,9 @@ public class WindowManagerService extends IWindowManager.Stub
}
// Now stick it in.
+ if (DEBUG_WALLPAPER) Log.v(TAG, "Moving wallpaper " + wallpaper
+ + " from " + oldIndex + " to " + i);
+
localmWindows.add(i, wallpaper);
changed = true;
}
@@ -1288,7 +1299,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
void setWallpaperAnimLayerAdjustmentLocked(int adj) {
- if (DEBUG_LAYERS) Log.v(TAG, "Setting wallpaper layer adj to " + adj);
+ if (DEBUG_LAYERS || DEBUG_WALLPAPER) Log.v(TAG,
+ "Setting wallpaper layer adj to " + adj);
mWallpaperAnimLayerAdjustment = adj;
int curTokenIndex = mWallpaperTokens.size();
while (curTokenIndex > 0) {
@@ -1299,8 +1311,8 @@ public class WindowManagerService extends IWindowManager.Stub
curWallpaperIndex--;
WindowState wallpaper = token.windows.get(curWallpaperIndex);
wallpaper.mAnimLayer = wallpaper.mLayer + adj;
- if (DEBUG_LAYERS) Log.v(TAG, "Wallpaper win " + wallpaper
- + " anim layer: " + wallpaper.mAnimLayer);
+ if (DEBUG_LAYERS || DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper win "
+ + wallpaper + " anim layer: " + wallpaper.mAnimLayer);
}
}
}
@@ -1308,27 +1320,38 @@ public class WindowManagerService extends IWindowManager.Stub
boolean updateWallpaperOffsetLocked(WindowState target,
WindowState wallpaperWin, int dw, int dh) {
boolean changed = false;
+ boolean rawChanged = false;
if (target.mWallpaperX >= 0) {
int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw;
int offset = availw > 0 ? -(int)(availw*target.mWallpaperX+.5f) : 0;
changed = wallpaperWin.mXOffset != offset;
if (changed) {
+ if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper "
+ + wallpaperWin + " x: " + offset);
wallpaperWin.mXOffset = offset;
}
+ if (wallpaperWin.mWallpaperX != target.mWallpaperX) {
+ wallpaperWin.mWallpaperX = target.mWallpaperX;
+ rawChanged = true;
+ }
}
+
if (target.mWallpaperY >= 0) {
int availh = wallpaperWin.mFrame.bottom-wallpaperWin.mFrame.top-dh;
int offset = availh > 0 ? -(int)(availh*target.mWallpaperY+.5f) : 0;
if (wallpaperWin.mYOffset != offset) {
+ if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper "
+ + wallpaperWin + " y: " + offset);
changed = true;
wallpaperWin.mYOffset = offset;
}
+ if (wallpaperWin.mWallpaperY != target.mWallpaperY) {
+ wallpaperWin.mWallpaperY = target.mWallpaperY;
+ rawChanged = true;
+ }
}
- if (wallpaperWin.mWallpaperX != target.mWallpaperX
- || wallpaperWin.mWallpaperY != target.mWallpaperY) {
- wallpaperWin.mWallpaperX = target.mWallpaperX;
- wallpaperWin.mWallpaperY = target.mWallpaperY;
+ if (rawChanged) {
try {
wallpaperWin.mClient.dispatchWallpaperOffsets(
wallpaperWin.mWallpaperX, wallpaperWin.mWallpaperY);
@@ -5997,6 +6020,7 @@ public class WindowManagerService extends IWindowManager.Stub
int mAnimLayer;
int mLastLayer;
boolean mHaveFrame;
+ boolean mObscured;
WindowState mNextOutsideTouch;
@@ -6767,6 +6791,12 @@ public class WindowManagerService extends IWindowManager.Stub
mWallpaperTarget.mAppToken.hasTransformation) {
appTransformation = mWallpaperTarget.mAppToken.transformation;
}
+ if (DEBUG_WALLPAPER && attachedTransformation != null) {
+ Log.v(TAG, "WP target attached xform: " + attachedTransformation);
+ }
+ if (DEBUG_WALLPAPER && appTransformation != null) {
+ Log.v(TAG, "WP target app xform: " + appTransformation);
+ }
}
if (selfTransformation || attachedTransformation != null
@@ -6919,7 +6949,8 @@ public class WindowManagerService extends IWindowManager.Stub
final boolean animating = atoken != null
? (atoken.animation != null) : false;
return mSurface != null && mPolicyVisibility && !mDestroying
- && ((!mAttachedHidden && !mRootToken.hidden)
+ && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
+ && !mRootToken.hidden)
|| mAnimation != null || animating);
}
@@ -7119,7 +7150,8 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(prefix); pw.print("mViewVisibility=0x");
pw.print(Integer.toHexString(mViewVisibility));
pw.print(" mLastHidden="); pw.print(mLastHidden);
- pw.print(" mHaveFrame="); pw.println(mHaveFrame);
+ pw.print(" mHaveFrame="); pw.print(mHaveFrame);
+ pw.print(" mObscured="); pw.println(mObscured);
if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) {
pw.print(prefix); pw.print("mPolicyVisibility=");
pw.print(mPolicyVisibility);
@@ -8141,7 +8173,8 @@ public class WindowManagerService extends IWindowManager.Stub
for (i=0; i 0 && w.mIsWallpaper)) {
curLayer += WINDOW_LAYER_MULTIPLIER;
w.mLayer = curLayer;
} else {
@@ -8823,7 +8856,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
// Update effect.
- if (!obscured) {
+ if (!(w.mObscured=obscured)) {
if (w.mSurface != null) {
if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) {
holdScreen = w.mSession;
@@ -8989,6 +9022,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
// Destroy the surface of any windows that are no longer visible.
+ boolean wallpaperDestroyed = false;
i = mDestroySurface.size();
if (i > 0) {
do {
@@ -8998,6 +9032,9 @@ public class WindowManagerService extends IWindowManager.Stub
if (mInputMethodWindow == win) {
mInputMethodWindow = null;
}
+ if (win == mWallpaperTarget) {
+ wallpaperDestroyed = true;
+ }
win.destroySurfaceLocked();
} while (i > 0);
mDestroySurface.clear();
@@ -9026,7 +9063,12 @@ public class WindowManagerService extends IWindowManager.Stub
if (focusDisplayed) {
mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
}
- if (animating) {
+ if (wallpaperDestroyed) {
+ wallpaperDestroyed = adjustWallpaperWindowsLocked();
+ }
+ if (wallpaperDestroyed) {
+ requestAnimationLocked(0);
+ } else if (animating) {
requestAnimationLocked(currentTime+(1000/60)-SystemClock.uptimeMillis());
}
mQueue.setHoldScreenLocked(holdScreen != null);