what-the-bank/sources/o/ioR.java

170 lines
5.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.StrictMode;
import com.airbnb.deeplinkdispatch.base.MatchIndex;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import o.ubj;
/* loaded from: classes.dex */
public class ioR {
public static File b(Context context) {
File cacheDir = context.getCacheDir();
if (cacheDir == null) {
return null;
}
StringBuilder sb = new StringBuilder(".font");
sb.append(Process.myPid());
sb.append("-");
sb.append(Process.myTid());
sb.append("-");
String obj = sb.toString();
for (int i = 0; i < 100; i++) {
StringBuilder sb2 = new StringBuilder();
sb2.append(obj);
sb2.append(i);
File file = new File(cacheDir, sb2.toString());
if (file.createNewFile()) {
return file;
}
}
return null;
}
public static ByteBuffer po_(Context context, CancellationSignal cancellationSignal, Uri uri) {
try {
ParcelFileDescriptor pq_ = Sts.pq_(context.getContentResolver(), uri, MatchIndex.ROOT_VALUE, cancellationSignal);
if (pq_ == null) {
if (pq_ != null) {
pq_.close();
}
return null;
}
try {
FileInputStream fileInputStream = new FileInputStream(pq_.getFileDescriptor());
try {
FileChannel channel = fileInputStream.getChannel();
MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, channel.size());
fileInputStream.close();
if (pq_ != null) {
pq_.close();
}
return map;
} finally {
}
} finally {
}
} catch (IOException unused) {
return null;
}
}
public static boolean e(File file, InputStream inputStream) {
FileOutputStream fileOutputStream;
StrictMode.ThreadPolicy allowThreadDiskWrites = StrictMode.allowThreadDiskWrites();
FileOutputStream fileOutputStream2 = null;
try {
try {
fileOutputStream = new FileOutputStream(file, false);
} catch (IOException e) {
e = e;
}
} catch (Throwable th) {
th = th;
fileOutputStream = fileOutputStream2;
}
try {
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
fileOutputStream.write(bArr, 0, read);
} else {
a(fileOutputStream);
StrictMode.setThreadPolicy(allowThreadDiskWrites);
return true;
}
}
} catch (IOException e2) {
e = e2;
fileOutputStream2 = fileOutputStream;
e.getMessage();
a(fileOutputStream2);
StrictMode.setThreadPolicy(allowThreadDiskWrites);
return false;
} catch (Throwable th2) {
th = th2;
a(fileOutputStream);
StrictMode.setThreadPolicy(allowThreadDiskWrites);
throw th;
}
}
public static boolean pn_(File file, Resources resources, int i) {
InputStream inputStream;
try {
inputStream = resources.openRawResource(i);
try {
boolean e = e(file, inputStream);
a(inputStream);
return e;
} catch (Throwable th) {
th = th;
a(inputStream);
throw th;
}
} catch (Throwable th2) {
th = th2;
inputStream = null;
}
}
public static void a(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException unused) {
}
}
}
public static Map<Uri, ByteBuffer> pp_(Context context, ubj.HBt[] hBtArr, CancellationSignal cancellationSignal) {
HashMap hashMap = new HashMap();
for (ubj.HBt hBt : hBtArr) {
if (hBt.a() == 0) {
Uri qG_ = hBt.qG_();
if (!hashMap.containsKey(qG_)) {
hashMap.put(qG_, po_(context, cancellationSignal, qG_));
}
}
}
return Collections.unmodifiableMap(hashMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class Sts {
static ParcelFileDescriptor pq_(ContentResolver contentResolver, Uri uri, String str, CancellationSignal cancellationSignal) throws FileNotFoundException {
return contentResolver.openFileDescriptor(uri, str, cancellationSignal);
}
}
}