Loading api/current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -13633,14 +13633,14 @@ package android.graphics { field public static final int ALLOCATOR_HARDWARE = 3; // 0x3 field public static final int ALLOCATOR_SHARED_MEMORY = 2; // 0x2 field public static final int ALLOCATOR_SOFTWARE = 1; // 0x1 field public static final int ERROR_SOURCE_ERROR = 3; // 0x3 field public static final int ERROR_SOURCE_EXCEPTION = 1; // 0x1 field public static final int ERROR_SOURCE_INCOMPLETE = 2; // 0x2 } public static final class ImageDecoder.DecodeException extends java.io.IOException { method public int getError(); method public android.graphics.ImageDecoder.Source getSource(); field public static final int SOURCE_EXCEPTION = 1; // 0x1 field public static final int SOURCE_INCOMPLETE = 2; // 0x2 field public static final int SOURCE_MALFORMED_DATA = 3; // 0x3 } public static class ImageDecoder.ImageInfo { api/removed.txt +3 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ package android.graphics { public final class ImageDecoder implements java.lang.AutoCloseable { method public deprecated boolean getAsAlphaMask(); method public deprecated android.graphics.ImageDecoder setAsAlphaMask(boolean); field public static final deprecated int ERROR_SOURCE_ERROR = 3; // 0x3 field public static final deprecated int ERROR_SOURCE_EXCEPTION = 1; // 0x1 field public static final deprecated int ERROR_SOURCE_INCOMPLETE = 2; // 0x2 } public static deprecated class ImageDecoder.IncompleteException extends java.io.IOException { Loading core/jni/android/graphics/ImageDecoder.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ static jobject throw_exception(JNIEnv* env, ImageDecoder::Error error, const cha static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobject source) { if (!stream.get()) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to create a stream", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream", nullptr, source); } std::unique_ptr<ImageDecoder> decoder(new ImageDecoder); Loading @@ -96,8 +96,8 @@ static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobj SkString msg; msg.printf("Failed to create image decoder with message '%s'", SkCodec::ResultToString(result)); return throw_exception(env, ImageDecoder::kSourceError, msg.c_str(), nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, msg.c_str(), nullptr, source); } } Loading @@ -110,7 +110,7 @@ static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobj decoder->mCodec = SkAndroidCodec::MakeFromCodec(std::move(codec), SkAndroidCodec::ExifOrientationBehavior::kRespect); if (!decoder->mCodec.get()) { return throw_exception(env, ImageDecoder::kSourceError, "", nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, "", nullptr, source); } const auto& info = decoder->mCodec->getInfo(); Loading @@ -127,7 +127,7 @@ static jobject ImageDecoder_nCreateFd(JNIEnv* env, jobject /*clazz*/, struct stat fdStat; if (fstat(descriptor, &fdStat) == -1) { return throw_exception(env, ImageDecoder::kSourceError, return throw_exception(env, ImageDecoder::kSourceMalformedData, "broken file descriptor; fstat returned -1", nullptr, source); } Loading @@ -135,8 +135,8 @@ static jobject ImageDecoder_nCreateFd(JNIEnv* env, jobject /*clazz*/, FILE* file = fdopen(dupDescriptor, "r"); if (file == NULL) { close(dupDescriptor); return throw_exception(env, ImageDecoder::kSourceError, "Could not open file", nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, "Could not open file", nullptr, source); } std::unique_ptr<SkFILEStream> fileStream(new SkFILEStream(file)); Loading @@ -157,7 +157,7 @@ static jobject ImageDecoder_nCreateInputStream(JNIEnv* env, jobject /*clazz*/, std::unique_ptr<SkStream> stream(CreateJavaInputStreamAdaptor(env, is, storage, false)); if (!stream.get()) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to create a stream", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream", nullptr, source); } Loading @@ -179,7 +179,7 @@ static jobject ImageDecoder_nCreateByteBuffer(JNIEnv* env, jobject /*clazz*/, jo std::unique_ptr<SkStream> stream = CreateByteBufferStreamAdaptor(env, jbyteBuffer, initialPosition, limit); if (!stream) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to read ByteBuffer", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to read ByteBuffer", nullptr, source); } return native_create(env, std::move(stream), source); Loading Loading @@ -313,7 +313,7 @@ static jobject ImageDecoder_nDecodeBitmap(JNIEnv* env, jobject /*clazz*/, jlong break; case SkCodec::kErrorInInput: if (!jexception) { onPartialImageError = ImageDecoder::kSourceError; onPartialImageError = ImageDecoder::kSourceMalformedData; } break; default: Loading core/jni/android/graphics/ImageDecoder.h +3 −3 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ struct ImageDecoder { enum Error { kSourceException = 1, kSourceIncomplete = 2, kSourceError = 3, kSourceMalformedData = 3, }; // These need to stay in sync with PixelFormat.java's Format constants. Loading graphics/java/android/graphics/ImageDecoder.java +35 −17 Original line number Diff line number Diff line Loading @@ -457,31 +457,49 @@ public final class ImageDecoder implements AutoCloseable { }; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_EXCEPTION}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_EXCEPTION = 1; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_INCOMPLETE}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_INCOMPLETE = 2; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_MALFORMED_DATA}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_ERROR = 3; /** * Information about an interrupted decode. */ public static final class DecodeException extends IOException { /** * An Exception was thrown reading the {@link Source}. */ public static final int ERROR_SOURCE_EXCEPTION = 1; public static final int SOURCE_EXCEPTION = 1; /** * The encoded data was incomplete. */ public static final int ERROR_SOURCE_INCOMPLETE = 2; public static final int SOURCE_INCOMPLETE = 2; /** * The encoded data contained an error. */ public static final int ERROR_SOURCE_ERROR = 3; public static final int SOURCE_MALFORMED_DATA = 3; /** @hide **/ @Retention(SOURCE) @IntDef(value = { ERROR_SOURCE_EXCEPTION, ERROR_SOURCE_INCOMPLETE, ERROR_SOURCE_ERROR }, prefix = {"ERROR_"}) @IntDef(value = { SOURCE_EXCEPTION, SOURCE_INCOMPLETE, SOURCE_MALFORMED_DATA }, prefix = {"SOURCE_"}) public @interface Error {}; /** * Information about an interrupted decode. */ public static final class DecodeException extends IOException { @Error final int mError; @NonNull final Source mSource; Loading @@ -505,7 +523,7 @@ public final class ImageDecoder implements AutoCloseable { /** * Retrieve the reason that decoding was interrupted. * * <p>If the error is {@link #ERROR_SOURCE_EXCEPTION}, the underlying * <p>If the error is {@link #SOURCE_EXCEPTION}, the underlying * {@link java.lang.Throwable} can be retrieved with * {@link java.lang.Throwable#getCause}.</p> */ Loading @@ -524,11 +542,11 @@ public final class ImageDecoder implements AutoCloseable { private static String errorMessage(@Error int error, @Nullable Throwable cause) { switch (error) { case ERROR_SOURCE_EXCEPTION: case SOURCE_EXCEPTION: return "Exception in input: " + cause; case ERROR_SOURCE_INCOMPLETE: case SOURCE_INCOMPLETE: return "Input was incomplete."; case ERROR_SOURCE_ERROR: case SOURCE_MALFORMED_DATA: return "Input contained an error."; default: return ""; Loading Loading @@ -1368,7 +1386,7 @@ public final class ImageDecoder implements AutoCloseable { * Private method called by JNI. */ @SuppressWarnings("unused") private void onPartialImage(@Error int error, @Nullable Throwable cause) private void onPartialImage(@DecodeException.Error int error, @Nullable Throwable cause) throws DecodeException { DecodeException exception = new DecodeException(error, cause, mSource); if (mOnPartialImageListener == null Loading Loading
api/current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -13633,14 +13633,14 @@ package android.graphics { field public static final int ALLOCATOR_HARDWARE = 3; // 0x3 field public static final int ALLOCATOR_SHARED_MEMORY = 2; // 0x2 field public static final int ALLOCATOR_SOFTWARE = 1; // 0x1 field public static final int ERROR_SOURCE_ERROR = 3; // 0x3 field public static final int ERROR_SOURCE_EXCEPTION = 1; // 0x1 field public static final int ERROR_SOURCE_INCOMPLETE = 2; // 0x2 } public static final class ImageDecoder.DecodeException extends java.io.IOException { method public int getError(); method public android.graphics.ImageDecoder.Source getSource(); field public static final int SOURCE_EXCEPTION = 1; // 0x1 field public static final int SOURCE_INCOMPLETE = 2; // 0x2 field public static final int SOURCE_MALFORMED_DATA = 3; // 0x3 } public static class ImageDecoder.ImageInfo {
api/removed.txt +3 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ package android.graphics { public final class ImageDecoder implements java.lang.AutoCloseable { method public deprecated boolean getAsAlphaMask(); method public deprecated android.graphics.ImageDecoder setAsAlphaMask(boolean); field public static final deprecated int ERROR_SOURCE_ERROR = 3; // 0x3 field public static final deprecated int ERROR_SOURCE_EXCEPTION = 1; // 0x1 field public static final deprecated int ERROR_SOURCE_INCOMPLETE = 2; // 0x2 } public static deprecated class ImageDecoder.IncompleteException extends java.io.IOException { Loading
core/jni/android/graphics/ImageDecoder.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ static jobject throw_exception(JNIEnv* env, ImageDecoder::Error error, const cha static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobject source) { if (!stream.get()) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to create a stream", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream", nullptr, source); } std::unique_ptr<ImageDecoder> decoder(new ImageDecoder); Loading @@ -96,8 +96,8 @@ static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobj SkString msg; msg.printf("Failed to create image decoder with message '%s'", SkCodec::ResultToString(result)); return throw_exception(env, ImageDecoder::kSourceError, msg.c_str(), nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, msg.c_str(), nullptr, source); } } Loading @@ -110,7 +110,7 @@ static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream, jobj decoder->mCodec = SkAndroidCodec::MakeFromCodec(std::move(codec), SkAndroidCodec::ExifOrientationBehavior::kRespect); if (!decoder->mCodec.get()) { return throw_exception(env, ImageDecoder::kSourceError, "", nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, "", nullptr, source); } const auto& info = decoder->mCodec->getInfo(); Loading @@ -127,7 +127,7 @@ static jobject ImageDecoder_nCreateFd(JNIEnv* env, jobject /*clazz*/, struct stat fdStat; if (fstat(descriptor, &fdStat) == -1) { return throw_exception(env, ImageDecoder::kSourceError, return throw_exception(env, ImageDecoder::kSourceMalformedData, "broken file descriptor; fstat returned -1", nullptr, source); } Loading @@ -135,8 +135,8 @@ static jobject ImageDecoder_nCreateFd(JNIEnv* env, jobject /*clazz*/, FILE* file = fdopen(dupDescriptor, "r"); if (file == NULL) { close(dupDescriptor); return throw_exception(env, ImageDecoder::kSourceError, "Could not open file", nullptr, source); return throw_exception(env, ImageDecoder::kSourceMalformedData, "Could not open file", nullptr, source); } std::unique_ptr<SkFILEStream> fileStream(new SkFILEStream(file)); Loading @@ -157,7 +157,7 @@ static jobject ImageDecoder_nCreateInputStream(JNIEnv* env, jobject /*clazz*/, std::unique_ptr<SkStream> stream(CreateJavaInputStreamAdaptor(env, is, storage, false)); if (!stream.get()) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to create a stream", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream", nullptr, source); } Loading @@ -179,7 +179,7 @@ static jobject ImageDecoder_nCreateByteBuffer(JNIEnv* env, jobject /*clazz*/, jo std::unique_ptr<SkStream> stream = CreateByteBufferStreamAdaptor(env, jbyteBuffer, initialPosition, limit); if (!stream) { return throw_exception(env, ImageDecoder::kSourceError, "Failed to read ByteBuffer", return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to read ByteBuffer", nullptr, source); } return native_create(env, std::move(stream), source); Loading Loading @@ -313,7 +313,7 @@ static jobject ImageDecoder_nDecodeBitmap(JNIEnv* env, jobject /*clazz*/, jlong break; case SkCodec::kErrorInInput: if (!jexception) { onPartialImageError = ImageDecoder::kSourceError; onPartialImageError = ImageDecoder::kSourceMalformedData; } break; default: Loading
core/jni/android/graphics/ImageDecoder.h +3 −3 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ struct ImageDecoder { enum Error { kSourceException = 1, kSourceIncomplete = 2, kSourceError = 3, kSourceMalformedData = 3, }; // These need to stay in sync with PixelFormat.java's Format constants. Loading
graphics/java/android/graphics/ImageDecoder.java +35 −17 Original line number Diff line number Diff line Loading @@ -457,31 +457,49 @@ public final class ImageDecoder implements AutoCloseable { }; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_EXCEPTION}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_EXCEPTION = 1; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_INCOMPLETE}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_INCOMPLETE = 2; /** @removed * @deprecated Replaced by {@link #DecodeException#SOURCE_MALFORMED_DATA}. */ @java.lang.Deprecated public static final int ERROR_SOURCE_ERROR = 3; /** * Information about an interrupted decode. */ public static final class DecodeException extends IOException { /** * An Exception was thrown reading the {@link Source}. */ public static final int ERROR_SOURCE_EXCEPTION = 1; public static final int SOURCE_EXCEPTION = 1; /** * The encoded data was incomplete. */ public static final int ERROR_SOURCE_INCOMPLETE = 2; public static final int SOURCE_INCOMPLETE = 2; /** * The encoded data contained an error. */ public static final int ERROR_SOURCE_ERROR = 3; public static final int SOURCE_MALFORMED_DATA = 3; /** @hide **/ @Retention(SOURCE) @IntDef(value = { ERROR_SOURCE_EXCEPTION, ERROR_SOURCE_INCOMPLETE, ERROR_SOURCE_ERROR }, prefix = {"ERROR_"}) @IntDef(value = { SOURCE_EXCEPTION, SOURCE_INCOMPLETE, SOURCE_MALFORMED_DATA }, prefix = {"SOURCE_"}) public @interface Error {}; /** * Information about an interrupted decode. */ public static final class DecodeException extends IOException { @Error final int mError; @NonNull final Source mSource; Loading @@ -505,7 +523,7 @@ public final class ImageDecoder implements AutoCloseable { /** * Retrieve the reason that decoding was interrupted. * * <p>If the error is {@link #ERROR_SOURCE_EXCEPTION}, the underlying * <p>If the error is {@link #SOURCE_EXCEPTION}, the underlying * {@link java.lang.Throwable} can be retrieved with * {@link java.lang.Throwable#getCause}.</p> */ Loading @@ -524,11 +542,11 @@ public final class ImageDecoder implements AutoCloseable { private static String errorMessage(@Error int error, @Nullable Throwable cause) { switch (error) { case ERROR_SOURCE_EXCEPTION: case SOURCE_EXCEPTION: return "Exception in input: " + cause; case ERROR_SOURCE_INCOMPLETE: case SOURCE_INCOMPLETE: return "Input was incomplete."; case ERROR_SOURCE_ERROR: case SOURCE_MALFORMED_DATA: return "Input contained an error."; default: return ""; Loading Loading @@ -1368,7 +1386,7 @@ public final class ImageDecoder implements AutoCloseable { * Private method called by JNI. */ @SuppressWarnings("unused") private void onPartialImage(@Error int error, @Nullable Throwable cause) private void onPartialImage(@DecodeException.Error int error, @Nullable Throwable cause) throws DecodeException { DecodeException exception = new DecodeException(error, cause, mSource); if (mOnPartialImageListener == null Loading