Initial commit
This commit is contained in:
95
sources/com/baidu/uaq/agent/android/util/b.java
Normal file
95
sources/com/baidu/uaq/agent/android/util/b.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import com.baidu.uaq.agent.android.logging.a;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/* compiled from: CompressUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class b {
|
||||
private static final a a = com.baidu.uaq.agent.android.logging.b.a();
|
||||
|
||||
public static byte[] a(String str, String str2) {
|
||||
ByteArrayOutputStream byteArrayOutputStream;
|
||||
if (str == null || str.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
byteArrayOutputStream = null;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
byteArrayOutputStream = null;
|
||||
a(byteArrayOutputStream);
|
||||
throw th;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
|
||||
gZIPOutputStream.write(str.getBytes(str2));
|
||||
gZIPOutputStream.close();
|
||||
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
||||
a(byteArrayOutputStream);
|
||||
return byteArray;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
a(byteArrayOutputStream);
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
a.a("gzip compress exception: ", e);
|
||||
a(byteArrayOutputStream);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] a(String str) {
|
||||
Throwable th;
|
||||
ByteArrayOutputStream byteArrayOutputStream;
|
||||
Deflater deflater;
|
||||
try {
|
||||
deflater = new Deflater();
|
||||
deflater.setInput(str.getBytes());
|
||||
deflater.finish();
|
||||
byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
byteArrayOutputStream = null;
|
||||
}
|
||||
try {
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
while (!deflater.finished()) {
|
||||
int deflate = deflater.deflate(bArr);
|
||||
if (deflate <= 0) {
|
||||
a.a("HTTP request contains an incomplete payload");
|
||||
}
|
||||
byteArrayOutputStream.write(bArr, 0, deflate);
|
||||
}
|
||||
deflater.end();
|
||||
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
||||
a(byteArrayOutputStream);
|
||||
return byteArray;
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
a(byteArrayOutputStream);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Closeable closeable) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException unused) {
|
||||
a.a("Failed to close io.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
sources/com/baidu/uaq/agent/android/util/c.java
Normal file
17
sources/com/baidu/uaq/agent/android/util/c.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
/* compiled from: CustomException.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class c extends Exception {
|
||||
public c(String str) {
|
||||
this(str, null);
|
||||
}
|
||||
|
||||
public c(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
|
||||
public c(Throwable th) {
|
||||
super(th);
|
||||
}
|
||||
}
|
287
sources/com/baidu/uaq/agent/android/util/d.java
Normal file
287
sources/com/baidu/uaq/agent/android/util/d.java
Normal file
@@ -0,0 +1,287 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
/* compiled from: DeviceUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class d {
|
||||
private static final com.baidu.uaq.agent.android.logging.a a = com.baidu.uaq.agent.android.logging.b.a();
|
||||
private static String b = null;
|
||||
private static File c = new File(Environment.getDataDirectory(), "uaq_installation");
|
||||
|
||||
/* compiled from: DeviceUtil.java */
|
||||
public enum a {
|
||||
UNKNOWN,
|
||||
SMALL,
|
||||
NORMAL,
|
||||
LARGE,
|
||||
XLARGE
|
||||
}
|
||||
|
||||
public static a a(Context context) {
|
||||
int i = context.getResources().getConfiguration().screenLayout & 15;
|
||||
return i != 1 ? i != 2 ? i != 3 ? i > 3 ? a.XLARGE : a.UNKNOWN : a.LARGE : a.NORMAL : a.SMALL;
|
||||
}
|
||||
|
||||
@SuppressLint({"HardwareIds", "MissingPermission"})
|
||||
public static String b(Context context) {
|
||||
StringBuilder sb;
|
||||
if (TextUtils.isEmpty(b)) {
|
||||
b = c(context);
|
||||
try {
|
||||
try {
|
||||
if (TextUtils.isEmpty(b) || "000000000000000".equals(b)) {
|
||||
b = d(context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
a.a("Caught error while getPersistentUUID: ", e);
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e);
|
||||
if (TextUtils.isEmpty(b)) {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(b)) {
|
||||
sb = new StringBuilder();
|
||||
sb.append("TS");
|
||||
sb.append(System.currentTimeMillis());
|
||||
b = sb.toString();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
if (TextUtils.isEmpty(b)) {
|
||||
b = "TS" + System.currentTimeMillis();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@SuppressLint({"HardwareIds", "MissingPermission"})
|
||||
private static String c(Context context) {
|
||||
try {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
|
||||
if (telephonyManager != null) {
|
||||
b = telephonyManager.getDeviceId();
|
||||
}
|
||||
} catch (SecurityException unused) {
|
||||
a.a("Neither user nor current process has android.permission.READ_PHONE_STATE.");
|
||||
} catch (Exception e) {
|
||||
a.a("Caught error while getDeviceId: ", e);
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static String d(Context context) {
|
||||
c = new File(context.getFilesDir(), "uaq_installation");
|
||||
String a2 = a();
|
||||
if (!TextUtils.isEmpty(a2)) {
|
||||
b("UUIDRecovered");
|
||||
return a2;
|
||||
}
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
a.d("Created random UUID: " + uuid);
|
||||
com.baidu.uaq.agent.android.stats.a.b().a("Mobile/App/Install");
|
||||
a(uuid);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:20:0x0057 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:31:0x006c A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private static java.lang.String a() {
|
||||
/*
|
||||
java.io.File r0 = com.baidu.uaq.agent.android.util.d.c
|
||||
boolean r0 = r0.exists()
|
||||
if (r0 == 0) goto L7e
|
||||
r0 = 0
|
||||
java.io.BufferedReader r1 = new java.io.BufferedReader // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45
|
||||
java.io.FileReader r2 = new java.io.FileReader // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45
|
||||
java.io.File r3 = com.baidu.uaq.agent.android.util.d.c // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45
|
||||
r2.<init>(r3) // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45
|
||||
r1.<init>(r2) // Catch: java.lang.Throwable -> L3c java.lang.NullPointerException -> L41 org.json.JSONException -> L43 java.io.IOException -> L45
|
||||
java.lang.String r0 = r1.readLine() // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69
|
||||
org.json.JSONObject r2 = new org.json.JSONObject // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69
|
||||
r2.<init>(r0) // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69
|
||||
java.lang.String r0 = "uaq_uuid"
|
||||
java.lang.String r0 = r2.getString(r0) // Catch: java.lang.NullPointerException -> L36 org.json.JSONException -> L38 java.io.IOException -> L3a java.lang.Throwable -> L69
|
||||
r1.close() // Catch: java.io.IOException -> L28
|
||||
goto L80
|
||||
L28:
|
||||
r1 = move-exception
|
||||
com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a
|
||||
java.lang.String r3 = r1.getMessage()
|
||||
r2.a(r3)
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r1)
|
||||
goto L80
|
||||
L36:
|
||||
r0 = move-exception
|
||||
goto L49
|
||||
L38:
|
||||
r0 = move-exception
|
||||
goto L49
|
||||
L3a:
|
||||
r0 = move-exception
|
||||
goto L49
|
||||
L3c:
|
||||
r1 = move-exception
|
||||
r4 = r1
|
||||
r1 = r0
|
||||
r0 = r4
|
||||
goto L6a
|
||||
L41:
|
||||
r1 = move-exception
|
||||
goto L46
|
||||
L43:
|
||||
r1 = move-exception
|
||||
goto L46
|
||||
L45:
|
||||
r1 = move-exception
|
||||
L46:
|
||||
r4 = r1
|
||||
r1 = r0
|
||||
r0 = r4
|
||||
L49:
|
||||
com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a // Catch: java.lang.Throwable -> L69
|
||||
java.lang.String r3 = r0.getMessage() // Catch: java.lang.Throwable -> L69
|
||||
r2.a(r3) // Catch: java.lang.Throwable -> L69
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r0) // Catch: java.lang.Throwable -> L69
|
||||
if (r1 == 0) goto L7e
|
||||
r1.close() // Catch: java.io.IOException -> L5b
|
||||
goto L7e
|
||||
L5b:
|
||||
r0 = move-exception
|
||||
com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a
|
||||
java.lang.String r2 = r0.getMessage()
|
||||
r1.a(r2)
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r0)
|
||||
goto L7e
|
||||
L69:
|
||||
r0 = move-exception
|
||||
L6a:
|
||||
if (r1 == 0) goto L7d
|
||||
r1.close() // Catch: java.io.IOException -> L70
|
||||
goto L7d
|
||||
L70:
|
||||
r1 = move-exception
|
||||
com.baidu.uaq.agent.android.logging.a r2 = com.baidu.uaq.agent.android.util.d.a
|
||||
java.lang.String r3 = r1.getMessage()
|
||||
r2.a(r3)
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r1)
|
||||
L7d:
|
||||
throw r0
|
||||
L7e:
|
||||
java.lang.String r0 = ""
|
||||
L80:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.util.d.a():java.lang.String");
|
||||
}
|
||||
|
||||
private static void b(String str) {
|
||||
com.baidu.uaq.agent.android.stats.a b2 = com.baidu.uaq.agent.android.stats.a.b();
|
||||
if (b2 != null) {
|
||||
b2.a("Supportability/AgentHealth/" + str);
|
||||
return;
|
||||
}
|
||||
a.a("StatsEngine is null. " + str + " not recorded.");
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:20:0x0044 A[Catch: IOException -> 0x0048, TRY_ENTER, TRY_LEAVE, TryCatch #2 {IOException -> 0x0048, blocks: (B:8:0x0021, B:20:0x0044), top: B:2:0x0001 }] */
|
||||
/* JADX WARN: Type inference failed for: r0v0 */
|
||||
/* JADX WARN: Type inference failed for: r0v16 */
|
||||
/* JADX WARN: Type inference failed for: r0v17 */
|
||||
/* JADX WARN: Type inference failed for: r0v18 */
|
||||
/* JADX WARN: Type inference failed for: r0v19 */
|
||||
/* JADX WARN: Type inference failed for: r0v2 */
|
||||
/* JADX WARN: Type inference failed for: r0v3, types: [java.io.BufferedWriter] */
|
||||
/* JADX WARN: Type inference failed for: r0v5 */
|
||||
/* JADX WARN: Type inference failed for: r0v8 */
|
||||
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:35:0x0049 -> B:9:0x0055). Please report as a decompilation issue!!! */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private static void a(java.lang.String r5) {
|
||||
/*
|
||||
r0 = 0
|
||||
org.json.JSONObject r1 = new org.json.JSONObject // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
r1.<init>() // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
java.lang.String r2 = "uaq_uuid"
|
||||
r1.put(r2, r5) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
java.io.BufferedWriter r5 = new java.io.BufferedWriter // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
java.io.FileWriter r2 = new java.io.FileWriter // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
java.io.File r3 = com.baidu.uaq.agent.android.util.d.c // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
r2.<init>(r3) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
r5.<init>(r2) // Catch: java.lang.Throwable -> L31 org.json.JSONException -> L33 java.io.IOException -> L35
|
||||
java.lang.String r0 = r1.toString() // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c
|
||||
r5.write(r0) // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c
|
||||
r5.flush() // Catch: java.lang.Throwable -> L25 org.json.JSONException -> L2a java.io.IOException -> L2c
|
||||
r5.close() // Catch: java.io.IOException -> L48
|
||||
goto L55
|
||||
L25:
|
||||
r0 = move-exception
|
||||
r4 = r0
|
||||
r0 = r5
|
||||
r5 = r4
|
||||
goto L56
|
||||
L2a:
|
||||
r0 = move-exception
|
||||
goto L2d
|
||||
L2c:
|
||||
r0 = move-exception
|
||||
L2d:
|
||||
r4 = r0
|
||||
r0 = r5
|
||||
r5 = r4
|
||||
goto L36
|
||||
L31:
|
||||
r5 = move-exception
|
||||
goto L56
|
||||
L33:
|
||||
r5 = move-exception
|
||||
goto L36
|
||||
L35:
|
||||
r5 = move-exception
|
||||
L36:
|
||||
com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a // Catch: java.lang.Throwable -> L31
|
||||
java.lang.String r2 = r5.getMessage() // Catch: java.lang.Throwable -> L31
|
||||
r1.a(r2) // Catch: java.lang.Throwable -> L31
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r5) // Catch: java.lang.Throwable -> L31
|
||||
if (r0 == 0) goto L55
|
||||
r0.close() // Catch: java.io.IOException -> L48
|
||||
goto L55
|
||||
L48:
|
||||
r5 = move-exception
|
||||
com.baidu.uaq.agent.android.logging.a r0 = com.baidu.uaq.agent.android.util.d.a
|
||||
java.lang.String r1 = r5.getMessage()
|
||||
r0.a(r1)
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r5)
|
||||
L55:
|
||||
return
|
||||
L56:
|
||||
if (r0 == 0) goto L69
|
||||
r0.close() // Catch: java.io.IOException -> L5c
|
||||
goto L69
|
||||
L5c:
|
||||
r0 = move-exception
|
||||
com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.d.a
|
||||
java.lang.String r2 = r0.getMessage()
|
||||
r1.a(r2)
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(r0)
|
||||
L69:
|
||||
throw r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.util.d.a(java.lang.String):void");
|
||||
}
|
||||
}
|
70
sources/com/baidu/uaq/agent/android/util/e.java
Normal file
70
sources/com/baidu/uaq/agent/android/util/e.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import com.baidu.uaq.agent.android.logging.a;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/* compiled from: EncryptUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class e {
|
||||
static final /* synthetic */ boolean b = !e.class.desiredAssertionStatus();
|
||||
private static final a a = com.baidu.uaq.agent.android.logging.b.a();
|
||||
|
||||
public static String a(String str) throws NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException {
|
||||
if (str != null) {
|
||||
return a(a(b("587a0fb0c91ae061e66adbf2ec56f0b8"), str.getBytes()));
|
||||
}
|
||||
a.b("AES warning: content is null");
|
||||
return "";
|
||||
}
|
||||
|
||||
private static byte[] b(String str) {
|
||||
int length = str.length() / 2;
|
||||
byte[] bArr = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int i2 = i * 2;
|
||||
bArr[i] = Integer.valueOf(str.substring(i2, i2 + 2), 16).byteValue();
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
|
||||
private static byte[] a(byte[] bArr, byte[] bArr2) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
||||
Cipher a2 = a(1, bArr);
|
||||
if (b || a2 != null) {
|
||||
return a2.doFinal(bArr2);
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static Cipher a(int i, byte[] bArr) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(i, new SecretKeySpec(bArr, "AES"));
|
||||
return cipher;
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String a(byte[] bArr) {
|
||||
if (bArr == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer(bArr.length * 2);
|
||||
for (byte b2 : bArr) {
|
||||
a(stringBuffer, b2);
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
private static void a(StringBuffer stringBuffer, byte b2) {
|
||||
stringBuffer.append("0123456789ABCDEF".charAt((b2 >> 4) & 15));
|
||||
stringBuffer.append("0123456789ABCDEF".charAt(b2 & 15));
|
||||
}
|
||||
}
|
339
sources/com/baidu/uaq/agent/android/util/f.java
Normal file
339
sources/com/baidu/uaq/agent/android/util/f.java
Normal file
@@ -0,0 +1,339 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import android.content.Context;
|
||||
import com.baidu.uaq.agent.android.customtransmission.APMUploadConfigure;
|
||||
import com.baidu.uaq.agent.android.logging.a;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/* compiled from: MultiLogPersistentUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class f {
|
||||
private static final a d = com.baidu.uaq.agent.android.logging.b.a();
|
||||
private static String e = null;
|
||||
private final String a;
|
||||
private final ArrayList<String> b = new ArrayList<>();
|
||||
private Context c;
|
||||
|
||||
public f(Context context, String str) {
|
||||
this.c = context;
|
||||
this.a = str;
|
||||
c();
|
||||
}
|
||||
|
||||
private void a(String str, String str2, File file) {
|
||||
if (str.equals(APMUploadConfigure.APMUPLOADNAME)) {
|
||||
b(str2, file);
|
||||
} else {
|
||||
a(str2, file);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(String str, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
|
||||
fileOutputStream.write(str.getBytes());
|
||||
fileOutputStream.write(",".getBytes());
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e2);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean e(String str) {
|
||||
String b = b();
|
||||
try {
|
||||
File file = new File(b);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
File file2 = new File(b + str + "_ini");
|
||||
if (file2.exists()) {
|
||||
return true;
|
||||
}
|
||||
file2.createNewFile();
|
||||
if (this.b.contains(file2.getAbsolutePath())) {
|
||||
return true;
|
||||
}
|
||||
this.b.add(file2.getAbsolutePath());
|
||||
return true;
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> c(String str) {
|
||||
FileInputStream fileInputStream;
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
FileInputStream fileInputStream2 = null;
|
||||
try {
|
||||
try {
|
||||
fileInputStream = new FileInputStream(str);
|
||||
try {
|
||||
int available = fileInputStream.available();
|
||||
if (available > 0) {
|
||||
int i = 0;
|
||||
while (i < available) {
|
||||
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
|
||||
long readLong = dataInputStream.readLong();
|
||||
int i2 = (int) readLong;
|
||||
char[] cArr = new char[i2];
|
||||
for (int i3 = 0; i3 < readLong; i3++) {
|
||||
cArr[i3] = dataInputStream.readChar();
|
||||
}
|
||||
arrayList.add(new String(cArr, 0, i2));
|
||||
i = (int) (i + 8 + readLong);
|
||||
}
|
||||
}
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
return arrayList;
|
||||
} catch (EOFException unused) {
|
||||
fileInputStream2 = fileInputStream;
|
||||
d.d("read end");
|
||||
if (fileInputStream2 != null) {
|
||||
try {
|
||||
fileInputStream2.close();
|
||||
} catch (IOException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
} catch (IOException unused2) {
|
||||
fileInputStream2 = fileInputStream;
|
||||
d.d("read end");
|
||||
if (fileInputStream2 != null) {
|
||||
try {
|
||||
fileInputStream2.close();
|
||||
} catch (IOException e4) {
|
||||
e4.printStackTrace();
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e5) {
|
||||
e5.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (EOFException unused3) {
|
||||
} catch (IOException unused4) {
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public File d(String str) {
|
||||
File file = new File(b() + str + "_ini");
|
||||
if (file.exists() || e(str)) {
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(String str, String str2) {
|
||||
File d2 = d(str);
|
||||
if (d2 == null) {
|
||||
return;
|
||||
}
|
||||
if (d2.length() + str2.length() <= 10240) {
|
||||
a(str, str2, d2);
|
||||
return;
|
||||
}
|
||||
if (this.b.size() < 10) {
|
||||
a(d2, str2);
|
||||
return;
|
||||
}
|
||||
Collections.sort(this.b);
|
||||
String remove = this.b.remove(0);
|
||||
d.d("expire with file: " + remove);
|
||||
File file = new File(remove);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
a(d2, str2);
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:41:0x0072 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public java.lang.String b(java.lang.String r7) {
|
||||
/*
|
||||
r6 = this;
|
||||
r0 = 0
|
||||
java.io.File r1 = new java.io.File // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
r1.<init>(r7) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
boolean r2 = r1.exists() // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
if (r2 != 0) goto L2b
|
||||
java.lang.String r1 = r6.a // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
boolean r1 = r7.contains(r1) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
if (r1 != 0) goto L2a
|
||||
com.baidu.uaq.agent.android.logging.a r1 = com.baidu.uaq.agent.android.util.f.d // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
java.lang.StringBuilder r2 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
r2.<init>() // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
java.lang.String r3 = "log file not exists: "
|
||||
r2.append(r3) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
r2.append(r7) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
java.lang.String r7 = r2.toString() // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
r1.a(r7) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
L2a:
|
||||
return r0
|
||||
L2b:
|
||||
java.io.FileReader r7 = new java.io.FileReader // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
r7.<init>(r1) // Catch: java.lang.Throwable -> L5c java.io.IOException -> L5e
|
||||
java.lang.StringBuilder r1 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
r1.<init>() // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
r2 = 1024(0x400, float:1.435E-42)
|
||||
char[] r2 = new char[r2] // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
L39:
|
||||
int r3 = r7.read(r2) // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
r4 = -1
|
||||
if (r3 == r4) goto L45
|
||||
r4 = 0
|
||||
r1.append(r2, r4, r3) // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
goto L39
|
||||
L45:
|
||||
java.lang.String r0 = r1.toString() // Catch: java.lang.Throwable -> L52 java.io.IOException -> L57
|
||||
r7.close() // Catch: java.io.IOException -> L4d
|
||||
goto L51
|
||||
L4d:
|
||||
r7 = move-exception
|
||||
r7.printStackTrace()
|
||||
L51:
|
||||
return r0
|
||||
L52:
|
||||
r0 = move-exception
|
||||
r5 = r0
|
||||
r0 = r7
|
||||
r7 = r5
|
||||
goto L70
|
||||
L57:
|
||||
r1 = move-exception
|
||||
r5 = r1
|
||||
r1 = r7
|
||||
r7 = r5
|
||||
goto L60
|
||||
L5c:
|
||||
r7 = move-exception
|
||||
goto L70
|
||||
L5e:
|
||||
r7 = move-exception
|
||||
r1 = r0
|
||||
L60:
|
||||
r7.printStackTrace() // Catch: java.lang.Throwable -> L6e
|
||||
if (r1 == 0) goto L6d
|
||||
r1.close() // Catch: java.io.IOException -> L69
|
||||
goto L6d
|
||||
L69:
|
||||
r7 = move-exception
|
||||
r7.printStackTrace()
|
||||
L6d:
|
||||
return r0
|
||||
L6e:
|
||||
r7 = move-exception
|
||||
r0 = r1
|
||||
L70:
|
||||
if (r0 == 0) goto L7a
|
||||
r0.close() // Catch: java.io.IOException -> L76
|
||||
goto L7a
|
||||
L76:
|
||||
r0 = move-exception
|
||||
r0.printStackTrace()
|
||||
L7a:
|
||||
throw r7
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.util.f.b(java.lang.String):java.lang.String");
|
||||
}
|
||||
|
||||
private void a(File file, String str) {
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
int lastIndexOf = absolutePath.lastIndexOf(File.separator) + 1;
|
||||
if (lastIndexOf >= 0 && lastIndexOf <= absolutePath.length()) {
|
||||
String str2 = absolutePath.substring(0, lastIndexOf) + this.a + "_" + System.currentTimeMillis();
|
||||
file.renameTo(new File(str2));
|
||||
this.b.add(str2);
|
||||
a(this.a, str, file);
|
||||
return;
|
||||
}
|
||||
d.b("in toPersistentFile, StringIndexOutOfBoundsException happened!");
|
||||
}
|
||||
|
||||
private void c() {
|
||||
if (!this.b.isEmpty()) {
|
||||
this.b.clear();
|
||||
}
|
||||
File file = new File(b());
|
||||
e(this.a);
|
||||
String[] list = file.list();
|
||||
if (list == null || list.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (String str : list) {
|
||||
if (!this.b.contains(b() + str) && str.contains(this.a)) {
|
||||
this.b.add(b() + str);
|
||||
}
|
||||
}
|
||||
Collections.reverse(this.b);
|
||||
}
|
||||
|
||||
private void a(String str, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(fileOutputStream);
|
||||
d.d("writeToDefaultCustomFile log size:" + str.length());
|
||||
dataOutputStream.writeLong((long) str.length());
|
||||
dataOutputStream.writeChars(str);
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e2);
|
||||
}
|
||||
}
|
||||
|
||||
private String b() {
|
||||
if (e == null) {
|
||||
e = this.c.getFilesDir().getAbsolutePath() + "/apm/";
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
public boolean a(String str) {
|
||||
File file = new File(str);
|
||||
this.b.remove(str);
|
||||
if (file.exists()) {
|
||||
return file.delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ArrayList<String> a() {
|
||||
Collections.sort(this.b);
|
||||
return this.b;
|
||||
}
|
||||
}
|
30
sources/com/baidu/uaq/agent/android/util/g.java
Normal file
30
sources/com/baidu/uaq/agent/android/util/g.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* compiled from: NamedThreadFactory.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class g implements ThreadFactory {
|
||||
private final ThreadGroup a;
|
||||
private final String b;
|
||||
private final AtomicInteger c = new AtomicInteger(1);
|
||||
|
||||
public g(String str) {
|
||||
SecurityManager securityManager = System.getSecurityManager();
|
||||
this.a = securityManager == null ? Thread.currentThread().getThreadGroup() : securityManager.getThreadGroup();
|
||||
this.b = "APM_" + str + "-";
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public Thread newThread(Runnable runnable) {
|
||||
Thread thread = new Thread(this.a, runnable, this.b + this.c.getAndIncrement(), 0L);
|
||||
if (thread.isDaemon()) {
|
||||
thread.setDaemon(false);
|
||||
}
|
||||
if (thread.getPriority() != 5) {
|
||||
thread.setPriority(5);
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
}
|
51
sources/com/baidu/uaq/agent/android/util/h.java
Normal file
51
sources/com/baidu/uaq/agent/android/util/h.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.baidu.uaq.agent.android.UAQ;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.net.ssl.SSLException;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.conn.ConnectTimeoutException;
|
||||
|
||||
/* compiled from: NetworkErrorUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class h {
|
||||
static {
|
||||
com.baidu.uaq.agent.android.logging.b.a();
|
||||
UAQ.getInstance();
|
||||
}
|
||||
|
||||
public static int a(Exception exc) {
|
||||
if (exc instanceof ClientProtocolException) {
|
||||
return -1011;
|
||||
}
|
||||
if (exc instanceof UnknownHostException) {
|
||||
return -1006;
|
||||
}
|
||||
if ((exc instanceof SocketTimeoutException) || (exc instanceof ConnectTimeoutException)) {
|
||||
return -1001;
|
||||
}
|
||||
if (exc instanceof ConnectException) {
|
||||
return IMediaPlayer.MEDIA_ERROR_IO;
|
||||
}
|
||||
if (exc instanceof MalformedURLException) {
|
||||
return IMediaPlayer.MEDIA_ERROR_AUTH_FAILURE;
|
||||
}
|
||||
if (exc instanceof SocketException) {
|
||||
return -2001;
|
||||
}
|
||||
if (exc instanceof ProtocolException) {
|
||||
return -3001;
|
||||
}
|
||||
if (exc instanceof FileNotFoundException) {
|
||||
return -4001;
|
||||
}
|
||||
return !(exc instanceof SSLException) ? -1 : -1200;
|
||||
}
|
||||
}
|
142
sources/com/baidu/uaq/agent/android/util/i.java
Normal file
142
sources/com/baidu/uaq/agent/android/util/i.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.baidu.uaq.agent.android.logging.a;
|
||||
import com.ubt.jimu.blockly.feature.sensor.SensorObserver;
|
||||
import com.ubt.jimu.diy.model.CategoryModel;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/* compiled from: NetworkUtil.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class i {
|
||||
private static final a a = com.baidu.uaq.agent.android.logging.b.a();
|
||||
|
||||
private static String a(int i) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
return "GPRS";
|
||||
case 2:
|
||||
return "EDGE";
|
||||
case 3:
|
||||
return "UMTS";
|
||||
case 4:
|
||||
return "CDMA";
|
||||
case 5:
|
||||
return "EVDO rev 0";
|
||||
case 6:
|
||||
return "EVDO rev A";
|
||||
case 7:
|
||||
return "1xRTT";
|
||||
case 8:
|
||||
return "HSDPA";
|
||||
case 9:
|
||||
return "HSUPA";
|
||||
case 10:
|
||||
return "HSPA";
|
||||
case 11:
|
||||
return "IDEN";
|
||||
case 12:
|
||||
return "EVDO rev B";
|
||||
case 13:
|
||||
return SensorObserver.Compareration.OP_LESS_THAN;
|
||||
case 14:
|
||||
return "HRPD";
|
||||
case 15:
|
||||
return "HSPAP";
|
||||
default:
|
||||
return CategoryModel.unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public static String a(Context context) {
|
||||
NetworkInfo e;
|
||||
try {
|
||||
e = e(context);
|
||||
} catch (SecurityException unused) {
|
||||
}
|
||||
if (e == null || !a(e)) {
|
||||
return TransportFile.TYPE_NONE;
|
||||
}
|
||||
if (b(e)) {
|
||||
return f(context);
|
||||
}
|
||||
if (c(e)) {
|
||||
return "wifi";
|
||||
}
|
||||
a.b(MessageFormat.format("Unknown network type: {0} [{1}]", e.getTypeName(), Integer.valueOf(e.getType())));
|
||||
return CategoryModel.unknown;
|
||||
}
|
||||
|
||||
public static String b(Context context) {
|
||||
NetworkInfo e;
|
||||
try {
|
||||
e = e(context);
|
||||
} catch (SecurityException unused) {
|
||||
}
|
||||
if (e == null || !a(e)) {
|
||||
return TransportFile.TYPE_NONE;
|
||||
}
|
||||
if (c(e)) {
|
||||
return "wifi";
|
||||
}
|
||||
if (b(e)) {
|
||||
return a(e.getSubtype());
|
||||
}
|
||||
return CategoryModel.unknown;
|
||||
}
|
||||
|
||||
public static boolean c(Context context) {
|
||||
try {
|
||||
NetworkInfo e = e(context);
|
||||
return a(e) && e.getType() != 1;
|
||||
} catch (SecurityException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean d(Context context) {
|
||||
try {
|
||||
NetworkInfo e = e(context);
|
||||
return e != null && e.getType() == 1;
|
||||
} catch (SecurityException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static NetworkInfo e(Context context) throws SecurityException {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
|
||||
if (connectivityManager == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return connectivityManager.getActiveNetworkInfo();
|
||||
} catch (SecurityException e) {
|
||||
a.b("Cannot determine network state. Enable android.permission.ACCESS_NETWORK_STATE in your manifest.");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static String f(Context context) {
|
||||
String networkOperatorName = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName();
|
||||
return (networkOperatorName.equals("Android") && (Build.PRODUCT.equals("google_sdk") || Build.PRODUCT.equals("sdk") || Build.PRODUCT.equals("sdk_x86") || Build.FINGERPRINT.startsWith("generic"))) ? "wifi" : networkOperatorName;
|
||||
}
|
||||
|
||||
private static boolean c(NetworkInfo networkInfo) {
|
||||
int type = networkInfo.getType();
|
||||
return type == 1 || type == 9 || type == 6 || type == 7;
|
||||
}
|
||||
|
||||
private static boolean b(NetworkInfo networkInfo) {
|
||||
int type = networkInfo.getType();
|
||||
return type == 0 || type == 2 || type == 3 || type == 4 || type == 5;
|
||||
}
|
||||
|
||||
public static boolean a(NetworkInfo networkInfo) {
|
||||
return networkInfo != null && networkInfo.isConnected();
|
||||
}
|
||||
}
|
32
sources/com/baidu/uaq/agent/android/util/l.java
Normal file
32
sources/com/baidu/uaq/agent/android/util/l.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.baidu.uaq.agent.android.util;
|
||||
|
||||
import com.baidu.uaq.agent.android.logging.a;
|
||||
import java.util.Random;
|
||||
|
||||
/* compiled from: Util.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class l {
|
||||
private static final Random a = new Random();
|
||||
private static final a b = com.baidu.uaq.agent.android.logging.b.a();
|
||||
|
||||
public static void a(String str) {
|
||||
int length = str.length();
|
||||
int i = 2000;
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
while (i2 < 100) {
|
||||
if (length <= i) {
|
||||
b.d(str.substring(i3, length));
|
||||
return;
|
||||
}
|
||||
b.d(str.substring(i3, i));
|
||||
i2++;
|
||||
i3 = i;
|
||||
i += 2000;
|
||||
}
|
||||
}
|
||||
|
||||
public static Random a() {
|
||||
return a;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user