428 lines
16 KiB
Java
428 lines
16 KiB
Java
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 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 java.io.Closeable;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class DataHolder extends AbstractSafeParcelable implements Closeable {
|
|
public static final Parcelable.Creator<DataHolder> CREATOR = new zaf();
|
|
private static final Builder zaf = new zab(new String[0], null);
|
|
final int zaa;
|
|
Bundle zab;
|
|
int[] zac;
|
|
int zad;
|
|
boolean zae;
|
|
private final String[] zag;
|
|
private final CursorWindow[] zah;
|
|
private final int zai;
|
|
private final Bundle zaj;
|
|
private boolean zak;
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class Builder {
|
|
private final String[] zaa;
|
|
private final ArrayList<HashMap<String, Object>> zab = new ArrayList<>();
|
|
private final HashMap<Object, Integer> zac = new HashMap<>();
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public /* synthetic */ Builder(String[] strArr, String str, zac zacVar) {
|
|
this.zaa = (String[]) Preconditions.checkNotNull(strArr);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public DataHolder build(int i) {
|
|
return new DataHolder(this, i);
|
|
}
|
|
|
|
public Builder withRow(ContentValues contentValues) {
|
|
Asserts.checkNotNull(contentValues);
|
|
HashMap<String, Object> hashMap = new HashMap<>(contentValues.size());
|
|
for (Map.Entry<String, Object> entry : contentValues.valueSet()) {
|
|
hashMap.put(entry.getKey(), entry.getValue());
|
|
}
|
|
return zaa(hashMap);
|
|
}
|
|
|
|
public Builder zaa(HashMap<String, Object> hashMap) {
|
|
Asserts.checkNotNull(hashMap);
|
|
this.zab.add(hashMap);
|
|
return this;
|
|
}
|
|
|
|
public DataHolder build(int i, Bundle bundle) {
|
|
return new DataHolder(this, i, bundle);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public DataHolder(int i, String[] strArr, CursorWindow[] cursorWindowArr, int i2, Bundle bundle) {
|
|
this.zae = false;
|
|
this.zak = true;
|
|
this.zaa = i;
|
|
this.zag = strArr;
|
|
this.zah = cursorWindowArr;
|
|
this.zai = i2;
|
|
this.zaj = bundle;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static Builder builder(String[] strArr) {
|
|
return new Builder(strArr, null, 0 == true ? 1 : 0);
|
|
}
|
|
|
|
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)) {
|
|
String valueOf = String.valueOf(str);
|
|
throw new IllegalArgumentException(valueOf.length() != 0 ? "No such column: ".concat(valueOf) : new String("No such column: "));
|
|
}
|
|
if (isClosed()) {
|
|
throw new IllegalArgumentException("Buffer is closed.");
|
|
}
|
|
if (i < 0 || i >= this.zad) {
|
|
throw new CursorIndexOutOfBoundsException(i, this.zad);
|
|
}
|
|
}
|
|
|
|
private static CursorWindow[] zaf(Builder builder, int i) {
|
|
if (builder.zaa.length == 0) {
|
|
return new CursorWindow[0];
|
|
}
|
|
ArrayList arrayList = builder.zab;
|
|
int size = arrayList.size();
|
|
CursorWindow cursorWindow = new CursorWindow(false);
|
|
ArrayList arrayList2 = new ArrayList();
|
|
arrayList2.add(cursorWindow);
|
|
cursorWindow.setNumColumns(builder.zaa.length);
|
|
int i2 = 0;
|
|
boolean z = false;
|
|
while (i2 < size) {
|
|
try {
|
|
if (!cursorWindow.allocRow()) {
|
|
cursorWindow = new CursorWindow(false);
|
|
cursorWindow.setStartPosition(i2);
|
|
cursorWindow.setNumColumns(builder.zaa.length);
|
|
arrayList2.add(cursorWindow);
|
|
if (!cursorWindow.allocRow()) {
|
|
arrayList2.remove(cursorWindow);
|
|
return (CursorWindow[]) arrayList2.toArray(new CursorWindow[arrayList2.size()]);
|
|
}
|
|
}
|
|
Map map = (Map) arrayList.get(i2);
|
|
int i3 = 0;
|
|
boolean z2 = true;
|
|
while (true) {
|
|
if (i3 < builder.zaa.length) {
|
|
if (!z2) {
|
|
break;
|
|
}
|
|
String str = builder.zaa[i3];
|
|
Object obj = map.get(str);
|
|
if (obj == null) {
|
|
z2 = cursorWindow.putNull(i2, i3);
|
|
} else if (obj instanceof String) {
|
|
z2 = cursorWindow.putString((String) obj, i2, i3);
|
|
} else if (obj instanceof Long) {
|
|
z2 = cursorWindow.putLong(((Long) obj).longValue(), i2, i3);
|
|
} else if (obj instanceof Integer) {
|
|
z2 = cursorWindow.putLong(((Integer) obj).intValue(), i2, i3);
|
|
} else if (obj instanceof Boolean) {
|
|
z2 = cursorWindow.putLong(true != ((Boolean) obj).booleanValue() ? 0L : 1L, i2, i3);
|
|
} else if (obj instanceof byte[]) {
|
|
z2 = cursorWindow.putBlob((byte[]) obj, i2, i3);
|
|
} else if (obj instanceof Double) {
|
|
z2 = cursorWindow.putDouble(((Double) obj).doubleValue(), i2, i3);
|
|
} else if (obj instanceof Float) {
|
|
z2 = cursorWindow.putDouble(((Float) obj).floatValue(), i2, i3);
|
|
} else {
|
|
String obj2 = obj.toString();
|
|
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 32 + obj2.length());
|
|
sb.append("Unsupported object for column ");
|
|
sb.append(str);
|
|
sb.append(": ");
|
|
sb.append(obj2);
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
i3++;
|
|
} else if (z2) {
|
|
z = false;
|
|
}
|
|
}
|
|
if (z) {
|
|
throw new zad("Could not add the value to a new CursorWindow. The size of value may be larger than what a CursorWindow can handle.");
|
|
}
|
|
cursorWindow.freeLastRow();
|
|
cursorWindow = new CursorWindow(false);
|
|
cursorWindow.setStartPosition(i2);
|
|
cursorWindow.setNumColumns(builder.zaa.length);
|
|
arrayList2.add(cursorWindow);
|
|
i2--;
|
|
z = true;
|
|
i2++;
|
|
} catch (RuntimeException e) {
|
|
int size2 = arrayList2.size();
|
|
for (int i4 = 0; i4 < size2; i4++) {
|
|
((CursorWindow) arrayList2.get(i4)).close();
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
return (CursorWindow[]) arrayList2.toArray(new CursorWindow[arrayList2.size()]);
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() {
|
|
synchronized (this) {
|
|
if (!this.zae) {
|
|
this.zae = true;
|
|
int i = 0;
|
|
while (true) {
|
|
CursorWindow[] cursorWindowArr = this.zah;
|
|
if (i >= cursorWindowArr.length) {
|
|
break;
|
|
}
|
|
cursorWindowArr[i].close();
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected final void finalize() throws Throwable {
|
|
try {
|
|
if (this.zak && this.zah.length > 0 && !isClosed()) {
|
|
close();
|
|
}
|
|
} finally {
|
|
super.finalize();
|
|
}
|
|
}
|
|
|
|
public final boolean getBoolean(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getLong(i, this.zab.getInt(str)) == 1;
|
|
}
|
|
|
|
public final byte[] getByteArray(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getBlob(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final int getInteger(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getInt(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final long getLong(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getLong(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final String getString(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getString(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final 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;
|
|
}
|
|
|
|
public final boolean hasColumn(String str) {
|
|
return this.zab.containsKey(str);
|
|
}
|
|
|
|
public final boolean hasNull(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].isNull(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final boolean isClosed() {
|
|
boolean z;
|
|
synchronized (this) {
|
|
z = this.zae;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public final void writeToParcel(Parcel parcel, int i) {
|
|
int beginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel);
|
|
SafeParcelWriter.writeStringArray(parcel, 1, this.zag, 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(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getDouble(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final float zab(String str, int i, int i2) {
|
|
zae(str, i);
|
|
return this.zah[i2].getFloat(i, this.zab.getInt(str));
|
|
}
|
|
|
|
public final void zac(String str, int i, int i2, 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: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public DataHolder(android.database.Cursor r8, int r9, android.os.Bundle r10) {
|
|
/*
|
|
r7 = this;
|
|
com.google.android.gms.common.sqlite.CursorWrapper r0 = new com.google.android.gms.common.sqlite.CursorWrapper
|
|
r0.<init>(r8)
|
|
java.lang.String[] r8 = r0.getColumnNames()
|
|
java.util.ArrayList r1 = new java.util.ArrayList
|
|
r1.<init>()
|
|
int r2 = r0.getCount() // Catch: java.lang.Throwable -> L76
|
|
android.database.CursorWindow r3 = r0.getWindow() // Catch: java.lang.Throwable -> L76
|
|
r4 = 0
|
|
r5 = 0
|
|
if (r3 == 0) goto L2e
|
|
int r6 = r3.getStartPosition() // Catch: java.lang.Throwable -> L76
|
|
if (r6 != 0) goto L2e
|
|
r3.acquireReference() // Catch: java.lang.Throwable -> L76
|
|
r0.setWindow(r4) // Catch: java.lang.Throwable -> L76
|
|
r1.add(r3) // Catch: java.lang.Throwable -> L76
|
|
int r3 = r3.getNumRows() // Catch: java.lang.Throwable -> L76
|
|
goto L2f
|
|
L2e:
|
|
r3 = r5
|
|
L2f:
|
|
if (r3 >= r2) goto L63
|
|
boolean r6 = r0.moveToPosition(r3) // Catch: java.lang.Throwable -> L76
|
|
if (r6 == 0) goto L63
|
|
android.database.CursorWindow r6 = r0.getWindow() // Catch: java.lang.Throwable -> L76
|
|
if (r6 == 0) goto L44
|
|
r6.acquireReference() // Catch: java.lang.Throwable -> L76
|
|
r0.setWindow(r4) // Catch: java.lang.Throwable -> L76
|
|
goto L4f
|
|
L44:
|
|
android.database.CursorWindow r6 = new android.database.CursorWindow // Catch: java.lang.Throwable -> L76
|
|
r6.<init>(r5) // Catch: java.lang.Throwable -> L76
|
|
r6.setStartPosition(r3) // Catch: java.lang.Throwable -> L76
|
|
r0.fillWindow(r3, r6) // Catch: java.lang.Throwable -> L76
|
|
L4f:
|
|
int r3 = r6.getNumRows() // Catch: java.lang.Throwable -> L76
|
|
if (r3 != 0) goto L56
|
|
goto L63
|
|
L56:
|
|
r1.add(r6) // Catch: java.lang.Throwable -> L76
|
|
int r3 = r6.getStartPosition() // Catch: java.lang.Throwable -> L76
|
|
int r6 = r6.getNumRows() // Catch: java.lang.Throwable -> L76
|
|
int r3 = r3 + r6
|
|
goto L2f
|
|
L63:
|
|
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.<init>(r8, r0, r9, r10)
|
|
return
|
|
L76:
|
|
r8 = move-exception
|
|
r0.close()
|
|
throw r8
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.data.DataHolder.<init>(android.database.Cursor, int, android.os.Bundle):void");
|
|
}
|
|
|
|
private DataHolder(Builder builder, int i, Bundle bundle) {
|
|
this(builder.zaa, zaf(builder, -1), i, (Bundle) null);
|
|
}
|
|
|
|
public DataHolder(String[] strArr, CursorWindow[] cursorWindowArr, int i, 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();
|
|
}
|
|
|
|
public final int getStatusCode() {
|
|
return this.zai;
|
|
}
|
|
|
|
public final Bundle getMetadata() {
|
|
return this.zaj;
|
|
}
|
|
|
|
public final int getCount() {
|
|
return this.zad;
|
|
}
|
|
}
|