APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Microless
版本号:1.9
包名称:com.itplus.microless

MD5 校验值:76664d4beb7b8d8b1df7e59ba4c77a12

反编译源代码说明

a.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package h0;

import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
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.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 W;

    private static final d[] f11270a0;

    private static final d[] f11271b0;

    private static final d[] f11272c0;

    private static final d[] f11273d0;

    private static final d[] f11274e0;

    private static final d f11275f0;

    private static final d[] f11276g0;

    private static final d[] f11277h0;

    private static final d[] f11278i0;

    private static final d[] f11279j0;

    static final d[][] f11280k0;

    private static final d[] f11281l0;

    private static final d f11282m0;

    private static final d f11283n0;

    private static final HashMap<Integer, d>[] f11284o0;

    private static final HashMap<String, d>[] f11285p0;

    private static final HashSet<String> f11286q0;

    private static final HashMap<Integer, Integer> f11287r0;

    static final Charset f11288s0;

    static final byte[] f11289t0;

    private static final byte[] f11290u0;

    private static final Pattern f11291v0;

    private static final Pattern f11293w0;

    private String f11297a;

    private FileDescriptor f11298b;

    private AssetManager.AssetInputStream f11299c;

    private int f11300d;

    private boolean f11301e;

    private final HashMap<String, c>[] f11302f;

    private Set<Integer> f11303g;

    private ByteOrder f11304h;

    private boolean f11305i;

    private boolean f11306j;

    private boolean f11307k;

    private int f11308l;

    private int f11309m;

    private byte[] f11310n;

    private int f11311o;

    private int f11312p;

    private int f11313q;

    private int f11314r;

    private int f11315s;

    private int f11316t;

    private boolean f11317u;

    private boolean f11318v;

    private static final boolean f11292w = Log.isLoggable("ExifInterface", 3);

    private static final List<Integer> f11294x = Arrays.asList(1, 6, 3, 8);

    private static final List<Integer> f11295y = Arrays.asList(2, 7, 4, 5);

    public static final int[] f11296z = {8, 8, 8};
    public static final int[] A = {4};
    public static final int[] B = {8};
    static final byte[] C = {-1, -40, -1};
    private static final byte[] D = {102, 116, 121, 112};
    private static final byte[] E = {109, 105, 102, 49};
    private static final byte[] F = {104, 101, 105, 99};
    private static final byte[] G = {79, 76, 89, 77, 80, 0};
    private static final byte[] H = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    private static final byte[] I = {-119, 80, 78, 71, 13, 10, 26, 10};
    private static final byte[] J = {101, 88, 73, 102};
    private static final byte[] K = {73, 72, 68, 82};
    private static final byte[] L = {73, 69, 78, 68};
    private static final byte[] M = {82, 73, 70, 70};
    private static final byte[] N = {87, 69, 66, 80};
    private static final byte[] O = {69, 88, 73, 70};
    private static final byte[] P = {-99, 1, 42};
    private static final byte[] Q = "VP8X".getBytes(Charset.defaultCharset());
    private static final byte[] R = "VP8L".getBytes(Charset.defaultCharset());
    private static final byte[] S = "VP8 ".getBytes(Charset.defaultCharset());
    private static final byte[] T = "ANIM".getBytes(Charset.defaultCharset());
    private static final byte[] U = "ANMF".getBytes(Charset.defaultCharset());
    private static final byte[] V = "XMP ".getBytes(Charset.defaultCharset());
    static final String[] X = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    static final int[] Y = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    static final byte[] Z = {65, 83, 67, 73, 73, 0, 0, 0};

    public class C0142a extends MediaDataSource {

        long f11319m;

        final b f11320n;

        C0142a(b bVar) {
            this.f11320n = bVar;
        }

        @Override
        public void close() {
        }

        @Override
        public long getSize() {
            return -1L;
        }

        @Override
        public int readAt(long j10, byte[] bArr, int i10, int i11) {
            if (i11 == 0) {
                return 0;
            }
            if (j10 < 0) {
                return -1;
            }
            try {
                long j11 = this.f11319m;
                if (j11 != j10) {
                    if (j11 >= 0 && j10 >= j11 + this.f11320n.available()) {
                        return -1;
                    }
                    this.f11320n.p(j10);
                    this.f11319m = j10;
                }
                if (i11 > this.f11320n.available()) {
                    i11 = this.f11320n.available();
                }
                int read = this.f11320n.read(bArr, i10, i11);
                if (read >= 0) {
                    this.f11319m += read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.f11319m = -1L;
            return -1;
        }
    }

    public static class b extends InputStream implements DataInput {

        private static final ByteOrder f11322q = ByteOrder.LITTLE_ENDIAN;

        private static final ByteOrder f11323r = ByteOrder.BIG_ENDIAN;

        private DataInputStream f11324m;

        private ByteOrder f11325n;

        final int f11326o;

        int f11327p;

        public b(InputStream inputStream) {
            this(inputStream, ByteOrder.BIG_ENDIAN);
        }

        b(InputStream inputStream, ByteOrder byteOrder) {
            this.f11325n = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.f11324m = dataInputStream;
            int available = dataInputStream.available();
            this.f11326o = available;
            this.f11327p = 0;
            this.f11324m.mark(available);
            this.f11325n = byteOrder;
        }

        public b(byte[] bArr) {
            this(new ByteArrayInputStream(bArr));
        }

        public void B(ByteOrder byteOrder) {
            this.f11325n = byteOrder;
        }

        public int a() {
            return this.f11326o;
        }

        @Override
        public int available() {
            return this.f11324m.available();
        }

        public int c() {
            return this.f11327p;
        }

        public long f() {
            return readInt() & 4294967295L;
        }

        public void p(long j10) {
            int i10 = this.f11327p;
            if (i10 > j10) {
                this.f11327p = 0;
                this.f11324m.reset();
                this.f11324m.mark(this.f11326o);
            } else {
                j10 -= i10;
            }
            int i11 = (int) j10;
            if (skipBytes(i11) != i11) {
                throw new IOException("Couldn't seek up to the byteCount");
            }
        }

        @Override
        public int read() {
            this.f11327p++;
            return this.f11324m.read();
        }

        @Override
        public int read(byte[] bArr, int i10, int i11) {
            int read = this.f11324m.read(bArr, i10, i11);
            this.f11327p += read;
            return read;
        }

        @Override
        public boolean readBoolean() {
            this.f11327p++;
            return this.f11324m.readBoolean();
        }

        @Override
        public byte readByte() {
            int i10 = this.f11327p + 1;
            this.f11327p = i10;
            if (i10 > this.f11326o) {
                throw new EOFException();
            }
            int read = this.f11324m.read();
            if (read >= 0) {
                return (byte) read;
            }
            throw new EOFException();
        }

        @Override
        public char readChar() {
            this.f11327p += 2;
            return this.f11324m.readChar();
        }

        @Override
        public double readDouble() {
            return Double.longBitsToDouble(readLong());
        }

        @Override
        public float readFloat() {
            return Float.intBitsToFloat(readInt());
        }

        @Override
        public void readFully(byte[] bArr) {
            int length = this.f11327p + bArr.length;
            this.f11327p = length;
            if (length > this.f11326o) {
                throw new EOFException();
            }
            if (this.f11324m.read(bArr, 0, bArr.length) != bArr.length) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override
        public void readFully(byte[] bArr, int i10, int i11) {
            int i12 = this.f11327p + i11;
            this.f11327p = i12;
            if (i12 > this.f11326o) {
                throw new EOFException();
            }
            if (this.f11324m.read(bArr, i10, i11) != i11) {
                throw new IOException("Couldn't read up to the length of buffer");
            }
        }

        @Override
        public int readInt() {
            int i10 = this.f11327p + 4;
            this.f11327p = i10;
            if (i10 > this.f11326o) {
                throw new EOFException();
            }
            int read = this.f11324m.read();
            int read2 = this.f11324m.read();
            int read3 = this.f11324m.read();
            int read4 = this.f11324m.read();
            if ((read | read2 | read3 | read4) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.f11325n;
            if (byteOrder == f11322q) {
                return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
            }
            if (byteOrder == f11323r) {
                return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
            }
            throw new IOException("Invalid byte order: " + this.f11325n);
        }

        @Override
        public String readLine() {
            Log.d("ExifInterface", "Currently unsupported");
            return null;
        }

        @Override
        public long readLong() {
            int i10 = this.f11327p + 8;
            this.f11327p = i10;
            if (i10 > this.f11326o) {
                throw new EOFException();
            }
            int read = this.f11324m.read();
            int read2 = this.f11324m.read();
            int read3 = this.f11324m.read();
            int read4 = this.f11324m.read();
            int read5 = this.f11324m.read();
            int read6 = this.f11324m.read();
            int read7 = this.f11324m.read();
            int read8 = this.f11324m.read();
            if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.f11325n;
            if (byteOrder == f11322q) {
                return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
            }
            if (byteOrder == f11323r) {
                return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
            }
            throw new IOException("Invalid byte order: " + this.f11325n);
        }

        @Override
        public short readShort() {
            int i10 = this.f11327p + 2;
            this.f11327p = i10;
            if (i10 > this.f11326o) {
                throw new EOFException();
            }
            int read = this.f11324m.read();
            int read2 = this.f11324m.read();
            if ((read | read2) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.f11325n;
            if (byteOrder == f11322q) {
                return (short) ((read2 << 8) + read);
            }
            if (byteOrder == f11323r) {
                return (short) ((read << 8) + read2);
            }
            throw new IOException("Invalid byte order: " + this.f11325n);
        }

        @Override
        public String readUTF() {
            this.f11327p += 2;
            return this.f11324m.readUTF();
        }

        @Override
        public int readUnsignedByte() {
            this.f11327p++;
            return this.f11324m.readUnsignedByte();
        }

        @Override
        public int readUnsignedShort() {
            int i10 = this.f11327p + 2;
            this.f11327p = i10;
            if (i10 > this.f11326o) {
                throw new EOFException();
            }
            int read = this.f11324m.read();
            int read2 = this.f11324m.read();
            if ((read | read2) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.f11325n;
            if (byteOrder == f11322q) {
                return (read2 << 8) + read;
            }
            if (byteOrder == f11323r) {
                return (read << 8) + read2;
            }
            throw new IOException("Invalid byte order: " + this.f11325n);
        }

        @Override
        public int skipBytes(int i10) {
            int min = Math.min(i10, this.f11326o - this.f11327p);
            int i11 = 0;
            while (i11 < min) {
                i11 += this.f11324m.skipBytes(min - i11);
            }
            this.f11327p += i11;
            return i11;
        }
    }

    public static class c {

        public final int f11328a;

        public final int f11329b;

        public final long f11330c;

        public final byte[] f11331d;

        c(int i10, int i11, long j10, byte[] bArr) {
            this.f11328a = i10;
            this.f11329b = i11;
            this.f11330c = j10;
            this.f11331d = bArr;
        }

        c(int i10, int i11, byte[] bArr) {
            this(i10, i11, -1L, bArr);
        }

        public static c a(String str) {
            byte[] bytes = (str + (char) 0).getBytes(a.f11288s0);
            return new c(2, bytes.length, bytes);
        }

        public static c b(long j10, ByteOrder byteOrder) {
            return c(new long[]{j10}, byteOrder);
        }

        public static c c(long[] jArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.Y[4] * jArr.length]);
            wrap.order(byteOrder);
            for (long j10 : jArr) {
                wrap.putInt((int) j10);
            }
            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.Y[5] * eVarArr.length]);
            wrap.order(byteOrder);
            for (e eVar : eVarArr) {
                wrap.putInt((int) eVar.f11336a);
                wrap.putInt((int) eVar.f11337b);
            }
            return new c(5, eVarArr.length, wrap.array());
        }

        public static c f(int i10, ByteOrder byteOrder) {
            return g(new int[]{i10}, byteOrder);
        }

        public static c g(int[] iArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.Y[3] * iArr.length]);
            wrap.order(byteOrder);
            for (int i10 : iArr) {
                wrap.putShort((short) i10);
            }
            return new c(3, iArr.length, wrap.array());
        }

        public double h(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 == null) {
                throw new NumberFormatException("NULL can't be converted to a double value");
            }
            if (k10 instanceof String) {
                return Double.parseDouble((String) k10);
            }
            if (k10 instanceof long[]) {
                if (((long[]) k10).length == 1) {
                    return r5[0];
                }
                throw new NumberFormatException("There are more than one component");
            }
            if (k10 instanceof int[]) {
                if (((int[]) k10).length == 1) {
                    return r5[0];
                }
                throw new NumberFormatException("There are more than one component");
            }
            if (k10 instanceof double[]) {
                double[] dArr = (double[]) k10;
                if (dArr.length == 1) {
                    return dArr[0];
                }
                throw new NumberFormatException("There are more than one component");
            }
            if (!(k10 instanceof e[])) {
                throw new NumberFormatException("Couldn't find a double value");
            }
            e[] eVarArr = (e[]) k10;
            if (eVarArr.length == 1) {
                return eVarArr[0].a();
            }
            throw new NumberFormatException("There are more than one component");
        }

        public int i(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 == null) {
                throw new NumberFormatException("NULL can't be converted to a integer value");
            }
            if (k10 instanceof String) {
                return Integer.parseInt((String) k10);
            }
            if (k10 instanceof long[]) {
                long[] jArr = (long[]) k10;
                if (jArr.length == 1) {
                    return (int) jArr[0];
                }
                throw new NumberFormatException("There are more than one component");
            }
            if (!(k10 instanceof int[])) {
                throw new NumberFormatException("Couldn't find a integer value");
            }
            int[] iArr = (int[]) k10;
            if (iArr.length == 1) {
                return iArr[0];
            }
            throw new NumberFormatException("There are more than one component");
        }

        public String j(ByteOrder byteOrder) {
            Object k10 = k(byteOrder);
            if (k10 == null) {
                return null;
            }
            if (k10 instanceof String) {
                return (String) k10;
            }
            StringBuilder sb2 = new StringBuilder();
            int i10 = 0;
            if (k10 instanceof long[]) {
                long[] jArr = (long[]) k10;
                while (i10 < jArr.length) {
                    sb2.append(jArr[i10]);
                    i10++;
                    if (i10 != jArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (k10 instanceof int[]) {
                int[] iArr = (int[]) k10;
                while (i10 < iArr.length) {
                    sb2.append(iArr[i10]);
                    i10++;
                    if (i10 != iArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (k10 instanceof double[]) {
                double[] dArr = (double[]) k10;
                while (i10 < dArr.length) {
                    sb2.append(dArr[i10]);
                    i10++;
                    if (i10 != dArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (!(k10 instanceof e[])) {
                return null;
            }
            e[] eVarArr = (e[]) k10;
            while (i10 < eVarArr.length) {
                sb2.append(eVarArr[i10].f11336a);
                sb2.append('/');
                sb2.append(eVarArr[i10].f11337b);
                i10++;
                if (i10 != eVarArr.length) {
                    sb2.append(",");
                }
            }
            return sb2.toString();
        }

        Object k(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b10;
            byte[] bArr;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(this.f11331d);
                    try {
                        bVar.B(byteOrder);
                        boolean z10 = true;
                        int i10 = 0;
                        switch (this.f11328a) {
                            case 1:
                            case 6:
                                byte[] bArr2 = this.f11331d;
                                if (bArr2.length != 1 || bArr2[0] < 0 || bArr2[0] > 1) {
                                    String str = new String(bArr2, a.f11288s0);
                                    try {
                                        bVar.close();
                                    } catch (IOException e10) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                    }
                                    return str;
                                }
                                String str2 = new String(new char[]{(char) (bArr2[0] + 48)});
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (this.f11329b >= a.Z.length) {
                                    int i11 = 0;
                                    while (true) {
                                        bArr = a.Z;
                                        if (i11 < bArr.length) {
                                            if (this.f11331d[i11] != bArr[i11]) {
                                                z10 = false;
                                            } else {
                                                i11++;
                                            }
                                        }
                                    }
                                    if (z10) {
                                        i10 = bArr.length;
                                    }
                                }
                                StringBuilder sb2 = new StringBuilder();
                                while (i10 < this.f11329b && (b10 = this.f11331d[i10]) != 0) {
                                    if (b10 >= 32) {
                                        sb2.append((char) b10);
                                    } else {
                                        sb2.append('?');
                                    }
                                    i10++;
                                }
                                String sb3 = sb2.toString();
                                try {
                                    bVar.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return sb3;
                            case 3:
                                int[] iArr = new int[this.f11329b];
                                while (i10 < this.f11329b) {
                                    iArr[i10] = bVar.readUnsignedShort();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e13) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                                }
                                return iArr;
                            case 4:
                                long[] jArr = new long[this.f11329b];
                                while (i10 < this.f11329b) {
                                    jArr[i10] = bVar.f();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e14) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                                }
                                return jArr;
                            case 5:
                                e[] eVarArr = new e[this.f11329b];
                                while (i10 < this.f11329b) {
                                    eVarArr[i10] = new e(bVar.f(), bVar.f());
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e15) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                                }
                                return eVarArr;
                            case 8:
                                int[] iArr2 = new int[this.f11329b];
                                while (i10 < this.f11329b) {
                                    iArr2[i10] = bVar.readShort();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e16) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                                }
                                return iArr2;
                            case 9:
                                int[] iArr3 = new int[this.f11329b];
                                while (i10 < this.f11329b) {
                                    iArr3[i10] = bVar.readInt();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e17) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e17);
                                }
                                return iArr3;
                            case 10:
                                e[] eVarArr2 = new e[this.f11329b];
                                while (i10 < this.f11329b) {
                                    eVarArr2[i10] = new e(bVar.readInt(), bVar.readInt());
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e18) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e18);
                                }
                                return eVarArr2;
                            case 11:
                                double[] dArr = new double[this.f11329b];
                                while (i10 < this.f11329b) {
                                    dArr[i10] = bVar.readFloat();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e19) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e19);
                                }
                                return dArr;
                            case 12:
                                double[] dArr2 = new double[this.f11329b];
                                while (i10 < this.f11329b) {
                                    dArr2[i10] = bVar.readDouble();
                                    i10++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e20) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e20);
                                }
                                return dArr2;
                            default:
                                try {
                                    bVar.close();
                                } catch (IOException e21) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e21);
                                }
                                return null;
                        }
                    } catch (IOException e22) {
                        e = e22;
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (bVar != null) {
                            try {
                                bVar.close();
                            } catch (IOException e23) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e23);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th) {
                    th = th;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e24) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e24);
                        }
                    }
                    throw th;
                }
            } catch (IOException e25) {
                e = e25;
                bVar = null;
            } catch (Throwable th2) {
                th = th2;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

        public String toString() {
            return "(" + a.X[this.f11328a] + ", data length:" + this.f11331d.length + ")";
        }
    }

    public static class d {

        public final int f11332a;

        public final String f11333b;

        public final int f11334c;

        public final int f11335d;

        d(String str, int i10, int i11) {
            this.f11333b = str;
            this.f11332a = i10;
            this.f11334c = i11;
            this.f11335d = -1;
        }

        d(String str, int i10, int i11, int i12) {
            this.f11333b = str;
            this.f11332a = i10;
            this.f11334c = i11;
            this.f11335d = i12;
        }

        boolean a(int i10) {
            int i11;
            int i12 = this.f11334c;
            if (i12 == 7 || i10 == 7 || i12 == i10 || (i11 = this.f11335d) == i10) {
                return true;
            }
            if ((i12 == 4 || i11 == 4) && i10 == 3) {
                return true;
            }
            if ((i12 == 9 || i11 == 9) && i10 == 8) {
                return true;
            }
            return (i12 == 12 || i11 == 12) && i10 == 11;
        }
    }

    public static class e {

        public final long f11336a;

        public final long f11337b;

        e(long j10, long j11) {
            if (j11 == 0) {
                this.f11336a = 0L;
                this.f11337b = 1L;
            } else {
                this.f11336a = j10;
                this.f11337b = j11;
            }
        }

        public double a() {
            return this.f11336a / this.f11337b;
        }

        public String toString() {
            return this.f11336a + "/" + this.f11337b;
        }
    }

    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)};
        f11270a0 = 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)};
        f11271b0 = dVarArr2;
        d[] dVarArr3 = {new d("GPSVersionID", 0, 1), new d("GPSLatitudeRef", 1, 2), new d("GPSLatitude", 2, 5), new d("GPSLongitudeRef", 3, 2), new d("GPSLongitude", 4, 5), 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)};
        f11272c0 = dVarArr3;
        d[] dVarArr4 = {new d("InteroperabilityIndex", 1, 2)};
        f11273d0 = 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("Copyright", 33432, 2), new d("ExifIFDPointer", 34665, 4), new d("GPSInfoIFDPointer", 34853, 4), new d("DNGVersion", 50706, 1), new d("DefaultCropSize", 50720, 3, 4)};
        f11274e0 = dVarArr5;
        f11275f0 = new d("StripOffsets", 273, 3);
        d[] dVarArr6 = {new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)};
        f11276g0 = dVarArr6;
        d[] dVarArr7 = {new d("PreviewImageStart", 257, 4), new d("PreviewImageLength", 258, 4)};
        f11277h0 = dVarArr7;
        d[] dVarArr8 = {new d("AspectFrame", 4371, 3)};
        f11278i0 = dVarArr8;
        d[] dVarArr9 = {new d("ColorSpace", 55, 3)};
        f11279j0 = dVarArr9;
        d[][] dVarArr10 = {dVarArr, dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr, dVarArr6, dVarArr7, dVarArr8, dVarArr9};
        f11280k0 = dVarArr10;
        f11281l0 = 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)};
        f11282m0 = new d("JPEGInterchangeFormat", 513, 4);
        f11283n0 = new d("JPEGInterchangeFormatLength", 514, 4);
        f11284o0 = new HashMap[dVarArr10.length];
        f11285p0 = new HashMap[dVarArr10.length];
        f11286q0 = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        f11287r0 = new HashMap<>();
        Charset forName = Charset.forName("US-ASCII");
        f11288s0 = forName;
        f11289t0 = "Exif\u0000\u0000".getBytes(forName);
        f11290u0 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        W = simpleDateFormat;
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            d[][] dVarArr11 = f11280k0;
            if (i10 >= dVarArr11.length) {
                HashMap<Integer, Integer> hashMap = f11287r0;
                d[] dVarArr12 = f11281l0;
                hashMap.put(Integer.valueOf(dVarArr12[0].f11332a), 5);
                hashMap.put(Integer.valueOf(dVarArr12[1].f11332a), 1);
                hashMap.put(Integer.valueOf(dVarArr12[2].f11332a), 2);
                hashMap.put(Integer.valueOf(dVarArr12[3].f11332a), 3);
                hashMap.put(Integer.valueOf(dVarArr12[4].f11332a), 7);
                hashMap.put(Integer.valueOf(dVarArr12[5].f11332a), 8);
                f11291v0 = Pattern.compile(".*[1-9].*");
                f11293w0 = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
                return;
            }
            f11284o0[i10] = new HashMap<>();
            f11285p0[i10] = new HashMap<>();
            for (d dVar : dVarArr11[i10]) {
                f11284o0[i10].put(Integer.valueOf(dVar.f11332a), dVar);
                f11285p0[i10].put(dVar.f11333b, dVar);
            }
            i10++;
        }
    }

    public a(InputStream inputStream) {
        this(inputStream, false);
    }

    private a(InputStream inputStream, boolean z10) {
        d[][] dVarArr = f11280k0;
        this.f11302f = new HashMap[dVarArr.length];
        this.f11303g = new HashSet(dVarArr.length);
        this.f11304h = ByteOrder.BIG_ENDIAN;
        Objects.requireNonNull(inputStream, "inputStream cannot be null");
        this.f11297a = null;
        if (z10) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            if (!s(bufferedInputStream)) {
                Log.w("ExifInterface", "Given data does not follow the structure of an Exif-only data.");
                return;
            }
            this.f11301e = true;
            this.f11299c = null;
            this.f11298b = null;
            inputStream = bufferedInputStream;
        } else {
            if (inputStream instanceof AssetManager.AssetInputStream) {
                this.f11299c = (AssetManager.AssetInputStream) inputStream;
            } else {
                if (inputStream instanceof FileInputStream) {
                    FileInputStream fileInputStream = (FileInputStream) inputStream;
                    if (z(fileInputStream.getFD())) {
                        this.f11299c = null;
                        this.f11298b = fileInputStream.getFD();
                    }
                }
                this.f11299c = null;
            }
            this.f11298b = null;
        }
        D(inputStream);
    }

    private boolean A(HashMap hashMap) {
        c cVar;
        int i10;
        c cVar2 = (c) hashMap.get("BitsPerSample");
        if (cVar2 != null) {
            int[] iArr = (int[]) cVar2.k(this.f11304h);
            int[] iArr2 = f11296z;
            if (Arrays.equals(iArr2, iArr)) {
                return true;
            }
            if (this.f11300d == 3 && (cVar = (c) hashMap.get("PhotometricInterpretation")) != null && (((i10 = cVar.i(this.f11304h)) == 1 && Arrays.equals(iArr, B)) || (i10 == 6 && Arrays.equals(iArr, iArr2)))) {
                return true;
            }
        }
        if (!f11292w) {
            return false;
        }
        Log.d("ExifInterface", "Unsupported data type value");
        return false;
    }

    private boolean B(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.f11304h) <= 512 && cVar2.i(this.f11304h) <= 512;
    }

    private boolean C(byte[] bArr) {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = M;
            if (i10 >= bArr2.length) {
                int i11 = 0;
                while (true) {
                    byte[] bArr3 = N;
                    if (i11 >= bArr3.length) {
                        return true;
                    }
                    if (bArr[M.length + i11 + 4] != bArr3[i11]) {
                        return false;
                    }
                    i11++;
                }
            } else {
                if (bArr[i10] != bArr2[i10]) {
                    return false;
                }
                i10++;
            }
        }
    }

    private void D(InputStream inputStream) {
        Objects.requireNonNull(inputStream, "inputstream shouldn't be null");
        for (int i10 = 0; i10 < f11280k0.length; i10++) {
            try {
                try {
                    this.f11302f[i10] = new HashMap<>();
                } catch (IOException e10) {
                    this.f11317u = false;
                    boolean z10 = f11292w;
                    if (z10) {
                        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.", e10);
                    }
                    a();
                    if (!z10) {
                        return;
                    }
                }
            } finally {
                a();
                if (f11292w) {
                    F();
                }
            }
        }
        if (!this.f11301e) {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
            this.f11300d = i(bufferedInputStream);
            inputStream = bufferedInputStream;
        }
        b bVar = new b(inputStream);
        if (!this.f11301e) {
            switch (this.f11300d) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 5:
                case 6:
                case 8:
                case 11:
                    m(bVar);
                    break;
                case 4:
                    h(bVar, 0, 0);
                    break;
                case 7:
                    j(bVar);
                    break;
                case 9:
                    l(bVar);
                    break;
                case 10:
                    n(bVar);
                    break;
                case 12:
                    g(bVar);
                    break;
                case 13:
                    k(bVar);
                    break;
                case 14:
                    p(bVar);
                    break;
            }
        } else {
            o(bVar);
        }
        K(bVar);
        this.f11317u = true;
    }

    private void E(b bVar, int i10) {
        ByteOrder G2 = G(bVar);
        this.f11304h = G2;
        bVar.B(G2);
        int readUnsignedShort = bVar.readUnsignedShort();
        int i11 = this.f11300d;
        if (i11 != 7 && i11 != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = bVar.readInt();
        if (readInt < 8 || readInt >= i10) {
            throw new IOException("Invalid first Ifd offset: " + readInt);
        }
        int i12 = readInt - 8;
        if (i12 <= 0 || bVar.skipBytes(i12) == i12) {
            return;
        }
        throw new IOException("Couldn't jump to first Ifd: " + i12);
    }

    private void F() {
        for (int i10 = 0; i10 < this.f11302f.length; i10++) {
            Log.d("ExifInterface", "The size of tag group[" + i10 + "]: " + this.f11302f[i10].size());
            for (Map.Entry<String, c> entry : this.f11302f[i10].entrySet()) {
                c value = entry.getValue();
                Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.j(this.f11304h) + "'");
            }
        }
    }

    private ByteOrder G(b bVar) {
        short readShort = bVar.readShort();
        if (readShort == 18761) {
            if (f11292w) {
                Log.d("ExifInterface", "readExifSegment: Byte Align II");
            }
            return ByteOrder.LITTLE_ENDIAN;
        }
        if (readShort == 19789) {
            if (f11292w) {
                Log.d("ExifInterface", "readExifSegment: Byte Align MM");
            }
            return ByteOrder.BIG_ENDIAN;
        }
        throw new IOException("Invalid byte order: " + Integer.toHexString(readShort));
    }

    private void H(byte[] bArr, int i10) {
        b bVar = new b(bArr);
        E(bVar, bArr.length);
        I(bVar, i10);
    }

    private void I(b bVar, int i10) {
        StringBuilder sb2;
        String str;
        String str2;
        short s10;
        long j10;
        boolean z10;
        StringBuilder sb3;
        short s11;
        d dVar;
        long j11;
        int i11;
        int i12;
        int i13;
        long j12;
        int readUnsignedShort;
        String str3;
        int i14 = i10;
        this.f11303g.add(Integer.valueOf(bVar.f11327p));
        if (bVar.f11327p + 2 > bVar.f11326o) {
            return;
        }
        short readShort = bVar.readShort();
        String str4 = "ExifInterface";
        if (f11292w) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (bVar.f11327p + (readShort * 12) > bVar.f11326o || readShort <= 0) {
            return;
        }
        char c10 = 0;
        short s12 = 0;
        while (s12 < readShort) {
            int readUnsignedShort2 = bVar.readUnsignedShort();
            int readUnsignedShort3 = bVar.readUnsignedShort();
            int readInt = bVar.readInt();
            long c11 = bVar.c() + 4;
            d dVar2 = f11284o0[i14].get(Integer.valueOf(readUnsignedShort2));
            boolean z11 = f11292w;
            if (z11) {
                Object[] objArr = new Object[5];
                objArr[c10] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                objArr[2] = dVar2 != null ? dVar2.f11333b : 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 (dVar2 == null) {
                if (z11) {
                    sb3 = new StringBuilder();
                    sb3.append("Skip the tag entry since tag number is not defined: ");
                    sb3.append(readUnsignedShort2);
                    Log.d(str4, sb3.toString());
                }
                str2 = str4;
                s10 = s12;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < Y.length) {
                        if (dVar2.a(readUnsignedShort3)) {
                            if (readUnsignedShort3 == 7) {
                                readUnsignedShort3 = dVar2.f11334c;
                            }
                            str2 = str4;
                            s10 = s12;
                            j10 = readInt * r8[readUnsignedShort3];
                            if (j10 < 0 || j10 > 2147483647L) {
                                if (z11) {
                                    Log.d(str2, "Skip the tag entry since the number of components is invalid: " + readInt);
                                }
                                z10 = false;
                                if (z10) {
                                    if (j10 > 4) {
                                        int readInt2 = bVar.readInt();
                                        s11 = readShort;
                                        if (z11) {
                                            StringBuilder sb4 = new StringBuilder();
                                            i12 = readUnsignedShort3;
                                            sb4.append("seek to data offset: ");
                                            sb4.append(readInt2);
                                            Log.d(str2, sb4.toString());
                                        } else {
                                            i12 = readUnsignedShort3;
                                        }
                                        int i15 = this.f11300d;
                                        if (i15 == 7) {
                                            if ("MakerNote".equals(dVar2.f11333b)) {
                                                this.f11313q = readInt2;
                                            } else if (i14 == 6 && "ThumbnailImage".equals(dVar2.f11333b)) {
                                                this.f11314r = readInt2;
                                                this.f11315s = readInt;
                                                c f10 = c.f(6, this.f11304h);
                                                i13 = readInt;
                                                c b10 = c.b(this.f11314r, this.f11304h);
                                                i11 = readUnsignedShort2;
                                                c b11 = c.b(this.f11315s, this.f11304h);
                                                this.f11302f[4].put("Compression", f10);
                                                this.f11302f[4].put("JPEGInterchangeFormat", b10);
                                                this.f11302f[4].put("JPEGInterchangeFormatLength", b11);
                                            }
                                            i11 = readUnsignedShort2;
                                            i13 = readInt;
                                        } else {
                                            i11 = readUnsignedShort2;
                                            i13 = readInt;
                                            if (i15 == 10 && "JpgFromRaw".equals(dVar2.f11333b)) {
                                                this.f11316t = readInt2;
                                            }
                                        }
                                        long j13 = readInt2;
                                        dVar = dVar2;
                                        j11 = j10;
                                        if (j13 + j10 <= bVar.f11326o) {
                                            bVar.p(j13);
                                        } else {
                                            if (z11) {
                                                Log.d(str2, "Skip the tag entry since data offset is invalid: " + readInt2);
                                            }
                                            bVar.p(c11);
                                        }
                                    } else {
                                        s11 = readShort;
                                        dVar = dVar2;
                                        j11 = j10;
                                        i11 = readUnsignedShort2;
                                        i12 = readUnsignedShort3;
                                        i13 = readInt;
                                    }
                                    Integer num = f11287r0.get(Integer.valueOf(i11));
                                    if (z11) {
                                        StringBuilder sb5 = new StringBuilder();
                                        sb5.append("nextIfdType: ");
                                        sb5.append(num);
                                        sb5.append(" byteCount: ");
                                        j12 = j11;
                                        sb5.append(j12);
                                        Log.d(str2, sb5.toString());
                                    } else {
                                        j12 = j11;
                                    }
                                    if (num != null) {
                                        long j14 = -1;
                                        int i16 = i12;
                                        if (i16 != 3) {
                                            if (i16 == 4) {
                                                j14 = bVar.f();
                                            } else if (i16 == 8) {
                                                readUnsignedShort = bVar.readShort();
                                            } else if (i16 == 9 || i16 == 13) {
                                                readUnsignedShort = bVar.readInt();
                                            }
                                            if (z11) {
                                                Log.d(str2, String.format("Offset: %d, tagName: %s", Long.valueOf(j14), dVar.f11333b));
                                            }
                                            if (j14 > 0 || j14 >= bVar.f11326o) {
                                                if (z11) {
                                                    str3 = "Skip jump into the IFD since its offset is invalid: " + j14;
                                                    Log.d(str2, str3);
                                                }
                                            } else if (!this.f11303g.contains(Integer.valueOf((int) j14))) {
                                                bVar.p(j14);
                                                I(bVar, num.intValue());
                                            } else if (z11) {
                                                str3 = "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j14 + ")";
                                                Log.d(str2, str3);
                                            }
                                            s12 = (short) (s10 + 1);
                                            i14 = i10;
                                            str4 = str2;
                                            readShort = s11;
                                            c10 = 0;
                                        } else {
                                            readUnsignedShort = bVar.readUnsignedShort();
                                        }
                                        j14 = readUnsignedShort;
                                        if (z11) {
                                        }
                                        if (j14 > 0) {
                                        }
                                        if (z11) {
                                        }
                                    } else {
                                        d dVar3 = dVar;
                                        int c12 = bVar.c() + this.f11312p;
                                        byte[] bArr = new byte[(int) j12];
                                        bVar.readFully(bArr);
                                        c cVar = new c(i12, i13, c12, bArr);
                                        this.f11302f[i10].put(dVar3.f11333b, cVar);
                                        if ("DNGVersion".equals(dVar3.f11333b)) {
                                            this.f11300d = 3;
                                        }
                                        if ((("Make".equals(dVar3.f11333b) || "Model".equals(dVar3.f11333b)) && cVar.j(this.f11304h).contains("PENTAX")) || ("Compression".equals(dVar3.f11333b) && cVar.i(this.f11304h) == 65535)) {
                                            this.f11300d = 8;
                                        }
                                        if (bVar.c() == c11) {
                                            s12 = (short) (s10 + 1);
                                            i14 = i10;
                                            str4 = str2;
                                            readShort = s11;
                                            c10 = 0;
                                        }
                                    }
                                    bVar.p(c11);
                                    s12 = (short) (s10 + 1);
                                    i14 = i10;
                                    str4 = str2;
                                    readShort = s11;
                                    c10 = 0;
                                } else {
                                    bVar.p(c11);
                                    s11 = readShort;
                                }
                                s12 = (short) (s10 + 1);
                                i14 = i10;
                                str4 = str2;
                                readShort = s11;
                                c10 = 0;
                            } else {
                                z10 = true;
                                if (z10) {
                                }
                                s12 = (short) (s10 + 1);
                                i14 = i10;
                                str4 = str2;
                                readShort = s11;
                                c10 = 0;
                            }
                        } else {
                            if (z11) {
                                sb3 = new StringBuilder();
                                sb3.append("Skip the tag entry since data format (");
                                sb3.append(X[readUnsignedShort3]);
                                sb3.append(") is unexpected for tag: ");
                                sb3.append(dVar2.f11333b);
                                Log.d(str4, sb3.toString());
                            }
                            str2 = str4;
                            s10 = s12;
                        }
                    }
                }
                str2 = str4;
                s10 = s12;
                if (z11) {
                    Log.d(str2, "Skip the tag entry since data format is invalid: " + readUnsignedShort3);
                }
            }
            j10 = 0;
            z10 = false;
            if (z10) {
            }
            s12 = (short) (s10 + 1);
            i14 = i10;
            str4 = str2;
            readShort = s11;
            c10 = 0;
        }
        String str5 = str4;
        if (bVar.c() + 4 <= bVar.f11326o) {
            int readInt3 = bVar.readInt();
            boolean z12 = f11292w;
            if (z12) {
                Log.d(str5, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
            }
            long j15 = readInt3;
            if (j15 <= 0 || readInt3 >= bVar.f11326o) {
                if (!z12) {
                    return;
                }
                sb2 = new StringBuilder();
                str = "Stop reading file since a wrong offset may cause an infinite loop: ";
            } else {
                if (!this.f11303g.contains(Integer.valueOf(readInt3))) {
                    bVar.p(j15);
                    if (this.f11302f[4].isEmpty()) {
                        I(bVar, 4);
                        return;
                    } else {
                        if (this.f11302f[5].isEmpty()) {
                            I(bVar, 5);
                            return;
                        }
                        return;
                    }
                }
                if (!z12) {
                    return;
                }
                sb2 = new StringBuilder();
                str = "Stop reading file since re-reading an IFD may cause an infinite loop: ";
            }
            sb2.append(str);
            sb2.append(readInt3);
            Log.d(str5, sb2.toString());
        }
    }

    private void J(b bVar, int i10) {
        c cVar;
        c cVar2 = this.f11302f[i10].get("ImageLength");
        c cVar3 = this.f11302f[i10].get("ImageWidth");
        if ((cVar2 == null || cVar3 == null) && (cVar = this.f11302f[i10].get("JPEGInterchangeFormat")) != null) {
            h(bVar, cVar.i(this.f11304h), i10);
        }
    }

    private void K(b bVar) {
        HashMap<String, c> hashMap = this.f11302f[4];
        c cVar = hashMap.get("Compression");
        if (cVar != null) {
            int i10 = cVar.i(this.f11304h);
            this.f11311o = i10;
            if (i10 != 1) {
                if (i10 != 6) {
                    if (i10 != 7) {
                        return;
                    }
                }
            }
            if (A(hashMap)) {
                r(bVar, hashMap);
                return;
            }
            return;
        }
        this.f11311o = 6;
        q(bVar, hashMap);
    }

    private static boolean L(byte[] bArr, byte[] bArr2) {
        if (bArr == null || bArr2 == null || bArr.length < bArr2.length) {
            return false;
        }
        for (int i10 = 0; i10 < bArr2.length; i10++) {
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
        }
        return true;
    }

    private void M(int i10, int i11) {
        String str;
        if (this.f11302f[i10].isEmpty() || this.f11302f[i11].isEmpty()) {
            if (f11292w) {
                Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
                return;
            }
            return;
        }
        c cVar = this.f11302f[i10].get("ImageLength");
        c cVar2 = this.f11302f[i10].get("ImageWidth");
        c cVar3 = this.f11302f[i11].get("ImageLength");
        c cVar4 = this.f11302f[i11].get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            if (!f11292w) {
                return;
            } else {
                str = "First image does not contain valid size information";
            }
        } else {
            if (cVar3 != null && cVar4 != null) {
                int i12 = cVar.i(this.f11304h);
                int i13 = cVar2.i(this.f11304h);
                int i14 = cVar3.i(this.f11304h);
                int i15 = cVar4.i(this.f11304h);
                if (i12 >= i14 || i13 >= i15) {
                    return;
                }
                HashMap<String, c>[] hashMapArr = this.f11302f;
                HashMap<String, c> hashMap = hashMapArr[i10];
                hashMapArr[i10] = hashMapArr[i11];
                hashMapArr[i11] = hashMap;
                return;
            }
            if (!f11292w) {
                return;
            } else {
                str = "Second image does not contain valid size information";
            }
        }
        Log.d("ExifInterface", str);
    }

    private void N(b bVar, int i10) {
        StringBuilder sb2;
        String arrays;
        c f10;
        c f11;
        c cVar = this.f11302f[i10].get("DefaultCropSize");
        c cVar2 = this.f11302f[i10].get("SensorTopBorder");
        c cVar3 = this.f11302f[i10].get("SensorLeftBorder");
        c cVar4 = this.f11302f[i10].get("SensorBottomBorder");
        c cVar5 = this.f11302f[i10].get("SensorRightBorder");
        if (cVar == null) {
            if (cVar2 == null || cVar3 == null || cVar4 == null || cVar5 == null) {
                J(bVar, i10);
                return;
            }
            int i11 = cVar2.i(this.f11304h);
            int i12 = cVar4.i(this.f11304h);
            int i13 = cVar5.i(this.f11304h);
            int i14 = cVar3.i(this.f11304h);
            if (i12 <= i11 || i13 <= i14) {
                return;
            }
            c f12 = c.f(i12 - i11, this.f11304h);
            c f13 = c.f(i13 - i14, this.f11304h);
            this.f11302f[i10].put("ImageLength", f12);
            this.f11302f[i10].put("ImageWidth", f13);
            return;
        }
        if (cVar.f11328a == 5) {
            e[] eVarArr = (e[]) cVar.k(this.f11304h);
            if (eVarArr != null && eVarArr.length == 2) {
                f10 = c.d(eVarArr[0], this.f11304h);
                f11 = c.d(eVarArr[1], this.f11304h);
                this.f11302f[i10].put("ImageWidth", f10);
                this.f11302f[i10].put("ImageLength", f11);
                return;
            }
            sb2 = new StringBuilder();
            sb2.append("Invalid crop size values. cropSize=");
            arrays = Arrays.toString(eVarArr);
            sb2.append(arrays);
            Log.w("ExifInterface", sb2.toString());
        }
        int[] iArr = (int[]) cVar.k(this.f11304h);
        if (iArr != null && iArr.length == 2) {
            f10 = c.f(iArr[0], this.f11304h);
            f11 = c.f(iArr[1], this.f11304h);
            this.f11302f[i10].put("ImageWidth", f10);
            this.f11302f[i10].put("ImageLength", f11);
            return;
        }
        sb2 = new StringBuilder();
        sb2.append("Invalid crop size values. cropSize=");
        arrays = Arrays.toString(iArr);
        sb2.append(arrays);
        Log.w("ExifInterface", sb2.toString());
    }

    private void O() {
        M(0, 5);
        M(0, 4);
        M(5, 4);
        c cVar = this.f11302f[1].get("PixelXDimension");
        c cVar2 = this.f11302f[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            this.f11302f[0].put("ImageWidth", cVar);
            this.f11302f[0].put("ImageLength", cVar2);
        }
        if (this.f11302f[4].isEmpty() && B(this.f11302f[5])) {
            HashMap<String, c>[] hashMapArr = this.f11302f;
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (B(this.f11302f[4])) {
            return;
        }
        Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
    }

    private void a() {
        String d10 = d("DateTimeOriginal");
        if (d10 != null && d("DateTime") == null) {
            this.f11302f[0].put("DateTime", c.a(d10));
        }
        if (d("ImageWidth") == null) {
            this.f11302f[0].put("ImageWidth", c.b(0L, this.f11304h));
        }
        if (d("ImageLength") == null) {
            this.f11302f[0].put("ImageLength", c.b(0L, this.f11304h));
        }
        if (d("Orientation") == null) {
            this.f11302f[0].put("Orientation", c.b(0L, this.f11304h));
        }
        if (d("LightSource") == null) {
            this.f11302f[1].put("LightSource", c.b(0L, this.f11304h));
        }
    }

    private static String b(byte[] bArr) {
        StringBuilder sb2 = new StringBuilder(bArr.length * 2);
        for (byte b10 : bArr) {
            sb2.append(String.format("%02x", Byte.valueOf(b10)));
        }
        return sb2.toString();
    }

    private static long[] c(Object obj) {
        if (!(obj instanceof int[])) {
            if (obj instanceof long[]) {
                return (long[]) obj;
            }
            return null;
        }
        int[] iArr = (int[]) obj;
        long[] jArr = new long[iArr.length];
        for (int i10 = 0; i10 < iArr.length; i10++) {
            jArr[i10] = iArr[i10];
        }
        return jArr;
    }

    private c f(String str) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        if ("ISOSpeedRatings".equals(str)) {
            if (f11292w) {
                Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str = "PhotographicSensitivity";
        }
        for (int i10 = 0; i10 < f11280k0.length; i10++) {
            c cVar = this.f11302f[i10].get(str);
            if (cVar != null) {
                return cVar;
            }
        }
        return null;
    }

    private void g(b bVar) {
        String str;
        String str2;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new C0142a(bVar));
            } else {
                FileDescriptor fileDescriptor = this.f11298b;
                if (fileDescriptor != null) {
                    mediaMetadataRetriever.setDataSource(fileDescriptor);
                } else {
                    String str3 = this.f11297a;
                    if (str3 == null) {
                        return;
                    } else {
                        mediaMetadataRetriever.setDataSource(str3);
                    }
                }
            }
            String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
            String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
            String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
            String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
            String str4 = null;
            if ("yes".equals(extractMetadata3)) {
                str4 = mediaMetadataRetriever.extractMetadata(29);
                str = mediaMetadataRetriever.extractMetadata(30);
                str2 = mediaMetadataRetriever.extractMetadata(31);
            } else if ("yes".equals(extractMetadata4)) {
                str4 = mediaMetadataRetriever.extractMetadata(18);
                str = mediaMetadataRetriever.extractMetadata(19);
                str2 = mediaMetadataRetriever.extractMetadata(24);
            } else {
                str = null;
                str2 = null;
            }
            if (str4 != null) {
                this.f11302f[0].put("ImageWidth", c.f(Integer.parseInt(str4), this.f11304h));
            }
            if (str != null) {
                this.f11302f[0].put("ImageLength", c.f(Integer.parseInt(str), this.f11304h));
            }
            if (str2 != null) {
                int i10 = 1;
                int parseInt = Integer.parseInt(str2);
                if (parseInt == 90) {
                    i10 = 6;
                } else if (parseInt == 180) {
                    i10 = 3;
                } else if (parseInt == 270) {
                    i10 = 8;
                }
                this.f11302f[0].put("Orientation", c.f(i10, this.f11304h));
            }
            if (extractMetadata != null && extractMetadata2 != null) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 <= 6) {
                    throw new IOException("Invalid exif length");
                }
                bVar.p(parseInt2);
                byte[] bArr = new byte[6];
                if (bVar.read(bArr) != 6) {
                    throw new IOException("Can't read identifier");
                }
                int i11 = parseInt2 + 6;
                int i12 = parseInt3 - 6;
                if (!Arrays.equals(bArr, f11289t0)) {
                    throw new IOException("Invalid identifier");
                }
                byte[] bArr2 = new byte[i12];
                if (bVar.read(bArr2) != i12) {
                    throw new IOException("Can't read exif");
                }
                this.f11312p = i11;
                H(bArr2, 0);
            }
            if (f11292w) {
                Log.d("ExifInterface", "Heif meta: " + str4 + "x" + str + ", rotation " + str2);
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    private void h(b bVar, int i10, int i11) {
        int i12;
        if (f11292w) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.B(ByteOrder.BIG_ENDIAN);
        bVar.p(i10);
        byte readByte = bVar.readByte();
        byte b10 = -1;
        if (readByte != -1) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
        int i13 = 1;
        int i14 = i10 + 1;
        if (bVar.readByte() != -40) {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
        int i15 = i14 + 1;
        while (true) {
            byte readByte2 = bVar.readByte();
            if (readByte2 != b10) {
                throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
            }
            int i16 = i15 + i13;
            byte readByte3 = bVar.readByte();
            boolean z10 = f11292w;
            if (z10) {
                Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
            }
            int i17 = i16 + i13;
            if (readByte3 != -39 && readByte3 != -38) {
                int readUnsignedShort = bVar.readUnsignedShort() - 2;
                int i18 = i17 + 2;
                if (z10) {
                    Log.d("ExifInterface", "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);
                    i12 = i18 + readUnsignedShort;
                    byte[] bArr2 = f11289t0;
                    if (L(bArr, bArr2)) {
                        int length = i18 + bArr2.length;
                        byte[] copyOfRange = Arrays.copyOfRange(bArr, bArr2.length, readUnsignedShort);
                        this.f11312p = length;
                        H(copyOfRange, i11);
                    } else {
                        byte[] bArr3 = f11290u0;
                        if (L(bArr, bArr3)) {
                            int length2 = i18 + bArr3.length;
                            byte[] copyOfRange2 = Arrays.copyOfRange(bArr, bArr3.length, readUnsignedShort);
                            if (d("Xmp") == null) {
                                this.f11302f[0].put("Xmp", new c(1, copyOfRange2.length, length2, copyOfRange2));
                                this.f11318v = true;
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 0) {
                                }
                            }
                        }
                    }
                } else if (readByte3 != -2) {
                    switch (readByte3) {
                        default:
                            switch (readByte3) {
                                default:
                                    switch (readByte3) {
                                        default:
                                            switch (readByte3) {
                                            }
                                        case -55:
                                        case -54:
                                        case -53:
                                            if (bVar.skipBytes(i13) != i13) {
                                                throw new IOException("Invalid SOFx");
                                            }
                                            this.f11302f[i11].put("ImageLength", c.b(bVar.readUnsignedShort(), this.f11304h));
                                            this.f11302f[i11].put("ImageWidth", c.b(bVar.readUnsignedShort(), this.f11304h));
                                            readUnsignedShort -= 5;
                                            break;
                                    }
                                case -59:
                                case -58:
                                case -57:
                                    break;
                            }
                        case -64:
                        case -63:
                        case -62:
                        case -61:
                            break;
                    }
                    i12 = i18;
                    if (readUnsignedShort < 0) {
                        throw new IOException("Invalid length");
                    }
                    if (bVar.skipBytes(readUnsignedShort) != readUnsignedShort) {
                        throw new IOException("Invalid JPEG segment");
                    }
                    i15 = i12 + readUnsignedShort;
                    b10 = -1;
                    i13 = 1;
                } else {
                    byte[] bArr4 = new byte[readUnsignedShort];
                    if (bVar.read(bArr4) != readUnsignedShort) {
                        throw new IOException("Invalid exif");
                    }
                    if (d("UserComment") == null) {
                        this.f11302f[i13].put("UserComment", c.a(new String(bArr4, f11288s0)));
                    }
                    i12 = i18;
                }
                readUnsignedShort = 0;
                if (readUnsignedShort < 0) {
                }
            }
        }
    }

    private int i(BufferedInputStream bufferedInputStream) {
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        if (u(bArr)) {
            return 4;
        }
        if (x(bArr)) {
            return 9;
        }
        if (t(bArr)) {
            return 12;
        }
        if (v(bArr)) {
            return 7;
        }
        if (y(bArr)) {
            return 10;
        }
        if (w(bArr)) {
            return 13;
        }
        return C(bArr) ? 14 : 0;
    }

    private void j(b bVar) {
        c cVar;
        c cVar2;
        c cVar3;
        long j10;
        m(bVar);
        c cVar4 = this.f11302f[1].get("MakerNote");
        if (cVar4 == null) {
            return;
        }
        b bVar2 = new b(cVar4.f11331d);
        bVar2.B(this.f11304h);
        byte[] bArr = G;
        byte[] bArr2 = new byte[bArr.length];
        bVar2.readFully(bArr2);
        bVar2.p(0L);
        byte[] bArr3 = H;
        byte[] bArr4 = new byte[bArr3.length];
        bVar2.readFully(bArr4);
        if (!Arrays.equals(bArr2, bArr)) {
            j10 = Arrays.equals(bArr4, bArr3) ? 12L : 8L;
            I(bVar2, 6);
            cVar = this.f11302f[7].get("PreviewImageStart");
            cVar2 = this.f11302f[7].get("PreviewImageLength");
            if (cVar != null && cVar2 != null) {
                this.f11302f[5].put("JPEGInterchangeFormat", cVar);
                this.f11302f[5].put("JPEGInterchangeFormatLength", cVar2);
            }
            cVar3 = this.f11302f[8].get("AspectFrame");
            if (cVar3 == null) {
                int[] iArr = (int[]) cVar3.k(this.f11304h);
                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 i10 = (iArr[2] - iArr[0]) + 1;
                int i11 = (iArr[3] - iArr[1]) + 1;
                if (i10 < i11) {
                    int i12 = i10 + i11;
                    i11 = i12 - i11;
                    i10 = i12 - i11;
                }
                c f10 = c.f(i10, this.f11304h);
                c f11 = c.f(i11, this.f11304h);
                this.f11302f[0].put("ImageWidth", f10);
                this.f11302f[0].put("ImageLength", f11);
                return;
            }
            return;
        }
        bVar2.p(j10);
        I(bVar2, 6);
        cVar = this.f11302f[7].get("PreviewImageStart");
        cVar2 = this.f11302f[7].get("PreviewImageLength");
        if (cVar != null) {
            this.f11302f[5].put("JPEGInterchangeFormat", cVar);
            this.f11302f[5].put("JPEGInterchangeFormatLength", cVar2);
        }
        cVar3 = this.f11302f[8].get("AspectFrame");
        if (cVar3 == null) {
        }
    }

    private void k(b bVar) {
        if (f11292w) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.B(ByteOrder.BIG_ENDIAN);
        byte[] bArr = I;
        bVar.skipBytes(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = bVar.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) != 4) {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
                int i11 = i10 + 4;
                if (i11 == 16 && !Arrays.equals(bArr2, K)) {
                    throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                }
                if (Arrays.equals(bArr2, L)) {
                    return;
                }
                if (Arrays.equals(bArr2, J)) {
                    byte[] bArr3 = new byte[readInt];
                    if (bVar.read(bArr3) != readInt) {
                        throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr2));
                    }
                    int readInt2 = bVar.readInt();
                    CRC32 crc32 = new CRC32();
                    crc32.update(bArr2);
                    crc32.update(bArr3);
                    if (((int) crc32.getValue()) == readInt2) {
                        this.f11312p = i11;
                        H(bArr3, 0);
                        O();
                        return;
                    } else {
                        throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                    }
                }
                int i12 = readInt + 4;
                bVar.skipBytes(i12);
                length = i11 + i12;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    private void l(b bVar) {
        bVar.skipBytes(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        bVar.read(bArr);
        bVar.skipBytes(4);
        bVar.read(bArr2);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        h(bVar, i10, 5);
        bVar.p(i11);
        bVar.B(ByteOrder.BIG_ENDIAN);
        int readInt = bVar.readInt();
        if (f11292w) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i12 = 0; i12 < readInt; i12++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == f11275f0.f11332a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c f10 = c.f(readShort, this.f11304h);
                c f11 = c.f(readShort2, this.f11304h);
                this.f11302f[0].put("ImageLength", f10);
                this.f11302f[0].put("ImageWidth", f11);
                if (f11292w) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    private void m(b bVar) {
        c cVar;
        E(bVar, bVar.available());
        I(bVar, 0);
        N(bVar, 0);
        N(bVar, 5);
        N(bVar, 4);
        O();
        if (this.f11300d != 8 || (cVar = this.f11302f[1].get("MakerNote")) == null) {
            return;
        }
        b bVar2 = new b(cVar.f11331d);
        bVar2.B(this.f11304h);
        bVar2.p(6L);
        I(bVar2, 9);
        c cVar2 = this.f11302f[9].get("ColorSpace");
        if (cVar2 != null) {
            this.f11302f[1].put("ColorSpace", cVar2);
        }
    }

    private void n(b bVar) {
        m(bVar);
        if (this.f11302f[0].get("JpgFromRaw") != null) {
            h(bVar, this.f11316t, 5);
        }
        c cVar = this.f11302f[0].get("ISO");
        c cVar2 = this.f11302f[1].get("PhotographicSensitivity");
        if (cVar == null || cVar2 != null) {
            return;
        }
        this.f11302f[1].put("PhotographicSensitivity", cVar);
    }

    private void o(b bVar) {
        byte[] bArr = f11289t0;
        bVar.skipBytes(bArr.length);
        byte[] bArr2 = new byte[bVar.available()];
        bVar.readFully(bArr2);
        this.f11312p = bArr.length;
        H(bArr2, 0);
    }

    private void p(b bVar) {
        if (f11292w) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.B(ByteOrder.LITTLE_ENDIAN);
        bVar.skipBytes(M.length);
        int readInt = bVar.readInt() + 8;
        int skipBytes = bVar.skipBytes(N.length) + 8;
        while (true) {
            try {
                byte[] bArr = new byte[4];
                if (bVar.read(bArr) != 4) {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
                int readInt2 = bVar.readInt();
                int i10 = skipBytes + 4 + 4;
                if (Arrays.equals(O, bArr)) {
                    byte[] bArr2 = new byte[readInt2];
                    if (bVar.read(bArr2) == readInt2) {
                        this.f11312p = i10;
                        H(bArr2, 0);
                        this.f11312p = i10;
                        return;
                    } else {
                        throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr));
                    }
                }
                if (readInt2 % 2 == 1) {
                    readInt2++;
                }
                int i11 = i10 + readInt2;
                if (i11 == readInt) {
                    return;
                }
                if (i11 > readInt) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                int skipBytes2 = bVar.skipBytes(readInt2);
                if (skipBytes2 != readInt2) {
                    throw new IOException("Encountered WebP file with invalid chunk size");
                }
                skipBytes = i10 + skipBytes2;
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    private void q(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int i10 = cVar.i(this.f11304h);
        int i11 = cVar2.i(this.f11304h);
        if (this.f11300d == 7) {
            i10 += this.f11313q;
        }
        int min = Math.min(i11, bVar.a() - i10);
        if (i10 > 0 && min > 0) {
            this.f11305i = true;
            int i12 = this.f11312p + i10;
            this.f11308l = i12;
            this.f11309m = min;
            if (this.f11297a == null && this.f11299c == null && this.f11298b == null) {
                byte[] bArr = new byte[min];
                bVar.p(i12);
                bVar.readFully(bArr);
                this.f11310n = bArr;
            }
        }
        if (f11292w) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + i10 + ", length: " + min);
        }
    }

    private void r(b bVar, HashMap hashMap) {
        String str;
        c cVar = (c) hashMap.get("StripOffsets");
        c cVar2 = (c) hashMap.get("StripByteCounts");
        if (cVar == null || cVar2 == null) {
            return;
        }
        long[] c10 = c(cVar.k(this.f11304h));
        long[] c11 = c(cVar2.k(this.f11304h));
        if (c10 == null || c10.length == 0) {
            str = "stripOffsets should not be null or have zero length.";
        } else if (c11 == null || c11.length == 0) {
            str = "stripByteCounts should not be null or have zero length.";
        } else {
            if (c10.length == c11.length) {
                long j10 = 0;
                for (long j11 : c11) {
                    j10 += j11;
                }
                int i10 = (int) j10;
                byte[] bArr = new byte[i10];
                this.f11307k = true;
                this.f11306j = true;
                this.f11305i = true;
                int i11 = 0;
                int i12 = 0;
                for (int i13 = 0; i13 < c10.length; i13++) {
                    int i14 = (int) c10[i13];
                    int i15 = (int) c11[i13];
                    if (i13 < c10.length - 1 && i14 + i15 != c10[i13 + 1]) {
                        this.f11307k = false;
                    }
                    int i16 = i14 - i11;
                    if (i16 < 0) {
                        Log.d("ExifInterface", "Invalid strip offset value");
                    }
                    bVar.p(i16);
                    int i17 = i11 + i16;
                    byte[] bArr2 = new byte[i15];
                    bVar.read(bArr2);
                    i11 = i17 + i15;
                    System.arraycopy(bArr2, 0, bArr, i12, i15);
                    i12 += i15;
                }
                this.f11310n = bArr;
                if (this.f11307k) {
                    this.f11308l = ((int) c10[0]) + this.f11312p;
                    this.f11309m = i10;
                    return;
                }
                return;
            }
            str = "stripOffsets and stripByteCounts should have same length.";
        }
        Log.w("ExifInterface", str);
    }

    private static boolean s(BufferedInputStream bufferedInputStream) {
        byte[] bArr = f11289t0;
        bufferedInputStream.mark(bArr.length);
        byte[] bArr2 = new byte[bArr.length];
        bufferedInputStream.read(bArr2);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr3 = f11289t0;
            if (i10 >= bArr3.length) {
                return true;
            }
            if (bArr2[i10] != bArr3[i10]) {
                return false;
            }
            i10++;
        }
    }

    private boolean t(byte[] bArr) {
        b bVar;
        long readInt;
        byte[] bArr2;
        b bVar2 = null;
        try {
            try {
                bVar = new b(bArr);
            } catch (Exception e10) {
                e = e10;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            readInt = bVar.readInt();
            bArr2 = new byte[4];
            bVar.read(bArr2);
        } catch (Exception e11) {
            e = e11;
            bVar2 = bVar;
            if (f11292w) {
                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, D)) {
            bVar.close();
            return false;
        }
        long j10 = 16;
        if (readInt == 1) {
            readInt = bVar.readLong();
            if (readInt < 16) {
                bVar.close();
                return false;
            }
        } else {
            j10 = 8;
        }
        if (readInt > bArr.length) {
            readInt = bArr.length;
        }
        long j11 = readInt - j10;
        if (j11 < 8) {
            bVar.close();
            return false;
        }
        byte[] bArr3 = new byte[4];
        boolean z10 = false;
        boolean z11 = false;
        for (long j12 = 0; j12 < j11 / 4; j12++) {
            if (bVar.read(bArr3) != 4) {
                bVar.close();
                return false;
            }
            if (j12 != 1) {
                if (Arrays.equals(bArr3, E)) {
                    z10 = true;
                } else if (Arrays.equals(bArr3, F)) {
                    z11 = true;
                }
                if (z10 && z11) {
                    bVar.close();
                    return true;
                }
            }
        }
        bVar.close();
        return false;
    }

    private static boolean u(byte[] bArr) {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = C;
            if (i10 >= bArr2.length) {
                return true;
            }
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
            i10++;
        }
    }

    private boolean v(byte[] bArr) {
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder G2 = G(bVar2);
                this.f11304h = G2;
                bVar2.B(G2);
                short readShort = bVar2.readShort();
                boolean z10 = readShort == 20306 || readShort == 21330;
                bVar2.close();
                return z10;
            } 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 w(byte[] bArr) {
        int i10 = 0;
        while (true) {
            byte[] bArr2 = I;
            if (i10 >= bArr2.length) {
                return true;
            }
            if (bArr[i10] != bArr2[i10]) {
                return false;
            }
            i10++;
        }
    }

    private boolean x(byte[] bArr) {
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        for (int i10 = 0; i10 < bytes.length; i10++) {
            if (bArr[i10] != bytes[i10]) {
                return false;
            }
        }
        return true;
    }

    private boolean y(byte[] bArr) {
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder G2 = G(bVar2);
                this.f11304h = G2;
                bVar2.B(G2);
                boolean z10 = bVar2.readShort() == 85;
                bVar2.close();
                return z10;
            } 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 z(FileDescriptor fileDescriptor) {
        try {
            Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_CUR);
            return true;
        } catch (Exception unused) {
            if (!f11292w) {
                return false;
            }
            Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
            return false;
        }
    }

    public String d(String str) {
        String str2;
        Objects.requireNonNull(str, "tag shouldn't be null");
        c f10 = f(str);
        if (f10 != null) {
            if (!f11286q0.contains(str)) {
                return f10.j(this.f11304h);
            }
            if (str.equals("GPSTimeStamp")) {
                int i10 = f10.f11328a;
                if (i10 == 5 || i10 == 10) {
                    e[] eVarArr = (e[]) f10.k(this.f11304h);
                    if (eVarArr != null && eVarArr.length == 3) {
                        return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVarArr[0].f11336a) / ((float) eVarArr[0].f11337b))), Integer.valueOf((int) (((float) eVarArr[1].f11336a) / ((float) eVarArr[1].f11337b))), Integer.valueOf((int) (((float) eVarArr[2].f11336a) / ((float) eVarArr[2].f11337b))));
                    }
                    str2 = "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr);
                } else {
                    str2 = "GPS Timestamp format is not rational. format=" + f10.f11328a;
                }
                Log.w("ExifInterface", str2);
                return null;
            }
            try {
                return Double.toString(f10.h(this.f11304h));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public int e(String str, int i10) {
        Objects.requireNonNull(str, "tag shouldn't be null");
        c f10 = f(str);
        if (f10 == null) {
            return i10;
        }
        try {
            return f10.i(this.f11304h);
        } catch (NumberFormatException unused) {
            return i10;
        }
    }
}