package androidx.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Trace;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import b.j.d;
import b.j.g;
import b.j.h;
import b.j.o;
import b.j.t;
import b.j.u;
import b.l.a;
import com.cvte.vman.R;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public class ComponentActivity extends b.f.b.c implements g, u, b.l.c, b.a.c, b.a.e.e {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final b.a.d.a f5b = new b.a.d.a();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final h f6c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final b.l.b f7d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public t f8e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final OnBackPressedDispatcher f9f;
    public final b.a.e.d g;

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

        @Override // java.lang.Runnable
        public void run() {
            try {
                ComponentActivity.super.onBackPressed();
            } catch (IllegalStateException e2) {
                if (!TextUtils.equals(e2.getMessage(), "Can not perform this action after onSaveInstanceState")) {
                    throw e2;
                }
            }
        }
    }

    public class b extends b.a.e.d {
        public b(ComponentActivity componentActivity) {
        }
    }

    public class c implements a.b {
        public c() {
        }

        @Override // b.l.a.b
        @SuppressLint({"SyntheticAccessor"})
        public Bundle a() {
            Bundle bundle = new Bundle();
            b.a.e.d dVar = ComponentActivity.this.g;
            Objects.requireNonNull(dVar);
            bundle.putIntegerArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_RCS", new ArrayList<>(dVar.f202c.values()));
            bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS", new ArrayList<>(dVar.f202c.keySet()));
            bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS", new ArrayList<>(dVar.f204e));
            bundle.putBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT", (Bundle) dVar.h.clone());
            bundle.putSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT", dVar.f200a);
            return bundle;
        }
    }

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

        @Override // b.a.d.b
        @SuppressLint({"SyntheticAccessor"})
        public void a(Context context) {
            Bundle bundleA = ComponentActivity.this.f7d.f1312b.a("android:support:activity-result");
            if (bundleA != null) {
                b.a.e.d dVar = ComponentActivity.this.g;
                Objects.requireNonNull(dVar);
                ArrayList<Integer> integerArrayList = bundleA.getIntegerArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_RCS");
                ArrayList<String> stringArrayList = bundleA.getStringArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS");
                if (stringArrayList == null || integerArrayList == null) {
                    return;
                }
                dVar.f204e = bundleA.getStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS");
                dVar.f200a = (Random) bundleA.getSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT");
                dVar.h.putAll(bundleA.getBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT"));
                for (int i = 0; i < stringArrayList.size(); i++) {
                    String str = stringArrayList.get(i);
                    if (dVar.f202c.containsKey(str)) {
                        Integer numRemove = dVar.f202c.remove(str);
                        if (!dVar.h.containsKey(str)) {
                            dVar.f201b.remove(numRemove);
                        }
                    }
                    int iIntValue = integerArrayList.get(i).intValue();
                    String str2 = stringArrayList.get(i);
                    dVar.f201b.put(Integer.valueOf(iIntValue), str2);
                    dVar.f202c.put(str2, Integer.valueOf(iIntValue));
                }
            }
        }
    }

    public static final class e {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public t f16a;
    }

    public ComponentActivity() {
        h hVar = new h(this);
        this.f6c = hVar;
        b.l.b bVar = new b.l.b(this);
        this.f7d = bVar;
        this.f9f = new OnBackPressedDispatcher(new a());
        new AtomicInteger();
        this.g = new b(this);
        if (hVar == null) {
            throw new IllegalStateException("getLifecycle() returned null in ComponentActivity's constructor. Please make sure you are lazily constructing your Lifecycle in the first call to getLifecycle() rather than relying on field initialization.");
        }
        hVar.a(new b.j.e() { // from class: androidx.activity.ComponentActivity.3
            @Override // b.j.e
            public void g(g gVar, d.a aVar) {
                if (aVar == d.a.ON_STOP) {
                    Window window = ComponentActivity.this.getWindow();
                    View viewPeekDecorView = window != null ? window.peekDecorView() : null;
                    if (viewPeekDecorView != null) {
                        viewPeekDecorView.cancelPendingInputEvents();
                    }
                }
            }
        });
        hVar.a(new b.j.e() { // from class: androidx.activity.ComponentActivity.4
            @Override // b.j.e
            public void g(g gVar, d.a aVar) {
                if (aVar == d.a.ON_DESTROY) {
                    ComponentActivity.this.f5b.f197b = null;
                    if (ComponentActivity.this.isChangingConfigurations()) {
                        return;
                    }
                    ComponentActivity.this.e().a();
                }
            }
        });
        hVar.a(new b.j.e() { // from class: androidx.activity.ComponentActivity.5
            @Override // b.j.e
            public void g(g gVar, d.a aVar) {
                ComponentActivity.this.l();
                h hVar2 = ComponentActivity.this.f6c;
                hVar2.c("removeObserver");
                hVar2.f1290a.e(this);
            }
        });
        bVar.f1312b.b("android:support:activity-result", new c());
        k(new d());
    }

    @Override // b.j.g
    public b.j.d a() {
        return this.f6c;
    }

    @Override // android.app.Activity
    public void addContentView(@SuppressLint({"UnknownNullness", "MissingNullability"}) View view, @SuppressLint({"UnknownNullness", "MissingNullability"}) ViewGroup.LayoutParams layoutParams) {
        m();
        super.addContentView(view, layoutParams);
    }

    @Override // b.a.c
    public final OnBackPressedDispatcher c() {
        return this.f9f;
    }

    @Override // b.l.c
    public final b.l.a d() {
        return this.f7d.f1312b;
    }

    @Override // b.j.u
    public t e() {
        if (getApplication() == null) {
            throw new IllegalStateException("Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.");
        }
        l();
        return this.f8e;
    }

    @Override // b.a.e.e
    public final b.a.e.d g() {
        return this.g;
    }

    public final void k(b.a.d.b bVar) {
        b.a.d.a aVar = this.f5b;
        if (aVar.f197b != null) {
            bVar.a(aVar.f197b);
        }
        aVar.f196a.add(bVar);
    }

    public void l() {
        if (this.f8e == null) {
            e eVar = (e) getLastNonConfigurationInstance();
            if (eVar != null) {
                this.f8e = eVar.f16a;
            }
            if (this.f8e == null) {
                this.f8e = new t();
            }
        }
    }

    public final void m() {
        getWindow().getDecorView().setTag(R.id.view_tree_lifecycle_owner, this);
        getWindow().getDecorView().setTag(R.id.view_tree_view_model_store_owner, this);
        getWindow().getDecorView().setTag(R.id.view_tree_saved_state_registry_owner, this);
    }

    @Override // android.app.Activity
    @Deprecated
    public void onActivityResult(int i, int i2, Intent intent) {
        if (this.g.a(i, i2, intent)) {
            return;
        }
        super.onActivityResult(i, i2, intent);
    }

    @Override // android.app.Activity
    public void onBackPressed() {
        this.f9f.a();
    }

    @Override // b.f.b.c, android.app.Activity
    public void onCreate(Bundle bundle) {
        this.f7d.a(bundle);
        b.a.d.a aVar = this.f5b;
        aVar.f197b = this;
        Iterator<b.a.d.b> it = aVar.f196a.iterator();
        while (it.hasNext()) {
            it.next().a(this);
        }
        super.onCreate(bundle);
        o.b(this);
    }

    @Override // android.app.Activity
    @Deprecated
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        if (this.g.a(i, -1, new Intent().putExtra("androidx.activity.result.contract.extra.PERMISSIONS", strArr).putExtra("androidx.activity.result.contract.extra.PERMISSION_GRANT_RESULTS", iArr))) {
            return;
        }
        super.onRequestPermissionsResult(i, strArr, iArr);
    }

    @Override // android.app.Activity
    public final Object onRetainNonConfigurationInstance() {
        e eVar;
        t tVar = this.f8e;
        if (tVar == null && (eVar = (e) getLastNonConfigurationInstance()) != null) {
            tVar = eVar.f16a;
        }
        if (tVar == null) {
            return null;
        }
        e eVar2 = new e();
        eVar2.f16a = tVar;
        return eVar2;
    }

    @Override // b.f.b.c, android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        h hVar = this.f6c;
        if (hVar instanceof h) {
            d.b bVar = d.b.CREATED;
            hVar.c("setCurrentState");
            hVar.f(bVar);
        }
        super.onSaveInstanceState(bundle);
        this.f7d.b(bundle);
    }

    @Override // android.app.Activity
    public void reportFullyDrawn() {
        try {
            if (b.f.b.b.t()) {
                Trace.beginSection("reportFullyDrawn() for " + getComponentName());
            }
            super.reportFullyDrawn();
        } finally {
            Trace.endSection();
        }
    }

    @Override // android.app.Activity
    public void setContentView(int i) {
        m();
        super.setContentView(i);
    }

    @Override // android.app.Activity
    public void setContentView(@SuppressLint({"UnknownNullness", "MissingNullability"}) View view) {
        m();
        super.setContentView(view);
    }

    @Override // android.app.Activity
    public void setContentView(@SuppressLint({"UnknownNullness", "MissingNullability"}) View view, @SuppressLint({"UnknownNullness", "MissingNullability"}) ViewGroup.LayoutParams layoutParams) {
        m();
        super.setContentView(view, layoutParams);
    }

    @Override // android.app.Activity
    @Deprecated
    public void startActivityForResult(@SuppressLint({"UnknownNullness"}) Intent intent, int i) {
        super.startActivityForResult(intent, i);
    }

    @Override // android.app.Activity
    @Deprecated
    public void startActivityForResult(@SuppressLint({"UnknownNullness"}) Intent intent, int i, Bundle bundle) {
        super.startActivityForResult(intent, i, bundle);
    }

    @Override // android.app.Activity
    @Deprecated
    public void startIntentSenderForResult(@SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4) throws IntentSender.SendIntentException {
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4);
    }

    @Override // android.app.Activity
    @Deprecated
    public void startIntentSenderForResult(@SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4, Bundle bundle) throws IntentSender.SendIntentException {
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
    }
}
