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

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


package com.tencent.mtt.hippy.devsupport;

import com.tencent.mtt.hippy.HippyGlobalConfigs;
import com.tencent.mtt.hippy.adapter.http.HippyHttpAdapter;
import com.tencent.mtt.hippy.adapter.http.HippyHttpRequest;
import com.tencent.mtt.hippy.adapter.http.HippyHttpResponse;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;

public class DevServerHelper {

    private final HippyGlobalConfigs f66479a;

    private final String f66480b;

    public DevServerHelper(HippyGlobalConfigs hippyGlobalConfigs, String str) {
        this.f66479a = hippyGlobalConfigs;
        this.f66480b = str;
    }

    public String a() {
        return String.format(Locale.US, "ws://%s/debugger-live-reload", this.f66480b.split(Constants.COLON_SEPARATOR)[0] + ":38999");
    }

    public String a(String str, String str2, boolean z, boolean z2, boolean z3) {
        return String.format(Locale.US, "http://%s/%s?platform=android&dev=%s&hot=%s&minify=%s", str, str2, Boolean.valueOf(z), Boolean.valueOf(z2), Boolean.valueOf(z3));
    }

    public void a(final BundleFetchCallBack bundleFetchCallBack, final String str) {
        HippyHttpRequest hippyHttpRequest = new HippyHttpRequest();
        hippyHttpRequest.setUrl(str);
        this.f66479a.getHttpAdapter().sendRequest(hippyHttpRequest, new HippyHttpAdapter.HttpTaskCallback() {
            @Override
            public void onTaskFailed(HippyHttpRequest hippyHttpRequest2, Throwable th) {
                BundleFetchCallBack bundleFetchCallBack2 = bundleFetchCallBack;
                if (bundleFetchCallBack2 != null) {
                    bundleFetchCallBack2.a(new DevServerException("Could not connect to development server.URL: " + str + "  try to :adb reverse tcp:38989 tcp:38989 , message : " + th.getMessage()));
                }
            }

            @Override
            public void onTaskSuccess(HippyHttpRequest hippyHttpRequest2, HippyHttpResponse hippyHttpResponse) throws Exception {
                String str2;
                if (bundleFetchCallBack == null) {
                    return;
                }
                if (hippyHttpResponse.getStatusCode().intValue() == 200 && hippyHttpResponse.getInputStream() != null) {
                    bundleFetchCallBack.a(hippyHttpResponse.getInputStream());
                    return;
                }
                if (hippyHttpResponse.getErrorStream() != null) {
                    StringBuilder sb = new StringBuilder();
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(hippyHttpResponse.getErrorStream(), "UTF-8"));
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        sb.append(readLine);
                        sb.append("\r\n");
                    }
                    str2 = sb.toString();
                } else {
                    str2 = "unknown";
                }
                bundleFetchCallBack.a(new DevServerException("Could not connect to development server.URL: " + str + "  try to :adb reverse tcp:38989 tcp:38989 , message : " + str2));
            }
        });
    }
}