package androidx.datastore.preferences.protobuf;

import android.util.Base64;
import com.google.android.gms.internal.ads.k3;
import com.google.android.gms.internal.ads.m2;
import com.google.android.gms.internal.ads.q2;
import com.google.android.gms.internal.ads.u3;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class h implements q2, io.flutter.plugins.sharedpreferences.i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f2073a;

    public /* synthetic */ h(int i10) {
        this.f2073a = i10;
    }

    public List a(String str) throws ClassNotFoundException, IOException {
        switch (this.f2073a) {
            case 0:
                try {
                    return (List) new io.flutter.plugins.sharedpreferences.u(new ByteArrayInputStream(Base64.decode(str, 0))).readObject();
                } catch (IOException | ClassNotFoundException e10) {
                    throw new RuntimeException(e10);
                }
            default:
                nb.g.i(str, "listString");
                Object object = new io.flutter.plugins.sharedpreferences.u(new ByteArrayInputStream(Base64.decode(str, 0))).readObject();
                nb.g.g(object, "null cannot be cast to non-null type kotlin.collections.List<*>");
                ArrayList arrayList = new ArrayList();
                for (Object obj : (List) object) {
                    if (obj instanceof String) {
                        arrayList.add(obj);
                    }
                }
                return arrayList;
        }
    }

    public String b(List list) throws IOException {
        switch (this.f2073a) {
            case 0:
                try {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                    objectOutputStream.writeObject(list);
                    objectOutputStream.flush();
                    return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
                } catch (IOException e10) {
                    throw new RuntimeException(e10);
                }
            default:
                nb.g.i(list, "list");
                ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(byteArrayOutputStream2);
                objectOutputStream2.writeObject(list);
                objectOutputStream2.flush();
                String strEncodeToString = Base64.encodeToString(byteArrayOutputStream2.toByteArray(), 0);
                nb.g.h(strEncodeToString, "encodeToString(...)");
                return strEncodeToString;
        }
    }

    @Override // com.google.android.gms.internal.ads.q2
    public void d() {
        switch (this.f2073a) {
            case 0:
                throw new UnsupportedOperationException();
            default:
                return;
        }
    }

    @Override // com.google.android.gms.internal.ads.q2
    public u3 e(int i10, int i11) {
        switch (this.f2073a) {
            case 0:
                throw new UnsupportedOperationException();
            default:
                return new m2();
        }
    }

    @Override // com.google.android.gms.internal.ads.q2
    public void k(k3 k3Var) {
        switch (this.f2073a) {
            case 0:
                throw new UnsupportedOperationException();
            default:
                return;
        }
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ h(int i10, int i11) {
        this(0);
        this.f2073a = i10;
        int i12 = 1;
        if (i10 != 1) {
        } else {
            this(i12);
        }
    }
}
