package o;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Base64;
import com.google.android.gms.common.internal.Preconditions;
import com.google.firebase.datatransport.TransportRegistrar;
import com.google.firebase.sessions.FirebaseSessionsRegistrar;
import ir.devixor.app.service.ForegroundService;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.CancellationException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Oy, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final /* synthetic */ class C0387Oy implements InterfaceC0256Jw, InterfaceC0320Mj, LT, InterfaceC0246Jm, InterfaceC1880mg0, InterfaceC0250Jq, InterfaceC0070Cs, J30, Ce0, Vg0 {
    public static final C0387Oy m = new C0387Oy(19);
    public static final C0387Oy n = new C0387Oy(20);

    /* renamed from: o, reason: collision with root package name */
    public static final C0387Oy f277o = new C0387Oy(21);
    public static final C0387Oy p = new C0387Oy(22);
    public static final C0387Oy q = new C0387Oy(23);
    public final /* synthetic */ int l;

    public /* synthetic */ C0387Oy(int i) {
        this.l = i;
    }

    @Override // o.InterfaceC0250Jq
    public void a(DZ dz) {
        switch (this.l) {
            case 8:
                return;
            default:
                dz.get().getClass();
                throw new ClassCastException();
        }
    }

    @Override // o.InterfaceC1880mg0, o.J30
    public Object apply(Object obj) {
        switch (this.l) {
            case 7:
                C2520tP c2520tP = (C2520tP) obj;
                C3126zm0 c3126zm0 = AbstractC2056oZ.a;
                c3126zm0.getClass();
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                try {
                    c3126zm0.v(c2520tP, byteArrayOutputStream);
                } catch (IOException unused) {
                }
                return byteArrayOutputStream.toByteArray();
            default:
                Cursor cursorRawQuery = ((SQLiteDatabase) obj).rawQuery("SELECT distinct t._id, t.backend_name, t.priority, t.extras FROM transport_contexts AS t, events AS e WHERE e.context_id = t._id", new String[0]);
                try {
                    ArrayList arrayList = new ArrayList();
                    while (cursorRawQuery.moveToNext()) {
                        C3126zm0 c3126zm0A = C2156pc.a();
                        c3126zm0A.P(cursorRawQuery.getString(1));
                        c3126zm0A.f831o = JY.b(cursorRawQuery.getInt(2));
                        String string = cursorRawQuery.getString(3);
                        c3126zm0A.n = string == null ? null : Base64.decode(string, 0);
                        arrayList.add(c3126zm0A.m());
                    }
                    return arrayList;
                } finally {
                    cursorRawQuery.close();
                }
        }
    }

    @Override // o.LT
    public void d(Exception exc) {
        boolean z = ForegroundService.w;
    }

    @Override // o.InterfaceC0320Mj
    public Object i(U7 u7) {
        switch (this.l) {
            case 2:
                return FirebaseSessionsRegistrar.getComponents$lambda$0(u7);
            case 3:
                return FirebaseSessionsRegistrar.getComponents$lambda$1(u7);
            case 25:
                return TransportRegistrar.lambda$getComponents$0(u7);
            case 26:
                return TransportRegistrar.lambda$getComponents$1(u7);
            default:
                return TransportRegistrar.lambda$getComponents$2(u7);
        }
    }

    @Override // o.InterfaceC0246Jm
    public Object then(Pc0 pc0) throws IOException {
        Object obj;
        Hw0 hw0 = (Hw0) pc0;
        synchronized (hw0.a) {
            Preconditions.checkState(hw0.c, "Task is not yet complete");
            if (hw0.d) {
                throw new CancellationException("Task is already canceled.");
            }
            if (IOException.class.isInstance(hw0.f)) {
                throw ((Throwable) IOException.class.cast(hw0.f));
            }
            Exception exc = hw0.f;
            if (exc != null) {
                throw new G30(exc);
            }
            obj = hw0.e;
        }
        Bundle bundle = (Bundle) obj;
        if (bundle == null) {
            throw new IOException("SERVICE_NOT_AVAILABLE");
        }
        String string = bundle.getString("registration_id");
        if (string != null) {
            return string;
        }
        String string2 = bundle.getString("unregistered");
        if (string2 != null) {
            return string2;
        }
        String string3 = bundle.getString("error");
        if ("RST".equals(string3)) {
            throw new IOException("INSTANCE_ID_RESET");
        }
        if (string3 != null) {
            throw new IOException(string3);
        }
        bundle.toString();
        new Throwable();
        throw new IOException("SERVICE_NOT_AVAILABLE");
    }

    public /* synthetic */ C0387Oy(int i, Object obj) {
        this.l = i;
    }

    private final void e(DZ dz) {
    }

    @Override // o.Vg0
    public void b(Exception exc) {
    }

    @Override // o.InterfaceC0070Cs
    public double c(double d) {
        return d;
    }
}
