summaryrefslogtreecommitdiffstats
path: root/core/java/android/service/wallpaper
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2011-10-28 13:18:16 -0700
committerChet Haase <chet@google.com>2011-10-28 14:49:23 -0700
commita8e5a2bcd6a0d35893187c6df42425c03be005da (patch)
treef6ef550565e525e7b8262182a336eb40432915e9 /core/java/android/service/wallpaper
parent48ba4139b9dc1f53f996b71f509a9d0c6fd2d72b (diff)
downloadframeworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.zip
frameworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.tar.gz
frameworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.tar.bz2
Optimize handling of scrolled wallpapers
Swiping the home screen causes the WindowManagerService to do a bunch of work to keep the wallpapers in sync. First, it lays out and places all windows. Also, it notifies the SystemUI process that the wallpaper position has changed. The layout/place operation is too much work - we only need to set the position values for the wallpaper, not relayout the whole system. The notification mechanism must exist, but should be optional. Most wallpapers don't care (especially static ImageWallpapers). So we'll give them a new API (WallpaperService.Engine.setWantsOffsets()) to allow wallpapers to opt out of this process and avoid the performance overhead. Change-Id: I66c38375438937f14f6f5550565b28eb204b1e06
Diffstat (limited to 'core/java/android/service/wallpaper')
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index ba94ab2..a9a628a 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -148,7 +148,10 @@ public abstract class WallpaperService extends Service {
int mCurWidth;
int mCurHeight;
int mWindowFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
+ int mWindowPrivateFlags =
+ WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS;
int mCurWindowFlags = mWindowFlags;
+ int mCurWindowPrivateFlags = mWindowPrivateFlags;
final Rect mVisibleInsets = new Rect();
final Rect mWinFrame = new Rect();
final Rect mContentInsets = new Rect();
@@ -359,6 +362,25 @@ public abstract class WallpaperService extends Service {
updateSurface(false, false, false);
}
}
+
+ /**
+ * Control whether this wallpaper will receive notifications when the wallpaper
+ * has been scrolled. By default, wallpapers will receive notifications, although
+ * the default static image wallpapers do not. It is a performance optimization to
+ * set this to false.
+ *
+ * @param enabled whether the wallpaper wants to receive offset notifications
+ */
+ public void setOffsetNotificationsEnabled(boolean enabled) {
+ mWindowPrivateFlags = enabled
+ ? (mWindowPrivateFlags |
+ WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS)
+ : (mWindowPrivateFlags &
+ ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS);
+ if (mCreated) {
+ updateSurface(false, false, false);
+ }
+ }
/**
* Called once to initialize the engine. After returning, the
@@ -478,6 +500,8 @@ public abstract class WallpaperService extends Service {
out.print(prefix); out.print("mType="); out.print(mType);
out.print(" mWindowFlags="); out.print(mWindowFlags);
out.print(" mCurWindowFlags="); out.println(mCurWindowFlags);
+ out.print(" mWindowPrivateFlags="); out.print(mWindowPrivateFlags);
+ out.print(" mCurWindowPrivateFlags="); out.println(mCurWindowPrivateFlags);
out.print(prefix); out.print("mVisibleInsets=");
out.print(mVisibleInsets.toShortString());
out.print(" mWinFrame="); out.print(mWinFrame.toShortString());
@@ -528,7 +552,8 @@ public abstract class WallpaperService extends Service {
final boolean formatChanged = mFormat != mSurfaceHolder.getRequestedFormat();
boolean sizeChanged = mWidth != myWidth || mHeight != myHeight;
final boolean typeChanged = mType != mSurfaceHolder.getRequestedType();
- final boolean flagsChanged = mCurWindowFlags != mWindowFlags;
+ final boolean flagsChanged = mCurWindowFlags != mWindowFlags ||
+ mCurWindowPrivateFlags != mWindowPrivateFlags;
if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged
|| typeChanged || flagsChanged || redrawNeeded) {
@@ -554,6 +579,8 @@ public abstract class WallpaperService extends Service {
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
;
+ mCurWindowPrivateFlags = mWindowPrivateFlags;
+ mLayout.privateFlags = mWindowPrivateFlags;
mLayout.memoryType = mType;
mLayout.token = mWindowToken;