package b.i.b;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.OnBackPressedDispatcher;
import b.i.b.g0;
import b.i.b.l;
import b.i.b.n0;
import b.j.d;
import com.cvte.vman.R;
import com.cvte.vman.instance.InvokeCmd;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public abstract class y {
    public boolean A;
    public boolean B;
    public boolean C;
    public boolean D;
    public boolean E;
    public ArrayList<b.i.b.a> F;
    public ArrayList<Boolean> G;
    public ArrayList<b.i.b.l> H;
    public ArrayList<m> I;
    public b0 J;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f1259b;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public ArrayList<b.i.b.a> f1261d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public ArrayList<b.i.b.l> f1262e;
    public OnBackPressedDispatcher g;
    public v<?> q;
    public r r;
    public b.i.b.l s;
    public b.i.b.l t;
    public b.a.e.c<Intent> w;
    public b.a.e.c<?> x;
    public b.a.e.c<String[]> y;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList<l> f1258a = new ArrayList<>();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final f0 f1260c = new f0();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final w f1263f = new w(this);
    public final b.a.b h = new c(false);
    public final AtomicInteger i = new AtomicInteger();
    public final Map<String, Bundle> j = Collections.synchronizedMap(new HashMap());
    public final Map<String, ?> k = Collections.synchronizedMap(new HashMap());
    public Map<b.i.b.l, HashSet<b.f.f.a>> l = Collections.synchronizedMap(new HashMap());
    public final n0.a m = new d();
    public final x n = new x(this);
    public final CopyOnWriteArrayList<c0> o = new CopyOnWriteArrayList<>();
    public int p = -1;
    public u u = new e();
    public v0 v = new f(this);
    public ArrayDeque<k> z = new ArrayDeque<>();
    public Runnable K = new g();

    public class a implements b.a.e.b<b.a.e.a> {
        public a() {
        }

        @Override // b.a.e.b
        public void a(b.a.e.a aVar) {
            String strB;
            b.a.e.a aVar2 = aVar;
            k kVarPollFirst = y.this.z.pollFirst();
            if (kVarPollFirst == null) {
                strB = "No IntentSenders were started for " + this;
            } else {
                String str = kVarPollFirst.f1272a;
                int i = kVarPollFirst.f1273b;
                b.i.b.l lVarE = y.this.f1260c.e(str);
                if (lVarE != null) {
                    lVarE.z(i, aVar2.f198a, aVar2.f199b);
                    return;
                }
                strB = c.a.a.a.a.b("Intent Sender result delivered for unknown Fragment ", str);
            }
            Log.w("FragmentManager", strB);
        }
    }

    public class b implements b.a.e.b<Map<String, Boolean>> {
        public b() {
        }

        @Override // b.a.e.b
        @SuppressLint({"SyntheticAccessor"})
        public void a(Map<String, Boolean> map) {
            String strB;
            Map<String, Boolean> map2 = map;
            ArrayList arrayList = new ArrayList(map2.values());
            int[] iArr = new int[arrayList.size()];
            for (int i = 0; i < arrayList.size(); i++) {
                iArr[i] = ((Boolean) arrayList.get(i)).booleanValue() ? 0 : -1;
            }
            k kVarPollFirst = y.this.z.pollFirst();
            if (kVarPollFirst == null) {
                strB = "No permissions were requested for " + this;
            } else {
                String str = kVarPollFirst.f1272a;
                if (y.this.f1260c.e(str) != null) {
                    return;
                } else {
                    strB = c.a.a.a.a.b("Permission request result delivered for unknown Fragment ", str);
                }
            }
            Log.w("FragmentManager", strB);
        }
    }

    public class c extends b.a.b {
        public c(boolean z) {
            super(z);
        }

        @Override // b.a.b
        public void a() {
            y yVar = y.this;
            yVar.B(true);
            if (yVar.h.f194a) {
                yVar.S();
            } else {
                yVar.g.a();
            }
        }
    }

    public class d implements n0.a {
        public d() {
        }

        public void a(b.i.b.l lVar, b.f.f.a aVar) {
            boolean z;
            synchronized (aVar) {
                z = aVar.f931a;
            }
            if (z) {
                return;
            }
            y yVar = y.this;
            HashSet<b.f.f.a> hashSet = yVar.l.get(lVar);
            if (hashSet != null && hashSet.remove(aVar) && hashSet.isEmpty()) {
                yVar.l.remove(lVar);
                if (lVar.f1160b < 5) {
                    yVar.i(lVar);
                    yVar.Q(lVar, yVar.p);
                }
            }
        }

        public void b(b.i.b.l lVar, b.f.f.a aVar) {
            y yVar = y.this;
            if (yVar.l.get(lVar) == null) {
                yVar.l.put(lVar, new HashSet<>());
            }
            yVar.l.get(lVar).add(aVar);
        }
    }

    public class e extends u {
        public e() {
        }

        @Override // b.i.b.u
        public b.i.b.l a(ClassLoader classLoader, String str) {
            v<?> vVar = y.this.q;
            Context context = vVar.f1252b;
            Objects.requireNonNull(vVar);
            Object obj = b.i.b.l.f1159a;
            try {
                return u.c(context.getClassLoader(), str).getConstructor(new Class[0]).newInstance(new Object[0]);
            } catch (IllegalAccessException e2) {
                throw new l.b(c.a.a.a.a.c("Unable to instantiate fragment ", str, ": make sure class name exists, is public, and has an empty constructor that is public"), e2);
            } catch (InstantiationException e3) {
                throw new l.b(c.a.a.a.a.c("Unable to instantiate fragment ", str, ": make sure class name exists, is public, and has an empty constructor that is public"), e3);
            } catch (NoSuchMethodException e4) {
                throw new l.b(c.a.a.a.a.c("Unable to instantiate fragment ", str, ": could not find Fragment constructor"), e4);
            } catch (InvocationTargetException e5) {
                throw new l.b(c.a.a.a.a.c("Unable to instantiate fragment ", str, ": calling Fragment constructor caused an exception"), e5);
            }
        }
    }

    public class f implements v0 {
        public f(y yVar) {
        }
    }

    public class g implements Runnable {
        public g() {
        }

        @Override // java.lang.Runnable
        public void run() {
            y.this.B(true);
        }
    }

    public class h implements c0 {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final /* synthetic */ b.i.b.l f1270a;

        public h(y yVar, b.i.b.l lVar) {
            this.f1270a = lVar;
        }

        @Override // b.i.b.c0
        public void b(y yVar, b.i.b.l lVar) {
            Objects.requireNonNull(this.f1270a);
        }
    }

    public class i implements b.a.e.b<b.a.e.a> {
        public i() {
        }

        @Override // b.a.e.b
        public void a(b.a.e.a aVar) {
            String strB;
            b.a.e.a aVar2 = aVar;
            k kVarPollFirst = y.this.z.pollFirst();
            if (kVarPollFirst == null) {
                strB = "No Activities were started for result for " + this;
            } else {
                String str = kVarPollFirst.f1272a;
                int i = kVarPollFirst.f1273b;
                b.i.b.l lVarE = y.this.f1260c.e(str);
                if (lVarE != null) {
                    lVarE.z(i, aVar2.f198a, aVar2.f199b);
                    return;
                }
                strB = c.a.a.a.a.b("Activity result delivered for unknown Fragment ", str);
            }
            Log.w("FragmentManager", strB);
        }
    }

    public static class j extends b.a.e.f.a<?, b.a.e.a> {
        @Override // b.a.e.f.a
        public b.a.e.a a(int i, Intent intent) {
            return new b.a.e.a(i, intent);
        }
    }

    @SuppressLint({"BanParcelableUsage"})
    public static class k implements Parcelable {
        public static final Parcelable.Creator<k> CREATOR = new a();

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public String f1272a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public int f1273b;

        public class a implements Parcelable.Creator<k> {
            @Override // android.os.Parcelable.Creator
            public k createFromParcel(Parcel parcel) {
                return new k(parcel);
            }

            @Override // android.os.Parcelable.Creator
            public k[] newArray(int i) {
                return new k[i];
            }
        }

        public k(Parcel parcel) {
            this.f1272a = parcel.readString();
            this.f1273b = parcel.readInt();
        }

        @Override // android.os.Parcelable
        public int describeContents() {
            return 0;
        }

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeString(this.f1272a);
            parcel.writeInt(this.f1273b);
        }
    }

    public interface l {
        boolean a(ArrayList<b.i.b.a> arrayList, ArrayList<Boolean> arrayList2);
    }

    public static class m implements l.d {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final boolean f1274a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final b.i.b.a f1275b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f1276c;

        public void a() {
            boolean z = this.f1276c > 0;
            for (b.i.b.l lVar : this.f1275b.p.f1260c.i()) {
                lVar.L(null);
                if (z && lVar.y()) {
                    lVar.N();
                }
            }
            b.i.b.a aVar = this.f1275b;
            aVar.p.g(aVar, this.f1274a, !z, true);
        }
    }

    public static boolean K(int i2) {
        return Log.isLoggable("FragmentManager", i2);
    }

    public final void A(boolean z) {
        if (this.f1259b) {
            throw new IllegalStateException("FragmentManager is already executing transactions");
        }
        if (this.q == null) {
            if (!this.D) {
                throw new IllegalStateException("FragmentManager has not been attached to a host.");
            }
            throw new IllegalStateException("FragmentManager has been destroyed");
        }
        if (Looper.myLooper() != this.q.f1253c.getLooper()) {
            throw new IllegalStateException("Must be called from main thread of fragment host");
        }
        if (!z && O()) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.F == null) {
            this.F = new ArrayList<>();
            this.G = new ArrayList<>();
        }
        this.f1259b = true;
        try {
            D(null, null);
        } finally {
            this.f1259b = false;
        }
    }

    public boolean B(boolean z) {
        boolean zA;
        A(z);
        boolean z2 = false;
        while (true) {
            ArrayList<b.i.b.a> arrayList = this.F;
            ArrayList<Boolean> arrayList2 = this.G;
            synchronized (this.f1258a) {
                if (this.f1258a.isEmpty()) {
                    zA = false;
                } else {
                    int size = this.f1258a.size();
                    zA = false;
                    for (int i2 = 0; i2 < size; i2++) {
                        zA |= this.f1258a.get(i2).a(arrayList, arrayList2);
                    }
                    this.f1258a.clear();
                    this.q.f1253c.removeCallbacks(this.K);
                }
            }
            if (!zA) {
                d0();
                x();
                this.f1260c.b();
                return z2;
            }
            this.f1259b = true;
            try {
                U(this.F, this.G);
                e();
                z2 = true;
            } catch (Throwable th) {
                e();
                throw th;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:61:0x014f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void C(java.util.ArrayList<b.i.b.a> r20, java.util.ArrayList<java.lang.Boolean> r21, int r22, int r23) {
        /*
            Method dump skipped, instruction units count: 710
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.b.y.C(java.util.ArrayList, java.util.ArrayList, int, int):void");
    }

    public final void D(ArrayList<b.i.b.a> arrayList, ArrayList<Boolean> arrayList2) {
        int iIndexOf;
        int iIndexOf2;
        ArrayList<m> arrayList3 = this.I;
        int size = arrayList3 == null ? 0 : arrayList3.size();
        int i2 = 0;
        while (i2 < size) {
            m mVar = this.I.get(i2);
            if (arrayList == null || mVar.f1274a || (iIndexOf2 = arrayList.indexOf(mVar.f1275b)) == -1 || arrayList2 == null || !arrayList2.get(iIndexOf2).booleanValue()) {
                if ((mVar.f1276c == 0) || (arrayList != null && mVar.f1275b.h(arrayList, 0, arrayList.size()))) {
                    this.I.remove(i2);
                    i2--;
                    size--;
                    if (arrayList == null || mVar.f1274a || (iIndexOf = arrayList.indexOf(mVar.f1275b)) == -1 || arrayList2 == null || !arrayList2.get(iIndexOf).booleanValue()) {
                        mVar.a();
                    }
                }
                i2++;
            } else {
                this.I.remove(i2);
                i2--;
                size--;
            }
            b.i.b.a aVar = mVar.f1275b;
            aVar.p.g(aVar, mVar.f1274a, false, false);
            i2++;
        }
    }

    public b.i.b.l E(String str) {
        return this.f1260c.d(str);
    }

    public b.i.b.l F(int i2) {
        f0 f0Var = this.f1260c;
        int size = f0Var.f1121a.size();
        while (true) {
            size--;
            if (size < 0) {
                for (e0 e0Var : f0Var.f1122b.values()) {
                    if (e0Var != null) {
                        b.i.b.l lVar = e0Var.f1114c;
                        if (lVar.w == i2) {
                            return lVar;
                        }
                    }
                }
                return null;
            }
            b.i.b.l lVar2 = f0Var.f1121a.get(size);
            if (lVar2 != null && lVar2.w == i2) {
                return lVar2;
            }
        }
    }

    public final ViewGroup G(b.i.b.l lVar) {
        ViewGroup viewGroup = lVar.E;
        if (viewGroup != null) {
            return viewGroup;
        }
        if (lVar.x > 0 && this.r.h()) {
            View viewF = this.r.f(lVar.x);
            if (viewF instanceof ViewGroup) {
                return (ViewGroup) viewF;
            }
        }
        return null;
    }

    public u H() {
        b.i.b.l lVar = this.s;
        return lVar != null ? lVar.s.H() : this.u;
    }

    public v0 I() {
        b.i.b.l lVar = this.s;
        return lVar != null ? lVar.s.I() : this.v;
    }

    public void J(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "hide: " + lVar);
        }
        if (lVar.z) {
            return;
        }
        lVar.z = true;
        lVar.I = true ^ lVar.I;
        a0(lVar);
    }

    public final boolean L(b.i.b.l lVar) {
        y yVar = lVar.u;
        boolean zL = false;
        for (b.i.b.l lVar2 : (ArrayList) yVar.f1260c.g()) {
            if (lVar2 != null) {
                zL = yVar.L(lVar2);
            }
            if (zL) {
                return true;
            }
        }
        return false;
    }

    public boolean M(b.i.b.l lVar) {
        y yVar;
        if (lVar == null) {
            return true;
        }
        return lVar.C && ((yVar = lVar.s) == null || yVar.M(lVar.v));
    }

    public boolean N(b.i.b.l lVar) {
        if (lVar == null) {
            return true;
        }
        y yVar = lVar.s;
        return lVar.equals(yVar.t) && N(yVar.s);
    }

    public boolean O() {
        return this.B || this.C;
    }

    public void P(int i2, boolean z) {
        v<?> vVar;
        if (this.q == null && i2 != -1) {
            throw new IllegalStateException("No activity");
        }
        if (z || i2 != this.p) {
            this.p = i2;
            f0 f0Var = this.f1260c;
            Iterator<b.i.b.l> it = f0Var.f1121a.iterator();
            while (it.hasNext()) {
                e0 e0Var = f0Var.f1122b.get(it.next().f1164f);
                if (e0Var != null) {
                    e0Var.j();
                }
            }
            Iterator<e0> it2 = f0Var.f1122b.values().iterator();
            while (true) {
                boolean z2 = false;
                if (!it2.hasNext()) {
                    break;
                }
                e0 next = it2.next();
                if (next != null) {
                    next.j();
                    b.i.b.l lVar = next.f1114c;
                    if (lVar.m && !lVar.x()) {
                        z2 = true;
                    }
                    if (z2) {
                        f0Var.k(next);
                    }
                }
            }
            c0();
            if (this.A && (vVar = this.q) != null && this.p == 7) {
                vVar.k();
                this.A = false;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x0062  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x0067  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x006c  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0076  */
    /* JADX WARN: Removed duplicated region for block: B:66:0x00cb  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x00ce  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void Q(b.i.b.l r10, int r11) {
        /*
            Method dump skipped, instruction units count: 261
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.b.y.Q(b.i.b.l, int):void");
    }

    public void R() {
        if (this.q == null) {
            return;
        }
        this.B = false;
        this.C = false;
        this.J.h = false;
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                lVar.u.R();
            }
        }
    }

    public boolean S() {
        int size;
        boolean z = false;
        B(false);
        A(true);
        b.i.b.l lVar = this.t;
        if (lVar != null && lVar.h().S()) {
            return true;
        }
        ArrayList<b.i.b.a> arrayList = this.F;
        ArrayList<Boolean> arrayList2 = this.G;
        ArrayList<b.i.b.a> arrayList3 = this.f1261d;
        if (arrayList3 != null && (size = arrayList3.size() - 1) >= 0) {
            arrayList.add(this.f1261d.remove(size));
            arrayList2.add(Boolean.TRUE);
            z = true;
        }
        if (z) {
            this.f1259b = true;
            try {
                U(this.F, this.G);
            } finally {
                e();
            }
        }
        d0();
        x();
        this.f1260c.b();
        return z;
    }

    public void T(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "remove: " + lVar + " nesting=" + lVar.r);
        }
        boolean z = !lVar.x();
        if (!lVar.A || z) {
            this.f1260c.l(lVar);
            if (L(lVar)) {
                this.A = true;
            }
            lVar.m = true;
            a0(lVar);
        }
    }

    public final void U(ArrayList<b.i.b.a> arrayList, ArrayList<Boolean> arrayList2) {
        if (arrayList.isEmpty()) {
            return;
        }
        if (arrayList.size() != arrayList2.size()) {
            throw new IllegalStateException("Internal error with the back stack records");
        }
        D(arrayList, arrayList2);
        int size = arrayList.size();
        int i2 = 0;
        int i3 = 0;
        while (i2 < size) {
            if (!arrayList.get(i2).o) {
                if (i3 != i2) {
                    C(arrayList, arrayList2, i3, i2);
                }
                i3 = i2 + 1;
                if (arrayList2.get(i2).booleanValue()) {
                    while (i3 < size && arrayList2.get(i3).booleanValue() && !arrayList.get(i3).o) {
                        i3++;
                    }
                }
                C(arrayList, arrayList2, i2, i3);
                i2 = i3 - 1;
            }
            i2++;
        }
        if (i3 != size) {
            C(arrayList, arrayList2, i3, size);
        }
    }

    public void V(Parcelable parcelable) {
        e0 e0Var;
        if (parcelable == null) {
            return;
        }
        a0 a0Var = (a0) parcelable;
        if (a0Var.f1072a == null) {
            return;
        }
        this.f1260c.f1122b.clear();
        for (d0 d0Var : a0Var.f1072a) {
            if (d0Var != null) {
                b.i.b.l lVar = this.J.f1085c.get(d0Var.f1106b);
                if (lVar != null) {
                    if (K(2)) {
                        Log.v("FragmentManager", "restoreSaveState: re-attaching retained " + lVar);
                    }
                    e0Var = new e0(this.n, this.f1260c, lVar, d0Var);
                } else {
                    e0Var = new e0(this.n, this.f1260c, this.q.f1252b.getClassLoader(), H(), d0Var);
                }
                b.i.b.l lVar2 = e0Var.f1114c;
                lVar2.s = this;
                if (K(2)) {
                    StringBuilder sbD = c.a.a.a.a.d("restoreSaveState: active (");
                    sbD.append(lVar2.f1164f);
                    sbD.append("): ");
                    sbD.append(lVar2);
                    Log.v("FragmentManager", sbD.toString());
                }
                e0Var.l(this.q.f1252b.getClassLoader());
                this.f1260c.j(e0Var);
                e0Var.f1116e = this.p;
            }
        }
        b0 b0Var = this.J;
        Objects.requireNonNull(b0Var);
        for (b.i.b.l lVar3 : new ArrayList(b0Var.f1085c.values())) {
            if (!this.f1260c.c(lVar3.f1164f)) {
                if (K(2)) {
                    Log.v("FragmentManager", "Discarding retained Fragment " + lVar3 + " that was not found in the set of active Fragments " + a0Var.f1072a);
                }
                this.J.b(lVar3);
                lVar3.s = this;
                e0 e0Var2 = new e0(this.n, this.f1260c, lVar3);
                e0Var2.f1116e = 1;
                e0Var2.j();
                lVar3.m = true;
                e0Var2.j();
            }
        }
        f0 f0Var = this.f1260c;
        ArrayList<String> arrayList = a0Var.f1073b;
        f0Var.f1121a.clear();
        if (arrayList != null) {
            for (String str : arrayList) {
                b.i.b.l lVarD = f0Var.d(str);
                if (lVarD == null) {
                    throw new IllegalStateException(c.a.a.a.a.c("No instantiated fragment for (", str, ")"));
                }
                if (K(2)) {
                    Log.v("FragmentManager", "restoreSaveState: added (" + str + "): " + lVarD);
                }
                f0Var.a(lVarD);
            }
        }
        if (a0Var.f1074c != null) {
            this.f1261d = new ArrayList<>(a0Var.f1074c.length);
            int i2 = 0;
            while (true) {
                b.i.b.b[] bVarArr = a0Var.f1074c;
                if (i2 >= bVarArr.length) {
                    break;
                }
                b.i.b.b bVar = bVarArr[i2];
                Objects.requireNonNull(bVar);
                b.i.b.a aVar = new b.i.b.a(this);
                int i3 = 0;
                int i4 = 0;
                while (true) {
                    int[] iArr = bVar.f1078a;
                    if (i3 >= iArr.length) {
                        break;
                    }
                    g0.a aVar2 = new g0.a();
                    int i5 = i3 + 1;
                    aVar2.f1134a = iArr[i3];
                    if (K(2)) {
                        Log.v("FragmentManager", "Instantiate " + aVar + " op #" + i4 + " base fragment #" + bVar.f1078a[i5]);
                    }
                    String str2 = bVar.f1079b.get(i4);
                    aVar2.f1135b = str2 != null ? this.f1260c.d(str2) : null;
                    aVar2.g = d.b.values()[bVar.f1080c[i4]];
                    aVar2.h = d.b.values()[bVar.f1081d[i4]];
                    int[] iArr2 = bVar.f1078a;
                    int i6 = i5 + 1;
                    int i7 = iArr2[i5];
                    aVar2.f1136c = i7;
                    int i8 = i6 + 1;
                    int i9 = iArr2[i6];
                    aVar2.f1137d = i9;
                    int i10 = i8 + 1;
                    int i11 = iArr2[i8];
                    aVar2.f1138e = i11;
                    int i12 = iArr2[i10];
                    aVar2.f1139f = i12;
                    aVar.f1129b = i7;
                    aVar.f1130c = i9;
                    aVar.f1131d = i11;
                    aVar.f1132e = i12;
                    aVar.b(aVar2);
                    i4++;
                    i3 = i10 + 1;
                }
                aVar.f1133f = bVar.f1082e;
                aVar.h = bVar.f1083f;
                aVar.q = bVar.g;
                aVar.g = true;
                aVar.i = bVar.h;
                aVar.j = bVar.i;
                aVar.k = bVar.j;
                aVar.l = bVar.k;
                aVar.m = bVar.l;
                aVar.n = bVar.m;
                aVar.o = bVar.n;
                aVar.c(1);
                if (K(2)) {
                    Log.v("FragmentManager", "restoreAllState: back stack #" + i2 + " (index " + aVar.q + "): " + aVar);
                    PrintWriter printWriter = new PrintWriter(new t0("FragmentManager"));
                    aVar.d("  ", printWriter, false);
                    printWriter.close();
                }
                this.f1261d.add(aVar);
                i2++;
            }
        } else {
            this.f1261d = null;
        }
        this.i.set(a0Var.f1075d);
        String str3 = a0Var.f1076e;
        if (str3 != null) {
            b.i.b.l lVarE = E(str3);
            this.t = lVarE;
            t(lVarE);
        }
        ArrayList<String> arrayList2 = a0Var.f1077f;
        if (arrayList2 != null) {
            for (int i13 = 0; i13 < arrayList2.size(); i13++) {
                Bundle bundle = a0Var.g.get(i13);
                bundle.setClassLoader(this.q.f1252b.getClassLoader());
                this.j.put(arrayList2.get(i13), bundle);
            }
        }
        this.z = new ArrayDeque<>(a0Var.h);
    }

    public Parcelable W() {
        int i2;
        b.i.b.b[] bVarArr;
        ArrayList<String> arrayList;
        int size;
        Iterator it = ((HashSet) f()).iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            u0 u0Var = (u0) it.next();
            if (u0Var.f1235e) {
                u0Var.f1235e = false;
                u0Var.b();
            }
        }
        z();
        B(true);
        this.B = true;
        this.J.h = true;
        f0 f0Var = this.f1260c;
        Objects.requireNonNull(f0Var);
        ArrayList<d0> arrayList2 = new ArrayList<>(f0Var.f1122b.size());
        Iterator<e0> it2 = f0Var.f1122b.values().iterator();
        while (true) {
            bVarArr = null;
            bVarArr = null;
            if (!it2.hasNext()) {
                break;
            }
            e0 next = it2.next();
            if (next != null) {
                b.i.b.l lVar = next.f1114c;
                d0 d0Var = new d0(lVar);
                b.i.b.l lVar2 = next.f1114c;
                if (lVar2.f1160b <= -1 || d0Var.m != null) {
                    d0Var.m = lVar2.f1161c;
                } else {
                    Bundle bundle = new Bundle();
                    b.i.b.l lVar3 = next.f1114c;
                    lVar3.P.b(bundle);
                    Parcelable parcelableW = lVar3.u.W();
                    if (parcelableW != null) {
                        bundle.putParcelable("android:support:fragments", parcelableW);
                    }
                    next.f1112a.j(next.f1114c, bundle, false);
                    Bundle bundle2 = bundle.isEmpty() ? null : bundle;
                    Objects.requireNonNull(next.f1114c);
                    if (next.f1114c.f1162d != null) {
                        if (bundle2 == null) {
                            bundle2 = new Bundle();
                        }
                        bundle2.putSparseParcelableArray("android:view_state", next.f1114c.f1162d);
                    }
                    if (next.f1114c.f1163e != null) {
                        if (bundle2 == null) {
                            bundle2 = new Bundle();
                        }
                        bundle2.putBundle("android:view_registry_state", next.f1114c.f1163e);
                    }
                    if (!next.f1114c.G) {
                        if (bundle2 == null) {
                            bundle2 = new Bundle();
                        }
                        bundle2.putBoolean("android:user_visible_hint", next.f1114c.G);
                    }
                    d0Var.m = bundle2;
                    if (next.f1114c.i != null) {
                        if (bundle2 == null) {
                            d0Var.m = new Bundle();
                        }
                        d0Var.m.putString("android:target_state", next.f1114c.i);
                        int i3 = next.f1114c.j;
                        if (i3 != 0) {
                            d0Var.m.putInt("android:target_req_state", i3);
                        }
                    }
                }
                arrayList2.add(d0Var);
                if (K(2)) {
                    Log.v("FragmentManager", "Saved state of " + lVar + ": " + d0Var.m);
                }
            }
        }
        if (arrayList2.isEmpty()) {
            if (K(2)) {
                Log.v("FragmentManager", "saveAllState: no fragments!");
            }
            return null;
        }
        f0 f0Var2 = this.f1260c;
        synchronized (f0Var2.f1121a) {
            if (f0Var2.f1121a.isEmpty()) {
                arrayList = null;
            } else {
                arrayList = new ArrayList<>(f0Var2.f1121a.size());
                for (b.i.b.l lVar4 : f0Var2.f1121a) {
                    arrayList.add(lVar4.f1164f);
                    if (K(2)) {
                        Log.v("FragmentManager", "saveAllState: adding fragment (" + lVar4.f1164f + "): " + lVar4);
                    }
                }
            }
        }
        ArrayList<b.i.b.a> arrayList3 = this.f1261d;
        if (arrayList3 != null && (size = arrayList3.size()) > 0) {
            bVarArr = new b.i.b.b[size];
            for (i2 = 0; i2 < size; i2++) {
                bVarArr[i2] = new b.i.b.b(this.f1261d.get(i2));
                if (K(2)) {
                    Log.v("FragmentManager", "saveAllState: adding back stack #" + i2 + ": " + this.f1261d.get(i2));
                }
            }
        }
        a0 a0Var = new a0();
        a0Var.f1072a = arrayList2;
        a0Var.f1073b = arrayList;
        a0Var.f1074c = bVarArr;
        a0Var.f1075d = this.i.get();
        b.i.b.l lVar5 = this.t;
        if (lVar5 != null) {
            a0Var.f1076e = lVar5.f1164f;
        }
        a0Var.f1077f.addAll(this.j.keySet());
        a0Var.g.addAll(this.j.values());
        a0Var.h = new ArrayList<>(this.z);
        return a0Var;
    }

    public void X(b.i.b.l lVar, boolean z) {
        ViewGroup viewGroupG = G(lVar);
        if (viewGroupG == null || !(viewGroupG instanceof s)) {
            return;
        }
        ((s) viewGroupG).setDrawDisappearingViewsLast(!z);
    }

    public void Y(b.i.b.l lVar, d.b bVar) {
        if (lVar.equals(E(lVar.f1164f)) && (lVar.t == null || lVar.s == this)) {
            lVar.L = bVar;
            return;
        }
        throw new IllegalArgumentException("Fragment " + lVar + " is not an active fragment of FragmentManager " + this);
    }

    public void Z(b.i.b.l lVar) {
        if (lVar == null || (lVar.equals(E(lVar.f1164f)) && (lVar.t == null || lVar.s == this))) {
            b.i.b.l lVar2 = this.t;
            this.t = lVar;
            t(lVar2);
            t(this.t);
            return;
        }
        throw new IllegalArgumentException("Fragment " + lVar + " is not an active fragment of FragmentManager " + this);
    }

    public e0 a(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "add: " + lVar);
        }
        e0 e0VarH = h(lVar);
        lVar.s = this;
        this.f1260c.j(e0VarH);
        if (!lVar.A) {
            this.f1260c.a(lVar);
            lVar.m = false;
            lVar.I = false;
            if (L(lVar)) {
                this.A = true;
            }
        }
        return e0VarH;
    }

    public final void a0(b.i.b.l lVar) {
        ViewGroup viewGroupG = G(lVar);
        if (viewGroupG != null) {
            if (lVar.s() + lVar.r() + lVar.l() + lVar.i() > 0) {
                if (viewGroupG.getTag(R.id.visible_removing_fragment_view_tag) == null) {
                    viewGroupG.setTag(R.id.visible_removing_fragment_view_tag, lVar);
                }
                ((b.i.b.l) viewGroupG.getTag(R.id.visible_removing_fragment_view_tag)).M(lVar.q());
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:13:0x0022  */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0029  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0075  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00ec  */
    /* JADX WARN: Removed duplicated region for block: B:58:? A[RETURN, SYNTHETIC] */
    @android.annotation.SuppressLint({"SyntheticAccessor"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void b(b.i.b.v<?> r5, b.i.b.r r6, b.i.b.l r7) {
        /*
            Method dump skipped, instruction units count: 347
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.b.y.b(b.i.b.v, b.i.b.r, b.i.b.l):void");
    }

    public void b0(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "show: " + lVar);
        }
        if (lVar.z) {
            lVar.z = false;
            lVar.I = !lVar.I;
        }
    }

    public void c(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "attach: " + lVar);
        }
        if (lVar.A) {
            lVar.A = false;
            if (lVar.l) {
                return;
            }
            this.f1260c.a(lVar);
            if (K(2)) {
                Log.v("FragmentManager", "add from attach: " + lVar);
            }
            if (L(lVar)) {
                this.A = true;
            }
        }
    }

    public final void c0() {
        for (e0 e0Var : (ArrayList) this.f1260c.f()) {
            b.i.b.l lVar = e0Var.f1114c;
            if (lVar.F) {
                if (this.f1259b) {
                    this.E = true;
                } else {
                    lVar.F = false;
                    e0Var.j();
                }
            }
        }
    }

    public final void d(b.i.b.l lVar) {
        HashSet<b.f.f.a> hashSet = this.l.get(lVar);
        if (hashSet != null) {
            Iterator<b.f.f.a> it = hashSet.iterator();
            while (it.hasNext()) {
                it.next().a();
            }
            hashSet.clear();
            i(lVar);
            this.l.remove(lVar);
        }
    }

    public final void d0() {
        synchronized (this.f1258a) {
            if (!this.f1258a.isEmpty()) {
                this.h.f194a = true;
                return;
            }
            b.a.b bVar = this.h;
            ArrayList<b.i.b.a> arrayList = this.f1261d;
            bVar.f194a = (arrayList != null ? arrayList.size() : 0) > 0 && N(this.s);
        }
    }

    public final void e() {
        this.f1259b = false;
        this.G.clear();
        this.F.clear();
    }

    public final Set<u0> f() {
        HashSet hashSet = new HashSet();
        Iterator it = ((ArrayList) this.f1260c.f()).iterator();
        while (it.hasNext()) {
            ViewGroup viewGroup = ((e0) it.next()).f1114c.E;
            if (viewGroup != null) {
                hashSet.add(u0.e(viewGroup, I()));
            }
        }
        return hashSet;
    }

    public void g(b.i.b.a aVar, boolean z, boolean z2, boolean z3) {
        if (z) {
            aVar.f(z3);
        } else {
            aVar.e();
        }
        ArrayList arrayList = new ArrayList(1);
        ArrayList arrayList2 = new ArrayList(1);
        arrayList.add(aVar);
        arrayList2.add(Boolean.valueOf(z));
        if (z2 && this.p >= 1) {
            n0.o(this.q.f1252b, this.r, arrayList, arrayList2, 0, 1, true, this.m);
        }
        if (z3) {
            P(this.p, true);
        }
        for (b.i.b.l lVar : (ArrayList) this.f1260c.g()) {
        }
    }

    public e0 h(b.i.b.l lVar) {
        e0 e0VarH = this.f1260c.h(lVar.f1164f);
        if (e0VarH != null) {
            return e0VarH;
        }
        e0 e0Var = new e0(this.n, this.f1260c, lVar);
        e0Var.l(this.q.f1252b.getClassLoader());
        e0Var.f1116e = this.p;
        return e0Var;
    }

    public final void i(b.i.b.l lVar) {
        lVar.C();
        this.n.m(lVar, false);
        lVar.E = null;
        lVar.N = null;
        lVar.O.g(null);
        lVar.o = false;
    }

    public void j(b.i.b.l lVar) {
        if (K(2)) {
            Log.v("FragmentManager", "detach: " + lVar);
        }
        if (lVar.A) {
            return;
        }
        lVar.A = true;
        if (lVar.l) {
            if (K(2)) {
                Log.v("FragmentManager", "remove from detach: " + lVar);
            }
            this.f1260c.l(lVar);
            if (L(lVar)) {
                this.A = true;
            }
            a0(lVar);
        }
    }

    public void k(Configuration configuration) {
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                lVar.D = true;
                lVar.u.k(configuration);
            }
        }
    }

    public boolean l(MenuItem menuItem) {
        if (this.p < 1) {
            return false;
        }
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                if (!lVar.z ? lVar.u.l(menuItem) : false) {
                    return true;
                }
            }
        }
        return false;
    }

    public void m() {
        this.B = false;
        this.C = false;
        this.J.h = false;
        w(1);
    }

    public boolean n(Menu menu, MenuInflater menuInflater) {
        if (this.p < 1) {
            return false;
        }
        ArrayList<b.i.b.l> arrayList = null;
        boolean z = false;
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null && M(lVar)) {
                if (!lVar.z ? lVar.u.n(menu, menuInflater) | false : false) {
                    if (arrayList == null) {
                        arrayList = new ArrayList<>();
                    }
                    arrayList.add(lVar);
                    z = true;
                }
            }
        }
        if (this.f1262e != null) {
            for (int i2 = 0; i2 < this.f1262e.size(); i2++) {
                b.i.b.l lVar2 = this.f1262e.get(i2);
                if (arrayList == null || !arrayList.contains(lVar2)) {
                    Objects.requireNonNull(lVar2);
                }
            }
        }
        this.f1262e = arrayList;
        return z;
    }

    public void o() {
        this.D = true;
        B(true);
        z();
        w(-1);
        this.q = null;
        this.r = null;
        this.s = null;
        if (this.g != null) {
            Iterator<b.a.a> it = this.h.f195b.iterator();
            while (it.hasNext()) {
                it.next().cancel();
            }
            this.g = null;
        }
        b.a.e.c<Intent> cVar = this.w;
        if (cVar != null) {
            cVar.a();
            this.x.a();
            this.y.a();
        }
    }

    public void p() {
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                lVar.E();
            }
        }
    }

    public void q(boolean z) {
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                lVar.u.q(z);
            }
        }
    }

    public boolean r(MenuItem menuItem) {
        if (this.p < 1) {
            return false;
        }
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                if (!lVar.z ? lVar.u.r(menuItem) : false) {
                    return true;
                }
            }
        }
        return false;
    }

    public void s(Menu menu) {
        if (this.p < 1) {
            return;
        }
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null && !lVar.z) {
                lVar.u.s(menu);
            }
        }
    }

    public final void t(b.i.b.l lVar) {
        if (lVar == null || !lVar.equals(E(lVar.f1164f))) {
            return;
        }
        boolean zN = lVar.s.N(lVar);
        Boolean bool = lVar.k;
        if (bool == null || bool.booleanValue() != zN) {
            lVar.k = Boolean.valueOf(zN);
            y yVar = lVar.u;
            yVar.d0();
            yVar.t(yVar.t);
        }
    }

    public String toString() {
        Object obj;
        StringBuilder sb = new StringBuilder(InvokeCmd.CMD_SYSTEMCTRL_SET_HDMI_CLOCK_WAKEUP_STATE);
        sb.append("FragmentManager{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(" in ");
        b.i.b.l lVar = this.s;
        if (lVar != null) {
            sb.append(lVar.getClass().getSimpleName());
            sb.append("{");
            obj = this.s;
        } else {
            v<?> vVar = this.q;
            if (vVar == null) {
                sb.append("null");
                sb.append("}}");
                return sb.toString();
            }
            sb.append(vVar.getClass().getSimpleName());
            sb.append("{");
            obj = this.q;
        }
        sb.append(Integer.toHexString(System.identityHashCode(obj)));
        sb.append("}");
        sb.append("}}");
        return sb.toString();
    }

    public void u(boolean z) {
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null) {
                lVar.u.u(z);
            }
        }
    }

    public boolean v(Menu menu) {
        boolean z = false;
        if (this.p < 1) {
            return false;
        }
        for (b.i.b.l lVar : this.f1260c.i()) {
            if (lVar != null && M(lVar) && lVar.F(menu)) {
                z = true;
            }
        }
        return z;
    }

    public final void w(int i2) {
        try {
            this.f1259b = true;
            for (e0 e0Var : this.f1260c.f1122b.values()) {
                if (e0Var != null) {
                    e0Var.f1116e = i2;
                }
            }
            P(i2, false);
            Iterator it = ((HashSet) f()).iterator();
            while (it.hasNext()) {
                ((u0) it.next()).d();
            }
            this.f1259b = false;
            B(true);
        } catch (Throwable th) {
            this.f1259b = false;
            throw th;
        }
    }

    public final void x() {
        if (this.E) {
            this.E = false;
            c0();
        }
    }

    public void y(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        int size;
        int size2;
        String strB = c.a.a.a.a.b(str, "    ");
        f0 f0Var = this.f1260c;
        Objects.requireNonNull(f0Var);
        String str2 = str + "    ";
        if (!f0Var.f1122b.isEmpty()) {
            printWriter.print(str);
            printWriter.println("Active Fragments:");
            for (e0 e0Var : f0Var.f1122b.values()) {
                printWriter.print(str);
                if (e0Var != null) {
                    b.i.b.l lVar = e0Var.f1114c;
                    printWriter.println(lVar);
                    lVar.b(str2, fileDescriptor, printWriter, strArr);
                } else {
                    printWriter.println("null");
                }
            }
        }
        int size3 = f0Var.f1121a.size();
        if (size3 > 0) {
            printWriter.print(str);
            printWriter.println("Added Fragments:");
            for (int i2 = 0; i2 < size3; i2++) {
                b.i.b.l lVar2 = f0Var.f1121a.get(i2);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i2);
                printWriter.print(": ");
                printWriter.println(lVar2.toString());
            }
        }
        ArrayList<b.i.b.l> arrayList = this.f1262e;
        if (arrayList != null && (size2 = arrayList.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Fragments Created Menus:");
            for (int i3 = 0; i3 < size2; i3++) {
                b.i.b.l lVar3 = this.f1262e.get(i3);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i3);
                printWriter.print(": ");
                printWriter.println(lVar3.toString());
            }
        }
        ArrayList<b.i.b.a> arrayList2 = this.f1261d;
        if (arrayList2 != null && (size = arrayList2.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Back Stack:");
            for (int i4 = 0; i4 < size; i4++) {
                b.i.b.a aVar = this.f1261d.get(i4);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i4);
                printWriter.print(": ");
                printWriter.println(aVar.toString());
                aVar.d(strB, printWriter, true);
            }
        }
        printWriter.print(str);
        printWriter.println("Back Stack Index: " + this.i.get());
        synchronized (this.f1258a) {
            int size4 = this.f1258a.size();
            if (size4 > 0) {
                printWriter.print(str);
                printWriter.println("Pending Actions:");
                for (int i5 = 0; i5 < size4; i5++) {
                    Object obj = (l) this.f1258a.get(i5);
                    printWriter.print(str);
                    printWriter.print("  #");
                    printWriter.print(i5);
                    printWriter.print(": ");
                    printWriter.println(obj);
                }
            }
        }
        printWriter.print(str);
        printWriter.println("FragmentManager misc state:");
        printWriter.print(str);
        printWriter.print("  mHost=");
        printWriter.println(this.q);
        printWriter.print(str);
        printWriter.print("  mContainer=");
        printWriter.println(this.r);
        if (this.s != null) {
            printWriter.print(str);
            printWriter.print("  mParent=");
            printWriter.println(this.s);
        }
        printWriter.print(str);
        printWriter.print("  mCurState=");
        printWriter.print(this.p);
        printWriter.print(" mStateSaved=");
        printWriter.print(this.B);
        printWriter.print(" mStopped=");
        printWriter.print(this.C);
        printWriter.print(" mDestroyed=");
        printWriter.println(this.D);
        if (this.A) {
            printWriter.print(str);
            printWriter.print("  mNeedMenuInvalidate=");
            printWriter.println(this.A);
        }
    }

    public final void z() {
        Iterator it = ((HashSet) f()).iterator();
        while (it.hasNext()) {
            ((u0) it.next()).d();
        }
    }
}
