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

应用版本信息
应用名称:Candyfloss
版本号:3.9.6
包名称:com.stark.candyfloss

MD5 校验值:5b5c91fb96bf669521c42e375c79f86c

反编译源代码说明

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


package o;

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.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
import me.zhanghai.android.materialprogressbar.BuildConfig;

public class qx {
    public static SimpleDateFormat W;
    public static final d[] a0;
    public static final d[] b0;
    public static final d[] c0;
    public static final d[] d0;
    public static final d[] e0;
    public static final d f0;
    public static final d[] g0;
    public static final d[] h0;
    public static final d[] i0;
    public static final d[] j0;
    public static final d[][] k0;
    public static final d[] l0;
    public static final d m0;
    public static final d n0;
    public static final HashMap[] o0;
    public static final HashMap[] p0;
    public static final HashSet q0;
    public static final HashMap r0;
    public static final Charset s0;
    public static final byte[] t0;
    public static final byte[] u0;
    public static final Pattern v0;
    public static final Pattern w0;
    public String a;
    public FileDescriptor b;
    public AssetManager.AssetInputStream c;
    public int d;
    public boolean e;
    public final HashMap[] f;
    public Set g;
    public ByteOrder h;
    public boolean i;
    public boolean j;
    public boolean k;
    public int l;
    public int m;
    public byte[] n;

    public int f137o;
    public int p;
    public int q;
    public int r;
    public int s;
    public int t;
    public boolean u;
    public boolean v;
    public static final boolean w = Log.isLoggable("ExifInterface", 3);
    public static final List x = Arrays.asList(1, 6, 3, 8);
    public static final List y = Arrays.asList(2, 7, 4, 5);
    public static final int[] z = {8, 8, 8};
    public static final int[] A = {4};
    public static final int[] B = {8};
    public static final byte[] C = {-1, -40, -1};
    public static final byte[] D = {102, 116, 121, 112};
    public static final byte[] E = {109, 105, 102, 49};
    public static final byte[] F = {104, 101, 105, 99};
    public static final byte[] G = {79, 76, 89, 77, 80, 0};
    public static final byte[] H = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};
    public static final byte[] I = {-119, 80, 78, 71, 13, 10, 26, 10};
    public static final byte[] J = {101, 88, 73, 102};
    public static final byte[] K = {73, 72, 68, 82};
    public static final byte[] L = {73, 69, 78, 68};
    public static final byte[] M = {82, 73, 70, 70};
    public static final byte[] N = {87, 69, 66, 80};
    public static final byte[] O = {69, 88, 73, 70};
    public static final byte[] P = {-99, 1, 42};
    public static final byte[] Q = "VP8X".getBytes(Charset.defaultCharset());
    public static final byte[] R = "VP8L".getBytes(Charset.defaultCharset());
    public static final byte[] S = "VP8 ".getBytes(Charset.defaultCharset());
    public static final byte[] T = "ANIM".getBytes(Charset.defaultCharset());
    public static final byte[] U = "ANMF".getBytes(Charset.defaultCharset());
    public static final byte[] V = "XMP ".getBytes(Charset.defaultCharset());
    public static final String[] X = {BuildConfig.FLAVOR, "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
    public static final int[] Y = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
    public static final byte[] Z = {65, 83, 67, 73, 73, 0, 0, 0};

    public class a extends MediaDataSource {
        public long e;
        public final b f;

        public a(b bVar) {
            this.f = bVar;
        }

        public void citrus() {
        }

        @Override
        public void close() {
        }

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

        @Override
        public int readAt(long j, byte[] bArr, int i, int i2) {
            if (i2 == 0) {
                return 0;
            }
            if (j < 0) {
                return -1;
            }
            try {
                long j2 = this.e;
                if (j2 != j) {
                    if (j2 >= 0 && j >= j2 + this.f.available()) {
                        return -1;
                    }
                    this.f.g(j);
                    this.e = j;
                }
                if (i2 > this.f.available()) {
                    i2 = this.f.available();
                }
                int read = this.f.read(bArr, i, i2);
                if (read >= 0) {
                    this.e += read;
                    return read;
                }
            } catch (IOException unused) {
            }
            this.e = -1L;
            return -1;
        }
    }

    public static class b extends InputStream implements DataInput {
        public static final ByteOrder i = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder j = ByteOrder.BIG_ENDIAN;
        public DataInputStream e;
        public ByteOrder f;
        public final int g;
        public int h;

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

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

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

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

        public void citrus() {
        }

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

        public void g(long j2) {
            int i2 = this.h;
            if (i2 > j2) {
                this.h = 0;
                this.e.reset();
                this.e.mark(this.g);
            } else {
                j2 -= i2;
            }
            int i3 = (int) j2;
            if (skipBytes(i3) == i3) {
            } else {
                throw new IOException("Couldn't seek up to the byteCount");
            }
        }

        public void o(ByteOrder byteOrder) {
            this.f = byteOrder;
        }

        @Override
        public int read() {
            this.h++;
            return this.e.read();
        }

        @Override
        public boolean readBoolean() {
            this.h++;
            return this.e.readBoolean();
        }

        @Override
        public byte readByte() {
            int i2 = this.h + 1;
            this.h = i2;
            if (i2 <= this.g) {
                int read = this.e.read();
                if (read >= 0) {
                    return (byte) read;
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

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

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

        @Override
        public void readFully(byte[] bArr, int i2, int i3) {
            int i4 = this.h + i3;
            this.h = i4;
            if (i4 <= this.g) {
                if (this.e.read(bArr, i2, i3) != i3) {
                    throw new IOException("Couldn't read up to the length of buffer");
                }
                return;
            }
            throw new EOFException();
        }

        @Override
        public int readInt() {
            int i2 = this.h + 4;
            this.h = i2;
            if (i2 <= this.g) {
                int read = this.e.read();
                int read2 = this.e.read();
                int read3 = this.e.read();
                int read4 = this.e.read();
                if ((read | read2 | read3 | read4) >= 0) {
                    ByteOrder byteOrder = this.f;
                    if (byteOrder == i) {
                        return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == j) {
                        return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
                    }
                    throw new IOException("Invalid byte order: " + this.f);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

        @Override
        public long readLong() {
            int i2 = this.h + 8;
            this.h = i2;
            if (i2 <= this.g) {
                int read = this.e.read();
                int read2 = this.e.read();
                int read3 = this.e.read();
                int read4 = this.e.read();
                int read5 = this.e.read();
                int read6 = this.e.read();
                int read7 = this.e.read();
                int read8 = this.e.read();
                if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) >= 0) {
                    ByteOrder byteOrder = this.f;
                    if (byteOrder == i) {
                        return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
                    }
                    if (byteOrder == j) {
                        return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
                    }
                    throw new IOException("Invalid byte order: " + this.f);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public short readShort() {
            int i2 = this.h + 2;
            this.h = i2;
            if (i2 <= this.g) {
                int read = this.e.read();
                int read2 = this.e.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f;
                    if (byteOrder == i) {
                        return (short) ((read2 << 8) + read);
                    }
                    if (byteOrder == j) {
                        return (short) ((read << 8) + read2);
                    }
                    throw new IOException("Invalid byte order: " + this.f);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

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

        @Override
        public int readUnsignedByte() {
            this.h++;
            return this.e.readUnsignedByte();
        }

        @Override
        public int readUnsignedShort() {
            int i2 = this.h + 2;
            this.h = i2;
            if (i2 <= this.g) {
                int read = this.e.read();
                int read2 = this.e.read();
                if ((read | read2) >= 0) {
                    ByteOrder byteOrder = this.f;
                    if (byteOrder == i) {
                        return (read2 << 8) + read;
                    }
                    if (byteOrder == j) {
                        return (read << 8) + read2;
                    }
                    throw new IOException("Invalid byte order: " + this.f);
                }
                throw new EOFException();
            }
            throw new EOFException();
        }

        @Override
        public int skipBytes(int i2) {
            int min = Math.min(i2, this.g - this.h);
            int i3 = 0;
            while (i3 < min) {
                i3 += this.e.skipBytes(min - i3);
            }
            this.h += i3;
            return i3;
        }

        public b(InputStream inputStream, ByteOrder byteOrder) {
            this.f = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.e = dataInputStream;
            int available = dataInputStream.available();
            this.g = available;
            this.h = 0;
            this.e.mark(available);
            this.f = byteOrder;
        }

        @Override
        public int read(byte[] bArr, int i2, int i3) {
            int read = this.e.read(bArr, i2, i3);
            this.h += read;
            return read;
        }

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

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

    public static class c {
        public final int a;
        public final int b;
        public final long c;
        public final byte[] d;

        public c(int i, int i2, byte[] bArr) {
            this(i, i2, -1L, bArr);
        }

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

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

        public static c c(long[] jArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[qx.Y[4] * jArr.length]);
            wrap.order(byteOrder);
            for (long j : jArr) {
                wrap.putInt((int) j);
            }
            return new c(4, jArr.length, wrap.array());
        }

        public static c d(e eVar, ByteOrder byteOrder) {
            return e(new e[]{eVar}, byteOrder);
        }

        public static c e(e[] eVarArr, ByteOrder byteOrder) {
            ByteBuffer wrap = ByteBuffer.wrap(new byte[qx.Y[5] * eVarArr.length]);
            wrap.order(byteOrder);
            for (e eVar : eVarArr) {
                wrap.putInt((int) eVar.a);
                wrap.putInt((int) eVar.b);
            }
            return new c(5, eVarArr.length, wrap.array());
        }

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

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

        public void citrus() {
        }

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

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

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

        public Object k(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b;
            byte b2;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(this.d);
                    try {
                        bVar.o(byteOrder);
                        int i = 0;
                        switch (this.a) {
                            case 1:
                            case 6:
                                byte[] bArr = this.d;
                                if (bArr.length == 1 && (b = bArr[0]) >= 0 && b <= 1) {
                                    String str = new String(new char[]{(char) (b + 48)});
                                    try {
                                        bVar.close();
                                    } catch (IOException e) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e);
                                    }
                                    return str;
                                }
                                String str2 = new String(bArr, qx.s0);
                                try {
                                    bVar.close();
                                } catch (IOException e2) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e2);
                                }
                                return str2;
                            case 2:
                            case 7:
                                if (this.b >= qx.Z.length) {
                                    int i2 = 0;
                                    while (true) {
                                        byte[] bArr2 = qx.Z;
                                        if (i2 < bArr2.length) {
                                            if (this.d[i2] == bArr2[i2]) {
                                                i2++;
                                            }
                                        } else {
                                            i = bArr2.length;
                                        }
                                    }
                                }
                                StringBuilder sb = new StringBuilder();
                                while (i < this.b && (b2 = this.d[i]) != 0) {
                                    if (b2 >= 32) {
                                        sb.append((char) b2);
                                    } else {
                                        sb.append('?');
                                    }
                                    i++;
                                }
                                String sb2 = sb.toString();
                                try {
                                    bVar.close();
                                } catch (IOException e3) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e3);
                                }
                                return sb2;
                            case 3:
                                int[] iArr = new int[this.b];
                                while (i < this.b) {
                                    iArr[i] = bVar.readUnsignedShort();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e4) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e4);
                                }
                                return iArr;
                            case 4:
                                long[] jArr = new long[this.b];
                                while (i < this.b) {
                                    jArr[i] = bVar.d();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e5) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e5);
                                }
                                return jArr;
                            case 5:
                                e[] eVarArr = new e[this.b];
                                while (i < this.b) {
                                    eVarArr[i] = new e(bVar.d(), bVar.d());
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e6) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e6);
                                }
                                return eVarArr;
                            case lk.a:
                                int[] iArr2 = new int[this.b];
                                while (i < this.b) {
                                    iArr2[i] = bVar.readShort();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e7) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e7);
                                }
                                return iArr2;
                            case 9:
                                int[] iArr3 = new int[this.b];
                                while (i < this.b) {
                                    iArr3[i] = bVar.readInt();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e8) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e8);
                                }
                                return iArr3;
                            case 10:
                                e[] eVarArr2 = new e[this.b];
                                while (i < this.b) {
                                    eVarArr2[i] = new e(bVar.readInt(), bVar.readInt());
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e9) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e9);
                                }
                                return eVarArr2;
                            case 11:
                                double[] dArr = new double[this.b];
                                while (i < this.b) {
                                    dArr[i] = bVar.readFloat();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e10) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                }
                                return dArr;
                            case 12:
                                double[] dArr2 = new double[this.b];
                                while (i < this.b) {
                                    dArr2[i] = bVar.readDouble();
                                    i++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return dArr2;
                            default:
                                try {
                                    bVar.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return null;
                        }
                    } catch (IOException e13) {
                        e = e13;
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (bVar != null) {
                            try {
                                bVar.close();
                            } catch (IOException e14) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th) {
                    th = th;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e15) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                        }
                    }
                    throw th;
                }
            } catch (IOException e16) {
                e = e16;
                bVar = null;
            } catch (Throwable th2) {
                th = th2;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

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

        public c(int i, int i2, long j, byte[] bArr) {
            this.a = i;
            this.b = i2;
            this.c = j;
            this.d = bArr;
        }
    }

    public static class d {
        public final int a;
        public final String b;
        public final int c;
        public final int d;

        public d(String str, int i, int i2) {
            this.b = str;
            this.a = i;
            this.c = i2;
            this.d = -1;
        }

        public boolean a(int i) {
            int i2;
            int i3 = this.c;
            if (i3 == 7 || i == 7 || i3 == i || (i2 = this.d) == i) {
                return true;
            }
            if ((i3 == 4 || i2 == 4) && i == 3) {
                return true;
            }
            if ((i3 == 9 || i2 == 9) && i == 8) {
                return true;
            }
            return (i3 == 12 || i2 == 12) && i == 11;
        }

        public void citrus() {
        }

        public d(String str, int i, int i2, int i3) {
            this.b = str;
            this.a = i;
            this.c = i2;
            this.d = i3;
        }
    }

    public static class e {
        public final long a;
        public final long b;

        public e(long j, long j2) {
            if (j2 == 0) {
                this.a = 0L;
                this.b = 1L;
            } else {
                this.a = j;
                this.b = j2;
            }
        }

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

        public void citrus() {
        }

        public String toString() {
            return this.a + "/" + this.b;
        }
    }

    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)};
        a0 = 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)};
        b0 = 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)};
        c0 = dVarArr3;
        d[] dVarArr4 = {new d("InteroperabilityIndex", 1, 2)};
        d0 = 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)};
        e0 = dVarArr5;
        f0 = new d("StripOffsets", 273, 3);
        d[] dVarArr6 = {new d("ThumbnailImage", 256, 7), new d("CameraSettingsIFDPointer", 8224, 4), new d("ImageProcessingIFDPointer", 8256, 4)};
        g0 = dVarArr6;
        d[] dVarArr7 = {new d("PreviewImageStart", 257, 4), new d("PreviewImageLength", 258, 4)};
        h0 = dVarArr7;
        d[] dVarArr8 = {new d("AspectFrame", 4371, 3)};
        i0 = dVarArr8;
        d[] dVarArr9 = {new d("ColorSpace", 55, 3)};
        j0 = dVarArr9;
        d[][] dVarArr10 = {dVarArr, dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr, dVarArr6, dVarArr7, dVarArr8, dVarArr9};
        k0 = dVarArr10;
        l0 = 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)};
        m0 = new d("JPEGInterchangeFormat", 513, 4);
        n0 = new d("JPEGInterchangeFormatLength", 514, 4);
        o0 = new HashMap[dVarArr10.length];
        p0 = new HashMap[dVarArr10.length];
        q0 = new HashSet(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        r0 = new HashMap();
        Charset forName = Charset.forName("US-ASCII");
        s0 = forName;
        t0 = "Exif\u0000\u0000".getBytes(forName);
        u0 = "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 i = 0;
        while (true) {
            d[][] dVarArr11 = k0;
            if (i >= dVarArr11.length) {
                HashMap hashMap = r0;
                d[] dVarArr12 = l0;
                hashMap.put(Integer.valueOf(dVarArr12[0].a), 5);
                hashMap.put(Integer.valueOf(dVarArr12[1].a), 1);
                hashMap.put(Integer.valueOf(dVarArr12[2].a), 2);
                hashMap.put(Integer.valueOf(dVarArr12[3].a), 3);
                hashMap.put(Integer.valueOf(dVarArr12[4].a), 7);
                hashMap.put(Integer.valueOf(dVarArr12[5].a), 8);
                v0 = Pattern.compile(".*[1-9].*");
                w0 = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$");
                return;
            }
            o0[i] = new HashMap();
            p0[i] = new HashMap();
            for (d dVar : dVarArr11[i]) {
                o0[i].put(Integer.valueOf(dVar.a), dVar);
                p0[i].put(dVar.b, dVar);
            }
            i++;
        }
    }

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

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

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

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

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

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

    public static boolean z(FileDescriptor fileDescriptor) {
        try {
            Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_CUR);
            return true;
        } catch (Exception unused) {
            if (w) {
                Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
            }
            return false;
        }
    }

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

    public final boolean B(HashMap hashMap) {
        c cVar = (c) hashMap.get("ImageLength");
        c cVar2 = (c) hashMap.get("ImageWidth");
        if (cVar != null && cVar2 != null) {
            int i = cVar.i(this.h);
            int i2 = cVar2.i(this.h);
            if (i <= 512 && i2 <= 512) {
                return true;
            }
        }
        return false;
    }

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

    public final void D(InputStream inputStream) {
        if (inputStream != null) {
            for (int i = 0; i < k0.length; i++) {
                try {
                    try {
                        this.f[i] = new HashMap();
                    } catch (IOException e2) {
                        this.u = false;
                        boolean z2 = w;
                        if (z2) {
                            Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e2);
                        }
                        a();
                        if (!z2) {
                            return;
                        }
                    }
                } catch (Throwable th) {
                    a();
                    if (w) {
                        F();
                    }
                    throw th;
                }
            }
            if (!this.e) {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000);
                this.d = i(bufferedInputStream);
                inputStream = bufferedInputStream;
            }
            b bVar = new b(inputStream);
            if (!this.e) {
                switch (this.d) {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 5:
                    case 6:
                    case lk.a:
                    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.u = true;
            a();
            if (!w) {
                return;
            }
            F();
            return;
        }
        throw new NullPointerException("inputstream shouldn't be null");
    }

    public final void E(b bVar, int i) {
        ByteOrder G2 = G(bVar);
        this.h = G2;
        bVar.o(G2);
        int readUnsignedShort = bVar.readUnsignedShort();
        int i2 = this.d;
        if (i2 != 7 && i2 != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = bVar.readInt();
        if (readInt >= 8 && readInt < i) {
            int i3 = readInt - 8;
            if (i3 > 0 && bVar.skipBytes(i3) != i3) {
                throw new IOException("Couldn't jump to first Ifd: " + i3);
            }
            return;
        }
        throw new IOException("Invalid first Ifd offset: " + readInt);
    }

    public final void F() {
        for (int i = 0; i < this.f.length; i++) {
            Log.d("ExifInterface", "The size of tag group[" + i + "]: " + this.f[i].size());
            for (Map.Entry entry : this.f[i].entrySet()) {
                c cVar = (c) entry.getValue();
                Log.d("ExifInterface", "tagName: " + ((String) entry.getKey()) + ", tagType: " + cVar.toString() + ", tagValue: '" + cVar.j(this.h) + "'");
            }
        }
    }

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

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

    public final void I(b bVar, int i) {
        String str;
        short s;
        long j;
        boolean z2;
        short s2;
        d dVar;
        long j2;
        int i2;
        int i3;
        int i4;
        long j3;
        int readUnsignedShort;
        long j4;
        int i5 = i;
        this.g.add(Integer.valueOf(bVar.h));
        if (bVar.h + 2 > bVar.g) {
            return;
        }
        short readShort = bVar.readShort();
        String str2 = "ExifInterface";
        if (w) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (bVar.h + (readShort * 12) <= bVar.g && readShort > 0) {
            char c2 = 0;
            short s3 = 0;
            while (s3 < readShort) {
                int readUnsignedShort2 = bVar.readUnsignedShort();
                int readUnsignedShort3 = bVar.readUnsignedShort();
                int readInt = bVar.readInt();
                long c3 = bVar.c() + 4;
                d dVar2 = (d) o0[i5].get(Integer.valueOf(readUnsignedShort2));
                boolean z3 = w;
                if (z3) {
                    Object[] objArr = new Object[5];
                    objArr[c2] = Integer.valueOf(i);
                    objArr[1] = Integer.valueOf(readUnsignedShort2);
                    objArr[2] = dVar2 != null ? dVar2.b : null;
                    objArr[3] = Integer.valueOf(readUnsignedShort3);
                    objArr[4] = Integer.valueOf(readInt);
                    Log.d(str2, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
                }
                if (dVar2 == null) {
                    if (z3) {
                        Log.d(str2, "Skip the tag entry since tag number is not defined: " + readUnsignedShort2);
                    }
                } else {
                    if (readUnsignedShort3 > 0) {
                        if (readUnsignedShort3 < Y.length) {
                            if (!dVar2.a(readUnsignedShort3)) {
                                if (z3) {
                                    Log.d(str2, "Skip the tag entry since data format (" + X[readUnsignedShort3] + ") is unexpected for tag: " + dVar2.b);
                                }
                            } else {
                                if (readUnsignedShort3 == 7) {
                                    readUnsignedShort3 = dVar2.c;
                                }
                                str = str2;
                                s = s3;
                                j = readInt * r8[readUnsignedShort3];
                                if (j < 0 || j > 2147483647L) {
                                    if (z3) {
                                        Log.d(str, "Skip the tag entry since the number of components is invalid: " + readInt);
                                    }
                                    z2 = false;
                                    if (z2) {
                                        bVar.g(c3);
                                        s2 = readShort;
                                    } else {
                                        if (j > 4) {
                                            int readInt2 = bVar.readInt();
                                            s2 = readShort;
                                            if (z3) {
                                                StringBuilder sb = new StringBuilder();
                                                i3 = readUnsignedShort3;
                                                sb.append("seek to data offset: ");
                                                sb.append(readInt2);
                                                Log.d(str, sb.toString());
                                            } else {
                                                i3 = readUnsignedShort3;
                                            }
                                            int i6 = this.d;
                                            if (i6 == 7) {
                                                if ("MakerNote".equals(dVar2.b)) {
                                                    this.q = readInt2;
                                                } else if (i5 == 6 && "ThumbnailImage".equals(dVar2.b)) {
                                                    this.r = readInt2;
                                                    this.s = readInt;
                                                    c f = c.f(6, this.h);
                                                    i4 = readInt;
                                                    c b2 = c.b(this.r, this.h);
                                                    i2 = readUnsignedShort2;
                                                    c b3 = c.b(this.s, this.h);
                                                    this.f[4].put("Compression", f);
                                                    this.f[4].put("JPEGInterchangeFormat", b2);
                                                    this.f[4].put("JPEGInterchangeFormatLength", b3);
                                                }
                                                i2 = readUnsignedShort2;
                                                i4 = readInt;
                                            } else {
                                                i2 = readUnsignedShort2;
                                                i4 = readInt;
                                                if (i6 == 10 && "JpgFromRaw".equals(dVar2.b)) {
                                                    this.t = readInt2;
                                                }
                                            }
                                            long j5 = readInt2;
                                            dVar = dVar2;
                                            j2 = j;
                                            if (j5 + j <= bVar.g) {
                                                bVar.g(j5);
                                            } else {
                                                if (z3) {
                                                    Log.d(str, "Skip the tag entry since data offset is invalid: " + readInt2);
                                                }
                                                bVar.g(c3);
                                            }
                                        } else {
                                            s2 = readShort;
                                            dVar = dVar2;
                                            j2 = j;
                                            i2 = readUnsignedShort2;
                                            i3 = readUnsignedShort3;
                                            i4 = readInt;
                                        }
                                        Integer num = (Integer) r0.get(Integer.valueOf(i2));
                                        if (z3) {
                                            StringBuilder sb2 = new StringBuilder();
                                            sb2.append("nextIfdType: ");
                                            sb2.append(num);
                                            sb2.append(" byteCount: ");
                                            j3 = j2;
                                            sb2.append(j3);
                                            Log.d(str, sb2.toString());
                                        } else {
                                            j3 = j2;
                                        }
                                        if (num != null) {
                                            int i7 = i3;
                                            if (i7 != 3) {
                                                if (i7 != 4) {
                                                    if (i7 != 8) {
                                                        if (i7 != 9 && i7 != 13) {
                                                            j4 = -1;
                                                        } else {
                                                            readUnsignedShort = bVar.readInt();
                                                        }
                                                    } else {
                                                        readUnsignedShort = bVar.readShort();
                                                    }
                                                } else {
                                                    j4 = bVar.d();
                                                }
                                                if (z3) {
                                                    Log.d(str, String.format("Offset: %d, tagName: %s", Long.valueOf(j4), dVar.b));
                                                }
                                                if (j4 <= 0 && j4 < bVar.g) {
                                                    if (!this.g.contains(Integer.valueOf((int) j4))) {
                                                        bVar.g(j4);
                                                        I(bVar, num.intValue());
                                                    } else if (z3) {
                                                        Log.d(str, "Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j4 + ")");
                                                    }
                                                } else if (z3) {
                                                    Log.d(str, "Skip jump into the IFD since its offset is invalid: " + j4);
                                                }
                                                bVar.g(c3);
                                            } else {
                                                readUnsignedShort = bVar.readUnsignedShort();
                                            }
                                            j4 = readUnsignedShort;
                                            if (z3) {
                                            }
                                            if (j4 <= 0) {
                                            }
                                            if (z3) {
                                            }
                                            bVar.g(c3);
                                        } else {
                                            d dVar3 = dVar;
                                            int c4 = bVar.c() + this.p;
                                            byte[] bArr = new byte[(int) j3];
                                            bVar.readFully(bArr);
                                            c cVar = new c(i3, i4, c4, bArr);
                                            this.f[i].put(dVar3.b, cVar);
                                            if ("DNGVersion".equals(dVar3.b)) {
                                                this.d = 3;
                                            }
                                            if ((("Make".equals(dVar3.b) || "Model".equals(dVar3.b)) && cVar.j(this.h).contains("PENTAX")) || ("Compression".equals(dVar3.b) && cVar.i(this.h) == 65535)) {
                                                this.d = 8;
                                            }
                                            if (bVar.c() != c3) {
                                                bVar.g(c3);
                                            }
                                        }
                                        s3 = (short) (s + 1);
                                        i5 = i;
                                        str2 = str;
                                        readShort = s2;
                                        c2 = 0;
                                    }
                                    s3 = (short) (s + 1);
                                    i5 = i;
                                    str2 = str;
                                    readShort = s2;
                                    c2 = 0;
                                } else {
                                    z2 = true;
                                    if (z2) {
                                    }
                                    s3 = (short) (s + 1);
                                    i5 = i;
                                    str2 = str;
                                    readShort = s2;
                                    c2 = 0;
                                }
                            }
                        }
                    }
                    str = str2;
                    s = s3;
                    if (z3) {
                        Log.d(str, "Skip the tag entry since data format is invalid: " + readUnsignedShort3);
                    }
                    j = 0;
                    z2 = false;
                    if (z2) {
                    }
                    s3 = (short) (s + 1);
                    i5 = i;
                    str2 = str;
                    readShort = s2;
                    c2 = 0;
                }
                str = str2;
                s = s3;
                j = 0;
                z2 = false;
                if (z2) {
                }
                s3 = (short) (s + 1);
                i5 = i;
                str2 = str;
                readShort = s2;
                c2 = 0;
            }
            String str3 = str2;
            if (bVar.c() + 4 <= bVar.g) {
                int readInt3 = bVar.readInt();
                boolean z4 = w;
                if (z4) {
                    Log.d(str3, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
                }
                long j6 = readInt3;
                if (j6 > 0 && readInt3 < bVar.g) {
                    if (!this.g.contains(Integer.valueOf(readInt3))) {
                        bVar.g(j6);
                        if (this.f[4].isEmpty()) {
                            I(bVar, 4);
                            return;
                        } else {
                            if (this.f[5].isEmpty()) {
                                I(bVar, 5);
                                return;
                            }
                            return;
                        }
                    }
                    if (z4) {
                        Log.d(str3, "Stop reading file since re-reading an IFD may cause an infinite loop: " + readInt3);
                        return;
                    }
                    return;
                }
                if (z4) {
                    Log.d(str3, "Stop reading file since a wrong offset may cause an infinite loop: " + readInt3);
                }
            }
        }
    }

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

    public final void K(b bVar) {
        HashMap hashMap = this.f[4];
        c cVar = (c) hashMap.get("Compression");
        if (cVar != null) {
            int i = cVar.i(this.h);
            this.f137o = i;
            if (i != 1) {
                if (i != 6) {
                    if (i != 7) {
                        return;
                    }
                } else {
                    q(bVar, hashMap);
                    return;
                }
            }
            if (A(hashMap)) {
                r(bVar, hashMap);
                return;
            }
            return;
        }
        this.f137o = 6;
        q(bVar, hashMap);
    }

    public final void M(int i, int i2) {
        if (!this.f[i].isEmpty() && !this.f[i2].isEmpty()) {
            c cVar = (c) this.f[i].get("ImageLength");
            c cVar2 = (c) this.f[i].get("ImageWidth");
            c cVar3 = (c) this.f[i2].get("ImageLength");
            c cVar4 = (c) this.f[i2].get("ImageWidth");
            if (cVar != null && cVar2 != null) {
                if (cVar3 != null && cVar4 != null) {
                    int i3 = cVar.i(this.h);
                    int i4 = cVar2.i(this.h);
                    int i5 = cVar3.i(this.h);
                    int i6 = cVar4.i(this.h);
                    if (i3 < i5 && i4 < i6) {
                        HashMap[] hashMapArr = this.f;
                        HashMap hashMap = hashMapArr[i];
                        hashMapArr[i] = hashMapArr[i2];
                        hashMapArr[i2] = hashMap;
                        return;
                    }
                    return;
                }
                if (w) {
                    Log.d("ExifInterface", "Second image does not contain valid size information");
                    return;
                }
                return;
            }
            if (w) {
                Log.d("ExifInterface", "First image does not contain valid size information");
                return;
            }
            return;
        }
        if (w) {
            Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
        }
    }

    public final void N(b bVar, int i) {
        c f;
        c f2;
        c cVar = (c) this.f[i].get("DefaultCropSize");
        c cVar2 = (c) this.f[i].get("SensorTopBorder");
        c cVar3 = (c) this.f[i].get("SensorLeftBorder");
        c cVar4 = (c) this.f[i].get("SensorBottomBorder");
        c cVar5 = (c) this.f[i].get("SensorRightBorder");
        if (cVar != null) {
            if (cVar.a == 5) {
                e[] eVarArr = (e[]) cVar.k(this.h);
                if (eVarArr != null && eVarArr.length == 2) {
                    f = c.d(eVarArr[0], this.h);
                    f2 = c.d(eVarArr[1], this.h);
                } else {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(eVarArr));
                    return;
                }
            } else {
                int[] iArr = (int[]) cVar.k(this.h);
                if (iArr != null && iArr.length == 2) {
                    f = c.f(iArr[0], this.h);
                    f2 = c.f(iArr[1], this.h);
                } else {
                    Log.w("ExifInterface", "Invalid crop size values. cropSize=" + Arrays.toString(iArr));
                    return;
                }
            }
            this.f[i].put("ImageWidth", f);
            this.f[i].put("ImageLength", f2);
            return;
        }
        if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) {
            int i2 = cVar2.i(this.h);
            int i3 = cVar4.i(this.h);
            int i4 = cVar5.i(this.h);
            int i5 = cVar3.i(this.h);
            if (i3 > i2 && i4 > i5) {
                c f3 = c.f(i3 - i2, this.h);
                c f4 = c.f(i4 - i5, this.h);
                this.f[i].put("ImageLength", f3);
                this.f[i].put("ImageWidth", f4);
                return;
            }
            return;
        }
        J(bVar, i);
    }

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

    public final void a() {
        String d2 = d("DateTimeOriginal");
        if (d2 != null && d("DateTime") == null) {
            this.f[0].put("DateTime", c.a(d2));
        }
        if (d("ImageWidth") == null) {
            this.f[0].put("ImageWidth", c.b(0L, this.h));
        }
        if (d("ImageLength") == null) {
            this.f[0].put("ImageLength", c.b(0L, this.h));
        }
        if (d("Orientation") == null) {
            this.f[0].put("Orientation", c.b(0L, this.h));
        }
        if (d("LightSource") == null) {
            this.f[1].put("LightSource", c.b(0L, this.h));
        }
    }

    public void citrus() {
    }

    public String d(String str) {
        if (str != null) {
            c f = f(str);
            if (f != null) {
                if (!q0.contains(str)) {
                    return f.j(this.h);
                }
                if (str.equals("GPSTimeStamp")) {
                    int i = f.a;
                    if (i != 5 && i != 10) {
                        Log.w("ExifInterface", "GPS Timestamp format is not rational. format=" + f.a);
                        return null;
                    }
                    e[] eVarArr = (e[]) f.k(this.h);
                    if (eVarArr != null && eVarArr.length == 3) {
                        e eVar = eVarArr[0];
                        e eVar2 = eVarArr[1];
                        e eVar3 = eVarArr[2];
                        return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) eVar.a) / ((float) eVar.b))), Integer.valueOf((int) (((float) eVar2.a) / ((float) eVar2.b))), Integer.valueOf((int) (((float) eVar3.a) / ((float) eVar3.b))));
                    }
                    Log.w("ExifInterface", "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr));
                    return null;
                }
                try {
                    return Double.toString(f.h(this.h));
                } catch (NumberFormatException unused) {
                }
            }
            return null;
        }
        throw new NullPointerException("tag shouldn't be null");
    }

    public int e(String str, int i) {
        if (str != null) {
            c f = f(str);
            if (f == null) {
                return i;
            }
            try {
                return f.i(this.h);
            } catch (NumberFormatException unused) {
                return i;
            }
        }
        throw new NullPointerException("tag shouldn't be null");
    }

    public final c f(String str) {
        if (str != null) {
            if ("ISOSpeedRatings".equals(str)) {
                if (w) {
                    Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
                }
                str = "PhotographicSensitivity";
            }
            for (int i = 0; i < k0.length; i++) {
                c cVar = (c) this.f[i].get(str);
                if (cVar != null) {
                    return cVar;
                }
            }
            return null;
        }
        throw new NullPointerException("tag shouldn't be null");
    }

    public final void g(b bVar) {
        String str;
        String str2;
        String str3;
        int i;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            if (Build.VERSION.SDK_INT >= 23) {
                mediaMetadataRetriever.setDataSource(new a(bVar));
            } else {
                FileDescriptor fileDescriptor = this.b;
                if (fileDescriptor != null) {
                    mediaMetadataRetriever.setDataSource(fileDescriptor);
                } else {
                    String str4 = this.a;
                    if (str4 != null) {
                        mediaMetadataRetriever.setDataSource(str4);
                    } else {
                        mediaMetadataRetriever.release();
                        return;
                    }
                }
            }
            String extractMetadata = mediaMetadataRetriever.extractMetadata(33);
            String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34);
            String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26);
            String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17);
            if ("yes".equals(extractMetadata3)) {
                str = mediaMetadataRetriever.extractMetadata(29);
                str2 = mediaMetadataRetriever.extractMetadata(30);
                str3 = mediaMetadataRetriever.extractMetadata(31);
            } else if ("yes".equals(extractMetadata4)) {
                str = mediaMetadataRetriever.extractMetadata(18);
                str2 = mediaMetadataRetriever.extractMetadata(19);
                str3 = mediaMetadataRetriever.extractMetadata(24);
            } else {
                str = null;
                str2 = null;
                str3 = null;
            }
            if (str != null) {
                this.f[0].put("ImageWidth", c.f(Integer.parseInt(str), this.h));
            }
            if (str2 != null) {
                this.f[0].put("ImageLength", c.f(Integer.parseInt(str2), this.h));
            }
            if (str3 != null) {
                int parseInt = Integer.parseInt(str3);
                if (parseInt == 90) {
                    i = 6;
                } else if (parseInt != 180) {
                    i = parseInt != 270 ? 1 : 8;
                } else {
                    i = 3;
                }
                this.f[0].put("Orientation", c.f(i, this.h));
            }
            if (extractMetadata != null && extractMetadata2 != null) {
                int parseInt2 = Integer.parseInt(extractMetadata);
                int parseInt3 = Integer.parseInt(extractMetadata2);
                if (parseInt3 > 6) {
                    bVar.g(parseInt2);
                    byte[] bArr = new byte[6];
                    if (bVar.read(bArr) == 6) {
                        int i2 = parseInt2 + 6;
                        int i3 = parseInt3 - 6;
                        if (Arrays.equals(bArr, t0)) {
                            byte[] bArr2 = new byte[i3];
                            if (bVar.read(bArr2) == i3) {
                                this.p = i2;
                                H(bArr2, 0);
                            } else {
                                throw new IOException("Can't read exif");
                            }
                        } else {
                            throw new IOException("Invalid identifier");
                        }
                    } else {
                        throw new IOException("Can't read identifier");
                    }
                } else {
                    throw new IOException("Invalid exif length");
                }
            }
            if (w) {
                Log.d("ExifInterface", "Heif meta: " + str + "x" + str2 + ", rotation " + str3);
            }
            mediaMetadataRetriever.release();
        } catch (Throwable th) {
            mediaMetadataRetriever.release();
            throw th;
        }
    }

    public final void h(b bVar, int i, int i2) {
        int i3;
        if (w) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.o(ByteOrder.BIG_ENDIAN);
        bVar.g(i);
        byte readByte = bVar.readByte();
        byte b2 = -1;
        if (readByte == -1) {
            if (bVar.readByte() == -40) {
                int i4 = i + 2;
                while (true) {
                    byte readByte2 = bVar.readByte();
                    if (readByte2 == b2) {
                        byte readByte3 = bVar.readByte();
                        boolean z2 = w;
                        if (z2) {
                            Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                        }
                        if (readByte3 != -39 && readByte3 != -38) {
                            int readUnsignedShort = bVar.readUnsignedShort();
                            int i5 = readUnsignedShort - 2;
                            int i6 = i4 + 4;
                            if (z2) {
                                Log.d("ExifInterface", "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + readUnsignedShort + ")");
                            }
                            if (i5 >= 0) {
                                if (readByte3 != -31) {
                                    if (readByte3 != -2) {
                                        switch (readByte3) {
                                            default:
                                                switch (readByte3) {
                                                    default:
                                                        switch (readByte3) {
                                                            default:
                                                                switch (readByte3) {
                                                                }
                                                            case -55:
                                                            case -54:
                                                            case -53:
                                                                if (bVar.skipBytes(1) == 1) {
                                                                    this.f[i2].put("ImageLength", c.b(bVar.readUnsignedShort(), this.h));
                                                                    this.f[i2].put("ImageWidth", c.b(bVar.readUnsignedShort(), this.h));
                                                                    i5 = readUnsignedShort - 7;
                                                                    break;
                                                                } else {
                                                                    throw new IOException("Invalid SOFx");
                                                                }
                                                        }
                                                    case -59:
                                                    case -58:
                                                    case -57:
                                                        break;
                                                }
                                            case -64:
                                            case -63:
                                            case -62:
                                            case -61:
                                                break;
                                        }
                                        if (i5 < 0) {
                                            if (bVar.skipBytes(i5) == i5) {
                                                i4 = i6 + i5;
                                                b2 = -1;
                                            } else {
                                                throw new IOException("Invalid JPEG segment");
                                            }
                                        } else {
                                            throw new IOException("Invalid length");
                                        }
                                    } else {
                                        byte[] bArr = new byte[i5];
                                        if (bVar.read(bArr) == i5) {
                                            if (d("UserComment") == null) {
                                                this.f[1].put("UserComment", c.a(new String(bArr, s0)));
                                            }
                                        } else {
                                            throw new IOException("Invalid exif");
                                        }
                                    }
                                } else {
                                    byte[] bArr2 = new byte[i5];
                                    bVar.readFully(bArr2);
                                    int i7 = i6 + i5;
                                    byte[] bArr3 = t0;
                                    if (L(bArr2, bArr3)) {
                                        int length = i6 + bArr3.length;
                                        byte[] copyOfRange = Arrays.copyOfRange(bArr2, bArr3.length, i5);
                                        this.p = length;
                                        H(copyOfRange, i2);
                                    } else {
                                        byte[] bArr4 = u0;
                                        if (L(bArr2, bArr4)) {
                                            int length2 = i6 + bArr4.length;
                                            byte[] copyOfRange2 = Arrays.copyOfRange(bArr2, bArr4.length, i5);
                                            if (d("Xmp") == null) {
                                                i3 = i7;
                                                this.f[0].put("Xmp", new c(1, copyOfRange2.length, length2, copyOfRange2));
                                                this.v = true;
                                                i6 = i3;
                                            }
                                        }
                                    }
                                    i3 = i7;
                                    i6 = i3;
                                }
                                i5 = 0;
                                if (i5 < 0) {
                                }
                            } else {
                                throw new IOException("Invalid length");
                            }
                        }
                    } else {
                        throw new IOException("Invalid marker:" + Integer.toHexString(readByte2 & 255));
                    }
                }
            } else {
                throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
            }
        } else {
            throw new IOException("Invalid marker: " + Integer.toHexString(readByte & 255));
        }
    }

    public final 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;
    }

    public final void j(b bVar) {
        int i;
        int i2;
        m(bVar);
        c cVar = (c) this.f[1].get("MakerNote");
        if (cVar != null) {
            b bVar2 = new b(cVar.d);
            bVar2.o(this.h);
            byte[] bArr = G;
            byte[] bArr2 = new byte[bArr.length];
            bVar2.readFully(bArr2);
            bVar2.g(0L);
            byte[] bArr3 = H;
            byte[] bArr4 = new byte[bArr3.length];
            bVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                bVar2.g(8L);
            } else if (Arrays.equals(bArr4, bArr3)) {
                bVar2.g(12L);
            }
            I(bVar2, 6);
            c cVar2 = (c) this.f[7].get("PreviewImageStart");
            c cVar3 = (c) this.f[7].get("PreviewImageLength");
            if (cVar2 != null && cVar3 != null) {
                this.f[5].put("JPEGInterchangeFormat", cVar2);
                this.f[5].put("JPEGInterchangeFormatLength", cVar3);
            }
            c cVar4 = (c) this.f[8].get("AspectFrame");
            if (cVar4 != null) {
                int[] iArr = (int[]) cVar4.k(this.h);
                if (iArr != null && iArr.length == 4) {
                    int i3 = iArr[2];
                    int i4 = iArr[0];
                    if (i3 > i4 && (i = iArr[3]) > (i2 = iArr[1])) {
                        int i5 = (i3 - i4) + 1;
                        int i6 = (i - i2) + 1;
                        if (i5 < i6) {
                            int i7 = i5 + i6;
                            i6 = i7 - i6;
                            i5 = i7 - i6;
                        }
                        c f = c.f(i5, this.h);
                        c f2 = c.f(i6, this.h);
                        this.f[0].put("ImageWidth", f);
                        this.f[0].put("ImageLength", f2);
                        return;
                    }
                    return;
                }
                Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
            }
        }
    }

    public final void k(b bVar) {
        if (w) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.o(ByteOrder.BIG_ENDIAN);
        byte[] bArr = I;
        bVar.skipBytes(bArr.length);
        int length = bArr.length;
        while (true) {
            try {
                int readInt = bVar.readInt();
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int i = length + 8;
                    if (i == 16 && !Arrays.equals(bArr2, K)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (!Arrays.equals(bArr2, L)) {
                        if (Arrays.equals(bArr2, J)) {
                            byte[] bArr3 = new byte[readInt];
                            if (bVar.read(bArr3) == readInt) {
                                int readInt2 = bVar.readInt();
                                CRC32 crc32 = new CRC32();
                                crc32.update(bArr2);
                                crc32.update(bArr3);
                                if (((int) crc32.getValue()) == readInt2) {
                                    this.p = i;
                                    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());
                                }
                            }
                            throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr2));
                        }
                        int i2 = readInt + 4;
                        bVar.skipBytes(i2);
                        length = i + i2;
                    } else {
                        return;
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing PNG chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt PNG file.");
            }
        }
    }

    public final 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 i = ByteBuffer.wrap(bArr).getInt();
        int i2 = ByteBuffer.wrap(bArr2).getInt();
        h(bVar, i, 5);
        bVar.g(i2);
        bVar.o(ByteOrder.BIG_ENDIAN);
        int readInt = bVar.readInt();
        if (w) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i3 = 0; i3 < readInt; i3++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == f0.a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c f = c.f(readShort, this.h);
                c f2 = c.f(readShort2, this.h);
                this.f[0].put("ImageLength", f);
                this.f[0].put("ImageWidth", f2);
                if (w) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.skipBytes(readUnsignedShort2);
        }
    }

    public final 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.d == 8 && (cVar = (c) this.f[1].get("MakerNote")) != null) {
            b bVar2 = new b(cVar.d);
            bVar2.o(this.h);
            bVar2.g(6L);
            I(bVar2, 9);
            c cVar2 = (c) this.f[9].get("ColorSpace");
            if (cVar2 != null) {
                this.f[1].put("ColorSpace", cVar2);
            }
        }
    }

    public final void n(b bVar) {
        m(bVar);
        if (((c) this.f[0].get("JpgFromRaw")) != null) {
            h(bVar, this.t, 5);
        }
        c cVar = (c) this.f[0].get("ISO");
        c cVar2 = (c) this.f[1].get("PhotographicSensitivity");
        if (cVar != null && cVar2 == null) {
            this.f[1].put("PhotographicSensitivity", cVar);
        }
    }

    public final void o(b bVar) {
        byte[] bArr = t0;
        bVar.skipBytes(bArr.length);
        byte[] bArr2 = new byte[bVar.available()];
        bVar.readFully(bArr2);
        this.p = bArr.length;
        H(bArr2, 0);
    }

    public final void p(b bVar) {
        if (w) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.o(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) {
                    int readInt2 = bVar.readInt();
                    int i = skipBytes + 8;
                    if (Arrays.equals(O, bArr)) {
                        byte[] bArr2 = new byte[readInt2];
                        if (bVar.read(bArr2) == readInt2) {
                            this.p = i;
                            H(bArr2, 0);
                            this.p = i;
                            return;
                        } else {
                            throw new IOException("Failed to read given length for given PNG chunk type: " + b(bArr));
                        }
                    }
                    if (readInt2 % 2 == 1) {
                        readInt2++;
                    }
                    int i2 = i + readInt2;
                    if (i2 == readInt) {
                        return;
                    }
                    if (i2 <= readInt) {
                        int skipBytes2 = bVar.skipBytes(readInt2);
                        if (skipBytes2 == readInt2) {
                            skipBytes = i + skipBytes2;
                        } else {
                            throw new IOException("Encountered WebP file with invalid chunk size");
                        }
                    } else {
                        throw new IOException("Encountered WebP file with invalid chunk size");
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void q(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar != null && cVar2 != null) {
            int i = cVar.i(this.h);
            int i2 = cVar2.i(this.h);
            if (this.d == 7) {
                i += this.q;
            }
            int min = Math.min(i2, bVar.a() - i);
            if (i > 0 && min > 0) {
                this.i = true;
                int i3 = this.p + i;
                this.l = i3;
                this.m = min;
                if (this.a == null && this.c == null && this.b == null) {
                    byte[] bArr = new byte[min];
                    bVar.g(i3);
                    bVar.readFully(bArr);
                    this.n = bArr;
                }
            }
            if (w) {
                Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + i + ", length: " + min);
            }
        }
    }

    public final void r(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("StripOffsets");
        c cVar2 = (c) hashMap.get("StripByteCounts");
        if (cVar != null && cVar2 != null) {
            long[] c2 = c(cVar.k(this.h));
            long[] c3 = c(cVar2.k(this.h));
            if (c2 != null && c2.length != 0) {
                if (c3 != null && c3.length != 0) {
                    if (c2.length != c3.length) {
                        Log.w("ExifInterface", "stripOffsets and stripByteCounts should have same length.");
                        return;
                    }
                    long j = 0;
                    for (long j2 : c3) {
                        j += j2;
                    }
                    int i = (int) j;
                    byte[] bArr = new byte[i];
                    this.k = true;
                    this.j = true;
                    this.i = true;
                    int i2 = 0;
                    int i3 = 0;
                    for (int i4 = 0; i4 < c2.length; i4++) {
                        int i5 = (int) c2[i4];
                        int i6 = (int) c3[i4];
                        if (i4 < c2.length - 1 && i5 + i6 != c2[i4 + 1]) {
                            this.k = false;
                        }
                        int i7 = i5 - i2;
                        if (i7 < 0) {
                            Log.d("ExifInterface", "Invalid strip offset value");
                        }
                        bVar.g(i7);
                        int i8 = i2 + i7;
                        byte[] bArr2 = new byte[i6];
                        bVar.read(bArr2);
                        i2 = i8 + i6;
                        System.arraycopy(bArr2, 0, bArr, i3, i6);
                        i3 += i6;
                    }
                    this.n = bArr;
                    if (this.k) {
                        this.l = ((int) c2[0]) + this.p;
                        this.m = i;
                        return;
                    }
                    return;
                }
                Log.w("ExifInterface", "stripByteCounts should not be null or have zero length.");
                return;
            }
            Log.w("ExifInterface", "stripOffsets should not be null or have zero length.");
        }
    }

    public final boolean t(byte[] bArr) {
        b bVar;
        long readInt;
        byte[] bArr2;
        long j;
        b bVar2 = null;
        try {
            try {
                bVar = new b(bArr);
            } catch (Throwable th) {
                th = th;
            }
        } catch (Exception e2) {
            e = e2;
        }
        try {
            readInt = bVar.readInt();
            bArr2 = new byte[4];
            bVar.read(bArr2);
        } catch (Exception e3) {
            e = e3;
            bVar2 = bVar;
            if (w) {
                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;
        }
        if (readInt == 1) {
            readInt = bVar.readLong();
            j = 16;
            if (readInt < 16) {
                bVar.close();
                return false;
            }
        } else {
            j = 8;
        }
        if (readInt > bArr.length) {
            readInt = bArr.length;
        }
        long j2 = readInt - j;
        if (j2 < 8) {
            bVar.close();
            return false;
        }
        byte[] bArr3 = new byte[4];
        boolean z2 = false;
        boolean z3 = false;
        for (long j3 = 0; j3 < j2 / 4; j3++) {
            if (bVar.read(bArr3) != 4) {
                bVar.close();
                return false;
            }
            if (j3 != 1) {
                if (Arrays.equals(bArr3, E)) {
                    z2 = true;
                } else if (Arrays.equals(bArr3, F)) {
                    z3 = true;
                }
                if (z2 && z3) {
                    bVar.close();
                    return true;
                }
            }
        }
        bVar.close();
        return false;
    }

    public final boolean v(byte[] bArr) {
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder G2 = G(bVar2);
                this.h = G2;
                bVar2.o(G2);
                short readShort = bVar2.readShort();
                boolean z2 = readShort == 20306 || readShort == 21330;
                bVar2.close();
                return z2;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                return false;
            } catch (Throwable th) {
                th = th;
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final boolean w(byte[] bArr) {
        int i = 0;
        while (true) {
            byte[] bArr2 = I;
            if (i >= bArr2.length) {
                return true;
            }
            if (bArr[i] != bArr2[i]) {
                return false;
            }
            i++;
        }
    }

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

    public final boolean y(byte[] bArr) {
        b bVar = null;
        try {
            b bVar2 = new b(bArr);
            try {
                ByteOrder G2 = G(bVar2);
                this.h = G2;
                bVar2.o(G2);
                boolean z2 = bVar2.readShort() == 85;
                bVar2.close();
                return z2;
            } catch (Exception unused) {
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                return false;
            } catch (Throwable th) {
                th = th;
                bVar = bVar2;
                if (bVar != null) {
                    bVar.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public qx(InputStream inputStream, boolean z2) {
        d[][] dVarArr = k0;
        this.f = new HashMap[dVarArr.length];
        this.g = new HashSet(dVarArr.length);
        this.h = ByteOrder.BIG_ENDIAN;
        if (inputStream != null) {
            this.a = null;
            if (z2) {
                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.e = true;
                this.c = null;
                this.b = null;
                inputStream = bufferedInputStream;
            } else if (inputStream instanceof AssetManager.AssetInputStream) {
                this.c = (AssetManager.AssetInputStream) inputStream;
                this.b = null;
            } else {
                if (inputStream instanceof FileInputStream) {
                    FileInputStream fileInputStream = (FileInputStream) inputStream;
                    if (z(fileInputStream.getFD())) {
                        this.c = null;
                        this.b = fileInputStream.getFD();
                    }
                }
                this.c = null;
                this.b = null;
            }
            D(inputStream);
            return;
        }
        throw new NullPointerException("inputStream cannot be null");
    }
}