正版风暴黑马 v5.0版本的 MD5 值为:01425d13106471265483ee3782390bf1

以下内容为反编译后的 C1132oo00o0o.java 源代码,内容仅作参考


package p0000oO008.p001ooo8o088.p002Oo0oo80;

import android.graphics.Bitmap;
import android.text.TextUtils;
import android.util.Base64;
import com.android.launcher3.StringFog;
import com.gibb.App;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

public class C1132oo00o0o extends OO0O0 {

    String f3747lll = null;
    String LLI1lI1 = null;

    private String LLI1lI1(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        try {
            JSONArray optJSONArray = new JSONObject(str).optJSONArray("words_result");
            JSONArray jSONArray = new JSONArray();
            for (int i = 0; i < optJSONArray.length(); i++) {
                JSONObject jSONObject = optJSONArray.getJSONObject(i);
                JSONObject jSONObject2 = new JSONObject();
                try {
                    jSONObject2.putOpt("label", jSONObject.optString("words"));
                } catch (JSONException unused) {
                }
                try {
                    jSONObject2.putOpt("confidence", 100);
                } catch (JSONException unused2) {
                }
                JSONObject jSONObject3 = jSONObject.getJSONObject("location");
                if (jSONObject3 != null) {
                    try {
                        jSONObject2.putOpt("x", Integer.valueOf(jSONObject3.optInt("left")));
                    } catch (JSONException unused3) {
                    }
                    try {
                        jSONObject2.putOpt("y", Integer.valueOf(jSONObject3.optInt("top")));
                    } catch (JSONException unused4) {
                    }
                    try {
                        jSONObject2.putOpt(StringFog.decrypt("N1ldTFk="), Integer.valueOf(jSONObject3.optInt(StringFog.decrypt("N1ldTFk="))));
                    } catch (JSONException unused5) {
                    }
                    try {
                        jSONObject2.putOpt(StringFog.decrypt("KFVQX1lN"), Integer.valueOf(jSONObject3.optInt(StringFog.decrypt("KFVQX1lN"))));
                    } catch (JSONException unused6) {
                    }
                }
                jSONArray.put(jSONObject2);
            }
            return jSONArray.toString();
        } catch (Exception e) {
            m2084lll("解析百度结果失败 " + e.getLocalizedMessage());
            return null;
        }
    }

    public static String LLI1lI1(String str, String str2, String str3, String str4) throws Exception {
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setRequestProperty("Content-Type", str2);
        httpURLConnection.setRequestProperty("Connection", "Keep-Alive");
        httpURLConnection.setUseCaches(false);
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setDoInput(true);
        DataOutputStream dataOutputStream = new DataOutputStream(httpURLConnection.getOutputStream());
        dataOutputStream.write(str3.getBytes(str4));
        dataOutputStream.flush();
        dataOutputStream.close();
        httpURLConnection.connect();
        Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
        for (String str5 : headerFields.keySet()) {
            System.err.println(str5 + "--->" + headerFields.get(str5));
        }
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream(), str4));
        String str6 = "";
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                bufferedReader.close();
                System.err.println("result:" + str6);
                return str6;
            }
            str6 = str6 + readLine;
        }
    }

    private JSONObject il() {
        try {
            String body = Jsoup.connect("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + this.f3747lll + "&client_secret=" + this.LLI1lI1).method(Connection.Method.GET).ignoreContentType(true).ignoreHttpErrors(true).execute().body();
            System.out.println("data " + body);
            return new JSONObject(body);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("== " + e.getLocalizedMessage());
            m2084lll("请求百度的token错误: " + e.getLocalizedMessage());
            return null;
        }
    }

    public static String m6138lll(String str, String str2, String str3) throws Exception {
        return m6139lll(str, str2, "application/x-www-form-urlencoded", str3);
    }

    public static String m6139lll(String str, String str2, String str3, String str4) throws Exception {
        return m6140lll(str, str2, str3, str4, str.contains("nlp") ? "GBK" : "UTF-8");
    }

    public static String m6140lll(String str, String str2, String str3, String str4, String str5) throws Exception {
        return LLI1lI1(str + "?access_token=" + str2, str3, str4, str5);
    }

    public String LLI1lI1() {
        JSONObject jSONObject;
        String LLI1lI1 = O88o00o88.m1820lll(App.getContext(), "baidutoken").LLI1lI1("tokens");
        System.out.println("data " + LLI1lI1);
        try {
        } catch (Exception e) {
            m2084lll("获取token失败 " + e.getLocalizedMessage());
        }
        if (!TextUtils.isEmpty(LLI1lI1)) {
            JSONObject jSONObject2 = new JSONObject(LLI1lI1);
            if (TextUtils.isEmpty(jSONObject2.optString(StringFog.decrypt("JUJLV0M=")))) {
                jSONObject = jSONObject2;
                if (jSONObject != null) {
                    if (m2083lILLLIL() != null) {
                        m2084lll("请求token错误,请检查ak和sk");
                    }
                    return "";
                }
                if (!TextUtils.isEmpty(jSONObject.optString(StringFog.decrypt("JUJLV0M=")))) {
                    m2084lll("请求token错误 error: " + jSONObject.optString(StringFog.decrypt("JUJLV0M=")) + "  error_description: " + jSONObject.optString(StringFog.decrypt("JUJLV0NmV1ZBUQoVDAgVFy4=")));
                    return "";
                }
                long optLong = jSONObject.optLong(StringFog.decrypt("M0RWSlRtWl5X"));
                long optLong2 = jSONObject.optLong("expires_in");
                if (optLong <= 0) {
                    long currentTimeMillis = System.currentTimeMillis();
                    jSONObject.put(StringFog.decrypt("M0RWSlRtWl5X"), System.currentTimeMillis());
                    O88o00o88.m1820lll(App.getContext(), StringFog.decrypt("IlFQXERNXFhXXA==")).LLI1lI1(StringFog.decrypt("NF9SXV9K"), jSONObject.toString());
                    optLong = currentTimeMillis;
                }
                if (!(System.currentTimeMillis() - optLong < optLong2)) {
                    jSONObject = il();
                    if (jSONObject == null) {
                        if (m2083lILLLIL() != null) {
                            m2084lll("请求token错误");
                        }
                        return "";
                    }
                    if (!TextUtils.isEmpty(jSONObject.optString(StringFog.decrypt("JUJLV0M=")))) {
                        m2084lll("请求token错误 error: " + jSONObject.optString(StringFog.decrypt("JUJLV0M=")) + "  error_description: " + jSONObject.optString(StringFog.decrypt("JUJLV0NmV1ZBUQoVDAgVFy4=")));
                        return "";
                    }
                    jSONObject.put(StringFog.decrypt("M0RWSlRtWl5X"), System.currentTimeMillis());
                    O88o00o88.m1820lll(App.getContext(), StringFog.decrypt("IlFQXERNXFhXXA==")).LLI1lI1(StringFog.decrypt("NF9SXV9K"), jSONObject.toString());
                }
                if (jSONObject != null) {
                    return jSONObject.getString("access_token");
                }
                return "";
            }
        }
        jSONObject = il();
        if (jSONObject != null) {
        }
    }

    @Override
    public boolean mo1720Lil1l() {
        super.mo1720Lil1l();
        return true;
    }

    @Override
    public String mo1721lll(Bitmap bitmap, String str) {
        String str2;
        m2084lll((String) null);
        if (bitmap == null) {
            str2 = "图片对象无效";
        } else {
            try {
                JSONObject jSONObject = new JSONObject(str);
                String optString = jSONObject.optString("access_token");
                if (TextUtils.isEmpty(optString)) {
                    optString = LLI1lI1();
                }
                if (TextUtils.isEmpty(optString)) {
                    return null;
                }
                try {
                    String optString2 = jSONObject.optString("url");
                    if (TextUtils.isEmpty(optString2)) {
                        m2084lll("百度在线OCR请设置请求的URL,具体参考 https://ai.baidu.com/ai-doc/OCR/Ck3h7y2ia");
                        return null;
                    }
                    o8ooo0 o8ooo0Var = new o8ooo0();
                    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, o8ooo0Var);
                    byte[] LLI1lI1 = o8ooo0Var.LLI1lI1();
                    o8ooo0Var.close();
                    return LLI1lI1(m6138lll(optString2, optString, "image=" + URLEncoder.encode(Base64.encodeToString(LLI1lI1, 0), "UTF-8")));
                } catch (Exception e) {
                    e.printStackTrace();
                    m2084lll("OCR识别失败 " + e.getLocalizedMessage());
                    return super.mo1721lll(bitmap, str);
                }
            } catch (JSONException e2) {
                e2.printStackTrace();
                str2 = "扩展参数错误: " + e2.getLocalizedMessage();
            }
        }
        m2084lll(str2);
        return null;
    }

    @Override
    public boolean mo1722lll() {
        return true;
    }

    @Override
    public boolean mo1723lll(JSONObject jSONObject) {
        m2084lll((String) null);
        if (jSONObject == null) {
            m2084lll("初始化参数为空");
            return false;
        }
        this.f3747lll = jSONObject.optString("ak");
        this.LLI1lI1 = jSONObject.optString("sk");
        return true;
    }
}