package androidx.activity;

import android.annotation.SuppressLint;
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 c.i.d;
import c.i.e;
import c.i.g;
import c.i.h;
import c.i.n;
import c.i.p;
import c.i.q;
import com.ifpdos.factory.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 c.e.b.b implements g, q, c.j.c {

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final c.j.b f4530e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public p f4531f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final OnBackPressedDispatcher f4532g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final c.a.d.c f4533h;

    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 c.a.d.c {
        public b(ComponentActivity componentActivity) {
        }
    }

    public static final class c {

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

    public ComponentActivity() {
        h hVar = new h(this);
        this.f4529d = hVar;
        this.f4530e = new c.j.b(this);
        this.f4532g = new OnBackPressedDispatcher(new a());
        new AtomicInteger();
        this.f4533h = 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 e() { // from class: androidx.activity.ComponentActivity.3
            @Override // c.i.e
            public void e(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 e() { // from class: androidx.activity.ComponentActivity.4
            @Override // c.i.e
            public void e(g gVar, d.a aVar) {
                if (aVar == d.a.ON_DESTROY) {
                    ComponentActivity.this.f4528c.f4721b = null;
                    if (ComponentActivity.this.isChangingConfigurations()) {
                        return;
                    }
                    ComponentActivity.this.d().a();
                }
            }
        });
        hVar.a(new e() { // from class: androidx.activity.ComponentActivity.5
            @Override // c.i.e
            public void e(g gVar, d.a aVar) {
                ComponentActivity.this.f();
                h hVar2 = ComponentActivity.this.f4529d;
                hVar2.c("removeObserver");
                hVar2.f5380a.e(this);
            }
        });
    }

    @Override // c.i.g
    public d a() {
        return this.f4529d;
    }

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

    @Override // c.j.c
    public final c.j.a b() {
        return this.f4530e.f5400b;
    }

    @Override // c.i.q
    public p d() {
        if (getApplication() == null) {
            throw new IllegalStateException("Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.");
        }
        f();
        return this.f4531f;
    }

    public void f() {
        if (this.f4531f == null) {
            c cVar = (c) getLastNonConfigurationInstance();
            if (cVar != null) {
                this.f4531f = cVar.f4538a;
            }
            if (this.f4531f == null) {
                this.f4531f = new p();
            }
        }
    }

    public final void g() {
        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 i2, int i3, Intent intent) {
        if (this.f4533h.a(i2, i3, intent)) {
            return;
        }
        super.onActivityResult(i2, i3, intent);
    }

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

    @Override // c.e.b.b, android.app.Activity
    public void onCreate(Bundle bundle) {
        this.f4530e.a(bundle);
        c.a.c.a aVar = this.f4528c;
        aVar.f4721b = this;
        Iterator<c.a.c.b> it = aVar.f4720a.iterator();
        while (it.hasNext()) {
            it.next().a(this);
        }
        super.onCreate(bundle);
        c.a.d.c cVar = this.f4533h;
        Objects.requireNonNull(cVar);
        if (bundle != null) {
            ArrayList<Integer> integerArrayList = bundle.getIntegerArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_RCS");
            ArrayList<String> stringArrayList = bundle.getStringArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS");
            if (stringArrayList != null && integerArrayList != null) {
                int size = stringArrayList.size();
                for (int i2 = 0; i2 < size; i2++) {
                    int iIntValue = integerArrayList.get(i2).intValue();
                    String str = stringArrayList.get(i2);
                    cVar.f4725b.put(Integer.valueOf(iIntValue), str);
                    cVar.f4726c.put(str, Integer.valueOf(iIntValue));
                }
                cVar.f4728e = bundle.getStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS");
                cVar.f4724a = (Random) bundle.getSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT");
                cVar.f4731h.putAll(bundle.getBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT"));
            }
        }
        n.c(this);
    }

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

    @Override // android.app.Activity
    public final Object onRetainNonConfigurationInstance() {
        c cVar;
        p pVar = this.f4531f;
        if (pVar == null && (cVar = (c) getLastNonConfigurationInstance()) != null) {
            pVar = cVar.f4538a;
        }
        if (pVar == null) {
            return null;
        }
        c cVar2 = new c();
        cVar2.f4538a = pVar;
        return cVar2;
    }

    @Override // c.e.b.b, android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        h hVar = this.f4529d;
        if (hVar instanceof h) {
            hVar.g(d.b.CREATED);
        }
        super.onSaveInstanceState(bundle);
        this.f4530e.b(bundle);
        c.a.d.c cVar = this.f4533h;
        Objects.requireNonNull(cVar);
        bundle.putIntegerArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_RCS", new ArrayList<>(cVar.f4725b.keySet()));
        bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS", new ArrayList<>(cVar.f4725b.values()));
        bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS", new ArrayList<>(cVar.f4728e));
        bundle.putBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT", (Bundle) cVar.f4731h.clone());
        bundle.putSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT", cVar.f4724a);
    }

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

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

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

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

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

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

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

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