Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Trebuchet: Commit

packages/apps/Trebuchet


Commit MetaInfo

Révision273db439991b7230f1adbf4502bc5f1ce01b211c (tree)
l'heure2017-05-27 07:16:14
AuteurTony Wickham <twickham@goog...>
CommiterArne Coucheron

Message de Log

Handle OutOfMemoryException gracefully in WallpaperCropActivity.

Now instead of crashing, it says "Couldn't load image."

Bug: 25326319
Change-Id: I6918b7b34e0a9b40036b1405fc449c10c2e1d40a

Change Summary

Modification

--- a/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java
+++ b/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java
@@ -159,6 +159,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
159159 public enum State { NOT_LOADED, LOADED, ERROR_LOADING };
160160 private State mState = State.NOT_LOADED;
161161
162+ /** Returns whether loading was successful. */
162163 public boolean loadInBackground(InBitmapProvider bitmapProvider) {
163164 ExifInterface ei = new ExifInterface();
164165 if (readExif(ei)) {
@@ -193,7 +194,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
193194 try {
194195 mPreview = loadPreviewBitmap(opts);
195196 } catch (IllegalArgumentException e) {
196- Log.d(TAG, "Unable to reusage bitmap", e);
197+ Log.d(TAG, "Unable to reuse bitmap", e);
197198 opts.inBitmap = null;
198199 mPreview = null;
199200 }
@@ -202,6 +203,10 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
202203 if (mPreview == null) {
203204 mPreview = loadPreviewBitmap(opts);
204205 }
206+ if (mPreview == null) {
207+ mState = State.ERROR_LOADING;
208+ return false;
209+ }
205210
206211 // Verify that the bitmap can be used on GL surface
207212 try {
@@ -212,7 +217,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
212217 Log.d(TAG, "Image cannot be rendered on a GL surface", e);
213218 mState = State.ERROR_LOADING;
214219 }
215- return true;
220+ return mState == State.LOADED;
216221 }
217222 }
218223
@@ -310,7 +315,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
310315 Bitmap b = BitmapFactory.decodeStream(is, null, options);
311316 Utils.closeSilently(is);
312317 return b;
313- } catch (FileNotFoundException e) {
318+ } catch (FileNotFoundException | OutOfMemoryError e) {
314319 Log.e("BitmapRegionTileSource", "Failed to load URI " + mUri, e);
315320 return null;
316321 }
@@ -412,7 +417,8 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
412417 "Failed to create preview of apropriate size! "
413418 + " in: %dx%d, out: %dx%d",
414419 mWidth, mHeight,
415- preview.getWidth(), preview.getHeight()));
420+ preview == null ? -1 : preview.getWidth(),
421+ preview == null ? -1 : preview.getHeight()));
416422 }
417423 }
418424 }
Afficher sur ancien navigateur de dépôt.