what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzpy.java

204 lines
8.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import com.google.android.gms.common.internal.GmsLogger;
import com.google.android.gms.common.util.IOUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes2.dex */
public final class zzpy {
private static final GmsLogger zzaoz = new GmsLogger("MLKitImageUtils", "");
private static zzpy zzaxq = new zzpy();
private zzpy() {
}
/* JADX WARN: Failed to find 'out' block for switch in B:9:0x0044. Please report as an issue. */
public static Bitmap zza(ContentResolver contentResolver, Uri uri, int i) throws IOException {
InputStream inputStream;
InputStream inputStream2;
BitmapFactory.Options options;
InputStream openInputStream;
Matrix matrix;
Bitmap createBitmap;
InputStream inputStream3 = null;
Matrix matrix2 = null;
r12 = null;
r12 = null;
InputStream inputStream4 = null;
try {
inputStream2 = contentResolver.openInputStream(uri);
try {
try {
BitmapFactory.Options options2 = new BitmapFactory.Options();
options2.inJustDecodeBounds = true;
BitmapFactory.decodeStream(inputStream2, null, options2);
options = new BitmapFactory.Options();
options.inSampleSize = Math.max(options.outWidth / 1024, options.outHeight / 1024);
openInputStream = contentResolver.openInputStream(uri);
} catch (FileNotFoundException e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
} catch (FileNotFoundException e2) {
e = e2;
inputStream2 = null;
} catch (Throwable th2) {
th = th2;
inputStream = null;
IOUtils.closeQuietly(inputStream3);
IOUtils.closeQuietly(inputStream);
throw th;
}
try {
Bitmap decodeStream = BitmapFactory.decodeStream(openInputStream, null, options);
int zza = zza(contentResolver, uri);
Matrix matrix3 = new Matrix();
int width = decodeStream.getWidth();
int height = decodeStream.getHeight();
switch (zza) {
case 2:
matrix2 = new Matrix();
matrix2.postScale(-1.0f, 1.0f);
matrix = matrix2;
break;
case 3:
matrix3.postRotate(180.0f);
matrix = matrix3;
break;
case 4:
matrix3.postScale(1.0f, -1.0f);
matrix = matrix3;
break;
case 5:
matrix3.postRotate(90.0f);
matrix3.postScale(-1.0f, 1.0f);
matrix = matrix3;
break;
case 6:
matrix3.postRotate(90.0f);
matrix = matrix3;
break;
case 7:
matrix3.postRotate(-90.0f);
matrix3.postScale(-1.0f, 1.0f);
matrix = matrix3;
break;
case 8:
matrix3.postRotate(-90.0f);
matrix = matrix3;
break;
default:
matrix = matrix2;
break;
}
if (matrix != null && decodeStream != (createBitmap = Bitmap.createBitmap(decodeStream, 0, 0, width, height, matrix, true))) {
decodeStream.recycle();
decodeStream = createBitmap;
}
IOUtils.closeQuietly(inputStream2);
IOUtils.closeQuietly(openInputStream);
return decodeStream;
} catch (FileNotFoundException e3) {
e = e3;
inputStream4 = openInputStream;
GmsLogger gmsLogger = zzaoz;
String valueOf = String.valueOf(uri.toString());
gmsLogger.e("MLKitImageUtils", valueOf.length() != 0 ? "Could not open file: ".concat(valueOf) : new String("Could not open file: "), e);
throw e;
} catch (Throwable th3) {
th = th3;
inputStream4 = openInputStream;
inputStream = inputStream4;
inputStream3 = inputStream2;
IOUtils.closeQuietly(inputStream3);
IOUtils.closeQuietly(inputStream);
throw th;
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:14:0x005d A[RETURN] */
/* JADX WARN: Removed duplicated region for block: B:15:0x005e */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static int zza(android.content.ContentResolver r7, android.net.Uri r8) {
/*
java.lang.String r0 = "content"
java.lang.String r1 = r8.getScheme()
boolean r0 = r0.equals(r1)
r1 = 0
if (r0 != 0) goto L1a
java.lang.String r0 = "file"
java.lang.String r2 = r8.getScheme()
boolean r0 = r0.equals(r2)
if (r0 != 0) goto L1a
return r1
L1a:
r0 = 0
java.io.InputStream r7 = r7.openInputStream(r8) // Catch: java.lang.Throwable -> L2e java.io.IOException -> L30
o.hvV r2 = new o.hvV // Catch: java.lang.Throwable -> L29 java.io.IOException -> L2c
r2.<init>(r7) // Catch: java.lang.Throwable -> L29 java.io.IOException -> L2c
com.google.android.gms.common.util.IOUtils.closeQuietly(r7)
r0 = r2
goto L5b
L29:
r8 = move-exception
r0 = r7
goto L66
L2c:
r2 = move-exception
goto L32
L2e:
r7 = move-exception
goto L67
L30:
r2 = move-exception
r7 = r0
L32:
com.google.android.gms.common.internal.GmsLogger r3 = com.google.android.gms.internal.firebase_ml.zzpy.zzaoz // Catch: java.lang.Throwable -> L29
java.lang.String r8 = java.lang.String.valueOf(r8) // Catch: java.lang.Throwable -> L29
java.lang.String r4 = java.lang.String.valueOf(r8) // Catch: java.lang.Throwable -> L29
int r4 = r4.length() // Catch: java.lang.Throwable -> L29
java.lang.StringBuilder r5 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L29
int r4 = r4 + 48
r5.<init>(r4) // Catch: java.lang.Throwable -> L29
java.lang.String r4 = "MLKitImageUtils"
java.lang.String r6 = "failed to open file to read rotation meta data: "
r5.append(r6) // Catch: java.lang.Throwable -> L29
r5.append(r8) // Catch: java.lang.Throwable -> L29
java.lang.String r8 = r5.toString() // Catch: java.lang.Throwable -> L29
r3.e(r4, r8, r2) // Catch: java.lang.Throwable -> L29
com.google.android.gms.common.util.IOUtils.closeQuietly(r7)
L5b:
if (r0 != 0) goto L5e
return r1
L5e:
java.lang.String r7 = "Orientation"
r8 = 1
int r7 = r0.a(r7, r8)
return r7
L66:
r7 = r8
L67:
com.google.android.gms.common.util.IOUtils.closeQuietly(r0)
throw r7
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.firebase_ml.zzpy.zza(android.content.ContentResolver, android.net.Uri):int");
}
public static zzpy zznl() {
return zzaxq;
}
}