Loading core/java/android/app/WallpaperManager.java +66 −100 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -115,7 +117,9 @@ public class WallpaperManager { @Override public void draw(Canvas canvas) { canvas.drawBitmap(mBitmap, mDrawLeft, mDrawTop, null); Paint paint = new Paint(); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); canvas.drawBitmap(mBitmap, mDrawLeft, mDrawTop, paint); } @Override Loading Loading @@ -246,39 +250,19 @@ public class WallpaperManager { int width = params.getInt("width", 0); int height = params.getInt("height", 0); if (width <= 0 || height <= 0) { // Degenerate case: no size requested, just load // bitmap as-is. Bitmap bm = null; try { bm = BitmapFactory.decodeFileDescriptor( fd.getFileDescriptor(), null, null); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode file", e); } try { fd.close(); } catch (IOException e) { } if (bm != null) { bm.setDensity(DisplayMetrics.DENSITY_DEVICE); } return bm; } // Load the bitmap with full color depth, to preserve // quality for later processing. BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bm = BitmapFactory.decodeFileDescriptor( fd.getFileDescriptor(), null, options); return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode file", e); } finally { try { fd.close(); } catch (IOException e) { } return generateBitmap(context, bm, width, height); } } } catch (RemoteException e) { } Loading @@ -293,41 +277,17 @@ public class WallpaperManager { int width = mService.getWidthHint(); int height = mService.getHeightHint(); if (width <= 0 || height <= 0) { // Degenerate case: no size requested, just load // bitmap as-is. Bitmap bm = null; try { bm = BitmapFactory.decodeStream(is, null, null); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode stream", e); } try { is.close(); } catch (IOException e) { } if (bm != null) { bm.setDensity(DisplayMetrics.DENSITY_DEVICE); } return bm; } // Load the bitmap with full color depth, to preserve // quality for later processing. BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bm = BitmapFactory.decodeStream(is, null, options); return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode stream", e); } finally { try { is.close(); } catch (IOException e) { } try { return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); return bm; } } } catch (RemoteException e) { Loading Loading @@ -711,20 +671,22 @@ public class WallpaperManager { static Bitmap generateBitmap(Context context, Bitmap bm, int width, int height) { if (bm == null) { return bm; return null; } bm.setDensity(DisplayMetrics.DENSITY_DEVICE); if (bm.getWidth() == width && bm.getHeight() == height) { return bm; } // This is the final bitmap we want to return. // XXX We should get the pixel depth from the system (to match the // physical display depth), when there is a way. Bitmap newbm = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); try { Bitmap newbm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); newbm.setDensity(DisplayMetrics.DENSITY_DEVICE); Canvas c = new Canvas(newbm); c.setDensity(DisplayMetrics.DENSITY_DEVICE); Rect targetRect = new Rect(); targetRect.left = targetRect.top = 0; targetRect.right = bm.getWidth(); targetRect.bottom = bm.getHeight(); Loading @@ -732,8 +694,7 @@ public class WallpaperManager { int deltah = height - targetRect.bottom; if (deltaw > 0 || deltah > 0) { // We need to scale up so it covers the entire // area. // We need to scale up so it covers the entire area. float scale = 1.0f; if (deltaw > deltah) { scale = width / (float)targetRect.right; Loading @@ -747,12 +708,17 @@ public class WallpaperManager { } targetRect.offset(deltaw/2, deltah/2); Paint paint = new Paint(); paint.setFilterBitmap(true); paint.setDither(true); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); c.drawBitmap(bm, null, targetRect, paint); bm.recycle(); return newbm; } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); return bm; } } } core/java/android/service/wallpaper/WallpaperService.java +1 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public abstract class WallpaperService extends Service { final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { { mRequestedFormat = PixelFormat.RGB_565; mRequestedFormat = PixelFormat.RGBX_8888; } @Override Loading core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +7 −9 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ 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; Loading @@ -46,19 +47,20 @@ public class ImageWallpaper extends WallpaperService { 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) { setCallbackLooper(looper); } else { if (looper == null) { mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND); mThread.start(); setCallbackLooper(mThread.getLooper()); looper = mThread.getLooper(); } setCallbackLooper(looper); mHandler = new Handler(looper); } public Engine onCreateEngine() { Loading Loading @@ -96,10 +98,6 @@ public class ImageWallpaper extends WallpaperService { updateWallpaperLocked(); drawFrameLocked(); } // Assume we are the only one using the wallpaper in this // process, and force a GC now to release the old wallpaper. System.gc(); } } Loading @@ -112,7 +110,7 @@ public class ImageWallpaper extends WallpaperService { super.onCreate(surfaceHolder); IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); mReceiver = new WallpaperObserver(); registerReceiver(mReceiver, filter); registerReceiver(mReceiver, filter, null, mHandler); updateSurfaceSize(surfaceHolder); Loading services/java/com/android/server/wm/WindowManagerService.java +5 −18 Original line number Diff line number Diff line Loading @@ -428,7 +428,6 @@ public class WindowManagerService extends IWindowManager.Stub boolean mDisplayFrozen = false; boolean mWaitingForConfig = false; boolean mWindowsFreezingScreen = false; long mFreezeGcPending = 0; int mAppsFreezingScreen = 0; int mLastWindowForcedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -4975,9 +4974,11 @@ public class WindowManagerService extends IWindowManager.Stub * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN. */ public boolean setRotationUncheckedLocked(int rotation, int animFlags, boolean inTransaction) { if (mDragState != null || mScreenRotationAnimation != null) { // Potential rotation during a drag. Don't do the rotation now, but make // a note to perform the rotation later. if (mDragState != null || (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating())) { // Potential rotation during a drag or while waiting for a previous orientation // change to finish (rotation animation will be dismissed). // Don't do the rotation now, but make a note to perform the rotation later. if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation."); if (rotation != WindowManagerPolicy.USE_LAST_ROTATION) { mDeferredRotation = rotation; Loading Loading @@ -6435,7 +6436,6 @@ public class WindowManagerService extends IWindowManager.Stub if (mDisplayFrozen) { return; } mFreezeGcPending = 0; } Runtime.getRuntime().gc(); break; Loading Loading @@ -8653,19 +8653,6 @@ public class WindowManagerService extends IWindowManager.Stub mScreenFrozenLock.acquire(); long now = SystemClock.uptimeMillis(); //Slog.i(TAG, "Freezing, gc pending: " + mFreezeGcPending + ", now " + now); if (mFreezeGcPending != 0) { if (now > (mFreezeGcPending+1000)) { //Slog.i(TAG, "Gc! " + now + " > " + (mFreezeGcPending+1000)); mH.removeMessages(H.FORCE_GC); Runtime.getRuntime().gc(); mFreezeGcPending = now; } } else { mFreezeGcPending = now; } mDisplayFrozen = true; mInputMonitor.freezeInputDispatchingLw(); Loading Loading
core/java/android/app/WallpaperManager.java +66 −100 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -115,7 +117,9 @@ public class WallpaperManager { @Override public void draw(Canvas canvas) { canvas.drawBitmap(mBitmap, mDrawLeft, mDrawTop, null); Paint paint = new Paint(); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); canvas.drawBitmap(mBitmap, mDrawLeft, mDrawTop, paint); } @Override Loading Loading @@ -246,39 +250,19 @@ public class WallpaperManager { int width = params.getInt("width", 0); int height = params.getInt("height", 0); if (width <= 0 || height <= 0) { // Degenerate case: no size requested, just load // bitmap as-is. Bitmap bm = null; try { bm = BitmapFactory.decodeFileDescriptor( fd.getFileDescriptor(), null, null); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode file", e); } try { fd.close(); } catch (IOException e) { } if (bm != null) { bm.setDensity(DisplayMetrics.DENSITY_DEVICE); } return bm; } // Load the bitmap with full color depth, to preserve // quality for later processing. BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bm = BitmapFactory.decodeFileDescriptor( fd.getFileDescriptor(), null, options); return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode file", e); } finally { try { fd.close(); } catch (IOException e) { } return generateBitmap(context, bm, width, height); } } } catch (RemoteException e) { } Loading @@ -293,41 +277,17 @@ public class WallpaperManager { int width = mService.getWidthHint(); int height = mService.getHeightHint(); if (width <= 0 || height <= 0) { // Degenerate case: no size requested, just load // bitmap as-is. Bitmap bm = null; try { bm = BitmapFactory.decodeStream(is, null, null); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode stream", e); } try { is.close(); } catch (IOException e) { } if (bm != null) { bm.setDensity(DisplayMetrics.DENSITY_DEVICE); } return bm; } // Load the bitmap with full color depth, to preserve // quality for later processing. BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bm = BitmapFactory.decodeStream(is, null, options); return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode stream", e); } finally { try { is.close(); } catch (IOException e) { } try { return generateBitmap(context, bm, width, height); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); return bm; } } } catch (RemoteException e) { Loading Loading @@ -711,20 +671,22 @@ public class WallpaperManager { static Bitmap generateBitmap(Context context, Bitmap bm, int width, int height) { if (bm == null) { return bm; return null; } bm.setDensity(DisplayMetrics.DENSITY_DEVICE); if (bm.getWidth() == width && bm.getHeight() == height) { return bm; } // This is the final bitmap we want to return. // XXX We should get the pixel depth from the system (to match the // physical display depth), when there is a way. Bitmap newbm = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); try { Bitmap newbm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); newbm.setDensity(DisplayMetrics.DENSITY_DEVICE); Canvas c = new Canvas(newbm); c.setDensity(DisplayMetrics.DENSITY_DEVICE); Rect targetRect = new Rect(); targetRect.left = targetRect.top = 0; targetRect.right = bm.getWidth(); targetRect.bottom = bm.getHeight(); Loading @@ -732,8 +694,7 @@ public class WallpaperManager { int deltah = height - targetRect.bottom; if (deltaw > 0 || deltah > 0) { // We need to scale up so it covers the entire // area. // We need to scale up so it covers the entire area. float scale = 1.0f; if (deltaw > deltah) { scale = width / (float)targetRect.right; Loading @@ -747,12 +708,17 @@ public class WallpaperManager { } targetRect.offset(deltaw/2, deltah/2); Paint paint = new Paint(); paint.setFilterBitmap(true); paint.setDither(true); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); c.drawBitmap(bm, null, targetRect, paint); bm.recycle(); return newbm; } catch (OutOfMemoryError e) { Log.w(TAG, "Can't generate default bitmap", e); return bm; } } }
core/java/android/service/wallpaper/WallpaperService.java +1 −1 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public abstract class WallpaperService extends Service { final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { { mRequestedFormat = PixelFormat.RGB_565; mRequestedFormat = PixelFormat.RGBX_8888; } @Override Loading
core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +7 −9 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ 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; Loading @@ -46,19 +47,20 @@ public class ImageWallpaper extends WallpaperService { 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) { setCallbackLooper(looper); } else { if (looper == null) { mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND); mThread.start(); setCallbackLooper(mThread.getLooper()); looper = mThread.getLooper(); } setCallbackLooper(looper); mHandler = new Handler(looper); } public Engine onCreateEngine() { Loading Loading @@ -96,10 +98,6 @@ public class ImageWallpaper extends WallpaperService { updateWallpaperLocked(); drawFrameLocked(); } // Assume we are the only one using the wallpaper in this // process, and force a GC now to release the old wallpaper. System.gc(); } } Loading @@ -112,7 +110,7 @@ public class ImageWallpaper extends WallpaperService { super.onCreate(surfaceHolder); IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); mReceiver = new WallpaperObserver(); registerReceiver(mReceiver, filter); registerReceiver(mReceiver, filter, null, mHandler); updateSurfaceSize(surfaceHolder); Loading
services/java/com/android/server/wm/WindowManagerService.java +5 −18 Original line number Diff line number Diff line Loading @@ -428,7 +428,6 @@ public class WindowManagerService extends IWindowManager.Stub boolean mDisplayFrozen = false; boolean mWaitingForConfig = false; boolean mWindowsFreezingScreen = false; long mFreezeGcPending = 0; int mAppsFreezingScreen = 0; int mLastWindowForcedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -4975,9 +4974,11 @@ public class WindowManagerService extends IWindowManager.Stub * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN. */ public boolean setRotationUncheckedLocked(int rotation, int animFlags, boolean inTransaction) { if (mDragState != null || mScreenRotationAnimation != null) { // Potential rotation during a drag. Don't do the rotation now, but make // a note to perform the rotation later. if (mDragState != null || (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating())) { // Potential rotation during a drag or while waiting for a previous orientation // change to finish (rotation animation will be dismissed). // Don't do the rotation now, but make a note to perform the rotation later. if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation."); if (rotation != WindowManagerPolicy.USE_LAST_ROTATION) { mDeferredRotation = rotation; Loading Loading @@ -6435,7 +6436,6 @@ public class WindowManagerService extends IWindowManager.Stub if (mDisplayFrozen) { return; } mFreezeGcPending = 0; } Runtime.getRuntime().gc(); break; Loading Loading @@ -8653,19 +8653,6 @@ public class WindowManagerService extends IWindowManager.Stub mScreenFrozenLock.acquire(); long now = SystemClock.uptimeMillis(); //Slog.i(TAG, "Freezing, gc pending: " + mFreezeGcPending + ", now " + now); if (mFreezeGcPending != 0) { if (now > (mFreezeGcPending+1000)) { //Slog.i(TAG, "Gc! " + now + " > " + (mFreezeGcPending+1000)); mH.removeMessages(H.FORCE_GC); Runtime.getRuntime().gc(); mFreezeGcPending = now; } } else { mFreezeGcPending = now; } mDisplayFrozen = true; mInputMonitor.freezeInputDispatchingLw(); Loading