Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
package com.google.firebase.encoders;
import java.io.Writer;
/* loaded from: classes3.dex */
public interface DataEncoder {
String encode(Object obj);
void encode(Object obj, Writer writer);
}

View File

@@ -0,0 +1,12 @@
package com.google.firebase.encoders;
/* loaded from: classes3.dex */
public final class EncodingException extends RuntimeException {
public EncodingException(String str) {
super(str);
}
public EncodingException(String str, Exception exc) {
super(str, exc);
}
}

View File

@@ -0,0 +1,80 @@
package com.google.firebase.encoders;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes3.dex */
public final class FieldDescriptor {
public final String name;
public final Map properties;
public String getName() {
return this.name;
}
public FieldDescriptor(String str, Map map) {
this.name = str;
this.properties = map;
}
public Annotation getProperty(Class cls) {
return (Annotation) this.properties.get(cls);
}
public static FieldDescriptor of(String str) {
return new FieldDescriptor(str, Collections.emptyMap());
}
public static Builder builder(String str) {
return new Builder(str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FieldDescriptor)) {
return false;
}
FieldDescriptor fieldDescriptor = (FieldDescriptor) obj;
return this.name.equals(fieldDescriptor.name) && this.properties.equals(fieldDescriptor.properties);
}
public int hashCode() {
return (this.name.hashCode() * 31) + this.properties.hashCode();
}
public String toString() {
return "FieldDescriptor{name=" + this.name + ", properties=" + this.properties.values() + "}";
}
public static final class Builder {
public final String name;
public Map properties = null;
public Builder(String str) {
this.name = str;
}
public Builder withProperty(Annotation annotation) {
if (this.properties == null) {
this.properties = new HashMap();
}
this.properties.put(annotation.annotationType(), annotation);
return this;
}
public FieldDescriptor build() {
Map unmodifiableMap;
String str = this.name;
if (this.properties == null) {
unmodifiableMap = Collections.emptyMap();
} else {
unmodifiableMap = Collections.unmodifiableMap(new HashMap(this.properties));
}
return new FieldDescriptor(str, unmodifiableMap);
}
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.encoders;
/* loaded from: classes3.dex */
public interface ObjectEncoder {
/* synthetic */ void encode(Object obj, Object obj2);
}

View File

@@ -0,0 +1,14 @@
package com.google.firebase.encoders;
/* loaded from: classes3.dex */
public interface ObjectEncoderContext {
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d);
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, int i);
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, long j);
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj);
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, boolean z);
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.encoders;
/* loaded from: classes3.dex */
public interface ValueEncoder {
/* synthetic */ void encode(Object obj, Object obj2);
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.encoders;
/* loaded from: classes3.dex */
public interface ValueEncoderContext {
ValueEncoderContext add(String str);
ValueEncoderContext add(boolean z);
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.encoders.config;
/* loaded from: classes3.dex */
public interface Configurator {
void configure(EncoderConfig encoderConfig);
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.encoders.config;
import com.google.firebase.encoders.ObjectEncoder;
/* loaded from: classes3.dex */
public interface EncoderConfig {
EncoderConfig registerEncoder(Class cls, ObjectEncoder objectEncoder);
}

View File

@@ -0,0 +1,123 @@
package com.google.firebase.encoders.json;
import com.google.firebase.encoders.DataEncoder;
import com.google.firebase.encoders.EncodingException;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.ValueEncoder;
import com.google.firebase.encoders.ValueEncoderContext;
import com.google.firebase.encoders.config.Configurator;
import com.google.firebase.encoders.config.EncoderConfig;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
/* loaded from: classes3.dex */
public final class JsonDataEncoderBuilder implements EncoderConfig {
public static final ObjectEncoder DEFAULT_FALLBACK_ENCODER = new ObjectEncoder() { // from class: com.google.firebase.encoders.json.JsonDataEncoderBuilder$$ExternalSyntheticLambda0
@Override // com.google.firebase.encoders.ObjectEncoder
public final void encode(Object obj, Object obj2) {
JsonDataEncoderBuilder.lambda$static$0(obj, (ObjectEncoderContext) obj2);
}
};
public static final ValueEncoder STRING_ENCODER = new ValueEncoder() { // from class: com.google.firebase.encoders.json.JsonDataEncoderBuilder$$ExternalSyntheticLambda1
@Override // com.google.firebase.encoders.ValueEncoder
public final void encode(Object obj, Object obj2) {
((ValueEncoderContext) obj2).add((String) obj);
}
};
public static final ValueEncoder BOOLEAN_ENCODER = new ValueEncoder() { // from class: com.google.firebase.encoders.json.JsonDataEncoderBuilder$$ExternalSyntheticLambda2
@Override // com.google.firebase.encoders.ValueEncoder
public final void encode(Object obj, Object obj2) {
JsonDataEncoderBuilder.lambda$static$2((Boolean) obj, (ValueEncoderContext) obj2);
}
};
public static final TimestampEncoder TIMESTAMP_ENCODER = new TimestampEncoder();
public final Map objectEncoders = new HashMap();
public final Map valueEncoders = new HashMap();
public ObjectEncoder fallbackEncoder = DEFAULT_FALLBACK_ENCODER;
public boolean ignoreNullValues = false;
public JsonDataEncoderBuilder ignoreNullValues(boolean z) {
this.ignoreNullValues = z;
return this;
}
public static /* synthetic */ void lambda$static$0(Object obj, ObjectEncoderContext objectEncoderContext) {
throw new EncodingException("Couldn't find encoder for type " + obj.getClass().getCanonicalName());
}
public static final class TimestampEncoder implements ValueEncoder {
public static final DateFormat rfc339;
public TimestampEncoder() {
}
static {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
rfc339 = simpleDateFormat;
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@Override // com.google.firebase.encoders.ValueEncoder
public void encode(Date date, ValueEncoderContext valueEncoderContext) {
valueEncoderContext.add(rfc339.format(date));
}
}
public static /* synthetic */ void lambda$static$2(Boolean bool, ValueEncoderContext valueEncoderContext) {
valueEncoderContext.add(bool.booleanValue());
}
public JsonDataEncoderBuilder() {
registerEncoder(String.class, STRING_ENCODER);
registerEncoder(Boolean.class, BOOLEAN_ENCODER);
registerEncoder(Date.class, TIMESTAMP_ENCODER);
}
@Override // com.google.firebase.encoders.config.EncoderConfig
public JsonDataEncoderBuilder registerEncoder(Class cls, ObjectEncoder objectEncoder) {
this.objectEncoders.put(cls, objectEncoder);
this.valueEncoders.remove(cls);
return this;
}
public JsonDataEncoderBuilder registerEncoder(Class cls, ValueEncoder valueEncoder) {
this.valueEncoders.put(cls, valueEncoder);
this.objectEncoders.remove(cls);
return this;
}
public JsonDataEncoderBuilder configureWith(Configurator configurator) {
configurator.configure(this);
return this;
}
public DataEncoder build() {
return new DataEncoder() { // from class: com.google.firebase.encoders.json.JsonDataEncoderBuilder.1
@Override // com.google.firebase.encoders.DataEncoder
public void encode(Object obj, Writer writer) {
JsonValueObjectEncoderContext jsonValueObjectEncoderContext = new JsonValueObjectEncoderContext(writer, JsonDataEncoderBuilder.this.objectEncoders, JsonDataEncoderBuilder.this.valueEncoders, JsonDataEncoderBuilder.this.fallbackEncoder, JsonDataEncoderBuilder.this.ignoreNullValues);
jsonValueObjectEncoderContext.add(obj, false);
jsonValueObjectEncoderContext.close();
}
@Override // com.google.firebase.encoders.DataEncoder
public String encode(Object obj) {
StringWriter stringWriter = new StringWriter();
try {
encode(obj, stringWriter);
} catch (IOException unused) {
}
return stringWriter.toString();
}
};
}
}

View File

@@ -0,0 +1,285 @@
package com.google.firebase.encoders.json;
import android.util.Base64;
import android.util.JsonWriter;
import com.google.firebase.encoders.EncodingException;
import com.google.firebase.encoders.FieldDescriptor;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.ValueEncoder;
import com.google.firebase.encoders.ValueEncoderContext;
import java.io.Writer;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes3.dex */
public final class JsonValueObjectEncoderContext implements ObjectEncoderContext, ValueEncoderContext {
public final ObjectEncoder fallbackEncoder;
public final boolean ignoreNullValues;
public final JsonWriter jsonWriter;
public final Map objectEncoders;
public final Map valueEncoders;
public JsonValueObjectEncoderContext childContext = null;
public boolean active = true;
public JsonValueObjectEncoderContext(Writer writer, Map map, Map map2, ObjectEncoder objectEncoder, boolean z) {
this.jsonWriter = new JsonWriter(writer);
this.objectEncoders = map;
this.valueEncoders = map2;
this.fallbackEncoder = objectEncoder;
this.ignoreNullValues = z;
}
public JsonValueObjectEncoderContext add(String str, Object obj) {
if (this.ignoreNullValues) {
return internalAddIgnoreNullValues(str, obj);
}
return internalAdd(str, obj);
}
public JsonValueObjectEncoderContext add(String str, double d) {
maybeUnNest();
this.jsonWriter.name(str);
return add(d);
}
public JsonValueObjectEncoderContext add(String str, int i) {
maybeUnNest();
this.jsonWriter.name(str);
return add(i);
}
public JsonValueObjectEncoderContext add(String str, long j) {
maybeUnNest();
this.jsonWriter.name(str);
return add(j);
}
public JsonValueObjectEncoderContext add(String str, boolean z) {
maybeUnNest();
this.jsonWriter.name(str);
return add(z);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj) {
return add(fieldDescriptor.getName(), obj);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d) {
return add(fieldDescriptor.getName(), d);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, int i) {
return add(fieldDescriptor.getName(), i);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, long j) {
return add(fieldDescriptor.getName(), j);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, boolean z) {
return add(fieldDescriptor.getName(), z);
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public JsonValueObjectEncoderContext add(String str) {
maybeUnNest();
this.jsonWriter.value(str);
return this;
}
public JsonValueObjectEncoderContext add(double d) {
maybeUnNest();
this.jsonWriter.value(d);
return this;
}
public JsonValueObjectEncoderContext add(int i) {
maybeUnNest();
this.jsonWriter.value(i);
return this;
}
public JsonValueObjectEncoderContext add(long j) {
maybeUnNest();
this.jsonWriter.value(j);
return this;
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public JsonValueObjectEncoderContext add(boolean z) {
maybeUnNest();
this.jsonWriter.value(z);
return this;
}
public JsonValueObjectEncoderContext add(byte[] bArr) {
maybeUnNest();
if (bArr == null) {
this.jsonWriter.nullValue();
} else {
this.jsonWriter.value(Base64.encodeToString(bArr, 2));
}
return this;
}
public JsonValueObjectEncoderContext add(Object obj, boolean z) {
int i = 0;
if (z && cannotBeInline(obj)) {
Object[] objArr = new Object[1];
objArr[0] = obj == null ? null : obj.getClass();
throw new EncodingException(String.format("%s cannot be encoded inline", objArr));
}
if (obj == null) {
this.jsonWriter.nullValue();
return this;
}
if (obj instanceof Number) {
this.jsonWriter.value((Number) obj);
return this;
}
if (obj.getClass().isArray()) {
if (obj instanceof byte[]) {
return add((byte[]) obj);
}
this.jsonWriter.beginArray();
if (obj instanceof int[]) {
int length = ((int[]) obj).length;
while (i < length) {
this.jsonWriter.value(r6[i]);
i++;
}
} else if (obj instanceof long[]) {
long[] jArr = (long[]) obj;
int length2 = jArr.length;
while (i < length2) {
add(jArr[i]);
i++;
}
} else if (obj instanceof double[]) {
double[] dArr = (double[]) obj;
int length3 = dArr.length;
while (i < length3) {
this.jsonWriter.value(dArr[i]);
i++;
}
} else if (obj instanceof boolean[]) {
boolean[] zArr = (boolean[]) obj;
int length4 = zArr.length;
while (i < length4) {
this.jsonWriter.value(zArr[i]);
i++;
}
} else if (obj instanceof Number[]) {
for (Number number : (Number[]) obj) {
add((Object) number, false);
}
} else {
for (Object obj2 : (Object[]) obj) {
add(obj2, false);
}
}
this.jsonWriter.endArray();
return this;
}
if (obj instanceof Collection) {
this.jsonWriter.beginArray();
Iterator it = ((Collection) obj).iterator();
while (it.hasNext()) {
add(it.next(), false);
}
this.jsonWriter.endArray();
return this;
}
if (obj instanceof Map) {
this.jsonWriter.beginObject();
for (Map.Entry entry : ((Map) obj).entrySet()) {
Object key = entry.getKey();
try {
add((String) key, entry.getValue());
} catch (ClassCastException e) {
throw new EncodingException(String.format("Only String keys are currently supported in maps, got %s of type %s instead.", key, key.getClass()), e);
}
}
this.jsonWriter.endObject();
return this;
}
ObjectEncoder objectEncoder = (ObjectEncoder) this.objectEncoders.get(obj.getClass());
if (objectEncoder != null) {
return doEncode(objectEncoder, obj, z);
}
ValueEncoder valueEncoder = (ValueEncoder) this.valueEncoders.get(obj.getClass());
if (valueEncoder != null) {
valueEncoder.encode(obj, this);
return this;
}
if (obj instanceof Enum) {
if (obj instanceof NumberedEnum) {
add(((NumberedEnum) obj).getNumber());
} else {
add(((Enum) obj).name());
}
return this;
}
return doEncode(this.fallbackEncoder, obj, z);
}
public JsonValueObjectEncoderContext doEncode(ObjectEncoder objectEncoder, Object obj, boolean z) {
if (!z) {
this.jsonWriter.beginObject();
}
objectEncoder.encode(obj, this);
if (!z) {
this.jsonWriter.endObject();
}
return this;
}
public final boolean cannotBeInline(Object obj) {
return obj == null || obj.getClass().isArray() || (obj instanceof Collection) || (obj instanceof Date) || (obj instanceof Enum) || (obj instanceof Number);
}
public void close() {
maybeUnNest();
this.jsonWriter.flush();
}
public final void maybeUnNest() {
if (!this.active) {
throw new IllegalStateException("Parent context used since this context was created. Cannot use this context anymore.");
}
JsonValueObjectEncoderContext jsonValueObjectEncoderContext = this.childContext;
if (jsonValueObjectEncoderContext != null) {
jsonValueObjectEncoderContext.maybeUnNest();
this.childContext.active = false;
this.childContext = null;
this.jsonWriter.endObject();
}
}
public final JsonValueObjectEncoderContext internalAdd(String str, Object obj) {
maybeUnNest();
this.jsonWriter.name(str);
if (obj == null) {
this.jsonWriter.nullValue();
return this;
}
return add(obj, false);
}
public final JsonValueObjectEncoderContext internalAddIgnoreNullValues(String str, Object obj) {
if (obj == null) {
return this;
}
maybeUnNest();
this.jsonWriter.name(str);
return add(obj, false);
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.encoders.json;
/* loaded from: classes3.dex */
public interface NumberedEnum {
int getNumber();
}

View File

@@ -0,0 +1,69 @@
package com.google.firebase.encoders.proto;
import com.google.firebase.encoders.proto.Protobuf;
/* loaded from: classes3.dex */
public final class AtProtobuf {
public Protobuf.IntEncoding intEncoding = Protobuf.IntEncoding.DEFAULT;
public int tag;
public AtProtobuf tag(int i) {
this.tag = i;
return this;
}
public static AtProtobuf builder() {
return new AtProtobuf();
}
public Protobuf build() {
return new ProtobufImpl(this.tag, this.intEncoding);
}
public static final class ProtobufImpl implements Protobuf {
public final Protobuf.IntEncoding intEncoding;
public final int tag;
@Override // java.lang.annotation.Annotation
public Class annotationType() {
return Protobuf.class;
}
@Override // com.google.firebase.encoders.proto.Protobuf
public Protobuf.IntEncoding intEncoding() {
return this.intEncoding;
}
@Override // com.google.firebase.encoders.proto.Protobuf
public int tag() {
return this.tag;
}
public ProtobufImpl(int i, Protobuf.IntEncoding intEncoding) {
this.tag = i;
this.intEncoding = intEncoding;
}
@Override // java.lang.annotation.Annotation
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Protobuf)) {
return false;
}
Protobuf protobuf = (Protobuf) obj;
return this.tag == protobuf.tag() && this.intEncoding.equals(protobuf.intEncoding());
}
@Override // java.lang.annotation.Annotation
public int hashCode() {
return (14552422 ^ this.tag) + (this.intEncoding.hashCode() ^ 2041407134);
}
@Override // java.lang.annotation.Annotation
public String toString() {
return "@com.google.firebase.encoders.proto.Protobuf(tag=" + this.tag + "intEncoding=" + this.intEncoding + ')';
}
}
}

View File

@@ -0,0 +1,31 @@
package com.google.firebase.encoders.proto;
import java.io.OutputStream;
/* loaded from: classes3.dex */
public final class LengthCountingOutputStream extends OutputStream {
public long length = 0;
public long getLength() {
return this.length;
}
@Override // java.io.OutputStream
public void write(int i) {
this.length++;
}
@Override // java.io.OutputStream
public void write(byte[] bArr) {
this.length += bArr.length;
}
@Override // java.io.OutputStream
public void write(byte[] bArr, int i, int i2) {
int i3;
if (i < 0 || i > bArr.length || i2 < 0 || (i3 = i + i2) > bArr.length || i3 < 0) {
throw new IndexOutOfBoundsException();
}
this.length += i2;
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.encoders.proto;
/* loaded from: classes3.dex */
public interface ProtoEnum {
int getNumber();
}

View File

@@ -0,0 +1,15 @@
package com.google.firebase.encoders.proto;
/* loaded from: classes3.dex */
public @interface Protobuf {
public enum IntEncoding {
DEFAULT,
SIGNED,
FIXED
}
IntEncoding intEncoding() default IntEncoding.DEFAULT;
int tag();
}

View File

@@ -0,0 +1,311 @@
package com.google.firebase.encoders.proto;
import androidx.work.WorkInfo;
import com.google.firebase.encoders.EncodingException;
import com.google.firebase.encoders.FieldDescriptor;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.ValueEncoder;
import com.google.firebase.encoders.proto.Protobuf;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes3.dex */
public final class ProtobufDataEncoderContext implements ObjectEncoderContext {
public final ObjectEncoder fallbackEncoder;
public final Map objectEncoders;
public OutputStream output;
public final ProtobufValueEncoderContext valueEncoderContext = new ProtobufValueEncoderContext(this);
public final Map valueEncoders;
public static final Charset UTF_8 = Charset.forName("UTF-8");
public static final FieldDescriptor MAP_KEY_DESC = FieldDescriptor.builder("key").withProperty(AtProtobuf.builder().tag(1).build()).build();
public static final FieldDescriptor MAP_VALUE_DESC = FieldDescriptor.builder("value").withProperty(AtProtobuf.builder().tag(2).build()).build();
public static final ObjectEncoder DEFAULT_MAP_ENCODER = new ObjectEncoder() { // from class: com.google.firebase.encoders.proto.ProtobufDataEncoderContext$$ExternalSyntheticLambda0
@Override // com.google.firebase.encoders.ObjectEncoder
public final void encode(Object obj, Object obj2) {
ProtobufDataEncoderContext.lambda$static$0((Map.Entry) obj, (ObjectEncoderContext) obj2);
}
};
public static /* synthetic */ void lambda$static$0(Map.Entry entry, ObjectEncoderContext objectEncoderContext) {
objectEncoderContext.add(MAP_KEY_DESC, entry.getKey());
objectEncoderContext.add(MAP_VALUE_DESC, entry.getValue());
}
public ProtobufDataEncoderContext(OutputStream outputStream, Map map, Map map2, ObjectEncoder objectEncoder) {
this.output = outputStream;
this.objectEncoders = map;
this.valueEncoders = map2;
this.fallbackEncoder = objectEncoder;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj) {
return add(fieldDescriptor, obj, true);
}
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj, boolean z) {
if (obj == null) {
return this;
}
if (obj instanceof CharSequence) {
CharSequence charSequence = (CharSequence) obj;
if (z && charSequence.length() == 0) {
return this;
}
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
byte[] bytes = charSequence.toString().getBytes(UTF_8);
writeVarInt32(bytes.length);
this.output.write(bytes);
return this;
}
if (obj instanceof Collection) {
Iterator it = ((Collection) obj).iterator();
while (it.hasNext()) {
add(fieldDescriptor, it.next(), false);
}
return this;
}
if (obj instanceof Map) {
Iterator it2 = ((Map) obj).entrySet().iterator();
while (it2.hasNext()) {
doEncode(DEFAULT_MAP_ENCODER, fieldDescriptor, it2.next(), false);
}
return this;
}
if (obj instanceof Double) {
return add(fieldDescriptor, ((Double) obj).doubleValue(), z);
}
if (obj instanceof Float) {
return add(fieldDescriptor, ((Float) obj).floatValue(), z);
}
if (obj instanceof Number) {
return add(fieldDescriptor, ((Number) obj).longValue(), z);
}
if (obj instanceof Boolean) {
return add(fieldDescriptor, ((Boolean) obj).booleanValue(), z);
}
if (obj instanceof byte[]) {
byte[] bArr = (byte[]) obj;
if (z && bArr.length == 0) {
return this;
}
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
writeVarInt32(bArr.length);
this.output.write(bArr);
return this;
}
ObjectEncoder objectEncoder = (ObjectEncoder) this.objectEncoders.get(obj.getClass());
if (objectEncoder != null) {
return doEncode(objectEncoder, fieldDescriptor, obj, z);
}
ValueEncoder valueEncoder = (ValueEncoder) this.valueEncoders.get(obj.getClass());
if (valueEncoder != null) {
return doEncode(valueEncoder, fieldDescriptor, obj, z);
}
if (obj instanceof ProtoEnum) {
return add(fieldDescriptor, ((ProtoEnum) obj).getNumber());
}
if (obj instanceof Enum) {
return add(fieldDescriptor, ((Enum) obj).ordinal());
}
return doEncode(this.fallbackEncoder, fieldDescriptor, obj, z);
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d) {
return add(fieldDescriptor, d, true);
}
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d, boolean z) {
if (z && d == 0.0d) {
return this;
}
writeVarInt32((getTag(fieldDescriptor) << 3) | 1);
this.output.write(allocateBuffer(8).putDouble(d).array());
return this;
}
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, float f, boolean z) {
if (z && f == 0.0f) {
return this;
}
writeVarInt32((getTag(fieldDescriptor) << 3) | 5);
this.output.write(allocateBuffer(4).putFloat(f).array());
return this;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, int i) {
return add(fieldDescriptor, i, true);
}
/* renamed from: com.google.firebase.encoders.proto.ProtobufDataEncoderContext$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding;
static {
int[] iArr = new int[Protobuf.IntEncoding.values().length];
$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding = iArr;
try {
iArr[Protobuf.IntEncoding.DEFAULT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding[Protobuf.IntEncoding.SIGNED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding[Protobuf.IntEncoding.FIXED.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, int i, boolean z) {
if (z && i == 0) {
return this;
}
Protobuf protobuf = getProtobuf(fieldDescriptor);
int i2 = AnonymousClass1.$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding[protobuf.intEncoding().ordinal()];
if (i2 == 1) {
writeVarInt32(protobuf.tag() << 3);
writeVarInt32(i);
} else if (i2 == 2) {
writeVarInt32(protobuf.tag() << 3);
writeVarInt32((i << 1) ^ (i >> 31));
} else if (i2 == 3) {
writeVarInt32((protobuf.tag() << 3) | 5);
this.output.write(allocateBuffer(4).putInt(i).array());
}
return this;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, long j) {
return add(fieldDescriptor, j, true);
}
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, long j, boolean z) {
if (z && j == 0) {
return this;
}
Protobuf protobuf = getProtobuf(fieldDescriptor);
int i = AnonymousClass1.$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding[protobuf.intEncoding().ordinal()];
if (i == 1) {
writeVarInt32(protobuf.tag() << 3);
writeVarInt64(j);
} else if (i == 2) {
writeVarInt32(protobuf.tag() << 3);
writeVarInt64((j >> 63) ^ (j << 1));
} else if (i == 3) {
writeVarInt32((protobuf.tag() << 3) | 1);
this.output.write(allocateBuffer(8).putLong(j).array());
}
return this;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, boolean z) {
return add(fieldDescriptor, z, true);
}
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, boolean z, boolean z2) {
return add(fieldDescriptor, z ? 1 : 0, z2);
}
public ProtobufDataEncoderContext encode(Object obj) {
if (obj == null) {
return this;
}
ObjectEncoder objectEncoder = (ObjectEncoder) this.objectEncoders.get(obj.getClass());
if (objectEncoder != null) {
objectEncoder.encode(obj, this);
return this;
}
throw new EncodingException("No encoder for " + obj.getClass());
}
public final ProtobufDataEncoderContext doEncode(ObjectEncoder objectEncoder, FieldDescriptor fieldDescriptor, Object obj, boolean z) {
long determineSize = determineSize(objectEncoder, obj);
if (z && determineSize == 0) {
return this;
}
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
writeVarInt64(determineSize);
objectEncoder.encode(obj, this);
return this;
}
public final long determineSize(ObjectEncoder objectEncoder, Object obj) {
LengthCountingOutputStream lengthCountingOutputStream = new LengthCountingOutputStream();
try {
OutputStream outputStream = this.output;
this.output = lengthCountingOutputStream;
try {
objectEncoder.encode(obj, this);
this.output = outputStream;
long length = lengthCountingOutputStream.getLength();
lengthCountingOutputStream.close();
return length;
} catch (Throwable th) {
this.output = outputStream;
throw th;
}
} catch (Throwable th2) {
try {
lengthCountingOutputStream.close();
} catch (Throwable th3) {
th2.addSuppressed(th3);
}
throw th2;
}
}
public final ProtobufDataEncoderContext doEncode(ValueEncoder valueEncoder, FieldDescriptor fieldDescriptor, Object obj, boolean z) {
this.valueEncoderContext.resetContext(fieldDescriptor, z);
valueEncoder.encode(obj, this.valueEncoderContext);
return this;
}
public static ByteBuffer allocateBuffer(int i) {
return ByteBuffer.allocate(i).order(ByteOrder.LITTLE_ENDIAN);
}
public static int getTag(FieldDescriptor fieldDescriptor) {
Protobuf protobuf = (Protobuf) fieldDescriptor.getProperty(Protobuf.class);
if (protobuf == null) {
throw new EncodingException("Field has no @Protobuf config");
}
return protobuf.tag();
}
public static Protobuf getProtobuf(FieldDescriptor fieldDescriptor) {
Protobuf protobuf = (Protobuf) fieldDescriptor.getProperty(Protobuf.class);
if (protobuf != null) {
return protobuf;
}
throw new EncodingException("Field has no @Protobuf config");
}
public final void writeVarInt32(int i) {
while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) {
this.output.write((i & 127) | 128);
i >>>= 7;
}
this.output.write(i & 127);
}
public final void writeVarInt64(long j) {
while (((-128) & j) != 0) {
this.output.write((((int) j) & 127) | 128);
j >>>= 7;
}
this.output.write(((int) j) & 127);
}
}

View File

@@ -0,0 +1,76 @@
package com.google.firebase.encoders.proto;
import com.google.firebase.encoders.EncodingException;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.config.Configurator;
import com.google.firebase.encoders.config.EncoderConfig;
import com.google.firebase.encoders.proto.ProtobufEncoder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes3.dex */
public class ProtobufEncoder {
public final ObjectEncoder fallbackEncoder;
public final Map objectEncoders;
public final Map valueEncoders;
public ProtobufEncoder(Map map, Map map2, ObjectEncoder objectEncoder) {
this.objectEncoders = map;
this.valueEncoders = map2;
this.fallbackEncoder = objectEncoder;
}
public void encode(Object obj, OutputStream outputStream) {
new ProtobufDataEncoderContext(outputStream, this.objectEncoders, this.valueEncoders, this.fallbackEncoder).encode(obj);
}
public byte[] encode(Object obj) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
encode(obj, byteArrayOutputStream);
} catch (IOException unused) {
}
return byteArrayOutputStream.toByteArray();
}
public static Builder builder() {
return new Builder();
}
public static final class Builder implements EncoderConfig {
public static final ObjectEncoder DEFAULT_FALLBACK_ENCODER = new ObjectEncoder() { // from class: com.google.firebase.encoders.proto.ProtobufEncoder$Builder$$ExternalSyntheticLambda0
@Override // com.google.firebase.encoders.ObjectEncoder
public final void encode(Object obj, Object obj2) {
ProtobufEncoder.Builder.lambda$static$0(obj, (ObjectEncoderContext) obj2);
}
};
public final Map objectEncoders = new HashMap();
public final Map valueEncoders = new HashMap();
public ObjectEncoder fallbackEncoder = DEFAULT_FALLBACK_ENCODER;
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ void lambda$static$0(Object obj, ObjectEncoderContext objectEncoderContext) {
throw new EncodingException("Couldn't find encoder for type " + obj.getClass().getCanonicalName());
}
@Override // com.google.firebase.encoders.config.EncoderConfig
public Builder registerEncoder(Class cls, ObjectEncoder objectEncoder) {
this.objectEncoders.put(cls, objectEncoder);
this.valueEncoders.remove(cls);
return this;
}
public Builder configureWith(Configurator configurator) {
configurator.configure(this);
return this;
}
public ProtobufEncoder build() {
return new ProtobufEncoder(new HashMap(this.objectEncoders), new HashMap(this.valueEncoders), this.fallbackEncoder);
}
}
}

View File

@@ -0,0 +1,44 @@
package com.google.firebase.encoders.proto;
import com.google.firebase.encoders.EncodingException;
import com.google.firebase.encoders.FieldDescriptor;
import com.google.firebase.encoders.ValueEncoderContext;
/* loaded from: classes3.dex */
public class ProtobufValueEncoderContext implements ValueEncoderContext {
public FieldDescriptor field;
public final ProtobufDataEncoderContext objEncoderCtx;
public boolean encoded = false;
public boolean skipDefault = false;
public void resetContext(FieldDescriptor fieldDescriptor, boolean z) {
this.encoded = false;
this.field = fieldDescriptor;
this.skipDefault = z;
}
public ProtobufValueEncoderContext(ProtobufDataEncoderContext protobufDataEncoderContext) {
this.objEncoderCtx = protobufDataEncoderContext;
}
public final void checkNotUsed() {
if (this.encoded) {
throw new EncodingException("Cannot encode a second value in the ValueEncoderContext");
}
this.encoded = true;
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public ValueEncoderContext add(String str) {
checkNotUsed();
this.objEncoderCtx.add(this.field, str, this.skipDefault);
return this;
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public ValueEncoderContext add(boolean z) {
checkNotUsed();
this.objEncoderCtx.add(this.field, z, this.skipDefault);
return this;
}
}