华润售电云 v2.2.7版本的 MD5 值为:93c9468f6a7b82a4ae05a1eac91dbd03

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


package com.iflytek.thirdparty;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.iflytek.cloud.ErrorCode;
import com.iflytek.cloud.RequestListener;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.SpeechEvent;
import com.iflytek.cloud.SpeechUtility;
import com.iflytek.cloud.util.AudioDetector;
import com.iflytek.cloud.util.FileDownloadListener;
import com.iflytek.msc.MSC;
import com.iflytek.msc.MSCSessionInfo;
import com.iflytek.thirdparty.P;
import io.dcloud.common.util.JSUtil;
import java.io.UnsupportedEncodingException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
public class C0095s {
    private static String A = "http://wke.openspeech.cn/wakeup/";
    private Context w;
    private P x;
    private L z;
    private String b = "athinfo";
    private String c = "respath";
    private String d = "appid";
    private String e = "resid";
    private String f = "wakelist";
    private String g = "restype";
    private String h = "uid";
    private String i = "expiredate";
    private String j = "resver";
    private String k = "restime";
    private String l = "wakever";
    private String m = "ivwword";
    private String n = "words";
    private String o = "text";
    private String p = AudioDetector.THRESHOLD;
    private String q = "d";
    private String r = "netval";
    private String s = ":";
    private String t = "unkown";
    private String u = "header";
    private String v = "info";
    private RequestListener y = null;
    public P.a a = new P.a() {
        @Override
        public void a(SpeechError speechError) {
            if (speechError != null) {
                X.b("query resource error. errorcode:" + speechError.getErrorCode());
            } else {
                X.c("query resource succeed");
            }
            if (C0095s.this.y != null) {
                C0095s.this.y.onCompleted(speechError);
            }
        }

        @Override
        public void a(P p, byte[] bArr) {
            try {
                String str = new String(bArr, "utf-8");
                X.c("updateInfo:" + str);
                JSONObject jSONObject = new JSONObject(str);
                try {
                    H.a(C0095s.this.w).a("ivw_netval", Integer.valueOf((String) jSONObject.remove(C0095s.this.r)).intValue());
                } catch (Exception e) {
                    X.a(e);
                }
                int i = jSONObject.getInt(SpeechUtility.TAG_RESOURCE_RET);
                if (i == 0) {
                    if (C0095s.this.y != null) {
                        C0095s.this.y.onBufferReceived(bArr);
                    }
                    a(null);
                    return;
                }
                String string = jSONObject.getString(SpeechConstant.IST_SESSION_ID);
                if (C0095s.this.y != null) {
                    Bundle bundle = new Bundle();
                    bundle.putString(SpeechEvent.KEY_EVENT_SESSION_ID, string);
                    C0095s.this.y.onEvent(20001, bundle);
                }
                a(new SpeechError(i));
            } catch (Exception e2) {
                X.a(e2);
                a(new SpeechError(20004));
            }
        }
    };

    public C0095s(Context context) {
        this.w = null;
        this.x = null;
        this.z = null;
        this.w = context;
        this.z = L.a(context);
        this.x = new P();
    }

    private JSONObject a(JSONObject jSONObject, JSONObject jSONObject2) {
        try {
            if (jSONObject.getString(this.j).equalsIgnoreCase(this.t)) {
                X.c("user ivw resver unkown");
                return null;
            }
            if (!jSONObject2.getString(this.j).equalsIgnoreCase(this.t) && jSONObject.getString(this.j).equalsIgnoreCase(jSONObject2.getString(this.j))) {
                return (J.a(this.d, jSONObject, jSONObject2) && J.a(this.e, jSONObject, jSONObject2) && J.a(this.g, jSONObject, jSONObject2) && J.a(this.f, jSONObject, jSONObject2) && J.b(this.k, jSONObject, jSONObject2)) ? jSONObject2 : jSONObject;
            }
            X.c("cfg ivw resver unkown or unequal");
            return jSONObject;
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
    }

    private JSONObject c(String str, String str2) {
        JSONArray jSONArray;
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put(this.c, str);
            JSONObject jSONObject2 = new JSONObject(new JSONTokener(str2));
            JSONObject jSONObject3 = jSONObject2.getJSONObject(this.b);
            String str3 = this.d;
            jSONObject.put(str3, jSONObject3.getString(str3));
            String str4 = this.e;
            jSONObject.put(str4, jSONObject3.getString(str4));
            String string = jSONObject3.getString(this.g);
            jSONObject.put(this.g, string);
            if (!this.q.equalsIgnoreCase(string)) {
                String str5 = this.h;
                jSONObject.put(str5, jSONObject3.getString(str5));
                String str6 = this.i;
                jSONObject.put(str6, jSONObject3.getString(str6));
            }
            String str7 = "";
            for (int i = 0; i < jSONObject2.getJSONObject(this.m).getJSONArray(this.n).length(); i++) {
                str7 = (((str7 + jSONArray.getJSONObject(i).getString(this.o)) + this.s) + jSONArray.getJSONObject(i).getInt(this.p)) + JSUtil.COMMA;
            }
            jSONObject.put(this.f, str7.substring(0, str7.length() - 1));
            try {
                String str8 = this.j;
                jSONObject.put(str8, jSONObject2.getString(str8));
            } catch (JSONException unused) {
                jSONObject.put(this.j, this.t);
            }
            try {
                String str9 = this.k;
                jSONObject.put(str9, jSONObject2.getLong(str9));
            } catch (JSONException unused2) {
                jSONObject.put(this.k, 0L);
            }
            jSONObject.put(this.l, SpeechUtility.getUtility() != null ? SpeechUtility.getUtility().getParameter("ver_ivw") : "");
            X.c("root:" + jSONObject.toString());
            return jSONObject;
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
    }

    public int a(String str, String str2, String str3, FileDownloadListener fileDownloadListener) {
        return (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) ? ErrorCode.ERROR_INVALID_PARAM : this.z.a(str, str2, str3, fileDownloadListener);
    }

    public int a(JSONObject jSONObject, RequestListener requestListener) {
        if (jSONObject == null) {
            return ErrorCode.ERROR_INVALID_DATA;
        }
        if (requestListener != null) {
            try {
                this.y = requestListener;
            } catch (Exception e) {
                X.a(e);
                return 20003;
            }
        }
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put(this.u, C0063ac.d(this.w, new C0061aa()));
        jSONObject2.put(this.v, jSONObject);
        X.c("post data:" + jSONObject2);
        byte[] b = K.b(jSONObject2.toString().getBytes());
        this.x.a(1);
        this.x.a(A, null, b);
        this.x.a(this.a);
        return 0;
    }

    public synchronized JSONObject a(String str, String str2) {
        if (TextUtils.isEmpty(str2)) {
            return b(str, "");
        }
        JSONObject b = b(str, "");
        if (b == null) {
            return null;
        }
        JSONObject b2 = b(str2, "");
        if (b2 == null) {
            return b;
        }
        return a(b, b2);
    }

    public void a() {
        P p = this.x;
        if (p != null) {
            p.a();
            this.x = null;
        }
        this.y = null;
    }

    public JSONObject b(String str, String str2) {
        MSCSessionInfo mSCSessionInfo = new MSCSessionInfo();
        int QIVWGetResInfo = MSC.QIVWGetResInfo(str.getBytes(), str2.getBytes(), mSCSessionInfo);
        if (QIVWGetResInfo != 0) {
            X.b("read ivw resoure error:" + QIVWGetResInfo);
            return null;
        }
        try {
            String str3 = new String(mSCSessionInfo.buffer, "utf-8");
            X.c("resInfo:" + new String(mSCSessionInfo.buffer));
            return c(str, str3);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
}