package b2; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.net.Uri; import com.unity3d.services.core.request.metrics.MetricCommonTags; import java.util.List; import q1.h; import q1.j; import s1.v; /* loaded from: classes.dex */ public class d implements j { /* renamed from: a, reason: collision with root package name */ private final Context f3071a; public d(Context context) { this.f3071a = context.getApplicationContext(); } private Context d(Uri uri, String str) { if (str.equals(this.f3071a.getPackageName())) { return this.f3071a; } try { return this.f3071a.createPackageContext(str, 0); } catch (PackageManager.NameNotFoundException e10) { if (str.contains(this.f3071a.getPackageName())) { return this.f3071a; } throw new IllegalArgumentException("Failed to obtain context or unrecognized Uri format for: " + uri, e10); } } private int e(Uri uri) { try { return Integer.parseInt(uri.getPathSegments().get(0)); } catch (NumberFormatException e10) { throw new IllegalArgumentException("Unrecognized Uri format: " + uri, e10); } } private int f(Context context, Uri uri) { List pathSegments = uri.getPathSegments(); String authority = uri.getAuthority(); String str = pathSegments.get(0); String str2 = pathSegments.get(1); int identifier = context.getResources().getIdentifier(str2, str, authority); if (identifier == 0) { identifier = Resources.getSystem().getIdentifier(str2, str, MetricCommonTags.METRIC_COMMON_TAG_PLATFORM_ANDROID); } if (identifier != 0) { return identifier; } throw new IllegalArgumentException("Failed to find resource id for: " + uri); } private int g(Context context, Uri uri) { List pathSegments = uri.getPathSegments(); if (pathSegments.size() == 2) { return f(context, uri); } if (pathSegments.size() == 1) { return e(uri); } throw new IllegalArgumentException("Unrecognized Uri format: " + uri); } @Override // q1.j /* renamed from: c, reason: merged with bridge method [inline-methods] */ public v a(Uri uri, int i10, int i11, h hVar) { Context d10 = d(uri, uri.getAuthority()); return c.e(a.b(this.f3071a, d10, g(d10, uri))); } @Override // q1.j /* renamed from: h, reason: merged with bridge method [inline-methods] */ public boolean b(Uri uri, h hVar) { return uri.getScheme().equals("android.resource"); } }