package com.google.android.gms.internal.ads;

import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Constructor;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Field;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Param;
import java.util.List;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

/* JADX INFO: loaded from: classes2.dex */
public final class yk extends f8.a {
    public static final Parcelable.Creator<yk> CREATOR = new wk(1);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final long f18858a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f18859b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final String f18860c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final String f18861d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Bundle f18862e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final boolean f18863f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public long f18864g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public String f18865h;

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

    @Nullable
    @SafeParcelable$Field(id = 2)
    public final String zza;

    @SafeParcelable$Constructor
    public yk(@Nullable @SafeParcelable$Param(id = 2) String str, @SafeParcelable$Param(id = 3) long j10, @SafeParcelable$Param(id = 4) String str2, @SafeParcelable$Param(id = 5) String str3, @SafeParcelable$Param(id = 6) String str4, @SafeParcelable$Param(id = 7) Bundle bundle, @SafeParcelable$Param(id = 8) boolean z10, @SafeParcelable$Param(id = 9) long j11, @SafeParcelable$Param(id = 10) String str5, @SafeParcelable$Param(id = 11) int i10) {
        this.zza = str;
        this.f18858a = j10;
        this.f18859b = str2 == null ? "" : str2;
        this.f18860c = str3 == null ? "" : str3;
        this.f18861d = str4 == null ? "" : str4;
        this.f18862e = bundle == null ? new Bundle() : bundle;
        this.f18863f = z10;
        this.f18864g = j11;
        this.f18865h = str5;
        this.f18866i = i10;
    }

    @Nullable
    public static yk zza(Uri uri) {
        try {
            if (!"gcache".equals(uri.getScheme())) {
                return null;
            }
            List<String> pathSegments = uri.getPathSegments();
            if (pathSegments.size() != 2) {
                int size = pathSegments.size();
                StringBuilder sb = new StringBuilder(String.valueOf(size).length() + 51);
                sb.append("Expected 2 path parts for namespace and id, found :");
                sb.append(size);
                q7.j.d(sb.toString());
                return null;
            }
            String str = pathSegments.get(0);
            String str2 = pathSegments.get(1);
            String host = uri.getHost();
            String queryParameter = uri.getQueryParameter(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL);
            boolean zEquals = "1".equals(uri.getQueryParameter("read_only"));
            String queryParameter2 = uri.getQueryParameter("expiration");
            long j10 = queryParameter2 == null ? 0L : Long.parseLong(queryParameter2);
            Bundle bundle = new Bundle();
            for (String str3 : uri.getQueryParameterNames()) {
                if (str3.startsWith("tag.")) {
                    bundle.putString(str3.substring(4), uri.getQueryParameter(str3));
                }
            }
            return new yk(queryParameter, j10, host, str, str2, bundle, zEquals, 0L, "", 0);
        } catch (NullPointerException | NumberFormatException unused) {
            return null;
        }
    }

    @Override // android.os.Parcelable
    public final void writeToParcel(Parcel parcel, int i10) {
        String str = this.zza;
        int I = com.bumptech.glide.g.I(20293, parcel);
        com.bumptech.glide.g.r(parcel, 2, str);
        com.bumptech.glide.g.C(parcel, 3, 8);
        parcel.writeLong(this.f18858a);
        com.bumptech.glide.g.r(parcel, 4, this.f18859b);
        com.bumptech.glide.g.r(parcel, 5, this.f18860c);
        com.bumptech.glide.g.r(parcel, 6, this.f18861d);
        com.bumptech.glide.g.n(parcel, 7, this.f18862e);
        com.bumptech.glide.g.C(parcel, 8, 4);
        parcel.writeInt(this.f18863f ? 1 : 0);
        long j10 = this.f18864g;
        com.bumptech.glide.g.C(parcel, 9, 8);
        parcel.writeLong(j10);
        com.bumptech.glide.g.r(parcel, 10, this.f18865h);
        int i11 = this.f18866i;
        com.bumptech.glide.g.C(parcel, 11, 4);
        parcel.writeInt(i11);
        com.bumptech.glide.g.N(I, parcel);
    }
}
