package androidx.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Trace;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.result.ActivityResultRegistry;
import androidx.activity.result.IntentSenderRequest;
import androidx.lifecycle.SavedStateHandleAttacher;
import c.a.k;
import c.a.m.d.a;
import c.f.b.b;
import c.f.b.i;
import c.f.b.j;
import c.f.b.m;
import c.f.j.l;
import c.l.a0;
import c.l.c0;
import c.l.f0;
import c.l.g0;
import c.l.h;
import c.l.h0;
import c.l.j;
import c.l.n;
import c.l.o;
import c.l.x;
import c.l.z;
import c.o.b;
import c.o.e;
import com.ifpdos.debugmenu.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public class ComponentActivity extends i implements n, h0, h, c.o.d, k, c.a.m.c {
    private static final String ACTIVITY_RESULT_TAG = "android:support:activity-result";
    private final ActivityResultRegistry mActivityResultRegistry;
    private int mContentLayoutId;
    public final c.a.l.a mContextAwareHelper;
    private f0.b mDefaultFactory;
    private boolean mDispatchingOnMultiWindowModeChanged;
    private boolean mDispatchingOnPictureInPictureModeChanged;
    private final o mLifecycleRegistry;
    private final l mMenuHostHelper;
    private final AtomicInteger mNextLocalRequestCode;
    private final OnBackPressedDispatcher mOnBackPressedDispatcher;
    private final CopyOnWriteArrayList<c.f.i.a<Configuration>> mOnConfigurationChangedListeners;
    private final CopyOnWriteArrayList<c.f.i.a<j>> mOnMultiWindowModeChangedListeners;
    private final CopyOnWriteArrayList<c.f.i.a<Intent>> mOnNewIntentListeners;
    private final CopyOnWriteArrayList<c.f.i.a<m>> mOnPictureInPictureModeChangedListeners;
    private final CopyOnWriteArrayList<c.f.i.a<Integer>> mOnTrimMemoryListeners;
    public final c.o.c mSavedStateRegistryController;
    private g0 mViewModelStore;

    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 ActivityResultRegistry {

        public class a implements Runnable {

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

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ a.C0002a f4e;

            public a(int i2, a.C0002a c0002a) {
                this.f3b = i2;
                this.f4e = c0002a;
            }

            @Override // java.lang.Runnable
            public void run() {
                c.a.m.a<?> aVar;
                b bVar = b.this;
                int i2 = this.f3b;
                Object obj = this.f4e.a;
                String str = bVar.f25b.get(Integer.valueOf(i2));
                if (str == null) {
                    return;
                }
                ActivityResultRegistry.c<?> cVar = bVar.f29f.get(str);
                if (cVar == null || (aVar = cVar.a) == null) {
                    bVar.f31h.remove(str);
                    bVar.f30g.put(str, obj);
                } else if (bVar.f28e.remove(str)) {
                    aVar.a(obj);
                }
            }
        }

        /* JADX INFO: renamed from: androidx.activity.ComponentActivity$b$b, reason: collision with other inner class name */
        public class RunnableC0000b implements Runnable {

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

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ IntentSender.SendIntentException f7e;

            public RunnableC0000b(int i2, IntentSender.SendIntentException sendIntentException) {
                this.f6b = i2;
                this.f7e = sendIntentException;
            }

            @Override // java.lang.Runnable
            public void run() {
                b.this.a(this.f6b, 0, new Intent().setAction("androidx.activity.result.contract.action.INTENT_SENDER_REQUEST").putExtra("androidx.activity.result.contract.extra.SEND_INTENT_EXCEPTION", this.f7e));
            }
        }

        public b() {
        }

        /* JADX WARN: Multi-variable type inference failed */
        @Override // androidx.activity.result.ActivityResultRegistry
        public <I, O> void b(int i2, c.a.m.d.a<I, O> aVar, I i3, c.f.b.c cVar) {
            Bundle bundle;
            ComponentActivity componentActivity = ComponentActivity.this;
            a.C0002a<O> c0002aB = aVar.b(componentActivity, i3);
            if (c0002aB != null) {
                new Handler(Looper.getMainLooper()).post(new a(i2, c0002aB));
                return;
            }
            Intent intentA = aVar.a(componentActivity, i3);
            if (intentA.getExtras() != null && intentA.getExtras().getClassLoader() == null) {
                intentA.setExtrasClassLoader(componentActivity.getClassLoader());
            }
            if (intentA.hasExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE")) {
                Bundle bundleExtra = intentA.getBundleExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
                intentA.removeExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
                bundle = bundleExtra;
            } else {
                if (cVar != null) {
                    throw null;
                }
                bundle = null;
            }
            if (!"androidx.activity.result.contract.action.REQUEST_PERMISSIONS".equals(intentA.getAction())) {
                if (!"androidx.activity.result.contract.action.INTENT_SENDER_REQUEST".equals(intentA.getAction())) {
                    int i4 = c.f.b.b.f1274b;
                    b.a.b(componentActivity, intentA, i2, bundle);
                    return;
                }
                IntentSenderRequest intentSenderRequest = (IntentSenderRequest) intentA.getParcelableExtra("androidx.activity.result.contract.extra.INTENT_SENDER_REQUEST");
                try {
                    IntentSender intentSender = intentSenderRequest.f41b;
                    Intent intent = intentSenderRequest.f42e;
                    int i5 = intentSenderRequest.f43f;
                    int i6 = intentSenderRequest.f44g;
                    int i7 = c.f.b.b.f1274b;
                    b.a.c(componentActivity, intentSender, i2, intent, i5, i6, 0, bundle);
                    return;
                } catch (IntentSender.SendIntentException e2) {
                    new Handler(Looper.getMainLooper()).post(new RunnableC0000b(i2, e2));
                    return;
                }
            }
            String[] stringArrayExtra = intentA.getStringArrayExtra("androidx.activity.result.contract.extra.PERMISSIONS");
            if (stringArrayExtra == null) {
                stringArrayExtra = new String[0];
            }
            int i8 = c.f.b.b.f1274b;
            HashSet hashSet = new HashSet();
            for (int i9 = 0; i9 < stringArrayExtra.length; i9++) {
                if (TextUtils.isEmpty(stringArrayExtra[i9])) {
                    throw new IllegalArgumentException(d.b.a.a.a.v(d.b.a.a.a.B("Permission request for permissions "), Arrays.toString(stringArrayExtra), " must not contain null or empty values"));
                }
                if (!c.f.b.h.s() && TextUtils.equals(stringArrayExtra[i9], "android.permission.POST_NOTIFICATIONS")) {
                    hashSet.add(Integer.valueOf(i9));
                }
            }
            int size = hashSet.size();
            String[] strArr = size > 0 ? new String[stringArrayExtra.length - size] : stringArrayExtra;
            if (size > 0) {
                if (size == stringArrayExtra.length) {
                    return;
                }
                int i10 = 0;
                for (int i11 = 0; i11 < stringArrayExtra.length; i11++) {
                    if (!hashSet.contains(Integer.valueOf(i11))) {
                        strArr[i10] = stringArrayExtra[i11];
                        i10++;
                    }
                }
            }
            if (componentActivity instanceof b.d) {
                ((b.d) componentActivity).validateRequestPermissionsRequestCode(i2);
            }
            b.c.b(componentActivity, stringArrayExtra, i2);
        }
    }

    public static class c {
        public static OnBackInvokedDispatcher a(Activity activity) {
            return activity.getOnBackInvokedDispatcher();
        }
    }

    public static final class d {
        public Object a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public g0 f9b;
    }

    public ComponentActivity() {
        this.mContextAwareHelper = new c.a.l.a();
        this.mMenuHostHelper = new l(new Runnable() { // from class: c.a.b
            @Override // java.lang.Runnable
            public final void run() {
                this.f525b.invalidateMenu();
            }
        });
        this.mLifecycleRegistry = new o(this);
        c.o.c cVarA = c.o.c.a(this);
        this.mSavedStateRegistryController = cVarA;
        this.mOnBackPressedDispatcher = new OnBackPressedDispatcher(new a());
        this.mNextLocalRequestCode = new AtomicInteger();
        this.mActivityResultRegistry = new b();
        this.mOnConfigurationChangedListeners = new CopyOnWriteArrayList<>();
        this.mOnTrimMemoryListeners = new CopyOnWriteArrayList<>();
        this.mOnNewIntentListeners = new CopyOnWriteArrayList<>();
        this.mOnMultiWindowModeChangedListeners = new CopyOnWriteArrayList<>();
        this.mOnPictureInPictureModeChangedListeners = new CopyOnWriteArrayList<>();
        this.mDispatchingOnMultiWindowModeChanged = false;
        this.mDispatchingOnPictureInPictureModeChanged = false;
        if (getLifecycle() == 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.");
        }
        getLifecycle().a(new c.l.l() { // from class: androidx.activity.ComponentActivity.3
            @Override // c.l.l
            public void g(n nVar, j.a aVar) {
                if (aVar == j.a.ON_STOP) {
                    Window window = ComponentActivity.this.getWindow();
                    View viewPeekDecorView = window != null ? window.peekDecorView() : null;
                    if (viewPeekDecorView != null) {
                        viewPeekDecorView.cancelPendingInputEvents();
                    }
                }
            }
        });
        getLifecycle().a(new c.l.l() { // from class: androidx.activity.ComponentActivity.4
            @Override // c.l.l
            public void g(n nVar, j.a aVar) {
                if (aVar == j.a.ON_DESTROY) {
                    ComponentActivity.this.mContextAwareHelper.f532b = null;
                    if (ComponentActivity.this.isChangingConfigurations()) {
                        return;
                    }
                    ComponentActivity.this.getViewModelStore().a();
                }
            }
        });
        getLifecycle().a(new c.l.l() { // from class: androidx.activity.ComponentActivity.5
            @Override // c.l.l
            public void g(n nVar, j.a aVar) {
                ComponentActivity.this.ensureViewModelStore();
                ComponentActivity.this.getLifecycle().c(this);
            }
        });
        cVarA.b();
        g.h0.c.l.f(this, "<this>");
        j.b bVarB = getLifecycle().b();
        g.h0.c.l.e(bVarB, "lifecycle.currentState");
        if (!(bVarB == j.b.INITIALIZED || bVarB == j.b.CREATED)) {
            throw new IllegalArgumentException("Failed requirement.".toString());
        }
        if (getSavedStateRegistry().b("androidx.lifecycle.internal.SavedStateHandlesProvider") == null) {
            a0 a0Var = new a0(getSavedStateRegistry(), this);
            getSavedStateRegistry().c("androidx.lifecycle.internal.SavedStateHandlesProvider", a0Var);
            getLifecycle().a(new SavedStateHandleAttacher(a0Var));
        }
        getSavedStateRegistry().c(ACTIVITY_RESULT_TAG, new b.InterfaceC0024b() { // from class: c.a.e
            @Override // c.o.b.InterfaceC0024b
            public final Bundle a() {
                return this.a.c();
            }
        });
        addOnContextAvailableListener(new c.a.l.b() { // from class: c.a.d
            @Override // c.a.l.b
            public final void a(Context context) {
                this.a.d(context);
            }
        });
    }

    private void initViewTreeOwners() {
        getWindow().getDecorView().setTag(R.id.view_tree_lifecycle_owner, this);
        getWindow().getDecorView().setTag(R.id.view_tree_view_model_store_owner, this);
        e.a(getWindow().getDecorView(), this);
        View decorView = getWindow().getDecorView();
        g.h0.c.l.f(decorView, "<this>");
        g.h0.c.l.f(this, "onBackPressedDispatcherOwner");
        decorView.setTag(R.id.view_tree_on_back_pressed_dispatcher_owner, this);
    }

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

    public void addMenuProvider(c.f.j.n nVar) {
        l lVar = this.mMenuHostHelper;
        lVar.f1435b.add(nVar);
        lVar.a.run();
    }

    public final void addOnConfigurationChangedListener(c.f.i.a<Configuration> aVar) {
        this.mOnConfigurationChangedListeners.add(aVar);
    }

    public final void addOnContextAvailableListener(c.a.l.b bVar) {
        c.a.l.a aVar = this.mContextAwareHelper;
        if (aVar.f532b != null) {
            bVar.a(aVar.f532b);
        }
        aVar.a.add(bVar);
    }

    public final void addOnMultiWindowModeChangedListener(c.f.i.a<c.f.b.j> aVar) {
        this.mOnMultiWindowModeChangedListeners.add(aVar);
    }

    public final void addOnNewIntentListener(c.f.i.a<Intent> aVar) {
        this.mOnNewIntentListeners.add(aVar);
    }

    public final void addOnPictureInPictureModeChangedListener(c.f.i.a<m> aVar) {
        this.mOnPictureInPictureModeChangedListeners.add(aVar);
    }

    public final void addOnTrimMemoryListener(c.f.i.a<Integer> aVar) {
        this.mOnTrimMemoryListeners.add(aVar);
    }

    public Bundle c() {
        Bundle bundle = new Bundle();
        ActivityResultRegistry activityResultRegistry = this.mActivityResultRegistry;
        Objects.requireNonNull(activityResultRegistry);
        bundle.putIntegerArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_RCS", new ArrayList<>(activityResultRegistry.f26c.values()));
        bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS", new ArrayList<>(activityResultRegistry.f26c.keySet()));
        bundle.putStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS", new ArrayList<>(activityResultRegistry.f28e));
        bundle.putBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT", (Bundle) activityResultRegistry.f31h.clone());
        bundle.putSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT", activityResultRegistry.a);
        return bundle;
    }

    public void d(Context context) {
        Bundle bundleA = getSavedStateRegistry().a(ACTIVITY_RESULT_TAG);
        if (bundleA != null) {
            ActivityResultRegistry activityResultRegistry = this.mActivityResultRegistry;
            Objects.requireNonNull(activityResultRegistry);
            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;
            }
            activityResultRegistry.f28e = bundleA.getStringArrayList("KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS");
            activityResultRegistry.a = (Random) bundleA.getSerializable("KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT");
            activityResultRegistry.f31h.putAll(bundleA.getBundle("KEY_COMPONENT_ACTIVITY_PENDING_RESULT"));
            for (int i2 = 0; i2 < stringArrayList.size(); i2++) {
                String str = stringArrayList.get(i2);
                if (activityResultRegistry.f26c.containsKey(str)) {
                    Integer numRemove = activityResultRegistry.f26c.remove(str);
                    if (!activityResultRegistry.f31h.containsKey(str)) {
                        activityResultRegistry.f25b.remove(numRemove);
                    }
                }
                int iIntValue = integerArrayList.get(i2).intValue();
                String str2 = stringArrayList.get(i2);
                activityResultRegistry.f25b.put(Integer.valueOf(iIntValue), str2);
                activityResultRegistry.f26c.put(str2, Integer.valueOf(iIntValue));
            }
        }
    }

    public void ensureViewModelStore() {
        if (this.mViewModelStore == null) {
            d dVar = (d) getLastNonConfigurationInstance();
            if (dVar != null) {
                this.mViewModelStore = dVar.f9b;
            }
            if (this.mViewModelStore == null) {
                this.mViewModelStore = new g0();
            }
        }
    }

    @Override // c.a.m.c
    public final ActivityResultRegistry getActivityResultRegistry() {
        return this.mActivityResultRegistry;
    }

    @Override // c.l.h
    public c.l.i0.a getDefaultViewModelCreationExtras() {
        c.l.i0.c cVar = new c.l.i0.c();
        if (getApplication() != null) {
            f0.a.C0017a c0017a = f0.a.f1772c;
            cVar.b(f0.a.C0017a.C0018a.a, getApplication());
        }
        cVar.b(z.a, this);
        cVar.b(z.f1805b, this);
        if (getIntent() != null && getIntent().getExtras() != null) {
            cVar.b(z.f1806c, getIntent().getExtras());
        }
        return cVar;
    }

    public f0.b getDefaultViewModelProviderFactory() {
        if (this.mDefaultFactory == null) {
            this.mDefaultFactory = new c0(getApplication(), this, getIntent() != null ? getIntent().getExtras() : null);
        }
        return this.mDefaultFactory;
    }

    @Deprecated
    public Object getLastCustomNonConfigurationInstance() {
        d dVar = (d) getLastNonConfigurationInstance();
        if (dVar != null) {
            return dVar.a;
        }
        return null;
    }

    @Override // c.f.b.i, c.l.n
    public c.l.j getLifecycle() {
        return this.mLifecycleRegistry;
    }

    @Override // c.a.k
    public final OnBackPressedDispatcher getOnBackPressedDispatcher() {
        return this.mOnBackPressedDispatcher;
    }

    @Override // c.o.d
    public final c.o.b getSavedStateRegistry() {
        return this.mSavedStateRegistryController.f1917b;
    }

    @Override // c.l.h0
    public g0 getViewModelStore() {
        if (getApplication() == null) {
            throw new IllegalStateException("Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.");
        }
        ensureViewModelStore();
        return this.mViewModelStore;
    }

    public void invalidateMenu() {
        invalidateOptionsMenu();
    }

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

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

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        Iterator<c.f.i.a<Configuration>> it = this.mOnConfigurationChangedListeners.iterator();
        while (it.hasNext()) {
            it.next().accept(configuration);
        }
    }

    @Override // c.f.b.i, android.app.Activity
    public void onCreate(Bundle bundle) {
        this.mSavedStateRegistryController.c(bundle);
        c.a.l.a aVar = this.mContextAwareHelper;
        aVar.f532b = this;
        Iterator<c.a.l.b> it = aVar.a.iterator();
        while (it.hasNext()) {
            it.next().a(this);
        }
        super.onCreate(bundle);
        x.c(this);
        if (c.f.b.h.s()) {
            OnBackPressedDispatcher onBackPressedDispatcher = this.mOnBackPressedDispatcher;
            onBackPressedDispatcher.f17e = c.a(this);
            onBackPressedDispatcher.b();
        }
        int i2 = this.mContentLayoutId;
        if (i2 != 0) {
            setContentView(i2);
        }
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onCreatePanelMenu(int i2, Menu menu) {
        if (i2 != 0) {
            return true;
        }
        super.onCreatePanelMenu(i2, menu);
        this.mMenuHostHelper.a(menu, getMenuInflater());
        return true;
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onMenuItemSelected(int i2, MenuItem menuItem) {
        if (super.onMenuItemSelected(i2, menuItem)) {
            return true;
        }
        if (i2 == 0) {
            return this.mMenuHostHelper.b(menuItem);
        }
        return false;
    }

    @Override // android.app.Activity
    public void onMultiWindowModeChanged(boolean z) {
        if (this.mDispatchingOnMultiWindowModeChanged) {
            return;
        }
        Iterator<c.f.i.a<c.f.b.j>> it = this.mOnMultiWindowModeChangedListeners.iterator();
        while (it.hasNext()) {
            it.next().accept(new c.f.b.j(z));
        }
    }

    @Override // android.app.Activity
    public void onNewIntent(@SuppressLint({"UnknownNullness", "MissingNullability"}) Intent intent) {
        super.onNewIntent(intent);
        Iterator<c.f.i.a<Intent>> it = this.mOnNewIntentListeners.iterator();
        while (it.hasNext()) {
            it.next().accept(intent);
        }
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public void onPanelClosed(int i2, Menu menu) {
        Iterator<c.f.j.n> it = this.mMenuHostHelper.f1435b.iterator();
        while (it.hasNext()) {
            it.next().c();
        }
        super.onPanelClosed(i2, menu);
    }

    @Override // android.app.Activity
    public void onPictureInPictureModeChanged(boolean z) {
        if (this.mDispatchingOnPictureInPictureModeChanged) {
            return;
        }
        Iterator<c.f.i.a<m>> it = this.mOnPictureInPictureModeChangedListeners.iterator();
        while (it.hasNext()) {
            it.next().accept(new m(z));
        }
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onPreparePanel(int i2, View view, Menu menu) {
        if (i2 != 0) {
            return true;
        }
        super.onPreparePanel(i2, view, menu);
        this.mMenuHostHelper.c(menu);
        return true;
    }

    @Override // android.app.Activity
    @Deprecated
    public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
        if (this.mActivityResultRegistry.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);
    }

    @Deprecated
    public Object onRetainCustomNonConfigurationInstance() {
        return null;
    }

    @Override // android.app.Activity
    public final Object onRetainNonConfigurationInstance() {
        d dVar;
        Object objOnRetainCustomNonConfigurationInstance = onRetainCustomNonConfigurationInstance();
        g0 g0Var = this.mViewModelStore;
        if (g0Var == null && (dVar = (d) getLastNonConfigurationInstance()) != null) {
            g0Var = dVar.f9b;
        }
        if (g0Var == null && objOnRetainCustomNonConfigurationInstance == null) {
            return null;
        }
        d dVar2 = new d();
        dVar2.a = objOnRetainCustomNonConfigurationInstance;
        dVar2.f9b = g0Var;
        return dVar2;
    }

    @Override // c.f.b.i, android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        c.l.j lifecycle = getLifecycle();
        if (lifecycle instanceof o) {
            ((o) lifecycle).j(j.b.CREATED);
        }
        super.onSaveInstanceState(bundle);
        this.mSavedStateRegistryController.d(bundle);
    }

    @Override // android.app.Activity, android.content.ComponentCallbacks2
    public void onTrimMemory(int i2) {
        super.onTrimMemory(i2);
        Iterator<c.f.i.a<Integer>> it = this.mOnTrimMemoryListeners.iterator();
        while (it.hasNext()) {
            it.next().accept(Integer.valueOf(i2));
        }
    }

    public Context peekAvailableContext() {
        return this.mContextAwareHelper.f532b;
    }

    public final <I, O> c.a.m.b<I> registerForActivityResult(c.a.m.d.a<I, O> aVar, ActivityResultRegistry activityResultRegistry, c.a.m.a<O> aVar2) {
        StringBuilder sbB = d.b.a.a.a.B("activity_rq#");
        sbB.append(this.mNextLocalRequestCode.getAndIncrement());
        return activityResultRegistry.d(sbB.toString(), this, aVar, aVar2);
    }

    public void removeMenuProvider(c.f.j.n nVar) {
        this.mMenuHostHelper.d(nVar);
    }

    public final void removeOnConfigurationChangedListener(c.f.i.a<Configuration> aVar) {
        this.mOnConfigurationChangedListeners.remove(aVar);
    }

    public final void removeOnContextAvailableListener(c.a.l.b bVar) {
        this.mContextAwareHelper.a.remove(bVar);
    }

    public final void removeOnMultiWindowModeChangedListener(c.f.i.a<c.f.b.j> aVar) {
        this.mOnMultiWindowModeChangedListeners.remove(aVar);
    }

    public final void removeOnNewIntentListener(c.f.i.a<Intent> aVar) {
        this.mOnNewIntentListeners.remove(aVar);
    }

    public final void removeOnPictureInPictureModeChangedListener(c.f.i.a<m> aVar) {
        this.mOnPictureInPictureModeChangedListeners.remove(aVar);
    }

    public final void removeOnTrimMemoryListener(c.f.i.a<Integer> aVar) {
        this.mOnTrimMemoryListeners.remove(aVar);
    }

    @Override // android.app.Activity
    public void reportFullyDrawn() {
        try {
            if (c.n.a.K()) {
                Trace.beginSection("reportFullyDrawn() for ComponentActivity");
            }
            super.reportFullyDrawn();
            Trace.endSection();
        } catch (Throwable th) {
            Trace.endSection();
            throw th;
        }
    }

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

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

    @Override // android.app.Activity
    @Deprecated
    public void startIntentSenderForResult(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 startActivityForResult(Intent intent, int i2, Bundle bundle) {
        super.startActivityForResult(intent, i2, bundle);
    }

    @Override // android.app.Activity
    @Deprecated
    public void startIntentSenderForResult(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);
    }

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

    public void addMenuProvider(final c.f.j.n nVar, n nVar2) {
        final l lVar = this.mMenuHostHelper;
        lVar.f1435b.add(nVar);
        lVar.a.run();
        c.l.j lifecycle = nVar2.getLifecycle();
        l.a aVarRemove = lVar.f1436c.remove(nVar);
        if (aVarRemove != null) {
            aVarRemove.a();
        }
        lVar.f1436c.put(nVar, new l.a(lifecycle, new c.l.l() { // from class: c.f.j.b
            @Override // c.l.l
            public final void g(c.l.n nVar3, j.a aVar) {
                l lVar2 = lVar;
                n nVar4 = nVar;
                Objects.requireNonNull(lVar2);
                if (aVar == j.a.ON_DESTROY) {
                    lVar2.d(nVar4);
                }
            }
        }));
    }

    @Override // android.app.Activity
    public void onMultiWindowModeChanged(boolean z, Configuration configuration) {
        this.mDispatchingOnMultiWindowModeChanged = true;
        try {
            super.onMultiWindowModeChanged(z, configuration);
            this.mDispatchingOnMultiWindowModeChanged = false;
            Iterator<c.f.i.a<c.f.b.j>> it = this.mOnMultiWindowModeChangedListeners.iterator();
            while (it.hasNext()) {
                it.next().accept(new c.f.b.j(z, configuration));
            }
        } catch (Throwable th) {
            this.mDispatchingOnMultiWindowModeChanged = false;
            throw th;
        }
    }

    @Override // android.app.Activity
    public void onPictureInPictureModeChanged(boolean z, Configuration configuration) {
        this.mDispatchingOnPictureInPictureModeChanged = true;
        try {
            super.onPictureInPictureModeChanged(z, configuration);
            this.mDispatchingOnPictureInPictureModeChanged = false;
            Iterator<c.f.i.a<m>> it = this.mOnPictureInPictureModeChangedListeners.iterator();
            while (it.hasNext()) {
                it.next().accept(new m(z, configuration));
            }
        } catch (Throwable th) {
            this.mDispatchingOnPictureInPictureModeChanged = false;
            throw th;
        }
    }

    public final <I, O> c.a.m.b<I> registerForActivityResult(c.a.m.d.a<I, O> aVar, c.a.m.a<O> aVar2) {
        return registerForActivityResult(aVar, this.mActivityResultRegistry, aVar2);
    }

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

    @SuppressLint({"LambdaLast"})
    public void addMenuProvider(final c.f.j.n nVar, n nVar2, final j.b bVar) {
        final l lVar = this.mMenuHostHelper;
        Objects.requireNonNull(lVar);
        c.l.j lifecycle = nVar2.getLifecycle();
        l.a aVarRemove = lVar.f1436c.remove(nVar);
        if (aVarRemove != null) {
            aVarRemove.a();
        }
        lVar.f1436c.put(nVar, new l.a(lifecycle, new c.l.l() { // from class: c.f.j.a
            @Override // c.l.l
            public final void g(c.l.n nVar3, j.a aVar) {
                l lVar2 = lVar;
                j.b bVar2 = bVar;
                n nVar4 = nVar;
                Objects.requireNonNull(lVar2);
                if (aVar == j.a.upTo(bVar2)) {
                    lVar2.f1435b.add(nVar4);
                    lVar2.a.run();
                } else if (aVar == j.a.ON_DESTROY) {
                    lVar2.d(nVar4);
                } else if (aVar == j.a.downFrom(bVar2)) {
                    lVar2.f1435b.remove(nVar4);
                    lVar2.a.run();
                }
            }
        }));
    }

    public ComponentActivity(int i2) {
        this();
        this.mContentLayoutId = i2;
    }
}
