125 lines
3.9 KiB
Java
125 lines
3.9 KiB
Java
package com.google.firebase.iid;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.util.Log;
|
|
import androidx.collection.ArrayMap;
|
|
import androidx.core.content.ContextCompat;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class zzaw {
|
|
private final SharedPreferences a;
|
|
private final Context b;
|
|
private final zzy c;
|
|
private final Map<String, zzz> d;
|
|
|
|
public zzaw(Context context) {
|
|
this(context, new zzy());
|
|
}
|
|
|
|
private static String b(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("|");
|
|
sb.append(str3);
|
|
return sb.toString();
|
|
}
|
|
|
|
private final synchronized boolean c() {
|
|
return this.a.getAll().isEmpty();
|
|
}
|
|
|
|
public final synchronized String a() {
|
|
return this.a.getString("topic_operaion_queue", "");
|
|
}
|
|
|
|
private zzaw(Context context, zzy zzyVar) {
|
|
this.d = new ArrayMap();
|
|
this.b = context;
|
|
this.a = context.getSharedPreferences("com.google.android.gms.appid", 0);
|
|
this.c = zzyVar;
|
|
File file = new File(ContextCompat.b(this.b), "com.google.android.gms.appid-no-backup");
|
|
if (file.exists()) {
|
|
return;
|
|
}
|
|
try {
|
|
if (!file.createNewFile() || c()) {
|
|
return;
|
|
}
|
|
Log.i("FirebaseInstanceId", "App restored, clearing state");
|
|
b();
|
|
FirebaseInstanceId.j().e();
|
|
} catch (IOException e) {
|
|
if (Log.isLoggable("FirebaseInstanceId", 3)) {
|
|
String valueOf = String.valueOf(e.getMessage());
|
|
Log.d("FirebaseInstanceId", valueOf.length() != 0 ? "Error creating file in no backup dir: ".concat(valueOf) : new String("Error creating file in no backup dir: "));
|
|
}
|
|
}
|
|
}
|
|
|
|
public final synchronized void a(String str) {
|
|
this.a.edit().putString("topic_operaion_queue", str).apply();
|
|
}
|
|
|
|
public final synchronized void b() {
|
|
this.d.clear();
|
|
zzy.a(this.b);
|
|
this.a.edit().clear().commit();
|
|
}
|
|
|
|
public final synchronized void c(String str) {
|
|
String concat = String.valueOf(str).concat("|T|");
|
|
SharedPreferences.Editor edit = this.a.edit();
|
|
for (String str2 : this.a.getAll().keySet()) {
|
|
if (str2.startsWith(concat)) {
|
|
edit.remove(str2);
|
|
}
|
|
}
|
|
edit.commit();
|
|
}
|
|
|
|
static String a(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 synchronized zzax a(String str, String str2, String str3) {
|
|
return zzax.b(this.a.getString(b(str, str2, str3), null));
|
|
}
|
|
|
|
public final synchronized void a(String str, String str2, String str3, String str4, String str5) {
|
|
String a = zzax.a(str4, str5, System.currentTimeMillis());
|
|
if (a == null) {
|
|
return;
|
|
}
|
|
SharedPreferences.Editor edit = this.a.edit();
|
|
edit.putString(b(str, str2, str3), a);
|
|
edit.commit();
|
|
}
|
|
|
|
public final synchronized zzz b(String str) {
|
|
zzz b;
|
|
zzz zzzVar = this.d.get(str);
|
|
if (zzzVar != null) {
|
|
return zzzVar;
|
|
}
|
|
try {
|
|
b = this.c.a(this.b, str);
|
|
} catch (zzaa unused) {
|
|
Log.w("FirebaseInstanceId", "Stored data is corrupt, generating new identity");
|
|
FirebaseInstanceId.j().e();
|
|
b = this.c.b(this.b, str);
|
|
}
|
|
this.d.put(str, b);
|
|
return b;
|
|
}
|
|
}
|