package o; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import android.text.TextUtils; import com.bumptech.glide.load.ImageHeaderParser; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.List; /* loaded from: classes.dex */ final class FIN { private static final C0886QuU c = new C0886QuU(); private final Opg a; private final List b; private final AtO d; private final ContentResolver e; private final C0886QuU h; /* JADX INFO: Access modifiers changed from: package-private */ public FIN(List list, AtO atO, Opg opg, ContentResolver contentResolver) { this(list, c, atO, opg, contentResolver); } private FIN(List list, C0886QuU c0886QuU, AtO atO, Opg opg, ContentResolver contentResolver) { this.h = c0886QuU; this.d = atO; this.a = opg; this.e = contentResolver; this.b = list; } /* JADX INFO: Access modifiers changed from: package-private */ public final int DR_(Uri uri) { InputStream inputStream = null; try { inputStream = this.e.openInputStream(uri); int c2 = hKF.c(this.b, inputStream, this.a); if (inputStream != null) { try { inputStream.close(); } catch (IOException unused) { } } return c2; } catch (IOException | NullPointerException unused2) { if (inputStream == null) { return -1; } try { inputStream.close(); return -1; } catch (IOException unused3) { return -1; } } catch (Throwable th) { if (inputStream != null) { try { inputStream.close(); } catch (IOException unused4) { } } throw th; } } public final InputStream DS_(Uri uri) throws FileNotFoundException { String DQ_ = DQ_(uri); if (TextUtils.isEmpty(DQ_)) { return null; } File file = new File(DQ_); if (!file.exists() || 0 >= file.length()) { return null; } Uri fromFile = Uri.fromFile(file); try { return this.e.openInputStream(fromFile); } catch (NullPointerException e) { StringBuilder sb = new StringBuilder("NPE opening uri: "); sb.append(uri); sb.append(" -> "); sb.append(fromFile); throw ((FileNotFoundException) new FileNotFoundException(sb.toString()).initCause(e)); } } private String DQ_(Uri uri) { Cursor cursor; Cursor cursor2 = null; try { cursor = this.d.DP_(uri); if (cursor != null) { try { if (cursor.moveToFirst()) { String string = cursor.getString(0); if (cursor != null) { cursor.close(); } return string; } } catch (SecurityException unused) { if (cursor != null) { cursor.close(); } return null; } catch (Throwable th) { cursor2 = cursor; th = th; if (cursor2 != null) { cursor2.close(); } throw th; } } if (cursor != null) { cursor.close(); } return null; } catch (SecurityException unused2) { cursor = null; } catch (Throwable th2) { th = th2; } } }