package com.google.android.gms.measurement.internal; import android.content.SharedPreferences; import android.os.Bundle; import com.google.android.gms.common.internal.Preconditions; import com.vungle.warren.ui.view.n; import g8.d; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes.dex */ public final class zzfd { final /* synthetic */ zzfi zza; private final String zzb; private final Bundle zzc; private Bundle zzd; public zzfd(zzfi zzfiVar, String str, Bundle bundle) { this.zza = zzfiVar; Preconditions.checkNotEmpty("default_event_parameters"); this.zzb = "default_event_parameters"; this.zzc = new Bundle(); } public final Bundle zza() { char c10; if (this.zzd == null) { String string = this.zza.zza().getString(this.zzb, null); if (string != null) { try { Bundle bundle = new Bundle(); JSONArray jSONArray = new JSONArray(string); for (int i10 = 0; i10 < jSONArray.length(); i10++) { try { JSONObject jSONObject = jSONArray.getJSONObject(i10); String string2 = jSONObject.getString(n.f8540o); String string3 = jSONObject.getString("t"); int hashCode = string3.hashCode(); if (hashCode == 100) { if (string3.equals(d.f9761b)) { c10 = 1; } c10 = 65535; } else if (hashCode != 108) { if (hashCode == 115 && string3.equals("s")) { c10 = 0; } c10 = 65535; } else { if (string3.equals("l")) { c10 = 2; } c10 = 65535; } if (c10 == 0) { bundle.putString(string2, jSONObject.getString("v")); } else if (c10 == 1) { bundle.putDouble(string2, Double.parseDouble(jSONObject.getString("v"))); } else if (c10 != 2) { this.zza.zzt.zzaA().zzd().zzb("Unrecognized persisted bundle type. Type", string3); } else { bundle.putLong(string2, Long.parseLong(jSONObject.getString("v"))); } } catch (NumberFormatException | JSONException unused) { this.zza.zzt.zzaA().zzd().zza("Error reading value from SharedPreferences. Value dropped"); } } this.zzd = bundle; } catch (JSONException unused2) { this.zza.zzt.zzaA().zzd().zza("Error loading bundle from SharedPreferences. Values will be lost"); } } if (this.zzd == null) { this.zzd = this.zzc; } } return this.zzd; } public final void zzb(Bundle bundle) { if (bundle == null) { bundle = new Bundle(); } SharedPreferences.Editor edit = this.zza.zza().edit(); if (bundle.size() == 0) { edit.remove(this.zzb); } else { String str = this.zzb; JSONArray jSONArray = new JSONArray(); for (String str2 : bundle.keySet()) { Object obj = bundle.get(str2); if (obj != null) { try { JSONObject jSONObject = new JSONObject(); jSONObject.put(n.f8540o, str2); jSONObject.put("v", obj.toString()); if (obj instanceof String) { jSONObject.put("t", "s"); } else if (obj instanceof Long) { jSONObject.put("t", "l"); } else if (obj instanceof Double) { jSONObject.put("t", d.f9761b); } else { this.zza.zzt.zzaA().zzd().zzb("Cannot serialize bundle value to SharedPreferences. Type", obj.getClass()); } jSONArray.put(jSONObject); } catch (JSONException e10) { this.zza.zzt.zzaA().zzd().zzb("Cannot serialize bundle value to SharedPreferences", e10); } } } edit.putString(str, jSONArray.toString()); } edit.apply(); this.zzd = bundle; } }