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

580 lines
22 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.kut.utilities.appstats.dao;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import com.kofax.kmc.kut.utilities.Sizeof;
import com.kofax.kmc.kut.utilities.appstats.AppStatistics;
import com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField;
import com.kofax.kmc.kut.utilities.appstats.AppStatsSqLiteDs;
import com.kofax.kmc.kut.utilities.appstats.type.AppStatsDbFieldKeyType;
import com.kofax.kmc.kut.utilities.appstats.type.AppStatsDbFieldType;
import com.kofax.kmc.kut.utilities.appstats.type.AppStatsDsFieldType;
import com.kofax.kmc.kut.utilities.appstats.type.AppStatsDsOpType;
import com.kofax.kmc.kut.utilities.async.TaskRunner;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.mobile.sdk._internal.k;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.Callable;
import o.gjJ;
/* loaded from: classes3.dex */
public abstract class AppStatsDao implements Sizeof.SizeOfNewObject, Cloneable {
private static final String TAG = "AppStatsDao";
private static final int qT = 2;
private static final int qU = 50;
private static final int qV = 50;
private static final int qW = 50;
private static final int qX = 3;
private AppStatistics appStats;
private AppStatistics.FriendAS asFriend;
protected List<AppStatsDaoField> daoFields = new ArrayList();
protected AppStatsDsOpType dsOperation = AppStatsDsOpType.APP_STATS_DS_INSERT;
private static final b qY = b.SIZEOF_ALGORITHM;
private static long qZ = 0;
private static long ra = 0;
private static long rb = 0;
private static long rc = 0;
private static List<AppStatsDao> rd = new ArrayList();
private static int re = 0;
private static AppStatsDaoCalcObjSize rf = null;
private static TaskRunner aZ = null;
/* loaded from: classes3.dex */
public interface AppStatsDaoCalcObjSize {
void daoCalcObjSizeResult(int i, String str);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public enum b {
SIZEOF_ALGORITHM,
HEAP_SIZE_USAGE_ALGORITHM
}
protected abstract AppStatsDao createDaoSampleSizingObj();
protected abstract Integer getAppStatsDaoObjSize();
protected abstract Integer getAppStatsDaoObjSizeInstCnt();
public String getEnvironmentId() {
return null;
}
public String getInstanceId() {
return null;
}
protected abstract List<SQLiteStatement> getWriteToDbStatements(SQLiteDatabase sQLiteDatabase);
protected abstract void setAppStatsDaoObjSize(Integer num);
protected abstract void setAppStatsDaoObjSizeInstCnt(Integer num);
/* loaded from: classes3.dex */
public class AppStatsDaoCalcObjSizeResult {
public int daoObjSize;
public String daoObjSizeId;
final AppStatsDao ri;
public AppStatsDaoCalcObjSizeResult(AppStatsDao appStatsDao, int i, String str) {
this.ri = appStatsDao;
this.daoObjSize = i;
this.daoObjSizeId = str;
}
}
/* loaded from: classes3.dex */
protected static class FieldTemplate {
String name;
AppStatsDsFieldType oK;
AppStatsDbFieldType oL;
AppStatsDbFieldKeyType oM;
/* JADX INFO: Access modifiers changed from: package-private */
public FieldTemplate(String str, AppStatsDsFieldType appStatsDsFieldType, AppStatsDbFieldType appStatsDbFieldType, AppStatsDbFieldKeyType appStatsDbFieldKeyType) {
this.name = str;
this.oK = appStatsDsFieldType;
this.oL = appStatsDbFieldType;
this.oM = appStatsDbFieldKeyType;
}
}
public AppStatsDao() {
AppStatistics appStatistics = AppStatistics.getInstance();
this.appStats = appStatistics;
this.asFriend = new AppStatistics.FriendAS(appStatistics, "com.kofax.kmc.kut.utilities.appstats");
Sizeof.registerNewObjectListener(this);
}
public String getAppStatsSessionKey() {
return this.asFriend.getSessionKey();
}
public String getAppStatsCategory() {
return this.asFriend.getCategory();
}
public String dateStringFromEventTime(long j) {
if (j == 0) {
return null;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("gmt"));
return simpleDateFormat.format(new Date(j));
}
public void setInstanceId(String str) {
throw new UnsupportedOperationException("cannot set instanceId on AppStatsDao superclass; sub-class must implement this.");
}
public void setEnvironmentId(String str) {
throw new UnsupportedOperationException("cannot set environmentId on AppStatsDao superclass; sub-class must implement this.");
}
@Override //
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
public AppStatsDao mo279clone() {
try {
AppStatsDao appStatsDao = (AppStatsDao) super.clone();
appStatsDao.dsOperation = this.dsOperation;
appStatsDao.daoFields = new ArrayList();
for (AppStatsDaoField appStatsDaoField : this.daoFields) {
AppStatsDaoField appStatsDaoField2 = new AppStatsDaoField(appStatsDaoField.getDsFieldName(), appStatsDaoField.getDsFieldType(), appStatsDaoField.getDbFieldType(), appStatsDaoField.getDbFieldKeyType(), appStatsDaoField.getDsValueString());
appStatsDaoField2.setDsValueFloat(appStatsDaoField.getDsValueFloat());
appStatsDaoField2.setDsValueInt(appStatsDaoField.getDsValueInt());
appStatsDaoField2.setDsValueLong(appStatsDaoField.getDsValueLong());
appStatsDaoField2.setDsValueDate(appStatsDaoField.getDsValueDate());
appStatsDao.daoFields.add(appStatsDaoField2);
}
return appStatsDao;
} catch (CloneNotSupportedException unused) {
throw new InternalError("AppStatsDao: unexpected clone not supported exception");
}
}
public Integer calcObjSize(boolean z, String str) {
Integer appStatsDaoObjSize;
synchronized (this) {
if (getAppStatsDaoObjSize() == null || z) {
Integer appStatsDaoObjSizeInstCnt = getAppStatsDaoObjSizeInstCnt();
setAppStatsDaoObjSizeInstCnt(Integer.valueOf(appStatsDaoObjSizeInstCnt.intValue() + 1));
if (appStatsDaoObjSizeInstCnt.intValue() == 0) {
TaskRunner m = m();
a aVar = new a(this, str);
m.addOnTaskCompletedListener(new c(this, null), aVar, false);
m.submit(aVar);
}
} else {
getAppStatsDaoObjSize();
}
appStatsDaoObjSize = getAppStatsDaoObjSize();
}
return appStatsDaoObjSize;
}
@Override // com.kofax.kmc.kut.utilities.Sizeof.SizeOfNewObject
public Object genNextNewObject() {
return createDaoSampleSizingObj();
}
public final void writeToDb() {
List<SQLiteStatement> writeToDbStatements;
SQLiteDatabase sQLiteDatabase = (SQLiteDatabase) AppStatsSqLiteDs.getInstance().getDsHandle();
if (sQLiteDatabase == null || (writeToDbStatements = getWriteToDbStatements(sQLiteDatabase)) == null) {
return;
}
Iterator<SQLiteStatement> it = writeToDbStatements.iterator();
while (it.hasNext()) {
it.next().execute();
}
}
/* JADX INFO: Access modifiers changed from: protected */
public final SQLiteStatement createInsertStatement(String str, List<FieldTemplate> list, List<Object> list2, SQLiteDatabase sQLiteDatabase) {
int size = list.size();
StringBuilder sb = new StringBuilder();
StringBuilder sb2 = new StringBuilder("INSERT INTO ");
sb2.append(str);
sb2.append(" (");
sb.append(sb2.toString());
String str2 = "";
for (FieldTemplate fieldTemplate : list) {
StringBuilder sb3 = new StringBuilder();
sb3.append(str2);
sb3.append(fieldTemplate.name);
sb.append(sb3.toString());
str2 = ", ";
}
sb.append(") VALUES (");
sb.append(gjJ.b(Collections.nCopies(size, "?"), ", "));
sb.append(")");
SQLiteStatement compileStatement = sQLiteDatabase.compileStatement(sb.toString());
int i = 0;
while (i < list.size()) {
int i2 = i + 1;
a(compileStatement, i2, list2.get(i), list.get(i).oK);
i = i2;
}
return compileStatement;
}
/* JADX INFO: Access modifiers changed from: protected */
public final SQLiteStatement createUpdateStatement(String str, String str2, List<FieldTemplate> list, List<Object> list2, SQLiteDatabase sQLiteDatabase) {
StringBuilder sb = new StringBuilder();
StringBuilder sb2 = new StringBuilder("UPDATE ");
sb2.append(str);
sb2.append(" SET ");
sb.append(sb2.toString());
String str3 = "";
for (int i = 0; i < list.size(); i++) {
if (list2.get(i) != null) {
StringBuilder sb3 = new StringBuilder();
sb3.append(str3);
sb3.append(list.get(i).name);
sb3.append("=?");
sb.append(sb3.toString());
str3 = ", ";
}
}
sb.append(" WHERE ID=?");
SQLiteStatement compileStatement = sQLiteDatabase.compileStatement(sb.toString());
int i2 = 1;
for (int i3 = 0; i3 < list.size(); i3++) {
Object obj = list2.get(i3);
if (obj != null) {
a(compileStatement, i2, obj, list.get(i3).oK);
i2++;
}
}
compileStatement.bindString(i2, str2);
return compileStatement;
}
private void a(SQLiteStatement sQLiteStatement, int i, Object obj, AppStatsDsFieldType appStatsDsFieldType) {
int i2 = AnonymousClass1.rg[appStatsDsFieldType.ordinal()];
if (i2 == 1) {
sQLiteStatement.bindLong(i, ((Long) obj).longValue());
return;
}
if (i2 == 2) {
sQLiteStatement.bindLong(i, ((Integer) obj).intValue());
} else if (i2 == 3) {
sQLiteStatement.bindDouble(i, ((Float) obj).floatValue());
} else {
sQLiteStatement.bindString(i, String.valueOf(obj));
}
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Code restructure failed: missing block: B:10:0x005d, code lost:
r0.clear();
r2 = r22.iterator();
*/
/* JADX WARN: Code restructure failed: missing block: B:12:0x0068, code lost:
if (r2.hasNext() == false) goto L33;
*/
/* JADX WARN: Code restructure failed: missing block: B:13:0x006a, code lost:
r3 = r2.next();
r4 = r1.getColumnIndex(r3.name);
r5 = com.kofax.kmc.kut.utilities.appstats.dao.AppStatsDao.AnonymousClass1.rg[r3.oK.ordinal()];
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x0081, code lost:
if (r5 == 1) goto L30;
*/
/* JADX WARN: Code restructure failed: missing block: B:16:0x00d7, code lost:
r0.add(new com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField(r3.name, r3.oK, r3.oL, r3.oM, java.lang.Long.valueOf(r1.getLong(r4))));
*/
/* JADX WARN: Code restructure failed: missing block: B:21:0x0084, code lost:
if (r5 == 2) goto L31;
*/
/* JADX WARN: Code restructure failed: missing block: B:23:0x00bd, code lost:
r0.add(new com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField(r3.name, r3.oK, r3.oL, r3.oM, java.lang.Integer.valueOf(r1.getInt(r4))));
*/
/* JADX WARN: Code restructure failed: missing block: B:27:0x0087, code lost:
if (r5 == 3) goto L32;
*/
/* JADX WARN: Code restructure failed: missing block: B:29:0x009f, code lost:
r0.add(new com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField(r3.name, r3.oK, r3.oL, r3.oM, java.lang.Float.valueOf(r1.getFloat(r4))));
*/
/* JADX WARN: Code restructure failed: missing block: B:32:0x0089, code lost:
r0.add(new com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField(r3.name, r3.oK, r3.oL, r3.oM, r1.getString(r4)));
*/
/* JADX WARN: Code restructure failed: missing block: B:35:0x00f6, code lost:
r20.onExportAppStatsRowEvent(r21, (com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField[]) r0.toArray(new com.kofax.kmc.kut.utilities.appstats.AppStatsDaoField[r0.size()]));
*/
/* JADX WARN: Code restructure failed: missing block: B:36:0x010d, code lost:
if (r1.moveToNext() != false) goto L29;
*/
/* JADX WARN: Code restructure failed: missing block: B:39:0x010f, code lost:
r1.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:40:0x0112, code lost:
return;
*/
/* JADX WARN: Code restructure failed: missing block: B:9:0x005b, code lost:
if (r1.moveToFirst() != false) goto L10;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static void export(java.lang.String r19, com.kofax.kmc.kut.utilities.appstats.AppStatsDsExportHandler r20, java.lang.String r21, java.util.List<com.kofax.kmc.kut.utilities.appstats.dao.AppStatsDao.FieldTemplate> r22) {
/*
Method dump skipped, instructions count: 275
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.kmc.kut.utilities.appstats.dao.AppStatsDao.export(java.lang.String, com.kofax.kmc.kut.utilities.appstats.AppStatsDsExportHandler, java.lang.String, java.util.List):void");
}
/* JADX INFO: Access modifiers changed from: protected */
public String generateNewUniqueID() {
return UUID.randomUUID().toString();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class c implements TaskRunner.TaskCompletedListener {
final AppStatsDao ri;
private c(AppStatsDao appStatsDao) {
this.ri = appStatsDao;
}
/* synthetic */ c(AppStatsDao appStatsDao, AnonymousClass1 anonymousClass1) {
this(appStatsDao);
}
@Override // com.kofax.kmc.kut.utilities.async.TaskRunner.TaskCompletedListener
public void onTaskCompleted(TaskRunner.TaskCompletedEvent taskCompletedEvent) {
synchronized (this.ri) {
if (taskCompletedEvent.getTaskError() == ErrorInfo.KMC_SUCCESS) {
if (AppStatsDao.rf == null) {
throw new NullPointerException("daoCalcObjSizeListener is null, indicating no listener is registered");
}
AppStatsDaoCalcObjSizeResult appStatsDaoCalcObjSizeResult = (AppStatsDaoCalcObjSizeResult) taskCompletedEvent.getTaskReturnValue();
this.ri.setAppStatsDaoObjSize(Integer.valueOf(appStatsDaoCalcObjSizeResult.daoObjSize));
String str = AppStatsDao.TAG;
StringBuilder sb = new StringBuilder();
sb.append(this.ri.getClass().getSimpleName());
sb.append(".getAppStatsDaoObjSizeInstCnt() = ");
sb.append(this.ri.getAppStatsDaoObjSizeInstCnt());
k.b(str, sb.toString());
Integer valueOf = Integer.valueOf(this.ri.getAppStatsDaoObjSizeInstCnt().intValue() * appStatsDaoCalcObjSizeResult.daoObjSize);
AppStatsDao.rf.daoCalcObjSizeResult(valueOf.intValue(), appStatsDaoCalcObjSizeResult.daoObjSizeId);
String str2 = AppStatsDao.TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append(this.ri.getClass().getSimpleName());
sb2.append(".daoCalcObjSizeResult(");
sb2.append(valueOf);
sb2.append(")");
k.b(str2, sb2.toString());
this.ri.setAppStatsDaoObjSizeInstCnt(0);
}
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class a implements Callable<AppStatsDaoCalcObjSizeResult> {
final AppStatsDao ri;
private String rj;
int rk = 0;
a(AppStatsDao appStatsDao, String str) {
this.ri = appStatsDao;
this.rj = str;
}
@Override // java.util.concurrent.Callable
/* renamed from: bb, reason: merged with bridge method [inline-methods] */
public AppStatsDaoCalcObjSizeResult call() throws Exception {
int i = AnonymousClass1.rh[AppStatsDao.qY.ordinal()];
if (i == 1) {
this.rk = this.ri.aX();
} else if (i == 2) {
this.rk = this.ri.aY();
}
String str = AppStatsDao.TAG;
StringBuilder sb = new StringBuilder("Bytes used per ");
sb.append(this.ri.getClass().getSimpleName());
sb.append(" object = ");
sb.append(this.rk);
k.b(str, sb.toString());
return new AppStatsDaoCalcObjSizeResult(this.ri, this.rk, this.rj);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: com.kofax.kmc.kut.utilities.appstats.dao.AppStatsDao$1, reason: invalid class name */
/* loaded from: classes3.dex */
public static /* synthetic */ class AnonymousClass1 {
static final int[] rg;
static final int[] rh;
static {
int[] iArr = new int[b.values().length];
rh = iArr;
try {
iArr[b.SIZEOF_ALGORITHM.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
rh[b.HEAP_SIZE_USAGE_ALGORITHM.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
int[] iArr2 = new int[AppStatsDsFieldType.values().length];
rg = iArr2;
try {
iArr2[AppStatsDsFieldType.DS_FIELD_TYPE_LONG.ordinal()] = 1;
} catch (NoSuchFieldError unused3) {
}
try {
rg[AppStatsDsFieldType.DS_FIELD_TYPE_INTEGER.ordinal()] = 2;
} catch (NoSuchFieldError unused4) {
}
try {
rg[AppStatsDsFieldType.DS_FIELD_TYPE_FLOAT.ordinal()] = 3;
} catch (NoSuchFieldError unused5) {
}
}
}
private static void aW() {
for (int i = 0; i < 2; i++) {
System.gc();
try {
Thread.sleep(50L);
} catch (InterruptedException unused) {
}
}
}
private static void b(long j) {
try {
Thread.sleep(j);
} catch (InterruptedException unused) {
}
}
/* JADX INFO: Access modifiers changed from: private */
public int aX() {
int i = 0;
for (int i2 = 0; i2 < 3; i2++) {
try {
Sizeof.computeObjectSize(Sizeof.ObjectDataTypes.DATA_TYPE_OBJECT_SHELL, 50);
i = Sizeof.computeObjectSize(Sizeof.ObjectDataTypes.DATA_TYPE_APP_CREATED, 50);
Sizeof.computeObjectSize(Sizeof.ObjectDataTypes.DATA_TYPE_OBJECT_SHELL, 50);
if (i > 0) {
break;
}
} catch (Exception e) {
throw new IllegalThreadStateException(e.getMessage());
}
}
if (i > 0) {
return i;
}
return 0;
}
/* JADX INFO: Access modifiers changed from: private */
public int aY() {
String str = TAG;
k.b(str, "runComputeHeapSizeUsage(false)");
aW();
b(50L);
long h = h(false);
aW();
b(50L);
k.b(str, "runComputeHeapSizeUsage(true)");
long h2 = h(true);
k.b(str, "heapUsedBase: ".concat(String.valueOf(h)));
k.b(str, "heapUsedAppStatObj: ".concat(String.valueOf(h2)));
StringBuilder sb = new StringBuilder("instanceDao objects created: ");
sb.append(re);
k.b(str, sb.toString());
return (int) ((h2 - h) / re);
}
private long h(boolean z) {
re = 0;
rd.clear();
ra = Runtime.getRuntime().freeMemory();
String str = TAG;
StringBuilder sb = new StringBuilder("heapFreeSize (start) = ");
sb.append(NumberFormat.getInstance().format(ra));
k.b(str, sb.toString());
for (int i = 0; i < 50; i++) {
rc = qZ;
qZ = Runtime.getRuntime().freeMemory();
String str2 = TAG;
StringBuilder sb2 = new StringBuilder("heapFreeSize = ");
sb2.append(NumberFormat.getInstance().format(qZ));
k.b(str2, sb2.toString());
long j = rc;
if (j == 0) {
j = qZ;
}
rc = j;
if (z) {
rd.add(createDaoSampleSizingObj());
re++;
}
}
rb = Runtime.getRuntime().freeMemory();
String str3 = TAG;
StringBuilder sb3 = new StringBuilder("heapFreeSize (end) = ");
sb3.append(NumberFormat.getInstance().format(rb));
k.b(str3, sb3.toString());
long j2 = ra;
long j3 = rb;
rd.clear();
return j2 - j3;
}
private static TaskRunner m() {
if (aZ == null) {
aZ = new TaskRunner(1);
}
return aZ;
}
public void setDsOperation(AppStatsDsOpType appStatsDsOpType) {
this.dsOperation = appStatsDsOpType;
}
public AppStatsDsOpType getDsOperation() {
return this.dsOperation;
}
public static void addAppStatsDaoCalcObjSizeListener(AppStatsDaoCalcObjSize appStatsDaoCalcObjSize) {
rf = appStatsDaoCalcObjSize;
}
}