522 lines
18 KiB
Java
522 lines
18 KiB
Java
|
package o;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.pm.PackageItemInfo;
|
||
|
import android.database.Cursor;
|
||
|
import android.database.SQLException;
|
||
|
import android.database.sqlite.SQLiteCantOpenDatabaseException;
|
||
|
import android.database.sqlite.SQLiteDatabase;
|
||
|
import android.os.Bundle;
|
||
|
import java.io.File;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.fOm, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes5.dex */
|
||
|
public final class C13032fOm {
|
||
|
static Boolean b;
|
||
|
Integer a;
|
||
|
Context c;
|
||
|
public InterfaceC13042fOw d;
|
||
|
final String f;
|
||
|
final int g;
|
||
|
final int h;
|
||
|
SQLiteDatabase n;
|
||
|
|
||
|
/* renamed from: o, reason: collision with root package name */
|
||
|
final boolean f9104o;
|
||
|
final List<fOQ> i = new ArrayList();
|
||
|
final Map<Integer, fOB> e = new HashMap();
|
||
|
private int k = 0;
|
||
|
int j = 0;
|
||
|
private int l = 0;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public C13032fOm(Context context, String str, int i, boolean z, int i2) {
|
||
|
this.c = context;
|
||
|
this.f = str;
|
||
|
this.f9104o = z;
|
||
|
this.h = i;
|
||
|
this.g = i2;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static boolean b(Context context) {
|
||
|
return ((Bundle) PackageItemInfo.class.getField("metaData").get(context.getPackageManager().getApplicationInfo(context.getPackageName(), 128))).getBoolean("com.tekartik.sqflite.wal_enabled", false);
|
||
|
}
|
||
|
|
||
|
public static boolean e(String str) {
|
||
|
try {
|
||
|
return new File(str).exists();
|
||
|
} catch (Exception unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final String c() {
|
||
|
Thread currentThread = Thread.currentThread();
|
||
|
StringBuilder sb = new StringBuilder("");
|
||
|
sb.append(this.h);
|
||
|
sb.append(",");
|
||
|
sb.append(currentThread.getName());
|
||
|
sb.append("(");
|
||
|
sb.append(currentThread.getId());
|
||
|
sb.append(")");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
private static Map<String, Object> aBJ_(Cursor cursor, Integer num) {
|
||
|
Object valueOf;
|
||
|
HashMap hashMap = null;
|
||
|
ArrayList arrayList = null;
|
||
|
int i = 0;
|
||
|
while (cursor.moveToNext()) {
|
||
|
if (hashMap == null) {
|
||
|
arrayList = new ArrayList();
|
||
|
hashMap = new HashMap();
|
||
|
i = cursor.getColumnCount();
|
||
|
hashMap.put("columns", Arrays.asList(cursor.getColumnNames()));
|
||
|
hashMap.put("rows", arrayList);
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList(i);
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
int type = cursor.getType(i2);
|
||
|
if (type == 1) {
|
||
|
valueOf = Long.valueOf(cursor.getLong(i2));
|
||
|
} else if (type == 2) {
|
||
|
valueOf = Double.valueOf(cursor.getDouble(i2));
|
||
|
} else if (type == 3) {
|
||
|
valueOf = cursor.getString(i2);
|
||
|
} else {
|
||
|
valueOf = type != 4 ? null : cursor.getBlob(i2);
|
||
|
}
|
||
|
arrayList2.add(valueOf);
|
||
|
}
|
||
|
arrayList.add(arrayList2);
|
||
|
if (num != null && arrayList.size() >= num.intValue()) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return hashMap == null ? new HashMap() : hashMap;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final void a(fOP fop, Runnable runnable) {
|
||
|
Integer c = fop.c();
|
||
|
Integer num = this.a;
|
||
|
if (num == null) {
|
||
|
runnable.run();
|
||
|
return;
|
||
|
}
|
||
|
if (c != null && (c.equals(num) || c.intValue() == -1)) {
|
||
|
runnable.run();
|
||
|
if (this.a != null || this.i.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
this.d.d(this, new Runnable(this) { // from class: o.fOq
|
||
|
private C13032fOm b;
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
C13032fOm c13032fOm = this.b;
|
||
|
while (!c13032fOm.i.isEmpty() && c13032fOm.a == null) {
|
||
|
c13032fOm.i.get(0).b.run();
|
||
|
c13032fOm.i.remove(0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
this.i.add(new fOQ(fop, runnable));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:38:0x008b A[ADDED_TO_REGION] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public final boolean b(o.fOP r9) {
|
||
|
/*
|
||
|
r8 = this;
|
||
|
java.lang.String r0 = "cursorPageSize"
|
||
|
java.lang.Object r0 = r9.e(r0)
|
||
|
java.lang.Integer r0 = (java.lang.Integer) r0
|
||
|
o.fOD r1 = r9.d()
|
||
|
int r2 = r8.g
|
||
|
if (r2 > 0) goto L11
|
||
|
goto L14
|
||
|
L11:
|
||
|
r8.c()
|
||
|
L14:
|
||
|
r2 = 0
|
||
|
android.database.sqlite.SQLiteDatabase r3 = r8.n // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
o.fOs r4 = new o.fOs // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
r4.<init>(r1) // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
java.lang.String r1 = r1.d // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
java.lang.String[] r5 = o.C13026fOg.a // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
android.database.Cursor r1 = r3.rawQueryWithFactory(r4, r1, r5, r2) // Catch: java.lang.Throwable -> L70 java.lang.Exception -> L73
|
||
|
java.util.Map r3 = aBJ_(r1, r0) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
r4 = 1
|
||
|
if (r0 == 0) goto L5d
|
||
|
boolean r5 = r1.isLast() // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
if (r5 != 0) goto L5d
|
||
|
boolean r5 = r1.isAfterLast() // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
if (r5 != 0) goto L5d
|
||
|
int r5 = r8.l // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
int r5 = r5 + r4
|
||
|
r8.l = r5 // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
java.lang.String r6 = "cursorId"
|
||
|
java.lang.Integer r7 = java.lang.Integer.valueOf(r5) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
r3.put(r6, r7) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
o.fOB r6 = new o.fOB // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
int r0 = r0.intValue() // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
r6.<init>(r5, r0, r1) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
java.util.Map<java.lang.Integer, o.fOB> r0 = r8.e // Catch: java.lang.Throwable -> L59 java.lang.Exception -> L5b
|
||
|
java.lang.Integer r2 = java.lang.Integer.valueOf(r5) // Catch: java.lang.Throwable -> L59 java.lang.Exception -> L5b
|
||
|
r0.put(r2, r6) // Catch: java.lang.Throwable -> L59 java.lang.Exception -> L5b
|
||
|
r2 = r6
|
||
|
goto L5d
|
||
|
L59:
|
||
|
r9 = move-exception
|
||
|
goto L88
|
||
|
L5b:
|
||
|
r0 = move-exception
|
||
|
goto L6e
|
||
|
L5d:
|
||
|
r9.e(r3) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6c
|
||
|
if (r2 != 0) goto L67
|
||
|
if (r1 == 0) goto L67
|
||
|
r1.close()
|
||
|
L67:
|
||
|
return r4
|
||
|
L68:
|
||
|
r9 = move-exception
|
||
|
r6 = r2
|
||
|
r2 = r1
|
||
|
goto L87
|
||
|
L6c:
|
||
|
r0 = move-exception
|
||
|
r6 = r2
|
||
|
L6e:
|
||
|
r2 = r1
|
||
|
goto L75
|
||
|
L70:
|
||
|
r9 = move-exception
|
||
|
r1 = r2
|
||
|
goto L89
|
||
|
L73:
|
||
|
r0 = move-exception
|
||
|
r6 = r2
|
||
|
L75:
|
||
|
r8.a(r0, r9) // Catch: java.lang.Throwable -> L86
|
||
|
if (r6 == 0) goto L7d
|
||
|
r8.d(r6) // Catch: java.lang.Throwable -> L86
|
||
|
L7d:
|
||
|
if (r6 != 0) goto L84
|
||
|
if (r2 == 0) goto L84
|
||
|
r2.close()
|
||
|
L84:
|
||
|
r9 = 0
|
||
|
return r9
|
||
|
L86:
|
||
|
r9 = move-exception
|
||
|
L87:
|
||
|
r1 = r2
|
||
|
L88:
|
||
|
r2 = r6
|
||
|
L89:
|
||
|
if (r2 != 0) goto L90
|
||
|
if (r1 == 0) goto L90
|
||
|
r1.close()
|
||
|
L90:
|
||
|
throw r9
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: o.C13032fOm.b(o.fOP):boolean");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* JADX WARN: Not initialized variable reg: 6, insn: 0x00a9: MOVE (r5 I:??[int, float, boolean, short, byte, char, OBJECT, ARRAY]) = (r6 I:??[int, float, boolean, short, byte, char, OBJECT, ARRAY]), block:B:42:0x00a9 */
|
||
|
public final boolean e(fOP fop) {
|
||
|
boolean z;
|
||
|
boolean z2;
|
||
|
int intValue = ((Integer) fop.e("cursorId")).intValue();
|
||
|
boolean equals = Boolean.TRUE.equals(fop.e("cancel"));
|
||
|
if (this.g >= 2) {
|
||
|
c();
|
||
|
}
|
||
|
fOB fob = null;
|
||
|
if (!equals) {
|
||
|
fOB fob2 = this.e.get(Integer.valueOf(intValue));
|
||
|
boolean z3 = false;
|
||
|
try {
|
||
|
try {
|
||
|
if (fob2 == null) {
|
||
|
StringBuilder sb = new StringBuilder("Cursor ");
|
||
|
sb.append(intValue);
|
||
|
sb.append(" not found");
|
||
|
throw new IllegalStateException(sb.toString());
|
||
|
}
|
||
|
Cursor cursor = fob2.e;
|
||
|
Map<String, Object> aBJ_ = aBJ_(cursor, Integer.valueOf(fob2.d));
|
||
|
z = (cursor.isLast() || cursor.isAfterLast()) ? false : true;
|
||
|
if (z) {
|
||
|
try {
|
||
|
aBJ_.put("cursorId", Integer.valueOf(intValue));
|
||
|
} catch (Exception e) {
|
||
|
e = e;
|
||
|
a(e, fop);
|
||
|
if (fob2 != null) {
|
||
|
d(fob2);
|
||
|
} else {
|
||
|
fob = fob2;
|
||
|
}
|
||
|
if (!z && fob != null) {
|
||
|
d(fob);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
fop.e(aBJ_);
|
||
|
if (!z && fob2 != null) {
|
||
|
d(fob2);
|
||
|
}
|
||
|
return true;
|
||
|
} catch (Throwable th) {
|
||
|
th = th;
|
||
|
z3 = z2;
|
||
|
if (!z3 && fob2 != null) {
|
||
|
d(fob2);
|
||
|
}
|
||
|
throw th;
|
||
|
}
|
||
|
} catch (Exception e2) {
|
||
|
e = e2;
|
||
|
z = false;
|
||
|
} catch (Throwable th2) {
|
||
|
th = th2;
|
||
|
if (!z3) {
|
||
|
d(fob2);
|
||
|
}
|
||
|
throw th;
|
||
|
}
|
||
|
} else {
|
||
|
fOB fob3 = this.e.get(Integer.valueOf(intValue));
|
||
|
if (fob3 != null) {
|
||
|
d(fob3);
|
||
|
}
|
||
|
fop.e((Object) null);
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void d(fOB fob) {
|
||
|
try {
|
||
|
int i = fob.a;
|
||
|
if (this.g >= 2) {
|
||
|
c();
|
||
|
}
|
||
|
this.e.remove(Integer.valueOf(i));
|
||
|
fob.e.close();
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final void a(Exception exc, fOP fop) {
|
||
|
if (exc instanceof SQLiteCantOpenDatabaseException) {
|
||
|
StringBuilder sb = new StringBuilder("open_failed ");
|
||
|
sb.append(this.f);
|
||
|
fop.c("sqlite_error", sb.toString(), null);
|
||
|
} else if (exc instanceof SQLException) {
|
||
|
fop.c("sqlite_error", exc.getMessage(), fOU.c(fop));
|
||
|
} else {
|
||
|
fop.c("sqlite_error", exc.getMessage(), fOU.c(fop));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean d(fOP fop) {
|
||
|
fOD d = fop.d();
|
||
|
if (this.g > 0) {
|
||
|
c();
|
||
|
}
|
||
|
Boolean a = fop.a();
|
||
|
try {
|
||
|
SQLiteDatabase sQLiteDatabase = this.n;
|
||
|
String str = d.d;
|
||
|
List<Object> list = d.a;
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
if (list != null) {
|
||
|
Iterator<Object> it = list.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
arrayList.add(fOD.e(it.next()));
|
||
|
}
|
||
|
}
|
||
|
sQLiteDatabase.execSQL(str, arrayList.toArray(new Object[0]));
|
||
|
c(a);
|
||
|
return true;
|
||
|
} catch (Exception e) {
|
||
|
a(e, fop);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean a(fOP fop) {
|
||
|
Exception e;
|
||
|
if (!d(fop)) {
|
||
|
return false;
|
||
|
}
|
||
|
Cursor cursor = null;
|
||
|
if (fop.b()) {
|
||
|
fop.e((Object) null);
|
||
|
return true;
|
||
|
}
|
||
|
try {
|
||
|
try {
|
||
|
Cursor rawQuery = this.n.rawQuery("SELECT changes(), last_insert_rowid()", null);
|
||
|
if (rawQuery != null) {
|
||
|
try {
|
||
|
if (rawQuery.getCount() > 0 && rawQuery.moveToFirst()) {
|
||
|
if (rawQuery.getInt(0) == 0) {
|
||
|
if (this.g > 0) {
|
||
|
c();
|
||
|
rawQuery.getLong(1);
|
||
|
}
|
||
|
fop.e((Object) null);
|
||
|
if (rawQuery != null) {
|
||
|
rawQuery.close();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
long j = rawQuery.getLong(1);
|
||
|
if (this.g > 0) {
|
||
|
c();
|
||
|
}
|
||
|
fop.e(Long.valueOf(j));
|
||
|
if (rawQuery != null) {
|
||
|
rawQuery.close();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
} catch (Exception e2) {
|
||
|
e = e2;
|
||
|
cursor = rawQuery;
|
||
|
a(e, fop);
|
||
|
if (cursor != null) {
|
||
|
cursor.close();
|
||
|
}
|
||
|
return false;
|
||
|
} catch (Throwable th) {
|
||
|
th = th;
|
||
|
cursor = rawQuery;
|
||
|
if (cursor != null) {
|
||
|
cursor.close();
|
||
|
}
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
c();
|
||
|
fop.e((Object) null);
|
||
|
if (rawQuery != null) {
|
||
|
rawQuery.close();
|
||
|
}
|
||
|
return true;
|
||
|
} catch (Exception e3) {
|
||
|
e = e3;
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
th = th2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean c(fOP fop) {
|
||
|
Cursor cursor;
|
||
|
Exception e;
|
||
|
if (!d(fop)) {
|
||
|
return false;
|
||
|
}
|
||
|
Cursor cursor2 = null;
|
||
|
try {
|
||
|
if (fop.b()) {
|
||
|
fop.e((Object) null);
|
||
|
return true;
|
||
|
}
|
||
|
try {
|
||
|
cursor = this.n.rawQuery("SELECT changes()", null);
|
||
|
if (cursor != null) {
|
||
|
try {
|
||
|
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
|
||
|
int i = cursor.getInt(0);
|
||
|
if (this.g > 0) {
|
||
|
c();
|
||
|
}
|
||
|
fop.e(Integer.valueOf(i));
|
||
|
if (cursor != null) {
|
||
|
cursor.close();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
} catch (Exception e2) {
|
||
|
e = e2;
|
||
|
cursor2 = cursor;
|
||
|
a(e, fop);
|
||
|
if (cursor2 != null) {
|
||
|
cursor2.close();
|
||
|
}
|
||
|
return false;
|
||
|
} catch (Throwable th) {
|
||
|
th = th;
|
||
|
if (cursor != null) {
|
||
|
cursor.close();
|
||
|
}
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
c();
|
||
|
fop.e((Object) null);
|
||
|
if (cursor != null) {
|
||
|
cursor.close();
|
||
|
}
|
||
|
return true;
|
||
|
} catch (Exception e3) {
|
||
|
e = e3;
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
th = th2;
|
||
|
cursor = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean e() {
|
||
|
boolean z;
|
||
|
synchronized (this) {
|
||
|
z = this.k > 0;
|
||
|
}
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
private void c(Boolean bool) {
|
||
|
synchronized (this) {
|
||
|
if (Boolean.TRUE.equals(bool)) {
|
||
|
this.k++;
|
||
|
} else if (Boolean.FALSE.equals(bool)) {
|
||
|
this.k--;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|