Skip to content

Prevents a crash on wallpaper image decode when there is no memory available #17892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,19 @@ private static Bitmap getBitmapFromImagePath(String imagePath, BitmapFactory.Opt
imageBitmap = BitmapFactory.decodeStream(inputStream, null, options);
inputStream.close();
} catch (IOException exc) {
Log.e("NTP", exc.getMessage());
Log.e(TAG, "getBitmapFromImagePath: IOException: " + exc.getMessage());
} catch (IllegalArgumentException exc) {
Log.e("NTP", exc.getMessage());
Log.e(TAG, "getBitmapFromImagePath: IllegalArgumentException: " + exc.getMessage());
} catch (OutOfMemoryError exc) {
Log.e(TAG, "getBitmapFromImagePath: OutOfMemoryError: " + exc.getMessage());
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException exception) {
Log.e("NTP", exception.getMessage());
Log.e(TAG,
"getBitmapFromImagePath IOException in finally: " + exception.getMessage());
return null;
}
}
Expand Down Expand Up @@ -399,7 +402,7 @@ public static Bitmap getCalculatedBitmap(Bitmap imageBitmap, float centerPointX,
return bitmapWithGradient;
} catch (Exception exc) {
exc.printStackTrace();
Log.e("NTP", exc.getMessage());
Log.e(TAG, "getCalculatedBitmap: " + exc.getMessage());
return null;
} finally {
if (imageBitmap != null && !imageBitmap.isRecycled()) imageBitmap.recycle();
Expand All @@ -418,7 +421,7 @@ public static Bitmap getTopSiteBitmap(String iconPath) {
inputStream.close();
} catch (IOException exc) {
exc.printStackTrace();
Log.e("NTP", exc.getMessage());
Log.e(TAG, "getTopSiteBitmap IOException: " + exc.getMessage());
topSiteIcon = null;
} finally {
try {
Expand All @@ -427,7 +430,7 @@ public static Bitmap getTopSiteBitmap(String iconPath) {
}
} catch (IOException exception) {
exception.printStackTrace();
Log.e("NTP", exception.getMessage());
Log.e(TAG, "getTopSiteBitmap IOException in finally: " + exception.getMessage());
topSiteIcon = null;
}
}
Expand Down