alexandroid/decompiled/jadx/sources/androidx/work/Data.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

654 lines
22 KiB
Java

package androidx.work;
import android.annotation.SuppressLint;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.room.TypeConverter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.text.StringSubstitutor;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes14.dex */
public final class Data {
@SuppressLint({"MinMaxConstant"})
public static final int MAX_DATA_BYTES = 10240;
Map<String, Object> mValues;
private static final String TAG = Logger.tagWithPrefix("Data");
public static final Data EMPTY = new Builder().build();
public Data(@NonNull Data data) {
this.mValues = new HashMap(data.mValues);
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Boolean[] convertPrimitiveBooleanArray(@NonNull boolean[] zArr) {
Boolean[] boolArr = new Boolean[zArr.length];
for (int i = 0; i < zArr.length; i++) {
boolArr[i] = Boolean.valueOf(zArr[i]);
}
return boolArr;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Byte[] convertPrimitiveByteArray(@NonNull byte[] bArr) {
Byte[] bArr2 = new Byte[bArr.length];
for (int i = 0; i < bArr.length; i++) {
bArr2[i] = Byte.valueOf(bArr[i]);
}
return bArr2;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Double[] convertPrimitiveDoubleArray(@NonNull double[] dArr) {
Double[] dArr2 = new Double[dArr.length];
for (int i = 0; i < dArr.length; i++) {
dArr2[i] = Double.valueOf(dArr[i]);
}
return dArr2;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Float[] convertPrimitiveFloatArray(@NonNull float[] fArr) {
Float[] fArr2 = new Float[fArr.length];
for (int i = 0; i < fArr.length; i++) {
fArr2[i] = Float.valueOf(fArr[i]);
}
return fArr2;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Integer[] convertPrimitiveIntArray(@NonNull int[] iArr) {
Integer[] numArr = new Integer[iArr.length];
for (int i = 0; i < iArr.length; i++) {
numArr[i] = Integer.valueOf(iArr[i]);
}
return numArr;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static Long[] convertPrimitiveLongArray(@NonNull long[] jArr) {
Long[] lArr = new Long[jArr.length];
for (int i = 0; i < jArr.length; i++) {
lArr[i] = Long.valueOf(jArr[i]);
}
return lArr;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static boolean[] convertToPrimitiveArray(@NonNull Boolean[] boolArr) {
boolean[] zArr = new boolean[boolArr.length];
for (int i = 0; i < boolArr.length; i++) {
zArr[i] = boolArr[i].booleanValue();
}
return zArr;
}
/* JADX WARN: Code restructure failed: missing block: B:27:0x0051, code lost:
if (r3 == null) goto L50;
*/
/* JADX WARN: Removed duplicated region for block: B:38:0x005c A[EXC_TOP_SPLITTER, SYNTHETIC] */
@androidx.annotation.NonNull
@androidx.room.TypeConverter
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static androidx.work.Data fromByteArray(@androidx.annotation.NonNull byte[] r7) {
/*
java.lang.String r0 = "Error in Data#fromByteArray: "
int r1 = r7.length
r2 = 10240(0x2800, float:1.4349E-41)
if (r1 > r2) goto L71
java.util.HashMap r1 = new java.util.HashMap
r1.<init>()
java.io.ByteArrayInputStream r2 = new java.io.ByteArrayInputStream
r2.<init>(r7)
r7 = 0
java.io.ObjectInputStream r3 = new java.io.ObjectInputStream // Catch: java.lang.Throwable -> L44 java.lang.Throwable -> L48
r3.<init>(r2) // Catch: java.lang.Throwable -> L44 java.lang.Throwable -> L48
int r7 = r3.readInt() // Catch: java.lang.Throwable -> L2b java.lang.Throwable -> L2d
L1b:
if (r7 <= 0) goto L2f
java.lang.String r4 = r3.readUTF() // Catch: java.lang.Throwable -> L2b java.lang.Throwable -> L2d
java.lang.Object r5 = r3.readObject() // Catch: java.lang.Throwable -> L2b java.lang.Throwable -> L2d
r1.put(r4, r5) // Catch: java.lang.Throwable -> L2b java.lang.Throwable -> L2d
int r7 = r7 + (-1)
goto L1b
L2b:
r7 = move-exception
goto L5a
L2d:
r7 = move-exception
goto L4c
L2f:
r3.close() // Catch: java.io.IOException -> L33
goto L39
L33:
r7 = move-exception
java.lang.String r3 = androidx.work.Data.TAG
android.util.Log.e(r3, r0, r7)
L39:
r2.close() // Catch: java.io.IOException -> L3d
goto L54
L3d:
r7 = move-exception
java.lang.String r2 = androidx.work.Data.TAG
android.util.Log.e(r2, r0, r7)
goto L54
L44:
r1 = move-exception
r3 = r7
r7 = r1
goto L5a
L48:
r3 = move-exception
r6 = r3
r3 = r7
r7 = r6
L4c:
java.lang.String r4 = androidx.work.Data.TAG // Catch: java.lang.Throwable -> L2b
android.util.Log.e(r4, r0, r7) // Catch: java.lang.Throwable -> L2b
if (r3 == 0) goto L39
goto L2f
L54:
androidx.work.Data r7 = new androidx.work.Data
r7.<init>(r1)
return r7
L5a:
if (r3 == 0) goto L66
r3.close() // Catch: java.io.IOException -> L60
goto L66
L60:
r1 = move-exception
java.lang.String r3 = androidx.work.Data.TAG
android.util.Log.e(r3, r0, r1)
L66:
r2.close() // Catch: java.io.IOException -> L6a
goto L70
L6a:
r1 = move-exception
java.lang.String r2 = androidx.work.Data.TAG
android.util.Log.e(r2, r0, r1)
L70:
throw r7
L71:
java.lang.String r7 = "Data cannot occupy more than 10240 bytes when serialized"
rx.Single$$ExternalSyntheticBUOutline0.m$2(r7)
r7 = 0
return r7
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.work.Data.fromByteArray(byte[]):androidx.work.Data");
}
@NonNull
@TypeConverter
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static byte[] toByteArrayInternal(@NonNull Data data) {
ObjectOutputStream objectOutputStream;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream2 = null;
try {
try {
objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
} catch (Throwable th) {
th = th;
}
} catch (IOException e) {
e = e;
}
try {
objectOutputStream.writeInt(data.size());
for (Map.Entry<String, Object> entry : data.mValues.entrySet()) {
objectOutputStream.writeUTF(entry.getKey());
objectOutputStream.writeObject(entry.getValue());
}
try {
objectOutputStream.close();
} catch (IOException e2) {
Log.e(TAG, "Error in Data#toByteArray: ", e2);
}
try {
byteArrayOutputStream.close();
} catch (IOException e3) {
Log.e(TAG, "Error in Data#toByteArray: ", e3);
}
if (byteArrayOutputStream.size() <= 10240) {
return byteArrayOutputStream.toByteArray();
}
Single$$ExternalSyntheticBUOutline0.m$2("Data cannot occupy more than 10240 bytes when serialized");
return null;
} catch (IOException e4) {
e = e4;
objectOutputStream2 = objectOutputStream;
Log.e(TAG, "Error in Data#toByteArray: ", e);
byte[] byteArray = byteArrayOutputStream.toByteArray();
if (objectOutputStream2 != null) {
try {
objectOutputStream2.close();
} catch (IOException e5) {
Log.e(TAG, "Error in Data#toByteArray: ", e5);
}
}
try {
byteArrayOutputStream.close();
} catch (IOException e6) {
Log.e(TAG, "Error in Data#toByteArray: ", e6);
}
return byteArray;
} catch (Throwable th2) {
th = th2;
objectOutputStream2 = objectOutputStream;
if (objectOutputStream2 != null) {
try {
objectOutputStream2.close();
} catch (IOException e7) {
Log.e(TAG, "Error in Data#toByteArray: ", e7);
}
}
try {
byteArrayOutputStream.close();
throw th;
} catch (IOException e8) {
Log.e(TAG, "Error in Data#toByteArray: ", e8);
throw th;
}
}
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || Data.class != obj.getClass()) {
return false;
}
Data data = (Data) obj;
Set<String> keySet = this.mValues.keySet();
if (!keySet.equals(data.mValues.keySet())) {
return false;
}
for (String str : keySet) {
Object obj2 = this.mValues.get(str);
Object obj3 = data.mValues.get(str);
if (!((obj2 == null || obj3 == null) ? obj2 == obj3 : ((obj2 instanceof Object[]) && (obj3 instanceof Object[])) ? Arrays.deepEquals((Object[]) obj2, (Object[]) obj3) : obj2.equals(obj3))) {
return false;
}
}
return true;
}
public boolean getBoolean(@NonNull String str, boolean z) {
Object obj = this.mValues.get(str);
return obj instanceof Boolean ? ((Boolean) obj).booleanValue() : z;
}
@Nullable
public boolean[] getBooleanArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Boolean[]) {
return convertToPrimitiveArray((Boolean[]) obj);
}
return null;
}
public byte getByte(@NonNull String str, byte b) {
Object obj = this.mValues.get(str);
return obj instanceof Byte ? ((Byte) obj).byteValue() : b;
}
@Nullable
public byte[] getByteArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Byte[]) {
return convertToPrimitiveArray((Byte[]) obj);
}
return null;
}
public double getDouble(@NonNull String str, double d) {
Object obj = this.mValues.get(str);
return obj instanceof Double ? ((Double) obj).doubleValue() : d;
}
@Nullable
public double[] getDoubleArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Double[]) {
return convertToPrimitiveArray((Double[]) obj);
}
return null;
}
public float getFloat(@NonNull String str, float f) {
Object obj = this.mValues.get(str);
return obj instanceof Float ? ((Float) obj).floatValue() : f;
}
@Nullable
public float[] getFloatArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Float[]) {
return convertToPrimitiveArray((Float[]) obj);
}
return null;
}
public int getInt(@NonNull String str, int i) {
Object obj = this.mValues.get(str);
return obj instanceof Integer ? ((Integer) obj).intValue() : i;
}
@Nullable
public int[] getIntArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Integer[]) {
return convertToPrimitiveArray((Integer[]) obj);
}
return null;
}
@NonNull
public Map<String, Object> getKeyValueMap() {
return Collections.unmodifiableMap(this.mValues);
}
public long getLong(@NonNull String str, long j) {
Object obj = this.mValues.get(str);
return obj instanceof Long ? ((Long) obj).longValue() : j;
}
@Nullable
public long[] getLongArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof Long[]) {
return convertToPrimitiveArray((Long[]) obj);
}
return null;
}
@Nullable
public String getString(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof String) {
return (String) obj;
}
return null;
}
@Nullable
public String[] getStringArray(@NonNull String str) {
Object obj = this.mValues.get(str);
if (obj instanceof String[]) {
return (String[]) obj;
}
return null;
}
public <T> boolean hasKeyWithValueOfType(@NonNull String str, @NonNull Class<T> cls) {
Object obj = this.mValues.get(str);
return obj != null && cls.isAssignableFrom(obj.getClass());
}
public int hashCode() {
return this.mValues.hashCode() * 31;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
@VisibleForTesting
public int size() {
return this.mValues.size();
}
@NonNull
public byte[] toByteArray() {
return toByteArrayInternal(this);
}
@NonNull
public String toString() {
StringBuilder sb = new StringBuilder("Data {");
if (!this.mValues.isEmpty()) {
for (String str : this.mValues.keySet()) {
sb.append(str);
sb.append(" : ");
Object obj = this.mValues.get(str);
if (obj instanceof Object[]) {
sb.append(Arrays.toString((Object[]) obj));
} else {
sb.append(obj);
}
sb.append(", ");
}
}
sb.append(StringSubstitutor.DEFAULT_VAR_END);
return sb.toString();
}
public Data() {
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public Data(@NonNull Map<String, ?> map) {
this.mValues = new HashMap(map);
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static byte[] convertToPrimitiveArray(@NonNull Byte[] bArr) {
byte[] bArr2 = new byte[bArr.length];
for (int i = 0; i < bArr.length; i++) {
bArr2[i] = bArr[i].byteValue();
}
return bArr2;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static int[] convertToPrimitiveArray(@NonNull Integer[] numArr) {
int[] iArr = new int[numArr.length];
for (int i = 0; i < numArr.length; i++) {
iArr[i] = numArr[i].intValue();
}
return iArr;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static long[] convertToPrimitiveArray(@NonNull Long[] lArr) {
long[] jArr = new long[lArr.length];
for (int i = 0; i < lArr.length; i++) {
jArr[i] = lArr[i].longValue();
}
return jArr;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static float[] convertToPrimitiveArray(@NonNull Float[] fArr) {
float[] fArr2 = new float[fArr.length];
for (int i = 0; i < fArr.length; i++) {
fArr2[i] = fArr[i].floatValue();
}
return fArr2;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static double[] convertToPrimitiveArray(@NonNull Double[] dArr) {
double[] dArr2 = new double[dArr.length];
for (int i = 0; i < dArr.length; i++) {
dArr2[i] = dArr[i].doubleValue();
}
return dArr2;
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class Builder {
private Map<String, Object> mValues = new HashMap();
@NonNull
public Data build() {
Data data = new Data((Map<String, ?>) this.mValues);
Data.toByteArrayInternal(data);
return data;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public Builder put(@NonNull String str, @Nullable Object obj) {
if (obj == null) {
this.mValues.put(str, null);
return this;
}
Class<?> cls = obj.getClass();
if (cls == Boolean.class || cls == Byte.class || cls == Integer.class || cls == Long.class || cls == Float.class || cls == Double.class || cls == String.class || cls == Boolean[].class || cls == Byte[].class || cls == Integer[].class || cls == Long[].class || cls == Float[].class || cls == Double[].class || cls == String[].class) {
this.mValues.put(str, obj);
return this;
}
if (cls == boolean[].class) {
this.mValues.put(str, Data.convertPrimitiveBooleanArray((boolean[]) obj));
return this;
}
if (cls == byte[].class) {
this.mValues.put(str, Data.convertPrimitiveByteArray((byte[]) obj));
return this;
}
if (cls == int[].class) {
this.mValues.put(str, Data.convertPrimitiveIntArray((int[]) obj));
return this;
}
if (cls == long[].class) {
this.mValues.put(str, Data.convertPrimitiveLongArray((long[]) obj));
return this;
}
if (cls == float[].class) {
this.mValues.put(str, Data.convertPrimitiveFloatArray((float[]) obj));
return this;
}
if (cls == double[].class) {
this.mValues.put(str, Data.convertPrimitiveDoubleArray((double[]) obj));
return this;
}
Single$$ExternalSyntheticBUOutline0.m("Key ", str, " has invalid type ", cls);
return null;
}
@NonNull
public Builder putAll(@NonNull Map<String, Object> map) {
for (Map.Entry<String, Object> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
return this;
}
@NonNull
public Builder putBoolean(@NonNull String str, boolean z) {
this.mValues.put(str, Boolean.valueOf(z));
return this;
}
@NonNull
public Builder putBooleanArray(@NonNull String str, @NonNull boolean[] zArr) {
this.mValues.put(str, Data.convertPrimitiveBooleanArray(zArr));
return this;
}
@NonNull
public Builder putByte(@NonNull String str, byte b) {
this.mValues.put(str, Byte.valueOf(b));
return this;
}
@NonNull
public Builder putByteArray(@NonNull String str, @NonNull byte[] bArr) {
this.mValues.put(str, Data.convertPrimitiveByteArray(bArr));
return this;
}
@NonNull
public Builder putDouble(@NonNull String str, double d) {
this.mValues.put(str, Double.valueOf(d));
return this;
}
@NonNull
public Builder putDoubleArray(@NonNull String str, @NonNull double[] dArr) {
this.mValues.put(str, Data.convertPrimitiveDoubleArray(dArr));
return this;
}
@NonNull
public Builder putFloat(@NonNull String str, float f) {
this.mValues.put(str, Float.valueOf(f));
return this;
}
@NonNull
public Builder putFloatArray(@NonNull String str, @NonNull float[] fArr) {
this.mValues.put(str, Data.convertPrimitiveFloatArray(fArr));
return this;
}
@NonNull
public Builder putInt(@NonNull String str, int i) {
this.mValues.put(str, Integer.valueOf(i));
return this;
}
@NonNull
public Builder putIntArray(@NonNull String str, @NonNull int[] iArr) {
this.mValues.put(str, Data.convertPrimitiveIntArray(iArr));
return this;
}
@NonNull
public Builder putLong(@NonNull String str, long j) {
this.mValues.put(str, Long.valueOf(j));
return this;
}
@NonNull
public Builder putLongArray(@NonNull String str, @NonNull long[] jArr) {
this.mValues.put(str, Data.convertPrimitiveLongArray(jArr));
return this;
}
@NonNull
public Builder putString(@NonNull String str, @Nullable String str2) {
this.mValues.put(str, str2);
return this;
}
@NonNull
public Builder putStringArray(@NonNull String str, @NonNull String[] strArr) {
this.mValues.put(str, strArr);
return this;
}
@NonNull
public Builder putAll(@NonNull Data data) {
putAll(data.mValues);
return this;
}
}
}