package com.seewo.ota.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.util.Log;
import android.view.MenuItem;
import androidx.fragment.app.Fragment;
import com.seewo.ota.R;

/* JADX INFO: loaded from: classes.dex */
public class MainActivity extends androidx.appcompat.app.c {
    private UserManager v;

    private boolean K() {
        UserManager userManager;
        return (getResources().getBoolean(R.bool.support_child_user_ota) || (userManager = this.v) == null || userManager.isAdminUser()) ? false : true;
    }

    private void L(String str) {
        if (s().l0() > 0) {
            s().R0(null, 1);
        }
        if (K()) {
            M();
            return;
        }
        if ("com.seewo.ota.action.UPDATE_HOME_SETTINGS".equals(str)) {
            N();
            return;
        }
        if ("com.seewo.ota.action.UPDATE_INFO_SETTINGS".equals(str)) {
            O();
            return;
        }
        if ("com.seewo.ota.action.UPDATE_INFO_SETTINGS2".equals(str)) {
            P();
            return;
        }
        if ("com.seewo.ota.action.UPDATE_INFO_SETTINGS3".equals(str)) {
            Q();
        } else if (getResources().getBoolean(R.bool.support_local_ota)) {
            N();
        } else {
            O();
        }
    }

    private void M() {
        Log.d("MainActivity", "switchChildUserFragment");
        androidx.fragment.app.v vVarL = s().l();
        vVarL.j(R.id.content, new e2());
        vVarL.f();
    }

    private void N() {
        Log.d("MainActivity", "switchOTAUpdateHomeFragment");
        androidx.fragment.app.v vVarL = s().l();
        vVarL.j(R.id.content, new i2());
        vVarL.f();
    }

    private void O() {
        Log.d("MainActivity", "switchUpdateInfoFragment");
        androidx.fragment.app.v vVarL = s().l();
        vVarL.j(R.id.content, new j2());
        vVarL.f();
    }

    private void P() {
        Log.d("MainActivity", "switchUpdateInfoFragment2");
        androidx.fragment.app.v vVarL = s().l();
        vVarL.j(R.id.content, new l2());
        vVarL.f();
    }

    private void Q() {
        Log.d("MainActivity", "switchUpdateInfoFragment3");
        androidx.fragment.app.v vVarL = s().l();
        vVarL.j(R.id.content, new m2());
        vVarL.f();
    }

    public Fragment J(Fragment fragment) {
        if (fragment != null) {
            Log.d("MainActivity", "AddSubFragment:" + fragment.getClass().getName());
            androidx.fragment.app.v vVarL = s().l();
            vVarL.m(4099);
            vVarL.e("BackStack_" + fragment.getClass().getSimpleName());
            vVarL.j(R.id.content, fragment);
            vVarL.f();
        }
        return fragment;
    }

    @Override // androidx.appcompat.app.c, androidx.fragment.app.d, androidx.activity.ComponentActivity, androidx.core.app.d, android.app.Activity
    protected void onCreate(Bundle bundle) {
        requestWindowFeature(0);
        super.onCreate(bundle);
        setContentView(R.layout.activity_main);
        this.v = (UserManager) getSystemService("user");
        L(getIntent().getAction());
        if (B() != null) {
            B().s(true);
        }
    }

    @Override // androidx.fragment.app.d, android.app.Activity
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        L(intent.getAction());
    }

    @Override // android.app.Activity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        onBackPressed();
        return true;
    }
}
