package com.xiaomi.push.service; import android.content.Context; import android.content.SharedPreferences; import com.xiaomi.mipush.sdk.Constants; import com.xiaomi.push.ai; import com.xiaomi.push.al; import com.xiaomi.push.bj; import com.xiaomi.push.t; import java.util.concurrent.ConcurrentHashMap; public final class bu implements ao { private static volatile bu a; /* renamed from: a reason: collision with other field name */ private long f7583a; /* renamed from: a reason: collision with other field name */ Context f7584a; /* renamed from: a reason: collision with other field name */ private SharedPreferences f7585a; /* renamed from: a reason: collision with other field name */ private ConcurrentHashMap<String, a> f7586a = new ConcurrentHashMap<>(); /* renamed from: a reason: collision with other field name */ private volatile boolean f7587a = false; public static abstract class a implements Runnable { long a; /* renamed from: a reason: collision with other field name */ String f7588a; a(String str, long j) { this.f7588a = str; this.a = j; } /* access modifiers changed from: package-private */ public abstract void a(bu buVar); public void run() { if (bu.a != null) { Context context = bu.a.f7584a; if (bj.d(context)) { long currentTimeMillis = System.currentTimeMillis(); SharedPreferences sharedPreferences = bu.a.f7585a; if (currentTimeMillis - sharedPreferences.getLong(":ts-" + this.f7588a, 0) > this.a || ai.a(context)) { SharedPreferences.Editor edit = bu.a.f7585a.edit(); t.a(edit.putLong(":ts-" + this.f7588a, System.currentTimeMillis())); a(bu.a); } } } } } private bu(Context context) { this.f7584a = context.getApplicationContext(); this.f7585a = context.getSharedPreferences("sync", 0); } public static bu a(Context context) { if (a == null) { synchronized (bu.class) { if (a == null) { a = new bu(context); } } } return a; } public final String a(String str, String str2) { SharedPreferences sharedPreferences = this.f7585a; return sharedPreferences.getString(str + Constants.COLON_SEPARATOR + str2, ""); } @Override // com.xiaomi.push.service.ao public final void a() { if (!this.f7587a) { long currentTimeMillis = System.currentTimeMillis(); if (currentTimeMillis - this.f7583a >= 3600000) { this.f7583a = currentTimeMillis; this.f7587a = true; al.a(this.f7584a).a(new bv(this), (int) (Math.random() * 10.0d)); } } } public final void a(a aVar) { if (this.f7586a.putIfAbsent(aVar.f7588a, aVar) == null) { al.a(this.f7584a).a(aVar, ((int) (Math.random() * 30.0d)) + 10); } } public final void a(String str, String str2, String str3) { SharedPreferences.Editor edit = a.f7585a.edit(); t.a(edit.putString(str + Constants.COLON_SEPARATOR + str2, str3)); } }