package d1; import android.content.Context; import android.content.SharedPreferences; import androidx.work.impl.WorkDatabase; /* loaded from: classes.dex */ public class f { /* renamed from: a, reason: collision with root package name */ private final WorkDatabase f8997a; public f(WorkDatabase workDatabase) { this.f8997a = workDatabase; } public static void a(Context context, p0.b bVar) { SharedPreferences sharedPreferences = context.getSharedPreferences("androidx.work.util.id", 0); if (sharedPreferences.contains("next_job_scheduler_id") || sharedPreferences.contains("next_job_scheduler_id")) { int i10 = sharedPreferences.getInt("next_job_scheduler_id", 0); int i11 = sharedPreferences.getInt("next_alarm_manager_id", 0); bVar.v(); try { bVar.W("INSERT OR REPLACE INTO `Preference` (`key`, `long_value`) VALUES (@key, @long_value)", new Object[]{"next_job_scheduler_id", Integer.valueOf(i10)}); bVar.W("INSERT OR REPLACE INTO `Preference` (`key`, `long_value`) VALUES (@key, @long_value)", new Object[]{"next_alarm_manager_id", Integer.valueOf(i11)}); sharedPreferences.edit().clear().apply(); bVar.U(); } finally { bVar.h0(); } } } private int c(String str) { this.f8997a.c(); try { Long a10 = this.f8997a.x().a(str); int i10 = 0; int intValue = a10 != null ? a10.intValue() : 0; if (intValue != Integer.MAX_VALUE) { i10 = intValue + 1; } e(str, i10); this.f8997a.r(); return intValue; } finally { this.f8997a.g(); } } private void e(String str, int i10) { this.f8997a.x().b(new c1.d(str, i10)); } public int b() { int c10; synchronized (f.class) { c10 = c("next_alarm_manager_id"); } return c10; } public int d(int i10, int i11) { synchronized (f.class) { int c10 = c("next_job_scheduler_id"); if (c10 >= i10 && c10 <= i11) { i10 = c10; } e("next_job_scheduler_id", i10 + 1); } return i10; } }