package ඓ.ῲ.K.ᕣ.㳳.ᑓ;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.text.TextUtils;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import ඓ.ῲ.K.ؿ.C0821;
import ඓ.ῲ.K.ᕣ.C1121;
import ඓ.ῲ.K.ᕣ.㳳.AbstractC1033;
import ඓ.ῲ.K.ᕣ.㳳.AbstractC1091;
import ඓ.ῲ.K.ᕣ.㳳.C1092;
import ඓ.ῲ.K.ᕣ.㿎.AbstractC1146;
import ῲ.ᨨ.㳳.C1841;

/* renamed from: ඓ.ῲ.K.ᕣ.㳳.ᑓ.ඓ  reason: contains not printable characters */
/* compiled from: QMediaStoreUriLoader */
public final class C1054<DataT> implements AbstractC1033<Uri, DataT> {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final AbstractC1033<Uri, DataT> f4495;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AbstractC1033<File, DataT> f4496;

    /* renamed from: K  reason: contains not printable characters */
    public final Context f4497;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final Class<DataT> f4498;

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ᑓ.ඓ$ʬ  reason: contains not printable characters */
    /* compiled from: QMediaStoreUriLoader */
    public static final class C1055 extends AbstractC1057<InputStream> {
        public C1055(Context context) {
            super(context, InputStream.class);
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ᑓ.ඓ$ῲ  reason: contains not printable characters */
    /* compiled from: QMediaStoreUriLoader */
    public static final class C1056 extends AbstractC1057<ParcelFileDescriptor> {
        public C1056(Context context) {
            super(context, ParcelFileDescriptor.class);
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ᑓ.ඓ$K  reason: contains not printable characters */
    /* compiled from: QMediaStoreUriLoader */
    public static abstract class AbstractC1057<DataT> implements AbstractC1091<Uri, DataT> {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final Class<DataT> f4499;

        /* renamed from: K  reason: contains not printable characters */
        public final Context f4500;

        public AbstractC1057(Context context, Class<DataT> cls) {
            this.f4500 = context;
            this.f4499 = cls;
        }

        @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1091
        /* renamed from: K  reason: contains not printable characters */
        public final AbstractC1033<Uri, DataT> m2882(C1092 r6) {
            return new C1054(this.f4500, r6.m2953(File.class, this.f4499), r6.m2953(Uri.class, this.f4499), this.f4499);
        }
    }

    public C1054(Context context, AbstractC1033<File, DataT> r2, AbstractC1033<Uri, DataT> r3, Class<DataT> cls) {
        this.f4497 = context.getApplicationContext();
        this.f4496 = r2;
        this.f4495 = r3;
        this.f4498 = cls;
    }

    /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, int, int, ඓ.ῲ.K.ᕣ.㸾] */
    @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1033
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC1033.C1034 m2880(Uri uri, int i, int i2, C1121 r15) {
        Uri uri2 = uri;
        return new AbstractC1033.C1034(new C0821(uri2), new C1058(this.f4497, this.f4496, this.f4495, uri2, i, i2, r15, this.f4498));
    }

    /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
    @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1033
    /* renamed from: K  reason: contains not printable characters */
    public boolean m2881(Uri uri) {
        return Build.VERSION.SDK_INT >= 29 && C1841.m4801(uri);
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ᑓ.ඓ$㸾  reason: contains not printable characters */
    /* compiled from: QMediaStoreUriLoader */
    public static final class C1058<DataT> implements AbstractC1146<DataT> {

        /* renamed from: 㑃  reason: contains not printable characters */
        public static final String[] f4501 = {"_data"};

        /* renamed from: ʬ  reason: contains not printable characters */
        public final AbstractC1033<File, DataT> f4502;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final Uri f4503;

        /* renamed from: ᕣ  reason: contains not printable characters */
        public volatile AbstractC1146<DataT> f4504;

        /* renamed from: ᨨ  reason: contains not printable characters */
        public final Class<DataT> f4505;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final Context f4506;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public final int f4507;

        /* renamed from: 㳳  reason: contains not printable characters */
        public volatile boolean f4508;

        /* renamed from: 㴹  reason: contains not printable characters */
        public final int f4509;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final AbstractC1033<Uri, DataT> f4510;

        /* renamed from: 㿎  reason: contains not printable characters */
        public final C1121 f4511;

        public C1058(Context context, AbstractC1033<File, DataT> r2, AbstractC1033<Uri, DataT> r3, Uri uri, int i, int i2, C1121 r7, Class<DataT> cls) {
            this.f4506 = context.getApplicationContext();
            this.f4502 = r2;
            this.f4510 = r3;
            this.f4503 = uri;
            this.f4509 = i;
            this.f4507 = i2;
            this.f4511 = r7;
            this.f4505 = cls;
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        public void cancel() {
            this.f4508 = true;
            AbstractC1146<DataT> r0 = this.f4504;
            if (r0 != null) {
                r0.cancel();
            }
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: ʬ  reason: contains not printable characters */
        public DataSource m2883() {
            return DataSource.LOCAL;
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: ῲ  reason: contains not printable characters */
        public void m2884() {
            AbstractC1146<DataT> r0 = this.f4504;
            if (r0 != null) {
                r0.m3065();
            }
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: K  reason: contains not printable characters */
        public void m2886(Priority priority, AbstractC1146.AbstractC1147<? super DataT> k) {
            try {
                AbstractC1146<DataT> r0 = m2887();
                if (r0 == null) {
                    k.m3068((Exception) new IllegalArgumentException("Failed to build fetcher for: " + this.f4503));
                    return;
                }
                this.f4504 = r0;
                if (this.f4508) {
                    cancel();
                } else {
                    r0.m3067(priority, k);
                }
            } catch (FileNotFoundException e) {
                k.m3068((Exception) e);
            }
        }

        /* JADX DEBUG: Type inference failed for r1v1. Raw type applied. Possible types: ඓ.ῲ.K.ᕣ.㿎.㸾<Data>, ඓ.ῲ.K.ᕣ.㿎.㸾<DataT> */
        /* JADX WARNING: Removed duplicated region for block: B:21:0x007a  */
        /* renamed from: 㸾  reason: contains not printable characters */
        public final AbstractC1146<DataT> m2887() throws FileNotFoundException {
            AbstractC1033.C1034<DataT> k;
            Cursor cursor;
            Throwable th;
            if (Environment.isExternalStorageLegacy()) {
                AbstractC1033<File, DataT> r0 = this.f4502;
                Uri uri = this.f4503;
                try {
                    cursor = this.f4506.getContentResolver().query(uri, f4501, null, null, null);
                    if (cursor != null) {
                        try {
                            if (cursor.moveToFirst()) {
                                String string = cursor.getString(cursor.getColumnIndexOrThrow("_data"));
                                if (!TextUtils.isEmpty(string)) {
                                    File file = new File(string);
                                    cursor.close();
                                    k = r0.m2849(file, this.f4509, this.f4507, this.f4511);
                                } else {
                                    throw new FileNotFoundException("File path was empty in media store for: " + uri);
                                }
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            if (cursor != null) {
                                cursor.close();
                            }
                            throw th;
                        }
                    }
                    throw new FileNotFoundException("Failed to media store entry for: " + uri);
                } catch (Throwable th3) {
                    th = th3;
                    cursor = null;
                    if (cursor != null) {
                    }
                    throw th;
                }
            } else {
                k = this.f4510.m2849(this.f4506.checkSelfPermission("android.permission.ACCESS_MEDIA_LOCATION") == 0 ? MediaStore.setRequireOriginal(this.f4503) : this.f4503, this.f4509, this.f4507, this.f4511);
            }
            if (k != null) {
                return (AbstractC1146<Data>) k.f4474;
            }
            return null;
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: K  reason: contains not printable characters */
        public Class<DataT> m2885() {
            return this.f4505;
        }
    }
}
