package com.google.android.gms.common.data; import android.content.ContentValues; import android.database.CharArrayBuffer; import android.database.CursorIndexOutOfBoundsException; import android.database.CursorWindow; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.android.gms.common.annotation.KeepForSdk; import com.google.android.gms.common.annotation.KeepName; import com.google.android.gms.common.internal.Asserts; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; import com.google.android.gms.common.internal.safeparcel.SafeParcelWriter; import com.google.android.gms.common.internal.safeparcel.SafeParcelable; import java.io.Closeable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @KeepForSdk @KeepName @SafeParcelable.Class(creator = "DataHolderCreator", validate = true) /* loaded from: classes2.dex */ public final class DataHolder extends AbstractSafeParcelable implements Closeable { @NonNull @KeepForSdk public static final Parcelable.Creator CREATOR = new zaf(); private static final Builder zaf = new zab(new String[0], null); @SafeParcelable.VersionField(id = 1000) final int zaa; Bundle zab; int[] zac; int zad; boolean zae; @SafeParcelable.Field(getter = "getColumns", id = 1) private final String[] zag; @SafeParcelable.Field(getter = "getWindows", id = 2) private final CursorWindow[] zah; @SafeParcelable.Field(getter = "getStatusCode", id = 3) private final int zai; @Nullable @SafeParcelable.Field(getter = "getMetadata", id = 4) private final Bundle zaj; private boolean zak; @KeepForSdk public static class Builder { private final String[] zaa; private final ArrayList zab = new ArrayList(); private final HashMap zac = new HashMap(); public /* synthetic */ Builder(String[] strArr, String str, zac zacVar) { this.zaa = (String[]) Preconditions.checkNotNull(strArr); } /* JADX WARN: Multi-variable type inference failed */ @NonNull @KeepForSdk public DataHolder build(int i) { return new DataHolder(this, i); } @NonNull @KeepForSdk public Builder withRow(@NonNull ContentValues contentValues) { Asserts.checkNotNull(contentValues); HashMap hashMap = new HashMap(contentValues.size()); for (Map.Entry entry : contentValues.valueSet()) { hashMap.put(entry.getKey(), entry.getValue()); } return zaa(hashMap); } @NonNull public Builder zaa(@NonNull HashMap hashMap) { Asserts.checkNotNull(hashMap); this.zab.add(hashMap); return this; } @NonNull @KeepForSdk public DataHolder build(int i, @NonNull Bundle bundle) { return new DataHolder(this, i, bundle); } } @SafeParcelable.Constructor public DataHolder(@SafeParcelable.Param(id = 1000) int i, @SafeParcelable.Param(id = 1) String[] strArr, @SafeParcelable.Param(id = 2) CursorWindow[] cursorWindowArr, @SafeParcelable.Param(id = 3) int i2, @Nullable @SafeParcelable.Param(id = 4) Bundle bundle) { this.zae = false; this.zak = true; this.zaa = i; this.zag = strArr; this.zah = cursorWindowArr; this.zai = i2; this.zaj = bundle; } @KeepForSdk public DataHolder(@NonNull String[] strArr, @NonNull CursorWindow[] cursorWindowArr, int i, @Nullable Bundle bundle) { this.zae = false; this.zak = true; this.zaa = 1; this.zag = (String[]) Preconditions.checkNotNull(strArr); this.zah = (CursorWindow[]) Preconditions.checkNotNull(cursorWindowArr); this.zai = i; this.zaj = bundle; zad(); } /* JADX WARN: Multi-variable type inference failed */ @NonNull @KeepForSdk public static Builder builder(@NonNull String[] strArr) { return new Builder(strArr, null, 0 == true ? 1 : 0); } @NonNull @KeepForSdk public static DataHolder empty(int i) { return new DataHolder(zaf, i, (Bundle) null); } private final void zae(String str, int i) { Bundle bundle = this.zab; if (bundle == null || !bundle.containsKey(str)) { throw new IllegalArgumentException("No such column: ".concat(String.valueOf(str))); } if (isClosed()) { throw new IllegalArgumentException("Buffer is closed."); } if (i < 0 || i >= this.zad) { throw new CursorIndexOutOfBoundsException(i, this.zad); } } /* JADX WARN: Code restructure failed: missing block: B:61:0x012f, code lost: if (r5 != false) goto L67; */ /* JADX WARN: Code restructure failed: missing block: B:62:0x0131, code lost: r5 = new java.lang.StringBuilder(); r5.append("Couldn't populate window data for row "); r5.append(r4); r5.append(" - allocating new window."); r2.freeLastRow(); r2 = new android.database.CursorWindow(false); r2.setStartPosition(r4); r2.setNumColumns(r12.zaa.length); r3.add(r2); r4 = r4 - 1; r5 = true; */ /* JADX WARN: Code restructure failed: missing block: B:64:0x015c, code lost: r4 = r4 + 1; */ /* JADX WARN: Code restructure failed: missing block: B:67:0x0166, code lost: throw new com.google.android.gms.common.data.zad("Could not add the value to a new CursorWindow. The size of value may be larger than what a CursorWindow can handle."); */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static android.database.CursorWindow[] zaf(com.google.android.gms.common.data.DataHolder.Builder r12, int r13) { /* Method dump skipped, instructions count: 391 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.data.DataHolder.zaf(com.google.android.gms.common.data.DataHolder$Builder, int):android.database.CursorWindow[]"); } @Override // java.io.Closeable, java.lang.AutoCloseable @KeepForSdk public void close() { synchronized (this) { try { if (!this.zae) { this.zae = true; int i = 0; while (true) { CursorWindow[] cursorWindowArr = this.zah; if (i >= cursorWindowArr.length) { break; } cursorWindowArr[i].close(); i++; } } } catch (Throwable th) { throw th; } } } public final void finalize() throws Throwable { try { if (this.zak && this.zah.length > 0 && !isClosed()) { close(); Log.e("DataBuffer", "Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: " + toString() + ")"); } } finally { super.finalize(); } } @KeepForSdk public boolean getBoolean(@NonNull String str, int i, int i2) { zae(str, i); return Long.valueOf(this.zah[i2].getLong(i, this.zab.getInt(str))).longValue() == 1; } @NonNull @KeepForSdk public byte[] getByteArray(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getBlob(i, this.zab.getInt(str)); } @KeepForSdk public int getCount() { return this.zad; } @KeepForSdk public int getInteger(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getInt(i, this.zab.getInt(str)); } @KeepForSdk public long getLong(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getLong(i, this.zab.getInt(str)); } @Nullable @KeepForSdk public Bundle getMetadata() { return this.zaj; } @KeepForSdk public int getStatusCode() { return this.zai; } @NonNull @KeepForSdk public String getString(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getString(i, this.zab.getInt(str)); } @KeepForSdk public int getWindowIndex(int i) { int length; int i2 = 0; Preconditions.checkState(i >= 0 && i < this.zad); while (true) { int[] iArr = this.zac; length = iArr.length; if (i2 >= length) { break; } if (i < iArr[i2]) { i2--; break; } i2++; } return i2 == length ? i2 - 1 : i2; } @KeepForSdk public boolean hasColumn(@NonNull String str) { return this.zab.containsKey(str); } @KeepForSdk public boolean hasNull(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].isNull(i, this.zab.getInt(str)); } @KeepForSdk public boolean isClosed() { boolean z; synchronized (this) { z = this.zae; } return z; } @Override // android.os.Parcelable public final void writeToParcel(@NonNull Parcel parcel, int i) { String[] strArr = this.zag; int beginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel); SafeParcelWriter.writeStringArray(parcel, 1, strArr, false); SafeParcelWriter.writeTypedArray(parcel, 2, this.zah, i, false); SafeParcelWriter.writeInt(parcel, 3, getStatusCode()); SafeParcelWriter.writeBundle(parcel, 4, getMetadata(), false); SafeParcelWriter.writeInt(parcel, 1000, this.zaa); SafeParcelWriter.finishObjectHeader(parcel, beginObjectHeader); if ((i & 1) != 0) { close(); } } public final double zaa(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getDouble(i, this.zab.getInt(str)); } public final float zab(@NonNull String str, int i, int i2) { zae(str, i); return this.zah[i2].getFloat(i, this.zab.getInt(str)); } public final void zac(@NonNull String str, int i, int i2, @NonNull CharArrayBuffer charArrayBuffer) { zae(str, i); this.zah[i2].copyStringToBuffer(i, this.zab.getInt(str), charArrayBuffer); } public final void zad() { this.zab = new Bundle(); int i = 0; int i2 = 0; while (true) { String[] strArr = this.zag; if (i2 >= strArr.length) { break; } this.zab.putInt(strArr[i2], i2); i2++; } this.zac = new int[this.zah.length]; int i3 = 0; while (true) { CursorWindow[] cursorWindowArr = this.zah; if (i >= cursorWindowArr.length) { this.zad = i3; return; } this.zac[i] = i3; i3 += this.zah[i].getNumRows() - (i3 - cursorWindowArr[i].getStartPosition()); i++; } } /* JADX WARN: Finally extract failed */ /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public DataHolder(@androidx.annotation.NonNull android.database.Cursor r8, int r9, @androidx.annotation.Nullable android.os.Bundle r10) { /* r7 = this; com.google.android.gms.common.sqlite.CursorWrapper r0 = new com.google.android.gms.common.sqlite.CursorWrapper r0.(r8) java.lang.String[] r8 = r0.getColumnNames() java.util.ArrayList r1 = new java.util.ArrayList r1.() int r2 = r0.getCount() // Catch: java.lang.Throwable -> L2e android.database.CursorWindow r3 = r0.getWindow() // Catch: java.lang.Throwable -> L2e r4 = 0 r5 = 0 if (r3 == 0) goto L30 int r6 = r3.getStartPosition() // Catch: java.lang.Throwable -> L2e if (r6 != 0) goto L30 r3.acquireReference() // Catch: java.lang.Throwable -> L2e r0.setWindow(r4) // Catch: java.lang.Throwable -> L2e r1.add(r3) // Catch: java.lang.Throwable -> L2e int r3 = r3.getNumRows() // Catch: java.lang.Throwable -> L2e goto L31 L2e: r8 = move-exception goto L78 L30: r3 = r5 L31: if (r3 >= r2) goto L65 boolean r6 = r0.moveToPosition(r3) // Catch: java.lang.Throwable -> L2e if (r6 == 0) goto L65 android.database.CursorWindow r6 = r0.getWindow() // Catch: java.lang.Throwable -> L2e if (r6 == 0) goto L46 r6.acquireReference() // Catch: java.lang.Throwable -> L2e r0.setWindow(r4) // Catch: java.lang.Throwable -> L2e goto L51 L46: android.database.CursorWindow r6 = new android.database.CursorWindow // Catch: java.lang.Throwable -> L2e r6.(r5) // Catch: java.lang.Throwable -> L2e r6.setStartPosition(r3) // Catch: java.lang.Throwable -> L2e r0.fillWindow(r3, r6) // Catch: java.lang.Throwable -> L2e L51: int r3 = r6.getNumRows() // Catch: java.lang.Throwable -> L2e if (r3 != 0) goto L58 goto L65 L58: r1.add(r6) // Catch: java.lang.Throwable -> L2e int r3 = r6.getStartPosition() // Catch: java.lang.Throwable -> L2e int r6 = r6.getNumRows() // Catch: java.lang.Throwable -> L2e int r3 = r3 + r6 goto L31 L65: r0.close() int r0 = r1.size() android.database.CursorWindow[] r0 = new android.database.CursorWindow[r0] java.lang.Object[] r0 = r1.toArray(r0) android.database.CursorWindow[] r0 = (android.database.CursorWindow[]) r0 r7.(r8, r0, r9, r10) return L78: r0.close() throw r8 */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.data.DataHolder.(android.database.Cursor, int, android.os.Bundle):void"); } private DataHolder(Builder builder, int i, @Nullable Bundle bundle) { this(builder.zaa, zaf(builder, -1), i, (Bundle) null); } }