package com.ss.android.ugc.aweme.legoImp.task;

import X.2kf;
import X.AnonymousClass7fE;
import X.AnonymousClass7lW;
import X.AnonymousClass9FH;
import X.AnonymousClass9Y3;
import X.C07527qh;
import X.C08617sS;
import X.C08627sT;
import X.C08637sU;
import X.C08647sV;
import X.C08657sW;
import X.C08667sX;
import X.C08677sY;
import X.C08687sZ;
import X.C08697sa;
import X.C08707sb;
import X.C08937sy;
import X.C09037t8;
import X.C09047t9;
import X.C11817xc;
import X.C22428Zd;
import X.C22438Ze;
import X.C25518ec;
import X.C26968gx;
import X.C26998h0;
import X.C27888iR;
import X.C29988lp;
import X.C42749Fh;
import X.C42759Fi;
import X.C42869Ft;
import X.C42909Fx;
import X.C43189Gz;
import X.RXb;
import X.SfZ;
import X.TnA;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import com.bytedance.common.jato.Jato;
import com.bytedance.common.jato.shrinker.Shrinker;
import com.bytedance.common.utility.reflect.Reflect;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.abmock.SettingsManager;
import com.bytedance.keva.Keva;
import com.bytedance.sysoptimizer.ArtOptimizer;
import com.bytedance.sysoptimizer.DetachCurrentThreadOpt;
import com.bytedance.sysoptimizer.DvmDeadLockOptimizer;
import com.bytedance.sysoptimizer.DvmGlesOptimizer;
import com.bytedance.sysoptimizer.DvmOptimizer;
import com.bytedance.sysoptimizer.EglCreateSurfaceFixer;
import com.bytedance.sysoptimizer.GraphicsEnvOpt;
import com.bytedance.sysoptimizer.HeapGCOptimizer;
import com.bytedance.sysoptimizer.HighLevelTrimMemory;
import com.bytedance.sysoptimizer.JitCompileMethodCrash;
import com.bytedance.sysoptimizer.KGetCookieOptimizer;
import com.bytedance.sysoptimizer.LocalRefEnlarger;
import com.bytedance.sysoptimizer.MaliGpuExtIsSupportOptimizer;
import com.bytedance.sysoptimizer.MaliMemOptimizer;
import com.bytedance.sysoptimizer.MediaCodecReleaseOpt;
import com.bytedance.sysoptimizer.NativeAllocatorOptimizer;
import com.bytedance.sysoptimizer.ONativeCryptoCRLOptimizer;
import com.bytedance.sysoptimizer.ReceiverRegisterCrashOptimizer;
import com.bytedance.sysoptimizer.RedmiTypeFaceOptimizer;
import com.bytedance.sysoptimizer.SmEditTextLeakOpt;
import com.bytedance.sysoptimizer.StackLeakChecker;
import com.bytedance.sysoptimizer.StackLeakItem;
import com.bytedance.sysoptimizer.StageFrightAndroid4Optimizer;
import com.bytedance.sysoptimizer.SysOptimizer;
import com.bytedance.sysoptimizer.SystemSensorManagerOptimizer;
import com.bytedance.sysoptimizer.TypeFaceOptimizer;
import com.bytedance.sysoptimizer.VMDebugDumpHprofOptimizer;
import com.bytedance.sysoptimizer.fake.name.SmFakeNameHandler;
import com.bytedance.sysoptimizer.java.BinderServiceWrapperProtector;
import com.bytedance.sysoptimizer.java.IAutofillManagerProtector;
import com.bytedance.sysoptimizer.java.IConnectivityManagerProtector;
import com.bytedance.sysoptimizer.java.OppoNAlarmProtector;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SysOptimizerTask implements AnonymousClass9FH, C22438Ze {
    public Long LIZ;
    public Boolean LIZIZ;

    static {
        Covode.recordClassIndex(90640);
    }

    public String prefix() {
        return "task_";
    }

    public int priority() {
        return 1;
    }

    public boolean serialExecute() {
        return false;
    }

    public List triggerOtherLegoComponents() {
        return null;
    }

    public C42869Ft triggerType() {
        return C22428Zd.LIZ(this);
    }

    public class SysOptAddMemAllocator implements C22438Ze {
        static {
            Covode.recordClassIndex(90642);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptAddMemAllocator() {
        }

        public void run(Context context) {
            SysOptimizerTask.this.LJIILJJIL(context);
        }
    }

    public class SysOptCheckSoLoadResult implements C22438Ze {
        static {
            Covode.recordClassIndex(90643);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BOOT_FINISH;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public void run(Context context) {
            SysOptimizerTask.LIZIZ();
        }

        public SysOptCheckSoLoadResult() {
        }
    }

    public class SysOptDisableDumpOatFileForANR implements C22438Ze {
        static {
            Covode.recordClassIndex(90644);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public void run(Context context) {
            SysOptimizerTask.LJIJ(context);
        }

        public SysOptDisableDumpOatFileForANR() {
        }
    }

    public class SysOptDvmOptimizer implements C22438Ze {
        static {
            Covode.recordClassIndex(90645);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptDvmOptimizer() {
        }

        public void run(Context context) {
            SysOptimizerTask.this.LIZ = Long.valueOf(System.currentTimeMillis());
            DvmOptimizer.optDvmLinearAllocBuffer(context);
        }
    }

    public class SysOptEnableStackLeakChecker implements C22438Ze {
        static {
            Covode.recordClassIndex(90646);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public void run(Context context) {
            SysOptimizerTask.LJIJI(context);
        }

        public SysOptEnableStackLeakChecker() {
        }
    }

    public class SysOptFixSamSungGetNameCrash implements C22438Ze {
        static {
            Covode.recordClassIndex(90647);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public void run(Context context) {
            SysOptimizerTask.LIZIZ(context);
        }

        public SysOptFixSamSungGetNameCrash() {
        }
    }

    public class SysOptHeapGCAdjustTask implements C22438Ze {
        static {
            Covode.recordClassIndex(90648);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptHeapGCAdjustTask() {
        }

        public void run(Context context) {
            C08617sS r3 = (C08617sS) AnonymousClass9Y3.LIZ().LIZ(true, "heap_gc_adjust_settings", C08617sS.class, (Object) C08677sY.LIZ);
            if (r3 != null && r3.LIZ) {
                HeapGCOptimizer.optimize(context, r3.LIZIZ, r3.LIZJ, r3.LIZLLL);
            }
        }
    }

    public class SysOptHookOptimizerEnable implements C22438Ze {
        static {
            Covode.recordClassIndex(90649);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptHookOptimizerEnable() {
        }

        public void run(Context context) {
            Long.valueOf(System.currentTimeMillis());
            if (Build.VERSION.SDK_INT == 24) {
                HighLevelTrimMemory.optimize(context);
            }
            DvmDeadLockOptimizer.optimize(context);
            if (C11817xc.LIZ(context)) {
                SysOptimizerTask.LJIILLIIL(context);
            }
            SysOptimizerTask.this.LIZJ(context);
            SysOptimizerTask.LIZLLL(context);
            SysOptimizerTask.this.LIZ(context);
            SysOptimizerTask.this.LJII(context);
            SysOptimizerTask.this.LJIIIIZZ(context);
            SysOptimizerTask.this.LIZ();
            SysOptimizerTask.this.LJIILL(context);
            SysOptimizerTask.LJ(context);
            SysOptimizerTask.LJFF(context);
            SysOptimizerTask.LJI(context);
            SysOptimizerTask.this.LJIIL(context);
            SysOptimizerTask.this.LJIIIZ(context);
            SysOptimizerTask.this.LJIIJ(context);
            SysOptimizerTask.this.LJIIJJI(context);
            DvmGlesOptimizer.fix(context);
            SysOptimizer.hookOptimizerEnable();
            Long.valueOf(System.currentTimeMillis());
            SysOptimizerTask.this.LIZIZ.booleanValue();
        }
    }

    public class SysOptMaliSwapBufferError implements C22438Ze {
        static {
            Covode.recordClassIndex(90650);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptMaliSwapBufferError() {
        }

        public void run(Context context) {
            SysOptimizerTask.this.LJIILIIL(context);
        }
    }

    public class SysOptOptimizeShrinker implements C22438Ze {
        static {
            Covode.recordClassIndex(90651);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public void run(Context context) {
            SysOptimizerTask.LIZJ();
        }

        public SysOptOptimizeShrinker() {
        }
    }

    public class SysOptOptimizeSuspendTimeout implements C22438Ze {
        static {
            Covode.recordClassIndex(90652);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptOptimizeSuspendTimeout() {
        }

        public void run(Context context) {
            if (AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "suspendtimeout_opt", true)) {
                SysOptimizerTask.LJIIZILJ(context);
            }
        }
    }

    public class SysOptRegionSpaceShrinkTask implements C22438Ze {
        static {
            Covode.recordClassIndex(90653);
        }

        public boolean meetTrigger() {
            return true;
        }

        public String prefix() {
            return "task_";
        }

        public boolean serialExecute() {
            return false;
        }

        public int targetProcess() {
            return 1048575;
        }

        public List triggerOtherLegoComponents() {
            return null;
        }

        public C42869Ft triggerType() {
            return C22428Zd.LIZ(this);
        }

        public C42909Fx scenesType() {
            return C42909Fx.DEFAULT;
        }

        public C25518ec type() {
            return C25518ec.APP_BACKGROUND;
        }

        public String key() {
            return getClass().getSimpleName();
        }

        public SysOptRegionSpaceShrinkTask() {
        }

        public void run(Context context) {
            C09037t8 r3 = (C09037t8) AnonymousClass9Y3.LIZ().LIZ(true, "heap_region_space_shrink_settings", C09037t8.class, (Object) C09047t9.LIZ);
            if (r3 != null && r3.LIZ) {
                HeapGCOptimizer.optimizeRegionSpaceVSS(context, r3.LIZIZ, r3.LIZJ, r3.LIZLLL);
            }
        }
    }

    public C42909Fx scenesType() {
        return C42909Fx.DEFAULT;
    }

    public int targetProcess() {
        return C07527qh.LIZ;
    }

    public C25518ec type() {
        return C25518ec.BACKGROUND;
    }

    public String[] deps() {
        return new String[]{"ABTask"};
    }

    public String key() {
        return getClass().getSimpleName();
    }

    public final void LIZ() {
        if (SettingsManager.LIZ().LIZ("type_face_opt_switch", true)) {
            TypeFaceOptimizer.start();
        }
    }

    public boolean meetTrigger() {
        if (((Boolean) C43189Gz.LIZ.getValue()).booleanValue()) {
            return false;
        }
        return true;
    }

    public C29988lp threadType() {
        if (((Boolean) RXb.LIZJ.getValue()).booleanValue()) {
            return C29988lp.IO;
        }
        return C29988lp.CPU;
    }

    public static void LIZIZ() {
        int size = SysOptimizer.getLoadLibraryError().size();
        if (size > 0) {
            int i = 0;
            do {
                LIZ(SysOptimizer.getLoadLibraryError().get(i), "load_so_exception", "load_sysoptimizer_failed", "load_sysoptimizer_failed", "load_sysoptimizer_failed", "SysOptimizerTask Thread");
                i++;
            } while (i < size);
        }
    }

    public static void LIZJ() {
        try {
            C08697sa r0 = (C08697sa) SettingsManager.LIZ().LIZ("shrink_settings", C08697sa.class);
            if (r0 != null && r0.LIZ) {
                Shrinker.getInstance().doShrink(SettingsManager.LIZ().LIZ("shrink_threshold", 512));
            }
        } catch (Throwable unused) {
        }
    }

    public static Context LJIJJ(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (AnonymousClass7lW.LIZJ && applicationContext == null) {
            return AnonymousClass7lW.LIZ;
        }
        return applicationContext;
    }

    public final void LJIIJJI(Context context) {
        MediaCodecReleaseOpt.fix(context, AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "media_codec_11_crash_fix_32_ab", false));
    }

    public static void LIZIZ(Context context) {
        if (SettingsManager.LIZ().LIZ("fix_samsung_field_get_name_crash", true)) {
            SmFakeNameHandler.start(context);
        }
    }

    public static void LIZLLL(Context context) {
        int LIZ2 = AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "fix_egl_create_surface_crash_times_ab", 0);
        if (LIZ2 > 0) {
            EglCreateSurfaceFixer.fixOsOP(context, LIZ2);
        }
    }

    public static void LJ(Context context) {
        if (SettingsManager.LIZ().LIZ("ul_native_crypto_opt", false)) {
            ONativeCryptoCRLOptimizer.fix(context);
        }
    }

    public static void LJFF(Context context) {
        if (SettingsManager.LIZ().LIZ("ul_mali_gpu_format_opt", false)) {
            MaliGpuExtIsSupportOptimizer.fix(context);
        }
    }

    public static void LJI(Context context) {
        if (SettingsManager.LIZ().LIZ("ul_kitkat_get_cookie_opt", false)) {
            KGetCookieOptimizer.fix(context);
        }
    }

    public static void LJIJ(Context context) {
        try {
            C08687sZ r0 = (C08687sZ) SettingsManager.LIZ().LIZ("art_oatfile_dump_settings", C08687sZ.class);
            if (r0 == null) {
                ArtOptimizer.disableDumpOatFileForANR(context);
            } else if (r0.LIZ) {
                ArtOptimizer.disableDumpOatFileForANR(context);
            }
        } catch (Throwable unused) {
        }
    }

    public final void LJIIIIZZ(Context context) {
        if (SettingsManager.LIZ().LIZ("fix_package_not_belong", false)) {
            BinderServiceWrapperProtector.setDebug(false);
            IConnectivityManagerProtector.install(context);
            IAutofillManagerProtector.install(context);
            OppoNAlarmProtector.install(context);
        }
    }

    public final void LJIIIZ(Context context) {
        if (SettingsManager.LIZ().LIZ("red_mi_typeface_fix", false)) {
            RedmiTypeFaceOptimizer.fixOnAndroidQ(context);
        }
    }

    public final void LJIIJ(Context context) {
        if (SettingsManager.LIZ().LIZ("stage_fright_fix", false)) {
            StageFrightAndroid4Optimizer.fixStageFrightAndroid4(context);
        }
    }

    public final void LJIIL(Context context) {
        int LIZ2 = AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "detach_current_thread_crash_fix_ab2", -1);
        if (LIZ2 > 0) {
            DetachCurrentThreadOpt.fix(context, LIZ2);
        }
    }

    public final void LJIILIIL(Context context) {
        if (Build.VERSION.SDK_INT >= 29 && Process.is64Bit() && AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "opt_mali_swap_buffer_error_ab", true)) {
            MaliMemOptimizer.enableMaliGLErrorSkip(context, false);
        }
    }

    public static void LJIIZILJ(Context context) {
        try {
            C08667sX r1 = (C08667sX) SettingsManager.LIZ().LIZ("art_suspend_timeout_settings", C08667sX.class);
            if (r1 == null) {
                ArtOptimizer.optSuspendTimeout(context);
            } else if (r1.LIZIZ) {
                if (r1.LIZ || C11817xc.LIZ(context)) {
                    ArtOptimizer.optSuspendTimeout(context);
                }
            }
        } catch (Throwable unused) {
        }
    }

    public final void LJII(Context context) {
        if (SettingsManager.LIZ().LIZ("fix_sensor_at_index", true)) {
            SystemSensorManagerOptimizer.fix(context);
        }
        if (SettingsManager.LIZ().LIZ("local_ref_enlarger", false)) {
            LocalRefEnlarger.fix(context);
        }
    }

    public final void LJIILL(Context context) {
        if (SettingsManager.LIZ().LIZ("register_broadcast_protector", true) && (LJIJJ(context) instanceof Application)) {
            ReceiverRegisterCrashOptimizer.fix((Application) LJIJJ(context));
        }
        ReceiverRegisterCrashOptimizer.setDoRegisterHandlerCallback(C08937sy.LIZ);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0036, code lost:
        if (r3 != null) goto L_0x0038;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0040, code lost:
        if (java.util.Arrays.asList(r4).contains(r3) != false) goto L_0x0042;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean LJIILLIIL(android.content.Context r7) {
        /*
            com.bytedance.ies.abmock.SettingsManager r2 = com.bytedance.ies.abmock.SettingsManager.LIZ()     // Catch:{ all -> 0x000f }
            java.lang.String r1 = "mtk_power_vr_optimizer"
            java.lang.Class<X.7sR> r0 = X.C08607sR.class
            java.lang.Object r5 = r2.LIZ((java.lang.String) r1, (java.lang.Class) r0)     // Catch:{ all -> 0x000f }
            X.7sR r5 = (X.C08607sR) r5     // Catch:{ all -> 0x000f }
            goto L_0x0010
        L_0x000f:
            r5 = 0
        L_0x0010:
            r1 = 0
            if (r5 != 0) goto L_0x0014
            return r1
        L_0x0014:
            r6 = 1
            boolean r0 = r5.LIZ
            if (r0 == 0) goto L_0x004a
            java.lang.String[] r0 = r5.LIZJ
            if (r0 == 0) goto L_0x0042
            java.lang.String[] r0 = r5.LIZJ
            int r0 = r0.length
            if (r0 <= 0) goto L_0x0042
            java.lang.String[] r0 = r5.LIZJ
            r1 = r0[r1]
            java.lang.String r0 = "all_devices"
            boolean r0 = r0.equals(r1)
            if (r0 != 0) goto L_0x0042
            java.lang.String[] r4 = r5.LIZJ
            java.lang.String r3 = android.os.Build.BRAND
            java.lang.String r2 = android.os.Build.MODEL
            if (r2 != 0) goto L_0x004b
        L_0x0036:
            if (r3 == 0) goto L_0x004a
        L_0x0038:
            java.util.List r0 = java.util.Arrays.asList(r4)
            boolean r0 = r0.contains(r3)
            if (r0 == 0) goto L_0x004a
        L_0x0042:
            boolean r0 = r5.LIZIZ
            com.bytedance.sysoptimizer.MTK_PVR_Optimizer.setAlwaysCatchSIGSEGV(r0)
            com.bytedance.sysoptimizer.MTK_PVR_Optimizer.enable(r7)
        L_0x004a:
            return r6
        L_0x004b:
            if (r3 == 0) goto L_0x0068
            boolean r0 = r2.contains(r3)
            if (r0 != 0) goto L_0x0068
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            r1.<init>()
            r1.append(r3)
            r0 = 32
            r1.append(r0)
            r1.append(r2)
            java.lang.String r3 = r1.toString()
            goto L_0x0036
        L_0x0068:
            r3 = r2
            goto L_0x0038
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.legoImp.task.SysOptimizerTask.LJIILLIIL(android.content.Context):boolean");
    }

    public static void LJIJI(Context context) {
        try {
            C08627sT r5 = (C08627sT) SettingsManager.LIZ().LIZ("enable_stack_leak_checker", C08627sT.class);
            if (r5 != null && r5.LIZ) {
                StackLeakChecker.registerStackLeakListener(new StackLeakChecker.StackLeakListener() {
                    static {
                        Covode.recordClassIndex(90641);
                    }

                    public final void onLeakReport(ArrayList<StackLeakItem> arrayList) {
                        Iterator<StackLeakItem> it = arrayList.iterator();
                        while (it.hasNext()) {
                            StackLeakItem next = it.next();
                            Throwable th = new Throwable(next.getLeakItem());
                            th.setStackTrace(new StackTraceElement[]{new StackTraceElement("StackLeakSoName", next.getSoName(), next.getSoName(), next.getLeakCount())});
                            SysOptimizerTask.LIZ(th, "stack_leak_info", "stackleak", "stackleak", "stackleak", "StackLeakChecker Thread");
                        }
                    }
                });
                StackLeakChecker.setInterval(r5.LIZIZ, ((long) (r5.LIZJ * 6)) * 10000000);
                String[] strArr = null;
                if (r5.LIZLLL != null && r5.LIZLLL.length() > 1) {
                    strArr = r5.LIZLLL.split(":");
                }
                StackLeakChecker.enableChecker(context, strArr);
            }
        } catch (Throwable unused) {
        }
    }

    public final void LIZ(Context context) {
        if (SettingsManager.LIZ().LIZ("hprof_dump_data_opt", true)) {
            VMDebugDumpHprofOptimizer.fix(context);
        }
    }

    public final void LIZJ(Context context) {
        if (Build.VERSION.SDK_INT >= 27 && Build.VERSION.SDK_INT <= 30 && SettingsManager.LIZ().LIZ("fix_jit_comile_method_crash", true)) {
            JitCompileMethodCrash.optimize(context);
        }
        if (Build.VERSION.SDK_INT == 26 && AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "jit_compile_method_crash_api26_fix_ab", false)) {
            JitCompileMethodCrash.optimize(context);
        }
    }

    public final void LJIILJJIL(Context context) {
        C08647sV r1 = (C08647sV) AnonymousClass9Y3.LIZ().LIZ(true, "tiktok_jemalloc_settings", C08647sV.class, (Object) C08637sU.LIZ);
        if (r1 != null && r1.LIZ) {
            NativeAllocatorOptimizer.optimize(context, r1.LIZIZ);
        }
        int LIZ2 = AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "tiktok_jemalloc_decaytime_opt", -1);
        if (LIZ2 > 0) {
            NativeAllocatorOptimizer.doJemallocDecayOpt(context, LIZ2);
        }
        if (AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "tiktok_native_thread_shrink_opt", false)) {
            NativeAllocatorOptimizer.doShrinkNativeThread(context, 524288);
        }
        if (AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "tiktok_webview_reserved_shrink_opt", false)) {
            Jato.shrinkVM(true);
        }
    }

    public void run(Context context) {
        int i;
        2kf.LIZ("SysOptimizerTask");
        this.LIZIZ = Boolean.valueOf(C11817xc.LIZ(context));
        if (TnA.LJFF.LJFF()) {
            this.LIZ = Long.valueOf(System.currentTimeMillis());
            C42759Fi r1 = new C42759Fi();
            r1.LIZ(new SysOptDvmOptimizer());
            r1.LIZ(new SysOptOptimizeSuspendTimeout());
            r1.LIZ(new SysOptFixSamSungGetNameCrash());
            r1.LIZ(new SysOptAddMemAllocator());
            r1.LIZ(new SysOptMaliSwapBufferError());
            r1.LIZ(new SysOptHeapGCAdjustTask());
            r1.LIZ(new SysOptRegionSpaceShrinkTask());
            r1.LIZ(new SysOptDisableDumpOatFileForANR());
            r1.LIZ(new SysOptHookOptimizerEnable());
            r1.LIZ(new SysOptOptimizeShrinker());
            r1.LIZ(new SysOptEnableStackLeakChecker());
            r1.LIZ(new SysOptCheckSoLoadResult());
            r1.LIZ();
            return;
        }
        this.LIZ = Long.valueOf(System.currentTimeMillis());
        DvmOptimizer.optDvmLinearAllocBuffer(context);
        if (AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "suspendtimeout_opt", true)) {
            LJIIZILJ(context);
        }
        C42749Fh r0 = C42749Fh.LJIILIIL;
        C42759Fi r12 = new C42759Fi();
        r12.LIZ(new SysOptRegionSpaceShrinkTask());
        r12.LIZ();
        LJIILIIL(context);
        C08617sS r4 = (C08617sS) AnonymousClass9Y3.LIZ().LIZ(true, "heap_gc_adjust_settings", C08617sS.class, (Object) C08677sY.LIZ);
        if (r4 != null && r4.LIZ) {
            HeapGCOptimizer.optimize(context, r4.LIZIZ, r4.LIZJ, r4.LIZLLL);
        }
        try {
            i = Keva.getRepo("ab_repo_cold_boot").getInt("out_of_memory_error_heap_gc", 0);
        } catch (Throwable unused) {
            i = 0;
        }
        C08707sb.LIZ = i;
        LJIILJJIL(context);
        LIZIZ(context);
        LJIJ(context);
        if (Build.VERSION.SDK_INT == 24) {
            HighLevelTrimMemory.optimize(context);
        }
        DvmDeadLockOptimizer.optimize(context);
        if (C11817xc.LIZ(context)) {
            LJIILLIIL(context);
        }
        LIZJ(context);
        LJII(context);
        LJIIIIZZ(context);
        LIZ();
        LJIILL(context);
        LJ(context);
        LJFF(context);
        LJI(context);
        LJIIIZ(context);
        Application application = (Application) context;
        if (SettingsManager.LIZ().LIZ("samsung_et_leak_opt", true)) {
            SmEditTextLeakOpt.optimize(application);
            SfZ.LJIJ.LJI().LIZLLL(AnonymousClass7fE.LIZ);
        }
        LJIIJ(context);
        LJIIJJI(context);
        if (AnonymousClass9Y3.LIZ(AnonymousClass9Y3.LIZ(), true, "hint_activity_launch_crash_fix_ab", false)) {
            GraphicsEnvOpt.fix(context);
        }
        LJIIL(context);
        LIZLLL(context);
        if (SettingsManager.LIZ().LIZ("fix_NativeCrypto_d2i_X509_CRL_bio_crash", true)) {
            ONativeCryptoCRLOptimizer.fix(context);
        }
        if (SettingsManager.LIZ().LIZ("fix_damage_frame_log", false)) {
            MaliMemOptimizer.enableEglSetDamageRegionKHRErrorSkip(context, true);
        }
        DvmGlesOptimizer.fix(context);
        SysOptimizer.hookOptimizerEnable();
        LIZJ();
        LIZ(context);
        LJIJI(context);
        if (C08657sW.LIZ) {
            try {
                Reflect on = Reflect.on("com.mediatek.view.ViewDebugManager");
                on.set("sInstance", on.create().get());
            } catch (Throwable unused2) {
            }
        }
        LIZIZ();
        this.LIZIZ.booleanValue();
    }

    public static void LIZ(Throwable th, String str, String str2, String str3, String str4, String str5) {
        String str6 = str3;
        String str7 = str5;
        String str8 = str2;
        C26998h0 LIZ2 = C26998h0.LIZ(th.getStackTrace()[th.getStackTrace().length - 1], C26968gx.LIZ(th.getStackTrace()), str8, str7, false, str6, str6);
        ArrayList arrayList = new ArrayList();
        arrayList.add(th.toString());
        LIZ2.LIZ(str, (List<String>) arrayList);
        LIZ2.LIZ(str4, "true");
        C27888iR.LIZ(LIZ2);
    }
}
