QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.btts.engine.a;

import android.util.Base64;
import android.util.Log;
import com.tencent.btts.d;
import com.tencent.btts.e;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import org.json.JSONObject;

public class b implements Callable<Integer> {

    private String f8850a = "HttpEngineCallableImpl";

    private d f8851b = null;

    private com.tencent.btts.engine.d f8852c = null;

    private com.tencent.btts.engine.c f8853d = null;

    private String a(HttpURLConnection httpURLConnection) {
        InputStream inputStream = httpURLConnection.getInputStream();
        String contentEncoding = httpURLConnection.getContentEncoding();
        InputStream inflaterInputStream = (contentEncoding == null || !contentEncoding.equalsIgnoreCase("gzip")) ? (contentEncoding == null || !contentEncoding.equalsIgnoreCase("deflate")) ? inputStream : new InflaterInputStream(inputStream, new Inflater(true)) : new GZIPInputStream(inputStream);
        String a2 = c.a(inflaterInputStream);
        inflaterInputStream.close();
        return a2;
    }

    private void a(d dVar, com.tencent.btts.engine.d dVar2, byte[] bArr, com.tencent.btts.engine.c cVar, boolean z, boolean z2) {
        int ceil = (int) Math.ceil(bArr.length / 1024);
        int i = 0;
        while (i < ceil) {
            boolean z3 = true;
            boolean z4 = cVar.a() && z && i == 0;
            boolean z5 = cVar.b() && z2 && i == ceil + (-1);
            int i2 = i * 1024;
            int i3 = i + 1;
            int i4 = i3 * 1024;
            if (i4 >= bArr.length) {
                i4 = bArr.length;
            }
            byte[] copyOfRange = Arrays.copyOfRange(bArr, i2, i4);
            e eVar = new e(dVar.a(), dVar.c(), z4, z5);
            eVar.a(dVar.e());
            eVar.a(copyOfRange);
            eVar.a(cVar.c());
            eVar.b(cVar.d());
            if (!z || i != 0) {
                z3 = false;
            }
            eVar.c(z3);
            dVar2.a(eVar);
            i = i3;
        }
    }

    private void a(HttpURLConnection httpURLConnection, String str) {
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setDoInput(true);
        httpURLConnection.setUseCaches(false);
        httpURLConnection.setConnectTimeout(15000);
        httpURLConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        httpURLConnection.setRequestProperty("Authorization", str);
    }

    private void a(HttpURLConnection httpURLConnection, JSONObject jSONObject, String str) {
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setDoInput(true);
        httpURLConnection.setUseCaches(false);
        httpURLConnection.setConnectTimeout(15000);
        httpURLConnection.setReadTimeout(15000);
        httpURLConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        httpURLConnection.setRequestProperty("Authorization", str);
        httpURLConnection.connect();
        byte[] bytes = jSONObject.toString().getBytes("utf-8");
        OutputStream outputStream = httpURLConnection.getOutputStream();
        outputStream.write(bytes);
        outputStream.flush();
        outputStream.close();
    }

    @Override
    public Integer call() {
        int i;
        String str;
        String str2;
        JSONObject a2;
        HttpURLConnection httpURLConnection;
        String str3;
        String str4;
        String str5 = null;
        int i2 = 0;
        while (true) {
            i = -3;
            try {
                a2 = c.a(this.f8851b.b(), str5, i2);
            } catch (Exception e) {
                e = e;
                str = this.f8850a;
                str2 = "synthesize online: assemble http json object failed";
            }
            try {
                String a3 = c.a(a2, this.f8851b.g(), this.f8851b.h());
                try {
                    httpURLConnection = (HttpURLConnection) new URL("https://aiwx.html5.qq.com/api/tts").openConnection();
                    a(httpURLConnection, a3);
                    try {
                        a(httpURLConnection, a2, a3);
                    } catch (Exception e2) {
                        e = e2;
                        str3 = this.f8850a;
                        str4 = "synthesize online: set http body error";
                    }
                } catch (Exception e3) {
                    e3.printStackTrace();
                    Log.e(this.f8850a, "synthesize online: set http head error");
                }
                try {
                    if (httpURLConnection.getResponseCode() != 200) {
                        break;
                    }
                    JSONObject jSONObject = new JSONObject(a(httpURLConnection));
                    str5 = jSONObject.getJSONObject("header").getJSONObject("session").getString("session_id");
                    JSONObject jSONObject2 = jSONObject.getJSONObject("payload");
                    String string = jSONObject2.getString("speech_base64");
                    boolean z = jSONObject2.getBoolean("speech_finished");
                    a(this.f8851b, this.f8852c, Base64.decode(string, 0), this.f8853d, i2 == 0, z);
                    if (z) {
                        i = 0;
                        break;
                    }
                    i2++;
                } catch (Exception e4) {
                    e = e4;
                    str3 = this.f8850a;
                    str4 = "synthesize online: parse http response error";
                    Log.e(str3, str4);
                    e.printStackTrace();
                    i = -6;
                    return Integer.valueOf(i);
                }
            } catch (Exception e5) {
                e = e5;
                str = this.f8850a;
                str2 = "synthesize online: sign http data error";
                Log.e(str, str2);
                e.printStackTrace();
                return Integer.valueOf(i);
            }
        }
        return Integer.valueOf(i);
    }

    public void a(d dVar) {
        this.f8851b = dVar;
    }

    public void a(com.tencent.btts.engine.d dVar) {
        this.f8852c = dVar;
    }

    public void a(Object obj) {
        this.f8853d = (com.tencent.btts.engine.c) obj;
    }
}