Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3645,6 +3645,7 @@ package android.app { public class WallpaperManager { method public void clear() throws java.io.IOException; method public void clearWallpaperOffsets(android.os.IBinder); method public void forgetLoadedWallpaper(); method public int getDesiredMinimumHeight(); method public int getDesiredMinimumWidth(); method public android.graphics.drawable.Drawable getDrawable(); core/java/android/app/WallpaperManager.java +26 −4 Original line number Diff line number Diff line Loading @@ -234,14 +234,25 @@ public class WallpaperManager { } catch (OutOfMemoryError e) { Log.w(TAG, "No memory load current wallpaper", e); } if (mWallpaper == null && returnDefault) { if (returnDefault) { if (mWallpaper == null) { mDefaultWallpaper = getDefaultWallpaperLocked(context); return mDefaultWallpaper; } else { mDefaultWallpaper = null; } } return mWallpaper; } } public void forgetLoadedWallpaper() { synchronized (this) { mWallpaper = null; mDefaultWallpaper = null; } } private Bitmap getCurrentWallpaperLocked(Context context) { try { Bundle params = new Bundle(); Loading Loading @@ -401,6 +412,16 @@ public class WallpaperManager { return null; } /** * Remove all internal references to the last loaded wallpaper. Useful * for apps that want to reduce memory usage when they only temporarily * need to have the wallpaper. After calling, the next request for the * wallpaper will require reloading it again from disk. */ public void forgetLoadedWallpaper() { sGlobals.forgetLoadedWallpaper(); } /** * If the current wallpaper is a live wallpaper component, return the * information about that wallpaper. Otherwise, if it is a static image, Loading Loading @@ -716,6 +737,7 @@ public class WallpaperManager { c.drawBitmap(bm, null, targetRect, paint); bm.recycle(); c.setBitmap(null); return newbm; } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); Loading core/res/AndroidManifest.xml +0 −4 Original line number Diff line number Diff line Loading @@ -1504,10 +1504,6 @@ android:excludeFromRecents="true"> </activity> <service android:name="com.android.internal.service.wallpaper.ImageWallpaper" android:permission="android.permission.BIND_WALLPAPER"> </service> <receiver android:name="com.android.server.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> Loading packages/SystemUI/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ <service android:name=".LoadAverageService" android:exported="true" /> <service android:name=".ImageWallpaper" android:permission="android.permission.BIND_WALLPAPER" android:exported="true" /> <receiver android:name=".BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> Loading core/java/com/android/internal/service/wallpaper/ImageWallpaper.java→packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +48 −42 Original line number Diff line number Diff line Loading @@ -14,23 +14,19 @@ * limitations under the License. */ package com.android.internal.service.wallpaper; package com.android.systemui; import java.io.IOException; import com.android.internal.view.WindowManagerPolicyThread; import android.app.WallpaperManager; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.Region.Op; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Process; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.util.Slog; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.content.Context; Loading @@ -45,40 +41,27 @@ public class ImageWallpaper extends WallpaperService { private static final String TAG = "ImageWallpaper"; private static final boolean DEBUG = false; static final boolean FIXED_SIZED_SURFACE = true; WallpaperManager mWallpaperManager; private HandlerThread mThread; private Handler mHandler; @Override public void onCreate() { super.onCreate(); mWallpaperManager = (WallpaperManager) getSystemService(WALLPAPER_SERVICE); Looper looper = WindowManagerPolicyThread.getLooper(); if (looper == null) { mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND); mThread.start(); looper = mThread.getLooper(); } setCallbackLooper(looper); mHandler = new Handler(looper); mHandler = new Handler(); } public Engine onCreateEngine() { return new DrawableEngine(); } @Override public void onDestroy() { super.onDestroy(); if (mThread != null) { mThread.quit(); } } class DrawableEngine extends Engine { private final Object mLock = new Object(); private WallpaperObserver mReceiver; Drawable mBackground; int mBackgroundWidth = -1, mBackgroundHeight = -1; float mXOffset; float mYOffset; Loading @@ -95,7 +78,9 @@ public class ImageWallpaper extends WallpaperService { } synchronized (mLock) { updateWallpaperLocked(); mBackgroundWidth = mBackgroundHeight = -1; mBackground = null; mRedrawNeeded = true; drawFrameLocked(); } } Loading @@ -113,10 +98,6 @@ public class ImageWallpaper extends WallpaperService { registerReceiver(mReceiver, filter, null, mHandler); updateSurfaceSize(surfaceHolder); synchronized (mLock) { updateWallpaperLocked(); } } @Override Loading @@ -135,11 +116,14 @@ public class ImageWallpaper extends WallpaperService { } void updateSurfaceSize(SurfaceHolder surfaceHolder) { surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight()); if (FIXED_SIZED_SURFACE) { // Used a fixed size surface, because we are special. We can do // this because we know the current design of window animations doesn't // cause this to break. //surfaceHolder.setSizeFromLayout(); surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight()); } else { surfaceHolder.setSizeFromLayout(); } } @Override Loading Loading @@ -216,15 +200,18 @@ public class ImageWallpaper extends WallpaperService { return; } if (mBackgroundWidth < 0 || mBackgroundHeight < 0) { // If we don't yet know the size of the wallpaper bitmap, // we need to get it now. updateWallpaperLocked(); } SurfaceHolder sh = getSurfaceHolder(); final Rect frame = sh.getSurfaceFrame(); final Drawable background = mBackground; final int dw = frame.width(); final int dh = frame.height(); final int bw = background != null ? background.getIntrinsicWidth() : 0; final int bh = background != null ? background.getIntrinsicHeight() : 0; final int availw = dw - bw; final int availh = dh - bh; final int availw = dw - mBackgroundWidth; final int availh = dh - mBackgroundHeight; int xPixels = availw < 0 ? (int)(availw * mXOffset + .5f) : (availw / 2); int yPixels = availh < 0 ? (int)(availh * mYOffset + .5f) : (availh / 2); Loading @@ -241,6 +228,14 @@ public class ImageWallpaper extends WallpaperService { 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(); } //Slog.i(TAG, "************** DRAWING WALLAPER ******************"); Canvas c = sh.lockCanvas(); if (c != null) { try { Loading @@ -251,20 +246,30 @@ public class ImageWallpaper extends WallpaperService { c.translate(xPixels, yPixels); if (availw < 0 || availh < 0) { c.save(Canvas.CLIP_SAVE_FLAG); c.clipRect(0, 0, bw, bh, Op.DIFFERENCE); c.clipRect(0, 0, mBackgroundWidth, mBackgroundHeight, Op.DIFFERENCE); c.drawColor(0xff000000); c.restore(); } if (background != null) { background.draw(c); if (mBackground != null) { mBackground.draw(c); } } finally { sh.unlockCanvasAndPost(c); } } if (FIXED_SIZED_SURFACE) { // If the surface is fixed-size, we should only need to // draw it once and then we'll let the window manager // position it appropriately. As such, we no longer needed // the loaded bitmap. Yay! mBackground = null; mWallpaperManager.forgetLoadedWallpaper(); } } void updateWallpaperLocked() { //Slog.i(TAG, "************** LOADING WALLAPER ******************"); Throwable exception = null; try { mBackground = mWallpaperManager.getFastDrawable(); Loading @@ -286,7 +291,8 @@ public class ImageWallpaper extends WallpaperService { Log.w(TAG, "Unable reset to default wallpaper!", ex); } } mRedrawNeeded = true; mBackgroundWidth = mBackground != null ? mBackground.getIntrinsicWidth() : 0; mBackgroundHeight = mBackground != null ? mBackground.getIntrinsicHeight() : 0; } } } Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3645,6 +3645,7 @@ package android.app { public class WallpaperManager { method public void clear() throws java.io.IOException; method public void clearWallpaperOffsets(android.os.IBinder); method public void forgetLoadedWallpaper(); method public int getDesiredMinimumHeight(); method public int getDesiredMinimumWidth(); method public android.graphics.drawable.Drawable getDrawable();
core/java/android/app/WallpaperManager.java +26 −4 Original line number Diff line number Diff line Loading @@ -234,14 +234,25 @@ public class WallpaperManager { } catch (OutOfMemoryError e) { Log.w(TAG, "No memory load current wallpaper", e); } if (mWallpaper == null && returnDefault) { if (returnDefault) { if (mWallpaper == null) { mDefaultWallpaper = getDefaultWallpaperLocked(context); return mDefaultWallpaper; } else { mDefaultWallpaper = null; } } return mWallpaper; } } public void forgetLoadedWallpaper() { synchronized (this) { mWallpaper = null; mDefaultWallpaper = null; } } private Bitmap getCurrentWallpaperLocked(Context context) { try { Bundle params = new Bundle(); Loading Loading @@ -401,6 +412,16 @@ public class WallpaperManager { return null; } /** * Remove all internal references to the last loaded wallpaper. Useful * for apps that want to reduce memory usage when they only temporarily * need to have the wallpaper. After calling, the next request for the * wallpaper will require reloading it again from disk. */ public void forgetLoadedWallpaper() { sGlobals.forgetLoadedWallpaper(); } /** * If the current wallpaper is a live wallpaper component, return the * information about that wallpaper. Otherwise, if it is a static image, Loading Loading @@ -716,6 +737,7 @@ public class WallpaperManager { c.drawBitmap(bm, null, targetRect, paint); bm.recycle(); c.setBitmap(null); return newbm; } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); Loading
core/res/AndroidManifest.xml +0 −4 Original line number Diff line number Diff line Loading @@ -1504,10 +1504,6 @@ android:excludeFromRecents="true"> </activity> <service android:name="com.android.internal.service.wallpaper.ImageWallpaper" android:permission="android.permission.BIND_WALLPAPER"> </service> <receiver android:name="com.android.server.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> Loading
packages/SystemUI/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ <service android:name=".LoadAverageService" android:exported="true" /> <service android:name=".ImageWallpaper" android:permission="android.permission.BIND_WALLPAPER" android:exported="true" /> <receiver android:name=".BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> Loading
core/java/com/android/internal/service/wallpaper/ImageWallpaper.java→packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +48 −42 Original line number Diff line number Diff line Loading @@ -14,23 +14,19 @@ * limitations under the License. */ package com.android.internal.service.wallpaper; package com.android.systemui; import java.io.IOException; import com.android.internal.view.WindowManagerPolicyThread; import android.app.WallpaperManager; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.Region.Op; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Process; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.util.Slog; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.content.Context; Loading @@ -45,40 +41,27 @@ public class ImageWallpaper extends WallpaperService { private static final String TAG = "ImageWallpaper"; private static final boolean DEBUG = false; static final boolean FIXED_SIZED_SURFACE = true; WallpaperManager mWallpaperManager; private HandlerThread mThread; private Handler mHandler; @Override public void onCreate() { super.onCreate(); mWallpaperManager = (WallpaperManager) getSystemService(WALLPAPER_SERVICE); Looper looper = WindowManagerPolicyThread.getLooper(); if (looper == null) { mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND); mThread.start(); looper = mThread.getLooper(); } setCallbackLooper(looper); mHandler = new Handler(looper); mHandler = new Handler(); } public Engine onCreateEngine() { return new DrawableEngine(); } @Override public void onDestroy() { super.onDestroy(); if (mThread != null) { mThread.quit(); } } class DrawableEngine extends Engine { private final Object mLock = new Object(); private WallpaperObserver mReceiver; Drawable mBackground; int mBackgroundWidth = -1, mBackgroundHeight = -1; float mXOffset; float mYOffset; Loading @@ -95,7 +78,9 @@ public class ImageWallpaper extends WallpaperService { } synchronized (mLock) { updateWallpaperLocked(); mBackgroundWidth = mBackgroundHeight = -1; mBackground = null; mRedrawNeeded = true; drawFrameLocked(); } } Loading @@ -113,10 +98,6 @@ public class ImageWallpaper extends WallpaperService { registerReceiver(mReceiver, filter, null, mHandler); updateSurfaceSize(surfaceHolder); synchronized (mLock) { updateWallpaperLocked(); } } @Override Loading @@ -135,11 +116,14 @@ public class ImageWallpaper extends WallpaperService { } void updateSurfaceSize(SurfaceHolder surfaceHolder) { surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight()); if (FIXED_SIZED_SURFACE) { // Used a fixed size surface, because we are special. We can do // this because we know the current design of window animations doesn't // cause this to break. //surfaceHolder.setSizeFromLayout(); surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight()); } else { surfaceHolder.setSizeFromLayout(); } } @Override Loading Loading @@ -216,15 +200,18 @@ public class ImageWallpaper extends WallpaperService { return; } if (mBackgroundWidth < 0 || mBackgroundHeight < 0) { // If we don't yet know the size of the wallpaper bitmap, // we need to get it now. updateWallpaperLocked(); } SurfaceHolder sh = getSurfaceHolder(); final Rect frame = sh.getSurfaceFrame(); final Drawable background = mBackground; final int dw = frame.width(); final int dh = frame.height(); final int bw = background != null ? background.getIntrinsicWidth() : 0; final int bh = background != null ? background.getIntrinsicHeight() : 0; final int availw = dw - bw; final int availh = dh - bh; final int availw = dw - mBackgroundWidth; final int availh = dh - mBackgroundHeight; int xPixels = availw < 0 ? (int)(availw * mXOffset + .5f) : (availw / 2); int yPixels = availh < 0 ? (int)(availh * mYOffset + .5f) : (availh / 2); Loading @@ -241,6 +228,14 @@ public class ImageWallpaper extends WallpaperService { 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(); } //Slog.i(TAG, "************** DRAWING WALLAPER ******************"); Canvas c = sh.lockCanvas(); if (c != null) { try { Loading @@ -251,20 +246,30 @@ public class ImageWallpaper extends WallpaperService { c.translate(xPixels, yPixels); if (availw < 0 || availh < 0) { c.save(Canvas.CLIP_SAVE_FLAG); c.clipRect(0, 0, bw, bh, Op.DIFFERENCE); c.clipRect(0, 0, mBackgroundWidth, mBackgroundHeight, Op.DIFFERENCE); c.drawColor(0xff000000); c.restore(); } if (background != null) { background.draw(c); if (mBackground != null) { mBackground.draw(c); } } finally { sh.unlockCanvasAndPost(c); } } if (FIXED_SIZED_SURFACE) { // If the surface is fixed-size, we should only need to // draw it once and then we'll let the window manager // position it appropriately. As such, we no longer needed // the loaded bitmap. Yay! mBackground = null; mWallpaperManager.forgetLoadedWallpaper(); } } void updateWallpaperLocked() { //Slog.i(TAG, "************** LOADING WALLAPER ******************"); Throwable exception = null; try { mBackground = mWallpaperManager.getFastDrawable(); Loading @@ -286,7 +291,8 @@ public class ImageWallpaper extends WallpaperService { Log.w(TAG, "Unable reset to default wallpaper!", ex); } } mRedrawNeeded = true; mBackgroundWidth = mBackground != null ? mBackground.getIntrinsicWidth() : 0; mBackgroundHeight = mBackground != null ? mBackground.getIntrinsicHeight() : 0; } } }