package com.google.android.play.core.e.b;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.android.play.core.b.at;
import com.google.android.play.core.d.q;
import com.google.android.play.core.e.aa;
import com.google.android.play.core.e.ad;
import com.google.android.play.core.e.ah;
import com.google.android.play.core.e.al;
import com.google.android.play.core.e.c;
import com.google.android.play.core.e.f;
import com.google.android.play.core.tasks.e;
import com.google.android.play.core.tasks.g;
import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

public final class a implements c {
    public static final long LIZ = TimeUnit.SECONDS.toMillis(1);
    public final Context LIZIZ;
    public final com.google.android.play.core.b.a<f> LIZJ;
    public final com.google.android.play.core.b.a<f> LIZLLL;
    public final Executor LJ;
    public final File LJFF;
    public final Set<String> LJI = Collections.synchronizedSet(new HashSet());
    public final Set<String> LJII = Collections.synchronizedSet(new HashSet());
    public final AtomicBoolean LJIIIIZZ = new AtomicBoolean(false);
    public final Handler LJIIIZ = new Handler(Looper.getMainLooper());
    public final al LJIIJ;
    public final at LJIIJJI;
    public final aa LJIIL;
    public final AtomicReference<f> LJIILIIL = new AtomicReference<>();
    public final b LJIILJJIL;

    static {
        Covode.recordClassIndex(44361);
    }

    public a(Context context, File file, al alVar) {
        Executor LIZ2 = q.LIZ();
        at atVar = new at(context);
        b bVar = b.LIZ;
        this.LIZIZ = context;
        this.LJFF = file;
        this.LJIIJ = alVar;
        this.LJ = LIZ2;
        this.LJIIJJI = atVar;
        this.LJIILJJIL = bVar;
        this.LIZLLL = new com.google.android.play.core.b.a<>();
        this.LIZJ = new com.google.android.play.core.b.a<>();
        this.LJIIL = ah.a;
    }

    private final synchronized f LIZ(l lVar) {
        MethodCollector.i(12836);
        f LIZLLL2 = LIZLLL();
        f LIZ2 = lVar.LIZ(LIZLLL2);
        if (this.LJIILIIL.compareAndSet(LIZLLL2, LIZ2)) {
            MethodCollector.o(12836);
            return LIZ2;
        }
        MethodCollector.o(12836);
        return null;
    }

    public static String LIZ(String str) {
        return str.split("\\.config\\.", 2)[0];
    }

    private final void LIZ(f fVar) {
        this.LJIIIZ.post(new h(this, fVar));
    }

    private final e<Integer> LIZJ(int i) {
        LIZ((l) new e(i));
        return g.LIZ((Exception) new com.google.android.play.core.e.a(i));
    }

    private final ad LJ() {
        ad LIZJ2 = this.LJIIJ.LIZJ();
        if (LIZJ2 != null) {
            return LIZJ2;
        }
        throw new IllegalStateException("Language information could not be found. Make sure you are using the target application context, not the tests context, and the app is built as a bundle.");
    }

    public final e<List<f>> LIZ() {
        f LIZLLL2 = LIZLLL();
        return g.LIZ(LIZLLL2 != null ? Collections.singletonList(LIZLLL2) : Collections.emptyList());
    }

    public final e<Void> LIZ(int i) {
        try {
            f LIZ2 = LIZ((l) new g(i));
            if (LIZ2 != null) {
                LIZ(LIZ2);
            }
            return g.LIZ(null);
        } catch (com.google.android.play.core.e.a e) {
            return g.LIZ((Exception) e);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:45:0x0159, code lost:
        if (r11.contains(r1) == false) goto L_0x0104;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final com.google.android.play.core.tasks.e<java.lang.Integer> LIZ(com.google.android.play.core.e.e r21) {
        /*
            r20 = this;
            r2 = r20
            com.google.android.play.core.e.b.f r0 = new com.google.android.play.core.e.b.f     // Catch:{ a -> 0x01c2 }
            r6 = r21
            r0.<init>(r6)     // Catch:{ a -> 0x01c2 }
            com.google.android.play.core.e.f r0 = r2.LIZ((com.google.android.play.core.e.b.l) r0)     // Catch:{ a -> 0x01c2 }
            if (r0 == 0) goto L_0x01bb
            int r19 = r0.LIZ()     // Catch:{ a -> 0x01c2 }
            java.util.ArrayList r4 = new java.util.ArrayList
            r4.<init>()
            java.util.List<java.util.Locale> r0 = r6.LIZIZ
            java.util.Iterator r1 = r0.iterator()
        L_0x001e:
            boolean r0 = r1.hasNext()
            if (r0 == 0) goto L_0x0032
            java.lang.Object r0 = r1.next()
            java.util.Locale r0 = (java.util.Locale) r0
            java.lang.String r0 = r0.getLanguage()
            r4.add(r0)
            goto L_0x001e
        L_0x0032:
            java.util.HashSet r7 = new java.util.HashSet
            r7.<init>()
            java.util.ArrayList r3 = new java.util.ArrayList
            r3.<init>()
            java.io.File r0 = r2.LJFF
            java.io.File[] r10 = r0.listFiles()
            if (r10 != 0) goto L_0x004a
            r0 = -5
            com.google.android.play.core.tasks.e r0 = r2.LIZJ(r0)
            return r0
        L_0x004a:
            int r9 = r10.length
            r8 = 0
            r17 = 0
        L_0x004e:
            if (r8 >= r9) goto L_0x0168
            r5 = r10[r8]
            java.lang.String r1 = com.google.android.play.core.b.r.LIZ(r5)
            java.lang.String r11 = LIZ((java.lang.String) r1)
            r7.add(r1)
            java.util.List<java.lang.String> r0 = r6.LIZ
            boolean r0 = r0.contains(r11)
            if (r0 == 0) goto L_0x0104
            java.lang.String r13 = LIZ((java.lang.String) r1)
            java.util.HashSet r14 = new java.util.HashSet
            com.google.android.play.core.b.at r0 = r2.LJIIJJI
            java.util.List r0 = r0.LIZ()
            r14.<init>(r0)
            com.google.android.play.core.e.ad r12 = r20.LJ()
            r0 = 1
            java.lang.String[] r11 = new java.lang.String[r0]
            r0 = 0
            r11[r0] = r13
            java.util.List r0 = java.util.Arrays.asList(r11)
            java.util.Map r16 = r12.LIZ(r0)
            java.util.HashSet r13 = new java.util.HashSet
            r13.<init>()
            java.util.Collection r0 = r16.values()
            java.util.Iterator r11 = r0.iterator()
        L_0x0093:
            boolean r0 = r11.hasNext()
            if (r0 == 0) goto L_0x00a3
            java.lang.Object r0 = r11.next()
            java.util.Collection r0 = (java.util.Collection) r0
            r13.addAll(r0)
            goto L_0x0093
        L_0x00a3:
            java.util.HashSet r12 = new java.util.HashSet
            r12.<init>()
            java.util.Iterator r15 = r14.iterator()
        L_0x00ac:
            boolean r0 = r15.hasNext()
            if (r0 == 0) goto L_0x00ce
            java.lang.Object r11 = r15.next()
            java.lang.String r11 = (java.lang.String) r11
            java.lang.String r14 = "_"
            boolean r0 = r11.contains(r14)
            if (r0 == 0) goto L_0x00cc
            r0 = -1
            java.lang.String[] r11 = r11.split(r14, r0)
            r0 = 0
            r11 = r11[r0]
        L_0x00c8:
            r12.add(r11)
            goto L_0x00ac
        L_0x00cc:
            r0 = 0
            goto L_0x00c8
        L_0x00ce:
            r0 = 0
            java.util.Set<java.lang.String> r0 = r2.LJII
            r12.addAll(r0)
            r12.addAll(r4)
            java.util.HashSet r11 = new java.util.HashSet
            r11.<init>()
            java.util.Set r0 = r16.entrySet()
            java.util.Iterator r15 = r0.iterator()
        L_0x00e4:
            boolean r0 = r15.hasNext()
            if (r0 == 0) goto L_0x014f
            java.lang.Object r14 = r15.next()
            java.util.Map$Entry r14 = (java.util.Map.Entry) r14
            java.lang.Object r0 = r14.getKey()
            boolean r0 = r12.contains(r0)
            if (r0 == 0) goto L_0x00e4
            java.lang.Object r0 = r14.getValue()
            java.util.Collection r0 = (java.util.Collection) r0
            r11.addAll(r0)
            goto L_0x00e4
        L_0x0104:
            java.util.List<java.util.Locale> r12 = r6.LIZIZ
            java.util.ArrayList r11 = new java.util.ArrayList
            java.util.Set<java.lang.String> r0 = r2.LJI
            r11.<init>(r0)
            java.lang.String r13 = ""
            java.lang.String r0 = "base"
            java.lang.String[] r0 = new java.lang.String[]{r13, r0}
            java.util.List r0 = java.util.Arrays.asList(r0)
            r11.addAll(r0)
            com.google.android.play.core.e.ad r0 = r20.LJ()
            java.util.Map r11 = r0.LIZ(r11)
            java.util.Iterator r13 = r12.iterator()
        L_0x0128:
            boolean r0 = r13.hasNext()
            if (r0 == 0) goto L_0x0164
            java.lang.Object r12 = r13.next()
            java.util.Locale r12 = (java.util.Locale) r12
            java.lang.String r0 = r12.getLanguage()
            boolean r0 = r11.containsKey(r0)
            if (r0 == 0) goto L_0x0128
            java.lang.String r0 = r12.getLanguage()
            java.lang.Object r0 = r11.get(r0)
            java.util.Set r0 = (java.util.Set) r0
            boolean r0 = r0.contains(r1)
            if (r0 == 0) goto L_0x0128
            goto L_0x015b
        L_0x014f:
            boolean r0 = r13.contains(r1)
            if (r0 == 0) goto L_0x015b
            boolean r0 = r11.contains(r1)
            if (r0 == 0) goto L_0x0104
        L_0x015b:
            long r0 = r5.length()
            long r17 = r17 + r0
            r3.add(r5)
        L_0x0164:
            int r8 = r8 + 1
            goto L_0x004e
        L_0x0168:
            java.lang.String r5 = java.lang.String.valueOf(r7)
            java.util.List<java.lang.String> r0 = r6.LIZ
            java.lang.String r1 = java.lang.String.valueOf(r0)
            java.lang.String r0 = java.lang.String.valueOf(r5)
            r0.length()
            java.lang.String r0 = java.lang.String.valueOf(r1)
            r0.length()
            java.util.HashSet r1 = new java.util.HashSet
            java.util.List<java.lang.String> r0 = r6.LIZ
            r1.<init>(r0)
            boolean r0 = r7.containsAll(r1)
            if (r0 != 0) goto L_0x0193
            r0 = -2
            com.google.android.play.core.tasks.e r0 = r2.LIZJ(r0)
            return r0
        L_0x0193:
            r0 = 0
            java.lang.Long r8 = java.lang.Long.valueOf(r0)
            java.lang.Long r9 = java.lang.Long.valueOf(r17)
            java.util.List<java.lang.String> r0 = r6.LIZ
            java.lang.Integer r11 = java.lang.Integer.valueOf(r19)
            r6 = 1
            r7 = 0
            r5 = r20
            r10 = r0
            r12 = r4
            r5.LIZ(r6, r7, r8, r9, r10, r11, r12)
            java.util.concurrent.Executor r1 = r2.LJ
            com.google.android.play.core.e.b.d r0 = new com.google.android.play.core.e.b.d
            r0.<init>(r2, r3, r4)
            r1.execute(r0)
            com.google.android.play.core.tasks.e r0 = com.google.android.play.core.tasks.g.LIZ(r11)
            return r0
        L_0x01bb:
            r0 = -100
            com.google.android.play.core.tasks.e r0 = r2.LIZJ(r0)     // Catch:{ a -> 0x01c2 }
            return r0
        L_0x01c2:
            r0 = move-exception
            int r0 = r0.getErrorCode()
            com.google.android.play.core.tasks.e r0 = r2.LIZJ(r0)
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.play.core.e.b.a.LIZ(com.google.android.play.core.e.e):com.google.android.play.core.tasks.e");
    }

    public final void LIZ(com.google.android.play.core.e.g gVar) {
        this.LIZLLL.LIZ(gVar);
    }

    public final void LIZ(List<Intent> list, List<String> list2, List<String> list3, long j, boolean z) {
        List<Intent> list4 = list;
        this.LJIIL.a().LIZ(list4, new k(this, list2, list3, j, z, list4));
    }

    public final boolean LIZ(int i, int i2, Long l, Long l2, List<String> list, Integer num, List<String> list2) {
        f LIZ2 = LIZ((l) new c(num, i, i2, l, l2, list, list2));
        if (LIZ2 == null) {
            return false;
        }
        LIZ(LIZ2);
        return true;
    }

    public final boolean LIZ(f fVar, Activity activity, int i) {
        return false;
    }

    public final Set<String> LIZIZ() {
        HashSet hashSet = new HashSet();
        if (this.LJIIJ.LIZIZ() != null) {
            hashSet.addAll(this.LJIIJ.LIZIZ());
        }
        hashSet.addAll(this.LJII);
        return hashSet;
    }

    public final boolean LIZIZ(int i) {
        return LIZ(6, i, (Long) null, (Long) null, (List<String>) null, (Integer) null, (List<String>) null);
    }

    public final Set<String> LIZJ() {
        HashSet hashSet = new HashSet();
        hashSet.addAll(this.LJIIJ.LIZ());
        hashSet.addAll(this.LJI);
        return hashSet;
    }

    public final f LIZLLL() {
        return this.LJIILIIL.get();
    }
}
