package com.pgl.ssdk;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import com.pgl.ssdk.ces.out.DungeonFlag;
import java.util.Arrays;
import org.json.JSONArray;
import org.json.JSONObject;
import org.objectweb.asm.Opcodes;
/* renamed from: com.pgl.ssdk.v  reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public class C1482v {

    /* renamed from: a  reason: collision with root package name */
    private static Context f4771a;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.pgl.ssdk.v$a */
    /* loaded from: classes6.dex */
    public static class a implements Runnable {
        a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            w.b(C1482v.b());
            com.pgl.ssdk.ces.a.meta(226, C1482v.b(), null);
        }
    }

    @DungeonFlag
    public static String a(Context context) {
        TelephonyManager telephonyManager;
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("status", 0);
            jSONObject.put("envcode", ((Long) com.pgl.ssdk.ces.a.meta(154, context, null)).longValue());
            jSONObject.put("bootcount", C1479s.a(context));
            Object meta = com.pgl.ssdk.ces.a.meta(155, context, null);
            jSONObject.put("usb_debug", meta instanceof Boolean ? ((Boolean) meta).booleanValue() : false);
            JSONArray[] b = C1479s.b(context);
            if (b != null) {
                jSONObject.put("sdata", b[0]);
                jSONObject.put("sdmta", b[1]);
                jSONObject.put("curtime", System.currentTimeMillis() / 1000);
            }
            jSONObject.put("camera_count", C1480t.a());
            if (C1480t.f4768a == -1 && (telephonyManager = (TelephonyManager) context.getSystemService("phone")) != null) {
                C1480t.f4768a = telephonyManager.getSimState();
            }
            jSONObject.put("sim", C1480t.f4768a);
            jSONObject.put("virtual_display", w.a(context));
            jSONObject.put("acbs", C1478q.a(context));
            Object meta2 = com.pgl.ssdk.ces.a.meta(156, context, null);
            jSONObject.put("bl_unlock", meta2 instanceof Boolean ? ((Boolean) meta2).booleanValue() : false);
            C1481u.g();
            C1481u.a(jSONObject);
            String e = r.e();
            jSONObject.put("romtype", C1479s.c());
            jSONObject.put("root", ((Integer) com.pgl.ssdk.ces.a.meta(Opcodes.IF_ICMPGE, null, null)).intValue());
            if (!TextUtils.isEmpty(e)) {
                jSONObject.put("sign", e);
            }
            return (String) com.pgl.ssdk.ces.a.meta(227, context, jSONObject.toString());
        } catch (Throwable th) {
            JSONObject jSONObject2 = new JSONObject();
            try {
                jSONObject2.put("status", 3);
                jSONObject2.put("exception", th.toString());
                jSONObject2.put("stacktrace", Arrays.toString(th.getStackTrace()));
                jSONObject2.put("cause", String.valueOf(th.getCause()));
                return Base64.encodeToString(jSONObject2.toString().getBytes("UTF-8"), 0);
            } catch (Throwable unused) {
                return "eyJzdGF0dXMiOjN9";
            }
        }
    }

    public static Context b() {
        return f4771a;
    }

    public static void b(Context context) {
        f4771a = context;
    }

    public static String c() {
        String a2 = a(f4771a);
        a();
        return a2;
    }

    @DungeonFlag
    public static void a() {
        AbstractC1464c.a(new a());
    }
}
