committed by
Android (Google) Code Review
commit
9c93db60e6
@@ -139,6 +139,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
boolean mSurfaceCreated;
|
boolean mSurfaceCreated;
|
||||||
boolean mIsCreating;
|
boolean mIsCreating;
|
||||||
boolean mDrawingAllowed;
|
boolean mDrawingAllowed;
|
||||||
|
boolean mOffsetsChanged;
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
int mFormat;
|
int mFormat;
|
||||||
@@ -604,12 +605,15 @@ public abstract class WallpaperService extends Service {
|
|||||||
if (DEBUG) Log.v(TAG, "Layout: Surface destroyed");
|
if (DEBUG) Log.v(TAG, "Layout: Surface destroyed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean didSurface = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mSurfaceHolder.ungetCallbacks();
|
mSurfaceHolder.ungetCallbacks();
|
||||||
|
|
||||||
if (surfaceCreating) {
|
if (surfaceCreating) {
|
||||||
mIsCreating = true;
|
mIsCreating = true;
|
||||||
|
didSurface = true;
|
||||||
if (DEBUG) Log.v(TAG, "onSurfaceCreated("
|
if (DEBUG) Log.v(TAG, "onSurfaceCreated("
|
||||||
+ mSurfaceHolder + "): " + this);
|
+ mSurfaceHolder + "): " + this);
|
||||||
onSurfaceCreated(mSurfaceHolder);
|
onSurfaceCreated(mSurfaceHolder);
|
||||||
@@ -637,6 +641,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
+ mSurfaceHolder + ", " + mFormat
|
+ mSurfaceHolder + ", " + mFormat
|
||||||
+ ", " + mCurWidth + ", " + mCurHeight
|
+ ", " + mCurWidth + ", " + mCurHeight
|
||||||
+ "): " + this);
|
+ "): " + this);
|
||||||
|
didSurface = true;
|
||||||
onSurfaceChanged(mSurfaceHolder, mFormat,
|
onSurfaceChanged(mSurfaceHolder, mFormat,
|
||||||
mCurWidth, mCurHeight);
|
mCurWidth, mCurHeight);
|
||||||
SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
|
SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
|
||||||
@@ -661,6 +666,26 @@ public abstract class WallpaperService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (didSurface && !mReportedVisible) {
|
||||||
|
// This wallpaper is currently invisible, but its
|
||||||
|
// surface has changed. At this point let's tell it
|
||||||
|
// again that it is invisible in case the report about
|
||||||
|
// the surface caused it to start running. We really
|
||||||
|
// don't want wallpapers running when not visible.
|
||||||
|
if (mIsCreating) {
|
||||||
|
// Some wallpapers will ignore this call if they
|
||||||
|
// had previously been told they were invisble,
|
||||||
|
// so if we are creating a new surface then toggle
|
||||||
|
// the state to get them to notice.
|
||||||
|
if (DEBUG) Log.v(TAG, "onVisibilityChanged(true) at surface: "
|
||||||
|
+ this);
|
||||||
|
onVisibilityChanged(true);
|
||||||
|
}
|
||||||
|
if (DEBUG) Log.v(TAG, "onVisibilityChanged(false) at surface: "
|
||||||
|
+ this);
|
||||||
|
onVisibilityChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
mIsCreating = false;
|
mIsCreating = false;
|
||||||
mSurfaceCreated = true;
|
mSurfaceCreated = true;
|
||||||
@@ -701,6 +726,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
onCreate(mSurfaceHolder);
|
onCreate(mSurfaceHolder);
|
||||||
|
|
||||||
mInitializing = false;
|
mInitializing = false;
|
||||||
|
mReportedVisible = false;
|
||||||
updateSurface(false, false, false);
|
updateSurface(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,7 +737,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
mIWallpaperEngine.mReqWidth = desiredWidth;
|
mIWallpaperEngine.mReqWidth = desiredWidth;
|
||||||
mIWallpaperEngine.mReqHeight = desiredHeight;
|
mIWallpaperEngine.mReqHeight = desiredHeight;
|
||||||
onDesiredSizeChanged(desiredWidth, desiredHeight);
|
onDesiredSizeChanged(desiredWidth, desiredHeight);
|
||||||
doOffsetsChanged();
|
doOffsetsChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,6 +759,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
// If becoming visible, in preview mode the surface
|
// If becoming visible, in preview mode the surface
|
||||||
// may have been destroyed so now we need to make
|
// may have been destroyed so now we need to make
|
||||||
// sure it is re-created.
|
// sure it is re-created.
|
||||||
|
doOffsetsChanged(false);
|
||||||
updateSurface(false, false, false);
|
updateSurface(false, false, false);
|
||||||
}
|
}
|
||||||
onVisibilityChanged(visible);
|
onVisibilityChanged(visible);
|
||||||
@@ -740,11 +767,15 @@ public abstract class WallpaperService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doOffsetsChanged() {
|
void doOffsetsChanged(boolean always) {
|
||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!always && !mOffsetsChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float xOffset;
|
float xOffset;
|
||||||
float yOffset;
|
float yOffset;
|
||||||
float xOffsetStep;
|
float xOffsetStep;
|
||||||
@@ -759,15 +790,19 @@ public abstract class WallpaperService extends Service {
|
|||||||
mPendingSync = false;
|
mPendingSync = false;
|
||||||
mOffsetMessageEnqueued = false;
|
mOffsetMessageEnqueued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSurfaceCreated) {
|
if (mSurfaceCreated) {
|
||||||
if (DEBUG) Log.v(TAG, "Offsets change in " + this
|
if (mReportedVisible) {
|
||||||
+ ": " + xOffset + "," + yOffset);
|
if (DEBUG) Log.v(TAG, "Offsets change in " + this
|
||||||
final int availw = mIWallpaperEngine.mReqWidth-mCurWidth;
|
+ ": " + xOffset + "," + yOffset);
|
||||||
final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0;
|
final int availw = mIWallpaperEngine.mReqWidth-mCurWidth;
|
||||||
final int availh = mIWallpaperEngine.mReqHeight-mCurHeight;
|
final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0;
|
||||||
final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0;
|
final int availh = mIWallpaperEngine.mReqHeight-mCurHeight;
|
||||||
onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels);
|
final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0;
|
||||||
|
onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels);
|
||||||
|
} else {
|
||||||
|
mOffsetsChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
@@ -953,7 +988,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
mEngine.doVisibilityChanged(message.arg1 != 0);
|
mEngine.doVisibilityChanged(message.arg1 != 0);
|
||||||
break;
|
break;
|
||||||
case MSG_WALLPAPER_OFFSETS: {
|
case MSG_WALLPAPER_OFFSETS: {
|
||||||
mEngine.doOffsetsChanged();
|
mEngine.doOffsetsChanged(true);
|
||||||
} break;
|
} break;
|
||||||
case MSG_WALLPAPER_COMMAND: {
|
case MSG_WALLPAPER_COMMAND: {
|
||||||
WallpaperCommand cmd = (WallpaperCommand)message.obj;
|
WallpaperCommand cmd = (WallpaperCommand)message.obj;
|
||||||
@@ -962,7 +997,7 @@ public abstract class WallpaperService extends Service {
|
|||||||
case MSG_WINDOW_RESIZED: {
|
case MSG_WINDOW_RESIZED: {
|
||||||
final boolean reportDraw = message.arg1 != 0;
|
final boolean reportDraw = message.arg1 != 0;
|
||||||
mEngine.updateSurface(true, false, reportDraw);
|
mEngine.updateSurface(true, false, reportDraw);
|
||||||
mEngine.doOffsetsChanged();
|
mEngine.doOffsetsChanged(true);
|
||||||
} break;
|
} break;
|
||||||
case MSG_TOUCH_EVENT: {
|
case MSG_TOUCH_EVENT: {
|
||||||
boolean skip = false;
|
boolean skip = false;
|
||||||
|
|||||||
@@ -2533,6 +2533,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
boolean wallpaperMayMove = win.mViewVisibility != viewVisibility
|
boolean wallpaperMayMove = win.mViewVisibility != viewVisibility
|
||||||
&& (win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0;
|
&& (win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0;
|
||||||
|
wallpaperMayMove |= (flagChanges & FLAG_SHOW_WALLPAPER) != 0;
|
||||||
|
|
||||||
win.mRelayoutCalled = true;
|
win.mRelayoutCalled = true;
|
||||||
final int oldVisibility = win.mViewVisibility;
|
final int oldVisibility = win.mViewVisibility;
|
||||||
@@ -7925,11 +7926,26 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (windowAnimationBackgroundColor != 0) {
|
if (windowAnimationBackgroundColor != 0) {
|
||||||
|
// If this window that wants black is the current wallpaper
|
||||||
|
// target, then the black goes *below* the wallpaper so we
|
||||||
|
// don't cause the wallpaper to suddenly disappear.
|
||||||
|
WindowState target = windowAnimationBackground;
|
||||||
|
if (mWallpaperTarget == windowAnimationBackground
|
||||||
|
|| mLowerWallpaperTarget == windowAnimationBackground
|
||||||
|
|| mUpperWallpaperTarget == windowAnimationBackground) {
|
||||||
|
for (i=0; i<mWindows.size(); i++) {
|
||||||
|
WindowState w = mWindows.get(i);
|
||||||
|
if (w.mIsWallpaper) {
|
||||||
|
target = w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (mWindowAnimationBackgroundSurface == null) {
|
if (mWindowAnimationBackgroundSurface == null) {
|
||||||
mWindowAnimationBackgroundSurface = new DimSurface(mFxSession);
|
mWindowAnimationBackgroundSurface = new DimSurface(mFxSession);
|
||||||
}
|
}
|
||||||
mWindowAnimationBackgroundSurface.show(dw, dh,
|
mWindowAnimationBackgroundSurface.show(dw, dh,
|
||||||
windowAnimationBackground.mAnimLayer - LAYER_OFFSET_DIM,
|
target.mAnimLayer - LAYER_OFFSET_DIM,
|
||||||
windowAnimationBackgroundColor);
|
windowAnimationBackgroundColor);
|
||||||
} else if (mWindowAnimationBackgroundSurface != null) {
|
} else if (mWindowAnimationBackgroundSurface != null) {
|
||||||
mWindowAnimationBackgroundSurface.hide();
|
mWindowAnimationBackgroundSurface.hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user