package o; import android.content.Context; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PointF; import android.net.Uri; import android.text.TextUtils; import android.view.View; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.pdfview.subsamplincscaleimageview.SubsamplingScaleImageView; import java.io.InputStream; import java.lang.reflect.Method; import java.util.List; /* loaded from: classes3.dex */ public class wwB implements xOV { private static int a = 1; private static int c; private final Bitmap.Config d; public wwB() { this((byte) 0); } private wwB(byte b) { Bitmap.Config Pi_ = SubsamplingScaleImageView.Pi_(); if (Pi_ != null) { this.d = Pi_; } else { this.d = Bitmap.Config.RGB_565; } } @Override // o.xOV public final Bitmap Pt_(Context context, Uri uri) throws Exception { Bitmap decodeStream; int i = 2 % 2; String obj = uri.toString(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = this.d; int i2 = a + 23; c = i2 % 128; int i3 = i2 % 2; try { int i4 = 0; if (((Boolean) String.class.getMethod("startsWith", String.class).invoke(obj, "android.resource://")).booleanValue()) { int i5 = c + 57; a = i5 % 128; int i6 = i5 % 2; String authority = uri.getAuthority(); Resources resources = ((Boolean) String.class.getMethod("equals", Object.class).invoke(context.getPackageName(), authority)).booleanValue() ? context.getResources() : context.getPackageManager().getResourcesForApplication(authority); List pathSegments = uri.getPathSegments(); int size = pathSegments.size(); if (size == 2) { if (((Boolean) String.class.getMethod("equals", Object.class).invoke(pathSegments.get(0), "drawable")).booleanValue()) { int i7 = a + 31; c = i7 % 128; int i8 = i7 % 2; i4 = resources.getIdentifier(pathSegments.get(1), "drawable", authority); decodeStream = BitmapFactory.decodeResource(context.getResources(), i4, options); } } if (size == 1 && TextUtils.isDigitsOnly(pathSegments.get(0))) { try { i4 = Integer.parseInt(pathSegments.get(0)); } catch (NumberFormatException unused) { } } decodeStream = BitmapFactory.decodeResource(context.getResources(), i4, options); } else { InputStream inputStream = null; if (!(!((Boolean) String.class.getMethod("startsWith", String.class).invoke(obj, "file:///android_asset/")).booleanValue())) { int i9 = c + 19; a = i9 % 128; int i10 = i9 % 2; try { Object[] objArr = {context.getAssets(), (String) String.class.getMethod("substring", Integer.TYPE).invoke(obj, 22)}; Object obj2 = xzZ.y.get(-867414553); if (obj2 == null) { obj2 = ((Class) xzZ.c(5 - (PointF.length(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED) > BitmapDescriptorFactory.HUE_RED ? 1 : (PointF.length(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED) == BitmapDescriptorFactory.HUE_RED ? 0 : -1)), 5 - View.resolveSizeAndState(0, 0, 0), (char) Color.green(0))).getMethod("NN_", AssetManager.class, String.class); xzZ.y.put(-867414553, obj2); } decodeStream = BitmapFactory.decodeStream((InputStream) ((Method) obj2).invoke(null, objArr), null, options); } catch (Throwable th) { Throwable cause = th.getCause(); if (cause != null) { throw cause; } throw th; } } else if (((Boolean) String.class.getMethod("startsWith", String.class).invoke(obj, "file://")).booleanValue()) { int i11 = c + 125; a = i11 % 128; int i12 = i11 % 2; decodeStream = BitmapFactory.decodeFile((String) String.class.getMethod("substring", Integer.TYPE).invoke(obj, 7), options); } else { try { InputStream openInputStream = context.getContentResolver().openInputStream(uri); try { decodeStream = BitmapFactory.decodeStream(openInputStream, null, options); if (openInputStream != null) { int i13 = c + 113; a = i13 % 128; try { if (i13 % 2 == 0) { openInputStream.close(); inputStream.hashCode(); throw null; } openInputStream.close(); } catch (Exception unused2) { } } } catch (Throwable th2) { th = th2; inputStream = openInputStream; if (inputStream != null) { try { inputStream.close(); } catch (Exception unused3) { } } throw th; } } catch (Throwable th3) { th = th3; } } } if (decodeStream != null) { return decodeStream; } throw new RuntimeException("Skia image region decoder returned null bitmap - image format may not be supported"); } catch (Throwable th4) { Throwable cause2 = th4.getCause(); if (cause2 != null) { throw cause2; } throw th4; } } }