xiaodi8 v1.0.0版本的 MD5 值为:6b857c57f508176c5ba1afb422bbb5a9
以下内容为反编译后的 e.java 源代码,内容仅作参考
package c.t.m.g;
import android.annotation.SuppressLint;
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.g.j3;
import com.luck.picture.lib.config.FileSizeUnit;
import com.tencent.map.geolocation.util.DateUtils;
import io.github.inflationx.calligraphy3.BuildConfig;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Collection;
import java.util.Date;
import java.util.List;
public class e extends d2 {
public static final String z = j.b() + i3.a(e.class.getName(), "SHA-256").substring(0, 8);
public Context f3346c;
public final File f3347d;
public boolean f3348e;
public volatile Handler f3349f;
public long f3350g;
public long f3351h;
public int i;
public int j;
public long k;
public long l;
public long m;
public long n;
public boolean o;
public boolean p;
public boolean q;
public long r;
public volatile List<d> s;
public volatile List<ScanResult> t;
public volatile Location u;
public h v;
public g w;
public f x;
public BroadcastReceiver y;
public class a extends BroadcastReceiver {
public a() {
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null && "android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
try {
boolean booleanExtra = intent.getBooleanExtra("noConnectivity", false);
if (g3.a()) {
String str = "intent:" + intent + ",";
}
if (booleanExtra) {
return;
}
c3.a(e.this.f3349f, 107, 2000L);
if (e.this.w == null) {
} else {
e.this.w.c(2000L);
}
} catch (Throwable unused) {
}
}
}
}
public class b implements Runnable {
public final File f3353a;
public final String f3354b;
public class a implements t1 {
public a() {
}
@Override
public void a(String str) {
String str2 = "upload error," + str;
}
@Override
public void b(String str) {
b.this.f3353a.delete();
if (g3.a()) {
String str2 = "upload " + b.this.f3353a.getName() + " succeed, then delete.";
}
}
}
public b(e eVar, File file, String str) {
this.f3353a = file;
this.f3354b = str;
}
@Override
public void run() {
try {
byte[] b2 = z2.b(this.f3353a);
if (m3.a(b2)) {
this.f3353a.delete();
if (g3.a()) {
String str = "file " + this.f3353a.getName() + " is empty, then delete.";
return;
}
return;
}
j.k.a(this.f3354b, b2, new a());
} catch (Throwable unused) {
if (g3.a()) {
String str2 = "upload error,url=" + this.f3354b;
}
}
}
}
public e(Context context, String str) {
this(context, new File(str + "/f_c"));
}
@Override
public String a() {
return "DC_Pro";
}
public e(Context context, File file) {
this.f3346c = null;
this.f3350g = 102400L;
this.f3351h = DateUtils.ONE_HOUR;
this.i = 1;
this.j = 25600;
this.k = 104857600L;
this.l = 10485760L;
this.m = 259200000L;
this.n = 2592000000L;
this.o = true;
this.p = false;
this.q = false;
this.r = 0L;
this.y = new a();
this.f3346c = context;
this.f3347d = file;
this.f3348e = false;
}
@Override
public int b(Looper looper) {
i();
File file = this.f3347d;
this.f3348e = file != null && (file.exists() || this.f3347d.mkdirs());
if (g3.a()) {
String str = "startup! prepared:" + this.f3348e;
}
if (this.f3348e) {
this.f3349f = new c(looper);
this.r = System.currentTimeMillis() - 40000;
c3.a(this.f3349f, 107, 300000L);
try {
this.f3346c.registerReceiver(this.y, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
} catch (Throwable unused) {
g3.a();
}
}
if (this.f3348e && this.o) {
h hVar = new h(this.f3347d);
this.v = hVar;
hVar.b(looper);
}
if (this.p) {
g gVar = new g(this.f3347d);
this.w = gVar;
gVar.b(looper);
}
if (this.q) {
f fVar = new f();
this.x = fVar;
fVar.b(looper);
}
g3.a("FC", "systemInfo," + q3.a() + "," + q3.k());
g3.a("FC", "start," + k3.a(this.o) + "," + k3.a(this.p) + "," + k3.a(this.q));
return 0;
}
@Override
public void d() {
try {
this.f3346c.unregisterReceiver(this.y);
} catch (Throwable unused) {
}
h hVar = this.v;
if (hVar != null) {
hVar.a(100L);
this.v = null;
}
g gVar = this.w;
if (gVar != null) {
gVar.a(100L);
this.w = null;
}
f fVar = this.x;
if (fVar != null) {
fVar.f();
this.x = null;
}
if (g()) {
c3.b(this.f3349f, 104);
c3.b(this.f3349f, 106);
this.r = 0L;
c3.b(this.f3349f, 107);
c3.a(this.f3349f, 105, 200L);
this.f3349f = null;
}
}
public final boolean g() {
return this.f3348e;
}
public final void i() {
this.s = null;
this.t = null;
this.u = null;
this.r = 0L;
}
public void a(String str, String str2) {
if ("D_UP_INTERVAL".equals(str)) {
this.f3351h = Math.max(900000L, Long.parseLong(str2));
return;
}
if ("D_UP_USE_HTTPS".equals(str)) {
j.f3489e = Boolean.parseBoolean(str2);
return;
}
if ("D_MAX_1F_SIZE".equals(str)) {
this.f3350g = a(Long.parseLong(str2), 10240L, 512000L);
return;
}
if ("D_NUM_UP".equals(str)) {
this.i = (int) a(Long.parseLong(str2), 1L, 5L);
return;
}
if ("D_MAX_BUF_WF".equals(str)) {
this.j = (int) a(Long.parseLong(str2), 5120L, 51200L);
return;
}
if ("D_MAX_FOLDER_SIZE".equals(str)) {
this.k = a(Long.parseLong(str2), 10485760L, 209715200L);
return;
}
if ("D_MAX_SIZE_UP_1DAY".equals(str)) {
this.l = Math.max(Long.parseLong(str2), 0L);
return;
}
if ("D_MAX_DAY_RENAME".equals(str)) {
this.m = a(Long.parseLong(str2), 1L, 5L) * 24 * 60 * 60 * 1000;
return;
}
if ("D_MAX_DAY_DELETE".equals(str)) {
this.n = a(Long.parseLong(str2), 1L, 30L) * 24 * 60 * 60 * 1000;
return;
}
if ("D_UP_WF_INFO".equals(str)) {
this.o = Boolean.parseBoolean(str2);
} else if ("D_UP_U_TRACK_INFO".equals(str)) {
this.p = Boolean.parseBoolean(str2);
} else if ("D_UP_GPS_FOR_NAVI".equals(str)) {
this.q = Boolean.parseBoolean(str2);
}
}
public final long a(long j, long j2, long j3) {
return Math.max(j2, Math.min(j, j3));
}
public class c extends Handler {
public File f3356a;
public BufferedOutputStream f3357b;
public StringBuffer f3358c;
public String f3359d;
public long f3360e;
public c(Looper looper) {
super(looper);
this.f3359d = BuildConfig.FLAVOR;
this.f3360e = 0L;
}
public final void a(Message message) {
File file;
int i = message.what;
switch (i) {
case 101:
case 102:
try {
a(i);
return;
} catch (Throwable unused) {
return;
}
case 103:
if (e.this.g()) {
String absolutePath = e.this.f3347d.getAbsolutePath();
if (a(absolutePath)) {
return;
}
a(absolutePath.replaceAll("f_c", "d_c"));
return;
}
return;
case 104:
b();
return;
case 105:
try {
f();
StringBuffer stringBuffer = this.f3358c;
if (stringBuffer != null) {
stringBuffer.setLength(0);
}
} catch (Throwable unused2) {
}
this.f3356a = null;
z2.a(this.f3357b);
a(e.this.n, e.this.k);
removeCallbacksAndMessages(null);
return;
case 106:
a();
if (e.this.f3347d == null || (file = this.f3356a) == null || !file.exists()) {
return;
}
f();
long longValue = ((Long) p3.a("LocationSDK", "log_fc_create", (Object) 0L)).longValue();
long currentTimeMillis = System.currentTimeMillis();
if (g3.a()) {
String str = "desFileLen=" + this.f3356a.length() + ",maxFileSize=" + c() + ",curT=" + currentTimeMillis + ",createT=" + longValue + ",maxTimeRename:" + e.this.m;
}
if (this.f3356a.length() > c() || currentTimeMillis - longValue > e.this.m) {
e();
a(e.this.n, e.this.k);
if (j.f3490f) {
sendEmptyMessage(107);
return;
}
return;
}
return;
case 107:
removeMessages(107);
e eVar = e.this;
eVar.a(eVar.f3349f);
c3.a(e.this.f3349f, 107, e.this.f3351h);
return;
default:
return;
}
}
public final void b() {
try {
BufferedOutputStream bufferedOutputStream = this.f3357b;
if (bufferedOutputStream != null) {
bufferedOutputStream.flush();
}
} catch (Throwable unused) {
this.f3356a = null;
z2.a(this.f3357b);
}
}
public final long c() {
long j = j.f3490f ? 51200L : 512000L;
return e.this.f3350g > j ? j : e.this.f3350g;
}
public final File d() {
File file = e.this.f3347d;
if (!file.exists()) {
file.mkdirs();
}
return new File(file, e.z);
}
public final void e() {
b();
File file = this.f3356a;
if (file == null || file.length() < FileSizeUnit.KB) {
return;
}
z2.a(this.f3357b);
this.f3357b = null;
a(4, this.f3356a);
this.f3356a = null;
p3.b("LocationSDK", "log_fc_create", (Object) 0L);
}
public final void f() {
StringBuffer stringBuffer = this.f3358c;
if (stringBuffer == null || stringBuffer.length() == 0 || this.f3357b == null) {
return;
}
byte[] a2 = l.a(this.f3358c.toString());
if (g3.a()) {
StringBuilder sb = new StringBuilder();
sb.append("write buf to file:buf:");
sb.append(this.f3358c.length());
sb.append(",enc:");
sb.append(a2 == null ? 0 : a2.length);
sb.toString();
}
this.f3358c.setLength(0);
if (a2 == null || a2.length == 0) {
return;
}
try {
this.f3357b.write(a2);
this.f3357b.write(36);
this.f3357b.flush();
} catch (Throwable unused) {
this.f3356a = null;
z2.a(this.f3357b);
}
}
@Override
public void handleMessage(Message message) {
try {
if (g3.a()) {
String str = "handleMessage:" + message.what;
}
a(message);
} catch (Throwable unused) {
g3.a();
}
}
public final 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) {
long currentTimeMillis = System.currentTimeMillis();
int i = e.this.i;
int i2 = 0;
while (true) {
boolean z = true;
if (i2 >= fileArr.length || i <= 0) {
break;
}
File file2 = fileArr[i2];
String name = (file2 != null && file2.exists() && file2.isFile()) ? file2.getName() : BuildConfig.FLAVOR;
if (name.startsWith("dc") || name.startsWith("fc")) {
if (str.endsWith("d_c") && (file2.length() == 0 || currentTimeMillis - file2.lastModified() > e.this.n)) {
file2.delete();
} else {
boolean z2 = (name.startsWith(j.b()) && name.endsWith(".enc")) || (name.startsWith("fc2") || name.startsWith("fc3"));
if (z2) {
z = z2;
} else {
if (g3.a()) {
String str2 = str + ",has no " + j.b() + "***.enc files!!!";
}
if (!name.startsWith("dc") || System.currentTimeMillis() - file2.lastModified() <= 172800000) {
z = false;
}
}
if (z && a(file2.length())) {
if (g3.a()) {
String str3 = "upload:" + file2.getName() + ",len=" + file2.length();
}
int a2 = j.a(name);
if (a2 > 0) {
String a3 = j.a(a2);
if (!TextUtils.isEmpty(a3)) {
if (!j.f3489e) {
a3 = a3.replace("https:", "http:");
}
e.this.a(file2, a3);
i--;
}
}
}
}
}
i2++;
}
return i != e.this.i;
}
if (fileArr != null && str.endsWith("d_c")) {
file.delete();
}
return false;
}
public final void a(int i) {
String str;
File file;
a();
if (!m3.a((Collection) e.this.s)) {
long j = ((d) e.this.s.get(0)).f3326e;
r1 = this.f3360e != j;
this.f3360e = j;
}
if (i == 102) {
str = k.a(j.i, e.this.u, null, e.this.s, r1);
} else {
if (i == 101) {
List list = e.this.t;
if (!m3.a((Collection) list)) {
str = k.a(j.i, e.this.u, list, e.this.s, r1);
}
}
str = BuildConfig.FLAVOR;
}
if (this.f3357b == null || TextUtils.isEmpty(str) || str.length() < 25) {
return;
}
String a2 = i3.a(str.substring(22).getBytes(), "SHA-256");
if (this.f3359d.equals(a2)) {
return;
}
this.f3359d = a2;
if (this.f3358c == null) {
this.f3358c = new StringBuffer(e.this.j);
}
StringBuffer stringBuffer = this.f3358c;
stringBuffer.append(str);
stringBuffer.append("\n");
if (this.f3358c.length() > e.this.j || ((file = this.f3356a) != null && file.length() == 0)) {
f();
if (this.f3356a.length() > c()) {
c3.b(e.this.f3349f, 106);
}
}
if (g3.a()) {
String str2 = "write:" + str.substring(0, 60) + "***,len=" + str.length();
}
}
public final void a() {
File file = this.f3356a;
if (file == null || !file.exists() || this.f3357b == null || !e.z.equals(this.f3356a.getName())) {
File d2 = d();
this.f3356a = d2;
try {
boolean exists = d2.exists();
this.f3357b = new BufferedOutputStream(new FileOutputStream(this.f3356a, true), 1024);
if (exists) {
return;
}
p3.b("LocationSDK", "log_fc_create", Long.valueOf(System.currentTimeMillis()));
} catch (Throwable unused) {
}
}
}
public final boolean a(long j) {
try {
SharedPreferences a2 = p3.a("LocationSDK");
SharedPreferences.Editor edit = a2.edit();
String string = a2.getString("log_up_fc_date", BuildConfig.FLAVOR);
long j2 = a2.getLong("log_up_fc_size", 0L);
String format = t2.b("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 > e.this.l) {
return false;
}
edit.putLong("log_up_fc_size", j + j2);
}
edit.apply();
return true;
} catch (Throwable unused) {
return true;
}
}
public final void a(int i, File file) {
try {
if (file.isFile()) {
File file2 = new File(file.getAbsolutePath() + "." + System.currentTimeMillis() + ".enc");
if (i == 4) {
byte[] b2 = z2.b(file);
if (!m3.a(b2)) {
byte[] a2 = r2.a(b2);
if (!m3.a(a2)) {
FileOutputStream fileOutputStream = new FileOutputStream(file2, true);
fileOutputStream.write(a2);
fileOutputStream.close();
file.delete();
}
}
} else {
file.renameTo(file2);
}
if (g3.a()) {
String str = "rename:" + file.getName() + " to " + file2.getName();
}
}
} catch (Throwable unused) {
if (g3.a()) {
String str2 = "rename:" + file.getName() + " error.";
}
}
}
public final void a(long j, long j2) {
File file = null;
File[] listFiles = e.this.f3347d == null ? null : e.this.f3347d.listFiles();
if (listFiles == null || listFiles.length == 0) {
return;
}
long currentTimeMillis = System.currentTimeMillis();
long j3 = 0;
for (File file2 : listFiles) {
if (file2.exists() && file2.isFile() && !e.z.equals(file2.getName())) {
if (currentTimeMillis - file2.lastModified() <= j && file2.length() != 0) {
String name = file2.getName();
if (currentTimeMillis - file2.lastModified() > 172800000 && !name.endsWith(".enc") && name.startsWith(j.b())) {
a(j.a(name), file2);
} else {
j3 += file2.length();
if (file == null || file.lastModified() > file2.lastModified()) {
file = file2;
}
}
} else {
if (g3.a()) {
String str = "delete expired file:" + file2.getName() + ",len:" + file2.length();
}
file2.delete();
}
}
}
if (j3 < j2 || file == null) {
return;
}
if (g3.a()) {
String str2 = "too big folder size:" + j3 + ", delete " + file.getName() + ",size:" + file.length();
}
file.delete();
}
}
public void a(int i, Location location) {
g gVar = this.w;
if (gVar != null) {
gVar.a(i, location);
}
f fVar = this.x;
if (fVar != null) {
fVar.a(i, location);
}
}
public void a(long j, int i, double d2, double d3, double d4) {
g gVar = this.w;
if (gVar != null) {
gVar.a(j, i, d2, d3, d4);
}
}
public void a(List<ScanResult> list) {
h hVar = this.v;
if (hVar != null) {
hVar.a(list);
}
}
public void a(int i, long j, Object obj) {
g gVar;
if ((i == 1 || i == 2) && (gVar = this.w) != null) {
gVar.a(i, j, obj);
}
}
@SuppressLint({"MissingPermission"})
public final void a(Handler handler) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.r < DateUtils.ONE_MINUTE) {
return;
}
c3.b(handler, 106);
try {
j3.a b2 = j3.b();
boolean z2 = true;
if (b2 == j3.a.NETWORK_NONE) {
z2 = false;
} else if (b2 == j3.a.NETWORK_MOBILE) {
boolean z3 = j.f3490f;
if (!z3 && j.f3491g) {
long longValue = ((Long) p3.a("LocationSDK", "log_fc_up_in_m", Long.valueOf(currentTimeMillis))).longValue();
if (currentTimeMillis - longValue > DateUtils.ONE_DAY) {
p3.b("LocationSDK", "log_fc_up_in_m", Long.valueOf(currentTimeMillis));
if (g3.a()) {
String str = "upload in mobile once today. lastUpT=" + longValue + ",curT=" + currentTimeMillis;
}
}
}
z2 = z3;
}
if (g3.a()) {
String str2 = "network status:" + b2 + ",isUpload:" + z2;
}
if (z2 && g()) {
c3.b(handler, 103);
this.r = currentTimeMillis;
if (g3.a()) {
String str3 = "send upload msg, last upload time:" + this.r;
}
}
} catch (Throwable unused) {
}
}
public synchronized void a(Location location, List<ScanResult> list, List<d> list2) {
long currentTimeMillis = System.currentTimeMillis();
if (location != null && currentTimeMillis - location.getTime() <= DateUtils.TEN_SECOND) {
this.u = location;
this.t = list;
this.s = list2;
if (g()) {
if (list == null) {
if (!m3.a((Collection) list2)) {
c3.b(this.f3349f, 102);
}
} else if (!m3.a((Collection) list)) {
c3.b(this.f3349f, 101);
}
}
}
}
public final void a(File file, String str) {
if (TextUtils.isEmpty(str)) {
return;
}
a3.a("th_loc_task_t_consume", new b(this, file, str));
}
}