package v0; import android.content.BroadcastReceiver; import android.content.Context; import android.os.Build; import androidx.work.WorkerParameters; import androidx.work.impl.WorkDatabase; import androidx.work.impl.utils.ForceStopRunnable; import androidx.work.m; import androidx.work.p; import androidx.work.s; import androidx.work.w; import d1.l; import java.util.Arrays; import java.util.List; import java.util.UUID; /* loaded from: classes.dex */ public class j extends w { /* renamed from: j, reason: collision with root package name */ private static final String f14813j = m.f("WorkManagerImpl"); /* renamed from: k, reason: collision with root package name */ private static j f14814k = null; /* renamed from: l, reason: collision with root package name */ private static j f14815l = null; /* renamed from: m, reason: collision with root package name */ private static final Object f14816m = new Object(); /* renamed from: a, reason: collision with root package name */ private Context f14817a; /* renamed from: b, reason: collision with root package name */ private androidx.work.b f14818b; /* renamed from: c, reason: collision with root package name */ private WorkDatabase f14819c; /* renamed from: d, reason: collision with root package name */ private e1.a f14820d; /* renamed from: e, reason: collision with root package name */ private List f14821e; /* renamed from: f, reason: collision with root package name */ private d f14822f; /* renamed from: g, reason: collision with root package name */ private d1.h f14823g; /* renamed from: h, reason: collision with root package name */ private boolean f14824h; /* renamed from: i, reason: collision with root package name */ private BroadcastReceiver.PendingResult f14825i; public j(Context context, androidx.work.b bVar, e1.a aVar) { this(context, bVar, aVar, context.getResources().getBoolean(s.f3036a)); } /* JADX WARN: Code restructure failed: missing block: B:13:0x0016, code lost: r4 = r4.getApplicationContext(); */ /* JADX WARN: Code restructure failed: missing block: B:14:0x001c, code lost: if (v0.j.f14815l != null) goto L15; */ /* JADX WARN: Code restructure failed: missing block: B:15:0x001e, code lost: v0.j.f14815l = new v0.j(r4, r5, new e1.b(r5.l())); */ /* JADX WARN: Code restructure failed: missing block: B:16:0x002e, code lost: v0.j.f14814k = v0.j.f14815l; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public static void e(android.content.Context r4, androidx.work.b r5) { /* java.lang.Object r0 = v0.j.f14816m monitor-enter(r0) v0.j r1 = v0.j.f14814k // Catch: java.lang.Throwable -> L34 if (r1 == 0) goto L14 v0.j r2 = v0.j.f14815l // Catch: java.lang.Throwable -> L34 if (r2 != 0) goto Lc goto L14 Lc: java.lang.IllegalStateException r4 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L34 java.lang.String r5 = "WorkManager is already initialized. Did you try to initialize it manually without disabling WorkManagerInitializer? See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information." r4.(r5) // Catch: java.lang.Throwable -> L34 throw r4 // Catch: java.lang.Throwable -> L34 L14: if (r1 != 0) goto L32 android.content.Context r4 = r4.getApplicationContext() // Catch: java.lang.Throwable -> L34 v0.j r1 = v0.j.f14815l // Catch: java.lang.Throwable -> L34 if (r1 != 0) goto L2e v0.j r1 = new v0.j // Catch: java.lang.Throwable -> L34 e1.b r2 = new e1.b // Catch: java.lang.Throwable -> L34 java.util.concurrent.Executor r3 = r5.l() // Catch: java.lang.Throwable -> L34 r2.(r3) // Catch: java.lang.Throwable -> L34 r1.(r4, r5, r2) // Catch: java.lang.Throwable -> L34 v0.j.f14815l = r1 // Catch: java.lang.Throwable -> L34 L2e: v0.j r4 = v0.j.f14815l // Catch: java.lang.Throwable -> L34 v0.j.f14814k = r4 // Catch: java.lang.Throwable -> L34 L32: monitor-exit(r0) // Catch: java.lang.Throwable -> L34 return L34: r4 = move-exception monitor-exit(r0) // Catch: java.lang.Throwable -> L34 throw r4 */ throw new UnsupportedOperationException("Method not decompiled: v0.j.e(android.content.Context, androidx.work.b):void"); } public static j j() { synchronized (f14816m) { j jVar = f14814k; if (jVar != null) { return jVar; } return f14815l; } } public static j k(Context context) { j j10; synchronized (f14816m) { j10 = j(); if (j10 == null) { context.getApplicationContext(); throw new IllegalStateException("WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider."); } } return j10; } private void q(Context context, androidx.work.b bVar, e1.a aVar, WorkDatabase workDatabase, List list, d dVar) { boolean isDeviceProtectedStorage; Context applicationContext = context.getApplicationContext(); this.f14817a = applicationContext; this.f14818b = bVar; this.f14820d = aVar; this.f14819c = workDatabase; this.f14821e = list; this.f14822f = dVar; this.f14823g = new d1.h(workDatabase); this.f14824h = false; if (Build.VERSION.SDK_INT >= 24) { isDeviceProtectedStorage = applicationContext.isDeviceProtectedStorage(); if (isDeviceProtectedStorage) { throw new IllegalStateException("Cannot initialize WorkManager in direct boot mode"); } } this.f14820d.c(new ForceStopRunnable(applicationContext, this)); } @Override // androidx.work.w public p a(String str) { d1.a d10 = d1.a.d(str, this); this.f14820d.c(d10); return d10.e(); } @Override // androidx.work.w public p c(List list) { if (list.isEmpty()) { throw new IllegalArgumentException("enqueue needs at least one WorkRequest."); } return new g(this, list).a(); } public p f(UUID uuid) { d1.a b10 = d1.a.b(uuid, this); this.f14820d.c(b10); return b10.e(); } public List g(Context context, androidx.work.b bVar, e1.a aVar) { return Arrays.asList(f.a(context, this), new w0.b(context, bVar, aVar, this)); } public Context h() { return this.f14817a; } public androidx.work.b i() { return this.f14818b; } public d1.h l() { return this.f14823g; } public d m() { return this.f14822f; } public List n() { return this.f14821e; } public WorkDatabase o() { return this.f14819c; } public e1.a p() { return this.f14820d; } public void r() { synchronized (f14816m) { this.f14824h = true; BroadcastReceiver.PendingResult pendingResult = this.f14825i; if (pendingResult != null) { pendingResult.finish(); this.f14825i = null; } } } public void s() { if (Build.VERSION.SDK_INT >= 23) { x0.m.b(h()); } o().B().u(); f.b(i(), o(), n()); } public void t(BroadcastReceiver.PendingResult pendingResult) { synchronized (f14816m) { this.f14825i = pendingResult; if (this.f14824h) { pendingResult.finish(); this.f14825i = null; } } } public void u(String str) { v(str, null); } public void v(String str, WorkerParameters.a aVar) { this.f14820d.c(new l(this, str, aVar)); } public void w(String str) { this.f14820d.c(new d1.m(this, str, true)); } public void x(String str) { this.f14820d.c(new d1.m(this, str, false)); } public j(Context context, androidx.work.b bVar, e1.a aVar, boolean z10) { this(context, bVar, aVar, WorkDatabase.s(context.getApplicationContext(), aVar.a(), z10)); } public j(Context context, androidx.work.b bVar, e1.a aVar, WorkDatabase workDatabase) { Context applicationContext = context.getApplicationContext(); m.e(new m.a(bVar.j())); List g10 = g(applicationContext, bVar, aVar); q(context, bVar, aVar, workDatabase, g10, new d(context, bVar, aVar, workDatabase, g10)); } }