package q6; 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 e6.j; import e6.l; import h6.h; import java.util.List; /* loaded from: classes2.dex */ public class d implements l { /* renamed from: a, reason: collision with root package name */ private final Context f13491a; public d(Context context) { this.f13491a = context.getApplicationContext(); } private int c(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 d(Uri uri) { try { return Integer.parseInt(uri.getPathSegments().get(0)); } catch (NumberFormatException e10) { throw new IllegalArgumentException("Unrecognized Uri format: " + uri, e10); } } private Context e(Uri uri, String str) { if (str.equals(this.f13491a.getPackageName())) { return this.f13491a; } try { return this.f13491a.createPackageContext(str, 0); } catch (PackageManager.NameNotFoundException e10) { if (str.contains(this.f13491a.getPackageName())) { return this.f13491a; } throw new IllegalArgumentException("Failed to obtain context or unrecognized Uri format for: " + uri, e10); } } private int f(Context context, Uri uri) { List pathSegments = uri.getPathSegments(); if (pathSegments.size() == 2) { return c(context, uri); } if (pathSegments.size() == 1) { return d(uri); } throw new IllegalArgumentException("Unrecognized Uri format: " + uri); } @Override // e6.l /* renamed from: g, reason: merged with bridge method [inline-methods] */ public h a(Uri uri, int i10, int i11, j jVar) { Context e10 = e(uri, uri.getAuthority()); return f.e(a.e(this.f13491a, e10, f(e10, uri))); } @Override // e6.l /* renamed from: h, reason: merged with bridge method [inline-methods] */ public boolean b(Uri uri, j jVar) { return uri.getScheme().equals("android.resource"); } }