百度手机卫士 v8.8.0版本的 MD5 值为:a85894a6923c8a39f0c3a3a686ad7443
以下内容为反编译后的 op.java 源代码,内容仅作参考
package dxoptimizer;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.alipay.android.phone.mrpc.core.HttpException;
import com.alipay.android.phone.mrpc.core.HttpUrlHeader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
public final class op implements Callable<ot> {
private static final HttpRequestRetryHandler e = new nw();
protected ok a;
protected Context b;
protected on c;
String d;
private HttpUriRequest f;
private CookieManager i;
private AbstractHttpEntity j;
private HttpHost k;
private URL l;
private String q;
private HttpContext g = new BasicHttpContext();
private CookieStore h = new BasicCookieStore();
private int m = 0;
private boolean n = false;
private boolean o = false;
private String p = null;
public op(ok okVar, on onVar) {
this.a = okVar;
this.b = this.a.a;
this.c = onVar;
}
private static long a(String[] strArr) {
for (int i = 0; i < strArr.length; i++) {
if ("max-age".equalsIgnoreCase(strArr[i]) && strArr[i + 1] != null) {
try {
return Long.parseLong(strArr[i + 1]);
} catch (Exception e2) {
}
}
}
return 0L;
}
private static HttpUrlHeader a(HttpResponse httpResponse) {
HttpUrlHeader httpUrlHeader = new HttpUrlHeader();
for (Header header : httpResponse.getAllHeaders()) {
httpUrlHeader.setHead(header.getName(), header.getValue());
}
return httpUrlHeader;
}
private ot a(HttpResponse httpResponse, int i, String str) {
ByteArrayOutputStream byteArrayOutputStream;
Throwable th;
ByteArrayOutputStream byteArrayOutputStream2;
String str2;
String str3 = null;
new StringBuilder("开始handle,handleResponse-1,").append(Thread.currentThread().getId());
HttpEntity entity = httpResponse.getEntity();
if (entity == null || httpResponse.getStatusLine().getStatusCode() != 200) {
if (entity != null) {
return null;
}
httpResponse.getStatusLine().getStatusCode();
return null;
}
new StringBuilder("200,开始处理,handleResponse-2,threadid = ").append(Thread.currentThread().getId());
try {
byteArrayOutputStream2 = new ByteArrayOutputStream();
} catch (Throwable th2) {
byteArrayOutputStream = null;
th = th2;
}
try {
long currentTimeMillis = System.currentTimeMillis();
a(entity, byteArrayOutputStream2);
byte[] byteArray = byteArrayOutputStream2.toByteArray();
this.o = false;
this.a.c(System.currentTimeMillis() - currentTimeMillis);
this.a.a(byteArray.length);
new StringBuilder("res:").append(byteArray.length);
oo ooVar = new oo(a(httpResponse), i, str, byteArray);
long b = b(httpResponse);
Header contentType = httpResponse.getEntity().getContentType();
if (contentType != null) {
HashMap<String, String> a = a(contentType.getValue());
str3 = a.get("charset");
str2 = a.get("Content-Type");
} else {
str2 = null;
}
ooVar.b(str2);
ooVar.a(str3);
ooVar.a(System.currentTimeMillis());
ooVar.b(b);
try {
byteArrayOutputStream2.close();
return ooVar;
} catch (IOException e2) {
throw new RuntimeException("ArrayOutputStream close error!", e2.getCause());
}
} catch (Throwable th3) {
th = th3;
byteArrayOutputStream = byteArrayOutputStream2;
if (byteArrayOutputStream == null) {
throw th;
}
try {
byteArrayOutputStream.close();
throw th;
} catch (IOException e3) {
throw new RuntimeException("ArrayOutputStream close error!", e3.getCause());
}
}
}
private static HashMap<String, String> a(String str) {
HashMap<String, String> hashMap = new HashMap<>();
for (String str2 : str.split(";")) {
String[] split = str2.indexOf(61) == -1 ? new String[]{"Content-Type", str2} : str2.split("=");
hashMap.put(split[0], split[1]);
}
return hashMap;
}
private void a(HttpEntity httpEntity, OutputStream outputStream) {
InputStream a = nx.a(httpEntity);
long contentLength = httpEntity.getContentLength();
try {
try {
byte[] bArr = new byte[2048];
while (true) {
int read = a.read(bArr);
if (read == -1 || this.c.h()) {
break;
}
outputStream.write(bArr, 0, read);
if (this.c.f() != null && contentLength > 0) {
this.c.f();
on onVar = this.c;
}
}
outputStream.flush();
} catch (Exception e2) {
e2.getCause();
throw new IOException("HttpWorker Request Error!" + e2.getLocalizedMessage());
}
} finally {
oq.a(a);
}
}
private static long b(HttpResponse httpResponse) {
Header firstHeader = httpResponse.getFirstHeader("Cache-Control");
if (firstHeader != null) {
String[] split = firstHeader.getValue().split("=");
if (split.length >= 2) {
try {
return a(split);
} catch (NumberFormatException e2) {
}
}
}
Header firstHeader2 = httpResponse.getFirstHeader("Expires");
if (firstHeader2 != null) {
return nx.b(firstHeader2.getValue()) - System.currentTimeMillis();
}
return 0L;
}
private URI b() {
String a = this.c.a();
if (this.d != null) {
a = this.d;
}
if (a == null) {
throw new RuntimeException("url should not be null");
}
return new URI(a);
}
private HttpUriRequest c() {
if (this.f != null) {
return this.f;
}
if (this.j == null) {
byte[] b = this.c.b();
String b2 = this.c.b("gzip");
if (b != null) {
if (TextUtils.equals(b2, "true")) {
this.j = nx.a(b);
} else {
this.j = new ByteArrayEntity(b);
}
this.j.setContentType(this.c.c());
}
}
AbstractHttpEntity abstractHttpEntity = this.j;
if (abstractHttpEntity != null) {
HttpPost httpPost = new HttpPost(b());
httpPost.setEntity(abstractHttpEntity);
this.f = httpPost;
} else {
this.f = new HttpGet(b());
}
return this.f;
}
@Override
public ot call() {
boolean z;
HttpHost httpHost;
HttpHost httpHost2;
List<Cookie> cookies;
int statusCode;
ot a;
long j;
String a2;
while (true) {
try {
try {
NetworkInfo[] allNetworkInfo = ((ConnectivityManager) this.b.getSystemService("connectivity")).getAllNetworkInfo();
if (allNetworkInfo != null) {
int length = allNetworkInfo.length;
int i = 0;
while (true) {
if (i >= length) {
z = false;
break;
}
NetworkInfo networkInfo = allNetworkInfo[i];
if (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnectedOrConnecting()) {
z = true;
break;
}
i++;
}
} else {
z = false;
}
if (!z) {
throw new HttpException(1, "The network is not available");
}
if (this.c.f() != null) {
this.c.f();
on onVar = this.c;
}
ArrayList<Header> d = this.c.d();
if (d != null && !d.isEmpty()) {
Iterator<Header> it = d.iterator();
while (it.hasNext()) {
c().addHeader(it.next());
}
}
nx.a((HttpRequest) c());
nx.b((HttpRequest) c());
c().addHeader("cookie", i().getCookie(this.c.a()));
this.g.setAttribute("http.cookie-store", this.h);
this.a.a().a(e);
long currentTimeMillis = System.currentTimeMillis();
new StringBuilder("By Http/Https to request. operationType=").append(f()).append(" url=").append(this.f.getURI().toString());
HttpParams params = this.a.a().getParams();
NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.b.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) {
String defaultHost = Proxy.getDefaultHost();
int defaultPort = Proxy.getDefaultPort();
if (defaultHost != null) {
httpHost = new HttpHost(defaultHost, defaultPort);
if (httpHost != null && TextUtils.equals(httpHost.getHostName(), "127.0.0.1") && httpHost.getPort() == 8087) {
httpHost = null;
}
params.setParameter("http.route.default-proxy", httpHost);
if (this.k == null) {
httpHost2 = this.k;
} else {
URL h = h();
this.k = new HttpHost(h.getHost(), g(), h.getProtocol());
httpHost2 = this.k;
}
if (g() == 80) {
httpHost2 = new HttpHost(h().getHost());
}
HttpResponse execute = this.a.a().execute(httpHost2, this.f, this.g);
this.a.b(System.currentTimeMillis() - currentTimeMillis);
cookies = this.h.getCookies();
if (this.c.e()) {
i().removeAllCookie();
}
if (!cookies.isEmpty()) {
for (Cookie cookie : cookies) {
if (cookie.getDomain() != null) {
i().setCookie(this.c.a(), cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + (cookie.isSecure() ? "; Secure" : ""));
CookieSyncManager.getInstance().sync();
}
}
}
on onVar2 = this.c;
statusCode = execute.getStatusLine().getStatusCode();
String reasonPhrase = execute.getStatusLine().getReasonPhrase();
if (statusCode != 200) {
if (!(statusCode == 304)) {
throw new HttpException(Integer.valueOf(execute.getStatusLine().getStatusCode()), execute.getStatusLine().getReasonPhrase());
}
}
a = a(execute, statusCode, reasonPhrase);
j = -1;
if (a != null && a.b() != null) {
j = a.b().length;
}
if (j == -1 && (a instanceof oo)) {
try {
Long.parseLong(((oo) a).a().getHead("Content-Length"));
} catch (Exception e2) {
}
}
a2 = this.c.a();
if (a2 != null && !TextUtils.isEmpty(f())) {
new StringBuilder().append(a2).append("#").append(f());
}
return a;
}
}
httpHost = null;
if (httpHost != null) {
httpHost = null;
}
params.setParameter("http.route.default-proxy", httpHost);
if (this.k == null) {
}
if (g() == 80) {
}
HttpResponse execute2 = this.a.a().execute(httpHost2, this.f, this.g);
this.a.b(System.currentTimeMillis() - currentTimeMillis);
cookies = this.h.getCookies();
if (this.c.e()) {
}
if (!cookies.isEmpty()) {
}
on onVar22 = this.c;
statusCode = execute2.getStatusLine().getStatusCode();
String reasonPhrase2 = execute2.getStatusLine().getReasonPhrase();
if (statusCode != 200) {
}
a = a(execute2, statusCode, reasonPhrase2);
j = -1;
if (a != null) {
j = a.b().length;
}
if (j == -1) {
Long.parseLong(((oo) a).a().getHead("Content-Length"));
}
a2 = this.c.a();
if (a2 != null) {
new StringBuilder().append(a2).append("#").append(f());
}
return a;
} catch (Exception e3) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar3 = this.c;
new StringBuilder().append(e3);
}
throw new HttpException(0, String.valueOf(e3));
}
} catch (HttpException e4) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar4 = this.c;
e4.getCode();
e4.getMsg();
}
new StringBuilder().append(e4);
throw e4;
} catch (NullPointerException e5) {
e();
if (this.m > 0) {
new StringBuilder().append(e5);
throw new HttpException(0, String.valueOf(e5));
}
this.m++;
} catch (SocketTimeoutException e6) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar5 = this.c;
new StringBuilder().append(e6);
}
new StringBuilder().append(e6);
throw new HttpException(4, String.valueOf(e6));
} catch (URISyntaxException e7) {
throw new RuntimeException("Url parser error!", e7.getCause());
} catch (UnknownHostException e8) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar6 = this.c;
new StringBuilder().append(e8);
}
new StringBuilder().append(e8);
throw new HttpException(9, String.valueOf(e8));
} catch (SSLHandshakeException e9) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar7 = this.c;
new StringBuilder().append(e9);
}
new StringBuilder().append(e9);
throw new HttpException(2, String.valueOf(e9));
} catch (SSLPeerUnverifiedException e10) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar8 = this.c;
new StringBuilder().append(e10);
}
new StringBuilder().append(e10);
throw new HttpException(2, String.valueOf(e10));
} catch (SSLException e11) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar9 = this.c;
new StringBuilder().append(e11);
}
new StringBuilder().append(e11);
throw new HttpException(6, String.valueOf(e11));
} catch (NoHttpResponseException e12) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar10 = this.c;
new StringBuilder().append(e12);
}
new StringBuilder().append(e12);
throw new HttpException(5, String.valueOf(e12));
} catch (ConnectionPoolTimeoutException e13) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar11 = this.c;
new StringBuilder().append(e13);
}
new StringBuilder().append(e13);
throw new HttpException(3, String.valueOf(e13));
} catch (ConnectTimeoutException e14) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar12 = this.c;
new StringBuilder().append(e14);
}
new StringBuilder().append(e14);
throw new HttpException(3, String.valueOf(e14));
} catch (HttpHostConnectException e15) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar13 = this.c;
new StringBuilder().append(e15);
}
throw new HttpException(8, String.valueOf(e15));
} catch (IOException e16) {
e();
if (this.c.f() != null) {
this.c.f();
on onVar14 = this.c;
new StringBuilder().append(e16);
}
new StringBuilder().append(e16);
throw new HttpException(6, String.valueOf(e16));
}
}
}
private void e() {
if (this.f != null) {
this.f.abort();
}
}
private String f() {
if (!TextUtils.isEmpty(this.q)) {
return this.q;
}
this.q = this.c.b("operationType");
return this.q;
}
private int g() {
URL h = h();
return h.getPort() == -1 ? h.getDefaultPort() : h.getPort();
}
private URL h() {
if (this.l != null) {
return this.l;
}
this.l = new URL(this.c.a());
return this.l;
}
private CookieManager i() {
if (this.i != null) {
return this.i;
}
this.i = CookieManager.getInstance();
return this.i;
}
public final on a() {
return this.c;
}
}