package X6FRs_4.IMuAHx_6.Mqv2r_3;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
/* compiled from: NavUtils.java */
/* loaded from: classes.dex */
public final class Mqv2r_3 {
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m310KQgRr5e_0(Activity activity, Intent intent) {
        if (Build.VERSION.SDK_INT >= 16) {
            return activity.shouldUpRecreateTask(intent);
        }
        String action = activity.getIntent().getAction();
        return (action == null || action.equals("android.intent.action.MAIN")) ? false : true;
    }

    public static void KQgRr5e_0(Activity activity, Intent intent) {
        if (Build.VERSION.SDK_INT >= 16) {
            activity.navigateUpTo(intent);
            return;
        }
        intent.addFlags(67108864);
        activity.startActivity(intent);
        activity.finish();
    }

    public static Intent KQgRr5e_0(Activity activity) {
        Intent parentActivityIntent;
        if (Build.VERSION.SDK_INT < 16 || (parentActivityIntent = activity.getParentActivityIntent()) == null) {
            String m308KQgRr5e_0 = m308KQgRr5e_0(activity);
            if (m308KQgRr5e_0 == null) {
                return null;
            }
            ComponentName componentName = new ComponentName(activity, m308KQgRr5e_0);
            try {
                if (m309KQgRr5e_0((Context) activity, componentName) == null) {
                    return Intent.makeMainActivity(componentName);
                }
                return new Intent().setComponent(componentName);
            } catch (PackageManager.NameNotFoundException unused) {
                Log.e("NavUtils", "getParentActivityIntent: bad parentActivityName '" + m308KQgRr5e_0 + "' in manifest");
                return null;
            }
        }
        return parentActivityIntent;
    }

    public static Intent KQgRr5e_0(Context context, ComponentName componentName) throws PackageManager.NameNotFoundException {
        String m309KQgRr5e_0 = m309KQgRr5e_0(context, componentName);
        if (m309KQgRr5e_0 == null) {
            return null;
        }
        ComponentName componentName2 = new ComponentName(componentName.getPackageName(), m309KQgRr5e_0);
        if (m309KQgRr5e_0(context, componentName2) == null) {
            return Intent.makeMainActivity(componentName2);
        }
        return new Intent().setComponent(componentName2);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static String m308KQgRr5e_0(Activity activity) {
        try {
            return m309KQgRr5e_0((Context) activity, activity.getComponentName());
        } catch (PackageManager.NameNotFoundException e) {
            throw new IllegalArgumentException(e);
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static String m309KQgRr5e_0(Context context, ComponentName componentName) throws PackageManager.NameNotFoundException {
        String string;
        String str;
        PackageManager packageManager = context.getPackageManager();
        int i = Build.VERSION.SDK_INT;
        ActivityInfo activityInfo = packageManager.getActivityInfo(componentName, 640);
        if (Build.VERSION.SDK_INT < 16 || (str = activityInfo.parentActivityName) == null) {
            Bundle bundle = activityInfo.metaData;
            if (bundle == null || (string = bundle.getString("android.support.PARENT_ACTIVITY")) == null) {
                return null;
            }
            if (string.charAt(0) == '.') {
                return context.getPackageName() + string;
            }
            return string;
        }
        return str;
    }
}
