discord-jadx/app/src/main/java/com/facebook/imagepipeline/producers/LocalExifThumbnailProducer....

237 lines
8.9 KiB
Java

package com.facebook.imagepipeline.producers;
import android.content.ContentResolver;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.util.Pair;
import androidx.core.util.Pools;
import c.f.d.d.f;
import c.f.d.g.g;
import c.f.d.g.h;
import c.f.j.j.e;
import c.f.j.p.d1;
import c.f.j.p.j1;
import c.f.j.p.l;
import c.f.j.p.w0;
import c.f.j.p.y0;
import c.f.m.d;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.facebook.common.memory.PooledByteBuffer;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.request.ImageRequest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
public class LocalExifThumbnailProducer implements j1<e> {
public final Executor a;
public final g b;
/* renamed from: c reason: collision with root package name */
public final ContentResolver f2200c;
@d
public class Api24Utils {
}
public class a extends d1<e> {
public final /* synthetic */ ImageRequest n;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public a(l lVar, y0 y0Var, w0 w0Var, String str, ImageRequest imageRequest) {
super(lVar, y0Var, w0Var, str);
this.n = imageRequest;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // c.f.j.p.d1
public void b(e eVar) {
e eVar2 = eVar;
if (eVar2 != null) {
eVar2.close();
}
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // c.f.j.p.d1
public Map c(e eVar) {
return f.of("createdThumbnail", Boolean.toString(eVar != null));
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX WARNING: Removed duplicated region for block: B:16:0x0034 */
/* JADX WARNING: Removed duplicated region for block: B:19:0x003b */
/* JADX WARNING: Removed duplicated region for block: B:47:0x0088 */
/* JADX WARNING: Removed duplicated region for block: B:48:0x008e */
@Override // c.f.j.p.d1
public e d() throws Exception {
String str;
ExifInterface exifInterface;
AssetFileDescriptor assetFileDescriptor;
int i;
Throwable th;
int columnIndex;
Uri uri = this.n.f2201c;
LocalExifThumbnailProducer localExifThumbnailProducer = LocalExifThumbnailProducer.this;
ContentResolver contentResolver = localExifThumbnailProducer.f2200c;
e eVar = null;
Cursor cursor = null;
r8 = null;
Pair pair = null;
eVar = null;
int i2 = -1;
if (c.f.d.l.b.c(uri)) {
try {
Cursor query = contentResolver.query(uri, null, null, null, null);
if (query != null) {
try {
if (query.moveToFirst() && (columnIndex = query.getColumnIndex("_data")) != -1) {
str = query.getString(columnIndex);
if (query != null) {
query.close();
}
}
} catch (Throwable th2) {
th = th2;
cursor = query;
if (cursor != null) {
}
throw th;
}
}
str = null;
if (query != null) {
}
} catch (Throwable th3) {
th = th3;
if (cursor != null) {
cursor.close();
}
throw th;
}
} else {
str = c.f.d.l.b.d(uri) ? uri.getPath() : null;
}
boolean z2 = false;
if (str != null) {
try {
File file = new File(str);
if (file.exists() && file.canRead()) {
z2 = true;
}
} catch (IOException unused) {
} catch (StackOverflowError unused2) {
c.f.d.e.a.a(LocalExifThumbnailProducer.class, "StackOverflowError in ExifInterface constructor");
}
}
if (z2) {
exifInterface = new ExifInterface(str);
} else {
ContentResolver contentResolver2 = localExifThumbnailProducer.f2200c;
if (c.f.d.l.b.c(uri)) {
try {
assetFileDescriptor = contentResolver2.openAssetFileDescriptor(uri, "r");
} catch (FileNotFoundException unused3) {
}
if (assetFileDescriptor != null && (i = Build.VERSION.SDK_INT) >= 24) {
ExifInterface exifInterface2 = i < 24 ? new ExifInterface(assetFileDescriptor.getFileDescriptor()) : null;
assetFileDescriptor.close();
exifInterface = exifInterface2;
}
exifInterface = null;
}
assetFileDescriptor = null;
if (i < 24) {
}
assetFileDescriptor.close();
exifInterface = exifInterface2;
}
if (exifInterface != null && exifInterface.hasThumbnail()) {
PooledByteBuffer b = LocalExifThumbnailProducer.this.b.b(exifInterface.getThumbnail());
Objects.requireNonNull(LocalExifThumbnailProducer.this);
h hVar = new h(b);
Pools.SynchronizedPool<ByteBuffer> synchronizedPool = c.f.k.a.a;
Pools.SynchronizedPool<ByteBuffer> synchronizedPool2 = c.f.k.a.a;
ByteBuffer acquire = synchronizedPool2.acquire();
if (acquire == null) {
acquire = ByteBuffer.allocate(16384);
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
options.inTempStorage = acquire.array();
BitmapFactory.decodeStream(hVar, null, options);
if (options.outWidth != -1) {
if (options.outHeight != -1) {
pair = new Pair(Integer.valueOf(options.outWidth), Integer.valueOf(options.outHeight));
}
}
synchronizedPool2.release(acquire);
int u0 = AnimatableValueParser.u0(Integer.parseInt(exifInterface.getAttribute("Orientation")));
int intValue = pair != null ? ((Integer) pair.first).intValue() : -1;
if (pair != null) {
i2 = ((Integer) pair.second).intValue();
}
CloseableReference C = CloseableReference.C(b);
try {
eVar = new e(C);
eVar.k = c.f.i.b.a;
eVar.l = u0;
eVar.n = intValue;
eVar.o = i2;
} finally {
if (C != null) {
C.close();
}
}
} catch (Throwable th4) {
c.f.k.a.a.release(acquire);
throw th4;
}
}
return eVar;
}
}
public class b extends c.f.j.p.e {
public final /* synthetic */ d1 a;
public b(LocalExifThumbnailProducer localExifThumbnailProducer, d1 d1Var) {
this.a = d1Var;
}
@Override // c.f.j.p.x0
public void a() {
this.a.a();
}
}
public LocalExifThumbnailProducer(Executor executor, g gVar, ContentResolver contentResolver) {
this.a = executor;
this.b = gVar;
this.f2200c = contentResolver;
}
@Override // c.f.j.p.j1
public boolean a(c.f.j.d.e eVar) {
return AnimatableValueParser.n1(512, 512, eVar);
}
@Override // c.f.j.p.v0
public void b(l<e> lVar, w0 w0Var) {
y0 o = w0Var.o();
ImageRequest e = w0Var.e();
w0Var.i("local", "exif");
a aVar = new a(lVar, o, w0Var, "LocalExifThumbnailProducer", e);
w0Var.f(new b(this, aVar));
this.a.execute(aVar);
}
}