package defpackage;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteAccessPermException;
import android.database.sqlite.SQLiteCantOpenDatabaseException;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.database.sqlite.SQLiteDatabaseLockedException;
import android.database.sqlite.SQLiteDiskIOException;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteFullException;
import android.database.sqlite.SQLiteTableLockedException;
import android.os.Build;
import android.text.TextUtils;
import androidx.work.impl.utils.ForceStopRunnable;

/* renamed from: ˉᵝˎⁱ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class RunnableC1199 implements Runnable {

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public static final long f5109;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C5205 f5110;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final Context f5111;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public int f5112 = 0;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final C2852 f5113;

    static {
        ᵼᵫᵧˀ.ˁˑᵰ("ForceStopRunnable");
        f5109 = 315360000000L;
    }

    public RunnableC1199(Context context, C5205 c5205) {
        this.f5111 = context.getApplicationContext();
        this.f5110 = c5205;
        this.f5113 = c5205.f19421;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static void m3734(Context context) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService("alarm");
        int i = Build.VERSION.SDK_INT >= 31 ? 167772160 : 134217728;
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(context, (Class<?>) ForceStopRunnable.BroadcastReceiver.class));
        intent.setAction("ACTION_FORCE_STOP_RESCHEDULE");
        PendingIntent broadcast = PendingIntent.getBroadcast(context, -1, intent, i);
        long jCurrentTimeMillis = System.currentTimeMillis() + f5109;
        if (alarmManager != null) {
            alarmManager.setExact(0, jCurrentTimeMillis, broadcast);
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        boolean zM9665;
        C5205 c5205 = this.f5110;
        try {
            c5205.f19426.getClass();
            boolean zIsEmpty = TextUtils.isEmpty(null);
            Context context = this.f5111;
            if (zIsEmpty) {
                ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                zM9665 = true;
            } else {
                zM9665 = AbstractC4548.m9665(context);
                ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
            }
            if (!zM9665) {
                return;
            }
            while (true) {
                try {
                    ᵱᵞᵪ.ᵢˇᵭ(context);
                    ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                    try {
                        m3735();
                        return;
                    } catch (SQLiteAccessPermException | SQLiteCantOpenDatabaseException | SQLiteConstraintException | SQLiteDatabaseCorruptException | SQLiteDatabaseLockedException | SQLiteDiskIOException | SQLiteFullException | SQLiteTableLockedException e) {
                        int i = this.f5112 + 1;
                        this.f5112 = i;
                        if (i >= 3) {
                            String str = ᵮʛˀ.ᵡʠ(context) ? "The file system on the device is in a bad state. WorkManager cannot access the app's internal data store." : "WorkManager can't be accessed from direct boot, because credential encrypted storage isn't accessible.\nDon't access or initialise WorkManager from directAware components. See https://developer.android.com/training/articles/direct-boot";
                            ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                            IllegalStateException illegalStateException = new IllegalStateException(str, e);
                            c5205.f19426.getClass();
                            throw illegalStateException;
                        }
                        ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                        try {
                            Thread.sleep(this.f5112 * 300);
                        } catch (InterruptedException unused) {
                        }
                    }
                } catch (SQLiteException e2) {
                    ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                    IllegalStateException illegalStateException2 = new IllegalStateException("Unexpected SQLite exception during migrations", e2);
                    c5205.f19426.getClass();
                    throw illegalStateException2;
                }
            }
        } finally {
            c5205.m10763();
        }
    }

    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Removed duplicated region for block: B:116:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:92:0x01dd  */
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m3735() {
        /*
            Method dump skipped, instructions count: 551
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.RunnableC1199.m3735():void");
    }
}
