MD5 校验值:230b791cc707d42fd585468f66a30851
a.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package c.m.a; import android.content.res.AssetManager; import android.media.MediaDataSource; import android.media.MediaMetadataRetriever; import android.os.Build; import android.system.OsConstants; import android.util.Log; import c.m.a.b; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.EOFException; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.TimeZone; import java.util.regex.Pattern; import java.util.zip.CRC32; public class a { private static SimpleDateFormat A; private static final d[] E; private static final d[] F; private static final d[] G; private static final d[] H; private static final d[] I; private static final d J; private static final d[] K; private static final d[] L; private static final d[] M; private static final d[] N; static final d[][] O; private static final d[] P; private static final HashMap<Integer, d>[] Q; private static final HashMap<String, d>[] R; private static final HashSet<String> S; private static final HashMap<Integer, Integer> T; static final Charset U; static final byte[] V; private static final byte[] W; private static final Pattern X; private static final Pattern Y; private static final Pattern Z; private static final Pattern a0; private static SimpleDateFormat z; private String b0; private FileDescriptor c0; private AssetManager.AssetInputStream d0; private int e0; private boolean f0; private final HashMap<String, c>[] g0; private Set<Integer> h0; private ByteOrder i0; private boolean j0; private boolean k0; private boolean l0; private int m0; private int n0; private byte[] o0; private int p0; private int q0; private int r0; private int s0; private int t0; private boolean u0; private static final boolean a = Log.isLoggable("ExifInterface", 3); private static final List<Integer> f1600b = Arrays.asList(1, 6, 3, 8); private static final List<Integer> f1601c = Arrays.asList(2, 7, 4, 5); public static final int[] f1602d = {8, 8, 8}; public static final int[] f1603e = {4}; public static final int[] f1604f = {8}; static final byte[] g = {-1, -40, -1}; private static final byte[] h = {102, 116, 121, 112}; private static final byte[] i = {109, 105, 102, 49}; private static final byte[] j = {104, 101, 105, 99}; private static final byte[] k = {79, 76, 89, 77, 80, 0}; private static final byte[] l = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73}; private static final byte[] m = {-119, 80, 78, 71, 13, 10, 26, 10}; private static final byte[] n = {101, 88, 73, 102}; private static final byte[] o = {73, 72, 68, 82}; private static final byte[] p = {73, 69, 78, 68}; private static final byte[] q = {82, 73, 70, 70}; private static final byte[] r = {87, 69, 66, 80}; private static final byte[] s = {69, 88, 73, 70}; private static final byte[] t = {-99, 1, 42}; private static final byte[] u = "VP8X".getBytes(Charset.defaultCharset()); private static final byte[] v = "VP8L".getBytes(Charset.defaultCharset()); private static final byte[] w = "VP8 ".getBytes(Charset.defaultCharset()); private static final byte[] x = "ANIM".getBytes(Charset.defaultCharset()); private static final byte[] y = "ANMF".getBytes(Charset.defaultCharset()); static final String[] B = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"}; static final int[] C = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1}; static final byte[] D = {65, 83, 67, 73, 73, 0, 0, 0}; public class C0077a extends MediaDataSource { long p; final f q; C0077a(f fVar) { this.q = fVar; } @Override public void close() { } @Override public long getSize() { return -1L; } @Override public int readAt(long j, byte[] bArr, int i, int i2) { if (i2 == 0) { return 0; } if (j < 0) { return -1; } try { long j2 = this.p; if (j2 != j) { if (j2 >= 0 && j >= j2 + this.q.available()) { return -1; } this.q.p(j); this.p = j; } if (i2 > this.q.available()) { i2 = this.q.available(); } int read = this.q.read(bArr, i, i2); if (read >= 0) { this.p += read; return read; } } catch (IOException unused) { } this.p = -1L; return -1; } } public static class b extends InputStream implements DataInput { private static final ByteOrder p = ByteOrder.LITTLE_ENDIAN; private static final ByteOrder q = ByteOrder.BIG_ENDIAN; final DataInputStream r; private ByteOrder s; int t; private byte[] u; b(byte[] bArr) { this(new ByteArrayInputStream(bArr), ByteOrder.BIG_ENDIAN); } public int a() { return this.t; } @Override public int available() { return this.r.available(); } public long b() { return readInt() & 4294967295L; } public void i(ByteOrder byteOrder) { this.s = byteOrder; } public void m(int i) { int i2 = 0; while (i2 < i) { int i3 = i - i2; int skip = (int) this.r.skip(i3); if (skip <= 0) { if (this.u == null) { this.u = new byte[8192]; } skip = this.r.read(this.u, 0, Math.min(8192, i3)); if (skip == -1) { throw new EOFException("Reached EOF while skipping " + i + " bytes."); } } i2 += skip; } this.t += i2; } @Override public void mark(int i) { throw new UnsupportedOperationException("Mark is currently unsupported"); } @Override public int read() { this.t++; return this.r.read(); } @Override public boolean readBoolean() { this.t++; return this.r.readBoolean(); } @Override public byte readByte() { this.t++; int read = this.r.read(); if (read >= 0) { return (byte) read; } throw new EOFException(); } @Override public char readChar() { this.t += 2; return this.r.readChar(); } @Override public double readDouble() { return Double.longBitsToDouble(readLong()); } @Override public float readFloat() { return Float.intBitsToFloat(readInt()); } @Override public void readFully(byte[] bArr, int i, int i2) { this.t += i2; this.r.readFully(bArr, i, i2); } @Override public int readInt() { this.t += 4; int read = this.r.read(); int read2 = this.r.read(); int read3 = this.r.read(); int read4 = this.r.read(); if ((read | read2 | read3 | read4) >= 0) { ByteOrder byteOrder = this.s; if (byteOrder == p) { return (read4 << 24) + (read3 << 16) + (read2 << 8) + read; } if (byteOrder == q) { return (read << 24) + (read2 << 16) + (read3 << 8) + read4; } throw new IOException("Invalid byte order: " + this.s); } throw new EOFException(); } @Override public String readLine() { Log.d("ExifInterface", "Currently unsupported"); return null; } @Override public long readLong() { this.t += 8; int read = this.r.read(); int read2 = this.r.read(); int read3 = this.r.read(); int read4 = this.r.read(); int read5 = this.r.read(); int read6 = this.r.read(); int read7 = this.r.read(); int read8 = this.r.read(); if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) { ByteOrder byteOrder = this.s; if (byteOrder == p) { return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read; } if (byteOrder == q) { return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8; } throw new IOException("Invalid byte order: " + this.s); } throw new EOFException(); } @Override public short readShort() { this.t += 2; int read = this.r.read(); int read2 = this.r.read(); if ((read | read2) >= 0) { ByteOrder byteOrder = this.s; if (byteOrder == p) { return (short) ((read2 << 8) + read); } if (byteOrder == q) { return (short) ((read << 8) + read2); } throw new IOException("Invalid byte order: " + this.s); } throw new EOFException(); } @Override public String readUTF() { this.t += 2; return this.r.readUTF(); } @Override public int readUnsignedByte() { this.t++; return this.r.readUnsignedByte(); } @Override public int readUnsignedShort() { this.t += 2; int read = this.r.read(); int read2 = this.r.read(); if ((read | read2) >= 0) { ByteOrder byteOrder = this.s; if (byteOrder == p) { return (read2 << 8) + read; } if (byteOrder == q) { return (read << 8) + read2; } throw new IOException("Invalid byte order: " + this.s); } throw new EOFException(); } @Override public void reset() { throw new UnsupportedOperationException("Reset is currently unsupported"); } @Override public int skipBytes(int i) { throw new UnsupportedOperationException("skipBytes is currently unsupported"); } b(InputStream inputStream) { this(inputStream, ByteOrder.BIG_ENDIAN); } b(InputStream inputStream, ByteOrder byteOrder) { this.s = ByteOrder.BIG_ENDIAN; DataInputStream dataInputStream = new DataInputStream(inputStream); this.r = dataInputStream; dataInputStream.mark(0); this.t = 0; this.s = byteOrder; } @Override public int read(byte[] bArr, int i, int i2) { int read = this.r.read(bArr, i, i2); this.t += read; return read; } @Override public void readFully(byte[] bArr) { this.t += bArr.length; this.r.readFully(bArr); } } public static class c { public final int a; public final int f1605b; public final long f1606c; public final byte[] f1607d; c(int i, int i2, byte[] bArr) { this(i, i2, -1L, bArr); } public static c a(String str) { byte[] bytes = (str + (char) 0).getBytes(a.U); return new c(2, bytes.length, bytes); } public static c b(long j, ByteOrder byteOrder) { return c(new long[]{j}, byteOrder); } public static c c(long[] jArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[4] * jArr.length]); wrap.order(byteOrder); for (long j : jArr) { wrap.putInt((int) j); } return new c(4, jArr.length, wrap.array()); } public static c d(e eVar, ByteOrder byteOrder) { return e(new e[]{eVar}, byteOrder); } public static c e(e[] eVarArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[5] * eVarArr.length]); wrap.order(byteOrder); for (e eVar : eVarArr) { wrap.putInt((int) eVar.a); wrap.putInt((int) eVar.f1611b); } return new c(5, eVarArr.length, wrap.array()); } public static c f(int i, ByteOrder byteOrder) { return g(new int[]{i}, byteOrder); } public static c g(int[] iArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[3] * iArr.length]); wrap.order(byteOrder); for (int i : iArr) { wrap.putShort((short) i); } return new c(3, iArr.length, wrap.array()); } public double h(ByteOrder byteOrder) { Object k = k(byteOrder); if (k != null) { if (k instanceof String) { return Double.parseDouble((String) k); } if (k instanceof long[]) { if (((long[]) k).length == 1) { return r5[0]; } throw new NumberFormatException("There are more than one component"); } if (k instanceof int[]) { if (((int[]) k).length == 1) { return r5[0]; } throw new NumberFormatException("There are more than one component"); } if (k instanceof double[]) { double[] dArr = (double[]) k; if (dArr.length == 1) { return dArr[0]; } throw new NumberFormatException("There are more than one component"); } if (k instanceof e[]) { e[] eVarArr = (e[]) k; if (eVarArr.length == 1) { return eVarArr[0].a(); } throw new NumberFormatException("There are more than one component"); } throw new NumberFormatException("Couldn't find a double value"); } throw new NumberFormatException("NULL can't be converted to a double value"); } public int i(ByteOrder byteOrder) { Object k = k(byteOrder); if (k != null) { if (k instanceof String) { return Integer.parseInt((String) k); } if (k instanceof long[]) { long[] jArr = (long[]) k; if (jArr.length == 1) { return (int) jArr[0]; } throw new NumberFormatException("There are more than one component"); } if (k instanceof int[]) { int[] iArr = (int[]) k; if (iArr.length == 1) { return iArr[0]; } throw new NumberFormatException("There are more than one component"); } throw new NumberFormatException("Couldn't find a integer value"); } throw new NumberFormatException("NULL can't be converted to a integer value"); } public String j(ByteOrder byteOrder) { Object k = k(byteOrder); if (k == null) { return null; } if (k instanceof String) { return (String) k; } StringBuilder sb = new StringBuilder(); int i = 0; if (k instanceof long[]) { long[] jArr = (long[]) k; while (i < jArr.length) { sb.append(jArr[i]); i++; if (i != jArr.length) { sb.append(","); } } return sb.toString(); } if (k instanceof int[]) { int[] iArr = (int[]) k; while (i < iArr.length) { sb.append(iArr[i]); i++; if (i != iArr.length) { sb.append(","); } } return sb.toString(); } if (k instanceof double[]) { double[] dArr = (double[]) k; while (i < dArr.length) { sb.append(dArr[i]); i++; if (i != dArr.length) { sb.append(","); } } return sb.toString(); } if (!(k instanceof e[])) { return null; } e[] eVarArr = (e[]) k; while (i < eVarArr.length) { sb.append(eVarArr[i].a); sb.append('/'); sb.append(eVarArr[i].f1611b); i++; if (i != eVarArr.length) { sb.append(","); } } return sb.toString(); } Object k(ByteOrder byteOrder) { b bVar; InputStream inputStream; byte b2; byte[] bArr; InputStream inputStream2 = null; try { try { bVar = new b(this.f1607d); try { bVar.i(byteOrder); boolean z = true; int i = 0; switch (this.a) { case 1: case 6: byte[] bArr2 = this.f1607d; if (bArr2.length == 1 && bArr2[0] >= 0 && bArr2[0] <= 1) { String str = new String(new char[]{(char) (this.f1607d[0] + 48)}); try { bVar.close(); } catch (IOException e2) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e2); } return str; } String str2 = new String(this.f1607d, a.U); try { bVar.close(); } catch (IOException e3) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e3); } return str2; case 2: case 7: if (this.f1605b >= a.D.length) { int i2 = 0; while (true) { bArr = a.D; if (i2 < bArr.length) { if (this.f1607d[i2] != bArr[i2]) { z = false; } else { i2++; } } } if (z) { i = bArr.length; } } StringBuilder sb = new StringBuilder(); while (i < this.f1605b && (b2 = this.f1607d[i]) != 0) { if (b2 >= 32) { sb.append((char) b2); } else { sb.append('?'); } i++; } String sb2 = sb.toString(); try { bVar.close(); } catch (IOException e4) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e4); } return sb2; case 3: int[] iArr = new int[this.f1605b]; while (i < this.f1605b) { iArr[i] = bVar.readUnsignedShort(); i++; } try { bVar.close(); } catch (IOException e5) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e5); } return iArr; case 4: long[] jArr = new long[this.f1605b]; while (i < this.f1605b) { jArr[i] = bVar.b(); i++; } try { bVar.close(); } catch (IOException e6) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e6); } return jArr; case 5: e[] eVarArr = new e[this.f1605b]; while (i < this.f1605b) { eVarArr[i] = new e(bVar.b(), bVar.b()); i++; } try { bVar.close(); } catch (IOException e7) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e7); } return eVarArr; case 8: int[] iArr2 = new int[this.f1605b]; while (i < this.f1605b) { iArr2[i] = bVar.readShort(); i++; } try { bVar.close(); } catch (IOException e8) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e8); } return iArr2; case 9: int[] iArr3 = new int[this.f1605b]; while (i < this.f1605b) { iArr3[i] = bVar.readInt(); i++; } try { bVar.close(); } catch (IOException e9) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e9); } return iArr3; case 10: e[] eVarArr2 = new e[this.f1605b]; while (i < this.f1605b) { eVarArr2[i] = new e(bVar.readInt(), bVar.readInt()); i++; } try { bVar.close(); } catch (IOException e10) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e10); } return eVarArr2; case 11: double[] dArr = new double[this.f1605b]; while (i < this.f1605b) { dArr[i] = bVar.readFloat(); i++; } try { bVar.close(); } catch (IOException e11) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e11); } return dArr; case 12: double[] dArr2 = new double[this.f1605b]; while (i < this.f1605b) { dArr2[i] = bVar.readDouble(); i++; } try { bVar.close(); } catch (IOException e12) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e12); } return dArr2; default: try { bVar.close(); } catch (IOException e13) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e13); } return null; } } catch (IOException e14) { e = e14; Log.w("ExifInterface", "IOException occurred during reading a value", e); if (bVar != null) { try { bVar.close(); } catch (IOException e15) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e15); } } return null; } } catch (Throwable th) { th = th; inputStream2 = inputStream; if (inputStream2 != null) { try { inputStream2.close(); } catch (IOException e16) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e16); } } throw th; } } catch (IOException e17) { e = e17; bVar = null; } catch (Throwable th2) { th = th2; if (inputStream2 != null) { } throw th; } } public String toString() { return "(" + a.B[this.a] + ", data length:" + this.f1607d.length + ")"; } c(int i, int i2, long j, byte[] bArr) { this.a = i; this.f1605b = i2; this.f1606c = j; this.f1607d = bArr; } } public static class e { public final long a; public final long f1611b; e(long j, long j2) { if (j2 == 0) { this.a = 0L; this.f1611b = 1L; } else { this.a = j; this.f1611b = j2; } } public double a() { return this.a / this.f1611b; } public String toString() { return this.a + "/" + this.f1611b; } } static { d[] dVarArr = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ImageWidth", 256, 3, 4), new d("ImageLength", 257, 3, 4), new d("BitsPerSample", 258, 3), new d("Compression", 259, 3), new d("PhotometricInterpretation", 262, 3), new d("ImageDescription", 270, 2), new d("Make", 271, 2), new d("Model", 272, 2), new d("StripOffsets", 273, 3, 4), new d("Orientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), new d("XResolution", 282, 5), new d("YResolution", 283, 5), new d("PlanarConfiguration", 284, 3), new d("ResolutionUnit", 296, 3), new d("TransferFunction", 301, 3), new d("Software", 305, 2), new d("DateTime", 306, 2), new d("Artist", 315, 2), new d("WhitePoint", 318, 5), new d("PrimaryChromaticities", 319, 5), new d("SubIFDPointer", 330, 4), new d("JPEGInterchangeFormat", 513, 4), new d("JPEGInterchangeFormatLength", 514, 4), new d("YCbCrCoefficients", 529, 5), new d("YCbCrSubSampling", 530, 3), new d("YCbCrPositioning", 531, 3), new d("ReferenceBlackWhite", 532, 5), new d("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("SensorTopBorder", 4, 4), new d("SensorLeftBorder", 5, 4), new d("SensorBottomBorder", 6, 4), new d("SensorRightBorder", 7, 4), new d("ISO", 23, 3), new d("JpgFromRaw", 46, 7), new d("Xmp", 700, 1)}; E = dVarArr; d[] dVarArr2 = {new d("ExposureTime", 33434, 5), new d("FNumber", 33437, 5), new d("ExposureProgram", 34850, 3), new d("SpectralSensitivity", 34852, 2), new d("PhotographicSensitivity", 34855, 3), new d("OECF", 34856, 7), new d("SensitivityType", 34864, 3), new d("StandardOutputSensitivity", 34865, 4), new d("RecommendedExposureIndex", 34866, 4), new d("ISOSpeed", 34867, 4), new d("ISOSpeedLatitudeyyy", 34868, 4), new d("ISOSpeedLatitudezzz", 34869, 4), new d("ExifVersion", 36864, 2), new d("DateTimeOriginal", 36867, 2), new d("DateTimeDigitized", 36868, 2), new d("OffsetTime", 36880, 2), new d("OffsetTimeOriginal", 36881, 2), new d("OffsetTimeDigitized", 36882, 2), new d("ComponentsConfiguration", 37121, 7), new d("CompressedBitsPerPixel", 37122, 5), new d("ShutterSpeedValue", 37377, 10), new d("ApertureValue", 37378, 5), new d("BrightnessValue", 37379, 10), new d("ExposureBiasValue", 37380, 10), new d("MaxApertureValue", 37381, 5), new d("SubjectDistance", 37382, 5), new d("MeteringMode", 37383, 3), new d("LightSource", 37384, 3), new d("Flash", 37385, 3), new d("FocalLength", 37386, 5), new d("SubjectArea", 37396, 3), new d("MakerNote", 37500, 7), new d("UserComment", 37510, 7), new d("SubSecTime", 37520, 2), new d("SubSecTimeOriginal", 37521, 2), new d("SubSecTimeDigitized", 37522, 2), new d("FlashpixVersion", 40960, 7), new d("ColorSpace", 40961, 3), new d("PixelXDimension", 40962, 3, 4), new d("PixelYDimension", 40963, 3, 4), new d("RelatedSoundFile", 40964, 2), new d("InteroperabilityIFDPointer", 40965, 4), new d("FlashEnergy", 41483, 5), new d("SpatialFrequencyResponse", 41484, 7), new d("FocalPlaneXResolution", 41486, 5), new d("FocalPlaneYResolution", 41487, 5), new d("FocalPlaneResolutionUnit", 41488, 3), new d("SubjectLocation", 41492, 3), new d("ExposureIndex", 41493, 5), new d("SensingMethod", 41495, 3), new d("FileSource", 41728, 7), new d("SceneType", 41729, 7), new d("CFAPattern", 41730, 7), new d("CustomRendered", 41985, 3), new d("ExposureMode", 41986, 3), new d("WhiteBalance", 41987, 3), new d("DigitalZoomRatio", 41988, 5), new d("FocalLengthIn35mmFilm", 41989, 3), new d("SceneCaptureType", 41990, 3), new d("GainControl", 41991, 3), new d("Contrast", 41992, 3), new d("Saturation", 41993, 3), new d("Sharpness", 41994, 3), new d("DeviceSettingDescription", 41995, 7), new d("SubjectDistanceRange", 41996, 3), new d("ImageUniqueID", 42016, 2), new d("CameraOwnerName", 42032, 2), new d("BodySerialNumber", 42033, 2), new d("LensSpecification", 42034, 5), new d("LensMake", 42035, 2), new d("LensModel", 42036, 2), new d("Gamma", 42240, 5), new d("DNGVersion", 50706, 1), new d("DefaultCropSize", 50720, 3, 4)}; F = dVarArr2; d[] dVarArr3 = {new d("GPSVersionID", 0, 1), new d("GPSLatitudeRef", 1, 2), new d("GPSLatitude", 2, 5, 10), new d("GPSLongitudeRef", 3, 2), new d("GPSLongitude", 4, 5, 10), new d("GPSAltitudeRef", 5, 1), new d("GPSAltitude", 6, 5), new d("GPSTimeStamp", 7, 5), new d("GPSSatellites", 8, 2), new d("GPSStatus", 9, 2), new d("GPSMeasureMode", 10, 2), new d("GPSDOP", 11, 5), new d("GPSSpeedRef", 12, 2), new d("GPSSpeed", 13, 5), new d("GPSTrackRef", 14, 2), new d("GPSTrack", 15, 5), new d("GPSImgDirectionRef", 16, 2), new d("GPSImgDirection", 17, 5), new d("GPSMapDatum", 18, 2), new d("GPSDestLatitudeRef", 19, 2), new d("GPSDestLatitude", 20, 5), new d("GPSDestLongitudeRef", 21, 2), new d("GPSDestLongitude", 22, 5), new d("GPSDestBearingRef", 23, 2), new d("GPSDestBearing", 24, 5), new d("GPSDestDistanceRef", 25, 2), new d("GPSDestDistance", 26, 5), new d("GPSProcessingMethod", 27, 7), new d("GPSAreaInformation", 28, 7), new d("GPSDateStamp", 29, 2), new d("GPSDifferential", 30, 3), new d("GPSHPositioningError", 31, 5)}; G = dVarArr3; d[] dVarArr4 = {new d("InteroperabilityIndex", 1, 2)}; H = dVarArr4; d[] dVarArr5 = {new d("NewSubfileType", 254, 4), new d("SubfileType", 255, 4), new d("ThumbnailImageWidth", 256, 3, 4), new d("ThumbnailImageLength", 257, 3, 4), new d("BitsPerSample", 258, 3), new d("Compression", 259, 3), new d("PhotometricInterpretation", 262, 3), new d("ImageDescription", 270, 2), new d("Make", 271, 2), new d("Model", 272, 2), new d("StripOffsets", 273, 3, 4), new d("ThumbnailOrientation", 274, 3), new d("SamplesPerPixel", 277, 3), new d("RowsPerStrip", 278, 3, 4), new d("StripByteCounts", 279, 3, 4), new d("XResolution", 282, 5), new d("YResolution", 283, 5), new d("PlanarConfiguration", 284, 3), new d("ResolutionUnit", 296, 3), new d("TransferFunction", 301, 3), new d("Software", 305, 2), new d("DateTime", 306, 2), new d("Artist", 315, 2), new d("WhitePoint", 318, 5), new d("PrimaryChromaticities", 319, 5), new d("SubIFDPointer", 330, 4), new d("JPEGInterchangeFormat", 513, 4), new d("JPEGInterchangeFormatLength", 514, 4), new d("YCbCrCoefficients", 529, 5), new d("YCbCrSubSampling", 530, 3), new d("YCbCrPositioning", 531, 3), new d("ReferenceBlackWhite", 532, 5), new d("Xmp", 700, 1), new d("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("DNGVersion", 50706, 1), new d("DefaultCropSize", 50720, 3, 4)}; I = dVarArr5; J = new d("StripOffsets", 273, 3); d[] dVarArr6 = {new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)}; K = dVarArr6; d[] dVarArr7 = {new d("PreviewImageStart", 257, 4), new d("PreviewImageLength", 258, 4)}; L = dVarArr7; d[] dVarArr8 = {new d("AspectFrame", 4371, 3)}; M = dVarArr8; d[] dVarArr9 = {new d("ColorSpace", 55, 3)}; N = dVarArr9; d[][] dVarArr10 = {dVarArr, dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr, dVarArr6, dVarArr7, dVarArr8, dVarArr9}; O = dVarArr10; P = new d[]{new d("SubIFDPointer", 330, 4), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("InteroperabilityIFDPointer", 40965, 4), new d("CameraSettingsIFDPointer", 8224, 1), new d("ImageProcessingIFDPointer", 8256, 1)}; Q = new HashMap[dVarArr10.length]; R = new HashMap[dVarArr10.length]; S = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp")); T = new HashMap<>(); Charset forName = Charset.forName("US-ASCII"); U = forName; V = "Exif\u0000\u0000".getBytes(forName); W = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName); Locale locale = Locale.US; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale); z = simpleDateFormat; simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale); A = simpleDateFormat2; simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC")); int i2 = 0; while (true) { d[][] dVarArr11 = O; if (i2 < dVarArr11.length) { Q[i2] = new HashMap<>(); R[i2] = new HashMap<>(); for (d dVar : dVarArr11[i2]) { Q[i2].put(Integer.valueOf(dVar.a), dVar); R[i2].put(dVar.f1608b, dVar); } i2++; } else { HashMap<Integer, Integer> hashMap = T; d[] dVarArr12 = P; hashMap.put(Integer.valueOf(dVarArr12[0].a), 5); hashMap.put(Integer.valueOf(dVarArr12[1].a), 1); hashMap.put(Integer.valueOf(dVarArr12[2].a), 2); hashMap.put(Integer.valueOf(dVarArr12[3].a), 3); hashMap.put(Integer.valueOf(dVarArr12[4].a), 7); hashMap.put(Integer.valueOf(dVarArr12[5].a), 8); X = Pattern.compile(".*[1-9].*"); Y = Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})$"); Z = Pattern.compile("^(\\d{4}):(\\d{2}):(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$"); a0 = Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$"); return; } } } public a(InputStream inputStream) { this(inputStream, 0); } private boolean A(byte[] bArr) { int i2 = 0; while (true) { byte[] bArr2 = q; if (i2 >= bArr2.length) { int i3 = 0; while (true) { byte[] bArr3 = r; if (i3 >= bArr3.length) { return true; } if (bArr[q.length + i3 + 4] != bArr3[i3]) { return false; } i3++; } } else { if (bArr[i2] != bArr2[i2]) { return false; } i2++; } } } private void B(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputstream shouldn't be null"); for (int i2 = 0; i2 < O.length; i2++) { try { try { this.g0[i2] = new HashMap<>(); } finally { a(); if (a) { D(); } } } catch (IOException | UnsupportedOperationException e2) { boolean z2 = a; if (z2) { Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e2); } a(); if (!z2) { return; } } } if (!this.f0) { BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000); this.e0 = g(bufferedInputStream); inputStream = bufferedInputStream; } if (K(this.e0)) { f fVar = new f(inputStream); if (this.f0) { m(fVar); } else { int i3 = this.e0; if (i3 == 12) { e(fVar); } else if (i3 == 7) { h(fVar); } else if (i3 == 10) { l(fVar); } else { k(fVar); } } fVar.p(this.q0); J(fVar); } else { b bVar = new b(inputStream); int i4 = this.e0; if (i4 == 4) { f(bVar, 0, 0); } else if (i4 == 13) { i(bVar); } else if (i4 == 9) { j(bVar); } else if (i4 == 14) { n(bVar); } } } private void C(b bVar) { ByteOrder E2 = E(bVar); this.i0 = E2; bVar.i(E2); int readUnsignedShort = bVar.readUnsignedShort(); int i2 = this.e0; if (i2 != 7 && i2 != 10 && readUnsignedShort != 42) { throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort)); } int readInt = bVar.readInt(); if (readInt < 8) { throw new IOException("Invalid first Ifd offset: " + readInt); } int i3 = readInt - 8; if (i3 > 0) { bVar.m(i3); } } private void D() { for (int i2 = 0; i2 < this.g0.length; i2++) { Log.d("ExifInterface", "The size of tag group[" + i2 + "]: " + this.g0[i2].size()); for (Map.Entry<String, c> entry : this.g0[i2].entrySet()) { c value = entry.getValue(); Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.j(this.i0) + "'"); } } } private ByteOrder E(b bVar) { short readShort = bVar.readShort(); if (readShort == 18761) { if (a) { Log.d("ExifInterface", "readExifSegment: Byte Align II"); } return ByteOrder.LITTLE_ENDIAN; } if (readShort == 19789) { if (a) { Log.d("ExifInterface", "readExifSegment: Byte Align MM"); } return ByteOrder.BIG_ENDIAN; } throw new IOException("Invalid byte order: " + Integer.toHexString(readShort)); } private void F(byte[] bArr, int i2) { f fVar = new f(bArr); C(fVar); G(fVar, i2); } private void G(f fVar, int i2) { String str; short s2; long j2; boolean z2; short s3; long j3; String str2; int i3; String str3; int readUnsignedShort; this.h0.add(Integer.valueOf(fVar.t)); short readShort = fVar.readShort(); String str4 = "ExifInterface"; if (a) { Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort)); } if (readShort <= 0) { return; } char c2 = 0; short s4 = 0; while (s4 < readShort) { int readUnsignedShort2 = fVar.readUnsignedShort(); int readUnsignedShort3 = fVar.readUnsignedShort(); int readInt = fVar.readInt(); long a2 = fVar.a() + 4; d dVar = Q[i2].get(Integer.valueOf(readUnsignedShort2)); boolean z3 = a; if (z3) { Object[] objArr = new Object[5]; objArr[c2] = Integer.valueOf(i2); objArr[1] = Integer.valueOf(readUnsignedShort2); objArr[2] = dVar != null ? dVar.f1608b : null; objArr[3] = Integer.valueOf(readUnsignedShort3); objArr[4] = Integer.valueOf(readInt); Log.d(str4, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr)); } if (dVar != null) { if (readUnsignedShort3 > 0) { if (readUnsignedShort3 < C.length) { if (dVar.a(readUnsignedShort3)) { if (readUnsignedShort3 == 7) { readUnsignedShort3 = dVar.f1609c; } str = str4; s2 = s4; j2 = readInt * r7[readUnsignedShort3]; if (j2 < 0 || j2 > 2147483647L) { if (z3) { Log.d(str, "Skip the tag entry since the number of components is invalid: " + readInt); } z2 = false; if (z2) { fVar.p(a2); s3 = readShort; str3 = str; } else { if (j2 > 4) { int readInt2 = fVar.readInt(); s3 = readShort; if (z3) { StringBuilder sb = new StringBuilder(); j3 = a2; sb.append("seek to data offset: "); sb.append(readInt2); Log.d(str, sb.toString()); } else { j3 = a2; } if (this.e0 == 7) { if ("MakerNote".equals(dVar.f1608b)) { this.r0 = readInt2; } else if (i2 == 6 && "ThumbnailImage".equals(dVar.f1608b)) { this.s0 = readInt2; this.t0 = readInt; c f2 = c.f(6, this.i0); i3 = readInt; c b2 = c.b(this.s0, this.i0); str2 = str; c b3 = c.b(this.t0, this.i0); this.g0[4].put("Compression", f2); this.g0[4].put("JPEGInterchangeFormat", b2); this.g0[4].put("JPEGInterchangeFormatLength", b3); fVar.p(readInt2); } } str2 = str; i3 = readInt; fVar.p(readInt2); } else { s3 = readShort; j3 = a2; str2 = str; i3 = readInt; } Integer num = T.get(Integer.valueOf(readUnsignedShort2)); if (z3) { str3 = str2; Log.d(str3, "nextIfdType: " + num + " byteCount: " + j2); } else { str3 = str2; } if (num != null) { long j4 = -1; if (readUnsignedShort3 == 3) { readUnsignedShort = fVar.readUnsignedShort(); } else { if (readUnsignedShort3 == 4) { j4 = fVar.b(); } else if (readUnsignedShort3 == 8) { readUnsignedShort = fVar.readShort(); } else if (readUnsignedShort3 == 9 || readUnsignedShort3 == 13) { readUnsignedShort = fVar.readInt(); } if (z3) { Log.d(str3, String.format("Offset: %d, tagName: %s", Long.valueOf(j4), dVar.f1608b)); } if (j4 <= 0) { if (!this.h0.contains(Integer.valueOf((int) j4))) { fVar.p(j4); G(fVar, num.intValue()); } else if (z3) { Log.d(str3, "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j4 + ")"); } } else if (z3) { Log.d(str3, "Skip jump into the IFD since its offset is invalid: " + j4); } fVar.p(j3); } j4 = readUnsignedShort; if (z3) { } if (j4 <= 0) { } fVar.p(j3); } else { long j5 = j3; int a3 = fVar.a() + this.q0; byte[] bArr = new byte[(int) j2]; fVar.readFully(bArr); c cVar = new c(readUnsignedShort3, i3, a3, bArr); this.g0[i2].put(dVar.f1608b, cVar); if ("DNGVersion".equals(dVar.f1608b)) { this.e0 = 3; } if ((("Make".equals(dVar.f1608b) || "Model".equals(dVar.f1608b)) && cVar.j(this.i0).contains("PENTAX")) || ("Compression".equals(dVar.f1608b) && cVar.i(this.i0) == 65535)) { this.e0 = 8; } if (fVar.a() != j5) { fVar.p(j5); } } } s4 = (short) (s2 + 1); str4 = str3; readShort = s3; c2 = 0; } else { z2 = true; if (z2) { } s4 = (short) (s2 + 1); str4 = str3; readShort = s3; c2 = 0; } } else if (z3) { Log.d(str4, "Skip the tag entry since data format (" + B[readUnsignedShort3] + ") is unexpected for tag: " + dVar.f1608b); } } } str = str4; s2 = s4; if (z3) { Log.d(str, "Skip the tag entry since data format is invalid: " + readUnsignedShort3); } j2 = 0; z2 = false; if (z2) { } s4 = (short) (s2 + 1); str4 = str3; readShort = s3; c2 = 0; } else if (z3) { Log.d(str4, "Skip the tag entry since tag number is not defined: " + readUnsignedShort2); } str = str4; s2 = s4; j2 = 0; z2 = false; if (z2) { } s4 = (short) (s2 + 1); str4 = str3; readShort = s3; c2 = 0; } String str5 = str4; int readInt3 = fVar.readInt(); boolean z4 = a; if (z4) { Log.d(str5, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3))); } long j6 = readInt3; if (j6 <= 0) { if (z4) { Log.d(str5, "Stop reading file since a wrong offset may cause an infinite loop: " + readInt3); return; } return; } if (this.h0.contains(Integer.valueOf(readInt3))) { if (z4) { Log.d(str5, "Stop reading file since re-reading an IFD may cause an infinite loop: " + readInt3); return; } return; } fVar.p(j6); if (this.g0[4].isEmpty()) { G(fVar, 4); } else if (this.g0[5].isEmpty()) { G(fVar, 5); } } private void H(int i2, String str, String str2) { if (this.g0[i2].isEmpty() || this.g0[i2].get(str) == null) { return; } HashMap[] hashMapArr = this.g0; hashMapArr[i2].put(str2, hashMapArr[i2].get(str)); this.g0[i2].remove(str); } private void I(f fVar, int i2) { c cVar = this.g0[i2].get("ImageLength"); c cVar2 = this.g0[i2].get("ImageWidth"); if (cVar == null || cVar2 == null) { c cVar3 = this.g0[i2].get("JPEGInterchangeFormat"); c cVar4 = this.g0[i2].get("JPEGInterchangeFormatLength"); if (cVar3 == null || cVar4 == null) { return; } int i3 = cVar3.i(this.i0); int i4 = cVar3.i(this.i0); fVar.p(i3); byte[] bArr = new byte[i4]; fVar.read(bArr); f(new b(bArr), i3, i2); } } private void J(b bVar) { HashMap<String, c> hashMap = this.g0[4]; c cVar = hashMap.get("Compression"); if (cVar != null) { int i2 = cVar.i(this.i0); this.p0 = i2; if (i2 != 1) { if (i2 == 6) { o(bVar, hashMap); return; } else if (i2 != 7) { return; } } if (y(hashMap)) { p(bVar, hashMap); return; } return; } this.p0 = 6; o(bVar, hashMap); } private static boolean K(int i2) { return (i2 == 4 || i2 == 9 || i2 == 13 || i2 == 14) ? false : true; } private void L(int i2, int i3) { if (!this.g0[i2].isEmpty() && !this.g0[i3].isEmpty()) { c cVar = this.g0[i2].get("ImageLength"); c cVar2 = this.g0[i2].get("ImageWidth"); c cVar3 = this.g0[i3].get("ImageLength"); c cVar4 = this.g0[i3].get("ImageWidth"); if (cVar == null || cVar2 == null) { if (a) { Log.d("ExifInterface", "First image does not contain valid size information"); return; } return; } if (cVar3 != null && cVar4 != null) { int i4 = cVar.i(this.i0); int i5 = cVar2.i(this.i0); int i6 = cVar3.i(this.i0); int i7 = cVar4.i(this.i0); if (i4 >= i6 || i5 >= i7) { return; } HashMap<String, c>[] hashMapArr = this.g0; HashMap<String, c> hashMap = hashMapArr[i2]; hashMapArr[i2] = hashMapArr[i3]; hashMapArr[i3] = hashMap; return; } if (a) { Log.d("ExifInterface", "Second image does not contain valid size information"); return; } return; } if (a) { Log.d("ExifInterface", "Cannot perform swap since only one image data exists"); } } private void M(f fVar, int i2) { c f2; c f3; c cVar = this.g0[i2].get("DefaultCropSize"); c cVar2 = this.g0[i2].get("SensorTopBorder"); c cVar3 = this.g0[i2].get("SensorLeftBorder"); c cVar4 = this.g0[i2].get("SensorBottomBorder"); c cVar5 = this.g0[i2].get("SensorRightBorder"); if (cVar == null) { if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) { int i3 = cVar2.i(this.i0); int i4 = cVar4.i(this.i0); int i5 = cVar5.i(this.i0); int i6 = cVar3.i(this.i0); if (i4 <= i3 || i5 <= i6) { return; } c f4 = c.f(i4 - i3, this.i0); c f5 = c.f(i5 - i6, this.i0); this.g0[i2].put("ImageLength", f4); this.g0[i2].put("ImageWidth", f5); return; } I(fVar, i2); return; } if (cVar.a == 5) { e[] eVarArr = (e[]) cVar.k(this.i0); if (eVarArr != null && eVarArr.length == 2) { f2 = c.d(eVarArr[0], this.i0); f3 = c.d(eVarArr[1], this.i0); } else { Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(eVarArr)); return; } } else { int[] iArr = (int[]) cVar.k(this.i0); if (iArr != null && iArr.length == 2) { f2 = c.f(iArr[0], this.i0); f3 = c.f(iArr[1], this.i0); } else { Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(iArr)); return; } } this.g0[i2].put("ImageWidth", f2); this.g0[i2].put("ImageLength", f3); } private void N() { L(0, 5); L(0, 4); L(5, 4); c cVar = this.g0[1].get("PixelXDimension"); c cVar2 = this.g0[1].get("PixelYDimension"); if (cVar != null && cVar2 != null) { this.g0[0].put("ImageWidth", cVar); this.g0[0].put("ImageLength", cVar2); } if (this.g0[4].isEmpty() && z(this.g0[5])) { HashMap<String, c>[] hashMapArr = this.g0; hashMapArr[4] = hashMapArr[5]; hashMapArr[5] = new HashMap<>(); } if (!z(this.g0[4])) { Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image."); } H(0, "ThumbnailOrientation", "Orientation"); H(0, "ThumbnailImageLength", "ImageLength"); H(0, "ThumbnailImageWidth", "ImageWidth"); H(5, "ThumbnailOrientation", "Orientation"); H(5, "ThumbnailImageLength", "ImageLength"); H(5, "ThumbnailImageWidth", "ImageWidth"); H(4, "Orientation", "ThumbnailOrientation"); H(4, "ImageLength", "ThumbnailImageLength"); H(4, "ImageWidth", "ThumbnailImageWidth"); } private void a() { String b2 = b("DateTimeOriginal"); if (b2 != null && b("DateTime") == null) { this.g0[0].put("DateTime", c.a(b2)); } if (b("ImageWidth") == null) { this.g0[0].put("ImageWidth", c.b(0L, this.i0)); } if (b("ImageLength") == null) { this.g0[0].put("ImageLength", c.b(0L, this.i0)); } if (b("Orientation") == null) { this.g0[0].put("Orientation", c.b(0L, this.i0)); } if (b("LightSource") == null) { this.g0[1].put("LightSource", c.b(0L, this.i0)); } } private c d(String str) { Objects.requireNonNull(str, "tag shouldn't be null"); if ("ISOSpeedRatings".equals(str)) { if (a) { Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY."); } str = "PhotographicSensitivity"; } for (int i2 = 0; i2 < O.length; i2++) { c cVar = this.g0[i2].get(str); if (cVar != null) { return cVar; } } return null; } private void e(f fVar) { String str; String str2; if (Build.VERSION.SDK_INT >= 28) { MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); try { try { b.C0078b.a(mediaMetadataRetriever, new C0077a(fVar)); String extractMetadata = mediaMetadataRetriever.extractMetadata(33); String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34); String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26); String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17); String str3 = null; if ("yes".equals(extractMetadata3)) { str3 = mediaMetadataRetriever.extractMetadata(29); str = mediaMetadataRetriever.extractMetadata(30); str2 = mediaMetadataRetriever.extractMetadata(31); } else if ("yes".equals(extractMetadata4)) { str3 = mediaMetadataRetriever.extractMetadata(18); str = mediaMetadataRetriever.extractMetadata(19); str2 = mediaMetadataRetriever.extractMetadata(24); } else { str = null; str2 = null; } if (str3 != null) { this.g0[0].put("ImageWidth", c.f(Integer.parseInt(str3), this.i0)); } if (str != null) { this.g0[0].put("ImageLength", c.f(Integer.parseInt(str), this.i0)); } if (str2 != null) { int i2 = 1; int parseInt = Integer.parseInt(str2); if (parseInt == 90) { i2 = 6; } else if (parseInt == 180) { i2 = 3; } else if (parseInt == 270) { i2 = 8; } this.g0[0].put("Orientation", c.f(i2, this.i0)); } if (extractMetadata != null && extractMetadata2 != null) { int parseInt2 = Integer.parseInt(extractMetadata); int parseInt3 = Integer.parseInt(extractMetadata2); if (parseInt3 > 6) { fVar.p(parseInt2); byte[] bArr = new byte[6]; if (fVar.read(bArr) == 6) { int i3 = parseInt2 + 6; int i4 = parseInt3 - 6; if (Arrays.equals(bArr, V)) { byte[] bArr2 = new byte[i4]; if (fVar.read(bArr2) == i4) { this.q0 = i3; F(bArr2, 0); } else { throw new IOException("Can't read exif"); } } else { throw new IOException("Invalid identifier"); } } else { throw new IOException("Can't read identifier"); } } else { throw new IOException("Invalid exif length"); } } if (a) { Log.d("ExifInterface", "Heif meta: " + str3 + "x" + str + ", rotation " + str2); } return; } catch (RuntimeException unused) { throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported."); } } finally { mediaMetadataRetriever.release(); } } throw new UnsupportedOperationException("Reading EXIF from HEIF files is supported from SDK 28 and above"); } private void f(b bVar, int i2, int i3) { String str; String str2 = "ExifInterface"; if (a) { Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar); } bVar.i(ByteOrder.BIG_ENDIAN); byte readByte = bVar.readByte(); byte b2 = -1; if (readByte == -1) { if (bVar.readByte() != -40) { throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255)); } int i4 = 2; int i5 = 2; while (true) { byte readByte2 = bVar.readByte(); if (readByte2 == b2) { int i6 = i5 + 1; byte readByte3 = bVar.readByte(); boolean z2 = a; if (z2) { Log.d(str2, "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255)); } int i7 = i6 + 1; if (readByte3 != -39 && readByte3 != -38) { int readUnsignedShort = bVar.readUnsignedShort() - i4; int i8 = i7 + i4; if (z2) { Log.d(str2, "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")"); } if (readUnsignedShort < 0) { throw new IOException("Invalid length"); } if (readByte3 == -31) { byte[] bArr = new byte[readUnsignedShort]; bVar.readFully(bArr); int i9 = i8 + readUnsignedShort; byte[] bArr2 = V; if (c.m.a.b.c(bArr, bArr2)) { byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort); this.q0 = i2 + i8 + bArr2.length; F(copyOfRange, i3); J(new b(copyOfRange)); } else { byte[] bArr3 = W; if (c.m.a.b.c(bArr, bArr3)) { int length = i8 + bArr3.length; byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort); if (b("Xmp") == null) { str = str2; this.g0[0].put("Xmp", new c(1, copyOfRange2.length, length, copyOfRange2)); this.u0 = true; i8 = i9; } } } str = str2; i8 = i9; } else if (readByte3 != -2) { switch (readByte3) { case -64: case -63: case -62: case -61: break; default: switch (readByte3) { case -59: case -58: case -57: break; default: switch (readByte3) { case -55: case -54: case -53: break; default: switch (readByte3) { } if (readUnsignedShort >= 0) { bVar.m(readUnsignedShort); i5 = i8 + readUnsignedShort; str2 = str; i4 = 2; b2 = -1; } else { throw new IOException("Invalid length"); } break; } } } bVar.m(1); this.g0[i3].put(i3 != 4 ? "ImageLength" : "ThumbnailImageLength", c.b(bVar.readUnsignedShort(), this.i0)); this.g0[i3].put(i3 != 4 ? "ImageWidth" : "ThumbnailImageWidth", c.b(bVar.readUnsignedShort(), this.i0)); readUnsignedShort -= 5; str = str2; if (readUnsignedShort >= 0) { } } else { byte[] bArr4 = new byte[readUnsignedShort]; if (bVar.read(bArr4) == readUnsignedShort) { if (b("UserComment") == null) { this.g0[1].put("UserComment", c.a(new String(bArr4, U))); } str = str2; } else { throw new IOException("Invalid exif"); } } readUnsignedShort = 0; if (readUnsignedShort >= 0) { } } } else { throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255)); } } } else { throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255)); } } private int g(BufferedInputStream bufferedInputStream) { bufferedInputStream.mark(5000); byte[] bArr = new byte[5000]; bufferedInputStream.read(bArr); bufferedInputStream.reset(); if (s(bArr)) { return 4; } if (v(bArr)) { return 9; } if (r(bArr)) { return 12; } if (t(bArr)) { return 7; } if (w(bArr)) { return 10; } if (u(bArr)) { return 13; } return A(bArr) ? 14 : 0; } private void h(f fVar) { k(fVar); c cVar = this.g0[1].get("MakerNote"); if (cVar != null) { f fVar2 = new f(cVar.f1607d); fVar2.i(this.i0); byte[] bArr = k; byte[] bArr2 = new byte[bArr.length]; fVar2.readFully(bArr2); fVar2.p(0L); byte[] bArr3 = l; byte[] bArr4 = new byte[bArr3.length]; fVar2.readFully(bArr4); if (Arrays.equals(bArr2, bArr)) { fVar2.p(8L); } else if (Arrays.equals(bArr4, bArr3)) { fVar2.p(12L); } G(fVar2, 6); c cVar2 = this.g0[7].get("PreviewImageStart"); c cVar3 = this.g0[7].get("PreviewImageLength"); if (cVar2 != null && cVar3 != null) { this.g0[5].put("JPEGInterchangeFormat", cVar2); this.g0[5].put("JPEGInterchangeFormatLength", cVar3); } c cVar4 = this.g0[8].get("AspectFrame"); if (cVar4 != null) { int[] iArr = (int[]) cVar4.k(this.i0); if (iArr != null && iArr.length == 4) { if (iArr[2] <= iArr[0] || iArr[3] <= iArr[1]) { return; } int i2 = (iArr[2] - iArr[0]) + 1; int i3 = (iArr[3] - iArr[1]) + 1; if (i2 < i3) { int i4 = i2 + i3; i3 = i4 - i3; i2 = i4 - i3; } c f2 = c.f(i2, this.i0); c f3 = c.f(i3, this.i0); this.g0[0].put("ImageWidth", f2); this.g0[0].put("ImageLength", f3); return; } Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr)); } } } private void i(b bVar) { if (a) { Log.d("ExifInterface", "getPngAttributes starting with: " + bVar); } bVar.i(ByteOrder.BIG_ENDIAN); byte[] bArr = m; bVar.m(bArr.length); int length = bArr.length + 0; while (true) { try { int readInt = bVar.readInt(); int i2 = length + 4; byte[] bArr2 = new byte[4]; if (bVar.read(bArr2) == 4) { int i3 = i2 + 4; if (i3 == 16 && !Arrays.equals(bArr2, o)) { throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk"); } if (Arrays.equals(bArr2, p)) { return; } if (Arrays.equals(bArr2, n)) { byte[] bArr3 = new byte[readInt]; if (bVar.read(bArr3) == readInt) { int readInt2 = bVar.readInt(); CRC32 crc32 = new CRC32(); crc32.update(bArr2); crc32.update(bArr3); if (((int) crc32.getValue()) == readInt2) { this.q0 = i3; F(bArr3, 0); N(); J(new b(bArr3)); return; } throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue()); } throw new IOException("Failed to read given length for given PNG chunk type: " + c.m.a.b.a(bArr2)); } int i4 = readInt + 4; bVar.m(i4); length = i3 + i4; } else { throw new IOException("Encountered invalid length while parsing PNG chunktype"); } } catch (EOFException unused) { throw new IOException("Encountered corrupt PNG file."); } } } private void j(b bVar) { boolean z2 = a; if (z2) { Log.d("ExifInterface", "getRafAttributes starting with: " + bVar); } bVar.m(84); byte[] bArr = new byte[4]; byte[] bArr2 = new byte[4]; byte[] bArr3 = new byte[4]; bVar.read(bArr); bVar.read(bArr2); bVar.read(bArr3); int i2 = ByteBuffer.wrap(bArr).getInt(); int i3 = ByteBuffer.wrap(bArr2).getInt(); int i4 = ByteBuffer.wrap(bArr3).getInt(); byte[] bArr4 = new byte[i3]; bVar.m(i2 - bVar.a()); bVar.read(bArr4); f(new b(bArr4), i2, 5); bVar.m(i4 - bVar.a()); bVar.i(ByteOrder.BIG_ENDIAN); int readInt = bVar.readInt(); if (z2) { Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt); } for (int i5 = 0; i5 < readInt; i5++) { int readUnsignedShort = bVar.readUnsignedShort(); int readUnsignedShort2 = bVar.readUnsignedShort(); if (readUnsignedShort == J.a) { short readShort = bVar.readShort(); short readShort2 = bVar.readShort(); c f2 = c.f(readShort, this.i0); c f3 = c.f(readShort2, this.i0); this.g0[0].put("ImageLength", f2); this.g0[0].put("ImageWidth", f3); if (a) { Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2)); return; } return; } bVar.m(readUnsignedShort2); } } private void k(f fVar) { c cVar; C(fVar); G(fVar, 0); M(fVar, 0); M(fVar, 5); M(fVar, 4); N(); if (this.e0 != 8 || (cVar = this.g0[1].get("MakerNote")) == null) { return; } f fVar2 = new f(cVar.f1607d); fVar2.i(this.i0); fVar2.m(6); G(fVar2, 9); c cVar2 = this.g0[9].get("ColorSpace"); if (cVar2 != null) { this.g0[1].put("ColorSpace", cVar2); } } private void l(f fVar) { if (a) { Log.d("ExifInterface", "getRw2Attributes starting with: " + fVar); } k(fVar); c cVar = this.g0[0].get("JpgFromRaw"); if (cVar != null) { f(new b(cVar.f1607d), (int) cVar.f1606c, 5); } c cVar2 = this.g0[0].get("ISO"); c cVar3 = this.g0[1].get("PhotographicSensitivity"); if (cVar2 == null || cVar3 != null) { return; } this.g0[1].put("PhotographicSensitivity", cVar2); } private void m(f fVar) { byte[] bArr = V; fVar.m(bArr.length); byte[] bArr2 = new byte[fVar.available()]; fVar.readFully(bArr2); this.q0 = bArr.length; F(bArr2, 0); } private void n(b bVar) { if (a) { Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar); } bVar.i(ByteOrder.LITTLE_ENDIAN); bVar.m(q.length); int readInt = bVar.readInt() + 8; byte[] bArr = r; bVar.m(bArr.length); int length = bArr.length + 8; while (true) { try { byte[] bArr2 = new byte[4]; if (bVar.read(bArr2) == 4) { int readInt2 = bVar.readInt(); int i2 = length + 4 + 4; if (Arrays.equals(s, bArr2)) { byte[] bArr3 = new byte[readInt2]; if (bVar.read(bArr3) == readInt2) { this.q0 = i2; F(bArr3, 0); J(new b(bArr3)); return; } else { throw new IOException("Failed to read given length for given PNG chunk type: " + c.m.a.b.a(bArr2)); } } if (readInt2 % 2 == 1) { readInt2++; } length = i2 + readInt2; if (length == readInt) { return; } if (length <= readInt) { bVar.m(readInt2); } else { throw new IOException("Encountered WebP file with invalid chunk size"); } } else { throw new IOException("Encountered invalid length while parsing WebP chunktype"); } } catch (EOFException unused) { throw new IOException("Encountered corrupt WebP file."); } } } private void o(b bVar, HashMap hashMap) { c cVar = (c) hashMap.get("JPEGInterchangeFormat"); c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength"); if (cVar == null || cVar2 == null) { return; } int i2 = cVar.i(this.i0); int i3 = cVar2.i(this.i0); if (this.e0 == 7) { i2 += this.r0; } if (i2 > 0 && i3 > 0) { this.j0 = true; if (this.b0 == null && this.d0 == null && this.c0 == null) { byte[] bArr = new byte[i3]; bVar.skip(i2); bVar.read(bArr); this.o0 = bArr; } this.m0 = i2; this.n0 = i3; } if (a) { Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + i2 + ", length: " + i3); } } private void p(b bVar, HashMap hashMap) { c cVar = (c) hashMap.get("StripOffsets"); c cVar2 = (c) hashMap.get("StripByteCounts"); if (cVar == null || cVar2 == null) { return; } long[] b2 = c.m.a.b.b(cVar.k(this.i0)); long[] b3 = c.m.a.b.b(cVar2.k(this.i0)); if (b2 != null && b2.length != 0) { if (b3 != null && b3.length != 0) { if (b2.length != b3.length) { Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length."); return; } long j2 = 0; for (long j3 : b3) { j2 += j3; } int i2 = (int) j2; byte[] bArr = new byte[i2]; this.l0 = true; this.k0 = true; this.j0 = true; int i3 = 0; int i4 = 0; for (int i5 = 0; i5 < b2.length; i5++) { int i6 = (int) b2[i5]; int i7 = (int) b3[i5]; if (i5 < b2.length - 1 && i6 + i7 != b2[i5 + 1]) { this.l0 = false; } int i8 = i6 - i3; if (i8 < 0) { Log.d("ExifInterface", "Invalid strip offset value"); return; } long j4 = i8; if (bVar.skip(j4) != j4) { Log.d("ExifInterface", "Failed to skip " + i8 + " bytes."); return; } int i9 = i3 + i8; byte[] bArr2 = new byte[i7]; if (bVar.read(bArr2) != i7) { Log.d("ExifInterface", "Failed to read " + i7 + " bytes."); return; } i3 = i9 + i7; System.arraycopy(bArr2, 0, bArr, i4, i7); i4 += i7; } this.o0 = bArr; if (this.l0) { this.m0 = (int) b2[0]; this.n0 = i2; return; } return; } Log.w("ExifInterface", "stripByteCounts should not be null or have zero length."); return; } Log.w("ExifInterface", "stripOffsets should not be null or have zero length."); } private static boolean q(BufferedInputStream bufferedInputStream) { byte[] bArr = V; bufferedInputStream.mark(bArr.length); byte[] bArr2 = new byte[bArr.length]; bufferedInputStream.read(bArr2); bufferedInputStream.reset(); int i2 = 0; while (true) { byte[] bArr3 = V; if (i2 >= bArr3.length) { return true; } if (bArr2[i2] != bArr3[i2]) { return false; } i2++; } } private boolean r(byte[] bArr) { b bVar; long readInt; byte[] bArr2; b bVar2 = null; try { try { bVar = new b(bArr); } catch (Exception e2) { e = e2; } } catch (Throwable th) { th = th; } try { readInt = bVar.readInt(); bArr2 = new byte[4]; bVar.read(bArr2); } catch (Exception e3) { e = e3; bVar2 = bVar; if (a) { Log.d("ExifInterface", "Exception parsing HEIF file type box.", e); } if (bVar2 != null) { bVar2.close(); } return false; } catch (Throwable th2) { th = th2; bVar2 = bVar; if (bVar2 != null) { bVar2.close(); } throw th; } if (!Arrays.equals(bArr2, h)) { bVar.close(); return false; } long j2 = 16; if (readInt == 1) { readInt = bVar.readLong(); if (readInt < 16) { bVar.close(); return false; } } else { j2 = 8; } if (readInt > bArr.length) { readInt = bArr.length; } long j3 = readInt - j2; if (j3 < 8) { bVar.close(); return false; } byte[] bArr3 = new byte[4]; boolean z2 = false; boolean z3 = false; for (long j4 = 0; j4 < j3 / 4; j4++) { if (bVar.read(bArr3) != 4) { bVar.close(); return false; } if (j4 != 1) { if (Arrays.equals(bArr3, i)) { z2 = true; } else if (Arrays.equals(bArr3, j)) { z3 = true; } if (z2 && z3) { bVar.close(); return true; } } } bVar.close(); return false; } private static boolean s(byte[] bArr) { int i2 = 0; while (true) { byte[] bArr2 = g; if (i2 >= bArr2.length) { return true; } if (bArr[i2] != bArr2[i2]) { return false; } i2++; } } private boolean t(byte[] bArr) { b bVar = null; try { b bVar2 = new b(bArr); try { ByteOrder E2 = E(bVar2); this.i0 = E2; bVar2.i(E2); short readShort = bVar2.readShort(); boolean z2 = readShort == 20306 || readShort == 21330; bVar2.close(); return z2; } catch (Exception unused) { bVar = bVar2; if (bVar != null) { bVar.close(); } return false; } catch (Throwable th) { th = th; bVar = bVar2; if (bVar != null) { bVar.close(); } throw th; } } catch (Exception unused2) { } catch (Throwable th2) { th = th2; } } private boolean u(byte[] bArr) { int i2 = 0; while (true) { byte[] bArr2 = m; if (i2 >= bArr2.length) { return true; } if (bArr[i2] != bArr2[i2]) { return false; } i2++; } } private boolean v(byte[] bArr) { byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset()); for (int i2 = 0; i2 < bytes.length; i2++) { if (bArr[i2] != bytes[i2]) { return false; } } return true; } private boolean w(byte[] bArr) { b bVar = null; try { b bVar2 = new b(bArr); try { ByteOrder E2 = E(bVar2); this.i0 = E2; bVar2.i(E2); boolean z2 = bVar2.readShort() == 85; bVar2.close(); return z2; } catch (Exception unused) { bVar = bVar2; if (bVar != null) { bVar.close(); } return false; } catch (Throwable th) { th = th; bVar = bVar2; if (bVar != null) { bVar.close(); } throw th; } } catch (Exception unused2) { } catch (Throwable th2) { th = th2; } } private static boolean x(FileDescriptor fileDescriptor) { if (Build.VERSION.SDK_INT >= 21) { try { b.a.c(fileDescriptor, 0L, OsConstants.SEEK_CUR); return true; } catch (Exception unused) { if (a) { Log.d("ExifInterface", "The file descriptor for the given input is not seekable"); } } } return false; } private boolean y(HashMap hashMap) { c cVar; int i2; c cVar2 = (c) hashMap.get("BitsPerSample"); if (cVar2 != null) { int[] iArr = (int[]) cVar2.k(this.i0); int[] iArr2 = f1602d; if (Arrays.equals(iArr2, iArr)) { return true; } if (this.e0 == 3 && (cVar = (c) hashMap.get("PhotometricInterpretation")) != null && (((i2 = cVar.i(this.i0)) == 1 && Arrays.equals(iArr, f1604f)) || (i2 == 6 && Arrays.equals(iArr, iArr2)))) { return true; } } if (!a) { return false; } Log.d("ExifInterface", "Unsupported data type value"); return false; } private boolean z(HashMap hashMap) { c cVar = (c) hashMap.get("ImageLength"); c cVar2 = (c) hashMap.get("ImageWidth"); if (cVar == null || cVar2 == null) { return false; } return cVar.i(this.i0) <= 512 && cVar2.i(this.i0) <= 512; } public String b(String str) { Objects.requireNonNull(str, "tag shouldn't be null"); c d2 = d(str); if (d2 != null) { if (!S.contains(str)) { return d2.j(this.i0); } if (str.equals("GPSTimeStamp")) { int i2 = d2.a; if (i2 != 5 && i2 != 10) { Log.w("ExifInterface", "GPS Timestamp format is not rational. format=" + d2.a); return null; } e[] eVarArr = (e[]) d2.k(this.i0); if (eVarArr != null && eVarArr.length == 3) { return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVarArr[0].a) / ((float) eVarArr[0].f1611b))), Integer.valueOf((int) (((float) eVarArr[1].a) / ((float) eVarArr[1].f1611b))), Integer.valueOf((int) (((float) eVarArr[2].a) / ((float) eVarArr[2].f1611b)))); } Log.w("ExifInterface", "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr)); return null; } try { return Double.toString(d2.h(this.i0)); } catch (NumberFormatException unused) { } } return null; } public int c(String str, int i2) { Objects.requireNonNull(str, "tag shouldn't be null"); c d2 = d(str); if (d2 == null) { return i2; } try { return d2.i(this.i0); } catch (NumberFormatException unused) { return i2; } } public static class f extends b { f(byte[] bArr) { super(bArr); this.r.mark(Integer.MAX_VALUE); } public void p(long j) { int i = this.t; if (i > j) { this.t = 0; this.r.reset(); } else { j -= i; } m((int) j); } f(InputStream inputStream) { super(inputStream); if (inputStream.markSupported()) { this.r.mark(Integer.MAX_VALUE); return; } throw new IllegalArgumentException("Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset"); } } public a(InputStream inputStream, int i2) { d[][] dVarArr = O; this.g0 = new HashMap[dVarArr.length]; this.h0 = new HashSet(dVarArr.length); this.i0 = ByteOrder.BIG_ENDIAN; Objects.requireNonNull(inputStream, "inputStream cannot be null"); this.b0 = null; if (i2 == 1) { BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, V.length); if (!q(bufferedInputStream)) { Log.w("ExifInterface", "Given data does not follow the structure of an Exif-only data."); return; } this.f0 = true; this.d0 = null; this.c0 = null; inputStream = bufferedInputStream; } else if (inputStream instanceof AssetManager.AssetInputStream) { this.d0 = (AssetManager.AssetInputStream) inputStream; this.c0 = null; } else { if (inputStream instanceof FileInputStream) { FileInputStream fileInputStream = (FileInputStream) inputStream; if (x(fileInputStream.getFD())) { this.d0 = null; this.c0 = fileInputStream.getFD(); } } this.d0 = null; this.c0 = null; } B(inputStream); } public static class d { public final int a; public final String f1608b; public final int f1609c; public final int f1610d; d(String str, int i, int i2) { this.f1608b = str; this.a = i; this.f1609c = i2; this.f1610d = -1; } boolean a(int i) { int i2; int i3 = this.f1609c; if (i3 == 7 || i == 7 || i3 == i || (i2 = this.f1610d) == i) { return true; } if ((i3 == 4 || i2 == 4) && i == 3) { return true; } if ((i3 == 9 || i2 == 9) && i == 8) { return true; } return (i3 == 12 || i2 == 12) && i == 11; } d(String str, int i, int i2, int i3) { this.f1608b = str; this.a = i; this.f1609c = i2; this.f1610d = i3; } } }