酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.d.a.a.e;
import android.content.Context;
import android.net.Network;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.d.a.a.c.a.c;
import com.d.a.a.e.s;
import com.d.a.a.e.x;
import com.kugou.modulesv.svedit.backgroundmusic.cutmusic.entity.SvRecordTimeLimit;
import com.sina.weibo.sdk.statistic.LogBuilder;
import com.tencent.connect.common.Constants;
import com.wandoujia.upgradesdk.model.LocalAppsInfo;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.cert.CertPathValidatorException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import org.apache.commons.codec.net.StringEncodings;
import org.apache.http.entity.mime.MIME;
import org.json.JSONException;
import org.json.JSONObject;
import tmsdk.common.gourd.vine.IActionReportService;
public class d {
private String f1919a;
private String f1920b = "";
private int f1921c = 1;
private String f1922d = null;
public interface a {
void a(String str, String str2);
void a(String str, String str2, String str3);
}
public <T extends com.d.a.a.c.a.d> void a(String str, T t, boolean z, a aVar, String str2, String str3, Bundle bundle) {
this.f1919a = str3;
if (!h.a(str3) || str.contains("logReport") || str.contains("uniConfig")) {
f.c("HttpUtils", "使用wifi下取号???????" + z);
if (z) {
a(str, t, aVar, str2, bundle);
return;
}
if (str.contains("getPrePhonescrip")) {
a((com.d.a.a.c.a.c) t, bundle);
}
a(str, t.b().toString(), aVar, null, str2, bundle);
}
}
public void a(com.d.a.a.c.a.c cVar, Bundle bundle) {
String a2 = v.a();
String b2 = v.b();
bundle.putString("ipv4List", a2);
bundle.putString("ipv6List", b2);
c.a c2 = cVar.c();
if (!bundle.getBoolean("isCloseIpv4", false)) {
c2.a(a2);
}
if (!bundle.getBoolean("isCloseIpv6", true)) {
c2.b(b2);
}
c2.v(c2.w(bundle.getString(LogBuilder.KEY_APPKEY)));
cVar.a(c2);
}
public void a(String str, String str2, a aVar, Network network, String str3, Bundle bundle) {
HttpsURLConnection httpsURLConnection;
if (h.a(this.f1919a) && !str.contains("logReport") && !str.contains("uniConfig")) {
return;
}
try {
f.c("HttpUtils", "try " + this.f1921c + " http reqeust, url: " + str);
URL url = new URL(str);
httpsURLConnection = 21;
try {
if (Build.VERSION.SDK_INT >= 21 && network != null) {
HttpURLConnection httpURLConnection = (HttpURLConnection) network.openConnection(url);
f.c("HttpUtils", "is network null?不为空");
httpsURLConnection = httpURLConnection;
} else {
HttpURLConnection httpURLConnection2 = (HttpURLConnection) url.openConnection();
f.c("HttpUtils", "is network null?为空");
httpsURLConnection = httpURLConnection2;
}
if (str.startsWith("https")) {
a(httpsURLConnection, bundle, str);
}
httpsURLConnection.setConnectTimeout(SvRecordTimeLimit.MIN_LIMIT);
httpsURLConnection.setReadTimeout(SvRecordTimeLimit.MIN_LIMIT);
httpsURLConnection.addRequestProperty("traceId", this.f1919a);
if (bundle != null) {
httpsURLConnection.addRequestProperty("appid", bundle.getString("appid", ""));
httpsURLConnection.addRequestProperty("interfaceVersion", bundle.getString("interfaceVersion", ""));
}
httpsURLConnection.addRequestProperty(LocalAppsInfo.KEY_SDK_VERSION, "quick_login_android_9.0.7.1");
httpsURLConnection.setUseCaches(false);
httpsURLConnection.setRequestProperty(MIME.CONTENT_TYPE, "application/json");
if (str.contains("preGetMobile")) {
httpsURLConnection.setRequestProperty(MIME.CONTENT_TYPE, "application/x-www-form-urlencoded ");
}
if (str.contains("getPrePhonescrip")) {
httpsURLConnection.setRequestProperty("defendEOF", "1");
}
httpsURLConnection.setRequestProperty("Charset", StringEncodings.UTF8);
httpsURLConnection.setDoInput(true);
httpsURLConnection.setInstanceFollowRedirects(false);
} catch (Exception e2) {
e = e2;
}
} catch (Exception e3) {
e = e3;
httpsURLConnection = 0;
}
try {
if (str3.equals(Constants.HTTP_POST)) {
httpsURLConnection.setRequestMethod(Constants.HTTP_POST);
httpsURLConnection.setDoOutput(true);
DataOutputStream dataOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
byte[] bytes = str2.getBytes(StringEncodings.UTF8);
dataOutputStream.write(bytes, 0, bytes.length);
dataOutputStream.flush();
dataOutputStream.close();
} else if (str3.equals(Constants.HTTP_GET)) {
httpsURLConnection.setRequestMethod(Constants.HTTP_GET);
}
int responseCode = httpsURLConnection.getResponseCode();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
StringBuilder sb = new StringBuilder("");
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
sb.append(new String(readLine.getBytes(), "utf-8"));
} else {
bufferedReader.close();
String sb2 = sb.toString();
httpsURLConnection.disconnect();
a(sb2, responseCode, aVar, httpsURLConnection, network, str2, str, str3, bundle);
return;
}
}
} catch (Exception e4) {
e = e4;
if ((e instanceof SSLHandshakeException) || (e instanceof CertPathValidatorException)) {
bundle.putBoolean("isNeedToGetCert", true);
}
e.printStackTrace();
if (httpsURLConnection != 0) {
httpsURLConnection.disconnect();
}
com.d.a.a.d.a.f1900a.add(e);
if (e instanceof EOFException) {
a(null, Integer.valueOf("200050").intValue(), aVar, null, network, str2, str, str3, bundle);
} else {
a(null, -1, aVar, null, network, str2, str, str3, bundle);
}
}
}
private static void a(HttpsURLConnection httpsURLConnection, Bundle bundle, String str) throws Exception {
if (bundle.getBoolean("CLOSE_CERT_VERIFY", true) || str.contains("https://config.cmpassport.com/client/uniConfig")) {
return;
}
httpsURLConnection.setSSLSocketFactory(new com.d.a.a.c.c.a().a().getSocketFactory());
}
private <T extends com.d.a.a.c.a.d> void a(final String str, final T t, final a aVar, final String str2, final Bundle bundle) {
f.b("HttpUtils", "in wifiNetwork");
x a2 = x.a((Context) null);
if (Build.VERSION.SDK_INT >= 21) {
a2.a(new x.a() {
private AtomicBoolean g = new AtomicBoolean(false);
@Override
public void a(final Network network) {
if (this.g.getAndSet(true)) {
return;
}
s.a(new s.a(null, bundle) {
@Override
protected void a() {
if (network != null) {
f.b("HttpUtils", "onAvailable");
d.this.f1920b = t.a();
if (str.contains("getPrePhonescrip")) {
d.this.a((com.d.a.a.c.a.c) t, bundle);
}
d.this.a(str, t.b().toString(), aVar, network, str2, bundle);
}
}
});
}
});
return;
}
x.f1958a.startUsingNetworkFeature(0, "enableHIPRI");
for (int i = 0; i < 30; i++) {
try {
if (x.f1958a.getNetworkInfo(5).getState().compareTo(NetworkInfo.State.CONNECTED) == 0) {
break;
}
Thread.sleep(1000L);
} catch (InterruptedException e2) {
com.d.a.a.d.a.f1900a.add(e2);
f.a("HttpUtils", "check hipri failed");
}
}
boolean requestRouteToHost = x.f1958a.requestRouteToHost(5, x.a(x.b(str)));
f.a("HttpUtils", "切换数据网络结果 >>> " + requestRouteToHost);
x.a((Context) null).a(requestRouteToHost);
if (requestRouteToHost) {
f.a("HttpUtils", "切换网络成功");
this.f1920b = t.a();
if (str.contains("getPrePhonescrip")) {
a((com.d.a.a.c.a.c) t, bundle);
}
a(str, t.b().toString(), aVar, null, str2, bundle);
return;
}
f.a("HttpUtils", "切换网络失败or无数据网络");
aVar.a("102508", "数据网络切换失败", this.f1920b);
}
private void a(String str, int i, a aVar, HttpURLConnection httpURLConnection, Network network, String str2, String str3, String str4, Bundle bundle) {
String str5 = str;
try {
if (i == 302 || i == 301) {
if (TextUtils.isEmpty(bundle.getString("interfaceCode", ""))) {
bundle.putString("interfaceCode", String.valueOf(i));
} else {
bundle.putString("interfaceCode", bundle.getString("interfaceCode") + IActionReportService.COMMON_SEPARATOR + String.valueOf(i));
}
String headerField = httpURLConnection.getHeaderField("Location");
if (this.f1922d == null) {
this.f1922d = httpURLConnection.getHeaderField("pplocation");
}
if (!TextUtils.isEmpty(headerField)) {
if (TextUtils.isEmpty(bundle.getString("interfaceType", ""))) {
if ("2".equals(bundle.getString("operatortype", "0"))) {
bundle.putString("interfaceType", "getUnicomMobile");
} else {
bundle.putString("interfaceType", "getTelecomMobile");
}
} else if ("2".equals(bundle.getString("operatortype", "0"))) {
bundle.putString("interfaceType", bundle.getString("interfaceType") + ";getUnicomMobile");
} else {
bundle.putString("interfaceType", bundle.getString("interfaceType") + ";getTelecomMobile");
}
a(headerField, "", aVar, network, Constants.HTTP_GET, bundle);
return;
}
aVar.a("200038", "电信重定向失败", this.f1920b);
return;
}
try {
if (i != 200) {
f.a("HttpUtils", "http response code is not 200 ---" + i);
this.f1921c = this.f1921c + 1;
if (this.f1921c > 3 || (h.a(this.f1919a) && !str3.contains("logReport"))) {
if (i == 0) {
aVar.a(i + "", "请求出错", this.f1920b);
return;
}
if (i == Integer.valueOf("200050").intValue()) {
aVar.a("200050", "EOF异常", this.f1920b);
return;
}
if (i == Integer.valueOf("102507").intValue()) {
aVar.a(i + "", str5, this.f1920b);
return;
}
aVar.a("102102", TextUtils.isEmpty(str) ? "网络异常" : str5, this.f1920b);
return;
}
a(str3, str2, aVar, network, str4, bundle);
return;
}
if (!TextUtils.isEmpty(this.f1922d)) {
try {
f.b("HttpUtils", "电信取号结果 = " + str5);
JSONObject jSONObject = new JSONObject(str5);
String optString = jSONObject.optString("result", "0");
if (TextUtils.isEmpty(bundle.getString("interfaceCode", ""))) {
bundle.putString("interfaceCode", optString);
} else {
StringBuilder sb = new StringBuilder();
try {
sb.append(bundle.getString("interfaceCode"));
sb.append(IActionReportService.COMMON_SEPARATOR);
sb.append(optString);
bundle.putString("interfaceCode", sb.toString());
} catch (JSONException e2) {
e = e2;
com.d.a.a.d.a.f1900a.add(e);
aVar.a("200039", "电信取号接口失败", this.f1920b);
return;
}
}
if ("0".equals(optString)) {
f.c("HttpUtils", "pplocation" + this.f1922d);
String str6 = "http://www.cmpassport.com/unisdk/" + this.f1922d + "&data=" + jSONObject.getString("data");
if (TextUtils.isEmpty(bundle.getString("interfaceType", ""))) {
bundle.putString("interfaceType", "getNewTelecomPhoneNumberNotify");
} else {
bundle.putString("interfaceType", bundle.getString("interfaceType") + ";getNewTelecomPhoneNumberNotify");
}
this.f1922d = null;
f.c("HttpUtils", "location" + str6);
a(str6, "", aVar, network, Constants.HTTP_GET, bundle);
return;
}
aVar.a("200039" + optString, jSONObject.optString("msg"), this.f1920b);
} catch (JSONException e3) {
e = e3;
}
} else {
aVar.a(str5, this.f1920b);
}
} catch (Exception e4) {
e = e4;
com.d.a.a.d.a.f1900a.add(e);
if (TextUtils.isEmpty(str)) {
str5 = "网络异常";
}
aVar.a("102102", str5, this.f1920b);
}
} catch (Exception e5) {
e = e5;
}
}
}