362 lines
14 KiB
Java
362 lines
14 KiB
Java
package c.i.a.f.i.b;
|
|
|
|
import android.content.ContentValues;
|
|
import android.database.Cursor;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteDatabaseLockedException;
|
|
import android.database.sqlite.SQLiteException;
|
|
import android.database.sqlite.SQLiteFullException;
|
|
import android.os.SystemClock;
|
|
import androidx.annotation.WorkerThread;
|
|
/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
|
|
public final class m3 extends a5 {
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final p3 f1171c = new p3(this, this.a.b, "google_app_measurement_local.db");
|
|
public boolean d;
|
|
|
|
public m3(u4 u4Var) {
|
|
super(u4Var);
|
|
}
|
|
|
|
public static long w(SQLiteDatabase sQLiteDatabase) {
|
|
Cursor cursor = null;
|
|
try {
|
|
Cursor query = sQLiteDatabase.query("messages", new String[]{"rowid"}, "type=?", new String[]{"3"}, null, null, "rowid desc", "1");
|
|
if (query.moveToFirst()) {
|
|
long j = query.getLong(0);
|
|
query.close();
|
|
return j;
|
|
}
|
|
query.close();
|
|
return -1;
|
|
} catch (Throwable th) {
|
|
if (0 != 0) {
|
|
cursor.close();
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public final SQLiteDatabase A() throws SQLiteException {
|
|
if (this.d) {
|
|
return null;
|
|
}
|
|
SQLiteDatabase writableDatabase = this.f1171c.getWritableDatabase();
|
|
if (writableDatabase != null) {
|
|
return writableDatabase;
|
|
}
|
|
this.d = true;
|
|
return null;
|
|
}
|
|
|
|
@Override // c.i.a.f.i.b.a5
|
|
public final boolean v() {
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:47:0x00c2 A[SYNTHETIC, Splitter:B:47:0x00c2] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:53:0x00db */
|
|
/* JADX WARNING: Removed duplicated region for block: B:55:0x00e0 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:66:0x00f1 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:68:0x00f6 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:73:0x010c */
|
|
/* JADX WARNING: Removed duplicated region for block: B:75:0x0111 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:78:0x011c */
|
|
/* JADX WARNING: Removed duplicated region for block: B:80:0x0121 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:88:0x0114 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:90:0x0114 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:92:0x0114 A[SYNTHETIC] */
|
|
@WorkerThread
|
|
public final boolean x(int i, byte[] bArr) {
|
|
SQLiteDatabase sQLiteDatabase;
|
|
Throwable th;
|
|
SQLiteFullException e;
|
|
Cursor cursor;
|
|
SQLiteException e2;
|
|
b();
|
|
boolean z2 = false;
|
|
if (this.d) {
|
|
return false;
|
|
}
|
|
ContentValues contentValues = new ContentValues();
|
|
contentValues.put("type", Integer.valueOf(i));
|
|
contentValues.put("entry", bArr);
|
|
int i2 = 0;
|
|
int i3 = 5;
|
|
for (int i4 = 5; i2 < i4; i4 = 5) {
|
|
Cursor cursor2 = null;
|
|
Cursor cursor3 = null;
|
|
cursor2 = null;
|
|
r7 = null;
|
|
r7 = null;
|
|
SQLiteDatabase sQLiteDatabase2 = null;
|
|
Cursor cursor4 = null;
|
|
try {
|
|
sQLiteDatabase = A();
|
|
if (sQLiteDatabase == null) {
|
|
try {
|
|
this.d = true;
|
|
if (sQLiteDatabase != null) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
return z2;
|
|
} catch (SQLiteFullException e3) {
|
|
e = e3;
|
|
} catch (SQLiteDatabaseLockedException unused) {
|
|
try {
|
|
SystemClock.sleep((long) i3);
|
|
i3 += 20;
|
|
if (cursor4 != null) {
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
if (cursor4 != null) {
|
|
cursor4.close();
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (SQLiteException e4) {
|
|
e2 = e4;
|
|
cursor = cursor3;
|
|
sQLiteDatabase2 = sQLiteDatabase;
|
|
if (sQLiteDatabase2 != null) {
|
|
}
|
|
g().f.b("Error writing entry to local database", e2);
|
|
this.d = true;
|
|
if (cursor != null) {
|
|
}
|
|
if (sQLiteDatabase2 != null) {
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
}
|
|
} else {
|
|
sQLiteDatabase.beginTransaction();
|
|
long j = 0;
|
|
Cursor rawQuery = sQLiteDatabase.rawQuery("select count(1) from messages", null);
|
|
if (rawQuery != null) {
|
|
try {
|
|
if (rawQuery.moveToFirst()) {
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = z2 ? 1 : 0;
|
|
int i7 = z2 ? 1 : 0;
|
|
j = rawQuery.getLong(i5);
|
|
}
|
|
} catch (SQLiteFullException e5) {
|
|
e = e5;
|
|
cursor2 = rawQuery;
|
|
g().f.b("Error writing entry; local database full", e);
|
|
this.d = true;
|
|
if (cursor2 != null) {
|
|
cursor2.close();
|
|
}
|
|
if (sQLiteDatabase == null) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (SQLiteDatabaseLockedException unused2) {
|
|
cursor4 = rawQuery;
|
|
SystemClock.sleep((long) i3);
|
|
i3 += 20;
|
|
if (cursor4 != null) {
|
|
cursor4.close();
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (SQLiteException e6) {
|
|
e2 = e6;
|
|
cursor3 = rawQuery;
|
|
cursor = cursor3;
|
|
sQLiteDatabase2 = sQLiteDatabase;
|
|
if (sQLiteDatabase2 != null) {
|
|
try {
|
|
if (sQLiteDatabase2.inTransaction()) {
|
|
sQLiteDatabase2.endTransaction();
|
|
}
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
sQLiteDatabase = sQLiteDatabase2;
|
|
cursor4 = cursor;
|
|
if (cursor4 != null) {
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
g().f.b("Error writing entry to local database", e2);
|
|
this.d = true;
|
|
if (cursor != null) {
|
|
cursor.close();
|
|
}
|
|
if (sQLiteDatabase2 != null) {
|
|
sQLiteDatabase2.close();
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (Throwable th4) {
|
|
th = th4;
|
|
cursor4 = rawQuery;
|
|
if (cursor4 != null) {
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
if (j >= 100000) {
|
|
g().f.a("Data loss, local db full");
|
|
long j2 = (100000 - j) + 1;
|
|
String[] strArr = new String[1];
|
|
String l = Long.toString(j2);
|
|
char c2 = z2 ? 1 : 0;
|
|
char c3 = z2 ? 1 : 0;
|
|
char c4 = z2 ? 1 : 0;
|
|
strArr[c2] = l;
|
|
long delete = (long) sQLiteDatabase.delete("messages", "rowid in (select rowid from messages order by rowid asc limit ?)", strArr);
|
|
if (delete != j2) {
|
|
g().f.d("Different delete count than expected in local db. expected, received, difference", Long.valueOf(j2), Long.valueOf(delete), Long.valueOf(j2 - delete));
|
|
}
|
|
}
|
|
sQLiteDatabase.insertOrThrow("messages", null, contentValues);
|
|
sQLiteDatabase.setTransactionSuccessful();
|
|
sQLiteDatabase.endTransaction();
|
|
if (rawQuery != null) {
|
|
rawQuery.close();
|
|
}
|
|
sQLiteDatabase.close();
|
|
return true;
|
|
}
|
|
} catch (SQLiteFullException e7) {
|
|
e = e7;
|
|
sQLiteDatabase = null;
|
|
g().f.b("Error writing entry; local database full", e);
|
|
this.d = true;
|
|
if (cursor2 != null) {
|
|
}
|
|
if (sQLiteDatabase == null) {
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (SQLiteDatabaseLockedException unused3) {
|
|
sQLiteDatabase = null;
|
|
SystemClock.sleep((long) i3);
|
|
i3 += 20;
|
|
if (cursor4 != null) {
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (SQLiteException e8) {
|
|
e2 = e8;
|
|
cursor = null;
|
|
if (sQLiteDatabase2 != null) {
|
|
}
|
|
g().f.b("Error writing entry to local database", e2);
|
|
this.d = true;
|
|
if (cursor != null) {
|
|
}
|
|
if (sQLiteDatabase2 != null) {
|
|
}
|
|
i2++;
|
|
z2 = false;
|
|
} catch (Throwable th5) {
|
|
th = th5;
|
|
sQLiteDatabase = null;
|
|
if (cursor4 != null) {
|
|
}
|
|
if (sQLiteDatabase != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
g().n.a("Failed to write entry to local database");
|
|
return false;
|
|
}
|
|
|
|
@WorkerThread
|
|
public final void y() {
|
|
b();
|
|
try {
|
|
int delete = A().delete("messages", null, null) + 0;
|
|
if (delete > 0) {
|
|
g().n.b("Reset local analytics data. records", Integer.valueOf(delete));
|
|
}
|
|
} catch (SQLiteException e) {
|
|
g().f.b("Error resetting local analytics data. error", e);
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public final boolean z() {
|
|
b();
|
|
if (this.d || !this.a.b.getDatabasePath("google_app_measurement_local.db").exists()) {
|
|
return false;
|
|
}
|
|
int i = 5;
|
|
for (int i2 = 0; i2 < 5; i2++) {
|
|
SQLiteDatabase sQLiteDatabase = null;
|
|
try {
|
|
SQLiteDatabase A = A();
|
|
if (A == null) {
|
|
this.d = true;
|
|
if (A != null) {
|
|
A.close();
|
|
}
|
|
return false;
|
|
}
|
|
A.beginTransaction();
|
|
A.delete("messages", "type == ?", new String[]{Integer.toString(3)});
|
|
A.setTransactionSuccessful();
|
|
A.endTransaction();
|
|
A.close();
|
|
return true;
|
|
} catch (SQLiteFullException e) {
|
|
g().f.b("Error deleting app launch break from local database", e);
|
|
this.d = true;
|
|
if (0 != 0) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
} catch (SQLiteDatabaseLockedException unused) {
|
|
SystemClock.sleep((long) i);
|
|
i += 20;
|
|
if (0 != 0) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
} catch (SQLiteException e2) {
|
|
if (0 != 0) {
|
|
if (sQLiteDatabase.inTransaction()) {
|
|
sQLiteDatabase.endTransaction();
|
|
}
|
|
}
|
|
g().f.b("Error deleting app launch break from local database", e2);
|
|
this.d = true;
|
|
if (0 != 0) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
} catch (Throwable th) {
|
|
if (0 != 0) {
|
|
sQLiteDatabase.close();
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
g().i.a("Error deleting app launch break from local database in reasonable time");
|
|
return false;
|
|
}
|
|
}
|