package com.google.firebase.iid; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import java.io.File; import java.io.IOException; import java.util.Map; import o.nMh; import o.nyh; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class zzaz { private final SharedPreferences zza; private final Context zzb; private final Map zzc = new nyh(); public zzaz(Context context) { this.zzb = context; this.zza = context.getSharedPreferences("com.google.android.gms.appid", 0); File file = new File(nMh.getNoBackupFilesDir(context), "com.google.android.gms.appid-no-backup"); if (file.exists()) { return; } try { if (!file.createNewFile() || zzb()) { return; } zza(); FirebaseInstanceId.getInstance().zze(); } catch (IOException e) { if (Log.isLoggable("FirebaseInstanceId", 3)) { e.getMessage(); } } } private final boolean zzb() { boolean isEmpty; synchronized (this) { isEmpty = this.zza.getAll().isEmpty(); } return isEmpty; } private static String zzc(String str, String str2, String str3) { StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 4 + String.valueOf(str2).length() + String.valueOf(str3).length()); sb.append(str); sb.append("|T|"); sb.append(str2); sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR); sb.append(str3); return sb.toString(); } private static String zza(String str, String str2) { StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 3 + String.valueOf(str2).length()); sb.append(str); sb.append("|S|"); sb.append(str2); return sb.toString(); } public final void zza() { synchronized (this) { this.zzc.clear(); this.zza.edit().clear().commit(); } } public final zzay zza(String str, String str2, String str3) { zzay zza; synchronized (this) { zza = zzay.zza(this.zza.getString(zzc(str, str2, str3), null)); } return zza; } public final void zza(String str, String str2, String str3, String str4, String str5) { synchronized (this) { String zza = zzay.zza(str4, str5, System.currentTimeMillis()); if (zza == null) { return; } SharedPreferences.Editor edit = this.zza.edit(); edit.putString(zzc(str, str2, str3), zza); edit.commit(); } } private final long zzd(String str) { String string = this.zza.getString(zza(str, "cre"), null); if (string == null) { return 0L; } try { return Long.parseLong(string); } catch (NumberFormatException unused) { return 0L; } } public final long zzb(String str) { long currentTimeMillis; synchronized (this) { currentTimeMillis = System.currentTimeMillis(); if (!this.zza.contains(zza(str, "cre"))) { SharedPreferences.Editor edit = this.zza.edit(); edit.putString(zza(str, "cre"), String.valueOf(currentTimeMillis)); edit.commit(); } else { currentTimeMillis = zzd(str); } this.zzc.put(str, Long.valueOf(currentTimeMillis)); } return currentTimeMillis; } public final void zzc(String str) { synchronized (this) { String concat = String.valueOf(str).concat("|T|"); SharedPreferences.Editor edit = this.zza.edit(); for (String str2 : this.zza.getAll().keySet()) { if (str2.startsWith(concat)) { edit.remove(str2); } } edit.commit(); } } }