Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
package com.unity3d.ads.misc;
import android.text.TextUtils;
import com.unity3d.ads.log.DeviceLog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class JsonStorage {
private JSONObject _data;
private synchronized void createObjectTree(String str) {
String[] split = str.split("\\.");
JSONObject jSONObject = this._data;
if (str.length() == 0) {
return;
}
for (int i = 0; i < split.length; i++) {
if (jSONObject.has(split[i])) {
try {
jSONObject = jSONObject.getJSONObject(split[i]);
} catch (Exception e) {
DeviceLog.exception("Couldn't get existing JSONObject", e);
}
} else {
try {
jSONObject = jSONObject.put(split[i], new JSONObject()).getJSONObject(split[i]);
} catch (Exception e2) {
DeviceLog.exception("Couldn't create new JSONObject", e2);
}
}
}
}
private synchronized Object findObject(String str) {
String[] split = str.split("\\.");
JSONObject jSONObject = this._data;
if (str.length() == 0) {
return jSONObject;
}
for (int i = 0; i < split.length; i++) {
if (!jSONObject.has(split[i])) {
return null;
}
try {
jSONObject = jSONObject.getJSONObject(split[i]);
} catch (Exception e) {
DeviceLog.exception("Couldn't read JSONObject: " + split[i], e);
return null;
}
}
return jSONObject;
}
private synchronized String getParentObjectTreeFor(String str) {
ArrayList arrayList;
arrayList = new ArrayList(Arrays.asList(str.split("\\.")));
arrayList.remove(arrayList.size() - 1);
return TextUtils.join(".", arrayList.toArray());
}
public synchronized void clearData() {
this._data = null;
}
public synchronized boolean delete(String str) {
JSONObject jSONObject;
if (this._data == null) {
DeviceLog.error("Data is NULL, readStorage probably not called");
return false;
}
String[] split = str.split("\\.");
return (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject) || (jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str))) == null || jSONObject.remove(split[split.length - 1]) == null) ? false : true;
}
public synchronized Object get(String str) {
JSONObject jSONObject;
Object obj = null;
if (this._data == null) {
DeviceLog.error("Data is NULL, readStorage probably not called");
return null;
}
String[] split = str.split("\\.");
if (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject) || (jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str))) == null) {
return null;
}
try {
if (jSONObject.has(split[split.length - 1])) {
obj = jSONObject.get(split[split.length - 1]);
}
} catch (Exception e) {
DeviceLog.exception("Error getting data", e);
}
return obj;
}
public synchronized JSONObject getData() {
return this._data;
}
public synchronized List<String> getKeys(String str, boolean z) {
List<String> list;
if (!(get(str) instanceof JSONObject)) {
return null;
}
JSONObject jSONObject = (JSONObject) get(str);
ArrayList arrayList = new ArrayList();
if (jSONObject != null) {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
if (z) {
list = getKeys(str + "." + next, z);
} else {
list = null;
}
arrayList.add(next);
if (list != null) {
Iterator<String> it = list.iterator();
while (it.hasNext()) {
arrayList.add(next + "." + it.next());
}
}
}
}
return arrayList;
}
public synchronized boolean hasData() {
if (this._data != null) {
if (this._data.length() > 0) {
return true;
}
}
return false;
}
public synchronized boolean initData() {
if (this._data != null) {
return false;
}
this._data = new JSONObject();
return true;
}
public synchronized boolean set(String str, Object obj) {
if (this._data != null && str != null && str.length() != 0 && obj != null) {
createObjectTree(getParentObjectTreeFor(str));
if (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject)) {
DeviceLog.debug("Cannot set subvalue to an object that is not JSONObject");
return false;
}
JSONObject jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str));
String[] split = str.split("\\.");
if (jSONObject != null) {
try {
jSONObject.put(split[split.length - 1], obj);
} catch (JSONException e) {
DeviceLog.exception("Couldn't set value", e);
return false;
}
}
return true;
}
DeviceLog.error("Storage not properly initialized or incorrect parameters:" + this._data + ", " + str + ", " + obj);
return false;
}
public synchronized void setData(JSONObject jSONObject) {
this._data = jSONObject;
}
}

View File

@@ -0,0 +1,276 @@
package com.unity3d.ads.misc;
import android.os.Handler;
import android.os.Looper;
import com.ubt.jimu.base.util.FileUtil;
import com.unity3d.ads.log.DeviceLog;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class Utilities {
public static String Sha256(String str) {
return Sha256(str.getBytes());
}
public static JSONObject mergeJsonObjects(JSONObject jSONObject, JSONObject jSONObject2) throws JSONException {
if (jSONObject == null) {
return jSONObject2;
}
if (jSONObject2 == null) {
return jSONObject;
}
JSONObject jSONObject3 = new JSONObject();
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
jSONObject3.put(next, jSONObject2.get(next));
}
Iterator<String> keys2 = jSONObject.keys();
while (keys2.hasNext()) {
String next2 = keys2.next();
if (jSONObject3.has(next2) && (jSONObject3.get(next2) instanceof JSONObject) && (jSONObject.get(next2) instanceof JSONObject)) {
jSONObject3.put(next2, mergeJsonObjects(jSONObject.getJSONObject(next2), jSONObject3.getJSONObject(next2)));
} else {
jSONObject3.put(next2, jSONObject.get(next2));
}
}
return jSONObject3;
}
/* JADX WARN: Removed duplicated region for block: B:24:0x0044 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:29:0x0038 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 static java.lang.String readFile(java.io.File r4) {
/*
r0 = 0
if (r4 != 0) goto L4
return r0
L4:
boolean r1 = r4.exists()
if (r1 == 0) goto L4f
boolean r1 = r4.canRead()
if (r1 == 0) goto L4f
java.io.FileReader r1 = new java.io.FileReader // Catch: java.lang.Exception -> L2e
r1.<init>(r4) // Catch: java.lang.Exception -> L2e
java.io.BufferedReader r4 = new java.io.BufferedReader // Catch: java.lang.Exception -> L2b
r4.<init>(r1) // Catch: java.lang.Exception -> L2b
java.lang.String r2 = ""
L1c:
java.lang.String r3 = r4.readLine() // Catch: java.lang.Exception -> L29
if (r3 == 0) goto L27
java.lang.String r2 = r2.concat(r3) // Catch: java.lang.Exception -> L29
goto L1c
L27:
r0 = r2
goto L36
L29:
r2 = move-exception
goto L31
L2b:
r2 = move-exception
r4 = r0
goto L31
L2e:
r2 = move-exception
r4 = r0
r1 = r4
L31:
java.lang.String r3 = "Problem reading file"
com.unity3d.ads.log.DeviceLog.exception(r3, r2)
L36:
if (r4 == 0) goto L42
r4.close() // Catch: java.lang.Exception -> L3c
goto L42
L3c:
r4 = move-exception
java.lang.String r2 = "Couldn't close BufferedReader"
com.unity3d.ads.log.DeviceLog.exception(r2, r4)
L42:
if (r1 == 0) goto L4e
r1.close() // Catch: java.lang.Exception -> L48
goto L4e
L48:
r4 = move-exception
java.lang.String r1 = "Couldn't close FileReader"
com.unity3d.ads.log.DeviceLog.exception(r1, r4)
L4e:
return r0
L4f:
java.lang.String r4 = "File did not exist or couldn't be read"
com.unity3d.ads.log.DeviceLog.error(r4)
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.misc.Utilities.readFile(java.io.File):java.lang.String");
}
public static byte[] readFileBytes(File file) throws IOException {
if (file == null) {
return null;
}
FileInputStream fileInputStream = new FileInputStream(file);
byte[] bArr = new byte[(int) file.length()];
int i = 0;
int i2 = FileUtil.ZIP_BUFFER_SIZE;
long length = file.length();
long j = FileUtil.ZIP_BUFFER_SIZE;
if (length < j) {
i2 = (int) file.length();
}
while (true) {
int read = fileInputStream.read(bArr, i, i2);
if (read <= 0) {
fileInputStream.close();
return bArr;
}
i += read;
if (file.length() - i < j) {
i2 = ((int) file.length()) - i;
}
}
}
public static void runOnUiThread(Runnable runnable) {
runOnUiThread(runnable, 0L);
}
public static String toHexString(byte[] bArr) {
String str = "";
for (byte b : bArr) {
int i = b & 255;
if (i <= 15) {
str = str + "0";
}
str = str + Integer.toHexString(i);
}
return str;
}
/* JADX WARN: Removed duplicated region for block: B:15:0x003b */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static boolean writeFile(java.io.File r5, java.lang.String r6) {
/*
java.lang.String r0 = "Error closing FileOutputStream"
r1 = 0
if (r5 != 0) goto L6
return r1
L6:
r2 = 0
r3 = 1
java.io.FileOutputStream r4 = new java.io.FileOutputStream // Catch: java.lang.Throwable -> L27 java.lang.Exception -> L29
r4.<init>(r5) // Catch: java.lang.Throwable -> L27 java.lang.Exception -> L29
byte[] r6 = r6.getBytes() // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
r4.write(r6) // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
r4.flush() // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
r4.close() // Catch: java.lang.Exception -> L1b
goto L1f
L1b:
r6 = move-exception
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
L1f:
r1 = 1
goto L39
L21:
r5 = move-exception
r2 = r4
goto L54
L24:
r6 = move-exception
r2 = r4
goto L2a
L27:
r5 = move-exception
goto L54
L29:
r6 = move-exception
L2a:
java.lang.String r3 = "Could not write file"
com.unity3d.ads.log.DeviceLog.exception(r3, r6) // Catch: java.lang.Throwable -> L27
if (r2 == 0) goto L39
r2.close() // Catch: java.lang.Exception -> L35
goto L39
L35:
r6 = move-exception
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
L39:
if (r1 == 0) goto L53
java.lang.StringBuilder r6 = new java.lang.StringBuilder
r6.<init>()
java.lang.String r0 = "Wrote file: "
r6.append(r0)
java.lang.String r5 = r5.getAbsolutePath()
r6.append(r5)
java.lang.String r5 = r6.toString()
com.unity3d.ads.log.DeviceLog.debug(r5)
L53:
return r1
L54:
if (r2 == 0) goto L5e
r2.close() // Catch: java.lang.Exception -> L5a
goto L5e
L5a:
r6 = move-exception
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
L5e:
throw r5
*/
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.misc.Utilities.writeFile(java.io.File, java.lang.String):boolean");
}
public static String Sha256(byte[] bArr) {
if (bArr == null) {
return null;
}
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(bArr, 0, bArr.length);
return toHexString(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
DeviceLog.exception("SHA-256 algorithm not found", e);
return null;
}
}
public static void runOnUiThread(Runnable runnable, long j) {
Handler handler = new Handler(Looper.getMainLooper());
if (j > 0) {
handler.postDelayed(runnable, j);
} else {
handler.post(runnable);
}
}
public static String Sha256(InputStream inputStream) throws IOException {
if (inputStream == null) {
return null;
}
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
byte[] bArr = new byte[FileUtil.ZIP_BUFFER_SIZE];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
messageDigest.update(bArr, 0, read);
} else {
return toHexString(messageDigest.digest());
}
}
} catch (NoSuchAlgorithmException e) {
DeviceLog.exception("SHA-256 algorithm not found", e);
return null;
}
}
}

View File

@@ -0,0 +1,30 @@
package com.unity3d.ads.misc;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import com.unity3d.ads.log.DeviceLog;
/* loaded from: classes2.dex */
public class ViewUtilities {
public static void removeViewFromParent(View view) {
if (view == null || view.getParent() == null) {
return;
}
try {
((ViewGroup) view.getParent()).removeView(view);
} catch (Exception e) {
DeviceLog.exception("Error while removing view from it's parent", e);
}
}
public static void setBackground(View view, Drawable drawable) {
String str = Build.VERSION.SDK_INT < 16 ? "setBackgroundDrawable" : "setBackground";
try {
View.class.getMethod(str, Drawable.class).invoke(view, drawable);
} catch (Exception e) {
DeviceLog.exception("Couldn't run" + str, e);
}
}
}