package p037.p041.p042;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.LocaleList;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import java.util.ArrayList;
import java.util.Objects;
import p037.p041.C1476;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p041.p049.AbstractC1547;
import p037.p041.p049.C1550;
import p037.p041.p049.C1554;
import p037.p041.p051.C1615;
import p037.p041.p051.C1697;
import p037.p065.p067.C1830;
import p037.p065.p067.InterfaceC1849;
import p037.p065.p068.C1850;
import p037.p065.p068.p069.C1861;
import p037.p089.p090.ActivityC1999;
import p037.p099.p100.C2253;
import p037.p099.p101.C2254;
import p037.p112.C2429;

/* JADX INFO: renamed from: މ.ؠ.ވ.އ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class ActivityC1491 extends ActivityC1999 implements InterfaceC1492, InterfaceC1849 {
    public AbstractC1493 mDelegate;
    public Resources mResources;

    private void initViewTreeOwners() {
        getWindow().getDecorView().setTag(C2253.view_tree_lifecycle_owner, this);
        getWindow().getDecorView().setTag(C2254.view_tree_view_model_store_owner, this);
        getWindow().getDecorView().setTag(C2429.view_tree_saved_state_registry_owner, this);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        initViewTreeOwners();
        getDelegate().mo2825(view, layoutParams);
    }

    /* JADX WARN: Removed duplicated region for block: B:132:0x006e A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:17:0x0049  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0068  */
    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void attachBaseContext(Context context) {
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.f4714 = true;
        int i = layoutInflaterFactory2C1494.f4718;
        if (i == -100) {
            i = -100;
        }
        int iM2832 = layoutInflaterFactory2C1494.m2832(context, i);
        Configuration configuration = null;
        boolean z = false;
        if (LayoutInflaterFactory2C1494.f4680 && (context instanceof ContextThemeWrapper)) {
            Configuration configurationM2834 = layoutInflaterFactory2C1494.m2834(context, iM2832, (Configuration) null);
            Log.d("AppCompatDelegate", String.format("Attempting to apply config to base context: %s", configurationM2834.toString()));
            try {
                ((ContextThemeWrapper) context).applyOverrideConfiguration(configurationM2834);
            } catch (IllegalStateException e) {
                Log.d("AppCompatDelegate", "Failed to apply configuration to base context", e);
                if (!(context instanceof C1550)) {
                }
            }
        } else if (!(context instanceof C1550)) {
            Configuration configurationM28342 = layoutInflaterFactory2C1494.m2834(context, iM2832, (Configuration) null);
            Log.d("AppCompatDelegate", String.format("Attempting to apply config to base context: %s", configurationM28342.toString()));
            try {
                ((C1550) context).m3050(configurationM28342);
            } catch (IllegalStateException e2) {
                Log.d("AppCompatDelegate", "Failed to apply configuration to base context", e2);
                if (LayoutInflaterFactory2C1494.f4679) {
                }
            }
        } else if (LayoutInflaterFactory2C1494.f4679) {
            try {
                Configuration configuration2 = context.getPackageManager().getResourcesForApplication(context.getApplicationInfo()).getConfiguration();
                Configuration configuration3 = context.getResources().getConfiguration();
                if (configuration2.equals(configuration3)) {
                    Log.d("AppCompatDelegate", "Application config (" + configuration2 + ") matches base context config, using empty base overlay");
                } else {
                    configuration = new Configuration();
                    configuration.fontScale = 0.0f;
                    if (configuration3 != null && configuration2.diff(configuration3) != 0) {
                        float f = configuration2.fontScale;
                        float f2 = configuration3.fontScale;
                        if (f != f2) {
                            configuration.fontScale = f2;
                        }
                        int i2 = configuration2.mcc;
                        int i3 = configuration3.mcc;
                        if (i2 != i3) {
                            configuration.mcc = i3;
                        }
                        int i4 = configuration2.mnc;
                        int i5 = configuration3.mnc;
                        if (i4 != i5) {
                            configuration.mnc = i5;
                        }
                        if (Build.VERSION.SDK_INT >= 24) {
                            LocaleList locales = configuration2.getLocales();
                            LocaleList locales2 = configuration3.getLocales();
                            if (!locales.equals(locales2)) {
                                configuration.setLocales(locales2);
                                configuration.locale = configuration3.locale;
                            }
                        } else if (!Objects.equals(configuration2.locale, configuration3.locale)) {
                            configuration.locale = configuration3.locale;
                        }
                        int i6 = configuration2.touchscreen;
                        int i7 = configuration3.touchscreen;
                        if (i6 != i7) {
                            configuration.touchscreen = i7;
                        }
                        int i8 = configuration2.keyboard;
                        int i9 = configuration3.keyboard;
                        if (i8 != i9) {
                            configuration.keyboard = i9;
                        }
                        int i10 = configuration2.keyboardHidden;
                        int i11 = configuration3.keyboardHidden;
                        if (i10 != i11) {
                            configuration.keyboardHidden = i11;
                        }
                        int i12 = configuration2.navigation;
                        int i13 = configuration3.navigation;
                        if (i12 != i13) {
                            configuration.navigation = i13;
                        }
                        int i14 = configuration2.navigationHidden;
                        int i15 = configuration3.navigationHidden;
                        if (i14 != i15) {
                            configuration.navigationHidden = i15;
                        }
                        int i16 = configuration2.orientation;
                        int i17 = configuration3.orientation;
                        if (i16 != i17) {
                            configuration.orientation = i17;
                        }
                        int i18 = configuration2.screenLayout & 15;
                        int i19 = configuration3.screenLayout & 15;
                        if (i18 != i19) {
                            configuration.screenLayout |= i19;
                        }
                        int i20 = configuration2.screenLayout & 192;
                        int i21 = configuration3.screenLayout & 192;
                        if (i20 != i21) {
                            configuration.screenLayout |= i21;
                        }
                        int i22 = configuration2.screenLayout & 48;
                        int i23 = configuration3.screenLayout & 48;
                        if (i22 != i23) {
                            configuration.screenLayout |= i23;
                        }
                        int i24 = configuration2.screenLayout & 768;
                        int i25 = configuration3.screenLayout & 768;
                        if (i24 != i25) {
                            configuration.screenLayout |= i25;
                        }
                        if (Build.VERSION.SDK_INT >= 26) {
                            int i26 = configuration2.colorMode & 3;
                            int i27 = configuration3.colorMode & 3;
                            if (i26 != i27) {
                                configuration.colorMode |= i27;
                            }
                            int i28 = configuration2.colorMode & 12;
                            int i29 = configuration3.colorMode & 12;
                            if (i28 != i29) {
                                configuration.colorMode |= i29;
                            }
                        }
                        int i30 = configuration2.uiMode & 15;
                        int i31 = configuration3.uiMode & 15;
                        if (i30 != i31) {
                            configuration.uiMode |= i31;
                        }
                        int i32 = configuration2.uiMode & 48;
                        int i33 = configuration3.uiMode & 48;
                        if (i32 != i33) {
                            configuration.uiMode |= i33;
                        }
                        int i34 = configuration2.screenWidthDp;
                        int i35 = configuration3.screenWidthDp;
                        if (i34 != i35) {
                            configuration.screenWidthDp = i35;
                        }
                        int i36 = configuration2.screenHeightDp;
                        int i37 = configuration3.screenHeightDp;
                        if (i36 != i37) {
                            configuration.screenHeightDp = i37;
                        }
                        int i38 = configuration2.smallestScreenWidthDp;
                        int i39 = configuration3.smallestScreenWidthDp;
                        if (i38 != i39) {
                            configuration.smallestScreenWidthDp = i39;
                        }
                        int i40 = configuration2.densityDpi;
                        int i41 = configuration3.densityDpi;
                        if (i40 != i41) {
                            configuration.densityDpi = i41;
                        }
                    }
                    Log.d("AppCompatDelegate", "Application config (" + configuration2 + ") does not match base config (" + configuration3 + "), using base overlay: " + configuration);
                }
                Configuration configurationM28343 = layoutInflaterFactory2C1494.m2834(context, iM2832, configuration);
                Log.d("AppCompatDelegate", String.format("Applying night mode using ContextThemeWrapper and applyOverrideConfiguration(). Config: %s", configurationM28343.toString()));
                C1550 c1550 = new C1550(context, C1476.Theme_AppCompat_Empty);
                c1550.m3050(configurationM28343);
                try {
                    z = context.getTheme() != null;
                } catch (NullPointerException unused) {
                }
                if (z) {
                    Resources.Theme theme = c1550.getTheme();
                    int i42 = Build.VERSION.SDK_INT;
                    if (i42 >= 29) {
                        theme.rebase();
                    } else if (i42 >= 23) {
                        C1861.m3664(theme);
                    }
                }
                context = c1550;
            } catch (PackageManager.NameNotFoundException e3) {
                throw new RuntimeException("Application failed to obtain resources from itself", e3);
            }
        }
        super.attachBaseContext(context);
    }

    @Override // android.app.Activity
    public void closeOptionsMenu() {
        getSupportActionBar();
        if (getWindow().hasFeature(0)) {
            super.closeOptionsMenu();
        }
    }

    @Override // p037.p065.p067.ActivityC1841, android.app.Activity, android.view.Window.Callback
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        keyEvent.getKeyCode();
        getSupportActionBar();
        return super.dispatchKeyEvent(keyEvent);
    }

    @Override // android.app.Activity
    public <T extends View> T findViewById(int i) {
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.m2851();
        return (T) layoutInflaterFactory2C1494.f4684.findViewById(i);
    }

    public AbstractC1493 getDelegate() {
        if (this.mDelegate == null) {
            this.mDelegate = AbstractC1493.m2817(this, this);
        }
        return this.mDelegate;
    }

    @Override // android.app.Activity
    public MenuInflater getMenuInflater() {
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        if (layoutInflaterFactory2C1494.f4688 == null) {
            layoutInflaterFactory2C1494.m2854();
            AbstractC1478 abstractC1478 = layoutInflaterFactory2C1494.f4687;
            layoutInflaterFactory2C1494.f4688 = new C1554(abstractC1478 != null ? abstractC1478.mo2811() : layoutInflaterFactory2C1494.f4683);
        }
        return layoutInflaterFactory2C1494.f4688;
    }

    @Override // android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
    public Resources getResources() {
        if (this.mResources == null) {
            C1697.m3316();
        }
        Resources resources = this.mResources;
        return resources == null ? super.getResources() : resources;
    }

    public AbstractC1478 getSupportActionBar() {
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.m2854();
        return layoutInflaterFactory2C1494.f4687;
    }

    @Override // p037.p065.p067.InterfaceC1849
    public Intent getSupportParentActivityIntent() {
        return LayoutInflaterFactory2C1494.C1505.m2890((Activity) this);
    }

    @Override // android.app.Activity
    public void invalidateOptionsMenu() {
        getDelegate().mo2828();
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.mResources != null) {
            this.mResources.updateConfiguration(configuration, super.getResources().getDisplayMetrics());
        }
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        if (layoutInflaterFactory2C1494.f4705 && layoutInflaterFactory2C1494.f4699) {
            layoutInflaterFactory2C1494.m2854();
            AbstractC1478 abstractC1478 = layoutInflaterFactory2C1494.f4687;
            if (abstractC1478 != null) {
                abstractC1478.mo2804(configuration);
            }
        }
        C1615.m3156().m3161(layoutInflaterFactory2C1494.f4683);
        layoutInflaterFactory2C1494.m2843(false);
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public void onContentChanged() {
    }

    @Override // p037.p089.p090.ActivityC1999, androidx.activity.ComponentActivity, p037.p065.p067.ActivityC1841, android.app.Activity
    public void onCreate(Bundle bundle) {
        AbstractC1493 delegate = getDelegate();
        delegate.mo2822();
        delegate.mo2823(bundle);
        super.onCreate(bundle);
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        getDelegate().mo2831();
    }

    @Override // android.app.Activity, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        Window window;
        if ((Build.VERSION.SDK_INT >= 26 || keyEvent.isCtrlPressed() || KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState()) || keyEvent.getRepeatCount() != 0 || KeyEvent.isModifierKey(keyEvent.getKeyCode()) || (window = getWindow()) == null || window.getDecorView() == null || !window.getDecorView().dispatchKeyShortcutEvent(keyEvent)) ? false : true) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity, android.view.Window.Callback
    public final boolean onMenuItemSelected(int i, MenuItem menuItem) {
        Intent intentM2890;
        if (super.onMenuItemSelected(i, menuItem)) {
            return true;
        }
        AbstractC1478 supportActionBar = getSupportActionBar();
        if (menuItem.getItemId() != 16908332 || supportActionBar == null || (supportActionBar.mo2809() & 4) == 0 || (intentM2890 = LayoutInflaterFactory2C1494.C1505.m2890((Activity) this)) == null) {
            return false;
        }
        if (!shouldUpRecreateTask(intentM2890)) {
            navigateUpTo(intentM2890);
            return true;
        }
        ArrayList arrayList = new ArrayList();
        Intent supportParentActivityIntent = getSupportParentActivityIntent();
        if (supportParentActivityIntent == null) {
            supportParentActivityIntent = LayoutInflaterFactory2C1494.C1505.m2890((Activity) this);
        }
        if (supportParentActivityIntent != null) {
            ComponentName component = supportParentActivityIntent.getComponent();
            if (component == null) {
                component = supportParentActivityIntent.resolveActivity(getPackageManager());
            }
            int size = arrayList.size();
            try {
                Intent intentM2891 = LayoutInflaterFactory2C1494.C1505.m2891((Context) this, component);
                while (intentM2891 != null) {
                    arrayList.add(size, intentM2891);
                    intentM2891 = LayoutInflaterFactory2C1494.C1505.m2891((Context) this, intentM2891.getComponent());
                }
                arrayList.add(supportParentActivityIntent);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e("TaskStackBuilder", "Bad ComponentName while traversing activity parent metadata");
                throw new IllegalArgumentException(e);
            }
        }
        if (arrayList.isEmpty()) {
            throw new IllegalStateException("No intents added to TaskStackBuilder; cannot startActivities");
        }
        Intent[] intentArr = (Intent[]) arrayList.toArray(new Intent[arrayList.size()]);
        intentArr[0] = new Intent(intentArr[0]).addFlags(268484608);
        C1850.m3651(this, intentArr, (Bundle) null);
        try {
            C1830.m3630((Activity) this);
            return true;
        } catch (IllegalStateException unused) {
            finish();
            return true;
        }
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onMenuOpened(int i, Menu menu) {
        return super.onMenuOpened(i, menu);
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity, android.view.Window.Callback
    public void onPanelClosed(int i, Menu menu) {
        super.onPanelClosed(i, menu);
    }

    @Override // android.app.Activity
    public void onPostCreate(Bundle bundle) {
        super.onPostCreate(bundle);
        ((LayoutInflaterFactory2C1494) getDelegate()).m2851();
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity
    public void onPostResume() {
        super.onPostResume();
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.m2854();
        AbstractC1478 abstractC1478 = layoutInflaterFactory2C1494.f4687;
        if (abstractC1478 != null) {
            abstractC1478.mo2812(true);
        }
    }

    @Override // p037.p089.p090.ActivityC1999, androidx.activity.ComponentActivity, p037.p065.p067.ActivityC1841, android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        if (((LayoutInflaterFactory2C1494) getDelegate()) == null) {
            throw null;
        }
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity
    public void onStart() {
        super.onStart();
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.f4716 = true;
        layoutInflaterFactory2C1494.m2848();
    }

    @Override // p037.p089.p090.ActivityC1999, android.app.Activity
    public void onStop() {
        super.onStop();
        LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = (LayoutInflaterFactory2C1494) getDelegate();
        layoutInflaterFactory2C1494.f4716 = false;
        layoutInflaterFactory2C1494.m2854();
        AbstractC1478 abstractC1478 = layoutInflaterFactory2C1494.f4687;
        if (abstractC1478 != null) {
            abstractC1478.mo2812(false);
        }
    }

    @Override // p037.p041.p042.InterfaceC1492
    public void onSupportActionModeFinished(AbstractC1547 abstractC1547) {
    }

    @Override // p037.p041.p042.InterfaceC1492
    public void onSupportActionModeStarted(AbstractC1547 abstractC1547) {
    }

    @Override // android.app.Activity
    public void onTitleChanged(CharSequence charSequence, int i) {
        super.onTitleChanged(charSequence, i);
        getDelegate().mo2826(charSequence);
    }

    @Override // p037.p041.p042.InterfaceC1492
    public AbstractC1547 onWindowStartingSupportActionMode(AbstractC1547.InterfaceC1548 interfaceC1548) {
        return null;
    }

    @Override // android.app.Activity
    public void openOptionsMenu() {
        getSupportActionBar();
        if (getWindow().hasFeature(0)) {
            super.openOptionsMenu();
        }
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(int i) {
        initViewTreeOwners();
        getDelegate().mo2829(i);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(View view) {
        initViewTreeOwners();
        getDelegate().mo2824(view);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        initViewTreeOwners();
        getDelegate().mo2830(view, layoutParams);
    }

    @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
    public void setTheme(int i) {
        super.setTheme(i);
        ((LayoutInflaterFactory2C1494) getDelegate()).f4719 = i;
    }

    @Override // p037.p089.p090.ActivityC1999
    public void supportInvalidateOptionsMenu() {
        getDelegate().mo2828();
    }
}
