what-the-bank/sources/com/kofax/kmc/kut/utilities/appstats/AppStatsJsonExportHandler.java

704 lines
25 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.kut.utilities.appstats;
import android.graphics.Color;
import android.media.AudioTrack;
import android.os.Process;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.ViewConfiguration;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.kofax.kmc.kut.utilities.MemoryHelper;
import com.kofax.kmc.kut.utilities.SdkVersion;
import com.kofax.kmc.kut.utilities.appstats.AppStatistics;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import o.C4403bZM;
import o.gjJ;
import o.xzZ;
import org.bouncycastle.crypto.signers.PSSSigner;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class AppStatsJsonExportHandler implements AppStatsDsExportHandler, AppStatsExportListener {
private static final String TAG = "AppStatsJsonExportHandler";
private static int[] a;
private static AppStatistics appStats;
private static AppStatistics.FriendAS asFriend;
private static int e;
private final String LINE_SEPARATOR;
private final String pE = "AppStatisticsVersion";
private final String pF = "AppStatisticsTables";
private final String pG = ".json";
private final float pH = 0.1f;
private final String pI;
private JSONObject pJ;
private JSONObject pK;
private File pL;
private Map<String, Object> pM;
private String pN;
private String pO;
private String pP;
private String pQ;
private String pR;
private String pS;
private boolean pT;
private boolean pU;
private static final byte[] $$a = {0, PSSSigner.TRAILER_IMPLICIT, -126, 35};
private static final int $$b = 112;
private static int $10 = 0;
private static int $11 = 1;
private static int b = 1;
/* JADX WARN: Removed duplicated region for block: B:10:0x0026 */
/* JADX WARN: Removed duplicated region for block: B:7:0x001e */
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:10:0x0026 -> B:4:0x002a). Please report as a decompilation issue!!! */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static void h(byte r5, byte r6, int r7, java.lang.Object[] r8) {
/*
int r5 = r5 * 2
int r0 = 1 - r5
int r6 = r6 * 2
int r6 = 4 - r6
byte[] r1 = com.kofax.kmc.kut.utilities.appstats.AppStatsJsonExportHandler.$$a
int r7 = r7 * 2
int r7 = 104 - r7
byte[] r0 = new byte[r0]
r2 = 0
int r5 = 0 - r5
if (r1 != 0) goto L18
r4 = r5
r3 = r2
goto L2a
L18:
r3 = r2
L19:
byte r4 = (byte) r7
r0[r3] = r4
if (r3 != r5) goto L26
java.lang.String r5 = new java.lang.String
r5.<init>(r0, r2)
r8[r2] = r5
return
L26:
r4 = r1[r6]
int r3 = r3 + 1
L2a:
int r4 = -r4
int r7 = r7 + r4
int r6 = r6 + 1
goto L19
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.kmc.kut.utilities.appstats.AppStatsJsonExportHandler.h(byte, byte, int, java.lang.Object[]):void");
}
static {
e = 0;
c();
AppStatistics appStatistics = AppStatistics.getInstance();
appStats = appStatistics;
asFriend = new AppStatistics.FriendAS(appStatistics, "com.kofax.kmc.kut.utilities.appstats");
int i = b + 11;
e = i % 128;
if (i % 2 != 0) {
int i2 = 94 / 0;
}
}
public AppStatsJsonExportHandler() {
StringBuilder sb = new StringBuilder(",");
sb.append(System.getProperty("line.separator"));
this.pI = sb.toString();
String property = System.getProperty("line.separator");
this.LINE_SEPARATOR = property;
this.pJ = new JSONObject();
this.pK = new JSONObject();
this.pL = null;
this.pM = new HashMap();
this.pN = "";
this.pO = "";
this.pP = "";
this.pQ = "";
this.pR = "";
this.pS = "";
this.pT = false;
this.pU = false;
try {
this.pJ.put("AppStatisticsVersion", SdkVersion.getSdkVersion());
this.pJ.put("AppStatisticsTables", this.pK);
String jSONObject = this.pJ.toString(2);
int indexOf = jSONObject.indexOf(UrlTreeKt.componentParamPrefix, 1);
StringBuilder sb2 = new StringBuilder();
sb2.append(jSONObject.substring(0, indexOf + 1));
sb2.append(property);
this.pN = sb2.toString();
asFriend.addAppStatsExportListener(this, 0);
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
} catch (Exception e3) {
throw e3;
}
}
private static void d(int[] iArr, int i, Object[] objArr) {
int i2;
Object method;
int i3;
int i4 = 2 % 2;
C4403bZM c4403bZM = new C4403bZM();
char[] cArr = new char[4];
char[] cArr2 = new char[iArr.length * 2];
int[] iArr2 = a;
float f = BitmapDescriptorFactory.HUE_RED;
int i5 = 729798706;
int i6 = 1;
char c = 0;
if (iArr2 != null) {
int i7 = $10 + 87;
$11 = i7 % 128;
int i8 = i7 % 2;
int length = iArr2.length;
int[] iArr3 = new int[length];
int i9 = 0;
while (i9 < length) {
try {
Object[] objArr2 = new Object[i6];
objArr2[0] = Integer.valueOf(iArr2[i9]);
Object obj = xzZ.y.get(729798706);
if (obj == null) {
obj = ((Class) xzZ.c(15 - Color.green(0), (AudioTrack.getMaxVolume() > f ? 1 : (AudioTrack.getMaxVolume() == f ? 0 : -1)) + 4, (char) (KeyEvent.getDeadChar(0, 0) + 58134))).getMethod("i", Integer.TYPE);
xzZ.y.put(729798706, obj);
}
iArr3[i9] = ((Integer) ((Method) obj).invoke(null, objArr2)).intValue();
i9++;
f = BitmapDescriptorFactory.HUE_RED;
i6 = 1;
} catch (Throwable th) {
Throwable cause = th.getCause();
if (cause == null) {
throw th;
}
throw cause;
}
}
iArr2 = iArr3;
}
int length2 = iArr2.length;
int[] iArr4 = new int[length2];
int[] iArr5 = a;
if (iArr5 != null) {
int length3 = iArr5.length;
int[] iArr6 = new int[length3];
int i10 = 0;
while (i10 < length3) {
try {
Object[] objArr3 = new Object[1];
objArr3[c] = Integer.valueOf(iArr5[i10]);
Object obj2 = xzZ.y.get(Integer.valueOf(i5));
if (obj2 != null) {
i3 = i5;
} else {
obj2 = ((Class) xzZ.c((ViewConfiguration.getFadingEdgeLength() >> 16) + 15, (SystemClock.uptimeMillis() > 0L ? 1 : (SystemClock.uptimeMillis() == 0L ? 0 : -1)) + 4, (char) ((KeyEvent.getMaxKeyCode() >> 16) + 58134))).getMethod("i", Integer.TYPE);
i3 = 729798706;
xzZ.y.put(729798706, obj2);
}
iArr6[i10] = ((Integer) ((Method) obj2).invoke(null, objArr3)).intValue();
i10++;
i5 = i3;
c = 0;
} catch (Throwable th2) {
Throwable cause2 = th2.getCause();
if (cause2 == null) {
throw th2;
}
throw cause2;
}
}
int i11 = $10 + 103;
$11 = i11 % 128;
int i12 = i11 % 2;
iArr5 = iArr6;
i2 = 0;
} else {
i2 = 0;
}
System.arraycopy(iArr5, i2, iArr4, i2, length2);
c4403bZM.b = i2;
while (c4403bZM.b < iArr.length) {
int i13 = $11 + 21;
$10 = i13 % 128;
int i14 = i13 % 2;
cArr[0] = (char) (iArr[c4403bZM.b] >> 16);
cArr[1] = (char) iArr[c4403bZM.b];
cArr[2] = (char) (iArr[c4403bZM.b + 1] >> 16);
cArr[3] = (char) iArr[c4403bZM.b + 1];
c4403bZM.e = (cArr[0] << 16) + cArr[1];
c4403bZM.a = (cArr[2] << 16) + cArr[3];
C4403bZM.d(iArr4);
int i15 = 0;
for (int i16 = 16; i15 < i16; i16 = 16) {
c4403bZM.e ^= iArr4[i15];
Object[] objArr4 = {c4403bZM, Integer.valueOf(C4403bZM.d(c4403bZM.e)), c4403bZM, c4403bZM};
Object obj3 = xzZ.y.get(-1196964548);
if (obj3 != null) {
method = obj3;
} else {
Class cls = (Class) xzZ.c(117 - TextUtils.lastIndexOf("", '0', 0), (AudioTrack.getMinVolume() > BitmapDescriptorFactory.HUE_RED ? 1 : (AudioTrack.getMinVolume() == BitmapDescriptorFactory.HUE_RED ? 0 : -1)) + 5, (char) TextUtils.getOffsetAfter("", 0));
byte b2 = $$a[0];
byte b3 = b2;
Object[] objArr5 = new Object[1];
h(b2, b3, b3, objArr5);
method = cls.getMethod((String) objArr5[0], Object.class, Integer.TYPE, Object.class, Object.class);
xzZ.y.put(-1196964548, method);
}
int intValue = ((Integer) ((Method) method).invoke(null, objArr4)).intValue();
c4403bZM.e = c4403bZM.a;
c4403bZM.a = intValue;
i15++;
}
int i17 = c4403bZM.e;
c4403bZM.e = c4403bZM.a;
c4403bZM.a = i17;
c4403bZM.a ^= iArr4[16];
c4403bZM.e ^= iArr4[17];
int i18 = c4403bZM.e;
int i19 = c4403bZM.a;
cArr[0] = (char) (c4403bZM.e >>> 16);
cArr[1] = (char) c4403bZM.e;
cArr[2] = (char) (c4403bZM.a >>> 16);
cArr[3] = (char) c4403bZM.a;
C4403bZM.d(iArr4);
cArr2[c4403bZM.b * 2] = cArr[0];
cArr2[(c4403bZM.b * 2) + 1] = cArr[1];
cArr2[(c4403bZM.b * 2) + 2] = cArr[2];
cArr2[(c4403bZM.b * 2) + 3] = cArr[3];
Object[] objArr6 = {c4403bZM, c4403bZM};
Object obj4 = xzZ.y.get(1914371176);
if (obj4 == null) {
Class cls2 = (Class) xzZ.c(TextUtils.lastIndexOf("", '0', 0, 0) + 99, TextUtils.indexOf((CharSequence) "", '0') + 6, (char) (TextUtils.indexOf((CharSequence) "", '0') + 1));
byte b4 = $$a[0];
byte b5 = b4;
Object[] objArr7 = new Object[1];
h(b4, b5, (byte) (b5 + 1), objArr7);
obj4 = cls2.getMethod((String) objArr7[0], Object.class, Object.class);
xzZ.y.put(1914371176, obj4);
}
((Method) obj4).invoke(null, objArr6);
}
objArr[0] = new String(cArr2, 0, i);
}
@Override // com.kofax.kmc.kut.utilities.appstats.AppStatsDsExportHandler
public void onExportAppStatsRowEvent(String str, AppStatsDaoField[] appStatsDaoFieldArr) {
int i = 2 % 2;
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append("s");
String obj = sb.toString();
try {
if (!this.pK.has(obj)) {
int i2 = e + 21;
b = i2 % 128;
if (i2 % 2 == 0) {
this.pS.isEmpty();
throw null;
}
if (!this.pS.isEmpty()) {
this.pQ = e(false);
b(this.pS, true);
f(false);
this.pK.remove(this.pS);
this.pS = "";
}
if (this.pK.length() > 0 && MemoryHelper.getTotalFreeMemoryAsPctOfMax() < 0.1f) {
aR();
}
this.pU = false;
this.pK.put(obj, new JSONArray());
} else if (MemoryHelper.getTotalFreeMemoryAsPctOfMax() < 0.1f) {
if (this.pU) {
this.pQ = e(false);
b(obj, false);
} else {
JSONArray jSONArray = this.pK.getJSONArray(obj);
this.pK.remove(obj);
aR();
this.pK.put(obj, jSONArray);
StringBuilder sb2 = new StringBuilder(this.pJ.toString(2));
sb2.delete(0, this.pN.length());
sb2.delete(sb2.length() - this.pO.length(), sb2.length());
int indexOf = sb2.indexOf("[", 0);
StringBuilder sb3 = new StringBuilder();
sb3.append(sb2.substring(0, indexOf + 1));
sb3.append(this.LINE_SEPARATOR);
this.pP = sb3.toString();
this.pQ = e(true);
StringBuilder sb4 = new StringBuilder(this.pJ.toString(2));
sb4.delete(0, this.pN.length());
sb4.delete(0, this.pP.length());
sb4.delete(0, this.pQ.length());
sb4.delete(sb4.indexOf(this.pO), sb4.length());
this.pR = sb4.toString();
aU();
b(obj, false);
this.pS = obj;
}
}
JSONArray jSONArray2 = this.pK.getJSONArray(obj);
this.pM.clear();
for (AppStatsDaoField appStatsDaoField : appStatsDaoFieldArr) {
String dsValueString = appStatsDaoField.getDsValueString();
Object[] objArr = new Object[1];
d(new int[]{-925445201, -349069567}, 3 - Process.getGidForName(""), objArr);
if (dsValueString.equals(((String) objArr[0]).intern())) {
int i3 = e + 51;
b = i3 % 128;
if (i3 % 2 == 0) {
this.pM.put(appStatsDaoField.getDsFieldName(), JSONObject.NULL);
int i4 = 16 / 0;
} else {
this.pM.put(appStatsDaoField.getDsFieldName(), JSONObject.NULL);
}
int i5 = e + 71;
b = i5 % 128;
int i6 = i5 % 2;
} else {
this.pM.put(appStatsDaoField.getDsFieldName(), dsValueString);
}
}
jSONArray2.put(new JSONObject(this.pM));
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
@Override // com.kofax.kmc.kut.utilities.appstats.AppStatsDsExportHandler
public void configDsExpFilePath(String str) {
int i = 2 % 2;
int i2 = e + 77;
b = i2 % 128;
int i3 = i2 % 2;
if (!str.endsWith(".json")) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(".json");
str = sb.toString();
}
this.pL = new File(str);
int i4 = b + 17;
e = i4 % 128;
if (i4 % 2 != 0) {
throw null;
}
}
@Override // com.kofax.kmc.kut.utilities.appstats.AppStatsExportListener
public void exportStatusEvent(AppStatsExportEvent appStatsExportEvent) {
int i = 2 % 2;
if (appStatsExportEvent.getPercentComplete() == 100) {
int i2 = e + 67;
b = i2 % 128;
try {
if (i2 % 2 == 0) {
throw null;
}
if (!this.pT) {
a(this.pJ.toString(2), this.pL);
} else if (this.pS.isEmpty()) {
g(true);
aT();
int i3 = b + 85;
e = i3 % 128;
int i4 = i3 % 2;
} else {
int i5 = e + 31;
b = i5 % 128;
if (i5 % 2 == 0) {
this.pQ = e(false);
b(this.pS, true);
f(false);
aT();
} else {
this.pQ = e(false);
b(this.pS, true);
f(true);
aT();
}
this.pS = "";
}
appStats.removeAppStatsExportListener(this);
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
}
private void aQ() {
int i = 2 % 2;
Iterator<String> keys = this.pK.keys();
while (keys.hasNext()) {
int i2 = b + 45;
e = i2 % 128;
if (i2 % 2 != 0) {
keys.next();
keys.remove();
int i3 = 93 / 0;
} else {
keys.next();
keys.remove();
}
}
int i4 = b + 59;
e = i4 % 128;
if (i4 % 2 == 0) {
return;
}
Object obj = null;
obj.hashCode();
throw null;
}
private void aR() {
String substring;
int i = 2 % 2;
int i2 = e + 111;
int i3 = i2 % 128;
b = i3;
int i4 = i2 % 2;
try {
if (!this.pT) {
int i5 = i3 + 87;
e = i5 % 128;
if (i5 % 2 != 0) {
aS();
String jSONObject = this.pJ.toString(3);
substring = jSONObject.substring(jSONObject.lastIndexOf("]") / 3, jSONObject.length());
} else {
aS();
String jSONObject2 = this.pJ.toString(2);
substring = jSONObject2.substring(jSONObject2.lastIndexOf("]") + 2, jSONObject2.length());
}
this.pO = substring;
}
g(false);
aQ();
int i6 = e + 19;
b = i6 % 128;
int i7 = i6 % 2;
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
private void a(String str, File file) {
int i = 2 % 2;
int i2 = b + 21;
e = i2 % 128;
int i3 = i2 % 2;
a(str, file, false);
int i4 = e + 29;
b = i4 % 128;
if (i4 % 2 == 0) {
int i5 = 16 / 0;
}
}
private void aS() {
int i = 2 % 2;
int i2 = b + 125;
e = i2 % 128;
int i3 = i2 % 2;
this.pT = true;
a(this.pN, this.pL, false);
int i4 = b + 111;
e = i4 % 128;
int i5 = i4 % 2;
}
private void aT() {
int i = 2 % 2;
int i2 = b + 87;
e = i2 % 128;
int i3 = i2 % 2;
a(this.pO, this.pL, true);
int i4 = e + 67;
b = i4 % 128;
if (i4 % 2 != 0) {
return;
}
Object obj = null;
obj.hashCode();
throw null;
}
private void aU() {
int i = 2 % 2;
int i2 = e + 55;
b = i2 % 128;
int i3 = i2 % 2;
this.pU = true;
a(this.pP, this.pL, true);
int i4 = e + 101;
b = i4 % 128;
if (i4 % 2 != 0) {
return;
}
Object obj = null;
obj.hashCode();
throw null;
}
private String e(boolean z) {
int i = 2 % 2;
try {
StringBuilder sb = new StringBuilder(this.pJ.toString(2));
StringBuilder sb2 = new StringBuilder("[");
sb2.append(this.LINE_SEPARATOR);
String obj = sb2.toString();
sb.delete(0, sb.indexOf(obj) + obj.length());
sb.delete(sb.lastIndexOf("]"), sb.length());
if (!z) {
StringBuilder sb3 = new StringBuilder(",");
sb3.append(this.LINE_SEPARATOR);
sb.insert(0, sb3.toString());
}
sb.trimToSize();
String obj2 = sb.toString();
StringBuilder sb4 = new StringBuilder(" ");
sb4.append(this.LINE_SEPARATOR);
String b2 = gjJ.b(obj2, sb4.toString());
int i2 = e + 85;
b = i2 % 128;
int i3 = i2 % 2;
return b2;
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
private void b(String str, boolean z) {
int i = 2 % 2;
int i2 = b + 47;
e = i2 % 128;
if (i2 % 2 != 0) {
a(this.pQ, this.pL, false);
if (z) {
return;
}
} else {
a(this.pQ, this.pL, true);
if (z) {
return;
}
}
try {
this.pK.put(str, new JSONArray());
int i3 = e + 27;
b = i3 % 128;
int i4 = i3 % 2;
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
private void f(boolean z) {
String str;
int i = 2 % 2;
int i2 = b;
int i3 = i2 + 27;
e = i3 % 128;
if (i3 % 2 != 0) {
Object obj = null;
obj.hashCode();
throw null;
}
if (!z) {
StringBuilder sb = new StringBuilder();
sb.append(gjJ.b(this.pR, this.LINE_SEPARATOR));
sb.append(this.pI);
str = sb.toString();
} else {
str = this.pR;
int i4 = i2 + 65;
e = i4 % 128;
int i5 = i4 % 2;
}
a(str, this.pL, true);
}
private void g(boolean z) {
int i = 2 % 2;
try {
StringBuilder sb = new StringBuilder(this.pK.toString(4));
sb.replace(0, sb.indexOf(" "), "");
sb.deleteCharAt(sb.lastIndexOf(UrlTreeKt.componentParamSuffix));
if (!z) {
int i2 = b + 103;
e = i2 % 128;
sb.insert(i2 % 2 != 0 ? sb.lastIndexOf("]") >>> 1 : sb.lastIndexOf("]") + 1, ",");
int i3 = e + 17;
b = i3 % 128;
int i4 = i3 % 2;
}
a(sb.toString(), this.pL, true);
} catch (JSONException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_UT_STATS_INVALID_JSON);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
}
}
private void a(String str, File file, boolean z) {
int i = 2 % 2;
try {
FileOutputStream fileOutputStream = new FileOutputStream(file, z);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream);
outputStreamWriter.write(str);
outputStreamWriter.close();
fileOutputStream.close();
int i2 = b + 89;
e = i2 % 128;
int i3 = i2 % 2;
} catch (FileNotFoundException e2) {
KmcRuntimeException kmcRuntimeException = new KmcRuntimeException(ErrorInfo.KMC_GN_FILE_NOT_FOUND);
kmcRuntimeException.getErrorInfo().setErrCause(e2.getMessage());
throw kmcRuntimeException;
} catch (IOException e3) {
KmcRuntimeException kmcRuntimeException2 = new KmcRuntimeException(ErrorInfo.KMC_GN_IO_EXCEPTION);
kmcRuntimeException2.getErrorInfo().setErrCause(e3.getMessage());
throw kmcRuntimeException2;
}
}
static void c() {
a = new int[]{-128247296, 1169425523, -410755398, -727590922, -2130318068, -1369845844, 335854890, 908209140, -1315407739, -1566001533, -1507937813, -465304035, -1300328047, -797082093, 1719956015, 1409861427, 1444349355, -1215128293};
}
}