QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 ScanConfigParser.java 源代码,内容仅作参考
package com.tencent.mtt.fileclean.config;
import android.text.TextUtils;
import com.tencent.common.http.Apn;
import com.tencent.common.task.QBTask;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.FileUtils;
import com.tencent.common.utils.StorageDirs;
import com.tencent.common.utils.StringUtils;
import com.tencent.luggage.wxa.kr.ad;
import com.tencent.mtt.base.wup.PreferenceData;
import com.tencent.mtt.browser.download.core.facade.IBusinessDownloadService;
import com.tencent.mtt.browser.download.core.impl.DownloadServiceManager;
import com.tencent.mtt.browser.download.engine.DownloadErrorDetail;
import com.tencent.mtt.browser.download.engine.DownloadInfo;
import com.tencent.mtt.browser.download.engine.DownloadTask;
import com.tencent.mtt.browser.download.engine.DownloadTaskListener;
import com.tencent.mtt.browser.download.engine.PauseReason;
import com.tencent.mtt.browser.jsextension.open.IOpenJsApis;
import com.tencent.mtt.browser.utils.FileTool;
import com.tencent.mtt.browser.webbussiness.facade.IWebRecognizeService;
import com.tencent.mtt.fileclean.utils.JunkFileUtils;
import com.tencent.mtt.log.utils.StringUtil;
import com.tencent.mtt.tool.FilePreferenceManager;
import com.tencent.open.SocialConstants;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ScanConfigParser implements DownloadTaskListener {
private static volatile ScanConfigParser r;
String f;
String g;
String h;
Set<String> i;
String j;
String k;
boolean m;
String n;
public Map<String, AppScanConfigs> f65678a = new ConcurrentHashMap();
public Map<String, String> f65679b = new ConcurrentHashMap();
private volatile boolean o = false;
private volatile boolean p = false;
private Set<IParseListener> q = new HashSet();
public Map<Integer, List<String>> f65680c = new ConcurrentHashMap();
public Map<Integer, List<String>> f65681d = new ConcurrentHashMap();
public Map<Integer, List<String>> e = new ConcurrentHashMap();
int l = StringUtils.b(PreferenceData.a("JUNK_SCAN_VERSION"), 1);
private IBusinessDownloadService s = DownloadServiceManager.a();
public interface IParseListener {
void a();
}
private ScanConfigParser() {
this.m = false;
this.m = TextUtils.equals(PreferenceData.a("JUNK_CLEAN_TEST_NEW_JSON"), "1");
this.n = this.m ? "https://static.res.qq.com/nav/file/scan_config_debug.json" : "https://static.res.qq.com/nav/file/junk_scan_config_v4.json";
}
public static ScanConfigParser a() {
if (r == null) {
synchronized (ScanConfigParser.class) {
if (r == null) {
r = new ScanConfigParser();
}
}
}
return r;
}
public void a(String str) {
JSONArray jSONArray;
JSONArray jSONArray2;
String str2;
JSONArray jSONArray3;
String str3 = SocialConstants.PARAM_APP_DESC;
try {
JSONArray jSONArray4 = new JSONArray(str);
if (jSONArray4.length() > 0 && (jSONArray2 = jSONArray4.getJSONObject(0).getJSONArray("configs")) != null && jSONArray2.length() > 0) {
int i = 0;
while (i < jSONArray2.length()) {
JSONObject jSONObject = jSONArray2.getJSONObject(i);
String string = jSONObject.getString("pkgName");
String string2 = jSONObject.getString("appName");
AppScanConfigs appScanConfigs = new AppScanConfigs();
appScanConfigs.f65674a = string2;
if (jSONObject.has(str3)) {
appScanConfigs.f65675b = jSONObject.getString(str3);
}
JSONArray jSONArray5 = jSONObject.getJSONArray("caches");
if (jSONArray5 == null || jSONArray5.length() <= 0) {
str2 = str3;
} else {
ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
int i2 = 0;
while (i2 < jSONArray5.length()) {
JSONObject jSONObject2 = jSONArray5.getJSONObject(i2);
String str4 = str3;
String string3 = jSONObject2.getString("name");
if (string3 != null) {
concurrentHashMap.put(jSONObject2.getString("path"), string3);
}
i2++;
str3 = str4;
}
str2 = str3;
appScanConfigs.f65676c = concurrentHashMap;
}
if (jSONObject.has("unstalls") && (jSONArray3 = jSONObject.getJSONArray("unstalls")) != null && jSONArray3.length() > 0) {
ConcurrentHashMap concurrentHashMap2 = new ConcurrentHashMap();
for (int i3 = 0; i3 < jSONArray3.length(); i3++) {
JSONObject jSONObject3 = jSONArray3.getJSONObject(i3);
String string4 = jSONObject3.getString("name");
if (string4 != null) {
concurrentHashMap2.put(jSONObject3.getString("path"), string4);
}
}
appScanConfigs.f65677d = concurrentHashMap2;
}
this.f65678a.put(string, appScanConfigs);
i++;
str3 = str2;
}
}
if (jSONArray4.length() > 1 && (jSONArray = jSONArray4.getJSONObject(1).getJSONArray("configs")) != null && jSONArray.length() > 0) {
for (int i4 = 0; i4 < jSONArray.length(); i4++) {
JSONObject jSONObject4 = jSONArray.getJSONObject(i4);
if (jSONObject4 != null && jSONObject4.getString("name") != null) {
this.f65679b.put(jSONObject4.getString("path"), jSONObject4.getString("name"));
}
}
}
if (jSONArray4.length() > 2) {
c(jSONArray4.getJSONObject(2));
}
if (jSONArray4.length() > 3) {
b(jSONArray4.getJSONObject(3));
}
if (jSONArray4.length() > 4) {
a(jSONArray4.getJSONObject(4));
}
} catch (JSONException unused) {
}
b();
}
private void a(JSONObject jSONObject) {
try {
JSONArray jSONArray = jSONObject.getJSONArray("configs");
if (jSONArray == null || jSONArray.length() <= 0) {
return;
}
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
if (jSONObject2 != null && jSONObject2.getString("key") != null) {
JSONArray jSONArray2 = jSONObject2.getJSONArray("paths");
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
arrayList.add(this.f + File.separator + jSONArray2.getJSONObject(i2).getString("filepath"));
}
this.e.put(b(jSONObject2.getString("key")), arrayList);
}
}
} catch (JSONException unused) {
}
}
private Integer b(String str) {
int i;
if (StringUtil.a(str, "useless")) {
return 400;
}
if (StringUtil.a(str, "aiqiyi")) {
i = 411;
} else if (StringUtil.a(str, "qqlive")) {
i = ad.CTRL_INDEX;
} else {
if (!StringUtil.a(str, "youku")) {
return 400;
}
i = 409;
}
return Integer.valueOf(i);
}
private synchronized void b() {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
ScanConfigParser.this.p = true;
for (IParseListener iParseListener : ScanConfigParser.this.q) {
if (iParseListener != null) {
iParseListener.a();
}
}
ScanConfigParser.this.q.clear();
}
});
}
private void b(JSONObject jSONObject) {
StringBuilder sb;
try {
JSONArray jSONArray = jSONObject.getJSONArray("configs");
if (jSONArray == null || jSONArray.length() <= 0) {
return;
}
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
if (jSONObject2 != null && jSONObject2.getString("key") != null) {
JSONArray jSONArray2 = jSONObject2.getJSONArray("paths");
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
JSONObject jSONObject3 = jSONArray2.getJSONObject(i2);
String string = jSONObject3.getString("filepath");
boolean a2 = StringUtil.a(IOpenJsApis.TRUE, jSONObject3.getString("inTencentPath"));
boolean a3 = StringUtil.a(IOpenJsApis.TRUE, jSONObject3.getString("inSandBoxPath"));
if (a2 || a3) {
if (a2) {
arrayList.add(this.j + File.separator + string);
}
if (a3) {
sb = new StringBuilder();
sb.append(this.k);
sb.append(File.separator);
sb.append(string);
}
} else {
sb = new StringBuilder();
sb.append(this.f);
sb.append(File.separator);
sb.append(string);
}
arrayList.add(sb.toString());
}
this.f65681d.put(c(jSONObject2.getString("key")), arrayList);
}
}
} catch (JSONException unused) {
}
}
private Integer c(String str) {
int i;
if (StringUtil.a(str, "useless")) {
i = 200;
} else {
if (!StringUtil.a(str, "savedImg")) {
return StringUtil.a(str, "qqDirs") ? 201 : 201;
}
i = 202;
}
return Integer.valueOf(i);
}
private void c() {
if (TextUtils.isEmpty(this.f)) {
this.f = FileUtils.b().getAbsolutePath();
}
if (TextUtils.isEmpty(this.g)) {
this.g = FileTool.g(FileUtils.b());
}
if (TextUtils.isEmpty(this.h)) {
this.h = FileTool.h(FileUtils.b());
}
if (this.i == null) {
this.i = JunkFileUtils.a();
}
if (TextUtils.isEmpty(this.j)) {
this.j = FileTool.a(FileUtils.b());
}
if (TextUtils.isEmpty(this.k)) {
this.k = FileTool.f(FileUtils.b());
}
}
private void c(JSONObject jSONObject) {
try {
JSONArray jSONArray = jSONObject.getJSONArray("configs");
if (jSONArray == null || jSONArray.length() <= 0) {
return;
}
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i);
if (jSONObject2 != null && jSONObject2.getString("key") != null) {
JSONArray jSONArray2 = jSONObject2.getJSONArray("paths");
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
JSONObject jSONObject3 = jSONArray2.getJSONObject(i2);
String string = jSONObject3.getString("filepath");
boolean a2 = StringUtil.a(IOpenJsApis.TRUE, jSONObject3.getString("inMircoPath"));
boolean a3 = StringUtil.a(IOpenJsApis.TRUE, jSONObject3.getString("inSandBoxPath"));
boolean a4 = StringUtil.a(IOpenJsApis.TRUE, jSONObject3.getString("inUserPath"));
if (a2 || a3) {
if (a2) {
if (!a4 || this.i.size() <= 0) {
arrayList.add(this.g + File.separator + string);
} else {
Iterator<String> it = this.i.iterator();
while (it.hasNext()) {
arrayList.add(this.g + File.separator + it.next() + File.separator + string);
}
}
}
if (a3) {
if (!a4 || this.i.size() <= 0) {
arrayList.add(this.h + File.separator + string);
} else {
Iterator<String> it2 = this.i.iterator();
while (it2.hasNext()) {
arrayList.add(this.h + File.separator + it2.next() + File.separator + string);
}
}
}
} else {
arrayList.add(this.f + File.separator + string);
}
}
this.f65680c.put(Integer.valueOf(d(jSONObject2.getString("key"))), arrayList);
}
}
} catch (JSONException unused) {
}
}
private int d(String str) {
if (StringUtil.a(str, "useless")) {
return 100;
}
if (StringUtil.a(str, "snsCache")) {
return 101;
}
if (StringUtil.a(str, "xcxCache")) {
return 102;
}
if (StringUtil.a(str, "chatThumb")) {
return 103;
}
if (StringUtil.a(str, "chatImg")) {
return 104;
}
if (StringUtil.a(str, "emoji")) {
return 105;
}
if (StringUtil.a(str, "chatVideo")) {
return 106;
}
if (StringUtil.a(str, "doc")) {
return 107;
}
StringUtil.a(str, IWebRecognizeService.CALL_FROM_OTHER);
return 108;
}
private File d() {
return new File(e(), "junkScanConfig.json");
}
private String e() {
return FileUtils.a(StorageDirs.b(), ".junkscan").getAbsolutePath();
}
public void f() {
DownloadInfo downloadInfo;
String d2;
c();
if (this.m) {
if (Apn.isNetworkAvailable()) {
File file = new File(e(), "junkScanConfigDebug.json");
if (file.exists()) {
file.delete();
}
this.s.addTaskListener(this.n, this);
downloadInfo = new DownloadInfo();
downloadInfo.h = false;
downloadInfo.j = false;
downloadInfo.i = false;
downloadInfo.f37604a = this.n;
downloadInfo.H = 32;
downloadInfo.f = e();
downloadInfo.f37606c = "junkScanConfigDebug.json";
this.s.startDownloadTask(downloadInfo, null, null);
return;
}
d2 = JunkFileUtils.b("junk_scan_config.json");
} else if (FilePreferenceManager.a().getInt("local_scan_config_version", 0) == this.l && d().exists()) {
d2 = JunkFileUtils.d(d());
} else {
if (Apn.isNetworkAvailable()) {
if (d().exists()) {
d().delete();
}
this.s.addTaskListener("https://static.res.qq.com/nav/file/junk_scan_config_v4.json", this);
downloadInfo = new DownloadInfo();
downloadInfo.h = false;
downloadInfo.j = false;
downloadInfo.i = false;
downloadInfo.f37604a = "https://static.res.qq.com/nav/file/junk_scan_config_v4.json";
downloadInfo.H = 32;
downloadInfo.f = e();
downloadInfo.f37606c = "junkScanConfig.json";
this.s.startDownloadTask(downloadInfo, null, null);
return;
}
d2 = JunkFileUtils.b("junk_scan_config.json");
}
a(d2);
}
public synchronized void a(IParseListener iParseListener) {
this.q.add(iParseListener);
if (this.p) {
b();
} else if (!this.o) {
this.o = true;
QBTask.a((Callable) new Callable<Boolean>() {
@Override
public Boolean call() {
ScanConfigParser.this.f();
return null;
}
});
}
}
@Override
public void onTaskCompleted(final DownloadTask downloadTask) {
QBTask.a((Callable) new Callable<Boolean>() {
@Override
public Boolean call() {
String O = downloadTask.O();
if (TextUtils.isEmpty(O)) {
return null;
}
File file = new File(O);
if (!file.exists()) {
return null;
}
ScanConfigParser.this.a(JunkFileUtils.d(file));
FilePreferenceManager.a().setInt("local_scan_config_version", ScanConfigParser.this.l);
return null;
}
});
}
@Override
public void onTaskCreated(DownloadTask downloadTask) {
}
@Override
public void onTaskFailed(DownloadTask downloadTask, DownloadErrorDetail downloadErrorDetail) {
QBTask.a((Callable) new Callable<Boolean>() {
@Override
public Boolean call() {
ScanConfigParser.this.a(JunkFileUtils.b("junk_scan_config.json"));
return null;
}
});
}
@Override
public void onTaskPaused(DownloadTask downloadTask, PauseReason pauseReason) {
}
@Override
public void onTaskProgress(DownloadTask downloadTask) {
}
@Override
public void onTaskRemoved(DownloadTask downloadTask) {
}
@Override
public void onTaskStarted(DownloadTask downloadTask) {
}
@Override
public void onTaskWaiting(DownloadTask downloadTask) {
}
}