换机精灵 v2.5.4版本的 MD5 值为:79a45ef9a3e238691e836db31e5f23f0
以下内容为反编译后的 r.java 源代码,内容仅作参考
package com.cx.launcher.cloud.d;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.cx.huanji.R;
import com.cx.huanji.h.be;
import com.umeng.socialize.net.utils.SocializeProtocolConstants;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class r {
private static r f3150c = null;
private static final String f = r.class.getSimpleName();
private Context f3151a;
private com.cx.launcher.cloud.h f3152b;
private com.cx.launcher.cloud.i d;
private com.cx.launcher.cloud.m e;
private List g;
private List h;
private com.cx.launcher.cloud.c j;
private com.cx.launcher.cloud.f k;
private com.cx.launcher.cloud.e l;
private com.cx.launcher.cloud.q m;
private boolean o = false;
private int p = 0;
private int q = 0;
private int r = 0;
private Handler s = new Handler(Looper.getMainLooper());
private w t = null;
private List u = new ArrayList();
private List v = new ArrayList();
private Map i = new HashMap();
private aa n = new aa(this, null);
private r(Context context) {
this.f3151a = null;
this.f3152b = null;
this.d = null;
this.e = null;
this.g = null;
this.h = null;
this.j = null;
this.k = null;
this.l = null;
this.m = null;
this.f3151a = context;
this.h = Collections.synchronizedList(new ArrayList());
this.g = Collections.synchronizedList(new ArrayList());
this.d = com.cx.launcher.cloud.i.a(context);
this.e = com.cx.launcher.cloud.m.a(context);
this.f3152b = com.cx.launcher.cloud.h.a(context);
this.j = new com.cx.launcher.cloud.c(context);
this.k = new com.cx.launcher.cloud.f(context);
this.l = new com.cx.launcher.cloud.e(context);
this.m = new com.cx.launcher.cloud.q(context);
}
public static r a(Context context) {
if (f3150c == null) {
synchronized (r.class) {
if (f3150c == null) {
f3150c = new r(context);
}
}
}
return f3150c;
}
private y a(com.cx.launcher.cloud.c.d dVar, String str, com.cx.launcher.cloud.a aVar) {
try {
com.c.a.d.f fVar = new com.c.a.d.f();
y yVar = new y(this, fVar);
fVar.a("params", i(dVar).toString());
File a2 = this.d.a(dVar, aVar);
if (a2 == null || !a2.exists()) {
com.cx.tools.e.a.c(f, "upload xml not exist,name:" + dVar.s() + "," + str);
yVar = null;
} else {
yVar.a(a2.length());
fVar.a(str, a2);
}
return yVar;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public void a(int i) {
switch (i) {
case 1:
case 4:
this.p++;
break;
case 2:
this.q++;
break;
}
if (this.t != null) {
this.r = this.h.size();
this.t.a(this.q, this.p, this.r);
}
}
public void a(com.cx.launcher.cloud.t tVar) {
if (tVar != null) {
this.s.post(new v(this, tVar));
}
}
private com.cx.launcher.cloud.c.k b(com.cx.launcher.cloud.c.d dVar) {
com.cx.tools.e.a.c(f, "getFileTaskGroup device :" + dVar.a(this.f3151a));
if (dVar == null || be.a(dVar.a(this.f3151a))) {
return null;
}
int size = this.g.size();
for (int i = 0; i < size; i++) {
com.cx.launcher.cloud.c.k kVar = (com.cx.launcher.cloud.c.k) this.g.get(i);
if (kVar.c().equals(dVar.a(this.f3151a))) {
kVar.a(System.currentTimeMillis());
m();
c(kVar.e());
return kVar;
}
}
com.cx.launcher.cloud.c.k kVar2 = new com.cx.launcher.cloud.c.k();
kVar2.a(dVar.t());
kVar2.b(dVar.s());
kVar2.c(dVar.a(this.f3151a));
kVar2.d(dVar.m());
kVar2.e(dVar.f());
kVar2.a(new ArrayList());
kVar2.a(System.currentTimeMillis());
this.g.add(kVar2);
m();
return kVar2;
}
private void b(ab abVar, com.cx.launcher.cloud.c.d dVar) {
abVar.b(this.n);
this.r++;
}
private ab c(com.cx.launcher.cloud.c.d dVar) {
com.cx.launcher.cloud.c.g gVar = new com.cx.launcher.cloud.c.g(com.cx.base.f.i.APP);
gVar.e(System.currentTimeMillis());
gVar.a(com.cx.launcher.cloud.c.h.UPLOAD);
gVar.h("http://yun.goyihu.com/cloud/api/V1.0/backup/app/upload");
gVar.z = this.f3151a.getResources().getString(R.string.cloud_app_list);
gVar.a(dVar);
ab abVar = new ab(this.f3151a, gVar);
String str = "http://yun.goyihu.com/cloud/api/V1.0/backup/app/upload/" + dVar.a(this.f3151a);
abVar.b(3);
abVar.a(str);
gVar.i(str);
y d = d(dVar);
if (d == null) {
return null;
}
abVar.a(d.f3160a);
gVar.b(d.f3161b);
return abVar;
}
private void c(ab abVar, com.cx.launcher.cloud.c.d dVar) {
if (abVar == null || dVar == null) {
return;
}
com.cx.launcher.cloud.c.g a2 = abVar.a();
a2.a(dVar);
com.cx.base.f.i j = a2.j();
y yVar = null;
if (j == com.cx.base.f.i.APP) {
yVar = d(dVar);
} else if (j == com.cx.base.f.i.CONTACT) {
yVar = a(dVar, "contact.xml", this.k);
} else if (j == com.cx.base.f.i.CALLLOG) {
yVar = a(dVar, "call.xml", this.l);
} else if (j == com.cx.base.f.i.SMSDATA) {
yVar = a(dVar, "sms.xml", this.m);
}
if (yVar != null) {
abVar.a(yVar.f3160a);
a2.b(yVar.f3161b);
b(abVar, dVar);
}
}
private void c(List list) {
Collections.sort(list, new t(this));
}
private y d(com.cx.launcher.cloud.c.d dVar) {
y yVar;
Exception e;
com.c.a.d.f fVar;
try {
fVar = new com.c.a.d.f();
yVar = new y(this, fVar);
} catch (Exception e2) {
yVar = null;
e = e2;
}
try {
JSONObject i = i(dVar);
String a2 = this.j.a(dVar, com.cx.base.d.a.a(this.f3151a));
if (be.a(a2)) {
return null;
}
yVar.a(3072L);
i.put("list", a2 != null ? new JSONArray(a2) : "");
fVar.a("params", i.toString());
com.cx.tools.e.a.c(f, "createAppParams-->" + i);
return yVar;
} catch (Exception e3) {
e = e3;
e.printStackTrace();
return yVar;
}
}
private ab e(com.cx.launcher.cloud.c.d dVar) {
com.cx.launcher.cloud.c.g gVar = new com.cx.launcher.cloud.c.g(com.cx.base.f.i.CONTACT);
gVar.e(System.currentTimeMillis());
gVar.a(com.cx.launcher.cloud.c.h.UPLOAD);
gVar.h("http://yun.goyihu.com/cloud/api/V1.0/backup/contact/upload");
gVar.z = this.f3151a.getResources().getString(R.string.launcher_contacts);
gVar.a(dVar);
ab abVar = new ab(this.f3151a, gVar);
String str = "http://yun.goyihu.com/cloud/api/V1.0/backup/contact/upload/" + dVar.a(this.f3151a);
abVar.b(3);
abVar.a(str);
gVar.i(str);
y a2 = a(dVar, "contact.xml", this.k);
if (a2 == null) {
return null;
}
gVar.b(a2.f3161b);
abVar.a(a2.f3160a);
return abVar;
}
private ab f(com.cx.launcher.cloud.c.d dVar) {
com.cx.launcher.cloud.c.g gVar = new com.cx.launcher.cloud.c.g(com.cx.base.f.i.CALLLOG);
gVar.e(System.currentTimeMillis());
gVar.a(com.cx.launcher.cloud.c.h.UPLOAD);
gVar.h("http://yun.goyihu.com/cloud/api/V1.0/backup/call/upload");
gVar.z = this.f3151a.getResources().getString(R.string.launcher_call_log);
gVar.a(dVar);
ab abVar = new ab(this.f3151a, gVar);
String str = "http://yun.goyihu.com/cloud/api/V1.0/backup/call/upload/" + dVar.a(this.f3151a);
abVar.a(str);
gVar.i(str);
y a2 = a(dVar, "call.xml", this.l);
if (a2 == null) {
return null;
}
gVar.b(a2.f3161b);
abVar.a(a2.f3160a);
return abVar;
}
private ab g(com.cx.launcher.cloud.c.d dVar) {
com.cx.launcher.cloud.c.g gVar = new com.cx.launcher.cloud.c.g(com.cx.base.f.i.SMSDATA);
gVar.e(System.currentTimeMillis());
gVar.a(com.cx.launcher.cloud.c.h.UPLOAD);
gVar.a(dVar);
gVar.h("http://yun.goyihu.com/cloud/api/V1.0/backup/sms/upload");
gVar.z = this.f3151a.getResources().getString(R.string.launcher_sms);
ab abVar = new ab(this.f3151a, gVar);
String str = "http://yun.goyihu.com/cloud/api/V1.0/backup/sms/upload/" + dVar.a(this.f3151a);
abVar.a(str);
gVar.i(str);
y a2 = a(dVar, "sms.xml", this.m);
if (a2 == null) {
return null;
}
gVar.b(a2.f3161b);
abVar.a(a2.f3160a);
return abVar;
}
private List h(com.cx.launcher.cloud.c.d dVar) {
String a2;
ArrayList arrayList = new ArrayList();
List a3 = this.d.a(dVar);
ArrayList arrayList2 = new ArrayList();
com.cx.tools.e.a.c(f, "createEBookTask==>" + a3.size() + "," + dVar.s());
if (a3 != null) {
int size = a3.size();
int i = size > 10 ? 10 : size;
for (int i2 = 0; i2 < i; i2++) {
String str = (String) a3.get(i2);
if (!TextUtils.isEmpty(str) && new File(str).exists()) {
JSONObject i3 = i(dVar);
File file = new File(str);
try {
i3.put("file_name", file.getName());
i3.put("file_length", file.length());
i3.put("file_piece_count", new com.cx.launcher.cloud.e.d(file.getAbsolutePath()).a());
a2 = com.cx.huanji.h.s.a(file);
} catch (JSONException e) {
e.printStackTrace();
}
if (!arrayList2.contains(a2)) {
arrayList2.add(a2);
i3.put("file_hash_code", a2);
com.cx.launcher.cloud.c.g gVar = new com.cx.launcher.cloud.c.g(com.cx.base.f.i.DOC);
gVar.e(System.currentTimeMillis());
gVar.a(com.cx.launcher.cloud.c.h.UPLOAD);
gVar.a(dVar);
gVar.h("http://yun.goyihu.com/cloud/api/V1.0/backup/ebook/upload");
gVar.z = file.getName();
gVar.b(file.length());
ac acVar = new ac(this.f3151a, gVar, file.getAbsolutePath(), i3.toString(), this.s);
String str2 = file.getAbsolutePath() + "/" + dVar.a(this.f3151a);
acVar.a(str2);
gVar.i(str2);
gVar.b(file.length());
arrayList.add(acVar);
}
}
}
}
return arrayList;
}
private JSONObject i(com.cx.launcher.cloud.c.d dVar) {
String a2 = this.e.a() != null ? this.e.a().a() : "";
String str = com.cx.tools.i.k.a(com.cx.tools.d.c.f4637a) ? com.cx.tools.d.c.f4637a : "0";
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("openId", a2);
jSONObject.put("deviceId", dVar.a(this.f3151a));
jSONObject.put("displayName", dVar.s());
jSONObject.put("icon_url", dVar.t());
jSONObject.put("lang", this.f3151a.getResources().getConfiguration().locale.getLanguage());
jSONObject.put("usr", str);
jSONObject.put("apiLevel", Build.VERSION.SDK_INT);
jSONObject.put(SocializeProtocolConstants.PROTOCOL_KEY_IMEI, dVar.n());
jSONObject.put("androidId", dVar.o());
jSONObject.put("brand", dVar.m());
jSONObject.put("model", dVar.f());
if (dVar.u() == com.cx.launcher.cloud.c.f.LOCAL_PHONE) {
jSONObject.put("parentId", "0");
} else {
jSONObject.put("parentId", this.d.i().a(this.f3151a));
}
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject;
}
private void m() {
Collections.sort(this.g, new s(this));
}
public void a() {
this.g.clear();
this.h.clear();
this.g = this.f3152b.b();
int size = this.g.size();
this.i.clear();
for (int i = 0; i < size; i++) {
com.cx.launcher.cloud.c.k kVar = (com.cx.launcher.cloud.c.k) this.g.get(i);
List e = kVar.e();
c(e);
com.cx.launcher.cloud.c.d dVar = new com.cx.launcher.cloud.c.d();
dVar.i(kVar.b());
dVar.j(kVar.a());
dVar.l(kVar.c());
dVar.f(kVar.c());
dVar.e(kVar.f());
dVar.c(kVar.g());
int size2 = e.size();
for (int i2 = 0; i2 < size2; i2++) {
this.h.add(e.get(i2));
com.cx.launcher.cloud.b.l.a(this.f3151a).c(dVar);
c((ab) e.get(i2), dVar);
}
}
m();
com.cx.tools.e.a.c(f, "Load all upload task from db,group size:" + this.g.size() + ",child size:" + this.h.size());
}
public void a(com.cx.launcher.cloud.c.d dVar) {
if (dVar != null) {
int size = this.g.size();
ArrayList arrayList = new ArrayList();
for (int i = 0; i < size; i++) {
com.cx.launcher.cloud.c.k kVar = (com.cx.launcher.cloud.c.k) this.g.get(i);
com.cx.tools.e.a.c(f, "group name:" + kVar.b() + "," + kVar.c() + "**" + dVar.s() + "," + dVar.a(this.f3151a));
if (kVar.c().equals(dVar.a(this.f3151a))) {
arrayList.clear();
arrayList.addAll(kVar.e());
if (arrayList != null) {
a(arrayList, (com.cx.launcher.cloud.t) null);
}
}
}
}
}
public void a(List list) {
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
ab abVar = (ab) it.next();
if (abVar != null) {
if (this.h != null) {
this.h.remove(abVar);
}
if (this.g != null && this.g.size() > 0) {
Iterator it2 = this.g.iterator();
while (true) {
if (!it2.hasNext()) {
break;
}
List e = ((com.cx.launcher.cloud.c.k) it2.next()).e();
if (e != null && e.contains(abVar)) {
e.remove(abVar);
if (e.size() == 0) {
it2.remove();
}
}
}
}
}
}
}
}
public synchronized void a(List list, w wVar) {
this.o = false;
this.p = 0;
this.q = 0;
this.r = 0;
this.u.clear();
this.v.clear();
this.t = wVar;
if (list != null && list.size() > 0 && !this.o) {
this.i.clear();
f();
int size = list.size();
int i = 0;
loop0: while (true) {
if (i >= size) {
break;
}
com.cx.launcher.cloud.c.d dVar = (com.cx.launcher.cloud.c.d) list.get(i);
ab c2 = c(dVar);
if (c2 != null) {
b(c2, dVar);
} else {
com.cx.tools.e.a.c(f, "syncDeviceData--> app list task is null");
}
if (this.o) {
break;
}
ab e = e(dVar);
if (e != null) {
b(e, dVar);
} else {
com.cx.tools.e.a.c(f, "syncDeviceData--> contact task is null");
}
ab f2 = f(dVar);
if (f2 != null) {
b(f2, dVar);
} else {
com.cx.tools.e.a.c(f, "syncDeviceData--> call record task is null!");
}
ab g = g(dVar);
if (g != null) {
b(g, dVar);
} else {
com.cx.tools.e.a.c(f, "syncDeviceData--> sms task is null!");
}
if (this.o) {
break;
}
a(c2, dVar);
a(e, dVar);
a(f2, dVar);
a(g, dVar);
List<ab> h = h(dVar);
if (h != null) {
for (ab abVar : h) {
if (this.o) {
break loop0;
} else if (abVar != null) {
b(abVar, dVar);
a(abVar, dVar);
}
}
}
i++;
}
}
}
public void a(List list, com.cx.launcher.cloud.t tVar) {
b(list);
Thread thread = new Thread(new u(this, list, tVar));
thread.setName("CloudDelTaskThread");
thread.start();
}
public synchronized void a(boolean z) {
this.o = z;
}
public boolean a(ab abVar) {
return this.f3152b.a(abVar) > 0;
}
public boolean a(ab abVar, com.c.a.e.b bVar, com.cx.launcher.cloud.c.d dVar) {
if (abVar != null && dVar != null) {
if (this.h.contains(abVar)) {
com.cx.tools.e.a.c(f, "Exist task : " + abVar);
return true;
}
com.cx.launcher.cloud.c.k b2 = b(dVar);
if (b2 != null) {
b2.e().add(abVar);
this.h.add(abVar);
abVar.b(3);
this.f3152b.a(b2);
com.cx.tools.e.a.c(f, "Insert upload task to db.");
return true;
}
com.cx.tools.e.a.c(f, "Add upload task failed,device unique is null.");
}
return false;
}
public boolean a(ab abVar, com.cx.launcher.cloud.c.d dVar) {
return a(abVar, com.c.a.e.b.DEFAULT, dVar);
}
public List b(boolean z) {
if (this.h == null) {
return null;
}
ArrayList arrayList = new ArrayList();
int size = this.h.size();
for (int i = 0; i < size; i++) {
ab abVar = (ab) this.h.get(i);
if (z && abVar.g() == 2) {
arrayList.add(abVar);
} else if (!z && abVar.g() != 2) {
arrayList.add(abVar);
}
}
return arrayList;
}
public synchronized void b(List list) {
if (list != null) {
if (list.size() > 0) {
Iterator it = list.iterator();
while (it.hasNext()) {
ab abVar = (ab) it.next();
int g = abVar.g();
if (g == 0 || g == 3 || g == 4) {
abVar.e();
}
}
}
}
}
public boolean b() {
if (this.h != null && this.h.size() > 0) {
int size = this.h.size();
for (int i = 0; i < size; i++) {
int g = ((ab) this.h.get(i)).g();
if (g == 0 || g == 3) {
return true;
}
}
}
return false;
}
public boolean c() {
if (this.h != null && this.h.size() > 0) {
int size = this.h.size();
for (int i = 0; i < size; i++) {
if (((ab) this.h.get(i)).g() != 2) {
return false;
}
}
}
return true;
}
public List d() {
ArrayList arrayList = new ArrayList();
if (this.g != null) {
arrayList.addAll(this.g);
}
return arrayList;
}
public List e() {
return this.h;
}
public void f() {
h();
if (this.f3152b.c() > 0) {
this.g.clear();
this.h.clear();
}
}
public void g() {
for (ab abVar : this.h) {
int g = abVar.g();
if (g == 1 || g == 3 || g == 4) {
abVar.d();
}
}
}
public synchronized void h() {
b(this.h);
}
public void i() {
a(b(true), (com.cx.launcher.cloud.t) null);
}
public void j() {
k();
g();
}
public void k() {
this.p = 0;
this.u.clear();
}
}