360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0
以下内容为反编译后的 ao.java 源代码,内容仅作参考
package com.qihoo.d.a;
import com.qihoo.speedometer.Config;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class ao {
private static int f4223a = 0;
private static int f4224b = 1;
private int A;
private int B;
private int C;
private int D;
private long E;
private String F;
private long G;
private boolean H;
private long I;
private boolean c;
private int e;
private int o;
private String p;
private String q;
private String r;
private String s;
private boolean t;
private String u;
private int v;
private boolean w;
private int x;
private String y;
private m i = new m();
private Map j = new HashMap();
private Map k = new HashMap();
private Map l = new HashMap();
private com.qihoo.d.b.d m = am.h();
private bd n = am.a();
private com.qihoo.d.b.s d = new com.qihoo.d.b.s();
private long g = 0;
private int h = 1;
private long z = 0;
private int f = 0;
public ao() {
this.i.a(2, 5);
this.o = 3;
this.p = null;
this.q = null;
this.r = null;
this.c = true;
this.t = false;
this.u = null;
this.v = 80;
this.x = 80;
this.y = null;
this.w = false;
this.D = 0;
this.E = 0L;
this.F = Config.INVALID_IP;
this.H = false;
this.I = 0L;
this.A = 0;
this.B = 0;
this.C = 0;
}
private void a(int i, af afVar) {
this.k.put(Integer.valueOf(i), afVar);
}
private void a(int i, an anVar) {
this.j.put(Integer.valueOf(i), anVar);
}
private boolean a(h hVar, String str, String str2, int i, int[] iArr) {
if (hVar == null) {
return false;
}
iArr[0] = hVar.g();
int h = hVar.h();
if (iArr[0] == 500) {
this.i.a(iArr[0], 10, this.o);
this.i.a(str, iArr[0]);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " HttpCode=" + iArr[0] + " ip=" + str + " 尝试10次后剔除此IP!");
}
} else if (iArr[0] >= 400 && iArr[0] < 500 && iArr[0] != 408) {
if (h == 0) {
this.i.a(str);
} else {
this.i.a(iArr[0], 10, 1);
this.i.a(str, iArr[0]);
}
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " HttpCode=" + iArr[0] + " RedirectDepth:" + h + " ip=" + str + " 剔除此IP!");
}
} else if (iArr[0] > 500) {
this.i.a(iArr[0], 3, this.o);
this.i.a(str, iArr[0]);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " HttpCode=" + iArr[0] + " ip=" + str + " 降低此IP的连接频率!");
}
}
return true;
}
private boolean c(int i, int i2) {
an g = g(i);
if (g == null) {
return false;
}
long f = g.p.f();
if (this.g == 0) {
this.g = f;
} else if (f != this.g) {
this.i.a(g.g);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " Http200 FileLen is invalid! FileLen:[" + f + "][" + this.g + "]");
}
i(i);
return false;
}
if (g.i <= 0 || g.n) {
return true;
}
if (com.qihoo.d.b.a.f == 1 || com.qihoo.d.b.a.f == 2) {
this.i.a(g.g);
}
this.c = false;
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " not support range");
}
this.h = 1;
i(i);
return false;
}
private boolean d(int i, int i2) {
an g = g(i);
if (g == null) {
return false;
}
long f = g.p.f();
if (this.g == 0) {
this.g = f;
} else if (f != this.g) {
this.i.a(g.g);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " ProcHttp206 FileLen not same!");
}
i(i);
return false;
}
return true;
}
private an e(long j) {
for (Map.Entry entry : this.j.entrySet()) {
an anVar = (an) entry.getValue();
if (anVar != null && j - anVar.c > 30000) {
if (!com.qihoo.d.b.a.c) {
return anVar;
}
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + entry.getKey() + " HttpMgr PickTimeoutHttp!");
return anVar;
}
}
return null;
}
private boolean e(int i, int i2) {
return true;
}
private boolean f(int i, int i2) {
i(i);
return false;
}
private an g(int i) {
return (an) this.j.get(Integer.valueOf(i));
}
private boolean g(int i, int i2) {
an g = g(i);
if (g != null) {
this.i.a(g.g);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " ProcHttpUnKnowncode");
}
}
i(i);
return false;
}
private af h(int i) {
return (af) this.k.get(Integer.valueOf(i));
}
private void h(int i, int i2) {
af h = h(i);
if (h != null && i2 != 0) {
try {
h.k.d();
h.k.e();
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " HttpMgr DeleteConnect!");
}
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] cid:" + i + " HttpMgr DeleteConnect throw a exception!" + stringWriter.toString());
}
}
this.m.b(h.f4206a);
}
this.k.remove(Integer.valueOf(i));
}
private void i(int i) {
an g = g(i);
if (g != null) {
try {
g.p.d();
g.p.e();
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " HttpMgr DeleteHttp ");
}
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] cid:" + i + " HttpMgr DeleteHttp throw a exception!" + stringWriter.toString());
}
}
this.m.b(g.f);
}
this.j.remove(Integer.valueOf(i));
}
private af r() {
Iterator it = this.k.entrySet().iterator();
while (it.hasNext()) {
af afVar = (af) ((Map.Entry) it.next()).getValue();
if (afVar != null && afVar.f4207b == f4224b) {
return afVar;
}
}
return null;
}
private void s() {
for (Map.Entry entry : this.j.entrySet()) {
an anVar = (an) entry.getValue();
if (anVar != null) {
try {
anVar.p.d();
anVar.p.e();
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + entry.getKey() + " HttpMgr DeleteAllHttp!");
}
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] DeleteAllHttp throw a exception!" + stringWriter.toString());
}
}
this.m.b(anVar.f);
}
}
this.j.clear();
}
private void t() {
for (Map.Entry entry : this.k.entrySet()) {
af afVar = (af) entry.getValue();
if (afVar != null) {
try {
afVar.k.d();
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + entry.getKey() + " HttpMgr DeleteAllConnect!");
}
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] DeleteAllConnect throw a exception!" + stringWriter.toString());
}
}
this.m.b(afVar.f4206a);
afVar.k.e();
}
}
this.k.clear();
}
private boolean u() {
try {
this.i.b(3, 3);
if (this.t) {
this.i.a("http://" + this.u, this.h, 0, this.e, null, false);
} else {
this.i.a(this.s, this.h, 0, this.e, "http://agd.p.360.cn", false);
}
return true;
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] AsyncStartHttpMgr throw a exception!" + stringWriter.toString());
}
this.f = 509;
return false;
}
}
public int a(long j) {
try {
this.i.a();
if (j - this.G > 5000) {
q();
}
if (this.g == 0 && this.D < 3 && this.E != 0) {
if (this.D > 0) {
}
if (j - this.E > 10000) {
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] delete http!");
}
this.D++;
this.E = j;
s();
}
}
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] HttpMgr OnTime throw a exception!" + stringWriter.toString());
}
}
return this.h;
}
public int a(af afVar, long j, long j2) {
if (afVar == null) {
this.f = 541;
return this.f;
}
an anVar = new an();
try {
long currentTimeMillis = System.currentTimeMillis();
if (this.E == 0) {
this.E = currentTimeMillis;
}
afVar.k.a(j, j2, false);
anVar.i = j;
anVar.j = j2;
anVar.k = j;
anVar.p = afVar.k;
anVar.f = afVar.f4206a;
anVar.g = afVar.c;
anVar.h = afVar.d;
anVar.o = afVar.l;
anVar.e = afVar.g;
anVar.d = afVar.f;
anVar.f4222b = currentTimeMillis;
anVar.c = currentTimeMillis;
anVar.l = afVar.h;
anVar.m = afVar.i;
anVar.n = afVar.j;
anVar.f4221a = new com.qihoo.d.b.s();
a(anVar.f, anVar);
h(afVar.f4206a, 0);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + afVar.f4206a + " StartDownload startpos=" + j + " EndPos=" + j2);
}
return 0;
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] AsyncStartDownload throw a excception!" + stringWriter.toString());
}
this.f = 509;
return this.f;
}
}
public int a(an anVar) {
if (anVar == null) {
this.f = 541;
return this.f;
}
int i = anVar.f;
h(i, 1);
i(i);
return 0;
}
public void a(String str, String str2, String[] strArr) {
if (str.equals("agent")) {
this.r = str2;
return;
}
if (str.equals("cookie")) {
this.q = str2;
return;
}
if (str.equals("refer")) {
this.p = str2;
return;
}
if (str.equals("proxy_server")) {
this.u = str2;
this.t = true;
return;
}
if (str.equals("proxy_port")) {
this.v = Integer.parseInt(str2);
return;
}
if (str.equals("ip")) {
if (strArr != null) {
this.l.put(str2, strArr);
}
} else if (str.equals("maxconnect")) {
if (com.qihoo.d.b.a.y == 2 || com.qihoo.d.b.a.d <= 10) {
this.h = 1;
return;
}
this.h = Integer.parseInt(str2);
if (this.h <= 0) {
this.h = 1;
} else if (this.h > 5) {
this.h = 5;
}
}
}
public boolean a() {
return true;
}
public boolean a(int i) {
this.e = i;
return true;
}
public boolean a(int i, int i2) {
switch (i2) {
case Config.HTTP_STATUS_OK:
return c(i, i2);
case 206:
return d(i, i2);
case 301:
case 302:
case 307:
if (g(i) != null) {
}
return e(i, i2);
case 401:
case 407:
return f(i, i2);
default:
return g(i, i2);
}
}
public boolean a(int i, int i2, int[] iArr, int[] iArr2, String[] strArr) {
h hVar;
String str;
an g = g(i);
if (g == null) {
af h = h(i);
if (h != null) {
strArr[0] = h.c;
hVar = h.k;
str = h.l;
}
return true;
}
strArr[0] = g.g;
hVar = g.p;
str = g.o;
int l = hVar.l();
switch (i2) {
case 20102:
this.f = 508;
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " Reason=" + i2 + " APIErr=" + l + " ip=" + strArr[0]);
break;
}
break;
case 20201:
this.f = 544;
this.i.a(20201, 65535, this.o);
this.i.a(strArr[0], 20201);
break;
case 20302:
this.i.a(20302, 9, this.o);
this.i.a(strArr[0], 20302);
break;
case 20303:
this.i.a(20303, 9, this.o);
this.i.a(strArr[0], 20303);
break;
case 20501:
case 20503:
case 20505:
case 20506:
this.i.a(strArr[0]);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " Reason=" + i2 + " APIErr=" + l + " blockip=" + strArr[0]);
break;
}
break;
case 20502:
a(hVar, strArr[0], str, i, iArr2);
break;
}
h(i, 1);
i(i);
return true;
}
public boolean a(int i, long j, int i2, byte[] bArr) {
an anVar = (an) this.j.get(Integer.valueOf(i));
if (anVar == null) {
return false;
}
if (this.g != anVar.p.f()) {
return false;
}
anVar.c = System.currentTimeMillis();
this.G = anVar.c;
this.d.a(i2, true, anVar.c);
anVar.f4221a.a(i2, true, anVar.c);
anVar.k += i2;
this.i.b(anVar.g, i2);
if (this.F.length() == 0) {
this.F = anVar.p.k();
}
if (anVar.m) {
this.t = true;
this.u = this.y;
this.v = this.x;
} else if (!this.t) {
}
if ((this.A == 1 || this.A == 2) && !anVar.n) {
this.A = 0;
}
if (this.A == 2 && anVar.n && this.C > 0) {
this.A = 1;
}
return true;
}
public boolean a(int i, String[] strArr) {
af h = h(i);
if (h == null) {
return false;
}
strArr[0] = h.c;
return true;
}
public boolean a(String str, long j) {
if (this.n.b()) {
this.A = 0;
}
this.s = str;
this.g = j;
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] AsyncStartHttpMgr ConnectNum:" + this.h);
}
return u();
}
public boolean a(String str, String[] strArr, int i) {
if (this.i.a(str, strArr, i)) {
if (i == 0) {
this.f = 542;
}
return i > 0;
}
this.f = this.i.b();
if (this.f != 208) {
return false;
}
this.f = 511;
return false;
}
public boolean a(int[] iArr) {
if (this.k.size() + this.j.size() < this.h) {
iArr[0] = (this.h - this.k.size()) - this.j.size();
return true;
}
if (this.k.size() > 1) {
return false;
}
iArr[0] = 1;
return true;
}
public void b(int i) {
this.A = i;
}
public void b(long j) {
this.g = j;
}
public boolean b() {
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] SyncStopHttpMgr");
}
t();
s();
this.i = null;
this.i = new m();
return false;
}
public boolean b(int i, int i2) {
return false;
}
public boolean b(int[] iArr) {
if (this.j.size() >= this.h) {
return false;
}
if (this.g != 0) {
iArr[0] = this.h - this.j.size();
return true;
}
if (this.j.size() == 0) {
iArr[0] = 1;
return true;
}
iArr[0] = 0;
return false;
}
public int c(int i) {
h hVar;
an g = g(i);
if (g == null) {
af h = h(i);
if (h == null) {
return 0;
}
hVar = h.k;
} else {
hVar = g.p;
}
return hVar.l();
}
public int c(long j) {
return this.d.b(5, j);
}
public int c(int[] iArr) {
r rVar;
boolean a2;
boolean z;
boolean z2;
af afVar = new af();
h hVar = new h();
iArr[0] = this.m.a(2);
try {
rVar = new r();
} catch (Exception e) {
if (com.qihoo.d.b.a.c) {
StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
com.qihoo.d.b.p.a("TaskID:[" + this.e + "] cid:" + iArr[0] + " AsyncStartConnect throw a exception!" + stringWriter.toString());
}
}
if (this.A == 1 ? true : this.A == 2 ? this.B == 0 || this.C > 0 : false) {
a2 = this.i.a(p.HOST_POLICY_360NET, rVar, n.HOST_DL_PROXY);
if (a2) {
if (rVar.h.equals("http://agd.p.360.cn")) {
rVar.h = this.s;
afVar.j = true;
z = a2;
} else {
afVar.j = false;
z = a2;
}
if (!this.t) {
rVar.h = this.s;
afVar.i = false;
rVar.f4328a = this.u;
afVar.j = false;
z2 = true;
} else if (!this.n.b() || this.w) {
afVar.i = false;
z2 = false;
} else {
rVar.h = this.s;
this.w = true;
this.x = this.n.c();
this.y = this.n.d();
afVar.i = true;
rVar.f4328a = this.y;
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + iArr[0] + " TestProxySrv:" + this.y + " TestProxyPort" + this.x);
}
afVar.j = false;
z2 = true;
}
if (z && !z2) {
this.m.b(iArr[0]);
if (this.i.b() != 205) {
this.f = 542;
} else if (this.l.size() == 0) {
this.f = 504;
} else {
q();
this.f = 542;
}
return this.f;
}
if (this.A == 2) {
if (afVar.j) {
this.B++;
} else {
this.C++;
}
}
if (hVar.a(rVar.h, this.g, this.e, iArr[0], afVar.j)) {
this.m.b(iArr[0]);
this.f = 538;
return this.f;
}
if (this.t) {
hVar.a(0, 0, this.u, this.v, null, null);
} else if (afVar.i) {
hVar.a(0, 0, this.y, this.x, null, null);
} else {
hVar.a(0, 0, null, this.v, null, null);
}
if (this.p != null) {
hVar.b(this.p);
}
if (this.r != null) {
hVar.a(this.r);
}
if (this.q != null) {
hVar.c(this.q);
}
hVar.a(rVar.e > 0 ? 3500 * Math.min(rVar.e + 1, 7) : 3500, 0, 0);
hVar.d(rVar.f4328a);
afVar.d = 0;
afVar.l = rVar.h;
afVar.c = rVar.f4328a;
afVar.k = hVar;
afVar.f4206a = iArr[0];
afVar.f4207b = f4223a;
afVar.e = System.currentTimeMillis();
a(iArr[0], afVar);
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + iArr[0] + " StartConnect! TFW = " + afVar.j);
}
return 0;
}
} else {
a2 = this.i.a(p.HOST_POLICY_360NET, rVar, n.HOST_DL_HTTP);
afVar.j = false;
}
z = a2;
if (!this.t) {
}
if (z) {
}
if (this.A == 2) {
}
if (hVar.a(rVar.h, this.g, this.e, iArr[0], afVar.j)) {
}
}
public boolean c() {
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] RemoveHttpMgr");
}
t();
s();
return true;
}
public long d() {
return this.g;
}
public an d(long j) {
int i;
int i2;
int i3;
int i4;
an e = e(j);
if (e != null) {
return e;
}
if (this.h == 1 || this.j.size() < this.h) {
return null;
}
Iterator it = this.j.entrySet().iterator();
int i5 = 0;
int i6 = 0;
int i7 = -1;
while (it.hasNext()) {
an anVar = (an) ((Map.Entry) it.next()).getValue();
if (anVar != null) {
int b2 = anVar.f4221a.b(10, j);
if (i7 == -1) {
i6 = b2;
i = anVar.f;
i2 = b2;
} else {
int i8 = i5;
i = i7;
i2 = i8;
}
if (j - anVar.f4222b < 10000) {
return null;
}
if (i6 > b2) {
i3 = anVar.f;
i4 = b2;
} else {
int i9 = i6;
i3 = i;
i4 = i9;
}
int i10 = i2 < b2 ? b2 : i2;
i7 = i3;
i6 = i4;
i5 = i10;
}
}
if (i6 > 30720) {
return null;
}
if (i5 <= i6 * 2 || i5 - i6 <= 15360) {
return null;
}
return g(i7);
}
public String d(int i) {
h hVar;
an g = g(i);
if (g == null) {
af h = h(i);
if (h == null) {
return new String();
}
hVar = h.k;
} else {
hVar = g.p;
}
return hVar.j();
}
public int e() {
return this.A;
}
public boolean e(int i) {
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] cid:" + i + " OnNotifyHttpConnect ");
}
af h = h(i);
if (h == null) {
return false;
}
h.f4207b = f4224b;
return true;
}
public int f() {
return this.f;
}
public boolean f(int i) {
h(i, 1);
i(i);
return true;
}
public boolean g() {
return this.t;
}
public String h() {
return this.u;
}
public int i() {
return this.v;
}
public boolean j() {
return this.c;
}
public af k() {
return r();
}
public long l() {
long j = 0;
int i = this.j.size() <= 1 ? 0 : 1;
Iterator it = this.j.entrySet().iterator();
while (true) {
int i2 = i;
if (!it.hasNext()) {
this.I += j;
return this.I;
}
an anVar = (an) ((Map.Entry) it.next()).getValue();
if (anVar != null) {
long a2 = anVar.f4221a.a();
if (i2 > 0) {
j += a2;
i2--;
}
}
i = i2;
j = j;
}
}
public int m() {
return this.j.size();
}
public int n() {
return this.k.size();
}
public String o() {
return this.F;
}
public boolean p() {
return this.H;
}
public boolean q() {
for (Map.Entry entry : this.l.entrySet()) {
String str = (String) entry.getKey();
String[] strArr = (String[]) entry.getValue();
this.i.a(str, strArr, strArr.length);
for (String str2 : strArr) {
if (com.qihoo.d.b.a.c) {
com.qihoo.d.b.p.b("TaskID:[" + this.e + "] url:" + str + " ip:" + str2 + " AddIPToHost!");
}
}
this.H = true;
}
this.l.clear();
return true;
}
}