package com.google.android.play.core.assetpacks;

import android.content.Context;
import android.util.Base64;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.android.play.core.b.an;
import com.google.android.play.core.b.bf;
import com.google.android.play.core.d.q;
import java.io.File;
import java.io.FileInputStream;
import java.security.MessageDigest;
import java.util.List;

public final class bw {
    public static e LIZ;

    static {
        Covode.recordClassIndex(44156);
    }

    public static long LIZ(byte[] bArr, int i) {
        return ((long) ((LIZIZ(bArr, i + 2) << 16) | LIZIZ(bArr, i))) & 4294967295L;
    }

    public static String LIZ(List<File> list) {
        int read;
        MethodCollector.i(12128);
        MessageDigest instance = MessageDigest.getInstance("SHA256");
        byte[] bArr = new byte[8192];
        for (File fileInputStream : list) {
            FileInputStream fileInputStream2 = new FileInputStream(fileInputStream);
            do {
                try {
                    read = fileInputStream2.read(bArr);
                    if (read > 0) {
                        instance.update(bArr, 0, read);
                    }
                } catch (Throwable th) {
                    bf.LIZ(th, th);
                }
            } while (read != -1);
            fileInputStream2.close();
        }
        String encodeToString = Base64.encodeToString(instance.digest(), 11);
        MethodCollector.o(12128);
        return encodeToString;
        MethodCollector.o(12128);
        throw th;
    }

    public static boolean LIZ(int i) {
        return i == 1 || i == 7 || i == 2 || i == 3;
    }

    public static boolean LIZ(int i, int i2) {
        if (i == 5) {
            return i2 != 5;
        }
        if (i == 6) {
            return (i2 == 6 || i2 == 5) ? false : true;
        }
        if (i == 4) {
            return i2 != 4;
        }
        if (i == 3) {
            return i2 == 2 || i2 == 7 || i2 == 1 || i2 == 8;
        }
        if (i == 2) {
            return i2 == 1 || i2 == 8;
        }
        return false;
    }

    public static int LIZIZ(byte[] bArr, int i) {
        return ((bArr[i + 1] & 255) << 8) | (bArr[i] & 255);
    }

    public static boolean LIZIZ(int i) {
        return i == 5 || i == 6 || i == 4;
    }

    public static boolean LIZJ(int i) {
        return i == 2 || i == 7 || i == 3;
    }

    public static synchronized e LIZ(Context context) {
        e eVar;
        synchronized (bw.class) {
            MethodCollector.i(12574);
            if (LIZ == null) {
                ap apVar = new ap((byte) 0);
                apVar.LIZ = new db(q.LIZ(context));
                an.LIZ(apVar.LIZ, db.class);
                LIZ = new aq(apVar.LIZ);
            }
            eVar = LIZ;
            MethodCollector.o(12574);
        }
        return eVar;
    }
}
