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

应用版本信息
应用名称:Breathe - People Portal
版本号:2.19.0
包名称:com.elmo.rta.breathe

MD5 校验值:2a432003868ccf5f53c7a8e745fc59ec

反编译源代码说明

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


package c4;

import android.content.res.AssetManager;
import android.media.MediaDataSource;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.system.OsConstants;
import android.util.Log;
import androidx.appcompat.widget.u2;
import b6.j;
import c4.b;
import j$.util.DesugarTimeZone;
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.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.CRC32;

public final class a {
    public static final String[] D;
    public static final int[] E;
    public static final byte[] F;
    public static final d G;
    public static final d[][] H;
    public static final d[] I;
    public static final HashMap<Integer, d>[] J;
    public static final HashMap<String, d>[] K;
    public static final HashSet<String> L;
    public static final HashMap<Integer, Integer> M;
    public static final Charset N;
    public static final byte[] O;
    public static final byte[] P;

    public final FileDescriptor f2976a;

    public final AssetManager.AssetInputStream f2977b;

    public int f2978c;

    public final HashMap<String, c>[] f2979d;

    public final HashSet f2980e;

    public ByteOrder f2981f;

    public boolean f2982g;

    public int f2983h;

    public int f2984i;

    public int f2985j;

    public int f2986k;

    public static final boolean f2961l = Log.isLoggable("ExifInterface", 3);

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

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

    public static final int[] f2964o = {8, 8, 8};

    public static final int[] f2965p = {8};

    public static final byte[] f2966q = {-1, -40, -1};

    public static final byte[] f2967r = {102, 116, 121, 112};

    public static final byte[] f2968s = {109, 105, 102, 49};

    public static final byte[] f2969t = {104, 101, 105, 99};

    public static final byte[] f2970u = {79, 76, 89, 77, 80, 0};

    public static final byte[] f2971v = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73};

    public static final byte[] f2972w = {-119, 80, 78, 71, 13, 10, 26, 10};

    public static final byte[] f2973x = {101, 88, 73, 102};

    public static final byte[] f2974y = {73, 72, 68, 82};

    public static final byte[] f2975z = {73, 69, 78, 68};
    public static final byte[] A = {82, 73, 70, 70};
    public static final byte[] B = {87, 69, 66, 80};
    public static final byte[] C = {69, 88, 73, 70};

    public class C0088a extends MediaDataSource {
        public long A;
        public final f B;

        public C0088a(f fVar) {
            this.B = fVar;
        }

        @Override
        public final void close() {
        }

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

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

    public static class b extends InputStream implements DataInput {
        public static final ByteOrder E = ByteOrder.LITTLE_ENDIAN;
        public static final ByteOrder F = ByteOrder.BIG_ENDIAN;
        public final DataInputStream A;
        public ByteOrder B;
        public int C;
        public byte[] D;

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

        public b(InputStream inputStream, ByteOrder byteOrder) {
            this.B = ByteOrder.BIG_ENDIAN;
            DataInputStream dataInputStream = new DataInputStream(inputStream);
            this.A = dataInputStream;
            dataInputStream.mark(0);
            this.C = 0;
            this.B = byteOrder;
        }

        public b(byte[] bArr) {
            this(new ByteArrayInputStream(bArr), ByteOrder.BIG_ENDIAN);
        }

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

        public final void d(int i10) {
            int i11 = 0;
            while (i11 < i10) {
                DataInputStream dataInputStream = this.A;
                int i12 = i10 - i11;
                int skip = (int) dataInputStream.skip(i12);
                if (skip <= 0) {
                    if (this.D == null) {
                        this.D = new byte[8192];
                    }
                    skip = dataInputStream.read(this.D, 0, Math.min(8192, i12));
                    if (skip == -1) {
                        throw new EOFException(e.a.a("Reached EOF while skipping ", i10, " bytes."));
                    }
                }
                i11 += skip;
            }
            this.C += i11;
        }

        @Override
        public final void mark(int i10) {
            throw new UnsupportedOperationException("Mark is currently unsupported");
        }

        @Override
        public final int read() {
            this.C++;
            return this.A.read();
        }

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

        @Override
        public final boolean readBoolean() {
            this.C++;
            return this.A.readBoolean();
        }

        @Override
        public final byte readByte() {
            this.C++;
            int read = this.A.read();
            if (read >= 0) {
                return (byte) read;
            }
            throw new EOFException();
        }

        @Override
        public final char readChar() {
            this.C += 2;
            return this.A.readChar();
        }

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

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

        @Override
        public final void readFully(byte[] bArr) {
            this.C += bArr.length;
            this.A.readFully(bArr);
        }

        @Override
        public final void readFully(byte[] bArr, int i10, int i11) {
            this.C += i11;
            this.A.readFully(bArr, i10, i11);
        }

        @Override
        public final int readInt() {
            this.C += 4;
            DataInputStream dataInputStream = this.A;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            int read3 = dataInputStream.read();
            int read4 = dataInputStream.read();
            if ((read | read2 | read3 | read4) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.B;
            if (byteOrder == E) {
                return (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
            }
            if (byteOrder == F) {
                return (read << 24) + (read2 << 16) + (read3 << 8) + read4;
            }
            throw new IOException("Invalid byte order: " + this.B);
        }

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

        @Override
        public final long readLong() {
            this.C += 8;
            DataInputStream dataInputStream = this.A;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            int read3 = dataInputStream.read();
            int read4 = dataInputStream.read();
            int read5 = dataInputStream.read();
            int read6 = dataInputStream.read();
            int read7 = dataInputStream.read();
            int read8 = dataInputStream.read();
            if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.B;
            if (byteOrder == E) {
                return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read;
            }
            if (byteOrder == F) {
                return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8;
            }
            throw new IOException("Invalid byte order: " + this.B);
        }

        @Override
        public final short readShort() {
            this.C += 2;
            DataInputStream dataInputStream = this.A;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.B;
            if (byteOrder == E) {
                return (short) ((read2 << 8) + read);
            }
            if (byteOrder == F) {
                return (short) ((read << 8) + read2);
            }
            throw new IOException("Invalid byte order: " + this.B);
        }

        @Override
        public final String readUTF() {
            this.C += 2;
            return this.A.readUTF();
        }

        @Override
        public final int readUnsignedByte() {
            this.C++;
            return this.A.readUnsignedByte();
        }

        @Override
        public final int readUnsignedShort() {
            this.C += 2;
            DataInputStream dataInputStream = this.A;
            int read = dataInputStream.read();
            int read2 = dataInputStream.read();
            if ((read | read2) < 0) {
                throw new EOFException();
            }
            ByteOrder byteOrder = this.B;
            if (byteOrder == E) {
                return (read2 << 8) + read;
            }
            if (byteOrder == F) {
                return (read << 8) + read2;
            }
            throw new IOException("Invalid byte order: " + this.B);
        }

        @Override
        public final void reset() {
            throw new UnsupportedOperationException("Reset is currently unsupported");
        }

        @Override
        public final int skipBytes(int i10) {
            throw new UnsupportedOperationException("skipBytes is currently unsupported");
        }
    }

    public static class c {

        public final int f2987a;

        public final int f2988b;

        public final long f2989c;

        public final byte[] f2990d;

        public c(long j5, byte[] bArr, int i10, int i11) {
            this.f2987a = i10;
            this.f2988b = i11;
            this.f2989c = j5;
            this.f2990d = bArr;
        }

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

        public static c a(String str) {
            byte[] bytes = str.concat("\u0000").getBytes(a.N);
            return new c(bytes, 2, bytes.length);
        }

        public static c b(long j5, ByteOrder byteOrder) {
            long[] jArr = {j5};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[4] * 1]);
            wrap.order(byteOrder);
            wrap.putInt((int) jArr[0]);
            return new c(wrap.array(), 4, 1);
        }

        public static c c(e eVar, ByteOrder byteOrder) {
            e[] eVarArr = {eVar};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[5] * 1]);
            wrap.order(byteOrder);
            e eVar2 = eVarArr[0];
            wrap.putInt((int) eVar2.f2995a);
            wrap.putInt((int) eVar2.f2996b);
            return new c(wrap.array(), 5, 1);
        }

        public static c d(int i10, ByteOrder byteOrder) {
            int[] iArr = {i10};
            ByteBuffer wrap = ByteBuffer.wrap(new byte[a.E[3] * 1]);
            wrap.order(byteOrder);
            wrap.putShort((short) iArr[0]);
            return new c(wrap.array(), 3, 1);
        }

        public final double e(ByteOrder byteOrder) {
            Object h10 = h(byteOrder);
            if (h10 != null) {
                if (h10 instanceof String) {
                    return Double.parseDouble((String) h10);
                }
                if (h10 instanceof long[]) {
                    if (((long[]) h10).length == 1) {
                        return r5[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                }
                if (h10 instanceof int[]) {
                    if (((int[]) h10).length == 1) {
                        return r5[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                }
                if (h10 instanceof double[]) {
                    double[] dArr = (double[]) h10;
                    if (dArr.length == 1) {
                        return dArr[0];
                    }
                    throw new NumberFormatException("There are more than one component");
                }
                if (h10 instanceof e[]) {
                    e[] eVarArr = (e[]) h10;
                    if (eVarArr.length == 1) {
                        e eVar = eVarArr[0];
                        return eVar.f2995a / eVar.f2996b;
                    }
                    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 final int f(ByteOrder byteOrder) {
            Object h10 = h(byteOrder);
            if (h10 == null) {
                throw new NumberFormatException("NULL can't be converted to a integer value");
            }
            if (h10 instanceof String) {
                return Integer.parseInt((String) h10);
            }
            if (h10 instanceof long[]) {
                long[] jArr = (long[]) h10;
                if (jArr.length == 1) {
                    return (int) jArr[0];
                }
                throw new NumberFormatException("There are more than one component");
            }
            if (!(h10 instanceof int[])) {
                throw new NumberFormatException("Couldn't find a integer value");
            }
            int[] iArr = (int[]) h10;
            if (iArr.length == 1) {
                return iArr[0];
            }
            throw new NumberFormatException("There are more than one component");
        }

        public final String g(ByteOrder byteOrder) {
            Object h10 = h(byteOrder);
            if (h10 == null) {
                return null;
            }
            if (h10 instanceof String) {
                return (String) h10;
            }
            StringBuilder sb2 = new StringBuilder();
            int i10 = 0;
            if (h10 instanceof long[]) {
                long[] jArr = (long[]) h10;
                while (i10 < jArr.length) {
                    sb2.append(jArr[i10]);
                    i10++;
                    if (i10 != jArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (h10 instanceof int[]) {
                int[] iArr = (int[]) h10;
                while (i10 < iArr.length) {
                    sb2.append(iArr[i10]);
                    i10++;
                    if (i10 != iArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (h10 instanceof double[]) {
                double[] dArr = (double[]) h10;
                while (i10 < dArr.length) {
                    sb2.append(dArr[i10]);
                    i10++;
                    if (i10 != dArr.length) {
                        sb2.append(",");
                    }
                }
                return sb2.toString();
            }
            if (!(h10 instanceof e[])) {
                return null;
            }
            e[] eVarArr = (e[]) h10;
            while (i10 < eVarArr.length) {
                sb2.append(eVarArr[i10].f2995a);
                sb2.append('/');
                sb2.append(eVarArr[i10].f2996b);
                i10++;
                if (i10 != eVarArr.length) {
                    sb2.append(",");
                }
            }
            return sb2.toString();
        }

        public final Serializable h(ByteOrder byteOrder) {
            b bVar;
            InputStream inputStream;
            byte b10;
            byte[] bArr;
            byte[] bArr2 = this.f2990d;
            InputStream inputStream2 = null;
            try {
                try {
                    bVar = new b(bArr2);
                    try {
                        bVar.B = byteOrder;
                        int i10 = this.f2987a;
                        int i11 = 0;
                        boolean z10 = true;
                        int i12 = this.f2988b;
                        switch (i10) {
                            case 1:
                            case v3.f.STRING_SET_FIELD_NUMBER:
                                if (bArr2.length == 1 && (b10 = bArr2[0]) >= 0 && b10 <= 1) {
                                    String str = new String(new char[]{(char) (b10 + 48)});
                                    try {
                                        bVar.close();
                                    } catch (IOException e10) {
                                        Log.e("ExifInterface", "IOException occurred while closing InputStream", e10);
                                    }
                                    return str;
                                }
                                String str2 = new String(bArr2, a.N);
                                try {
                                    bVar.close();
                                } catch (IOException e11) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e11);
                                }
                                return str2;
                            case 2:
                            case v3.f.DOUBLE_FIELD_NUMBER:
                                if (i12 >= a.F.length) {
                                    int i13 = 0;
                                    while (true) {
                                        bArr = a.F;
                                        if (i13 < bArr.length) {
                                            if (bArr2[i13] != bArr[i13]) {
                                                z10 = false;
                                            } else {
                                                i13++;
                                            }
                                        }
                                    }
                                    if (z10) {
                                        i11 = bArr.length;
                                    }
                                }
                                StringBuilder sb2 = new StringBuilder();
                                while (i11 < i12) {
                                    byte b11 = bArr2[i11];
                                    if (b11 != 0) {
                                        if (b11 >= 32) {
                                            sb2.append((char) b11);
                                        } else {
                                            sb2.append('?');
                                        }
                                        i11++;
                                    } else {
                                        String sb3 = sb2.toString();
                                        bVar.close();
                                        return sb3;
                                    }
                                }
                                String sb32 = sb2.toString();
                                bVar.close();
                                return sb32;
                            case 3:
                                ?? r15 = new int[i12];
                                while (i11 < i12) {
                                    r15[i11] = bVar.readUnsignedShort();
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e12) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e12);
                                }
                                return r15;
                            case 4:
                                ?? r152 = new long[i12];
                                while (i11 < i12) {
                                    r152[i11] = bVar.readInt() & 4294967295L;
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e13) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e13);
                                }
                                return r152;
                            case 5:
                                ?? r153 = new e[i12];
                                while (i11 < i12) {
                                    r153[i11] = new e(bVar.readInt() & 4294967295L, bVar.readInt() & 4294967295L);
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e14) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e14);
                                }
                                return r153;
                            case 8:
                                ?? r154 = new int[i12];
                                while (i11 < i12) {
                                    r154[i11] = bVar.readShort();
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e15) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e15);
                                }
                                return r154;
                            case 9:
                                ?? r155 = new int[i12];
                                while (i11 < i12) {
                                    r155[i11] = bVar.readInt();
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e16) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e16);
                                }
                                return r155;
                            case 10:
                                ?? r156 = new e[i12];
                                while (i11 < i12) {
                                    r156[i11] = new e(bVar.readInt(), bVar.readInt());
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e17) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e17);
                                }
                                return r156;
                            case 11:
                                ?? r157 = new double[i12];
                                while (i11 < i12) {
                                    r157[i11] = bVar.readFloat();
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e18) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e18);
                                }
                                return r157;
                            case 12:
                                ?? r158 = new double[i12];
                                while (i11 < i12) {
                                    r158[i11] = bVar.readDouble();
                                    i11++;
                                }
                                try {
                                    bVar.close();
                                } catch (IOException e19) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e19);
                                }
                                return r158;
                            default:
                                try {
                                    bVar.close();
                                } catch (IOException e20) {
                                    Log.e("ExifInterface", "IOException occurred while closing InputStream", e20);
                                }
                                return null;
                        }
                    } catch (IOException e21) {
                        e = e21;
                        Log.w("ExifInterface", "IOException occurred during reading a value", e);
                        if (bVar != null) {
                            try {
                                bVar.close();
                            } catch (IOException e22) {
                                Log.e("ExifInterface", "IOException occurred while closing InputStream", e22);
                            }
                        }
                        return null;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    inputStream2 = inputStream;
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e23) {
                            Log.e("ExifInterface", "IOException occurred while closing InputStream", e23);
                        }
                    }
                    throw th;
                }
            } catch (IOException e24) {
                e = e24;
                bVar = null;
            } catch (Throwable th3) {
                th = th3;
                if (inputStream2 != null) {
                }
                throw th;
            }
        }

        public final String toString() {
            StringBuilder sb2 = new StringBuilder("(");
            sb2.append(a.D[this.f2987a]);
            sb2.append(", data length:");
            return p2.d.a(sb2, this.f2990d.length, ")");
        }
    }

    public static class d {

        public final int f2991a;

        public final String f2992b;

        public final int f2993c;

        public final int f2994d;

        public d(int i10, int i11, int i12, String str) {
            this.f2992b = str;
            this.f2991a = i10;
            this.f2993c = i11;
            this.f2994d = i12;
        }

        public d(int i10, int i11, String str) {
            this.f2992b = str;
            this.f2991a = i10;
            this.f2993c = i11;
            this.f2994d = -1;
        }
    }

    public static class e {

        public final long f2995a;

        public final long f2996b;

        public e(long j5, long j10) {
            if (j10 == 0) {
                this.f2995a = 0L;
                this.f2996b = 1L;
            } else {
                this.f2995a = j5;
                this.f2996b = j10;
            }
        }

        public final String toString() {
            return this.f2995a + "/" + this.f2996b;
        }
    }

    public static class f extends b {
        public f(InputStream inputStream) {
            super(inputStream);
            if (!inputStream.markSupported()) {
                throw new IllegalArgumentException("Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset");
            }
            this.A.mark(Integer.MAX_VALUE);
        }

        public f(byte[] bArr) {
            super(bArr);
            this.A.mark(Integer.MAX_VALUE);
        }

        public final void g(long j5) {
            int i10 = this.C;
            if (i10 > j5) {
                this.C = 0;
                this.A.reset();
            } else {
                j5 -= i10;
            }
            d((int) j5);
        }
    }

    static {
        "VP8X".getBytes(Charset.defaultCharset());
        "VP8L".getBytes(Charset.defaultCharset());
        "VP8 ".getBytes(Charset.defaultCharset());
        "ANIM".getBytes(Charset.defaultCharset());
        "ANMF".getBytes(Charset.defaultCharset());
        D = new String[]{"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"};
        E = new int[]{0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1};
        F = new byte[]{65, 83, 67, 73, 73, 0, 0, 0};
        d[] dVarArr = {new d(254, 4, "NewSubfileType"), new d(255, 4, "SubfileType"), new d(256, 3, 4, "ImageWidth"), new d(257, 3, 4, "ImageLength"), new d(258, 3, "BitsPerSample"), new d(259, 3, "Compression"), new d(262, 3, "PhotometricInterpretation"), new d(270, 2, "ImageDescription"), new d(271, 2, "Make"), new d(272, 2, "Model"), new d(273, 3, 4, "StripOffsets"), new d(274, 3, "Orientation"), new d(277, 3, "SamplesPerPixel"), new d(278, 3, 4, "RowsPerStrip"), new d(279, 3, 4, "StripByteCounts"), new d(282, 5, "XResolution"), new d(283, 5, "YResolution"), new d(284, 3, "PlanarConfiguration"), new d(296, 3, "ResolutionUnit"), new d(301, 3, "TransferFunction"), new d(305, 2, "Software"), new d(306, 2, "DateTime"), new d(315, 2, "Artist"), new d(318, 5, "WhitePoint"), new d(319, 5, "PrimaryChromaticities"), new d(330, 4, "SubIFDPointer"), new d(513, 4, "JPEGInterchangeFormat"), new d(514, 4, "JPEGInterchangeFormatLength"), new d(529, 5, "YCbCrCoefficients"), new d(530, 3, "YCbCrSubSampling"), new d(531, 3, "YCbCrPositioning"), new d(532, 5, "ReferenceBlackWhite"), new d(33432, 2, "Copyright"), new d(34665, 4, "ExifIFDPointer"), new d(34853, 4, "GPSInfoIFDPointer"), new d(4, 4, "SensorTopBorder"), new d(5, 4, "SensorLeftBorder"), new d(6, 4, "SensorBottomBorder"), new d(7, 4, "SensorRightBorder"), new d(23, 3, "ISO"), new d(46, 7, "JpgFromRaw"), new d(700, 1, "Xmp")};
        d[] dVarArr2 = {new d(33434, 5, "ExposureTime"), new d(33437, 5, "FNumber"), new d(34850, 3, "ExposureProgram"), new d(34852, 2, "SpectralSensitivity"), new d(34855, 3, "PhotographicSensitivity"), new d(34856, 7, "OECF"), new d(34864, 3, "SensitivityType"), new d(34865, 4, "StandardOutputSensitivity"), new d(34866, 4, "RecommendedExposureIndex"), new d(34867, 4, "ISOSpeed"), new d(34868, 4, "ISOSpeedLatitudeyyy"), new d(34869, 4, "ISOSpeedLatitudezzz"), new d(36864, 2, "ExifVersion"), new d(36867, 2, "DateTimeOriginal"), new d(36868, 2, "DateTimeDigitized"), new d(36880, 2, "OffsetTime"), new d(36881, 2, "OffsetTimeOriginal"), new d(36882, 2, "OffsetTimeDigitized"), new d(37121, 7, "ComponentsConfiguration"), new d(37122, 5, "CompressedBitsPerPixel"), new d(37377, 10, "ShutterSpeedValue"), new d(37378, 5, "ApertureValue"), new d(37379, 10, "BrightnessValue"), new d(37380, 10, "ExposureBiasValue"), new d(37381, 5, "MaxApertureValue"), new d(37382, 5, "SubjectDistance"), new d(37383, 3, "MeteringMode"), new d(37384, 3, "LightSource"), new d(37385, 3, "Flash"), new d(37386, 5, "FocalLength"), new d(37396, 3, "SubjectArea"), new d(37500, 7, "MakerNote"), new d(37510, 7, "UserComment"), new d(37520, 2, "SubSecTime"), new d(37521, 2, "SubSecTimeOriginal"), new d(37522, 2, "SubSecTimeDigitized"), new d(40960, 7, "FlashpixVersion"), new d(40961, 3, "ColorSpace"), new d(40962, 3, 4, "PixelXDimension"), new d(40963, 3, 4, "PixelYDimension"), new d(40964, 2, "RelatedSoundFile"), new d(40965, 4, "InteroperabilityIFDPointer"), new d(41483, 5, "FlashEnergy"), new d(41484, 7, "SpatialFrequencyResponse"), new d(41486, 5, "FocalPlaneXResolution"), new d(41487, 5, "FocalPlaneYResolution"), new d(41488, 3, "FocalPlaneResolutionUnit"), new d(41492, 3, "SubjectLocation"), new d(41493, 5, "ExposureIndex"), new d(41495, 3, "SensingMethod"), new d(41728, 7, "FileSource"), new d(41729, 7, "SceneType"), new d(41730, 7, "CFAPattern"), new d(41985, 3, "CustomRendered"), new d(41986, 3, "ExposureMode"), new d(41987, 3, "WhiteBalance"), new d(41988, 5, "DigitalZoomRatio"), new d(41989, 3, "FocalLengthIn35mmFilm"), new d(41990, 3, "SceneCaptureType"), new d(41991, 3, "GainControl"), new d(41992, 3, "Contrast"), new d(41993, 3, "Saturation"), new d(41994, 3, "Sharpness"), new d(41995, 7, "DeviceSettingDescription"), new d(41996, 3, "SubjectDistanceRange"), new d(42016, 2, "ImageUniqueID"), new d(42032, 2, "CameraOwnerName"), new d(42033, 2, "BodySerialNumber"), new d(42034, 5, "LensSpecification"), new d(42035, 2, "LensMake"), new d(42036, 2, "LensModel"), new d(42240, 5, "Gamma"), new d(50706, 1, "DNGVersion"), new d(50720, 3, 4, "DefaultCropSize")};
        d[] dVarArr3 = {new d(0, 1, "GPSVersionID"), new d(1, 2, "GPSLatitudeRef"), new d(2, 5, 10, "GPSLatitude"), new d(3, 2, "GPSLongitudeRef"), new d(4, 5, 10, "GPSLongitude"), new d(5, 1, "GPSAltitudeRef"), new d(6, 5, "GPSAltitude"), new d(7, 5, "GPSTimeStamp"), new d(8, 2, "GPSSatellites"), new d(9, 2, "GPSStatus"), new d(10, 2, "GPSMeasureMode"), new d(11, 5, "GPSDOP"), new d(12, 2, "GPSSpeedRef"), new d(13, 5, "GPSSpeed"), new d(14, 2, "GPSTrackRef"), new d(15, 5, "GPSTrack"), new d(16, 2, "GPSImgDirectionRef"), new d(17, 5, "GPSImgDirection"), new d(18, 2, "GPSMapDatum"), new d(19, 2, "GPSDestLatitudeRef"), new d(20, 5, "GPSDestLatitude"), new d(21, 2, "GPSDestLongitudeRef"), new d(22, 5, "GPSDestLongitude"), new d(23, 2, "GPSDestBearingRef"), new d(24, 5, "GPSDestBearing"), new d(25, 2, "GPSDestDistanceRef"), new d(26, 5, "GPSDestDistance"), new d(27, 7, "GPSProcessingMethod"), new d(28, 7, "GPSAreaInformation"), new d(29, 2, "GPSDateStamp"), new d(30, 3, "GPSDifferential"), new d(31, 5, "GPSHPositioningError")};
        d[] dVarArr4 = {new d(1, 2, "InteroperabilityIndex")};
        d[] dVarArr5 = {new d(254, 4, "NewSubfileType"), new d(255, 4, "SubfileType"), new d(256, 3, 4, "ThumbnailImageWidth"), new d(257, 3, 4, "ThumbnailImageLength"), new d(258, 3, "BitsPerSample"), new d(259, 3, "Compression"), new d(262, 3, "PhotometricInterpretation"), new d(270, 2, "ImageDescription"), new d(271, 2, "Make"), new d(272, 2, "Model"), new d(273, 3, 4, "StripOffsets"), new d(274, 3, "ThumbnailOrientation"), new d(277, 3, "SamplesPerPixel"), new d(278, 3, 4, "RowsPerStrip"), new d(279, 3, 4, "StripByteCounts"), new d(282, 5, "XResolution"), new d(283, 5, "YResolution"), new d(284, 3, "PlanarConfiguration"), new d(296, 3, "ResolutionUnit"), new d(301, 3, "TransferFunction"), new d(305, 2, "Software"), new d(306, 2, "DateTime"), new d(315, 2, "Artist"), new d(318, 5, "WhitePoint"), new d(319, 5, "PrimaryChromaticities"), new d(330, 4, "SubIFDPointer"), new d(513, 4, "JPEGInterchangeFormat"), new d(514, 4, "JPEGInterchangeFormatLength"), new d(529, 5, "YCbCrCoefficients"), new d(530, 3, "YCbCrSubSampling"), new d(531, 3, "YCbCrPositioning"), new d(532, 5, "ReferenceBlackWhite"), new d(700, 1, "Xmp"), new d(33432, 2, "Copyright"), new d(34665, 4, "ExifIFDPointer"), new d(34853, 4, "GPSInfoIFDPointer"), new d(50706, 1, "DNGVersion"), new d(50720, 3, 4, "DefaultCropSize")};
        G = new d(273, 3, "StripOffsets");
        H = new d[][]{dVarArr, dVarArr2, dVarArr3, dVarArr4, dVarArr5, dVarArr, new d[]{new d(256, 7, "ThumbnailImage"), new d(8224, 4, "CameraSettingsIFDPointer"), new d(8256, 4, "ImageProcessingIFDPointer")}, new d[]{new d(257, 4, "PreviewImageStart"), new d(258, 4, "PreviewImageLength")}, new d[]{new d(4371, 3, "AspectFrame")}, new d[]{new d(55, 3, "ColorSpace")}};
        I = new d[]{new d(330, 4, "SubIFDPointer"), new d(34665, 4, "ExifIFDPointer"), new d(34853, 4, "GPSInfoIFDPointer"), new d(40965, 4, "InteroperabilityIFDPointer"), new d(8224, 1, "CameraSettingsIFDPointer"), new d(8256, 1, "ImageProcessingIFDPointer")};
        J = new HashMap[10];
        K = new HashMap[10];
        L = new HashSet<>(Arrays.asList("FNumber", "DigitalZoomRatio", "ExposureTime", "SubjectDistance", "GPSTimeStamp"));
        M = new HashMap<>();
        Charset forName = Charset.forName("US-ASCII");
        N = forName;
        O = "Exif\u0000\u0000".getBytes(forName);
        P = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName);
        Locale locale = Locale.US;
        new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale).setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        int i10 = 0;
        while (true) {
            d[][] dVarArr6 = H;
            if (i10 >= dVarArr6.length) {
                HashMap<Integer, Integer> hashMap = M;
                d[] dVarArr7 = I;
                hashMap.put(Integer.valueOf(dVarArr7[0].f2991a), 5);
                hashMap.put(Integer.valueOf(dVarArr7[1].f2991a), 1);
                hashMap.put(Integer.valueOf(dVarArr7[2].f2991a), 2);
                hashMap.put(Integer.valueOf(dVarArr7[3].f2991a), 3);
                hashMap.put(Integer.valueOf(dVarArr7[4].f2991a), 7);
                hashMap.put(Integer.valueOf(dVarArr7[5].f2991a), 8);
                Pattern.compile(".*[1-9].*");
                Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})$");
                Pattern.compile("^(\\d{4}):(\\d{2}):(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})$");
                return;
            }
            J[i10] = new HashMap<>();
            K[i10] = new HashMap<>();
            for (d dVar : dVarArr6[i10]) {
                J[i10].put(Integer.valueOf(dVar.f2991a), dVar);
                K[i10].put(dVar.f2992b, dVar);
            }
            i10++;
        }
    }

    public a(j jVar) {
        boolean z10;
        d[][] dVarArr = H;
        this.f2979d = new HashMap[dVarArr.length];
        this.f2980e = new HashSet(dVarArr.length);
        this.f2981f = ByteOrder.BIG_ENDIAN;
        boolean z11 = jVar instanceof AssetManager.AssetInputStream;
        FileDescriptor fileDescriptor = null;
        boolean z12 = f2961l;
        if (z11) {
            this.f2977b = (AssetManager.AssetInputStream) jVar;
        } else {
            if (jVar instanceof FileInputStream) {
                FileInputStream fileInputStream = (FileInputStream) jVar;
                try {
                    b.a.c(fileInputStream.getFD(), 0L, OsConstants.SEEK_CUR);
                    z10 = true;
                } catch (Exception unused) {
                    if (z12) {
                        Log.d("ExifInterface", "The file descriptor for the given input is not seekable");
                    }
                    z10 = false;
                }
                if (z10) {
                    this.f2977b = null;
                    fileDescriptor = fileInputStream.getFD();
                }
            }
            this.f2977b = null;
        }
        this.f2976a = fileDescriptor;
        for (int i10 = 0; i10 < dVarArr.length; i10++) {
            try {
                try {
                    this.f2979d[i10] = new HashMap<>();
                } finally {
                    a();
                    if (z12) {
                        p();
                    }
                }
            } catch (IOException | UnsupportedOperationException e10) {
                if (z12) {
                    Log.w("ExifInterface", "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e10);
                }
                if (!z12) {
                    return;
                }
            }
        }
        BufferedInputStream bufferedInputStream = new BufferedInputStream(jVar, 5000);
        int f10 = f(bufferedInputStream);
        this.f2978c = f10;
        if ((f10 == 4 || f10 == 9 || f10 == 13 || f10 == 14) ? false : true) {
            f fVar = new f(bufferedInputStream);
            int i11 = this.f2978c;
            if (i11 == 12) {
                d(fVar);
            } else if (i11 == 7) {
                g(fVar);
            } else if (i11 == 10) {
                k(fVar);
            } else {
                j(fVar);
            }
            fVar.g(this.f2983h);
            u(fVar);
        } else {
            b bVar = new b(bufferedInputStream);
            int i12 = this.f2978c;
            if (i12 == 4) {
                e(bVar, 0, 0);
            } else if (i12 == 13) {
                h(bVar);
            } else if (i12 == 9) {
                i(bVar);
            } else if (i12 == 14) {
                l(bVar);
            }
        }
        a();
        if (!z12) {
        }
    }

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

    public final void a() {
        String b10 = b("DateTimeOriginal");
        HashMap<String, c>[] hashMapArr = this.f2979d;
        if (b10 != null && b("DateTime") == null) {
            hashMapArr[0].put("DateTime", c.a(b10));
        }
        if (b("ImageWidth") == null) {
            hashMapArr[0].put("ImageWidth", c.b(0L, this.f2981f));
        }
        if (b("ImageLength") == null) {
            hashMapArr[0].put("ImageLength", c.b(0L, this.f2981f));
        }
        if (b("Orientation") == null) {
            hashMapArr[0].put("Orientation", c.b(0L, this.f2981f));
        }
        if (b("LightSource") == null) {
            hashMapArr[1].put("LightSource", c.b(0L, this.f2981f));
        }
    }

    public final String b(String str) {
        String str2;
        c c10 = c(str);
        if (c10 != null) {
            if (!L.contains(str)) {
                return c10.g(this.f2981f);
            }
            if (str.equals("GPSTimeStamp")) {
                int i10 = c10.f2987a;
                if (i10 != 5 && i10 != 10) {
                    str2 = d0.a.c("GPS Timestamp format is not rational. format=", i10);
                } else {
                    e[] eVarArr = (e[]) c10.h(this.f2981f);
                    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.f2995a) / ((float) eVar.f2996b))), Integer.valueOf((int) (((float) eVar2.f2995a) / ((float) eVar2.f2996b))), Integer.valueOf((int) (((float) eVar3.f2995a) / ((float) eVar3.f2996b))));
                    }
                    str2 = "Invalid GPS Timestamp array. array=" + Arrays.toString(eVarArr);
                }
                Log.w("ExifInterface", str2);
                return null;
            }
            try {
                return Double.toString(c10.e(this.f2981f));
            } catch (NumberFormatException unused) {
            }
        }
        return null;
    }

    public final c c(String str) {
        if ("ISOSpeedRatings".equals(str)) {
            if (f2961l) {
                Log.d("ExifInterface", "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY.");
            }
            str = "PhotographicSensitivity";
        }
        for (int i10 = 0; i10 < H.length; i10++) {
            c cVar = this.f2979d[i10].get(str);
            if (cVar != null) {
                return cVar;
            }
        }
        return null;
    }

    public final void d(f fVar) {
        String str;
        String str2;
        String str3;
        if (Build.VERSION.SDK_INT < 28) {
            throw new UnsupportedOperationException("Reading EXIF from HEIF files is supported from SDK 28 and above");
        }
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        try {
            try {
                b.C0089b.a(mediaMetadataRetriever, new C0088a(fVar));
                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;
                }
                HashMap<String, c>[] hashMapArr = this.f2979d;
                if (str != null) {
                    hashMapArr[0].put("ImageWidth", c.d(Integer.parseInt(str), this.f2981f));
                }
                if (str2 != null) {
                    hashMapArr[0].put("ImageLength", c.d(Integer.parseInt(str2), this.f2981f));
                }
                if (str3 != null) {
                    int parseInt = Integer.parseInt(str3);
                    hashMapArr[0].put("Orientation", c.d(parseInt != 90 ? parseInt != 180 ? parseInt != 270 ? 1 : 8 : 3 : 6, this.f2981f));
                }
                if (extractMetadata != null && extractMetadata2 != null) {
                    int parseInt2 = Integer.parseInt(extractMetadata);
                    int parseInt3 = Integer.parseInt(extractMetadata2);
                    if (parseInt3 <= 6) {
                        throw new IOException("Invalid exif length");
                    }
                    fVar.g(parseInt2);
                    byte[] bArr = new byte[6];
                    if (fVar.read(bArr) != 6) {
                        throw new IOException("Can't read identifier");
                    }
                    int i10 = parseInt2 + 6;
                    int i11 = parseInt3 - 6;
                    if (!Arrays.equals(bArr, O)) {
                        throw new IOException("Invalid identifier");
                    }
                    byte[] bArr2 = new byte[i11];
                    if (fVar.read(bArr2) != i11) {
                        throw new IOException("Can't read exif");
                    }
                    this.f2983h = i10;
                    r(0, bArr2);
                }
                if (f2961l) {
                    Log.d("ExifInterface", "Heif meta: " + str + "x" + str2 + ", rotation " + str3);
                }
            } catch (RuntimeException unused) {
                throw new UnsupportedOperationException("Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported.");
            }
        } finally {
            mediaMetadataRetriever.release();
        }
    }

    public final void e(b bVar, int i10, int i11) {
        boolean z10;
        boolean z11;
        String str;
        String str2;
        boolean z12 = f2961l;
        if (z12) {
            Log.d("ExifInterface", "getJpegAttributes starting with: " + bVar);
        }
        bVar.B = ByteOrder.BIG_ENDIAN;
        byte readByte = bVar.readByte();
        byte b10 = -1;
        if (readByte == -1) {
            if (bVar.readByte() == -40) {
                int i12 = 2;
                int i13 = 2;
                while (true) {
                    byte readByte2 = bVar.readByte();
                    if (readByte2 == b10) {
                        int i14 = i13 + 1;
                        byte readByte3 = bVar.readByte();
                        if (z12) {
                            Log.d("ExifInterface", "Found JPEG segment indicator: " + Integer.toHexString(readByte3 & 255));
                        }
                        int i15 = i14 + 1;
                        if (readByte3 != -39 && readByte3 != -38) {
                            int readUnsignedShort = bVar.readUnsignedShort() - i12;
                            int i16 = i15 + i12;
                            if (z12) {
                                Log.d("ExifInterface", "JPEG segment: " + Integer.toHexString(readByte3 & 255) + " (length: " + (readUnsignedShort + 2) + ")");
                            }
                            if (readUnsignedShort >= 0) {
                                HashMap<String, c>[] hashMapArr = this.f2979d;
                                if (readByte3 != -31) {
                                    if (readByte3 != -2) {
                                        switch (readByte3) {
                                            case -64:
                                            case -63:
                                            case -62:
                                            case -61:
                                                break;
                                            default:
                                                switch (readByte3) {
                                                    case -59:
                                                    case -58:
                                                    case -57:
                                                        break;
                                                    default:
                                                        switch (readByte3) {
                                                            case -55:
                                                            case -54:
                                                            case -53:
                                                                break;
                                                            default:
                                                                switch (readByte3) {
                                                                }
                                                        }
                                                }
                                        }
                                        bVar.d(1);
                                        HashMap<String, c> hashMap = hashMapArr[i11];
                                        if (i11 != 4) {
                                            str = "ImageLength";
                                        } else {
                                            str = "ThumbnailImageLength";
                                        }
                                        hashMap.put(str, c.b(bVar.readUnsignedShort(), this.f2981f));
                                        HashMap<String, c> hashMap2 = hashMapArr[i11];
                                        if (i11 != 4) {
                                            str2 = "ImageWidth";
                                        } else {
                                            str2 = "ThumbnailImageWidth";
                                        }
                                        hashMap2.put(str2, c.b(bVar.readUnsignedShort(), this.f2981f));
                                        readUnsignedShort -= 5;
                                        if (readUnsignedShort < 0) {
                                            bVar.d(readUnsignedShort);
                                            i13 = i16 + readUnsignedShort;
                                            i12 = 2;
                                            b10 = -1;
                                        } else {
                                            throw new IOException("Invalid length");
                                        }
                                    } else {
                                        byte[] bArr = new byte[readUnsignedShort];
                                        if (bVar.read(bArr) == readUnsignedShort) {
                                            if (b("UserComment") == null) {
                                                hashMapArr[1].put("UserComment", c.a(new String(bArr, N)));
                                            }
                                        } else {
                                            throw new IOException("Invalid exif");
                                        }
                                    }
                                } else {
                                    byte[] bArr2 = new byte[readUnsignedShort];
                                    bVar.readFully(bArr2);
                                    int i17 = i16 + readUnsignedShort;
                                    byte[] bArr3 = O;
                                    if (bArr3 != null && readUnsignedShort >= bArr3.length) {
                                        for (int i18 = 0; i18 < bArr3.length; i18++) {
                                            if (bArr2[i18] == bArr3[i18]) {
                                            }
                                        }
                                        z10 = true;
                                        if (!z10) {
                                            byte[] copyOfRange = Arrays.copyOfRange(bArr2, bArr3.length, readUnsignedShort);
                                            this.f2983h = i10 + i16 + bArr3.length;
                                            r(i11, copyOfRange);
                                            u(new b(copyOfRange));
                                        } else {
                                            byte[] bArr4 = P;
                                            if (bArr4 != null && readUnsignedShort >= bArr4.length) {
                                                for (int i19 = 0; i19 < bArr4.length; i19++) {
                                                    if (bArr2[i19] == bArr4[i19]) {
                                                    }
                                                }
                                                z11 = true;
                                                if (z11) {
                                                    int length = bArr4.length + i16;
                                                    byte[] copyOfRange2 = Arrays.copyOfRange(bArr2, bArr4.length, readUnsignedShort);
                                                    if (b("Xmp") == null) {
                                                        hashMapArr[0].put("Xmp", new c(length, copyOfRange2, 1, copyOfRange2.length));
                                                    }
                                                }
                                            }
                                            z11 = false;
                                            if (z11) {
                                            }
                                        }
                                        i16 = i17;
                                    }
                                    z10 = false;
                                    if (!z10) {
                                    }
                                    i16 = i17;
                                }
                                readUnsignedShort = 0;
                                if (readUnsignedShort < 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 f(BufferedInputStream bufferedInputStream) {
        boolean z10;
        boolean z11;
        b bVar;
        b bVar2;
        boolean z12;
        b bVar3;
        b bVar4;
        boolean z13;
        b bVar5;
        b bVar6;
        boolean z14;
        boolean z15;
        boolean z16;
        long j5;
        bufferedInputStream.mark(5000);
        byte[] bArr = new byte[5000];
        bufferedInputStream.read(bArr);
        bufferedInputStream.reset();
        int i10 = 0;
        while (true) {
            byte[] bArr2 = f2966q;
            if (i10 < bArr2.length) {
                if (bArr[i10] != bArr2[i10]) {
                    z10 = false;
                    break;
                }
                i10++;
            } else {
                z10 = true;
                break;
            }
        }
        if (z10) {
            return 4;
        }
        byte[] bytes = "FUJIFILMCCD-RAW".getBytes(Charset.defaultCharset());
        int i11 = 0;
        while (true) {
            if (i11 < bytes.length) {
                if (bArr[i11] != bytes[i11]) {
                    z11 = false;
                    break;
                }
                i11++;
            } else {
                z11 = true;
                break;
            }
        }
        if (z11) {
            return 9;
        }
        try {
            bVar2 = new b(bArr);
            try {
                long readInt = bVar2.readInt();
                byte[] bArr3 = new byte[4];
                bVar2.read(bArr3);
                if (Arrays.equals(bArr3, f2967r)) {
                    if (readInt == 1) {
                        readInt = bVar2.readLong();
                        j5 = 16;
                        if (readInt < 16) {
                        }
                    } else {
                        j5 = 8;
                    }
                    long j10 = 5000;
                    if (readInt > j10) {
                        readInt = j10;
                    }
                    long j11 = readInt - j5;
                    if (j11 >= 8) {
                        byte[] bArr4 = new byte[4];
                        boolean z17 = false;
                        boolean z18 = false;
                        for (long j12 = 0; j12 < j11 / 4 && bVar2.read(bArr4) == 4; j12++) {
                            if (j12 != 1) {
                                if (Arrays.equals(bArr4, f2968s)) {
                                    z17 = true;
                                } else if (Arrays.equals(bArr4, f2969t)) {
                                    z18 = true;
                                }
                                if (z17 && z18) {
                                    bVar2.close();
                                    z12 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e10) {
                e = e10;
                try {
                    if (f2961l) {
                        Log.d("ExifInterface", "Exception parsing HEIF file type box.", e);
                    }
                } catch (Throwable th2) {
                    th = th2;
                    bVar = bVar2;
                    bVar2 = bVar;
                    if (bVar2 != null) {
                        bVar2.close();
                    }
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                if (bVar2 != null) {
                }
                throw th;
            }
        } catch (Exception e11) {
            e = e11;
            bVar2 = null;
        } catch (Throwable th4) {
            th = th4;
            bVar = null;
            bVar2 = bVar;
            if (bVar2 != null) {
            }
            throw th;
        }
        bVar2.close();
        z12 = false;
        if (z12) {
            return 12;
        }
        try {
            bVar4 = new b(bArr);
            try {
                ByteOrder q10 = q(bVar4);
                this.f2981f = q10;
                bVar4.B = q10;
                short readShort = bVar4.readShort();
                if (readShort != 20306 && readShort != 21330) {
                    z13 = false;
                } else {
                    z13 = true;
                }
                bVar4.close();
            } catch (Exception unused) {
                if (bVar4 != null) {
                    bVar4.close();
                }
                z13 = false;
                if (!z13) {
                }
            } catch (Throwable th5) {
                th = th5;
                bVar3 = bVar4;
                if (bVar3 != null) {
                    bVar3.close();
                }
                throw th;
            }
        } catch (Exception unused2) {
            bVar4 = null;
        } catch (Throwable th6) {
            th = th6;
            bVar3 = null;
        }
        if (!z13) {
            return 7;
        }
        try {
            b bVar7 = new b(bArr);
            try {
                ByteOrder q11 = q(bVar7);
                this.f2981f = q11;
                bVar7.B = q11;
                if (bVar7.readShort() == 85) {
                    z14 = true;
                } else {
                    z14 = false;
                }
                bVar7.close();
            } catch (Exception unused3) {
                bVar6 = bVar7;
                if (bVar6 != null) {
                    bVar6.close();
                }
                z14 = false;
                if (!z14) {
                }
            } catch (Throwable th7) {
                th = th7;
                bVar5 = bVar7;
                if (bVar5 != null) {
                    bVar5.close();
                }
                throw th;
            }
        } catch (Exception unused4) {
            bVar6 = null;
        } catch (Throwable th8) {
            th = th8;
            bVar5 = null;
        }
        if (!z14) {
            return 10;
        }
        int i12 = 0;
        while (true) {
            byte[] bArr5 = f2972w;
            if (i12 < bArr5.length) {
                if (bArr[i12] != bArr5[i12]) {
                    z15 = false;
                    break;
                }
                i12++;
            } else {
                z15 = true;
                break;
            }
        }
        if (z15) {
            return 13;
        }
        int i13 = 0;
        while (true) {
            byte[] bArr6 = A;
            if (i13 < bArr6.length) {
                if (bArr[i13] != bArr6[i13]) {
                    break;
                }
                i13++;
            } else {
                int i14 = 0;
                while (true) {
                    byte[] bArr7 = B;
                    if (i14 < bArr7.length) {
                        if (bArr[bArr6.length + i14 + 4] != bArr7[i14]) {
                            break;
                        }
                        i14++;
                    } else {
                        z16 = true;
                        break;
                    }
                }
            }
        }
        z16 = false;
        if (!z16) {
            return 0;
        }
        return 14;
    }

    public final void g(f fVar) {
        long j5;
        c cVar;
        c cVar2;
        c cVar3;
        int i10;
        int i11;
        j(fVar);
        HashMap<String, c>[] hashMapArr = this.f2979d;
        c cVar4 = hashMapArr[1].get("MakerNote");
        if (cVar4 != null) {
            f fVar2 = new f(cVar4.f2990d);
            fVar2.B = this.f2981f;
            byte[] bArr = f2970u;
            byte[] bArr2 = new byte[bArr.length];
            fVar2.readFully(bArr2);
            fVar2.g(0L);
            byte[] bArr3 = f2971v;
            byte[] bArr4 = new byte[bArr3.length];
            fVar2.readFully(bArr4);
            if (Arrays.equals(bArr2, bArr)) {
                j5 = 8;
            } else {
                if (Arrays.equals(bArr4, bArr3)) {
                    j5 = 12;
                }
                s(fVar2, 6);
                cVar = hashMapArr[7].get("PreviewImageStart");
                cVar2 = hashMapArr[7].get("PreviewImageLength");
                if (cVar != null && cVar2 != null) {
                    hashMapArr[5].put("JPEGInterchangeFormat", cVar);
                    hashMapArr[5].put("JPEGInterchangeFormatLength", cVar2);
                }
                cVar3 = hashMapArr[8].get("AspectFrame");
                if (cVar3 == null) {
                    int[] iArr = (int[]) cVar3.h(this.f2981f);
                    if (iArr != null && iArr.length == 4) {
                        int i12 = iArr[2];
                        int i13 = iArr[0];
                        if (i12 > i13 && (i10 = iArr[3]) > (i11 = iArr[1])) {
                            int i14 = (i12 - i13) + 1;
                            int i15 = (i10 - i11) + 1;
                            if (i14 < i15) {
                                int i16 = i14 + i15;
                                i15 = i16 - i15;
                                i14 = i16 - i15;
                            }
                            c d10 = c.d(i14, this.f2981f);
                            c d11 = c.d(i15, this.f2981f);
                            hashMapArr[0].put("ImageWidth", d10);
                            hashMapArr[0].put("ImageLength", d11);
                            return;
                        }
                        return;
                    }
                    Log.w("ExifInterface", "Invalid aspect frame values. frame=" + Arrays.toString(iArr));
                    return;
                }
                return;
            }
            fVar2.g(j5);
            s(fVar2, 6);
            cVar = hashMapArr[7].get("PreviewImageStart");
            cVar2 = hashMapArr[7].get("PreviewImageLength");
            if (cVar != null) {
                hashMapArr[5].put("JPEGInterchangeFormat", cVar);
                hashMapArr[5].put("JPEGInterchangeFormatLength", cVar2);
            }
            cVar3 = hashMapArr[8].get("AspectFrame");
            if (cVar3 == null) {
            }
        }
    }

    public final void h(b bVar) {
        if (f2961l) {
            Log.d("ExifInterface", "getPngAttributes starting with: " + bVar);
        }
        bVar.B = ByteOrder.BIG_ENDIAN;
        byte[] bArr = f2972w;
        bVar.d(bArr.length);
        int length = bArr.length + 0;
        while (true) {
            try {
                int readInt = bVar.readInt();
                int i10 = length + 4;
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int i11 = i10 + 4;
                    if (i11 == 16 && !Arrays.equals(bArr2, f2974y)) {
                        throw new IOException("Encountered invalid PNG file--IHDR chunk should appearas the first chunk");
                    }
                    if (!Arrays.equals(bArr2, f2975z)) {
                        if (Arrays.equals(bArr2, f2973x)) {
                            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.f2983h = i11;
                                    r(0, bArr3);
                                    x();
                                    u(new b(bArr3));
                                    return;
                                }
                                throw new IOException("Encountered invalid CRC value for PNG-EXIF chunk.\n recorded CRC value: " + readInt2 + ", calculated CRC value: " + crc32.getValue());
                            }
                            throw new IOException("Failed to read given length for given PNG chunk type: " + c4.b.a(bArr2));
                        }
                        int i12 = readInt + 4;
                        bVar.d(i12);
                        length = i11 + i12;
                    } 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 i(b bVar) {
        boolean z10 = f2961l;
        if (z10) {
            Log.d("ExifInterface", "getRafAttributes starting with: " + bVar);
        }
        bVar.d(84);
        byte[] bArr = new byte[4];
        byte[] bArr2 = new byte[4];
        byte[] bArr3 = new byte[4];
        bVar.read(bArr);
        bVar.read(bArr2);
        bVar.read(bArr3);
        int i10 = ByteBuffer.wrap(bArr).getInt();
        int i11 = ByteBuffer.wrap(bArr2).getInt();
        int i12 = ByteBuffer.wrap(bArr3).getInt();
        byte[] bArr4 = new byte[i11];
        bVar.d(i10 - bVar.C);
        bVar.read(bArr4);
        e(new b(bArr4), i10, 5);
        bVar.d(i12 - bVar.C);
        bVar.B = ByteOrder.BIG_ENDIAN;
        int readInt = bVar.readInt();
        if (z10) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + readInt);
        }
        for (int i13 = 0; i13 < readInt; i13++) {
            int readUnsignedShort = bVar.readUnsignedShort();
            int readUnsignedShort2 = bVar.readUnsignedShort();
            if (readUnsignedShort == G.f2991a) {
                short readShort = bVar.readShort();
                short readShort2 = bVar.readShort();
                c d10 = c.d(readShort, this.f2981f);
                c d11 = c.d(readShort2, this.f2981f);
                HashMap<String, c>[] hashMapArr = this.f2979d;
                hashMapArr[0].put("ImageLength", d10);
                hashMapArr[0].put("ImageWidth", d11);
                if (z10) {
                    Log.d("ExifInterface", "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2));
                    return;
                }
                return;
            }
            bVar.d(readUnsignedShort2);
        }
    }

    public final void j(f fVar) {
        o(fVar);
        s(fVar, 0);
        w(fVar, 0);
        w(fVar, 5);
        w(fVar, 4);
        x();
        if (this.f2978c == 8) {
            HashMap<String, c>[] hashMapArr = this.f2979d;
            c cVar = hashMapArr[1].get("MakerNote");
            if (cVar != null) {
                f fVar2 = new f(cVar.f2990d);
                fVar2.B = this.f2981f;
                fVar2.d(6);
                s(fVar2, 9);
                c cVar2 = hashMapArr[9].get("ColorSpace");
                if (cVar2 != null) {
                    hashMapArr[1].put("ColorSpace", cVar2);
                }
            }
        }
    }

    public final void k(f fVar) {
        if (f2961l) {
            Log.d("ExifInterface", "getRw2Attributes starting with: " + fVar);
        }
        j(fVar);
        HashMap<String, c>[] hashMapArr = this.f2979d;
        c cVar = hashMapArr[0].get("JpgFromRaw");
        if (cVar != null) {
            e(new b(cVar.f2990d), (int) cVar.f2989c, 5);
        }
        c cVar2 = hashMapArr[0].get("ISO");
        c cVar3 = hashMapArr[1].get("PhotographicSensitivity");
        if (cVar2 == null || cVar3 != null) {
            return;
        }
        hashMapArr[1].put("PhotographicSensitivity", cVar2);
    }

    public final void l(b bVar) {
        if (f2961l) {
            Log.d("ExifInterface", "getWebpAttributes starting with: " + bVar);
        }
        bVar.B = ByteOrder.LITTLE_ENDIAN;
        bVar.d(A.length);
        int readInt = bVar.readInt() + 8;
        byte[] bArr = B;
        bVar.d(bArr.length);
        int length = bArr.length + 8;
        while (true) {
            try {
                byte[] bArr2 = new byte[4];
                if (bVar.read(bArr2) == 4) {
                    int readInt2 = bVar.readInt();
                    int i10 = length + 4 + 4;
                    if (Arrays.equals(C, bArr2)) {
                        byte[] bArr3 = new byte[readInt2];
                        if (bVar.read(bArr3) == readInt2) {
                            this.f2983h = i10;
                            r(0, bArr3);
                            u(new b(bArr3));
                            return;
                        } else {
                            throw new IOException("Failed to read given length for given PNG chunk type: " + c4.b.a(bArr2));
                        }
                    }
                    if (readInt2 % 2 == 1) {
                        readInt2++;
                    }
                    length = i10 + readInt2;
                    if (length == readInt) {
                        return;
                    }
                    if (length <= readInt) {
                        bVar.d(readInt2);
                    } else {
                        throw new IOException("Encountered WebP file with invalid chunk size");
                    }
                } else {
                    throw new IOException("Encountered invalid length while parsing WebP chunktype");
                }
            } catch (EOFException unused) {
                throw new IOException("Encountered corrupt WebP file.");
            }
        }
    }

    public final void m(b bVar, HashMap hashMap) {
        c cVar = (c) hashMap.get("JPEGInterchangeFormat");
        c cVar2 = (c) hashMap.get("JPEGInterchangeFormatLength");
        if (cVar == null || cVar2 == null) {
            return;
        }
        int f10 = cVar.f(this.f2981f);
        int f11 = cVar2.f(this.f2981f);
        if (this.f2978c == 7) {
            f10 += this.f2984i;
        }
        if (f10 > 0 && f11 > 0 && this.f2977b == null && this.f2976a == null) {
            bVar.skip(f10);
            bVar.read(new byte[f11]);
        }
        if (f2961l) {
            Log.d("ExifInterface", "Setting thumbnail attributes with offset: " + f10 + ", length: " + f11);
        }
    }

    public final boolean n(HashMap hashMap) {
        c cVar = (c) hashMap.get("ImageLength");
        c cVar2 = (c) hashMap.get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            return false;
        }
        return cVar.f(this.f2981f) <= 512 && cVar2.f(this.f2981f) <= 512;
    }

    public final void o(b bVar) {
        ByteOrder q10 = q(bVar);
        this.f2981f = q10;
        bVar.B = q10;
        int readUnsignedShort = bVar.readUnsignedShort();
        int i10 = this.f2978c;
        if (i10 != 7 && i10 != 10 && readUnsignedShort != 42) {
            throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort));
        }
        int readInt = bVar.readInt();
        if (readInt >= 8) {
            int i11 = readInt - 8;
            if (i11 > 0) {
                bVar.d(i11);
                return;
            }
            return;
        }
        throw new IOException(d0.a.c("Invalid first Ifd offset: ", readInt));
    }

    public final void p() {
        int i10 = 0;
        while (true) {
            HashMap<String, c>[] hashMapArr = this.f2979d;
            if (i10 < hashMapArr.length) {
                StringBuilder b10 = u2.b("The size of tag group[", i10, "]: ");
                b10.append(hashMapArr[i10].size());
                Log.d("ExifInterface", b10.toString());
                for (Map.Entry<String, c> entry : hashMapArr[i10].entrySet()) {
                    c value = entry.getValue();
                    Log.d("ExifInterface", "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.g(this.f2981f) + "'");
                }
                i10++;
            } else {
                return;
            }
        }
    }

    public final void r(int i10, byte[] bArr) {
        f fVar = new f(bArr);
        o(fVar);
        s(fVar, i10);
    }

    public final void s(f fVar, int i10) {
        HashMap<String, c>[] hashMapArr;
        StringBuilder sb2;
        int i11;
        short s4;
        short s10;
        long j5;
        HashSet hashSet;
        StringBuilder sb3;
        boolean z10;
        long j10;
        boolean z11;
        int i12;
        HashSet hashSet2;
        d dVar;
        int i13;
        HashSet hashSet3;
        String str;
        boolean z12;
        long j11;
        int readUnsignedShort;
        long j12;
        StringBuilder sb4;
        String str2;
        int i14 = i10;
        Integer valueOf = Integer.valueOf(fVar.C);
        HashSet hashSet4 = this.f2980e;
        hashSet4.add(valueOf);
        short readShort = fVar.readShort();
        String str3 = "ExifInterface";
        boolean z13 = f2961l;
        if (z13) {
            Log.d("ExifInterface", "numberOfDirectoryEntry: " + ((int) readShort));
        }
        if (readShort <= 0) {
            return;
        }
        short s11 = 0;
        while (true) {
            hashMapArr = this.f2979d;
            if (s11 >= readShort) {
                break;
            }
            int readUnsignedShort2 = fVar.readUnsignedShort();
            int readUnsignedShort3 = fVar.readUnsignedShort();
            int readInt = fVar.readInt();
            long j13 = fVar.C + 4;
            d dVar2 = J[i14].get(Integer.valueOf(readUnsignedShort2));
            if (z13) {
                Object[] objArr = new Object[5];
                objArr[0] = Integer.valueOf(i10);
                objArr[1] = Integer.valueOf(readUnsignedShort2);
                s4 = readShort;
                if (dVar2 != null) {
                    str2 = dVar2.f2992b;
                } else {
                    str2 = null;
                }
                objArr[2] = str2;
                objArr[3] = Integer.valueOf(readUnsignedShort3);
                objArr[4] = Integer.valueOf(readInt);
                Log.d(str3, String.format("ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d", objArr));
            } else {
                s4 = readShort;
            }
            if (dVar2 == null) {
                if (z13) {
                    Log.d(str3, "Skip the tag entry since tag number is not defined: " + readUnsignedShort2);
                }
                s10 = s11;
                j5 = j13;
            } else {
                if (readUnsignedShort3 > 0) {
                    if (readUnsignedShort3 < E.length) {
                        int i15 = dVar2.f2993c;
                        s10 = s11;
                        if (i15 != 7 && readUnsignedShort3 != 7 && i15 != readUnsignedShort3 && (i12 = dVar2.f2994d) != readUnsignedShort3) {
                            j5 = j13;
                            if (((i15 != 4 && i12 != 4) || readUnsignedShort3 != 3) && (((i15 != 9 && i12 != 9) || readUnsignedShort3 != 8) && ((i15 != 12 && i12 != 12) || readUnsignedShort3 != 11))) {
                                z10 = false;
                                if (z10) {
                                    if (z13) {
                                        sb3 = new StringBuilder("Skip the tag entry since data format (");
                                        sb3.append(D[readUnsignedShort3]);
                                        sb3.append(") is unexpected for tag: ");
                                        sb3.append(dVar2.f2992b);
                                        hashSet = hashSet4;
                                        Log.d(str3, sb3.toString());
                                        j10 = 0;
                                        z11 = false;
                                        if (!z11) {
                                            str = str3;
                                            z12 = z13;
                                            hashSet3 = hashSet;
                                            j11 = j5;
                                        } else {
                                            if (j10 > 4) {
                                                int readInt2 = fVar.readInt();
                                                if (z13) {
                                                    hashSet2 = hashSet;
                                                    Log.d(str3, "seek to data offset: " + readInt2);
                                                } else {
                                                    hashSet2 = hashSet;
                                                }
                                                if (this.f2978c == 7) {
                                                    if ("MakerNote".equals(dVar2.f2992b)) {
                                                        this.f2984i = readInt2;
                                                    } else if (i14 == 6 && "ThumbnailImage".equals(dVar2.f2992b)) {
                                                        this.f2985j = readInt2;
                                                        this.f2986k = readInt;
                                                        c d10 = c.d(6, this.f2981f);
                                                        i13 = readInt;
                                                        c b10 = c.b(this.f2985j, this.f2981f);
                                                        dVar = dVar2;
                                                        c b11 = c.b(this.f2986k, this.f2981f);
                                                        hashMapArr[4].put("Compression", d10);
                                                        hashMapArr[4].put("JPEGInterchangeFormat", b10);
                                                        hashMapArr[4].put("JPEGInterchangeFormatLength", b11);
                                                        fVar.g(readInt2);
                                                    }
                                                }
                                                dVar = dVar2;
                                                i13 = readInt;
                                                fVar.g(readInt2);
                                            } else {
                                                hashSet2 = hashSet;
                                                dVar = dVar2;
                                                i13 = readInt;
                                            }
                                            Integer num = M.get(Integer.valueOf(readUnsignedShort2));
                                            if (z13) {
                                                Log.d(str3, "nextIfdType: " + num + " byteCount: " + j10);
                                            }
                                            if (num != null) {
                                                if (readUnsignedShort3 != 3) {
                                                    if (readUnsignedShort3 != 4) {
                                                        if (readUnsignedShort3 != 8) {
                                                            if (readUnsignedShort3 != 9 && readUnsignedShort3 != 13) {
                                                                j12 = -1;
                                                            } else {
                                                                readUnsignedShort = fVar.readInt();
                                                            }
                                                        } else {
                                                            readUnsignedShort = fVar.readShort();
                                                        }
                                                    } else {
                                                        j12 = fVar.readInt() & 4294967295L;
                                                    }
                                                    if (z13) {
                                                        Log.d(str3, String.format("Offset: %d, tagName: %s", Long.valueOf(j12), dVar.f2992b));
                                                    }
                                                    if (j12 <= 0) {
                                                        hashSet3 = hashSet2;
                                                        if (!hashSet3.contains(Integer.valueOf((int) j12))) {
                                                            fVar.g(j12);
                                                            s(fVar, num.intValue());
                                                        } else if (z13) {
                                                            sb4 = new StringBuilder("Skip jump into the IFD since it has already been read: IfdType ");
                                                            sb4.append(num);
                                                            sb4.append(" (at ");
                                                            sb4.append(j12);
                                                            sb4.append(")");
                                                            Log.d(str3, sb4.toString());
                                                        }
                                                        fVar.g(j5);
                                                        str = str3;
                                                        z12 = z13;
                                                    } else {
                                                        hashSet3 = hashSet2;
                                                        if (z13) {
                                                            sb4 = new StringBuilder("Skip jump into the IFD since its offset is invalid: ");
                                                            sb4.append(j12);
                                                            Log.d(str3, sb4.toString());
                                                        }
                                                        fVar.g(j5);
                                                        str = str3;
                                                        z12 = z13;
                                                    }
                                                } else {
                                                    readUnsignedShort = fVar.readUnsignedShort();
                                                }
                                                j12 = readUnsignedShort;
                                                if (z13) {
                                                }
                                                if (j12 <= 0) {
                                                }
                                            } else {
                                                hashSet3 = hashSet2;
                                                d dVar3 = dVar;
                                                int i16 = fVar.C + this.f2983h;
                                                byte[] bArr = new byte[(int) j10];
                                                fVar.readFully(bArr);
                                                long j14 = i16;
                                                str = str3;
                                                z12 = z13;
                                                j11 = j5;
                                                c cVar = new c(j14, bArr, readUnsignedShort3, i13);
                                                hashMapArr[i10].put(dVar3.f2992b, cVar);
                                                String str4 = dVar3.f2992b;
                                                if ("DNGVersion".equals(str4)) {
                                                    this.f2978c = 3;
                                                }
                                                if ((("Make".equals(str4) || "Model".equals(str4)) && cVar.g(this.f2981f).contains("PENTAX")) || ("Compression".equals(str4) && cVar.f(this.f2981f) == 65535)) {
                                                    this.f2978c = 8;
                                                }
                                                if (fVar.C == j11) {
                                                }
                                            }
                                            s11 = (short) (s10 + 1);
                                            str3 = str;
                                            hashSet4 = hashSet3;
                                            readShort = s4;
                                            z13 = z12;
                                            i14 = i10;
                                        }
                                        fVar.g(j11);
                                        s11 = (short) (s10 + 1);
                                        str3 = str;
                                        hashSet4 = hashSet3;
                                        readShort = s4;
                                        z13 = z12;
                                        i14 = i10;
                                    }
                                } else {
                                    if (readUnsignedShort3 == 7) {
                                        readUnsignedShort3 = i15;
                                    }
                                    hashSet = hashSet4;
                                    j10 = r3[readUnsignedShort3] * readInt;
                                    if (j10 >= 0 && j10 <= 2147483647L) {
                                        z11 = true;
                                        if (!z11) {
                                        }
                                        fVar.g(j11);
                                        s11 = (short) (s10 + 1);
                                        str3 = str;
                                        hashSet4 = hashSet3;
                                        readShort = s4;
                                        z13 = z12;
                                        i14 = i10;
                                    } else {
                                        if (z13) {
                                            Log.d(str3, "Skip the tag entry since the number of components is invalid: " + readInt);
                                        }
                                        z11 = false;
                                        if (!z11) {
                                        }
                                        fVar.g(j11);
                                        s11 = (short) (s10 + 1);
                                        str3 = str;
                                        hashSet4 = hashSet3;
                                        readShort = s4;
                                        z13 = z12;
                                        i14 = i10;
                                    }
                                }
                            }
                        } else {
                            j5 = j13;
                        }
                        z10 = true;
                        if (z10) {
                        }
                    }
                }
                s10 = s11;
                j5 = j13;
                hashSet = hashSet4;
                if (z13) {
                    sb3 = new StringBuilder("Skip the tag entry since data format is invalid: ");
                    sb3.append(readUnsignedShort3);
                    Log.d(str3, sb3.toString());
                }
                j10 = 0;
                z11 = false;
                if (!z11) {
                }
                fVar.g(j11);
                s11 = (short) (s10 + 1);
                str3 = str;
                hashSet4 = hashSet3;
                readShort = s4;
                z13 = z12;
                i14 = i10;
            }
            hashSet = hashSet4;
            j10 = 0;
            z11 = false;
            if (!z11) {
            }
            fVar.g(j11);
            s11 = (short) (s10 + 1);
            str3 = str;
            hashSet4 = hashSet3;
            readShort = s4;
            z13 = z12;
            i14 = i10;
        }
        HashSet hashSet5 = hashSet4;
        String str5 = str3;
        boolean z14 = z13;
        int readInt3 = fVar.readInt();
        if (z14) {
            Log.d(str5, String.format("nextIfdOffset: %d", Integer.valueOf(readInt3)));
        }
        long j15 = readInt3;
        if (j15 > 0) {
            if (!hashSet5.contains(Integer.valueOf(readInt3))) {
                fVar.g(j15);
                if (hashMapArr[4].isEmpty()) {
                    i11 = 4;
                } else if (hashMapArr[5].isEmpty()) {
                    i11 = 5;
                } else {
                    return;
                }
                s(fVar, i11);
                return;
            }
            if (z14) {
                sb2 = new StringBuilder("Stop reading file since re-reading an IFD may cause an infinite loop: ");
            } else {
                return;
            }
        } else if (z14) {
            sb2 = new StringBuilder("Stop reading file since a wrong offset may cause an infinite loop: ");
        } else {
            return;
        }
        sb2.append(readInt3);
        Log.d(str5, sb2.toString());
    }

    public final void t(int i10, String str, String str2) {
        HashMap<String, c>[] hashMapArr = this.f2979d;
        if (hashMapArr[i10].isEmpty() || hashMapArr[i10].get(str) == null) {
            return;
        }
        HashMap<String, c> hashMap = hashMapArr[i10];
        hashMap.put(str2, hashMap.get(str));
        hashMapArr[i10].remove(str);
    }

    public final void u(b bVar) {
        boolean z10;
        String str;
        String str2;
        StringBuilder sb2;
        c cVar;
        int f10;
        HashMap<String, c> hashMap = this.f2979d[4];
        c cVar2 = hashMap.get("Compression");
        if (cVar2 != null) {
            int f11 = cVar2.f(this.f2981f);
            if (f11 != 1) {
                if (f11 != 6) {
                    if (f11 != 7) {
                        return;
                    }
                }
            }
            c cVar3 = hashMap.get("BitsPerSample");
            if (cVar3 != null) {
                int[] iArr = (int[]) cVar3.h(this.f2981f);
                int[] iArr2 = f2964o;
                if (Arrays.equals(iArr2, iArr) || (this.f2978c == 3 && (cVar = hashMap.get("PhotometricInterpretation")) != null && (((f10 = cVar.f(this.f2981f)) == 1 && Arrays.equals(iArr, f2965p)) || (f10 == 6 && Arrays.equals(iArr, iArr2))))) {
                    z10 = true;
                    if (!z10) {
                        c cVar4 = hashMap.get("StripOffsets");
                        c cVar5 = hashMap.get("StripByteCounts");
                        if (cVar4 != null && cVar5 != null) {
                            long[] b10 = c4.b.b(cVar4.h(this.f2981f));
                            long[] b11 = c4.b.b(cVar5.h(this.f2981f));
                            if (b10 != null && b10.length != 0) {
                                if (b11 != null && b11.length != 0) {
                                    if (b10.length != b11.length) {
                                        str = "stripOffsets and stripByteCounts should have same length.";
                                    } else {
                                        long j5 = 0;
                                        for (long j10 : b11) {
                                            j5 += j10;
                                        }
                                        byte[] bArr = new byte[(int) j5];
                                        this.f2982g = true;
                                        int i10 = 0;
                                        int i11 = 0;
                                        for (int i12 = 0; i12 < b10.length; i12++) {
                                            int i13 = (int) b10[i12];
                                            int i14 = (int) b11[i12];
                                            if (i12 < b10.length - 1 && i13 + i14 != b10[i12 + 1]) {
                                                this.f2982g = false;
                                            }
                                            int i15 = i13 - i10;
                                            if (i15 < 0) {
                                                str2 = "Invalid strip offset value";
                                            } else {
                                                long j11 = i15;
                                                if (bVar.skip(j11) != j11) {
                                                    sb2 = new StringBuilder("Failed to skip ");
                                                    sb2.append(i15);
                                                } else {
                                                    int i16 = i10 + i15;
                                                    byte[] bArr2 = new byte[i14];
                                                    if (bVar.read(bArr2) != i14) {
                                                        sb2 = new StringBuilder("Failed to read ");
                                                        sb2.append(i14);
                                                    } else {
                                                        i10 = i16 + i14;
                                                        System.arraycopy(bArr2, 0, bArr, i11, i14);
                                                        i11 += i14;
                                                    }
                                                }
                                                sb2.append(" bytes.");
                                                str2 = sb2.toString();
                                            }
                                            Log.d("ExifInterface", str2);
                                            return;
                                        }
                                        if (this.f2982g) {
                                            long j12 = b10[0];
                                            return;
                                        }
                                        return;
                                    }
                                } else {
                                    str = "stripByteCounts should not be null or have zero length.";
                                }
                            } else {
                                str = "stripOffsets should not be null or have zero length.";
                            }
                            Log.w("ExifInterface", str);
                            return;
                        }
                        return;
                    }
                    return;
                }
            }
            if (f2961l) {
                Log.d("ExifInterface", "Unsupported data type value");
            }
            z10 = false;
            if (!z10) {
            }
        }
        m(bVar, hashMap);
    }

    public final void v(int i10, int i11) {
        String str;
        HashMap<String, c>[] hashMapArr = this.f2979d;
        boolean isEmpty = hashMapArr[i10].isEmpty();
        boolean z10 = f2961l;
        if (isEmpty || hashMapArr[i11].isEmpty()) {
            if (z10) {
                Log.d("ExifInterface", "Cannot perform swap since only one image data exists");
                return;
            }
            return;
        }
        c cVar = hashMapArr[i10].get("ImageLength");
        c cVar2 = hashMapArr[i10].get("ImageWidth");
        c cVar3 = hashMapArr[i11].get("ImageLength");
        c cVar4 = hashMapArr[i11].get("ImageWidth");
        if (cVar == null || cVar2 == null) {
            if (!z10) {
                return;
            } else {
                str = "First image does not contain valid size information";
            }
        } else {
            if (cVar3 != null && cVar4 != null) {
                int f10 = cVar.f(this.f2981f);
                int f11 = cVar2.f(this.f2981f);
                int f12 = cVar3.f(this.f2981f);
                int f13 = cVar4.f(this.f2981f);
                if (f10 >= f12 || f11 >= f13) {
                    return;
                }
                HashMap<String, c> hashMap = hashMapArr[i10];
                hashMapArr[i10] = hashMapArr[i11];
                hashMapArr[i11] = hashMap;
                return;
            }
            if (!z10) {
                return;
            } else {
                str = "Second image does not contain valid size information";
            }
        }
        Log.d("ExifInterface", str);
    }

    public final void w(f fVar, int i10) {
        StringBuilder sb2;
        String arrays;
        c d10;
        c d11;
        HashMap<String, c>[] hashMapArr = this.f2979d;
        c cVar = hashMapArr[i10].get("DefaultCropSize");
        c cVar2 = hashMapArr[i10].get("SensorTopBorder");
        c cVar3 = hashMapArr[i10].get("SensorLeftBorder");
        c cVar4 = hashMapArr[i10].get("SensorBottomBorder");
        c cVar5 = hashMapArr[i10].get("SensorRightBorder");
        if (cVar != null) {
            if (cVar.f2987a == 5) {
                e[] eVarArr = (e[]) cVar.h(this.f2981f);
                if (eVarArr != null && eVarArr.length == 2) {
                    d10 = c.c(eVarArr[0], this.f2981f);
                    d11 = c.c(eVarArr[1], this.f2981f);
                    hashMapArr[i10].put("ImageWidth", d10);
                    hashMapArr[i10].put("ImageLength", d11);
                    return;
                }
                sb2 = new StringBuilder("Invalid crop size values. cropSize=");
                arrays = Arrays.toString(eVarArr);
                sb2.append(arrays);
                Log.w("ExifInterface", sb2.toString());
                return;
            }
            int[] iArr = (int[]) cVar.h(this.f2981f);
            if (iArr != null && iArr.length == 2) {
                d10 = c.d(iArr[0], this.f2981f);
                d11 = c.d(iArr[1], this.f2981f);
                hashMapArr[i10].put("ImageWidth", d10);
                hashMapArr[i10].put("ImageLength", d11);
                return;
            }
            sb2 = new StringBuilder("Invalid crop size values. cropSize=");
            arrays = Arrays.toString(iArr);
            sb2.append(arrays);
            Log.w("ExifInterface", sb2.toString());
            return;
        }
        if (cVar2 != null && cVar3 != null && cVar4 != null && cVar5 != null) {
            int f10 = cVar2.f(this.f2981f);
            int f11 = cVar4.f(this.f2981f);
            int f12 = cVar5.f(this.f2981f);
            int f13 = cVar3.f(this.f2981f);
            if (f11 > f10 && f12 > f13) {
                c d12 = c.d(f11 - f10, this.f2981f);
                c d13 = c.d(f12 - f13, this.f2981f);
                hashMapArr[i10].put("ImageLength", d12);
                hashMapArr[i10].put("ImageWidth", d13);
                return;
            }
            return;
        }
        c cVar6 = hashMapArr[i10].get("ImageLength");
        c cVar7 = hashMapArr[i10].get("ImageWidth");
        if (cVar6 == null || cVar7 == null) {
            c cVar8 = hashMapArr[i10].get("JPEGInterchangeFormat");
            c cVar9 = hashMapArr[i10].get("JPEGInterchangeFormatLength");
            if (cVar8 != null && cVar9 != null) {
                int f14 = cVar8.f(this.f2981f);
                int f15 = cVar8.f(this.f2981f);
                fVar.g(f14);
                byte[] bArr = new byte[f15];
                fVar.read(bArr);
                e(new b(bArr), f14, i10);
            }
        }
    }

    public final void x() {
        v(0, 5);
        v(0, 4);
        v(5, 4);
        HashMap<String, c>[] hashMapArr = this.f2979d;
        c cVar = hashMapArr[1].get("PixelXDimension");
        c cVar2 = hashMapArr[1].get("PixelYDimension");
        if (cVar != null && cVar2 != null) {
            hashMapArr[0].put("ImageWidth", cVar);
            hashMapArr[0].put("ImageLength", cVar2);
        }
        if (hashMapArr[4].isEmpty() && n(hashMapArr[5])) {
            hashMapArr[4] = hashMapArr[5];
            hashMapArr[5] = new HashMap<>();
        }
        if (!n(hashMapArr[4])) {
            Log.d("ExifInterface", "No image meets the size requirements of a thumbnail image.");
        }
        t(0, "ThumbnailOrientation", "Orientation");
        t(0, "ThumbnailImageLength", "ImageLength");
        t(0, "ThumbnailImageWidth", "ImageWidth");
        t(5, "ThumbnailOrientation", "Orientation");
        t(5, "ThumbnailImageLength", "ImageLength");
        t(5, "ThumbnailImageWidth", "ImageWidth");
        t(4, "Orientation", "ThumbnailOrientation");
        t(4, "ImageLength", "ThumbnailImageLength");
        t(4, "ImageWidth", "ThumbnailImageWidth");
    }
}