package com.google.firebase.messaging; import android.content.SharedPreferences; import android.text.TextUtils; import java.util.ArrayDeque; import java.util.Iterator; import java.util.concurrent.Executor; /* loaded from: classes2.dex */ final class zzx { private final SharedPreferences zza; private final String zzb; private final String zzc; private final Executor zze; private final ArrayDeque zzd = new ArrayDeque<>(); private boolean zzf = false; private zzx(SharedPreferences sharedPreferences, String str, String str2, Executor executor) { this.zza = sharedPreferences; this.zzb = str; this.zzc = str2; this.zze = executor; } /* JADX INFO: Access modifiers changed from: package-private */ public static zzx zza(SharedPreferences sharedPreferences, String str, String str2, Executor executor) { zzx zzxVar = new zzx(sharedPreferences, str, str2, executor); synchronized (zzxVar.zzd) { zzxVar.zzd.clear(); String string = zzxVar.zza.getString(zzxVar.zzb, ""); if (!TextUtils.isEmpty(string) && string.contains(zzxVar.zzc)) { String[] split = string.split(zzxVar.zzc, -1); int length = split.length; for (String str3 : split) { if (!TextUtils.isEmpty(str3)) { zzxVar.zzd.add(str3); } } } } return zzxVar; } private final boolean zza(boolean z) { if (z) { this.zze.execute(new Runnable(this) { // from class: com.google.firebase.messaging.zzw private final zzx zza; @Override // java.lang.Runnable public final void run() { this.zza.zzb(); } /* JADX INFO: Access modifiers changed from: package-private */ { this.zza = this; } }); } return z; } public final boolean zza(Object obj) { boolean zza; synchronized (this.zzd) { zza = zza(this.zzd.remove(obj)); } return zza; } public final String zza() { String peek; synchronized (this.zzd) { peek = this.zzd.peek(); } return peek; } /* JADX INFO: Access modifiers changed from: package-private */ public final /* synthetic */ void zzb() { synchronized (this.zzd) { SharedPreferences.Editor edit = this.zza.edit(); String str = this.zzb; StringBuilder sb = new StringBuilder(); Iterator it = this.zzd.iterator(); while (it.hasNext()) { sb.append(it.next()); sb.append(this.zzc); } edit.putString(str, sb.toString()).commit(); } } }