package d.f.a.r2;

import android.app.ActivityManager;
import android.content.Context;
import android.provider.Settings;
import android.util.Log;
import com.cvte.vman.VmanMiddleWare;
import com.cvte.vman.impl.AtCfgControlManager;
import com.seewo.sdk.SDKConfigureHelper;
import f.a.w.e.d.c;
import java.io.File;
import java.util.Map;

/* JADX INFO: compiled from: ActionHelper.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public final class n2 {
    public static final n2 a = null;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static boolean f3282b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final g.g f3283c = f.a.y.a.v0(a.f3284b);

    /* JADX INFO: compiled from: ActionHelper.kt */
    @g.i
    public static final class a extends g.h0.c.m implements g.h0.b.a<Map<Integer, ? extends String>> {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public static final a f3284b = new a();

        public a() {
            super(0);
        }

        @Override // g.h0.b.a
        public Map<Integer, ? extends String> invoke() {
            return g.c0.g.v(new g.k(0, "Not defined"), new g.k(1, "0%-10%"), new g.k(2, "<b><font color=#FF0000>10%-20%</b>"), new g.k(3, "<b><font color=#FF0000>20%-30%</b>"), new g.k(4, "<b><font color=#FF0000>30%-40%</b>"), new g.k(5, "<b><font color=#FF0000>40%-50%</b>"), new g.k(6, "<b><font color=#FF0000>50%-60%</b>"), new g.k(7, "<b><font color=#FF0000>60%-70%</b>"), new g.k(8, "<b><font color=#cd9622>70%-80%</b>"), new g.k(9, "<b><font color=#ff0000>80%-90%</b>"), new g.k(10, "<b><font color=#ff0000>90%-100%</b>"), new g.k(11, "<b><font color=#ff0000>maximum</b>"));
        }
    }

    public static final boolean a() {
        String machineSN = SDKConfigureHelper.I.getMachineSN();
        g.h0.c.l.e(machineSN, "I.machineSN");
        return machineSN.length() > 0;
    }

    public static final f.a.i<d.f.a.q0> b(Context context, final String str, final String str2) {
        g.h0.c.l.f(context, "context");
        g.h0.c.l.f(str, "fileName");
        f.a.w.e.d.c cVar = new f.a.w.e.d.c(new f.a.k() { // from class: d.f.a.r2.a
            @Override // f.a.k
            public final void subscribe(f.a.j jVar) {
                String strQ = str2;
                String str3 = str;
                g.h0.c.l.f(str3, "$fileName");
                g.h0.c.l.f(jVar, "emitter");
                if (strQ == null) {
                    g.h0.c.l.f(str3, "fileName");
                    if (g.m0.f.J(str3, "/", false, 2)) {
                        strQ = str3;
                    } else if (u2.o()) {
                        File file = new File(d.b.a.a.a.v(new StringBuilder(), u2.i().a, "/xbug_log/"));
                        if (!file.exists()) {
                            file.mkdir();
                        }
                        strQ = file.getAbsolutePath() + '/' + str3 + ".zip";
                    } else {
                        strQ = d.b.a.a.a.q("/sdcard/xbug_log/", str3, ".zip");
                    }
                }
                String strP = d.b.a.a.a.p("xbug -d ", strQ);
                Log.i("ActionHelper", "start execute xbug command: " + strP);
                d.i.f.g.d dVarC = d.i.c.a.c(strP, false);
                StringBuilder sbF = d.b.a.a.a.F(d.b.a.a.a.B("result errorMsg:"), dVarC.f3660c, "ActionHelper", "result successMsg:");
                sbF.append(dVarC.f3659b);
                Log.i("ActionHelper", sbF.toString());
                d.i.f.g.d dVarC2 = d.i.c.a.c("sync", false);
                StringBuilder sbF2 = d.b.a.a.a.F(d.b.a.a.a.B("sync result errorMsg:"), dVarC2.f3660c, "ActionHelper", "sync result successMsg:");
                sbF2.append(dVarC2.f3659b);
                Log.i("ActionHelper", sbF2.toString());
                c.a aVar = (c.a) jVar;
                aVar.d(new d.f.a.q0(dVarC.a == 0, strQ));
                aVar.b();
            }
        });
        g.h0.c.l.e(cVar, "create { emitter: Observ…er.onComplete()\n        }");
        return cVar;
    }

    public static final boolean c(Context context) {
        int i2;
        g.h0.c.l.f(context, "context");
        if (d.i.f.a.a.a < 7) {
            return d.i.f.c.c.c("persist.sys.adbd.on", 0) == 1;
        }
        try {
            i2 = Settings.Global.getInt(context.getContentResolver(), "adb_enabled");
        } catch (Settings.SettingNotFoundException e2) {
            Log.e("ActionHelper", e2.getMessage(), e2);
            i2 = 0;
        }
        return i2 == 1;
    }

    public static final String d(String str) {
        g.h0.c.l.f(str, "fileName");
        if (g.m0.f.J(str, "/", false, 2)) {
            return str;
        }
        if (!u2.o()) {
            return d.b.a.a.a.q("/sdcard/xbug_log/", str, ".zip");
        }
        File file = new File(d.b.a.a.a.v(new StringBuilder(), u2.i().a, "/xbug_log/"));
        if (!file.exists()) {
            file.mkdir();
        }
        return file.getAbsolutePath() + '/' + str + ".zip";
    }

    public static final float e(Context context) {
        g.h0.c.l.f(context, "context");
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        Object systemService = context.getSystemService("activity");
        g.h0.c.l.d(systemService, "null cannot be cast to non-null type android.app.ActivityManager");
        ((ActivityManager) systemService).getMemoryInfo(memoryInfo);
        long j2 = memoryInfo.totalMem;
        long j3 = memoryInfo.availMem;
        StringBuilder sbB = d.b.a.a.a.B("totalMemory = ");
        sbB.append(c.n.a.d(j2));
        Log.i("ActionHelper", sbB.toString());
        Log.i("ActionHelper", "availMemory = " + c.n.a.d(j3));
        return (j2 - j3) / j2;
    }

    public static final boolean f() {
        String string = VmanMiddleWare.getInstance().getAtCfgControl().getString(AtCfgControlManager.IDX_PRELOADER_B);
        Log.i("ActionHelper", "preLoaderB: " + string);
        return g.h0.c.l.a("FAIL", string) || g.h0.c.l.a("fail", string);
    }

    public static final String g() {
        int emmclifeTime = VmanMiddleWare.getInstance().getSystemCtrl().readEmmclifeTime();
        Log.i("ActionHelper", "emmc life: " + emmclifeTime);
        String str = (String) ((Map) f3283c.getValue()).get(Integer.valueOf(emmclifeTime));
        return str == null ? "Not defined" : str;
    }

    public static final void h() {
        boolean camDefaultDistortionCorrection = VmanMiddleWare.getInstance().getAvManager().getCamDefaultDistortionCorrection();
        Log.d("ActionHelper", "resetCameraDistortionCorrection,default: " + camDefaultDistortionCorrection);
        d.b.a.a.a.P("setCamDistortionCorrection result: ", VmanMiddleWare.getInstance().getAvManager().setCamDistortionCorrection(camDefaultDistortionCorrection), "ActionHelper");
    }

    /* JADX WARN: Removed duplicated region for block: B:118:0x020a  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x016b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final boolean i(android.content.Context r17) {
        /*
            Method dump skipped, instruction units count: 553
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: d.f.a.r2.n2.i(android.content.Context):boolean");
    }

    public static final void j(boolean z, Context context) {
        g.h0.c.l.f(context, "context");
        int i2 = d.i.f.a.a.a;
        if (i2 >= 7) {
            Settings.Global.putInt(context.getContentResolver(), "adb_enabled", z ? 1 : 0);
            return;
        }
        if (d.i.f.b.a.a.contains("banpai") && i2 == 4) {
            Settings.Global.putInt(context.getContentResolver(), "adb_enabled", !z ? 1 : 0);
        }
        d.i.f.c.c.l("persist.sys.adbd.on", Integer.toString(z ? 1 : 0));
    }
}
