package p138.p176.p291.p320;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import p037.p057.C1714;
import p037.p065.p068.C1850;
import p138.p139.p143.p144.C2803;

/* JADX INFO: renamed from: ދ.ހ.ށ.ވ.ޗ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C5930 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final SharedPreferences f16730;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final Context f16731;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Map<String, Long> f16732 = new C1714();

    public C5930(Context context) {
        this.f16731 = context;
        this.f16730 = context.getSharedPreferences("com.google.android.gms.appid", 0);
        File file = new File(C1850.m3656(this.f16731), "com.google.android.gms.appid-no-backup");
        if (file.exists()) {
            return;
        }
        try {
            if (!file.createNewFile() || m9278()) {
                return;
            }
            Log.i("FirebaseInstanceId", "App restored, clearing state");
            m9275();
            FirebaseInstanceId.m1423().m1430();
        } catch (IOException e) {
            if (Log.isLoggable("FirebaseInstanceId", 3)) {
                String strValueOf = String.valueOf(e.getMessage());
                Log.d("FirebaseInstanceId", strValueOf.length() != 0 ? "Error creating file in no backup dir: ".concat(strValueOf) : new String("Error creating file in no backup dir: "));
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m9271(String str, String str2) {
        StringBuilder sb = new StringBuilder(C2803.m4895(str2, C2803.m4895(str, 3)));
        sb.append(str);
        sb.append("|S|");
        sb.append(str2);
        return sb.toString();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static String m9272(String str, String str2, String str3) {
        StringBuilder sb = new StringBuilder(C2803.m4895(str3, C2803.m4895(str2, C2803.m4895(str, 4))));
        sb.append(str);
        sb.append("|T|");
        sb.append(str2);
        sb.append("|");
        sb.append(str3);
        return sb.toString();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final synchronized long m9273(String str) {
        long jCurrentTimeMillis;
        jCurrentTimeMillis = System.currentTimeMillis();
        if (this.f16730.contains(m9271(str, "cre"))) {
            String string = this.f16730.getString(m9271(str, "cre"), null);
            if (string != null) {
                try {
                    jCurrentTimeMillis = Long.parseLong(string);
                } catch (NumberFormatException unused) {
                    jCurrentTimeMillis = 0;
                }
            } else {
                jCurrentTimeMillis = 0;
            }
        }
        SharedPreferences.Editor editorEdit = this.f16730.edit();
        editorEdit.putString(m9271(str, "cre"), String.valueOf(jCurrentTimeMillis));
        editorEdit.commit();
        this.f16732.put(str, Long.valueOf(jCurrentTimeMillis));
        return jCurrentTimeMillis;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final synchronized C5929 m9274(String str, String str2, String str3) {
        return C5929.m9270(this.f16730.getString(m9272(str, str2, str3), null));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final synchronized void m9275() {
        this.f16732.clear();
        this.f16730.edit().clear().commit();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final synchronized void m9276(String str, String str2, String str3, String str4, String str5) {
        String strM9269 = C5929.m9269(str4, str5, System.currentTimeMillis());
        if (strM9269 == null) {
            return;
        }
        SharedPreferences.Editor editorEdit = this.f16730.edit();
        editorEdit.putString(m9272(str, str2, str3), strM9269);
        editorEdit.commit();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final synchronized void m9277(String str) {
        String strConcat = String.valueOf(str).concat("|T|");
        SharedPreferences.Editor editorEdit = this.f16730.edit();
        for (String str2 : this.f16730.getAll().keySet()) {
            if (str2.startsWith(strConcat)) {
                editorEdit.remove(str2);
            }
        }
        editorEdit.commit();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final synchronized boolean m9278() {
        return this.f16730.getAll().isEmpty();
    }
}
