QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 cr.java 源代码,内容仅作参考
package c.t.m.sapp.g;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.location.Location;
import android.net.wifi.ScanResult;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import c.t.m.sapp.g.ex;
import com.facebook.common.statfs.StatFsHelper;
import com.huawei.hms.utils.FileUtil;
import com.tencent.map.geolocation.util.DateUtils;
import com.tencent.mm.ui.widget.dialog.MMTipsBar;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.List;
import org.xwalk.core.XWalkAppVersion;
import tmsdk.common.gourd.vine.IMessageCenter;
public class cr extends eh {
private static final String f1853c = cw.a() + ef.a(cr.class.getName(), XWalkAppVersion.XWALK_APK_HASH_ALGORITHM).substring(0, 8);
private ct A;
private cs B;
private BroadcastReceiver C;
private Context f1854d;
private final File e;
private boolean f;
private volatile Handler g;
private long h;
private long i;
private int j;
private int k;
private long l;
private long m;
private long n;
private long o;
private boolean p;
private boolean q;
private boolean r;
private int s;
private long t;
private long u;
private long v;
private volatile List<cq> w;
private volatile List<ScanResult> x;
private volatile Location y;
private cu z;
class a extends Handler {
private File f1860a;
private BufferedOutputStream f1861b;
private StringBuffer f1862c;
private String f1863d;
private long e;
public a(Looper looper) {
super(looper);
this.f1863d = "";
this.e = 0L;
}
private long a() {
long j = cw.f ? 51200L : 512000L;
return cr.this.h > j ? j : cr.this.h;
}
private static void a(int i, File file) {
try {
if (file.isFile()) {
File file2 = new File(file.getAbsolutePath() + "." + System.currentTimeMillis() + ".enc");
if (i == 4) {
byte[] b2 = ef.b(file);
if (!eo.a(b2)) {
byte[] a2 = ef.a(b2);
if (!eo.a(a2)) {
FileOutputStream fileOutputStream = new FileOutputStream(file2, true);
fileOutputStream.write(a2);
fileOutputStream.close();
file.delete();
}
}
} else {
file.renameTo(file2);
}
if (eo.f()) {
eo.a("DC_Pro", "rename:" + file.getName() + " to " + file2.getName());
}
}
} catch (Throwable th) {
if (eo.f()) {
eo.a("DC_Pro", "rename:" + file.getName() + " error.", th);
}
}
}
private void a(long j, long j2) {
File file = null;
File[] listFiles = cr.this.e == null ? null : cr.this.e.listFiles();
if (listFiles == null || listFiles.length == 0) {
return;
}
long currentTimeMillis = System.currentTimeMillis();
long j3 = 0;
for (File file2 : listFiles) {
if (file2.exists() && file2.isFile() && !cr.f1853c.equals(file2.getName())) {
if (currentTimeMillis - file2.lastModified() > j || file2.length() == 0) {
if (eo.f()) {
eo.a("DC_Pro", "delete expired file:" + file2.getName() + ",len:" + file2.length());
}
file2.delete();
} else {
String name = file2.getName();
if (currentTimeMillis - file2.lastModified() <= 172800000 || name.endsWith(".enc") || !name.startsWith(cw.a())) {
j3 += file2.length();
if (file == null || file.lastModified() > file2.lastModified()) {
file = file2;
}
} else {
a(cw.a(name), file2);
}
}
}
}
if (j3 < j2 || file == null) {
return;
}
if (eo.f()) {
eo.a("DC_Pro", "too big folder size:" + j3 + ", delete " + file.getName() + ",size:" + file.length());
}
file.delete();
}
private boolean a(long j) {
try {
SharedPreferences a2 = ez.a("LocationSDK");
SharedPreferences.Editor edit = a2.edit();
String string = a2.getString("log_up_fc_date", "");
long j2 = a2.getLong("log_up_fc_size", 0L);
String format = eq.a("yyyyMMdd").format(new Date());
if (!format.equals(string)) {
edit.putString("log_up_fc_date", format);
edit.putLong("log_up_fc_size", j);
} else {
if (j2 > cr.this.m) {
return false;
}
edit.putLong("log_up_fc_size", j + j2);
}
edit.apply();
return true;
} catch (Throwable unused) {
return true;
}
}
private boolean a(String str) {
File[] fileArr = null;
File file = TextUtils.isEmpty(str) ? null : new File(str);
if (file != null && file.exists() && file.isDirectory()) {
fileArr = file.listFiles();
}
if (fileArr == null || fileArr.length == 0) {
if (fileArr != null && str.endsWith("d_c")) {
file.delete();
}
return false;
}
long currentTimeMillis = System.currentTimeMillis();
int i = cr.this.j;
for (int i2 = 0; i2 < fileArr.length && i > 0; i2++) {
File file2 = fileArr[i2];
String name = (file2 != null && file2.exists() && file2.isFile()) ? file2.getName() : "";
if (name.startsWith("dc") || name.startsWith("fc")) {
if (!str.endsWith("d_c") || (file2.length() != 0 && currentTimeMillis - file2.lastModified() <= cr.this.o)) {
boolean z = (name.startsWith(cw.a()) && name.endsWith(".enc")) || (name.startsWith("fc2") || name.startsWith("fc3"));
if (!z) {
if (eo.f()) {
eo.a("DC_Pro", str + ",has no " + cw.a() + "***.enc files!!!");
}
z = name.startsWith("dc") && System.currentTimeMillis() - file2.lastModified() > 172800000;
}
if (z && a(file2.length())) {
if (eo.f()) {
eo.a("DC_Pro", "upload:" + file2.getName() + ",len=" + file2.length());
}
int a2 = cw.a(name);
if (a2 > 0) {
String a3 = cw.a(a2);
if (!TextUtils.isEmpty(a3)) {
if (!cw.e) {
a3 = a3.replace("https:", "http:");
}
cr.a(cr.this, file2, a3);
i--;
}
}
}
} else {
file2.delete();
}
}
}
return i != cr.this.j;
}
private void b() {
StringBuffer stringBuffer = this.f1862c;
if (stringBuffer == null || stringBuffer.length() == 0 || this.f1861b == null) {
return;
}
byte[] a2 = cy.a(this.f1862c.toString());
if (eo.f()) {
StringBuilder sb = new StringBuilder("write buf to file:buf:");
sb.append(this.f1862c.length());
sb.append(",enc:");
sb.append(a2 == null ? 0 : a2.length);
eo.a("DC_Pro", sb.toString());
}
this.f1862c.setLength(0);
if (a2 == null || a2.length == 0) {
eo.a("DC_Pro", "enc result is null or len = 0");
return;
}
try {
this.f1861b.write(a2);
this.f1861b.write(36);
this.f1861b.flush();
} catch (Throwable th) {
eo.a("DC_Pro", "write file failed.", th);
this.f1860a = null;
eo.a(this.f1861b);
}
}
private void c() {
try {
if (this.f1861b != null) {
this.f1861b.flush();
}
} catch (Throwable unused) {
this.f1860a = null;
eo.a(this.f1861b);
}
}
private void d() {
File file = this.f1860a;
if (file == null || !file.exists() || this.f1861b == null || !cr.f1853c.equals(this.f1860a.getName())) {
this.f1860a = e();
try {
boolean exists = this.f1860a.exists();
this.f1861b = new BufferedOutputStream(new FileOutputStream(this.f1860a, true), 1024);
if (exists) {
return;
}
ez.a("LocationSDK", "log_fc_create", Long.valueOf(System.currentTimeMillis()));
} catch (Throwable th) {
eo.a("DC_Pro", "open file error", th);
}
}
}
private File e() {
File file = cr.this.e;
if (!file.exists()) {
file.mkdirs();
}
return new File(file, cr.f1853c);
}
@Override
public final void handleMessage(Message message) {
long j;
long j2;
try {
if (eo.f()) {
eo.a("DC_Pro", "handleMessage:" + message.what);
}
switch (message.what) {
case 101:
case 102:
try {
int i = message.what;
d();
boolean z = true;
if (!eo.a(cr.this.w)) {
long j3 = ((cq) cr.this.w.get(0)).e;
if (this.e == j3) {
z = false;
}
this.e = j3;
}
String str = "";
if (i == 102) {
str = cx.a(cw.i, cr.this.y, null, cr.this.w, z);
} else if (i == 101) {
List list = cr.this.x;
if (!eo.a(list)) {
str = cx.a(cw.i, cr.this.y, list, cr.this.w, z);
}
}
if (this.f1861b != null && !TextUtils.isEmpty(str) && str.length() >= 25) {
String a2 = ef.a(str.substring(22).getBytes(), XWalkAppVersion.XWALK_APK_HASH_ALGORITHM);
if (this.f1863d.equals(a2)) {
return;
}
this.f1863d = a2;
if (this.f1862c == null) {
this.f1862c = new StringBuffer(cr.this.k);
}
StringBuffer stringBuffer = this.f1862c;
stringBuffer.append(str);
stringBuffer.append("\n");
if (this.f1862c.length() > cr.this.k || (this.f1860a != null && this.f1860a.length() == 0)) {
b();
if (this.f1860a.length() > a()) {
ef.a(cr.this.g, 106, 0L);
}
}
if (eo.f()) {
eo.a("DC_Pro", "write:" + str.substring(0, 60) + "***,len=" + str.length());
return;
}
return;
}
return;
} catch (Throwable th) {
eo.a("DC_Pro", "write data error!", th);
return;
}
case 103:
eo.a("DC_Pro", "upload msg");
if (cr.this.f) {
String absolutePath = cr.this.e.getAbsolutePath();
if (a(absolutePath)) {
return;
}
a(absolutePath.replaceAll("f_c", "d_c"));
return;
}
return;
case 104:
c();
return;
case 105:
try {
b();
if (this.f1862c != null) {
this.f1862c.setLength(0);
}
this.f1860a = null;
eo.a(this.f1861b);
j = cr.this.o;
j2 = cr.this.l;
} catch (Throwable unused) {
this.f1860a = null;
eo.a(this.f1861b);
j = cr.this.o;
j2 = cr.this.l;
}
a(j, j2);
removeCallbacksAndMessages(null);
return;
case 106:
d();
if (cr.this.e != null && this.f1860a != null && this.f1860a.exists()) {
b();
long longValue = ((Long) ez.b("LocationSDK", "log_fc_create", (Object) 0L)).longValue();
long currentTimeMillis = System.currentTimeMillis();
if (eo.f()) {
eo.a("DC_Pro", "desFileLen=" + this.f1860a.length() + ",maxFileSize=" + a() + ",curT=" + currentTimeMillis + ",createT=" + longValue + ",maxTimeRename:" + cr.this.n);
}
if (this.f1860a.length() > a() || currentTimeMillis - longValue > cr.this.n) {
eo.a("DC_Pro", "start rename file.");
c();
if (this.f1860a != null && this.f1860a.length() >= 1024) {
eo.a(this.f1861b);
this.f1861b = null;
a(4, this.f1860a);
this.f1860a = null;
ez.a("LocationSDK", "log_fc_create", (Object) 0L);
}
a(cr.this.o, cr.this.l);
if (cw.f) {
sendEmptyMessage(107);
return;
}
return;
}
return;
}
return;
case 107:
removeMessages(107);
cr.a(cr.this, cr.this.g);
ef.a(cr.this.g, 107, cr.this.i);
return;
default:
return;
}
} catch (Throwable th2) {
if (eo.f()) {
}
}
if (eo.f()) {
return;
}
eo.a("DC_Pro", "handler msg error!", th2);
}
}
private cr(Context context, File file) {
this.f1854d = null;
this.h = 102400L;
this.i = DateUtils.ONE_HOUR;
this.j = 1;
this.k = 25600;
this.l = StatFsHelper.DEFAULT_DISK_RED_LEVEL_IN_BYTES;
this.m = 10485760L;
this.n = 259200000L;
this.o = 2592000000L;
this.p = true;
this.q = false;
this.r = false;
this.s = 0;
this.t = DateUtils.ONE_MINUTE;
this.u = 3000L;
this.v = 0L;
this.C = new BroadcastReceiver() {
@Override
public final void onReceive(Context context2, Intent intent) {
if (intent != null && IMessageCenter.MSG_SYS_CONNECTIVITY_ACTION.equals(intent.getAction())) {
try {
boolean booleanExtra = intent.getBooleanExtra("noConnectivity", false);
if (eo.f()) {
eo.a("DC_Pro", "intent:" + intent + Constants.ACCEPT_TIME_SEPARATOR_SP);
}
if (booleanExtra) {
return;
}
ef.a(cr.this.g, 107, MMTipsBar.DURATION_SHORT);
if (cr.this.A == null) {
} else {
cr.this.A.a(1004, MMTipsBar.DURATION_SHORT);
}
} catch (Throwable unused) {
}
}
}
};
this.f1854d = context;
this.e = file;
this.f = false;
}
public cr(Context context, String str) {
this(context, new File(str + "/f_c"));
}
private static long a(long j, long j2, long j3) {
return Math.max(j2, Math.min(j, j3));
}
static void a(cr crVar, Handler handler) {
eo.a("DC_Pro", "check upload.");
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - crVar.v < DateUtils.ONE_MINUTE) {
eo.a("DC_Pro", "last upload time: < 1min");
return;
}
ef.a(handler, 106, 0L);
try {
ep.a();
ex.a a2 = ex.a();
boolean z = true;
if (a2 == ex.a.f2031a) {
z = false;
} else if (a2 == ex.a.f2032b) {
boolean z2 = cw.f;
if (!cw.f && cw.g) {
long longValue = ((Long) ez.b("LocationSDK", "log_fc_up_in_m", Long.valueOf(currentTimeMillis))).longValue();
if (currentTimeMillis - longValue > 86400000) {
ez.a("LocationSDK", "log_fc_up_in_m", Long.valueOf(currentTimeMillis));
if (eo.f()) {
eo.a("DC_Pro", "upload in mobile once today. lastUpT=" + longValue + ",curT=" + currentTimeMillis);
}
}
}
z = z2;
}
if (eo.f()) {
eo.a("DC_Pro", "network status:" + a2 + ",isUpload:" + z);
}
if (z && crVar.f) {
ef.a(handler, 103, 0L);
crVar.v = currentTimeMillis;
if (eo.f()) {
eo.a("DC_Pro", "send upload msg, last upload time:" + crVar.v);
}
}
} catch (Throwable th) {
eo.a("DC_Pro", "", th);
}
}
static void a(cr crVar, final File file, final String str) {
if (TextUtils.isEmpty(str)) {
return;
}
eu.a("th_loc_task_t_consume", new Runnable() {
@Override
public final void run() {
try {
byte[] b2 = ef.b(file);
if (!eo.a(b2)) {
cw.k.a(str, b2, new ea() {
@Override
public final void a(String str2) {
file.delete();
if (eo.f()) {
eo.a("DC_Pro", "upload " + file.getName() + " succeed, then delete.");
}
}
@Override
public final void b(String str2) {
eo.b("DC_Pro", "upload error,".concat(String.valueOf(str2)));
}
});
return;
}
file.delete();
if (eo.f()) {
eo.a("DC_Pro", "file " + file.getName() + " is empty, then delete.");
}
} catch (Throwable th) {
if (eo.f()) {
eo.a("DC_Pro", "upload error,url=" + str, th);
}
}
}
});
}
@Override
public final int a(Looper looper) {
this.w = null;
this.x = null;
this.y = null;
this.v = 0L;
File file = this.e;
this.f = file != null && (file.exists() || this.e.mkdirs());
if (eo.f()) {
eo.a("DC_Pro", "startup! prepared:" + this.f);
}
if (this.f) {
this.g = new a(looper);
this.v = System.currentTimeMillis() - 40000;
ef.a(this.g, 107, Constants.ASSEMBLE_PUSH_NETWORK_INTERVAL);
try {
this.f1854d.registerReceiver(this.C, new IntentFilter(IMessageCenter.MSG_SYS_CONNECTIVITY_ACTION));
} catch (Throwable th) {
if (eo.f()) {
eo.a("DC_Pro", "listenNetworkState: failed", th);
}
}
}
if (this.f && this.p) {
this.z = new cu(this.e);
this.z.a(looper);
}
if (this.q) {
this.A = new ct(this.e);
this.A.a(looper);
}
if (this.r) {
this.B = new cs();
this.B.a(looper);
}
eo.c("FC", "systemInfo," + fa.f());
eo.c("FC", "start," + (this.p ? 1 : 0) + Constants.ACCEPT_TIME_SEPARATOR_SP + (this.q ? 1 : 0) + Constants.ACCEPT_TIME_SEPARATOR_SP + (this.r ? 1 : 0));
return 0;
}
@Override
public final void a() {
try {
this.f1854d.unregisterReceiver(this.C);
} catch (Throwable unused) {
}
cu cuVar = this.z;
if (cuVar != null) {
cuVar.a(100L);
this.z = null;
}
ct ctVar = this.A;
if (ctVar != null) {
ctVar.a(100L);
this.A = null;
}
cs csVar = this.B;
if (csVar != null) {
csVar.e();
this.B = null;
}
if (this.f) {
ef.a(this.g, 104, 0L);
ef.a(this.g, 106, 0L);
this.v = 0L;
ef.a(this.g, 107, 0L);
ef.a(this.g, 105, 200L);
this.g = null;
}
}
public final void a(Location location) {
ct ctVar = this.A;
if (ctVar != null) {
ctVar.a(location);
}
cs csVar = this.B;
if (csVar != null) {
csVar.a(location);
}
}
public final synchronized void a(Location location, List<ScanResult> list, List<cq> list2) {
long currentTimeMillis = System.currentTimeMillis();
if (location != null && currentTimeMillis - location.getTime() <= DateUtils.TEN_SECOND) {
this.y = location;
this.x = list;
this.w = list2;
if (this.f) {
if (list == null) {
if (!eo.a(list2)) {
ef.a(this.g, 102, 0L);
}
} else if (!eo.a(list)) {
ef.a(this.g, 101, 0L);
}
}
}
}
public final void a(String str, String str2) {
if ("D_UP_INTERVAL".equals(str)) {
this.i = Math.max(900000L, Long.parseLong(str2));
return;
}
if ("D_UP_USE_HTTPS".equals(str)) {
cw.e = Boolean.parseBoolean(str2);
return;
}
if ("D_MAX_1F_SIZE".equals(str)) {
this.h = a(Long.parseLong(str2), FileUtil.LOCAL_REPORT_FILE_MAX_SIZE, 512000L);
return;
}
if ("D_NUM_UP".equals(str)) {
this.j = (int) a(Long.parseLong(str2), 1L, 5L);
return;
}
if ("D_MAX_BUF_WF".equals(str)) {
this.k = (int) a(Long.parseLong(str2), 5120L, 51200L);
return;
}
if ("D_MAX_FOLDER_SIZE".equals(str)) {
this.l = a(Long.parseLong(str2), 10485760L, 209715200L);
return;
}
if ("D_MAX_SIZE_UP_1DAY".equals(str)) {
this.m = Math.max(Long.parseLong(str2), 0L);
return;
}
if ("D_MAX_DAY_RENAME".equals(str)) {
this.n = a(Long.parseLong(str2), 1L, 5L) * 24 * 60 * 60 * 1000;
return;
}
if ("D_MAX_DAY_DELETE".equals(str)) {
this.o = a(Long.parseLong(str2), 1L, 30L) * 24 * 60 * 60 * 1000;
return;
}
if ("D_UP_WF_INFO".equals(str)) {
this.p = Boolean.parseBoolean(str2);
} else if ("D_UP_U_TRACK_INFO".equals(str)) {
this.q = Boolean.parseBoolean(str2);
} else if ("D_UP_GPS_FOR_NAVI".equals(str)) {
this.r = Boolean.parseBoolean(str2);
}
}
public final void a(List<ScanResult> list) {
cu cuVar = this.z;
if (cuVar == null || !cuVar.h() || eo.a(list)) {
return;
}
Message obtainMessage = cuVar.f().obtainMessage(102);
obtainMessage.obj = list;
cuVar.b(obtainMessage);
}
@Override
public final String b() {
return "DC_Pro";
}
}