what-the-bank/sources/com/google/android/gms/internal/gtm/zzey.java

613 lines
26 KiB
Java

package com.google.android.gms.internal.gtm;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.text.TextUtils;
import com.google.android.gms.auth.api.credentials.CredentialsApi;
import com.google.android.gms.common.util.Clock;
import com.google.android.gms.common.util.CrashUtils;
import com.google.android.gms.common.util.DefaultClock;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class zzey implements zzem {
private final String zzaih;
private long zzaii;
private final int zzaij;
private final zzfa zzaoj;
private volatile zzed zzaok;
private final zzen zzaol;
private final Context zzrm;
private Clock zzsd;
private static final String zzaog = String.format("CREATE TABLE IF NOT EXISTS %s ('%s' TEXT UNIQUE);", "gtm_hit_unique_ids", "hit_unique_id");
private static final String zzxj = String.format("CREATE TABLE IF NOT EXISTS %s ( '%s' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, '%s' INTEGER NOT NULL, '%s' TEXT NOT NULL, '%s' INTEGER NOT NULL, '%s' TEXT NOT NULL, '%s' TEXT UNIQUE, '%s' TEXT, '%s' TEXT);", "gtm_hits", "hit_id", "hit_time", "hit_url", "hit_first_send_time", "hit_method", "hit_unique_id", "hit_headers", "hit_body");
private static final String zzaoh = String.format("CREATE TRIGGER IF NOT EXISTS %s DELETE ON %s FOR EACH ROW WHEN OLD.%s NOTNULL BEGIN INSERT OR IGNORE INTO %s (%s) VALUES (OLD.%s); END;", "save_unique_on_delete", "gtm_hits", "hit_unique_id", "gtm_hit_unique_ids", "hit_unique_id", "hit_unique_id");
private static final String zzaoi = String.format("CREATE TRIGGER IF NOT EXISTS %s BEFORE INSERT ON %s FOR EACH ROW WHEN NEW.%s NOT NULL BEGIN SELECT RAISE(ABORT, 'Duplicate unique ID.') WHERE EXISTS (SELECT 1 FROM %s WHERE %s = NEW.%s); END;", "check_unique_on_insert", "gtm_hits", "hit_unique_id", "gtm_hit_unique_ids", "hit_unique_id", "hit_unique_id");
/* JADX INFO: Access modifiers changed from: package-private */
public zzey(zzen zzenVar, Context context) {
this(zzenVar, context, "gtm_urls.db", CredentialsApi.CREDENTIAL_PICKER_REQUEST_CODE);
}
private zzey(zzen zzenVar, Context context, String str, int i) {
Context applicationContext = context.getApplicationContext();
this.zzrm = applicationContext;
this.zzaih = str;
this.zzaol = zzenVar;
this.zzsd = DefaultClock.getInstance();
this.zzaoj = new zzfa(this, applicationContext, str);
this.zzaok = new zzfu(applicationContext, new zzez(this));
this.zzaii = 0L;
this.zzaij = CredentialsApi.CREDENTIAL_PICKER_REQUEST_CODE;
}
@Override // com.google.android.gms.internal.gtm.zzem
public final void zza(long j, String str, String str2, String str3, Map<String, String> map, String str4) {
long currentTimeMillis = this.zzsd.currentTimeMillis();
if (currentTimeMillis > this.zzaii + 86400000) {
this.zzaii = currentTimeMillis;
SQLiteDatabase zzau = zzau("Error opening database for deleteStaleHits.");
if (zzau != null) {
int delete = zzau.delete("gtm_hits", "HIT_TIME < ?", new String[]{Long.toString(this.zzsd.currentTimeMillis() - 2592000000L)});
StringBuilder sb = new StringBuilder(31);
sb.append("Removed ");
sb.append(delete);
sb.append(" stale hits.");
zzev.zzab(sb.toString());
this.zzaol.zze(zzbv("gtm_hits") == 0);
}
}
int zzbv = (zzbv("gtm_hits") - this.zzaij) + 1;
if (zzbv > 0) {
List<String> zzz = zzz(zzbv);
int size = zzz.size();
StringBuilder sb2 = new StringBuilder(51);
sb2.append("Store full, deleting ");
sb2.append(size);
sb2.append(" hits to make room.");
zzev.zzab(sb2.toString());
zza((String[]) zzz.toArray(new String[0]));
}
SQLiteDatabase zzau2 = zzau("Error opening database for putHit");
if (zzau2 != null) {
ContentValues contentValues = new ContentValues();
contentValues.put("hit_time", Long.valueOf(j));
contentValues.put("hit_url", str);
contentValues.put("hit_first_send_time", (Integer) 0);
if (str2 == null) {
str2 = "GET";
}
contentValues.put("hit_method", str2);
contentValues.put("hit_unique_id", str3);
contentValues.put("hit_headers", map == null ? null : new JSONObject(map).toString());
contentValues.put("hit_body", str4);
try {
zzau2.insertOrThrow("gtm_hits", null, contentValues);
StringBuilder sb3 = new StringBuilder(String.valueOf(str).length() + 19);
sb3.append("Hit stored (url = ");
sb3.append(str);
sb3.append(")");
zzev.zzab(sb3.toString());
this.zzaol.zze(false);
} catch (SQLiteConstraintException unused) {
String valueOf = String.valueOf(str);
zzev.zzab(valueOf.length() != 0 ? "Hit has already been sent: ".concat(valueOf) : new String("Hit has already been sent: "));
} catch (SQLiteException e) {
String valueOf2 = String.valueOf(e.getMessage());
zzev.zzac(valueOf2.length() != 0 ? "Error storing hit: ".concat(valueOf2) : new String("Error storing hit: "));
}
}
if (zzfd.zzkr().isPreview()) {
zzev.zzab("Sending hits immediately under preview.");
dispatch();
}
}
/* JADX WARN: Code restructure failed: missing block: B:12:0x003b, code lost:
if (r12.moveToFirst() != false) goto L12;
*/
/* JADX WARN: Code restructure failed: missing block: B:13:0x003d, code lost:
r1.add(java.lang.String.valueOf(r12.getLong(0)));
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x004c, code lost:
if (r12.moveToNext() != false) goto L34;
*/
/* JADX WARN: Code restructure failed: missing block: B:18:0x004e, code lost:
if (r12 == null) goto L27;
*/
/* JADX WARN: Code restructure failed: missing block: B:19:0x0050, code lost:
r12.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:20:0x0079, code lost:
return r1;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final java.util.List<java.lang.String> zzz(int r15) {
/*
r14 = this;
java.lang.String r0 = "hit_id"
java.util.ArrayList r1 = new java.util.ArrayList
r1.<init>()
if (r15 > 0) goto Lf
java.lang.String r15 = "Invalid maxHits specified. Skipping"
com.google.android.gms.internal.gtm.zzev.zzac(r15)
return r1
Lf:
java.lang.String r2 = "Error opening database for peekHitIds."
android.database.sqlite.SQLiteDatabase r3 = r14.zzau(r2)
if (r3 != 0) goto L18
return r1
L18:
r2 = 1
r12 = 0
java.lang.String[] r5 = new java.lang.String[r2] // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
r13 = 0
r5[r13] = r0 // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
java.lang.Object[] r2 = new java.lang.Object[r2] // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
r2[r13] = r0 // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
java.lang.String r0 = "%s ASC"
java.lang.String r10 = java.lang.String.format(r0, r2) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
java.lang.String r11 = java.lang.Integer.toString(r15) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
java.lang.String r4 = "gtm_hits"
r6 = 0
r7 = 0
r8 = 0
r9 = 0
android.database.Cursor r12 = r3.query(r4, r5, r6, r7, r8, r9, r10, r11) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
boolean r15 = r12.moveToFirst() // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
if (r15 == 0) goto L4e
L3d:
long r2 = r12.getLong(r13) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
java.lang.String r15 = java.lang.String.valueOf(r2) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
r1.add(r15) // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
boolean r15 = r12.moveToNext() // Catch: java.lang.Throwable -> L54 android.database.sqlite.SQLiteException -> L56
if (r15 != 0) goto L3d
L4e:
if (r12 == 0) goto L79
r12.close()
goto L79
L54:
r15 = move-exception
goto L7a
L56:
r15 = move-exception
java.lang.String r15 = r15.getMessage() // Catch: java.lang.Throwable -> L54
java.lang.String r15 = java.lang.String.valueOf(r15) // Catch: java.lang.Throwable -> L54
int r0 = r15.length() // Catch: java.lang.Throwable -> L54
java.lang.String r2 = "Error in peekHits fetching hitIds: "
if (r0 == 0) goto L6c
java.lang.String r15 = r2.concat(r15) // Catch: java.lang.Throwable -> L54
goto L71
L6c:
java.lang.String r15 = new java.lang.String // Catch: java.lang.Throwable -> L54
r15.<init>(r2) // Catch: java.lang.Throwable -> L54
L71:
com.google.android.gms.internal.gtm.zzev.zzac(r15) // Catch: java.lang.Throwable -> L54
if (r12 == 0) goto L79
r12.close()
L79:
return r1
L7a:
if (r12 == 0) goto L7f
r12.close()
L7f:
throw r15
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.gtm.zzey.zzz(int):java.util.List");
}
/* JADX WARN: Code restructure failed: missing block: B:111:0x006f, code lost:
r0 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:112:0x0070, code lost:
r14 = r13;
*/
/* JADX WARN: Code restructure failed: missing block: B:12:0x0050, code lost:
if (r13.moveToFirst() != false) goto L118;
*/
/* JADX WARN: Code restructure failed: missing block: B:13:0x0078, code lost:
if (r13 == null) goto L19;
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x007a, code lost:
r13.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:18:0x00a3, code lost:
r2 = r12;
r17 = r13;
*/
/* JADX WARN: Code restructure failed: missing block: B:20:0x00af, code lost:
r13 = r3.query("gtm_hits", new java.lang.String[]{"hit_id", "hit_url", "hit_method", "hit_headers", "hit_body"}, null, null, null, null, java.lang.String.format("%s ASC", "hit_id"), java.lang.Integer.toString(40));
*/
/* JADX WARN: Code restructure failed: missing block: B:23:0x00b7, code lost:
if (r13.moveToFirst() == false) goto L45;
*/
/* JADX WARN: Code restructure failed: missing block: B:24:0x00b9, code lost:
r1 = 0;
*/
/* JADX WARN: Code restructure failed: missing block: B:26:0x00c5, code lost:
if (((android.database.sqlite.SQLiteCursor) r13).getWindow().getNumRows() <= 0) goto L41;
*/
/* JADX WARN: Code restructure failed: missing block: B:27:0x00c7, code lost:
((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzbc(r13.getString(1));
((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzbt(r13.getString(2));
((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzbu(r13.getString(4));
*/
/* JADX WARN: Code restructure failed: missing block: B:30:0x00f0, code lost:
r0 = r13.getString(3);
*/
/* JADX WARN: Code restructure failed: missing block: B:31:0x00f4, code lost:
if (r0 == null) goto L37;
*/
/* JADX WARN: Code restructure failed: missing block: B:32:0x00f6, code lost:
r6 = new org.json.JSONObject(r0);
r0 = r6.names();
r7 = new java.util.HashMap();
r8 = 0;
*/
/* JADX WARN: Code restructure failed: missing block: B:34:0x0109, code lost:
if (r8 >= r0.length()) goto L126;
*/
/* JADX WARN: Code restructure failed: missing block: B:35:0x010b, code lost:
r9 = r0.getString(r8);
r7.put(r9, (java.lang.String) r6.opt(r9));
*/
/* JADX WARN: Code restructure failed: missing block: B:36:0x0118, code lost:
r8 = r8 + 1;
*/
/* JADX WARN: Code restructure failed: missing block: B:38:0x011c, code lost:
((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzg(r7);
*/
/* JADX WARN: Code restructure failed: missing block: B:39:0x0168, code lost:
r1 = r1 + 1;
*/
/* JADX WARN: Code restructure failed: missing block: B:41:0x016e, code lost:
if (r13.moveToNext() == false) goto L124;
*/
/* JADX WARN: Code restructure failed: missing block: B:44:0x011b, code lost:
r7 = null;
*/
/* JADX WARN: Code restructure failed: missing block: B:46:0x0127, code lost:
r0 = move-exception;
*/
/* JADX WARN: Code restructure failed: missing block: B:47:0x0128, code lost:
com.google.android.gms.internal.gtm.zzev.zzac(java.lang.String.format("Failed to read headers for hitId %d: %s", java.lang.Long.valueOf(((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzih()), r0.getMessage()));
*/
/* JADX WARN: Code restructure failed: missing block: B:48:0x014b, code lost:
com.google.android.gms.internal.gtm.zzev.zzac(java.lang.String.format("HitString for hitId %d too large. Hit will be deleted.", java.lang.Long.valueOf(((com.google.android.gms.internal.gtm.zzeh) r2.get(r1)).zzih())));
*/
/* JADX WARN: Code restructure failed: missing block: B:50:0x0170, code lost:
if (r13 != null) goto L46;
*/
/* JADX WARN: Code restructure failed: missing block: B:51:0x0172, code lost:
r13.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:52:0x0175, code lost:
return r2;
*/
/* JADX WARN: Code restructure failed: missing block: B:53:0x0176, code lost:
r0 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:54:0x0188, code lost:
r0 = java.lang.String.valueOf(r0.getMessage());
*/
/* JADX WARN: Code restructure failed: missing block: B:56:0x0196, code lost:
if (r0.length() == 0) goto L64;
*/
/* JADX WARN: Code restructure failed: missing block: B:57:0x0198, code lost:
r0 = "Error in peekHits fetching hit url: ".concat(r0);
*/
/* JADX WARN: Code restructure failed: missing block: B:58:0x01a2, code lost:
com.google.android.gms.internal.gtm.zzev.zzac(r0);
r0 = new java.util.ArrayList();
r12 = r2;
r1 = r2.size();
r3 = false;
*/
/* JADX WARN: Code restructure failed: missing block: B:60:0x01b4, code lost:
r5 = r2.get(r14);
r14 = r14 + 1;
r5 = (com.google.android.gms.internal.gtm.zzeh) r5;
*/
/* JADX WARN: Code restructure failed: missing block: B:61:0x01c4, code lost:
if (android.text.TextUtils.isEmpty(r5.zzij()) == false) goto L130;
*/
/* JADX WARN: Code restructure failed: missing block: B:62:0x01c6, code lost:
if (r3 == false) goto L70;
*/
/* JADX WARN: Code restructure failed: missing block: B:63:0x01c8, code lost:
r3 = true;
*/
/* JADX WARN: Code restructure failed: missing block: B:65:0x01c9, code lost:
r0.add(r5);
*/
/* JADX WARN: Code restructure failed: missing block: B:67:0x01cd, code lost:
if (r13 != null) goto L74;
*/
/* JADX WARN: Code restructure failed: missing block: B:68:0x01cf, code lost:
r13.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:69:0x01d2, code lost:
return r0;
*/
/* JADX WARN: Code restructure failed: missing block: B:73:0x019d, code lost:
r0 = new java.lang.String("Error in peekHits fetching hit url: ");
*/
/* JADX WARN: Code restructure failed: missing block: B:74:0x01d3, code lost:
r0 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:75:0x01d4, code lost:
if (r13 != null) goto L78;
*/
/* JADX WARN: Code restructure failed: missing block: B:76:0x01d6, code lost:
r13.close();
*/
/* JADX WARN: Code restructure failed: missing block: B:77:0x01d9, code lost:
throw r0;
*/
/* JADX WARN: Code restructure failed: missing block: B:79:0x017a, code lost:
r0 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:80:0x0186, code lost:
r13 = r17;
*/
/* JADX WARN: Code restructure failed: missing block: B:81:0x0178, code lost:
r0 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:82:0x017f, code lost:
r13 = r17;
*/
/* JADX WARN: Code restructure failed: missing block: B:84:0x0182, code lost:
r0 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:85:0x0183, code lost:
r2 = r12;
r17 = r13;
*/
/* JADX WARN: Code restructure failed: missing block: B:86:0x017c, code lost:
r0 = th;
*/
/* JADX WARN: Code restructure failed: missing block: B:87:0x017d, code lost:
r17 = r13;
*/
/* JADX WARN: Code restructure failed: missing block: B:89:0x0052, code lost:
r12.add(new com.google.android.gms.internal.gtm.zzeh(r13.getLong(0), r13.getLong(1), r13.getLong(2)));
*/
/* JADX WARN: Code restructure failed: missing block: B:90:0x006c, code lost:
if (r13.moveToNext() != false) goto L132;
*/
/* JADX WARN: Code restructure failed: missing block: B:94:0x0073, code lost:
r0 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:95:0x0074, code lost:
r2 = r12;
r14 = r13;
*/
/* JADX WARN: Removed duplicated region for block: B:100:0x01ff A[Catch: all -> 0x0212, TRY_ENTER, TryCatch #8 {all -> 0x0212, blocks: (B:97:0x01ef, B:100:0x01ff, B:101:0x0209, B:106:0x0204), top: B:96:0x01ef }] */
/* JADX WARN: Removed duplicated region for block: B:103:0x020e */
/* JADX WARN: Removed duplicated region for block: B:106:0x0204 A[Catch: all -> 0x0212, TryCatch #8 {all -> 0x0212, blocks: (B:97:0x01ef, B:100:0x01ff, B:101:0x0209, B:106:0x0204), top: B:96:0x01ef }] */
/* JADX WARN: Removed duplicated region for block: B:109:0x0215 */
/* JADX WARN: Removed duplicated region for block: B:57:0x0198 A[Catch: all -> 0x01d3, TRY_ENTER, TryCatch #9 {all -> 0x01d3, blocks: (B:22:0x00b3, B:25:0x00ba, B:27:0x00c7, B:30:0x00f0, B:32:0x00f6, B:33:0x0105, B:35:0x010b, B:38:0x011c, B:39:0x0168, B:40:0x016a, B:47:0x0128, B:48:0x014b, B:54:0x0188, B:57:0x0198, B:58:0x01a2, B:60:0x01b4, B:65:0x01c9, B:73:0x019d), top: B:21:0x00b3 }] */
/* JADX WARN: Removed duplicated region for block: B:60:0x01b4 A[Catch: all -> 0x01d3, TryCatch #9 {all -> 0x01d3, blocks: (B:22:0x00b3, B:25:0x00ba, B:27:0x00c7, B:30:0x00f0, B:32:0x00f6, B:33:0x0105, B:35:0x010b, B:38:0x011c, B:39:0x0168, B:40:0x016a, B:47:0x0128, B:48:0x014b, B:54:0x0188, B:57:0x0198, B:58:0x01a2, B:60:0x01b4, B:65:0x01c9, B:73:0x019d), top: B:21:0x00b3 }] */
/* JADX WARN: Removed duplicated region for block: B:68:0x01cf */
/* JADX WARN: Removed duplicated region for block: B:73:0x019d A[Catch: all -> 0x01d3, TryCatch #9 {all -> 0x01d3, blocks: (B:22:0x00b3, B:25:0x00ba, B:27:0x00c7, B:30:0x00f0, B:32:0x00f6, B:33:0x0105, B:35:0x010b, B:38:0x011c, B:39:0x0168, B:40:0x016a, B:47:0x0128, B:48:0x014b, B:54:0x0188, B:57:0x0198, B:58:0x01a2, B:60:0x01b4, B:65:0x01c9, B:73:0x019d), top: B:21:0x00b3 }] */
/* JADX WARN: Removed duplicated region for block: B:76:0x01d6 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final java.util.List<com.google.android.gms.internal.gtm.zzeh> zzaa(int r21) {
/*
Method dump skipped, instructions count: 537
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.gtm.zzey.zzaa(int):java.util.List");
}
private final void zza(String[] strArr) {
SQLiteDatabase zzau;
if (strArr == null || strArr.length == 0 || (zzau = zzau("Error opening database for deleteHits.")) == null) {
return;
}
try {
zzau.delete("gtm_hits", String.format("HIT_ID in (%s)", TextUtils.join(",", Collections.nCopies(strArr.length, "?"))), strArr);
this.zzaol.zze(zzbv("gtm_hits") == 0);
} catch (SQLiteException e) {
String valueOf = String.valueOf(e.getMessage());
zzev.zzac(valueOf.length() != 0 ? "Error deleting hits: ".concat(valueOf) : new String("Error deleting hits: "));
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void zze(long j) {
zza(new String[]{String.valueOf(j)});
}
/* JADX INFO: Access modifiers changed from: private */
public final void zzb(long j, long j2) {
SQLiteDatabase zzau = zzau("Error opening database for getNumStoredHits.");
if (zzau == null) {
return;
}
ContentValues contentValues = new ContentValues();
contentValues.put("hit_first_send_time", Long.valueOf(j2));
try {
zzau.update("gtm_hits", contentValues, "hit_id=?", new String[]{String.valueOf(j)});
} catch (SQLiteException e) {
String message = e.getMessage();
StringBuilder sb = new StringBuilder(String.valueOf(message).length() + 70);
sb.append("Error setting HIT_FIRST_DISPATCH_TIME for hitId ");
sb.append(j);
sb.append(": ");
sb.append(message);
zzev.zzac(sb.toString());
zze(j);
}
}
private final int zzbv(String str) {
SQLiteDatabase zzau = zzau("Error opening database for getNumRecords.");
if (zzau == null) {
return 0;
}
Cursor cursor = null;
try {
try {
String valueOf = String.valueOf(str);
cursor = zzau.rawQuery(valueOf.length() != 0 ? "SELECT COUNT(*) from ".concat(valueOf) : new String("SELECT COUNT(*) from "), null);
r1 = cursor.moveToFirst() ? (int) cursor.getLong(0) : 0;
if (cursor != null) {
cursor.close();
}
} catch (SQLiteException e) {
String valueOf2 = String.valueOf(e.getMessage());
zzev.zzac(valueOf2.length() != 0 ? "Error getting numStoredRecords: ".concat(valueOf2) : new String("Error getting numStoredRecords: "));
if (cursor != null) {
cursor.close();
}
}
return r1;
} catch (Throwable th) {
if (cursor != null) {
cursor.close();
}
throw th;
}
}
private final int zziw() {
SQLiteDatabase zzau = zzau("Error opening database for getNumStoredHits.");
int i = 0;
if (zzau == null) {
return 0;
}
Cursor cursor = null;
try {
try {
cursor = zzau.query("gtm_hits", new String[]{"hit_id", "hit_first_send_time"}, "hit_first_send_time=0", null, null, null, null);
i = cursor.getCount();
if (cursor != null) {
cursor.close();
}
} catch (SQLiteException e) {
String valueOf = String.valueOf(e.getMessage());
zzev.zzac(valueOf.length() != 0 ? "Error getting num untried hits: ".concat(valueOf) : new String("Error getting num untried hits: "));
if (cursor != null) {
cursor.close();
}
}
return i;
} catch (Throwable th) {
if (cursor != null) {
cursor.close();
}
throw th;
}
}
@Override // com.google.android.gms.internal.gtm.zzem
public final void dispatch() {
zzev.zzab("GTM Dispatch running...");
if (this.zzaok.zzhy()) {
List<zzeh> zzaa = zzaa(40);
if (zzaa.isEmpty()) {
zzev.zzab("...nothing to dispatch");
this.zzaol.zze(true);
} else {
this.zzaok.zzd(zzaa);
if (zziw() > 0) {
zzfo.zzkv().dispatch();
}
}
}
}
private final SQLiteDatabase zzau(String str) {
try {
return this.zzaoj.getWritableDatabase();
} catch (SQLiteException e) {
Context context = this.zzrm;
zzev.zzb(str, e);
if (CrashUtils.addDynamiteErrorToDropBox(context, e)) {
zzev.zzab("Crash reported successfully.");
return null;
}
zzev.zzab("Failed to report crash");
return null;
}
}
}