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

214 lines
9.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.kut.utilities.appstats;
import com.kofax.kmc.kut.utilities.appstats.AppStatistics;
import com.kofax.kmc.kut.utilities.appstats.AppStatsExportListener;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.mobile.sdk._internal.k;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes3.dex */
public abstract class AppStatsDataStore {
private static final String TAG = "AppStatsDataStore";
protected AppStatistics appStats;
protected AppStatistics.FriendAS asFriend;
protected String dsFilePath;
protected File dsFilePathAsFileObj;
protected String dsUniqueId;
private List<Class<?>> oS;
private long oT;
private List<Long> oU;
private long oV;
public abstract void close();
public abstract long countrows(String str);
public abstract Object getDsHandle();
public abstract boolean isOpen();
public abstract void open();
public abstract void open(String str);
public abstract void upgrade(String str);
public AppStatsDataStore() {
AppStatistics appStatistics = AppStatistics.getInstance();
this.appStats = appStatistics;
this.asFriend = new AppStatistics.FriendAS(appStatistics, "com.kofax.kmc.kut.utilities.appstats");
this.dsUniqueId = "";
this.dsFilePath = "";
this.dsFilePathAsFileObj = null;
this.oS = new ArrayList();
this.oT = 0L;
this.oU = new ArrayList();
this.oV = 0L;
}
/* loaded from: classes3.dex */
enum a {
DAO_CLASS_ENVIRONMENT_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.EnvironmentEventDao"),
DAO_CLASS_ERROR_LOG_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.ErrorLogEventDao"),
DAO_CLASS_DOCUMENT_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.DocumentEventDao"),
DAO_CLASS_SESSION_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.SessEventDao"),
DAO_CLASS_IMAGE("com.kofax.kmc.kut.utilities.appstats.dao.ImageDao"),
DAO_CLASS_EVENT_INSTANCE("com.kofax.kmc.kut.utilities.appstats.dao.EventInstanceDao"),
DAO_CLASS_IMG_CLASSIFIER_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.ImgClassificationEventDao"),
DAO_CLASS_IMG_CLASSIFIER_EVENT_ALT("com.kofax.kmc.kut.utilities.appstats.dao.ImgClassificationEventAltDao"),
DAO_CLASS_IMG_CAPTURE_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.ImgCaptureEventDao"),
DAO_CLASS_PROPERTY_CHANGE_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.PropertyChangeEventDao"),
DAO_CLASS_IMG_FIELD_CHANGED_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.FieldEventDao"),
DAO_CLASS_IMAGE_PROCESSED_EVENT("com.kofax.kmc.kut.utilities.appstats.dao.ImageProcessEventDao");
private String pi;
a(String str) {
this.pi = str;
}
public final String getName() {
return this.pi;
}
}
protected void setDsFilePath(String str) {
if (str == null || str.isEmpty()) {
throw new NullPointerException("setDsFilePath: dsFilePath parameter is null or empty");
}
this.dsFilePath = str;
this.dsFilePathAsFileObj = new File(str);
}
public long calcDsSize() {
String str = this.dsFilePath;
if (str == null || this.dsFilePathAsFileObj == null || str.isEmpty()) {
throw new NullPointerException("remove: dsFilePath parameter is null or empty");
}
return this.dsFilePathAsFileObj.length();
}
public void remove() {
String str = this.dsFilePath;
if (str == null || str.isEmpty()) {
throw new NullPointerException("remove: dsFilePath parameter is null or empty");
}
k.b(TAG, "remove: file was deleted = ".concat(String.valueOf(new File(this.dsFilePath).delete())));
}
public void export(String str, AppStatsDsExportHandler appStatsDsExportHandler, AppStatistics.DataStoreStatusCallback dataStoreStatusCallback) {
new Thread(new b(this, str, appStatsDsExportHandler, dataStoreStatusCallback)).start();
}
protected void remove(String... strArr) {
for (String str : strArr) {
if (str == null || str.isEmpty()) {
throw new NullPointerException("remove: dsFilePath parameter is null or empty");
}
boolean delete = new File(str).delete();
String str2 = TAG;
StringBuilder sb = new StringBuilder("remove: (");
sb.append(str);
sb.append(") file was deleted = ");
sb.append(delete);
k.b(str2, sb.toString());
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class b implements Runnable {
private ErrorInfo errorInfo = ErrorInfo.KMC_SUCCESS;
private String ov;
private AppStatsDsExportHandler pk;
/* renamed from: pl, reason: collision with root package name */
private AppStatistics.DataStoreStatusCallback f6506pl;
final AppStatsDataStore pm;
b(AppStatsDataStore appStatsDataStore, String str, AppStatsDsExportHandler appStatsDsExportHandler, AppStatistics.DataStoreStatusCallback dataStoreStatusCallback) {
this.pm = appStatsDataStore;
this.ov = str;
this.pk = appStatsDsExportHandler;
this.f6506pl = dataStoreStatusCallback;
}
@Override // java.lang.Runnable
public void run() {
k.b(AppStatsDataStore.TAG, "AppStatsExportRunnable: run() start");
this.pm.oS.clear();
this.pm.oU.clear();
this.pm.oT = 0L;
this.pm.oV = 0L;
this.pk.configDsExpFilePath(this.ov);
a(AppStatsExportListener.ExportStatus.EXPORTING, 0, this.errorInfo);
for (a aVar : a.values()) {
try {
Class<?> cls = Class.forName(aVar.getName());
Long l = (Long) cls.getMethod("countRows", null).invoke(null, new Object[0]);
if (l.longValue() > 0) {
this.pm.oS.add(cls);
this.pm.oU.add(l);
this.pm.oT += l.longValue();
}
} catch (ClassNotFoundException e) {
throw new TypeNotPresentException(aVar.getName(), new Throwable(e));
} catch (IllegalAccessException e2) {
throw new TypeNotPresentException(aVar.getName(), new Throwable(e2));
} catch (IllegalArgumentException e3) {
throw e3;
} catch (NoSuchMethodException e4) {
throw new IllegalArgumentException(e4.getMessage(), e4);
} catch (InvocationTargetException e5) {
throw new IllegalArgumentException(e5.getMessage(), e5);
}
}
Iterator it = this.pm.oS.iterator();
int i = 0;
while (it.hasNext()) {
try {
((Class) it.next()).getMethod("export", String.class, AppStatsDsExportHandler.class).invoke(null, this.ov, this.pk);
this.pm.oV += ((Long) this.pm.oU.get(i)).longValue();
int round = (int) Math.round((((float) this.pm.oV) / ((float) this.pm.oT)) * 100.0d);
AppStatsExportListener.ExportStatus exportStatus = this.pm.oV == this.pm.oT ? AppStatsExportListener.ExportStatus.COMPLETE : AppStatsExportListener.ExportStatus.EXPORTING;
if (exportStatus != AppStatsExportListener.ExportStatus.EXPORTING) {
this.f6506pl.dataStoreExportComplete(this.errorInfo);
}
a(exportStatus, round, this.errorInfo);
i++;
} catch (IllegalAccessException e6) {
throw new IllegalArgumentException(e6.getMessage(), e6);
} catch (IllegalArgumentException e7) {
throw e7;
} catch (NoSuchMethodException e8) {
throw new IllegalArgumentException(e8.getMessage(), e8);
} catch (InvocationTargetException e9) {
throw new IllegalArgumentException(e9.getMessage(), e9);
}
}
if (this.pm.oT == 0) {
this.f6506pl.dataStoreExportComplete(this.errorInfo);
a(AppStatsExportListener.ExportStatus.COMPLETE, 100, ErrorInfo.KMC_UT_STATS_NOTHING_TO_EXPORT);
}
k.b(AppStatsDataStore.TAG, "AppStatsExportRunnable: run() end");
}
private void a(AppStatsExportListener.ExportStatus exportStatus, int i, ErrorInfo errorInfo) {
this.pm.asFriend.fireExportStatusEvent(new AppStatsExportEvent(this.pm.appStats, exportStatus, i, errorInfo));
}
}
/* JADX INFO: Access modifiers changed from: protected */
public String getDsUniqueId() {
return this.dsUniqueId;
}
protected String getDsFilePath() {
return this.dsFilePath;
}
}