am 34d723d8: Merge change I32371166 into eclair
Merge commit '34d723d8fa75e8f97401311e03b3839246143018' into eclair-mr2 * commit '34d723d8fa75e8f97401311e03b3839246143018': Fix issue #2239203: Setting large background causes OOME and soft-reboot spiral
This commit is contained in:
@@ -195,7 +195,12 @@ public class WallpaperManager {
|
|||||||
if (mDefaultWallpaper != null) {
|
if (mDefaultWallpaper != null) {
|
||||||
return mDefaultWallpaper;
|
return mDefaultWallpaper;
|
||||||
}
|
}
|
||||||
|
mWallpaper = null;
|
||||||
|
try {
|
||||||
mWallpaper = getCurrentWallpaperLocked(context);
|
mWallpaper = getCurrentWallpaperLocked(context);
|
||||||
|
} catch (OutOfMemoryError e) {
|
||||||
|
Log.w(TAG, "No memory load current wallpaper", e);
|
||||||
|
}
|
||||||
if (mWallpaper == null && returnDefault) {
|
if (mWallpaper == null && returnDefault) {
|
||||||
mDefaultWallpaper = getDefaultWallpaperLocked(context);
|
mDefaultWallpaper = getDefaultWallpaperLocked(context);
|
||||||
return mDefaultWallpaper;
|
return mDefaultWallpaper;
|
||||||
@@ -279,7 +284,12 @@ public class WallpaperManager {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
return generateBitmap(context, bm, width, height);
|
return generateBitmap(context, bm, width, height);
|
||||||
|
} catch (OutOfMemoryError e) {
|
||||||
|
Log.w(TAG, "Can't generate default bitmap", e);
|
||||||
|
return bm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.service.wallpaper.WallpaperService;
|
import android.service.wallpaper.WallpaperService;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -134,8 +135,8 @@ public class ImageWallpaper extends WallpaperService {
|
|||||||
final Drawable background = mBackground;
|
final Drawable background = mBackground;
|
||||||
final int dw = frame.width();
|
final int dw = frame.width();
|
||||||
final int dh = frame.height();
|
final int dh = frame.height();
|
||||||
final int bw = mBackground.getIntrinsicWidth();
|
final int bw = background != null ? background.getIntrinsicWidth() : 0;
|
||||||
final int bh = mBackground.getIntrinsicHeight();
|
final int bh = background != null ? background.getIntrinsicHeight() : 0;
|
||||||
final int availw = dw-bw;
|
final int availw = dw-bw;
|
||||||
final int availh = dh-bh;
|
final int availh = dh-bh;
|
||||||
int xPixels = availw < 0 ? (int)(availw*mXOffset+.5f) : (availw/2);
|
int xPixels = availw < 0 ? (int)(availw*mXOffset+.5f) : (availw/2);
|
||||||
@@ -148,15 +149,21 @@ public class ImageWallpaper extends WallpaperService {
|
|||||||
c.drawColor(0xff000000);
|
c.drawColor(0xff000000);
|
||||||
c.restore();
|
c.restore();
|
||||||
}
|
}
|
||||||
|
if (background != null) {
|
||||||
background.draw(c);
|
background.draw(c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sh.unlockCanvasAndPost(c);
|
sh.unlockCanvasAndPost(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWallpaper() {
|
void updateWallpaper() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
try {
|
||||||
mBackground = mWallpaperManager.getFastDrawable();
|
mBackground = mWallpaperManager.getFastDrawable();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Log.w("ImageWallpaper", "Unable to load wallpaper!", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user