MD5 校验值:328357c6f846d37b47ed4cc8f5415f3d
a.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package c.i.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 android.util.Pair; import c.i.a.b; import j$.util.DesugarTimeZone; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.DataInput; import java.io.DataInputStream; import java.io.EOFException; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; 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.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.CRC32; public class a { private static SimpleDateFormat A; private static final e[] E; private static final e[] F; private static final e[] G; private static final e[] H; private static final e[] I; private static final e J; private static final e[] K; private static final e[] L; private static final e[] M; private static final e[] N; static final e[][] O; private static final e[] P; private static final HashMap<Integer, e>[] Q; private static final HashMap<String, e>[] 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, d>[] 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 boolean v0; private static final boolean a = Log.isLoggable("ExifInterface", 3); private static final List<Integer> f1432b = Arrays.asList(1, 6, 3, 8); private static final List<Integer> f1433c = Arrays.asList(2, 7, 4, 5); public static final int[] f1434d = {8, 8, 8}; public static final int[] f1435e = {4}; public static final int[] f1436f = {8}; static final byte[] f1437g = {-1, -40, -1}; private static final byte[] f1438h = {102, 116, 121, 112}; private static final byte[] f1439i = {109, 105, 102, 49}; private static final byte[] f1440j = {104, 101, 105, 99}; private static final byte[] f1441k = {79, 76, 89, 77, 80, 0}; private static final byte[] f1442l = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73}; private static final byte[] f1443m = {-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 C0064a extends MediaDataSource { long p; final g q; C0064a(g gVar) { this.q = gVar; } @Override public void close() { } @Override public long getSize() { return -1L; } @Override public int readAt(long j2, byte[] bArr, int i2, int i3) { if (i3 == 0) { return 0; } if (j2 < 0) { return -1; } try { long j3 = this.p; if (j3 != j2) { if (j3 >= 0 && j2 >= j3 + this.q.available()) { return -1; } this.q.f(j2); this.p = j2; } if (i3 > this.q.available()) { i3 = this.q.available(); } int read = this.q.read(bArr, i2, i3); 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(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; } 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 c(ByteOrder byteOrder) { this.s = byteOrder; } public void e(int i2) { int i3 = 0; while (i3 < i2) { int i4 = i2 - i3; int skip = (int) this.r.skip(i4); if (skip <= 0) { if (this.u == null) { this.u = new byte[8192]; } skip = this.r.read(this.u, 0, Math.min(8192, i4)); if (skip == -1) { throw new EOFException("Reached EOF while skipping " + i2 + " bytes."); } } i3 += skip; } this.t += i3; } @Override public void mark(int i2) { throw new UnsupportedOperationException("Mark is currently unsupported"); } @Override public int read() { this.t++; return this.r.read(); } @Override public int read(byte[] bArr, int i2, int i3) { int read = this.r.read(bArr, i2, i3); this.t += read; return 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) { this.t += bArr.length; this.r.readFully(bArr); } @Override public void readFully(byte[] bArr, int i2, int i3) { this.t += i3; this.r.readFully(bArr, i2, i3); } @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) { throw new EOFException(); } 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); } @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) { throw new EOFException(); } 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); } @Override public short readShort() { this.t += 2; int read = this.r.read(); int read2 = this.r.read(); if ((read | read2) < 0) { throw new EOFException(); } 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); } @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) { throw new EOFException(); } 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); } @Override public void reset() { throw new UnsupportedOperationException("Reset is currently unsupported"); } @Override public int skipBytes(int i2) { throw new UnsupportedOperationException("skipBytes is currently unsupported"); } } public static class c extends FilterOutputStream { final OutputStream p; private ByteOrder q; public c(OutputStream outputStream, ByteOrder byteOrder) { super(outputStream); this.p = outputStream; this.q = byteOrder; } public void a(ByteOrder byteOrder) { this.q = byteOrder; } public void b(int i2) { this.p.write(i2); } public void c(int i2) { OutputStream outputStream; int i3; ByteOrder byteOrder = this.q; if (byteOrder == ByteOrder.LITTLE_ENDIAN) { this.p.write((i2 >>> 0) & 255); this.p.write((i2 >>> 8) & 255); this.p.write((i2 >>> 16) & 255); outputStream = this.p; i3 = i2 >>> 24; } else { if (byteOrder != ByteOrder.BIG_ENDIAN) { return; } this.p.write((i2 >>> 24) & 255); this.p.write((i2 >>> 16) & 255); this.p.write((i2 >>> 8) & 255); outputStream = this.p; i3 = i2 >>> 0; } outputStream.write(i3 & 255); } public void e(short s) { OutputStream outputStream; int i2; ByteOrder byteOrder = this.q; if (byteOrder == ByteOrder.LITTLE_ENDIAN) { this.p.write((s >>> 0) & 255); outputStream = this.p; i2 = s >>> 8; } else { if (byteOrder != ByteOrder.BIG_ENDIAN) { return; } this.p.write((s >>> 8) & 255); outputStream = this.p; i2 = s >>> 0; } outputStream.write(i2 & 255); } public void f(long j2) { c((int) j2); } public void g(int i2) { e((short) i2); } @Override public void write(byte[] bArr) { this.p.write(bArr); } @Override public void write(byte[] bArr, int i2, int i3) { this.p.write(bArr, i2, i3); } } public static class d { public final int a; public final int f1444b; public final long f1445c; public final byte[] f1446d; d(int i2, int i3, long j2, byte[] bArr) { this.a = i2; this.f1444b = i3; this.f1445c = j2; this.f1446d = bArr; } d(int i2, int i3, byte[] bArr) { this(i2, i3, -1L, bArr); } public static d a(String str) { if (str.length() == 1 && str.charAt(0) >= '0' && str.charAt(0) <= '1') { return new d(1, 1, new byte[]{(byte) (str.charAt(0) - '0')}); } byte[] bytes = str.getBytes(a.U); return new d(1, bytes.length, bytes); } public static d b(double[] dArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[12] * dArr.length]); wrap.order(byteOrder); for (double d2 : dArr) { wrap.putDouble(d2); } return new d(12, dArr.length, wrap.array()); } public static d c(int[] iArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[9] * iArr.length]); wrap.order(byteOrder); for (int i2 : iArr) { wrap.putInt(i2); } return new d(9, iArr.length, wrap.array()); } public static d d(f[] fVarArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[10] * fVarArr.length]); wrap.order(byteOrder); for (f fVar : fVarArr) { wrap.putInt((int) fVar.a); wrap.putInt((int) fVar.f1450b); } return new d(10, fVarArr.length, wrap.array()); } public static d e(String str) { byte[] bytes = (str + (char) 0).getBytes(a.U); return new d(2, bytes.length, bytes); } public static d f(long j2, ByteOrder byteOrder) { return g(new long[]{j2}, byteOrder); } public static d g(long[] jArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[4] * jArr.length]); wrap.order(byteOrder); for (long j2 : jArr) { wrap.putInt((int) j2); } return new d(4, jArr.length, wrap.array()); } public static d h(f fVar, ByteOrder byteOrder) { return i(new f[]{fVar}, byteOrder); } public static d i(f[] fVarArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[5] * fVarArr.length]); wrap.order(byteOrder); for (f fVar : fVarArr) { wrap.putInt((int) fVar.a); wrap.putInt((int) fVar.f1450b); } return new d(5, fVarArr.length, wrap.array()); } public static d j(int i2, ByteOrder byteOrder) { return k(new int[]{i2}, byteOrder); } public static d k(int[] iArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[a.C[3] * iArr.length]); wrap.order(byteOrder); for (int i2 : iArr) { wrap.putShort((short) i2); } return new d(3, iArr.length, wrap.array()); } public double l(ByteOrder byteOrder) { Object o = o(byteOrder); if (o == null) { throw new NumberFormatException("NULL can't be converted to a double value"); } if (o instanceof String) { return Double.parseDouble((String) o); } if (o instanceof long[]) { if (((long[]) o).length == 1) { return r5[0]; } throw new NumberFormatException("There are more than one component"); } if (o instanceof int[]) { if (((int[]) o).length == 1) { return r5[0]; } throw new NumberFormatException("There are more than one component"); } if (o instanceof double[]) { double[] dArr = (double[]) o; if (dArr.length == 1) { return dArr[0]; } throw new NumberFormatException("There are more than one component"); } if (!(o instanceof f[])) { throw new NumberFormatException("Couldn't find a double value"); } f[] fVarArr = (f[]) o; if (fVarArr.length == 1) { return fVarArr[0].a(); } throw new NumberFormatException("There are more than one component"); } public int m(ByteOrder byteOrder) { Object o = o(byteOrder); if (o == null) { throw new NumberFormatException("NULL can't be converted to a integer value"); } if (o instanceof String) { return Integer.parseInt((String) o); } if (o instanceof long[]) { long[] jArr = (long[]) o; if (jArr.length == 1) { return (int) jArr[0]; } throw new NumberFormatException("There are more than one component"); } if (!(o instanceof int[])) { throw new NumberFormatException("Couldn't find a integer value"); } int[] iArr = (int[]) o; if (iArr.length == 1) { return iArr[0]; } throw new NumberFormatException("There are more than one component"); } public String n(ByteOrder byteOrder) { Object o = o(byteOrder); if (o == null) { return null; } if (o instanceof String) { return (String) o; } StringBuilder sb = new StringBuilder(); int i2 = 0; if (o instanceof long[]) { long[] jArr = (long[]) o; while (i2 < jArr.length) { sb.append(jArr[i2]); i2++; if (i2 != jArr.length) { sb.append(","); } } return sb.toString(); } if (o instanceof int[]) { int[] iArr = (int[]) o; while (i2 < iArr.length) { sb.append(iArr[i2]); i2++; if (i2 != iArr.length) { sb.append(","); } } return sb.toString(); } if (o instanceof double[]) { double[] dArr = (double[]) o; while (i2 < dArr.length) { sb.append(dArr[i2]); i2++; if (i2 != dArr.length) { sb.append(","); } } return sb.toString(); } if (!(o instanceof f[])) { return null; } f[] fVarArr = (f[]) o; while (i2 < fVarArr.length) { sb.append(fVarArr[i2].a); sb.append('/'); sb.append(fVarArr[i2].f1450b); i2++; if (i2 != fVarArr.length) { sb.append(","); } } return sb.toString(); } Object o(ByteOrder byteOrder) { b bVar; InputStream inputStream; byte b2; byte[] bArr; InputStream inputStream2 = null; try { try { bVar = new b(this.f1446d); try { bVar.c(byteOrder); boolean z = true; int i2 = 0; switch (this.a) { case 1: case 6: byte[] bArr2 = this.f1446d; if (bArr2.length != 1 || bArr2[0] < 0 || bArr2[0] > 1) { String str = new String(this.f1446d, a.U); try { bVar.close(); } catch (IOException e2) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e2); } return str; } String str2 = new String(new char[]{(char) (this.f1446d[0] + 48)}); try { bVar.close(); } catch (IOException e3) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e3); } return str2; case 2: case 7: if (this.f1444b >= a.D.length) { int i3 = 0; while (true) { bArr = a.D; if (i3 < bArr.length) { if (this.f1446d[i3] != bArr[i3]) { z = false; } else { i3++; } } } if (z) { i2 = bArr.length; } } StringBuilder sb = new StringBuilder(); while (i2 < this.f1444b && (b2 = this.f1446d[i2]) != 0) { if (b2 >= 32) { sb.append((char) b2); } else { sb.append('?'); } i2++; } 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.f1444b]; while (i2 < this.f1444b) { iArr[i2] = bVar.readUnsignedShort(); i2++; } try { bVar.close(); } catch (IOException e5) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e5); } return iArr; case 4: long[] jArr = new long[this.f1444b]; while (i2 < this.f1444b) { jArr[i2] = bVar.b(); i2++; } try { bVar.close(); } catch (IOException e6) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e6); } return jArr; case 5: f[] fVarArr = new f[this.f1444b]; while (i2 < this.f1444b) { fVarArr[i2] = new f(bVar.b(), bVar.b()); i2++; } try { bVar.close(); } catch (IOException e7) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e7); } return fVarArr; case 8: int[] iArr2 = new int[this.f1444b]; while (i2 < this.f1444b) { iArr2[i2] = bVar.readShort(); i2++; } try { bVar.close(); } catch (IOException e8) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e8); } return iArr2; case 9: int[] iArr3 = new int[this.f1444b]; while (i2 < this.f1444b) { iArr3[i2] = bVar.readInt(); i2++; } try { bVar.close(); } catch (IOException e9) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e9); } return iArr3; case 10: f[] fVarArr2 = new f[this.f1444b]; while (i2 < this.f1444b) { fVarArr2[i2] = new f(bVar.readInt(), bVar.readInt()); i2++; } try { bVar.close(); } catch (IOException e10) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e10); } return fVarArr2; case 11: double[] dArr = new double[this.f1444b]; while (i2 < this.f1444b) { dArr[i2] = bVar.readFloat(); i2++; } try { bVar.close(); } catch (IOException e11) { Log.e("ExifInterface", "IOException occurred while closing InputStream", e11); } return dArr; case 12: double[] dArr2 = new double[this.f1444b]; while (i2 < this.f1444b) { dArr2[i2] = bVar.readDouble(); i2++; } 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 int p() { return a.C[this.a] * this.f1444b; } public String toString() { return "(" + a.B[this.a] + ", data length:" + this.f1446d.length + ")"; } } public static class e { public final int a; public final String f1447b; public final int f1448c; public final int f1449d; e(String str, int i2, int i3) { this.f1447b = str; this.a = i2; this.f1448c = i3; this.f1449d = -1; } e(String str, int i2, int i3, int i4) { this.f1447b = str; this.a = i2; this.f1448c = i3; this.f1449d = i4; } boolean a(int i2) { int i3; int i4 = this.f1448c; if (i4 == 7 || i2 == 7 || i4 == i2 || (i3 = this.f1449d) == i2) { return true; } if ((i4 == 4 || i3 == 4) && i2 == 3) { return true; } if ((i4 == 9 || i3 == 9) && i2 == 8) { return true; } return (i4 == 12 || i3 == 12) && i2 == 11; } } public static class f { public final long a; public final long f1450b; f(double d2) { this((long) (d2 * 10000.0d), 10000L); } f(long j2, long j3) { if (j3 == 0) { this.a = 0L; this.f1450b = 1L; } else { this.a = j2; this.f1450b = j3; } } public double a() { return this.a / this.f1450b; } public String toString() { return this.a + "/" + this.f1450b; } } public static class g extends b { g(InputStream inputStream) { super(inputStream); if (!inputStream.markSupported()) { throw new IllegalArgumentException("Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset"); } this.r.mark(Integer.MAX_VALUE); } g(byte[] bArr) { super(bArr); this.r.mark(Integer.MAX_VALUE); } public void f(long j2) { int i2 = this.t; if (i2 > j2) { this.t = 0; this.r.reset(); } else { j2 -= i2; } e((int) j2); } } static { e[] eVarArr = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e("ImageWidth", 256, 3, 4), new e("ImageLength", 257, 3, 4), new e("BitsPerSample", 258, 3), new e("Compression", 259, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273, 3, 4), new e("Orientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278, 3, 4), new e("StripByteCounts", 279, 3, 4), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("SensorTopBorder", 4, 4), new e("SensorLeftBorder", 5, 4), new e("SensorBottomBorder", 6, 4), new e("SensorRightBorder", 7, 4), new e("ISO", 23, 3), new e("JpgFromRaw", 46, 7), new e("Xmp", 700, 1)}; E = eVarArr; e[] eVarArr2 = {new e("ExposureTime", 33434, 5), new e("FNumber", 33437, 5), new e("ExposureProgram", 34850, 3), new e("SpectralSensitivity", 34852, 2), new e("PhotographicSensitivity", 34855, 3), new e("OECF", 34856, 7), new e("SensitivityType", 34864, 3), new e("StandardOutputSensitivity", 34865, 4), new e("RecommendedExposureIndex", 34866, 4), new e("ISOSpeed", 34867, 4), new e("ISOSpeedLatitudeyyy", 34868, 4), new e("ISOSpeedLatitudezzz", 34869, 4), new e("ExifVersion", 36864, 2), new e("DateTimeOriginal", 36867, 2), new e("DateTimeDigitized", 36868, 2), new e("OffsetTime", 36880, 2), new e("OffsetTimeOriginal", 36881, 2), new e("OffsetTimeDigitized", 36882, 2), new e("ComponentsConfiguration", 37121, 7), new e("CompressedBitsPerPixel", 37122, 5), new e("ShutterSpeedValue", 37377, 10), new e("ApertureValue", 37378, 5), new e("BrightnessValue", 37379, 10), new e("ExposureBiasValue", 37380, 10), new e("MaxApertureValue", 37381, 5), new e("SubjectDistance", 37382, 5), new e("MeteringMode", 37383, 3), new e("LightSource", 37384, 3), new e("Flash", 37385, 3), new e("FocalLength", 37386, 5), new e("SubjectArea", 37396, 3), new e("MakerNote", 37500, 7), new e("UserComment", 37510, 7), new e("SubSecTime", 37520, 2), new e("SubSecTimeOriginal", 37521, 2), new e("SubSecTimeDigitized", 37522, 2), new e("FlashpixVersion", 40960, 7), new e("ColorSpace", 40961, 3), new e("PixelXDimension", 40962, 3, 4), new e("PixelYDimension", 40963, 3, 4), new e("RelatedSoundFile", 40964, 2), new e("InteroperabilityIFDPointer", 40965, 4), new e("FlashEnergy", 41483, 5), new e("SpatialFrequencyResponse", 41484, 7), new e("FocalPlaneXResolution", 41486, 5), new e("FocalPlaneYResolution", 41487, 5), new e("FocalPlaneResolutionUnit", 41488, 3), new e("SubjectLocation", 41492, 3), new e("ExposureIndex", 41493, 5), new e("SensingMethod", 41495, 3), new e("FileSource", 41728, 7), new e("SceneType", 41729, 7), new e("CFAPattern", 41730, 7), new e("CustomRendered", 41985, 3), new e("ExposureMode", 41986, 3), new e("WhiteBalance", 41987, 3), new e("DigitalZoomRatio", 41988, 5), new e("FocalLengthIn35mmFilm", 41989, 3), new e("SceneCaptureType", 41990, 3), new e("GainControl", 41991, 3), new e("Contrast", 41992, 3), new e("Saturation", 41993, 3), new e("Sharpness", 41994, 3), new e("DeviceSettingDescription", 41995, 7), new e("SubjectDistanceRange", 41996, 3), new e("ImageUniqueID", 42016, 2), new e("CameraOwnerName", 42032, 2), new e("BodySerialNumber", 42033, 2), new e("LensSpecification", 42034, 5), new e("LensMake", 42035, 2), new e("LensModel", 42036, 2), new e("Gamma", 42240, 5), new e("DNGVersion", 50706, 1), new e("DefaultCropSize", 50720, 3, 4)}; F = eVarArr2; e[] eVarArr3 = {new e("GPSVersionID", 0, 1), new e("GPSLatitudeRef", 1, 2), new e("GPSLatitude", 2, 5, 10), new e("GPSLongitudeRef", 3, 2), new e("GPSLongitude", 4, 5, 10), new e("GPSAltitudeRef", 5, 1), new e("GPSAltitude", 6, 5), new e("GPSTimeStamp", 7, 5), new e("GPSSatellites", 8, 2), new e("GPSStatus", 9, 2), new e("GPSMeasureMode", 10, 2), new e("GPSDOP", 11, 5), new e("GPSSpeedRef", 12, 2), new e("GPSSpeed", 13, 5), new e("GPSTrackRef", 14, 2), new e("GPSTrack", 15, 5), new e("GPSImgDirectionRef", 16, 2), new e("GPSImgDirection", 17, 5), new e("GPSMapDatum", 18, 2), new e("GPSDestLatitudeRef", 19, 2), new e("GPSDestLatitude", 20, 5), new e("GPSDestLongitudeRef", 21, 2), new e("GPSDestLongitude", 22, 5), new e("GPSDestBearingRef", 23, 2), new e("GPSDestBearing", 24, 5), new e("GPSDestDistanceRef", 25, 2), new e("GPSDestDistance", 26, 5), new e("GPSProcessingMethod", 27, 7), new e("GPSAreaInformation", 28, 7), new e("GPSDateStamp", 29, 2), new e("GPSDifferential", 30, 3), new e("GPSHPositioningError", 31, 5)}; G = eVarArr3; e[] eVarArr4 = {new e("InteroperabilityIndex", 1, 2)}; H = eVarArr4; e[] eVarArr5 = {new e("NewSubfileType", 254, 4), new e("SubfileType", 255, 4), new e("ThumbnailImageWidth", 256, 3, 4), new e("ThumbnailImageLength", 257, 3, 4), new e("BitsPerSample", 258, 3), new e("Compression", 259, 3), new e("PhotometricInterpretation", 262, 3), new e("ImageDescription", 270, 2), new e("Make", 271, 2), new e("Model", 272, 2), new e("StripOffsets", 273, 3, 4), new e("ThumbnailOrientation", 274, 3), new e("SamplesPerPixel", 277, 3), new e("RowsPerStrip", 278, 3, 4), new e("StripByteCounts", 279, 3, 4), new e("XResolution", 282, 5), new e("YResolution", 283, 5), new e("PlanarConfiguration", 284, 3), new e("ResolutionUnit", 296, 3), new e("TransferFunction", 301, 3), new e("Software", 305, 2), new e("DateTime", 306, 2), new e("Artist", 315, 2), new e("WhitePoint", 318, 5), new e("PrimaryChromaticities", 319, 5), new e("SubIFDPointer", 330, 4), new e("JPEGInterchangeFormat", 513, 4), new e("JPEGInterchangeFormatLength", 514, 4), new e("YCbCrCoefficients", 529, 5), new e("YCbCrSubSampling", 530, 3), new e("YCbCrPositioning", 531, 3), new e("ReferenceBlackWhite", 532, 5), new e("Xmp", 700, 1), new e("Copyright", 33432, 2), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("DNGVersion", 50706, 1), new e("DefaultCropSize", 50720, 3, 4)}; I = eVarArr5; J = new e("StripOffsets", 273, 3); e[] eVarArr6 = {new e("ThumbnailImage", 256, 7), new e("CameraSettingsIFDPointer", 8224, 4), new e("ImageProcessingIFDPointer", 8256, 4)}; K = eVarArr6; e[] eVarArr7 = {new e("PreviewImageStart", 257, 4), new e("PreviewImageLength", 258, 4)}; L = eVarArr7; e[] eVarArr8 = {new e("AspectFrame", 4371, 3)}; M = eVarArr8; e[] eVarArr9 = {new e("ColorSpace", 55, 3)}; N = eVarArr9; e[][] eVarArr10 = {eVarArr, eVarArr2, eVarArr3, eVarArr4, eVarArr5, eVarArr, eVarArr6, eVarArr7, eVarArr8, eVarArr9}; O = eVarArr10; P = new e[]{new e("SubIFDPointer", 330, 4), new e("ExifIFDPointer", 34665, 4), new e("GPSInfoIFDPointer", 34853, 4), new e("InteroperabilityIFDPointer", 40965, 4), new e("CameraSettingsIFDPointer", 8224, 1), new e("ImageProcessingIFDPointer", 8256, 1)}; Q = new HashMap[eVarArr10.length]; R = new HashMap[eVarArr10.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(DesugarTimeZone.getTimeZone("UTC")); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale); A = simpleDateFormat2; simpleDateFormat2.setTimeZone(DesugarTimeZone.getTimeZone("UTC")); int i2 = 0; while (true) { e[][] eVarArr11 = O; if (i2 >= eVarArr11.length) { HashMap<Integer, Integer> hashMap = T; e[] eVarArr12 = P; hashMap.put(Integer.valueOf(eVarArr12[0].a), 5); hashMap.put(Integer.valueOf(eVarArr12[1].a), 1); hashMap.put(Integer.valueOf(eVarArr12[2].a), 2); hashMap.put(Integer.valueOf(eVarArr12[3].a), 3); hashMap.put(Integer.valueOf(eVarArr12[4].a), 7); hashMap.put(Integer.valueOf(eVarArr12[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; } Q[i2] = new HashMap<>(); R[i2] = new HashMap<>(); for (e eVar : eVarArr11[i2]) { Q[i2].put(Integer.valueOf(eVar.a), eVar); R[i2].put(eVar.f1447b, eVar); } i2++; } } public a(String str) { e[][] eVarArr = O; this.g0 = new HashMap[eVarArr.length]; this.h0 = new HashSet(eVarArr.length); this.i0 = ByteOrder.BIG_ENDIAN; Objects.requireNonNull(str, "filename cannot be null"); u(str); } private boolean A(byte[] bArr) { b bVar = null; try { b bVar2 = new b(bArr); try { ByteOrder J2 = J(bVar2); this.i0 = J2; bVar2.c(J2); 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 B(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 C(HashMap hashMap) { d dVar; int m2; d dVar2 = (d) hashMap.get("BitsPerSample"); if (dVar2 != null) { int[] iArr = (int[]) dVar2.o(this.i0); int[] iArr2 = f1434d; if (Arrays.equals(iArr2, iArr)) { return true; } if (this.e0 == 3 && (dVar = (d) hashMap.get("PhotometricInterpretation")) != null && (((m2 = dVar.m(this.i0)) == 1 && Arrays.equals(iArr, f1436f)) || (m2 == 6 && Arrays.equals(iArr, iArr2)))) { return true; } } if (!a) { return false; } Log.d("ExifInterface", "Unsupported data type value"); return false; } private static boolean D(int i2) { return i2 == 4 || i2 == 13 || i2 == 14 || i2 == 3 || i2 == 0; } private boolean E(HashMap hashMap) { d dVar = (d) hashMap.get("ImageLength"); d dVar2 = (d) hashMap.get("ImageWidth"); if (dVar == null || dVar2 == null) { return false; } return dVar.m(this.i0) <= 512 && dVar2.m(this.i0) <= 512; } private boolean F(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 G(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) { I(); } } } 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 = h(bufferedInputStream); inputStream = bufferedInputStream; } if (V(this.e0)) { g gVar = new g(inputStream); if (this.f0) { n(gVar); } else { int i3 = this.e0; if (i3 == 12) { f(gVar); } else if (i3 == 7) { i(gVar); } else if (i3 == 10) { m(gVar); } else { l(gVar); } } gVar.f(this.q0); U(gVar); } else { b bVar = new b(inputStream); int i4 = this.e0; if (i4 == 4) { g(bVar, 0, 0); } else if (i4 == 13) { j(bVar); } else if (i4 == 9) { k(bVar); } else if (i4 == 14) { q(bVar); } } } private void H(b bVar) { ByteOrder J2 = J(bVar); this.i0 = J2; bVar.c(J2); 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.e(i3); } } private void I() { 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, d> entry : this.g0[i2].entrySet()) { d value = entry.getValue(); Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.n(this.i0) + "'"); } } } private ByteOrder J(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 K(byte[] bArr, int i2) { g gVar = new g(bArr); H(gVar); L(gVar, i2); } private void L(g gVar, int i2) { StringBuilder sb; String str; String str2; short s2; long j2; boolean z2; StringBuilder sb2; short s3; long j3; String str3; int i3; String str4; long j4; int readUnsignedShort; String str5; this.h0.add(Integer.valueOf(gVar.t)); short readShort = gVar.readShort(); String str6 = "ExifInterface"; if (a) { Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort)); } if (readShort <= 0) { return; } char c2 = 0; short s4 = 0; while (s4 < readShort) { int readUnsignedShort2 = gVar.readUnsignedShort(); int readUnsignedShort3 = gVar.readUnsignedShort(); int readInt = gVar.readInt(); long a2 = gVar.a() + 4; e eVar = 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] = eVar != null ? eVar.f1447b : null; objArr[3] = Integer.valueOf(readUnsignedShort3); objArr[4] = Integer.valueOf(readInt); Log.d(str6, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr)); } if (eVar == null) { if (z3) { sb2 = new StringBuilder(); sb2.append("Skip the tag entry since tag number is not defined: "); sb2.append(readUnsignedShort2); Log.d(str6, sb2.toString()); } str2 = str6; s2 = s4; } else { if (readUnsignedShort3 > 0) { if (readUnsignedShort3 < C.length) { if (eVar.a(readUnsignedShort3)) { if (readUnsignedShort3 == 7) { readUnsignedShort3 = eVar.f1448c; } str2 = str6; s2 = s4; j2 = readInt * r7[readUnsignedShort3]; if (j2 < 0 || j2 > 2147483647L) { if (z3) { Log.d(str2, "Skip the tag entry since the number of components is invalid: " + readInt); } z2 = false; if (z2) { if (j2 > 4) { int readInt2 = gVar.readInt(); s3 = readShort; if (z3) { StringBuilder sb3 = new StringBuilder(); j3 = a2; sb3.append("seek to data offset: "); sb3.append(readInt2); Log.d(str2, sb3.toString()); } else { j3 = a2; } if (this.e0 == 7) { if ("MakerNote".equals(eVar.f1447b)) { this.r0 = readInt2; } else if (i2 == 6 && "ThumbnailImage".equals(eVar.f1447b)) { this.s0 = readInt2; this.t0 = readInt; d j5 = d.j(6, this.i0); i3 = readInt; d f2 = d.f(this.s0, this.i0); str3 = str2; d f3 = d.f(this.t0, this.i0); this.g0[4].put("Compression", j5); this.g0[4].put("JPEGInterchangeFormat", f2); this.g0[4].put("JPEGInterchangeFormatLength", f3); gVar.f(readInt2); } } str3 = str2; i3 = readInt; gVar.f(readInt2); } else { s3 = readShort; j3 = a2; str3 = str2; i3 = readInt; } Integer num = T.get(Integer.valueOf(readUnsignedShort2)); if (z3) { str4 = str3; Log.d(str4, "nextIfdType: " + num + " byteCount: " + j2); } else { str4 = str3; } if (num != null) { long j6 = -1; if (readUnsignedShort3 != 3) { if (readUnsignedShort3 == 4) { j6 = gVar.b(); } else if (readUnsignedShort3 == 8) { readUnsignedShort = gVar.readShort(); } else if (readUnsignedShort3 == 9 || readUnsignedShort3 == 13) { readUnsignedShort = gVar.readInt(); } if (z3) { Log.d(str4, String.format("Offset: %d, tagName: %s", Long.valueOf(j6), eVar.f1447b)); } if (j6 <= 0) { if (!this.h0.contains(Integer.valueOf((int) j6))) { gVar.f(j6); L(gVar, num.intValue()); } else if (z3) { str5 = "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j6 + ")"; Log.d(str4, str5); } j4 = j3; } else { if (z3) { str5 = "Skip jump into the IFD since its offset is invalid: " + j6; Log.d(str4, str5); } j4 = j3; } } else { readUnsignedShort = gVar.readUnsignedShort(); } j6 = readUnsignedShort; if (z3) { } if (j6 <= 0) { } } else { j4 = j3; int a3 = gVar.a() + this.q0; byte[] bArr = new byte[(int) j2]; gVar.readFully(bArr); d dVar = new d(readUnsignedShort3, i3, a3, bArr); this.g0[i2].put(eVar.f1447b, dVar); if ("DNGVersion".equals(eVar.f1447b)) { this.e0 = 3; } if ((("Make".equals(eVar.f1447b) || "Model".equals(eVar.f1447b)) && dVar.n(this.i0).contains("PENTAX")) || ("Compression".equals(eVar.f1447b) && dVar.m(this.i0) == 65535)) { this.e0 = 8; } if (gVar.a() == j4) { } } gVar.f(j4); } else { gVar.f(a2); s3 = readShort; str4 = str2; } s4 = (short) (s2 + 1); str6 = str4; readShort = s3; c2 = 0; } else { z2 = true; if (z2) { } s4 = (short) (s2 + 1); str6 = str4; readShort = s3; c2 = 0; } } else { if (z3) { sb2 = new StringBuilder(); sb2.append("Skip the tag entry since data format ("); sb2.append(B[readUnsignedShort3]); sb2.append(") is unexpected for tag: "); sb2.append(eVar.f1447b); Log.d(str6, sb2.toString()); } str2 = str6; s2 = s4; } } } str2 = str6; s2 = s4; if (z3) { Log.d(str2, "Skip the tag entry since data format is invalid: " + readUnsignedShort3); } } j2 = 0; z2 = false; if (z2) { } s4 = (short) (s2 + 1); str6 = str4; readShort = s3; c2 = 0; } String str7 = str6; int readInt3 = gVar.readInt(); boolean z4 = a; if (z4) { Log.d(str7, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3))); } long j7 = readInt3; if (j7 > 0) { if (!this.h0.contains(Integer.valueOf(readInt3))) { gVar.f(j7); if (this.g0[4].isEmpty()) { L(gVar, 4); return; } else { if (this.g0[5].isEmpty()) { L(gVar, 5); return; } return; } } if (!z4) { return; } sb = new StringBuilder(); str = "Stop reading file since re-reading an IFD may cause an infinite loop: "; } else { if (!z4) { return; } sb = new StringBuilder(); str = "Stop reading file since a wrong offset may cause an infinite loop: "; } sb.append(str); sb.append(readInt3); Log.d(str7, sb.toString()); } private void M(String str) { for (int i2 = 0; i2 < O.length; i2++) { this.g0[i2].remove(str); } } private void N(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 O(g gVar, int i2) { d dVar = this.g0[i2].get("ImageLength"); d dVar2 = this.g0[i2].get("ImageWidth"); if (dVar == null || dVar2 == null) { d dVar3 = this.g0[i2].get("JPEGInterchangeFormat"); d dVar4 = this.g0[i2].get("JPEGInterchangeFormatLength"); if (dVar3 == null || dVar4 == null) { return; } int m2 = dVar3.m(this.i0); int m3 = dVar3.m(this.i0); gVar.f(m2); byte[] bArr = new byte[m3]; gVar.read(bArr); g(new b(bArr), m2, i2); } } private void Q(InputStream inputStream, OutputStream outputStream) { if (a) { Log.d("ExifInterface", "saveJpegAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")"); } b bVar = new b(inputStream); c cVar = new c(outputStream, ByteOrder.BIG_ENDIAN); if (bVar.readByte() != -1) { throw new IOException("Invalid marker"); } cVar.b(-1); if (bVar.readByte() != -40) { throw new IOException("Invalid marker"); } cVar.b(-40); d dVar = null; if (d("Xmp") != null && this.v0) { dVar = this.g0[0].remove("Xmp"); } cVar.b(-1); cVar.b(-31); Z(cVar); if (dVar != null) { this.g0[0].put("Xmp", dVar); } byte[] bArr = new byte[4096]; while (bVar.readByte() == -1) { byte readByte = bVar.readByte(); if (readByte == -39 || readByte == -38) { cVar.b(-1); cVar.b(readByte); c.i.a.b.e(bVar, cVar); return; } if (readByte != -31) { cVar.b(-1); cVar.b(readByte); int readUnsignedShort = bVar.readUnsignedShort(); cVar.g(readUnsignedShort); int i2 = readUnsignedShort - 2; if (i2 < 0) { throw new IOException("Invalid length"); } while (i2 > 0) { int read = bVar.read(bArr, 0, Math.min(i2, 4096)); if (read >= 0) { cVar.write(bArr, 0, read); i2 -= read; } } } else { int readUnsignedShort2 = bVar.readUnsignedShort() - 2; if (readUnsignedShort2 < 0) { throw new IOException("Invalid length"); } byte[] bArr2 = new byte[6]; if (readUnsignedShort2 >= 6) { if (bVar.read(bArr2) != 6) { throw new IOException("Invalid exif"); } if (Arrays.equals(bArr2, V)) { bVar.e(readUnsignedShort2 - 6); } } cVar.b(-1); cVar.b(readByte); cVar.g(readUnsignedShort2 + 2); if (readUnsignedShort2 >= 6) { readUnsignedShort2 -= 6; cVar.write(bArr2); } while (readUnsignedShort2 > 0) { int read2 = bVar.read(bArr, 0, Math.min(readUnsignedShort2, 4096)); if (read2 >= 0) { cVar.write(bArr, 0, read2); readUnsignedShort2 -= read2; } } } } throw new IOException("Invalid marker"); } private void R(InputStream inputStream, OutputStream outputStream) { ByteArrayOutputStream byteArrayOutputStream; if (a) { Log.d("ExifInterface", "savePngAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")"); } b bVar = new b(inputStream); ByteOrder byteOrder = ByteOrder.BIG_ENDIAN; c cVar = new c(outputStream, byteOrder); byte[] bArr = f1443m; c.i.a.b.f(bVar, cVar, bArr.length); int i2 = this.q0; if (i2 == 0) { int readInt = bVar.readInt(); cVar.c(readInt); c.i.a.b.f(bVar, cVar, readInt + 4 + 4); } else { c.i.a.b.f(bVar, cVar, ((i2 - bArr.length) - 4) - 4); bVar.e(bVar.readInt() + 4 + 4); } ByteArrayOutputStream byteArrayOutputStream2 = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); } catch (Throwable th) { th = th; } try { c cVar2 = new c(byteArrayOutputStream, byteOrder); Z(cVar2); byte[] byteArray = ((ByteArrayOutputStream) cVar2.p).toByteArray(); cVar.write(byteArray); CRC32 crc32 = new CRC32(); crc32.update(byteArray, 4, byteArray.length - 4); cVar.c((int) crc32.getValue()); c.i.a.b.c(byteArrayOutputStream); c.i.a.b.e(bVar, cVar); } catch (Throwable th2) { th = th2; byteArrayOutputStream2 = byteArrayOutputStream; c.i.a.b.c(byteArrayOutputStream2); throw th; } } private void S(InputStream inputStream, OutputStream outputStream) { ByteArrayOutputStream byteArrayOutputStream; int i2; int i3; int i4; int i5; if (a) { Log.d("ExifInterface", "saveWebpAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")"); } ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN; b bVar = new b(inputStream, byteOrder); c cVar = new c(outputStream, byteOrder); byte[] bArr = q; c.i.a.b.f(bVar, cVar, bArr.length); byte[] bArr2 = r; bVar.e(bArr2.length + 4); ByteArrayOutputStream byteArrayOutputStream2 = null; try { try { byteArrayOutputStream = new ByteArrayOutputStream(); } catch (Exception e2) { e = e2; } } catch (Throwable th) { th = th; } try { c cVar2 = new c(byteArrayOutputStream, byteOrder); int i6 = this.q0; if (i6 != 0) { c.i.a.b.f(bVar, cVar2, ((i6 - ((bArr.length + 4) + bArr2.length)) - 4) - 4); bVar.e(4); bVar.e(bVar.readInt()); } else { byte[] bArr3 = new byte[4]; if (bVar.read(bArr3) != 4) { throw new IOException("Encountered invalid length while parsing WebP chunk type"); } byte[] bArr4 = u; boolean z2 = true; if (!Arrays.equals(bArr3, bArr4)) { byte[] bArr5 = w; if (Arrays.equals(bArr3, bArr5) || Arrays.equals(bArr3, v)) { int readInt = bVar.readInt(); int i7 = readInt % 2 == 1 ? readInt + 1 : readInt; byte[] bArr6 = new byte[3]; if (Arrays.equals(bArr3, bArr5)) { bVar.read(bArr6); byte[] bArr7 = new byte[3]; if (bVar.read(bArr7) != 3 || !Arrays.equals(t, bArr7)) { throw new IOException("Encountered error while checking VP8 signature"); } i2 = bVar.readInt(); i3 = (i2 << 18) >> 18; i4 = (i2 << 2) >> 18; i7 -= 10; i5 = 0; } else if (!Arrays.equals(bArr3, v)) { i2 = 0; i3 = 0; i4 = 0; i5 = 0; } else { if (bVar.readByte() != 47) { throw new IOException("Encountered error while checking VP8L signature"); } i2 = bVar.readInt(); i5 = i2 & 8; i7 -= 5; i4 = ((i2 << 4) >> 18) + 1; i3 = ((i2 << 18) >> 18) + 1; } cVar2.write(bArr4); cVar2.c(10); byte[] bArr8 = new byte[10]; bArr8[0] = (byte) (bArr8[0] | 8); bArr8[0] = (byte) (bArr8[0] | (i5 << 4)); int i8 = i3 - 1; int i9 = i4 - 1; bArr8[4] = (byte) i8; bArr8[5] = (byte) (i8 >> 8); bArr8[6] = (byte) (i8 >> 16); bArr8[7] = (byte) i9; bArr8[8] = (byte) (i9 >> 8); bArr8[9] = (byte) (i9 >> 16); cVar2.write(bArr8); cVar2.write(bArr3); cVar2.c(readInt); if (Arrays.equals(bArr3, bArr5)) { cVar2.write(bArr6); cVar2.write(t); } else { if (Arrays.equals(bArr3, v)) { cVar2.write(47); } c.i.a.b.f(bVar, cVar2, i7); } cVar2.c(i2); c.i.a.b.f(bVar, cVar2, i7); } c.i.a.b.e(bVar, cVar2); int size = byteArrayOutputStream.size(); byte[] bArr9 = r; cVar.c(size + bArr9.length); cVar.write(bArr9); byteArrayOutputStream.writeTo(cVar); c.i.a.b.c(byteArrayOutputStream); } int readInt2 = bVar.readInt(); byte[] bArr10 = new byte[readInt2 % 2 == 1 ? readInt2 + 1 : readInt2]; bVar.read(bArr10); bArr10[0] = (byte) (8 | bArr10[0]); if (((bArr10[0] >> 1) & 1) != 1) { z2 = false; } cVar2.write(bArr4); cVar2.c(readInt2); cVar2.write(bArr10); if (z2) { b(bVar, cVar2, x, null); while (true) { byte[] bArr11 = new byte[4]; inputStream.read(bArr11); if (!Arrays.equals(bArr11, y)) { break; } else { c(bVar, cVar2, bArr11); } } } else { b(bVar, cVar2, w, v); } } Z(cVar2); c.i.a.b.e(bVar, cVar2); int size2 = byteArrayOutputStream.size(); byte[] bArr92 = r; cVar.c(size2 + bArr92.length); cVar.write(bArr92); byteArrayOutputStream.writeTo(cVar); c.i.a.b.c(byteArrayOutputStream); } catch (Exception e3) { e = e3; byteArrayOutputStream2 = byteArrayOutputStream; throw new IOException("Failed to save WebP file", e); } catch (Throwable th2) { th = th2; byteArrayOutputStream2 = byteArrayOutputStream; c.i.a.b.c(byteArrayOutputStream2); throw th; } } private void U(b bVar) { HashMap<String, d> hashMap = this.g0[4]; d dVar = hashMap.get("Compression"); if (dVar != null) { int m2 = dVar.m(this.i0); this.p0 = m2; if (m2 != 1) { if (m2 != 6) { if (m2 != 7) { return; } } } if (C(hashMap)) { t(bVar, hashMap); return; } return; } this.p0 = 6; s(bVar, hashMap); } private static boolean V(int i2) { return (i2 == 4 || i2 == 9 || i2 == 13 || i2 == 14) ? false : true; } private void W(int i2, int i3) { String str; if (this.g0[i2].isEmpty() || this.g0[i3].isEmpty()) { if (a) { Log.d("ExifInterface", "Cannot perform swap since only one image data exists"); return; } return; } d dVar = this.g0[i2].get("ImageLength"); d dVar2 = this.g0[i2].get("ImageWidth"); d dVar3 = this.g0[i3].get("ImageLength"); d dVar4 = this.g0[i3].get("ImageWidth"); if (dVar == null || dVar2 == null) { if (!a) { return; } else { str = "First image does not contain valid size information"; } } else { if (dVar3 != null && dVar4 != null) { int m2 = dVar.m(this.i0); int m3 = dVar2.m(this.i0); int m4 = dVar3.m(this.i0); int m5 = dVar4.m(this.i0); if (m2 >= m4 || m3 >= m5) { return; } HashMap<String, d>[] hashMapArr = this.g0; HashMap<String, d> hashMap = hashMapArr[i2]; hashMapArr[i2] = hashMapArr[i3]; hashMapArr[i3] = hashMap; return; } if (!a) { return; } else { str = "Second image does not contain valid size information"; } } Log.d("ExifInterface", str); } private void X(g gVar, int i2) { StringBuilder sb; String arrays; d j2; d j3; d dVar = this.g0[i2].get("DefaultCropSize"); d dVar2 = this.g0[i2].get("SensorTopBorder"); d dVar3 = this.g0[i2].get("SensorLeftBorder"); d dVar4 = this.g0[i2].get("SensorBottomBorder"); d dVar5 = this.g0[i2].get("SensorRightBorder"); if (dVar == null) { if (dVar2 == null || dVar3 == null || dVar4 == null || dVar5 == null) { O(gVar, i2); return; } int m2 = dVar2.m(this.i0); int m3 = dVar4.m(this.i0); int m4 = dVar5.m(this.i0); int m5 = dVar3.m(this.i0); if (m3 <= m2 || m4 <= m5) { return; } d j4 = d.j(m3 - m2, this.i0); d j5 = d.j(m4 - m5, this.i0); this.g0[i2].put("ImageLength", j4); this.g0[i2].put("ImageWidth", j5); return; } if (dVar.a == 5) { f[] fVarArr = (f[]) dVar.o(this.i0); if (fVarArr != null && fVarArr.length == 2) { j2 = d.h(fVarArr[0], this.i0); j3 = d.h(fVarArr[1], this.i0); this.g0[i2].put("ImageWidth", j2); this.g0[i2].put("ImageLength", j3); return; } sb = new StringBuilder(); sb.append("Invalid crop size values. cropSize="); arrays = Arrays.toString(fVarArr); sb.append(arrays); Log.w("ExifInterface", sb.toString()); } int[] iArr = (int[]) dVar.o(this.i0); if (iArr != null && iArr.length == 2) { j2 = d.j(iArr[0], this.i0); j3 = d.j(iArr[1], this.i0); this.g0[i2].put("ImageWidth", j2); this.g0[i2].put("ImageLength", j3); return; } sb = new StringBuilder(); sb.append("Invalid crop size values. cropSize="); arrays = Arrays.toString(iArr); sb.append(arrays); Log.w("ExifInterface", sb.toString()); } private void Y() { W(0, 5); W(0, 4); W(5, 4); d dVar = this.g0[1].get("PixelXDimension"); d dVar2 = this.g0[1].get("PixelYDimension"); if (dVar != null && dVar2 != null) { this.g0[0].put("ImageWidth", dVar); this.g0[0].put("ImageLength", dVar2); } if (this.g0[4].isEmpty() && E(this.g0[5])) { HashMap<String, d>[] hashMapArr = this.g0; hashMapArr[4] = hashMapArr[5]; hashMapArr[5] = new HashMap<>(); } if (!E(this.g0[4])) { Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image."); } N(0, "ThumbnailOrientation", "Orientation"); N(0, "ThumbnailImageLength", "ImageLength"); N(0, "ThumbnailImageWidth", "ImageWidth"); N(5, "ThumbnailOrientation", "Orientation"); N(5, "ThumbnailImageLength", "ImageLength"); N(5, "ThumbnailImageWidth", "ImageWidth"); N(4, "Orientation", "ThumbnailOrientation"); N(4, "ImageLength", "ThumbnailImageLength"); N(4, "ImageWidth", "ThumbnailImageWidth"); } private int Z(c cVar) { e[][] eVarArr = O; int[] iArr = new int[eVarArr.length]; int[] iArr2 = new int[eVarArr.length]; for (e eVar : P) { M(eVar.f1447b); } if (this.j0) { if (this.k0) { M("StripOffsets"); M("StripByteCounts"); } else { M("JPEGInterchangeFormat"); M("JPEGInterchangeFormatLength"); } } for (int i2 = 0; i2 < O.length; i2++) { for (Object obj : this.g0[i2].entrySet().toArray()) { Map.Entry entry = (Map.Entry) obj; if (entry.getValue() == null) { this.g0[i2].remove(entry.getKey()); } } } if (!this.g0[1].isEmpty()) { this.g0[0].put(P[1].f1447b, d.f(0L, this.i0)); } if (!this.g0[2].isEmpty()) { this.g0[0].put(P[2].f1447b, d.f(0L, this.i0)); } if (!this.g0[3].isEmpty()) { this.g0[1].put(P[3].f1447b, d.f(0L, this.i0)); } if (this.j0) { if (this.k0) { this.g0[4].put("StripOffsets", d.j(0, this.i0)); this.g0[4].put("StripByteCounts", d.j(this.n0, this.i0)); } else { this.g0[4].put("JPEGInterchangeFormat", d.f(0L, this.i0)); this.g0[4].put("JPEGInterchangeFormatLength", d.f(this.n0, this.i0)); } } for (int i3 = 0; i3 < O.length; i3++) { Iterator<Map.Entry<String, d>> it = this.g0[i3].entrySet().iterator(); int i4 = 0; while (it.hasNext()) { int p2 = it.next().getValue().p(); if (p2 > 4) { i4 += p2; } } iArr2[i3] = iArr2[i3] + i4; } int i5 = 8; for (int i6 = 0; i6 < O.length; i6++) { if (!this.g0[i6].isEmpty()) { iArr[i6] = i5; i5 += (this.g0[i6].size() * 12) + 2 + 4 + iArr2[i6]; } } if (this.j0) { if (this.k0) { this.g0[4].put("StripOffsets", d.j(i5, this.i0)); } else { this.g0[4].put("JPEGInterchangeFormat", d.f(i5, this.i0)); } this.m0 = i5; i5 += this.n0; } if (this.e0 == 4) { i5 += 8; } if (a) { for (int i7 = 0; i7 < O.length; i7++) { Log.d("ExifInterface", String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d", Integer.valueOf(i7), Integer.valueOf(iArr[i7]), Integer.valueOf(this.g0[i7].size()), Integer.valueOf(iArr2[i7]), Integer.valueOf(i5))); } } if (!this.g0[1].isEmpty()) { this.g0[0].put(P[1].f1447b, d.f(iArr[1], this.i0)); } if (!this.g0[2].isEmpty()) { this.g0[0].put(P[2].f1447b, d.f(iArr[2], this.i0)); } if (!this.g0[3].isEmpty()) { this.g0[1].put(P[3].f1447b, d.f(iArr[3], this.i0)); } int i8 = this.e0; if (i8 == 4) { cVar.g(i5); cVar.write(V); } else if (i8 == 13) { cVar.c(i5); cVar.write(n); } else if (i8 == 14) { cVar.write(s); cVar.c(i5); } cVar.e(this.i0 == ByteOrder.BIG_ENDIAN ? (short) 19789 : (short) 18761); cVar.a(this.i0); cVar.g(42); cVar.f(8L); for (int i9 = 0; i9 < O.length; i9++) { if (!this.g0[i9].isEmpty()) { cVar.g(this.g0[i9].size()); int size = iArr[i9] + 2 + (this.g0[i9].size() * 12) + 4; for (Map.Entry<String, d> entry2 : this.g0[i9].entrySet()) { int i10 = R[i9].get(entry2.getKey()).a; d value = entry2.getValue(); int p3 = value.p(); cVar.g(i10); cVar.g(value.a); cVar.c(value.f1444b); if (p3 > 4) { cVar.f(size); size += p3; } else { cVar.write(value.f1446d); if (p3 < 4) { while (p3 < 4) { cVar.b(0); p3++; } } } } if (i9 != 0 || this.g0[4].isEmpty()) { cVar.f(0L); } else { cVar.f(iArr[4]); } Iterator<Map.Entry<String, d>> it2 = this.g0[i9].entrySet().iterator(); while (it2.hasNext()) { byte[] bArr = it2.next().getValue().f1446d; if (bArr.length > 4) { cVar.write(bArr, 0, bArr.length); } } } } if (this.j0) { cVar.write(p()); } if (this.e0 == 14 && i5 % 2 == 1) { cVar.b(0); } cVar.a(ByteOrder.BIG_ENDIAN); return i5; } private void a() { String d2 = d("DateTimeOriginal"); if (d2 != null && d("DateTime") == null) { this.g0[0].put("DateTime", d.e(d2)); } if (d("ImageWidth") == null) { this.g0[0].put("ImageWidth", d.f(0L, this.i0)); } if (d("ImageLength") == null) { this.g0[0].put("ImageLength", d.f(0L, this.i0)); } if (d("Orientation") == null) { this.g0[0].put("Orientation", d.f(0L, this.i0)); } if (d("LightSource") == null) { this.g0[1].put("LightSource", d.f(0L, this.i0)); } } private void b(b bVar, c cVar, byte[] bArr, byte[] bArr2) { String str; while (true) { byte[] bArr3 = new byte[4]; if (bVar.read(bArr3) != 4) { StringBuilder sb = new StringBuilder(); sb.append("Encountered invalid length while copying WebP chunks up tochunk type "); Charset charset = U; sb.append(new String(bArr, charset)); if (bArr2 == null) { str = ""; } else { str = " or " + new String(bArr2, charset); } sb.append(str); throw new IOException(sb.toString()); } c(bVar, cVar, bArr3); if (Arrays.equals(bArr3, bArr)) { return; } if (bArr2 != null && Arrays.equals(bArr3, bArr2)) { return; } } } private void c(b bVar, c cVar, byte[] bArr) { int readInt = bVar.readInt(); cVar.write(bArr); cVar.c(readInt); if (readInt % 2 == 1) { readInt++; } c.i.a.b.f(bVar, cVar, readInt); } private d e(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++) { d dVar = this.g0[i2].get(str); if (dVar != null) { return dVar; } } return null; } private void f(g gVar) { String str; String str2; if (Build.VERSION.SDK_INT < 28) { throw new UnsupportedOperationException("Reading EXIF from HEIF files is supported from SDK 28 and above"); } MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); try { try { b.C0065b.a(mediaMetadataRetriever, new C0064a(gVar)); 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", d.j(Integer.parseInt(str3), this.i0)); } if (str != null) { this.g0[0].put("ImageLength", d.j(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", d.j(i2, this.i0)); } if (extractMetadata != null && extractMetadata2 != null) { int parseInt2 = Integer.parseInt(extractMetadata); int parseInt3 = Integer.parseInt(extractMetadata2); if (parseInt3 <= 6) { throw new IOException("Invalid exif length"); } gVar.f(parseInt2); byte[] bArr = new byte[6]; if (gVar.read(bArr) != 6) { throw new IOException("Can't read identifier"); } int i3 = parseInt2 + 6; int i4 = parseInt3 - 6; if (!Arrays.equals(bArr, V)) { throw new IOException("Invalid identifier"); } byte[] bArr2 = new byte[i4]; if (gVar.read(bArr2) != i4) { throw new IOException("Can't read exif"); } this.q0 = i3; K(bArr2, 0); } if (a) { Log.d("ExifInterface", "Heif meta: " + str3 + "x" + str + ", rotation " + str2); } } catch (RuntimeException unused) { throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported."); } } finally { mediaMetadataRetriever.release(); } } private void g(b bVar, int i2, int i3) { String str; String str2 = "ExifInterface"; if (a) { Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar); } bVar.c(ByteOrder.BIG_ENDIAN); byte readByte = bVar.readByte(); byte b2 = -1; if (readByte != -1) { throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255)); } 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) { throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255)); } 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.i.a.b.g(bArr, bArr2)) { byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort); this.q0 = i2 + i8 + bArr2.length; K(copyOfRange, i3); U(new b(copyOfRange)); } else { byte[] bArr3 = W; if (c.i.a.b.g(bArr, bArr3)) { int length = i8 + bArr3.length; byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort); if (d("Xmp") == null) { str = str2; this.g0[0].put("Xmp", new d(1, copyOfRange2.length, length, copyOfRange2)); this.v0 = 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) { throw new IOException("Invalid length"); } bVar.e(readUnsignedShort); i5 = i8 + readUnsignedShort; str2 = str; i4 = 2; b2 = -1; break; } } } bVar.e(1); this.g0[i3].put(i3 != 4 ? "ImageLength" : "ThumbnailImageLength", d.f(bVar.readUnsignedShort(), this.i0)); this.g0[i3].put(i3 != 4 ? "ImageWidth" : "ThumbnailImageWidth", d.f(bVar.readUnsignedShort(), this.i0)); readUnsignedShort -= 5; str = str2; if (readUnsignedShort < 0) { } } else { byte[] bArr4 = new byte[readUnsignedShort]; if (bVar.read(bArr4) != readUnsignedShort) { throw new IOException("Invalid exif"); } if (d("UserComment") == null) { this.g0[1].put("UserComment", d.e(new String(bArr4, U))); } str = str2; } readUnsignedShort = 0; if (readUnsignedShort < 0) { } } } } private int h(BufferedInputStream bufferedInputStream) { bufferedInputStream.mark(5000); byte[] bArr = new byte[5000]; bufferedInputStream.read(bArr); bufferedInputStream.reset(); if (w(bArr)) { return 4; } if (z(bArr)) { return 9; } if (v(bArr)) { return 12; } if (x(bArr)) { return 7; } if (A(bArr)) { return 10; } if (y(bArr)) { return 13; } return F(bArr) ? 14 : 0; } private void i(g gVar) { d dVar; d dVar2; d dVar3; long j2; l(gVar); d dVar4 = this.g0[1].get("MakerNote"); if (dVar4 == null) { return; } g gVar2 = new g(dVar4.f1446d); gVar2.c(this.i0); byte[] bArr = f1441k; byte[] bArr2 = new byte[bArr.length]; gVar2.readFully(bArr2); gVar2.f(0L); byte[] bArr3 = f1442l; byte[] bArr4 = new byte[bArr3.length]; gVar2.readFully(bArr4); if (!Arrays.equals(bArr2, bArr)) { j2 = Arrays.equals(bArr4, bArr3) ? 12L : 8L; L(gVar2, 6); dVar = this.g0[7].get("PreviewImageStart"); dVar2 = this.g0[7].get("PreviewImageLength"); if (dVar != null && dVar2 != null) { this.g0[5].put("JPEGInterchangeFormat", dVar); this.g0[5].put("JPEGInterchangeFormatLength", dVar2); } dVar3 = this.g0[8].get("AspectFrame"); if (dVar3 == null) { int[] iArr = (int[]) dVar3.o(this.i0); if (iArr == null || iArr.length != 4) { Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr)); return; } 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; } d j3 = d.j(i2, this.i0); d j4 = d.j(i3, this.i0); this.g0[0].put("ImageWidth", j3); this.g0[0].put("ImageLength", j4); return; } return; } gVar2.f(j2); L(gVar2, 6); dVar = this.g0[7].get("PreviewImageStart"); dVar2 = this.g0[7].get("PreviewImageLength"); if (dVar != null) { this.g0[5].put("JPEGInterchangeFormat", dVar); this.g0[5].put("JPEGInterchangeFormatLength", dVar2); } dVar3 = this.g0[8].get("AspectFrame"); if (dVar3 == null) { } } private void j(b bVar) { if (a) { Log.d("ExifInterface", "getPngAttributes starting with: " + bVar); } bVar.c(ByteOrder.BIG_ENDIAN); byte[] bArr = f1443m; bVar.e(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) { throw new IOException("Encountered invalid length while parsing PNG chunktype"); } 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) { throw new IOException("Failed to read given length for given PNG chunk type: " + c.i.a.b.a(bArr2)); } int readInt2 = bVar.readInt(); CRC32 crc32 = new CRC32(); crc32.update(bArr2); crc32.update(bArr3); if (((int) crc32.getValue()) == readInt2) { this.q0 = i3; K(bArr3, 0); Y(); U(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()); } int i4 = readInt + 4; bVar.e(i4); length = i3 + i4; } catch (EOFException unused) { throw new IOException("Encountered corrupt PNG file."); } } } private void k(b bVar) { boolean z2 = a; if (z2) { Log.d("ExifInterface", "getRafAttributes starting with: " + bVar); } bVar.e(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.e(i2 - bVar.a()); bVar.read(bArr4); g(new b(bArr4), i2, 5); bVar.e(i4 - bVar.a()); bVar.c(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(); d j2 = d.j(readShort, this.i0); d j3 = d.j(readShort2, this.i0); this.g0[0].put("ImageLength", j2); this.g0[0].put("ImageWidth", j3); if (a) { Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2)); return; } return; } bVar.e(readUnsignedShort2); } } private void l(g gVar) { d dVar; H(gVar); L(gVar, 0); X(gVar, 0); X(gVar, 5); X(gVar, 4); Y(); if (this.e0 != 8 || (dVar = this.g0[1].get("MakerNote")) == null) { return; } g gVar2 = new g(dVar.f1446d); gVar2.c(this.i0); gVar2.e(6); L(gVar2, 9); d dVar2 = this.g0[9].get("ColorSpace"); if (dVar2 != null) { this.g0[1].put("ColorSpace", dVar2); } } private void m(g gVar) { if (a) { Log.d("ExifInterface", "getRw2Attributes starting with: " + gVar); } l(gVar); d dVar = this.g0[0].get("JpgFromRaw"); if (dVar != null) { g(new b(dVar.f1446d), (int) dVar.f1445c, 5); } d dVar2 = this.g0[0].get("ISO"); d dVar3 = this.g0[1].get("PhotographicSensitivity"); if (dVar2 == null || dVar3 != null) { return; } this.g0[1].put("PhotographicSensitivity", dVar2); } private void n(g gVar) { byte[] bArr = V; gVar.e(bArr.length); byte[] bArr2 = new byte[gVar.available()]; gVar.readFully(bArr2); this.q0 = bArr.length; K(bArr2, 0); } private void q(b bVar) { if (a) { Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar); } bVar.c(ByteOrder.LITTLE_ENDIAN); bVar.e(q.length); int readInt = bVar.readInt() + 8; byte[] bArr = r; bVar.e(bArr.length); int length = bArr.length + 8; while (true) { try { byte[] bArr2 = new byte[4]; if (bVar.read(bArr2) != 4) { throw new IOException("Encountered invalid length while parsing WebP chunktype"); } 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; K(bArr3, 0); U(new b(bArr3)); return; } else { throw new IOException("Failed to read given length for given PNG chunk type: " + c.i.a.b.a(bArr2)); } } if (readInt2 % 2 == 1) { readInt2++; } length = i2 + readInt2; if (length == readInt) { return; } if (length > readInt) { throw new IOException("Encountered WebP file with invalid chunk size"); } bVar.e(readInt2); } catch (EOFException unused) { throw new IOException("Encountered corrupt WebP file."); } } } private static Pair<Integer, Integer> r(String str) { if (str.contains(",")) { String[] split = str.split(",", -1); Pair<Integer, Integer> r2 = r(split[0]); if (((Integer) r2.first).intValue() == 2) { return r2; } for (int i2 = 1; i2 < split.length; i2++) { Pair<Integer, Integer> r3 = r(split[i2]); int intValue = (((Integer) r3.first).equals(r2.first) || ((Integer) r3.second).equals(r2.first)) ? ((Integer) r2.first).intValue() : -1; int intValue2 = (((Integer) r2.second).intValue() == -1 || !(((Integer) r3.first).equals(r2.second) || ((Integer) r3.second).equals(r2.second))) ? -1 : ((Integer) r2.second).intValue(); if (intValue == -1 && intValue2 == -1) { return new Pair<>(2, -1); } if (intValue == -1) { r2 = new Pair<>(Integer.valueOf(intValue2), -1); } else if (intValue2 == -1) { r2 = new Pair<>(Integer.valueOf(intValue), -1); } } return r2; } if (!str.contains("/")) { try { try { Long valueOf = Long.valueOf(Long.parseLong(str)); return (valueOf.longValue() < 0 || valueOf.longValue() > 65535) ? valueOf.longValue() < 0 ? new Pair<>(9, -1) : new Pair<>(4, -1) : new Pair<>(3, 4); } catch (NumberFormatException unused) { return new Pair<>(2, -1); } } catch (NumberFormatException unused2) { Double.parseDouble(str); return new Pair<>(12, -1); } } String[] split2 = str.split("/", -1); if (split2.length == 2) { try { long parseDouble = (long) Double.parseDouble(split2[0]); long parseDouble2 = (long) Double.parseDouble(split2[1]); if (parseDouble >= 0 && parseDouble2 >= 0) { if (parseDouble <= 2147483647L && parseDouble2 <= 2147483647L) { return new Pair<>(10, 5); } return new Pair<>(5, -1); } return new Pair<>(10, -1); } catch (NumberFormatException unused3) { } } return new Pair<>(2, -1); } private void s(b bVar, HashMap hashMap) { d dVar = (d) hashMap.get("JPEGInterchangeFormat"); d dVar2 = (d) hashMap.get("JPEGInterchangeFormatLength"); if (dVar == null || dVar2 == null) { return; } int m2 = dVar.m(this.i0); int m3 = dVar2.m(this.i0); if (this.e0 == 7) { m2 += this.r0; } if (m2 > 0 && m3 > 0) { this.j0 = true; if (this.b0 == null && this.d0 == null && this.c0 == null) { byte[] bArr = new byte[m3]; bVar.skip(m2); bVar.read(bArr); this.o0 = bArr; } this.m0 = m2; this.n0 = m3; } if (a) { Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + m2 + ", length: " + m3); } } private void t(b bVar, HashMap hashMap) { d dVar = (d) hashMap.get("StripOffsets"); d dVar2 = (d) hashMap.get("StripByteCounts"); if (dVar == null || dVar2 == null) { return; } long[] d2 = c.i.a.b.d(dVar.o(this.i0)); long[] d3 = c.i.a.b.d(dVar2.o(this.i0)); if (d2 == null || d2.length == 0) { Log.w("ExifInterface", "stripOffsets should not be null or have zero length."); return; } if (d3 == null || d3.length == 0) { Log.w("ExifInterface", "stripByteCounts should not be null or have zero length."); return; } if (d2.length != d3.length) { Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length."); return; } long j2 = 0; for (long j3 : d3) { 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 < d2.length; i5++) { int i6 = (int) d2[i5]; int i7 = (int) d3[i5]; if (i5 < d2.length - 1 && i6 + i7 != d2[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) d2[0]; this.n0 = i2; } } private void u(String str) { Objects.requireNonNull(str, "filename cannot be null"); FileInputStream fileInputStream = null; this.d0 = null; this.b0 = str; try { FileInputStream fileInputStream2 = new FileInputStream(str); try { if (B(fileInputStream2.getFD())) { this.c0 = fileInputStream2.getFD(); } else { this.c0 = null; } G(fileInputStream2); c.i.a.b.c(fileInputStream2); } catch (Throwable th) { th = th; fileInputStream = fileInputStream2; c.i.a.b.c(fileInputStream); throw th; } } catch (Throwable th2) { th = th2; } } private boolean v(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, f1438h)) { 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, f1439i)) { z2 = true; } else if (Arrays.equals(bArr3, f1440j)) { z3 = true; } if (z2 && z3) { bVar.close(); return true; } } } bVar.close(); return false; } private static boolean w(byte[] bArr) { int i2 = 0; while (true) { byte[] bArr2 = f1437g; if (i2 >= bArr2.length) { return true; } if (bArr[i2] != bArr2[i2]) { return false; } i2++; } } private boolean x(byte[] bArr) { b bVar = null; try { b bVar2 = new b(bArr); try { ByteOrder J2 = J(bVar2); this.i0 = J2; bVar2.c(J2); 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 y(byte[] bArr) { int i2 = 0; while (true) { byte[] bArr2 = f1443m; if (i2 >= bArr2.length) { return true; } if (bArr[i2] != bArr2[i2]) { return false; } i2++; } } private boolean z(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; } public void P() { FileOutputStream fileOutputStream; FileInputStream fileInputStream; Closeable closeable; FileOutputStream fileOutputStream2; Exception exc; FileOutputStream fileOutputStream3; InputStream inputStream; Exception e2; FileOutputStream fileOutputStream4; FileInputStream fileInputStream2; BufferedInputStream bufferedInputStream; if (!D(this.e0)) { throw new IOException("ExifInterface only supports saving attributes for JPEG, PNG, WebP, and DNG formats."); } if (this.c0 == null && this.b0 == null) { throw new IOException("ExifInterface does not support saving attributes for the current input."); } if (this.j0 && this.k0 && !this.l0) { throw new IOException("ExifInterface does not support saving attributes when the image file has non-consecutive thumbnail strips"); } this.u0 = true; this.o0 = o(); InputStream inputStream2 = null; try { File createTempFile = File.createTempFile("temp", "tmp"); if (this.b0 != null) { fileInputStream = new FileInputStream(this.b0); } else if (Build.VERSION.SDK_INT >= 21) { b.a.c(this.c0, 0L, OsConstants.SEEK_SET); fileInputStream = new FileInputStream(this.c0); } else { fileInputStream = null; } try { fileOutputStream = new FileOutputStream(createTempFile); try { c.i.a.b.e(fileInputStream, fileOutputStream); c.i.a.b.c(fileInputStream); c.i.a.b.c(fileOutputStream); try { try { try { fileInputStream2 = new FileInputStream(createTempFile); try { if (this.b0 != null) { fileOutputStream3 = new FileOutputStream(this.b0); } else if (Build.VERSION.SDK_INT >= 21) { b.a.c(this.c0, 0L, OsConstants.SEEK_SET); fileOutputStream3 = new FileOutputStream(this.c0); } else { fileOutputStream3 = null; } try { bufferedInputStream = new BufferedInputStream(fileInputStream2); } catch (Exception e3) { inputStream2 = fileInputStream2; exc = e3; } } catch (Exception e4) { e = e4; fileOutputStream2 = null; inputStream2 = fileInputStream2; exc = e; fileOutputStream3 = fileOutputStream2; try { inputStream = new FileInputStream(createTempFile); try { if (this.b0 != null) { if (Build.VERSION.SDK_INT >= 21) { b.a.c(this.c0, 0L, OsConstants.SEEK_SET); fileOutputStream4 = new FileOutputStream(this.c0); } c.i.a.b.e(inputStream, fileOutputStream3); c.i.a.b.c(inputStream); c.i.a.b.c(fileOutputStream3); throw new IOException("Failed to save new file", exc); } fileOutputStream4 = new FileOutputStream(this.b0); fileOutputStream3 = fileOutputStream4; c.i.a.b.e(inputStream, fileOutputStream3); c.i.a.b.c(inputStream); c.i.a.b.c(fileOutputStream3); throw new IOException("Failed to save new file", exc); } catch (Exception e5) { e2 = e5; try { throw new IOException("Failed to save new file. Original file is stored in " + createTempFile.getAbsolutePath(), e2); } catch (Throwable th) { th = th; inputStream2 = inputStream; c.i.a.b.c(inputStream2); c.i.a.b.c(fileOutputStream3); throw th; } } catch (Throwable th2) { th = th2; inputStream2 = inputStream; c.i.a.b.c(inputStream2); c.i.a.b.c(fileOutputStream3); throw th; } } catch (Exception e6) { inputStream = inputStream2; e2 = e6; } catch (Throwable th3) { th = th3; c.i.a.b.c(inputStream2); c.i.a.b.c(fileOutputStream3); throw th; } } } catch (Exception e7) { e = e7; fileOutputStream2 = null; } } catch (Throwable th4) { th = th4; closeable = null; c.i.a.b.c(inputStream2); c.i.a.b.c(closeable); if (0 == 0) { createTempFile.delete(); } throw th; } } catch (Throwable th5) { th = th5; } try { BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream3); try { int i2 = this.e0; if (i2 == 4) { Q(bufferedInputStream, bufferedOutputStream); } else if (i2 == 13) { R(bufferedInputStream, bufferedOutputStream); } else if (i2 == 14) { S(bufferedInputStream, bufferedOutputStream); } else if (i2 == 3 || i2 == 0) { Z(new c(bufferedOutputStream, ByteOrder.BIG_ENDIAN)); } c.i.a.b.c(bufferedInputStream); c.i.a.b.c(bufferedOutputStream); createTempFile.delete(); this.o0 = null; } catch (Exception e8) { exc = e8; inputStream2 = fileInputStream2; inputStream = new FileInputStream(createTempFile); if (this.b0 != null) { } fileOutputStream3 = fileOutputStream4; c.i.a.b.e(inputStream, fileOutputStream3); c.i.a.b.c(inputStream); c.i.a.b.c(fileOutputStream3); throw new IOException("Failed to save new file", exc); } } catch (Exception e9) { inputStream2 = fileInputStream2; exc = e9; } catch (Throwable th6) { th = th6; closeable = null; inputStream2 = bufferedInputStream; c.i.a.b.c(inputStream2); c.i.a.b.c(closeable); if (0 == 0) { } throw th; } } catch (Exception e10) { e = e10; inputStream2 = fileInputStream; try { throw new IOException("Failed to copy original file to temp file", e); } catch (Throwable th7) { th = th7; c.i.a.b.c(inputStream2); c.i.a.b.c(fileOutputStream); throw th; } } catch (Throwable th8) { th = th8; inputStream2 = fileInputStream; c.i.a.b.c(inputStream2); c.i.a.b.c(fileOutputStream); throw th; } } catch (Exception e11) { e = e11; fileOutputStream = null; } catch (Throwable th9) { th = th9; fileOutputStream = null; } } catch (Exception e12) { e = e12; fileOutputStream = null; } catch (Throwable th10) { th = th10; fileOutputStream = null; } } public void T(String str, String str2) { StringBuilder sb; e eVar; int i2; int i3; HashMap<String, d> hashMap; d a2; HashMap<String, d> hashMap2; d c2; String str3 = str; String str4 = str2; Objects.requireNonNull(str3, "tag shouldn't be null"); if (("DateTime".equals(str3) || "DateTimeOriginal".equals(str3) || "DateTimeDigitized".equals(str3)) && str4 != null) { boolean find = Z.matcher(str4).find(); boolean find2 = a0.matcher(str4).find(); if (str2.length() != 19 || (!find && !find2)) { sb = new StringBuilder(); sb.append("Invalid value for "); sb.append(str3); sb.append(" : "); sb.append(str4); Log.w("ExifInterface", sb.toString()); return; } if (find2) { str4 = str4.replaceAll("-", ":"); } } if ("ISOSpeedRatings".equals(str3)) { if (a) { Log.d("ExifInterface", "setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY."); } str3 = "PhotographicSensitivity"; } int i4 = 2; int i5 = 1; if (str4 != null && S.contains(str3)) { if (str3.equals("GPSTimeStamp")) { Matcher matcher = Y.matcher(str4); if (!matcher.find()) { sb = new StringBuilder(); sb.append("Invalid value for "); sb.append(str3); sb.append(" : "); sb.append(str4); Log.w("ExifInterface", sb.toString()); return; } str4 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1"; } else { try { str4 = new f(Double.parseDouble(str4)).toString(); } catch (NumberFormatException unused) { sb = new StringBuilder(); } } } int i6 = 0; int i7 = 0; while (i7 < O.length) { if ((i7 != 4 || this.j0) && (eVar = R[i7].get(str3)) != null) { if (str4 == null) { this.g0[i7].remove(str3); } else { Pair<Integer, Integer> r2 = r(str4); int i8 = -1; if (eVar.f1448c == ((Integer) r2.first).intValue() || eVar.f1448c == ((Integer) r2.second).intValue()) { i2 = eVar.f1448c; } else { int i9 = eVar.f1449d; if (i9 == -1 || !(i9 == ((Integer) r2.first).intValue() || eVar.f1449d == ((Integer) r2.second).intValue())) { int i10 = eVar.f1448c; if (i10 == i5 || i10 == 7 || i10 == i4) { i2 = i10; } else if (a) { StringBuilder sb2 = new StringBuilder(); sb2.append("Given tag ("); sb2.append(str3); sb2.append(") value didn't match with one of expected formats: "); String[] strArr = B; sb2.append(strArr[eVar.f1448c]); sb2.append(eVar.f1449d == -1 ? "" : ", " + strArr[eVar.f1449d]); sb2.append(" (guess: "); sb2.append(strArr[((Integer) r2.first).intValue()]); sb2.append(((Integer) r2.second).intValue() != -1 ? ", " + strArr[((Integer) r2.second).intValue()] : ""); sb2.append(")"); Log.d("ExifInterface", sb2.toString()); } } else { i2 = eVar.f1449d; } } switch (i2) { case 1: i3 = i5; hashMap = this.g0[i7]; a2 = d.a(str4); hashMap.put(str3, a2); break; case 2: case 7: i3 = i5; hashMap = this.g0[i7]; a2 = d.e(str4); hashMap.put(str3, a2); break; case 3: i3 = i5; String[] split = str4.split(",", -1); int[] iArr = new int[split.length]; for (int i11 = 0; i11 < split.length; i11++) { iArr[i11] = Integer.parseInt(split[i11]); } hashMap = this.g0[i7]; a2 = d.k(iArr, this.i0); hashMap.put(str3, a2); break; case 4: i3 = i5; String[] split2 = str4.split(",", -1); long[] jArr = new long[split2.length]; for (int i12 = 0; i12 < split2.length; i12++) { jArr[i12] = Long.parseLong(split2[i12]); } hashMap = this.g0[i7]; a2 = d.g(jArr, this.i0); hashMap.put(str3, a2); break; case 5: String[] split3 = str4.split(",", -1); f[] fVarArr = new f[split3.length]; int i13 = 0; while (i13 < split3.length) { String[] split4 = split3[i13].split("/", i8); fVarArr[i13] = new f((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1])); i13++; i8 = -1; } i3 = 1; hashMap = this.g0[i7]; a2 = d.i(fVarArr, this.i0); hashMap.put(str3, a2); break; case 6: case 8: case 11: default: i3 = i5; if (a) { Log.d("ExifInterface", "Data format isn't one of expected formats: " + i2); break; } else { break; } case 9: String[] split5 = str4.split(",", -1); int[] iArr2 = new int[split5.length]; for (int i14 = 0; i14 < split5.length; i14++) { iArr2[i14] = Integer.parseInt(split5[i14]); } hashMap2 = this.g0[i7]; c2 = d.c(iArr2, this.i0); hashMap2.put(str3, c2); i3 = 1; break; case 10: String[] split6 = str4.split(",", -1); f[] fVarArr2 = new f[split6.length]; int i15 = i6; while (i15 < split6.length) { String[] split7 = split6[i15].split("/", -1); fVarArr2[i15] = new f((long) Double.parseDouble(split7[i6]), (long) Double.parseDouble(split7[i5])); i15++; split6 = split6; i6 = 0; i5 = 1; } hashMap2 = this.g0[i7]; c2 = d.d(fVarArr2, this.i0); hashMap2.put(str3, c2); i3 = 1; break; case 12: String[] split8 = str4.split(",", -1); double[] dArr = new double[split8.length]; for (int i16 = i6; i16 < split8.length; i16++) { dArr[i16] = Double.parseDouble(split8[i16]); } this.g0[i7].put(str3, d.b(dArr, this.i0)); break; } i7++; i5 = i3; i4 = 2; i6 = 0; } } i3 = i5; i7++; i5 = i3; i4 = 2; i6 = 0; } } public String d(String str) { String str2; Objects.requireNonNull(str, "tag shouldn't be null"); d e2 = e(str); if (e2 != null) { if (!S.contains(str)) { return e2.n(this.i0); } if (str.equals("GPSTimeStamp")) { int i2 = e2.a; if (i2 == 5 || i2 == 10) { f[] fVarArr = (f[]) e2.o(this.i0); if (fVarArr != null && fVarArr.length == 3) { return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) fVarArr[0].a) / ((float) fVarArr[0].f1450b))), Integer.valueOf((int) (((float) fVarArr[1].a) / ((float) fVarArr[1].f1450b))), Integer.valueOf((int) (((float) fVarArr[2].a) / ((float) fVarArr[2].f1450b)))); } str2 = "Invalid GPS Timestamp array. array=" + Arrays.toString(fVarArr); } else { str2 = "GPS Timestamp format is not rational. format=" + e2.a; } Log.w("ExifInterface", str2); return null; } try { return Double.toString(e2.l(this.i0)); } catch (NumberFormatException unused) { } } return null; } public byte[] o() { int i2 = this.p0; if (i2 == 6 || i2 == 7) { return p(); } return null; } public byte[] p() { FileDescriptor fileDescriptor; FileInputStream fileInputStream; Exception e2; FileDescriptor fileDescriptor2; FileInputStream fileInputStream2; FileInputStream fileInputStream3; Closeable closeable = null; if (!this.j0) { return null; } ?? r1 = this.o0; try { if (r1 != 0) { return r1; } try { r1 = this.d0; try { if (r1 != 0) { try { if (!r1.markSupported()) { Log.d("ExifInterface", "Cannot read thumbnail from inputstream without mark/reset support"); c.i.a.b.c(r1); return null; } r1.reset(); fileInputStream3 = r1; } catch (Exception e3) { e2 = e3; fileDescriptor2 = null; fileInputStream = r1; Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2); c.i.a.b.c(fileInputStream); if (fileDescriptor2 != null) { } return null; } catch (Throwable th) { th = th; fileDescriptor = null; closeable = r1; c.i.a.b.c(closeable); if (fileDescriptor != null) { c.i.a.b.b(fileDescriptor); } throw th; } } else { if (this.b0 == null) { if (Build.VERSION.SDK_INT >= 21) { FileDescriptor b2 = b.a.b(this.c0); try { b.a.c(b2, 0L, OsConstants.SEEK_SET); fileDescriptor2 = b2; fileInputStream2 = new FileInputStream(b2); } catch (Exception e4) { e2 = e4; fileDescriptor2 = b2; fileInputStream = null; Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2); c.i.a.b.c(fileInputStream); if (fileDescriptor2 != null) { } return null; } catch (Throwable th2) { th = th2; fileDescriptor = b2; c.i.a.b.c(closeable); if (fileDescriptor != null) { } throw th; } } else { fileInputStream2 = null; fileDescriptor2 = null; } if (fileInputStream2 != null) { throw new FileNotFoundException(); } if (fileInputStream2.skip(this.m0 + this.q0) != this.m0 + this.q0) { throw new IOException("Corrupted image"); } byte[] bArr = new byte[this.n0]; if (fileInputStream2.read(bArr) != this.n0) { throw new IOException("Corrupted image"); } this.o0 = bArr; c.i.a.b.c(fileInputStream2); if (fileDescriptor2 != null) { c.i.a.b.b(fileDescriptor2); } return bArr; } fileInputStream3 = new FileInputStream(this.b0); } if (fileInputStream2 != null) { } } catch (Exception e5) { e2 = e5; fileInputStream = fileInputStream2; Log.d("ExifInterface", "Encountered exception while getting thumbnail", e2); c.i.a.b.c(fileInputStream); if (fileDescriptor2 != null) { c.i.a.b.b(fileDescriptor2); } return null; } fileDescriptor2 = null; fileInputStream2 = fileInputStream3; } catch (Exception e6) { fileInputStream = null; e2 = e6; fileDescriptor2 = null; } catch (Throwable th3) { th = th3; fileDescriptor = null; } } catch (Throwable th4) { th = th4; } } }