package defpackage;

import androidx.work.impl.WorkDatabase;
import j$.util.Objects;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.Callable;
import org.json.JSONObject;

/* JADX INFO: renamed from: ᵖˁᵬ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class CallableC2397 implements Callable {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ Object f9371;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final /* synthetic */ Object f9372;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f9373;

    public /* synthetic */ CallableC2397(Object obj, int i, Object obj2) {
        this.f9373 = i;
        this.f9371 = obj;
        this.f9372 = obj2;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    private final Object m6120() {
        C1053 c1053 = (C1053) this.f9371;
        C2932 c2932 = (C2932) this.f9372;
        C4331 c4331 = c1053.f4534;
        HashMap map = c2932.f11275;
        synchronized (c4331.f16492) {
            try {
                HashMap mapM9310 = c4331.m9310();
                Iterator it = map.entrySet().iterator();
                boolean z = false;
                while (true) {
                    boolean z2 = true;
                    if (!it.hasNext()) {
                        if (!z) {
                            return null;
                        }
                        if (mapM9310.size() > 100) {
                            String.format("Invalid custom signal: Too many custom signals provided. The maximum allowed is %d.", 100);
                            return null;
                        }
                        c4331.f16493.edit().putString("customSignals", new JSONObject(mapM9310).toString()).commit();
                        Objects.toString(c4331.m9310().keySet());
                        return null;
                    }
                    Map.Entry entry = (Map.Entry) it.next();
                    String str = (String) entry.getKey();
                    String str2 = (String) entry.getValue();
                    if (str.length() > 250 || (str2 != null && str2.length() > 500)) {
                        break;
                    }
                    if (str2 != null) {
                        z |= !Objects.equals(mapM9310.put(str, str2), str2);
                    } else {
                        if (mapM9310.remove(str) == null) {
                            z2 = false;
                        }
                        z |= z2;
                    }
                }
                String.format("Invalid custom signal: Custom signal keys must be %d characters or less, and values must be %d characters or less.", 250, 500);
                return null;
            } finally {
            }
        }
    }

    @Override // java.util.concurrent.Callable
    public final Object call() {
        boolean z = false;
        switch (this.f9373) {
            case 0:
                C0708 c0708 = (C0708) this.f9371;
                C5235 c5235 = (C5235) this.f9372;
                C1516 c1516 = c0708.f3239;
                synchronized (c1516) {
                    FileOutputStream fileOutputStreamOpenFileOutput = c1516.f6143.openFileOutput(c1516.f6142, 0);
                    try {
                        fileOutputStreamOpenFileOutput.write(c5235.f19739.toString().getBytes("UTF-8"));
                    } finally {
                        fileOutputStreamOpenFileOutput.close();
                    }
                }
                return null;
            case 1:
                ᵯᵨᵲ r0 = (ᵯᵨᵲ) this.f9371;
                ᵘˇ r12 = (ᵘˇ) this.f9372;
                try {
                    ᵟˌᵫ.ˏᵩʨ((File) r0.ᵔᵖᵹᵫ, ((ˁˆᵳ) r0.ᵨᵼⁱ).ᵯᵷʽ(r12.ᵱʡˏ()).toString().getBytes("UTF-8"));
                    break;
                } catch (IOException unused) {
                }
                return null;
            case 2:
                return m6120();
            default:
                AbstractC1310 abstractC1310 = (AbstractC1310) this.f9371;
                C4351 c4351 = (C4351) this.f9372;
                String str = c4351.f16548;
                C3248 c3248 = c4351.f16556;
                C2590 c2590 = c4351.f16552;
                EnumC4913 enumC4913 = EnumC4913.f18695;
                if (abstractC1310 instanceof C4826) {
                    AbstractC3723 c4607 = ((C4826) abstractC1310).f18400;
                    EnumC4913 enumC4913M7400 = c3248.m7400(str);
                    WorkDatabase workDatabase = c3248.f12358;
                    ᵥˇᵛˎ.ˉˆᵗ(c4351.f16547.mo669().f11000, false, true, new C4704(8, str));
                    if (enumC4913M7400 != null) {
                        if (enumC4913M7400 == EnumC4913.f18697) {
                            if (c4607 instanceof C0142) {
                                int i = AbstractC5214.f19639;
                                C3814.m8515().getClass();
                                if (c2590.m6314()) {
                                    c4351.m9374();
                                } else {
                                    c3248.m7403(EnumC4913.f18696, str);
                                    ᵥˇᵛˎ.ˉˆᵗ(workDatabase, false, true, new ˁـᵫ(((C0142) c4607).f1511, 14, str));
                                    c4351.f16557.getClass();
                                    long jCurrentTimeMillis = System.currentTimeMillis();
                                    C1683 c1683 = c4351.f16551;
                                    for (String str2 : c1683.m4557(str)) {
                                        if (c3248.m7400(str2) == EnumC4913.f18699 && ((Boolean) ᵥˇᵛˎ.ˉˆᵗ(c1683.f6640, true, false, new C4704(2, str2))).booleanValue()) {
                                            int i2 = AbstractC5214.f19639;
                                            C3814.m8515().getClass();
                                            c3248.m7403(enumC4913, str2);
                                            ᵥˇᵛˎ.ˉˆᵗ(workDatabase, false, true, new C4033(jCurrentTimeMillis, 1, str2));
                                        }
                                    }
                                }
                            } else if (c4607 instanceof C1437) {
                                int i3 = AbstractC5214.f19639;
                                C3814.m8515().getClass();
                                c4351.m9373(-256);
                                z = true;
                            } else {
                                int i4 = AbstractC5214.f19639;
                                C3814.m8515().getClass();
                                if (c2590.m6314()) {
                                    c4351.m9374();
                                } else {
                                    if (c4607 == null) {
                                        c4607 = new C4607();
                                    }
                                    c4351.m9375(c4607);
                                }
                            }
                        } else if (!enumC4913M7400.m10217()) {
                            c4351.m9373(-512);
                            z = true;
                        }
                    }
                } else if (abstractC1310 instanceof C2828) {
                    AbstractC3723 abstractC3723 = ((C2828) abstractC1310).f10850;
                    int i5 = AbstractC5214.f19639;
                    C3814.m8515().getClass();
                    if (c2590.m6314()) {
                        c4351.m9374();
                    } else {
                        c4351.m9375(abstractC3723);
                    }
                } else {
                    if (!(abstractC1310 instanceof C2512)) {
                        C1685.m4561();
                        return null;
                    }
                    int i6 = ((C2512) abstractC1310).f9711;
                    if (ᵥˈᵛ.ˊᵫᵗ(c2590.f10012, Boolean.TRUE)) {
                        int i7 = AbstractC5214.f19639;
                        C3814.m8515().getClass();
                        c4351.m9373(i6);
                    } else {
                        EnumC4913 enumC4913M74002 = c3248.m7400(str);
                        if (enumC4913M74002 == null || enumC4913M74002.m10217()) {
                            int i8 = AbstractC5214.f19639;
                            C3814 c3814M8515 = C3814.m8515();
                            Objects.toString(enumC4913M74002);
                            c3814M8515.getClass();
                        } else {
                            int i9 = AbstractC5214.f19639;
                            C3814 c3814M85152 = C3814.m8515();
                            enumC4913M74002.toString();
                            c3814M85152.getClass();
                            c3248.m7403(enumC4913, str);
                            c3248.m7399(i6, str);
                            c3248.m7405(-1L, str);
                        }
                    }
                    z = true;
                }
                return Boolean.valueOf(z);
        }
    }
}
