jimu-decompiled/sources/androidx/core/app/NavUtils.java
2025-05-13 19:24:51 +02:00

90 lines
3.2 KiB
Java

package androidx.core.app;
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.util.Log;
import com.ubtrobot.jimu.robotapi.PeripheralType;
/* loaded from: classes.dex */
public final class NavUtils {
public static void a(Activity activity, Intent intent) {
if (Build.VERSION.SDK_INT >= 16) {
activity.navigateUpTo(intent);
return;
}
intent.addFlags(67108864);
activity.startActivity(intent);
activity.finish();
}
public static boolean b(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 String b(Activity activity) {
try {
return b(activity, activity.getComponentName());
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
public static Intent a(Activity activity) {
Intent parentActivityIntent;
if (Build.VERSION.SDK_INT >= 16 && (parentActivityIntent = activity.getParentActivityIntent()) != null) {
return parentActivityIntent;
}
String b = b(activity);
if (b == null) {
return null;
}
ComponentName componentName = new ComponentName(activity, b);
try {
if (b(activity, componentName) == null) {
return Intent.makeMainActivity(componentName);
}
return new Intent().setComponent(componentName);
} catch (PackageManager.NameNotFoundException unused) {
Log.e("NavUtils", "getParentActivityIntent: bad parentActivityName '" + b + "' in manifest");
return null;
}
}
public static String b(Context context, ComponentName componentName) throws PackageManager.NameNotFoundException {
String string;
String str;
ActivityInfo activityInfo = context.getPackageManager().getActivityInfo(componentName, PeripheralType.SERVO);
if (Build.VERSION.SDK_INT >= 16 && (str = activityInfo.parentActivityName) != null) {
return str;
}
if (activityInfo.metaData == null || (string = activityInfo.metaData.getString("android.support.PARENT_ACTIVITY")) == null) {
return null;
}
if (string.charAt(0) != '.') {
return string;
}
return context.getPackageName() + string;
}
public static Intent a(Context context, ComponentName componentName) throws PackageManager.NameNotFoundException {
String b = b(context, componentName);
if (b == null) {
return null;
}
ComponentName componentName2 = new ComponentName(componentName.getPackageName(), b);
if (b(context, componentName2) == null) {
return Intent.makeMainActivity(componentName2);
}
return new Intent().setComponent(componentName2);
}
}