Loading core/java/com/android/internal/widget/LocalImageResolver.java +23 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.util.Size; import com.android.internal.annotations.VisibleForTesting; import java.io.IOException; import java.util.Locale; /** A class to extract Drawables from a MessagingStyle/ConversationStyle message. */ public class LocalImageResolver { Loading Loading @@ -259,6 +260,28 @@ public class LocalImageResolver { int maxWidth, int maxHeight) { final Size size = info.getSize(); final String mimeType = info.getMimeType(); boolean isAllowedCodec = false; if (mimeType != null) { switch (mimeType.toLowerCase(Locale.US)) { case "image/png": case "image/jpeg": case "image/webp": case "image/gif": case "image/bmp": case "image/x-ico": case "image/vnd.wap.wbmp": case "image/heif": case "image/heic": case "image/avif": isAllowedCodec = true; break; } } if (!isAllowedCodec) { throw new RuntimeException("Image mime type (" + mimeType + ") is not allowed."); } if (size.getWidth() > DEFAULT_DECODE_HARD_LIMIT_PX || size.getHeight() > DEFAULT_DECODE_HARD_LIMIT_PX) { // The image is larger than what we can reasonably expect to decode without filling up Loading core/tests/coretests/res/raw/dng_opcode_MapTable_ProcessArea.png 0 → 100644 +85.4 KiB Loading image diff... core/tests/coretests/src/com/android/internal/widget/LocalImageResolverTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -334,4 +334,12 @@ public class LocalImageResolverTest { Icon icon = Icon.createWithResource("invalid.package", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } @Test(expected = IOException.class) public void resolveImage_asset_invalidMimeType() throws IOException { // dng mimetype is not supported Uri uri = Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.dng_opcode_MapTable_ProcessArea); LocalImageResolver.resolveImage(uri, mContext); } } Loading
core/java/com/android/internal/widget/LocalImageResolver.java +23 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.util.Size; import com.android.internal.annotations.VisibleForTesting; import java.io.IOException; import java.util.Locale; /** A class to extract Drawables from a MessagingStyle/ConversationStyle message. */ public class LocalImageResolver { Loading Loading @@ -259,6 +260,28 @@ public class LocalImageResolver { int maxWidth, int maxHeight) { final Size size = info.getSize(); final String mimeType = info.getMimeType(); boolean isAllowedCodec = false; if (mimeType != null) { switch (mimeType.toLowerCase(Locale.US)) { case "image/png": case "image/jpeg": case "image/webp": case "image/gif": case "image/bmp": case "image/x-ico": case "image/vnd.wap.wbmp": case "image/heif": case "image/heic": case "image/avif": isAllowedCodec = true; break; } } if (!isAllowedCodec) { throw new RuntimeException("Image mime type (" + mimeType + ") is not allowed."); } if (size.getWidth() > DEFAULT_DECODE_HARD_LIMIT_PX || size.getHeight() > DEFAULT_DECODE_HARD_LIMIT_PX) { // The image is larger than what we can reasonably expect to decode without filling up Loading
core/tests/coretests/res/raw/dng_opcode_MapTable_ProcessArea.png 0 → 100644 +85.4 KiB Loading image diff...
core/tests/coretests/src/com/android/internal/widget/LocalImageResolverTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -334,4 +334,12 @@ public class LocalImageResolverTest { Icon icon = Icon.createWithResource("invalid.package", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } @Test(expected = IOException.class) public void resolveImage_asset_invalidMimeType() throws IOException { // dng mimetype is not supported Uri uri = Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.dng_opcode_MapTable_ProcessArea); LocalImageResolver.resolveImage(uri, mContext); } }