Initial import of ADIF API reverse-engineering toolkit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface DataEncoder {
|
||||
String encode(Object obj);
|
||||
|
||||
void encode(Object obj, Writer writer) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: classes3.dex */
|
||||
public interface Encoder<TValue, TContext> {
|
||||
void encode(TValue tvalue, TContext tcontext) throws IOException;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
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 {
|
||||
private final String name;
|
||||
private final Map<Class<?>, Object> properties;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public static final class Builder {
|
||||
private final String name;
|
||||
private Map<Class<?>, Object> properties = null;
|
||||
|
||||
public Builder(String str) {
|
||||
this.name = str;
|
||||
}
|
||||
|
||||
public FieldDescriptor build() {
|
||||
return new FieldDescriptor(this.name, this.properties == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(new HashMap(this.properties)));
|
||||
}
|
||||
|
||||
public <T extends Annotation> Builder withProperty(T t2) {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap();
|
||||
}
|
||||
this.properties.put(t2.annotationType(), t2);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder builder(String str) {
|
||||
return new Builder(str);
|
||||
}
|
||||
|
||||
public static FieldDescriptor of(String str) {
|
||||
return new FieldDescriptor(str, Collections.EMPTY_MAP);
|
||||
}
|
||||
|
||||
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 String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public <T extends Annotation> T getProperty(Class<T> cls) {
|
||||
return (T) this.properties.get(cls);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.properties.hashCode() + (this.name.hashCode() * 31);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "FieldDescriptor{name=" + this.name + ", properties=" + this.properties.values() + "}";
|
||||
}
|
||||
|
||||
private FieldDescriptor(String str, Map<Class<?>, Object> map) {
|
||||
this.name = str;
|
||||
this.properties = map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface ObjectEncoder<T> extends Encoder<T, ObjectEncoderContext> {
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface ObjectEncoderContext {
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d4) throws IOException;
|
||||
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, float f2) throws IOException;
|
||||
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, int i) throws IOException;
|
||||
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, long j4) throws IOException;
|
||||
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj) throws IOException;
|
||||
|
||||
ObjectEncoderContext add(FieldDescriptor fieldDescriptor, boolean z3) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
ObjectEncoderContext add(String str, double d4) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
ObjectEncoderContext add(String str, int i) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
ObjectEncoderContext add(String str, long j4) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
ObjectEncoderContext add(String str, Object obj) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
ObjectEncoderContext add(String str, boolean z3) throws IOException;
|
||||
|
||||
ObjectEncoderContext inline(Object obj) throws IOException;
|
||||
|
||||
ObjectEncoderContext nested(FieldDescriptor fieldDescriptor) throws IOException;
|
||||
|
||||
ObjectEncoderContext nested(String str) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface ValueEncoder<T> extends Encoder<T, ValueEncoderContext> {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.google.firebase.encoders;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface ValueEncoderContext {
|
||||
ValueEncoderContext add(double d4) throws IOException;
|
||||
|
||||
ValueEncoderContext add(float f2) throws IOException;
|
||||
|
||||
ValueEncoderContext add(int i) throws IOException;
|
||||
|
||||
ValueEncoderContext add(long j4) throws IOException;
|
||||
|
||||
ValueEncoderContext add(String str) throws IOException;
|
||||
|
||||
ValueEncoderContext add(boolean z3) throws IOException;
|
||||
|
||||
ValueEncoderContext add(byte[] bArr) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.google.firebase.encoders.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes3.dex */
|
||||
public @interface Encodable {
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes3.dex */
|
||||
public @interface Field {
|
||||
boolean inline() default false;
|
||||
|
||||
String name() default "";
|
||||
}
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes3.dex */
|
||||
public @interface Ignore {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.google.firebase.encoders.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes3.dex */
|
||||
public @interface ExtraProperty {
|
||||
Class<?>[] allowedTypes() default {};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.google.firebase.encoders.config;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface Configurator {
|
||||
void configure(EncoderConfig<?> encoderConfig);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.google.firebase.encoders.config;
|
||||
|
||||
import com.google.firebase.encoders.ObjectEncoder;
|
||||
import com.google.firebase.encoders.ValueEncoder;
|
||||
import com.google.firebase.encoders.config.EncoderConfig;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface EncoderConfig<T extends EncoderConfig<T>> {
|
||||
<U> T registerEncoder(Class<U> cls, ObjectEncoder<? super U> objectEncoder);
|
||||
|
||||
<U> T registerEncoder(Class<U> cls, ValueEncoder<? super U> valueEncoder);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.google.firebase.encoders.json;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public final class BuildConfig {
|
||||
public static final String BUILD_TYPE = "release";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String LIBRARY_PACKAGE_NAME = "com.google.firebase.encoders.json";
|
||||
public static final String VERSION_NAME = "18.0.1";
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
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<JsonDataEncoderBuilder> {
|
||||
private static final ValueEncoder<Boolean> BOOLEAN_ENCODER;
|
||||
private static final ValueEncoder<String> STRING_ENCODER;
|
||||
private static final ObjectEncoder<Object> DEFAULT_FALLBACK_ENCODER = new Object();
|
||||
private static final TimestampEncoder TIMESTAMP_ENCODER = new TimestampEncoder();
|
||||
private final Map<Class<?>, ObjectEncoder<?>> objectEncoders = new HashMap();
|
||||
private final Map<Class<?>, ValueEncoder<?>> valueEncoders = new HashMap();
|
||||
private ObjectEncoder<Object> fallbackEncoder = DEFAULT_FALLBACK_ENCODER;
|
||||
private boolean ignoreNullValues = false;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public static final class TimestampEncoder implements ValueEncoder<Date> {
|
||||
private static final DateFormat rfc339;
|
||||
|
||||
static {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
rfc339 = simpleDateFormat;
|
||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
private TimestampEncoder() {
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.Encoder
|
||||
public void encode(Date date, ValueEncoderContext valueEncoderContext) throws IOException {
|
||||
valueEncoderContext.add(rfc339.format(date));
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r0v0, types: [java.lang.Object, com.google.firebase.encoders.ObjectEncoder<java.lang.Object>] */
|
||||
static {
|
||||
final int i = 0;
|
||||
STRING_ENCODER = new ValueEncoder() { // from class: com.google.firebase.encoders.json.b
|
||||
@Override // com.google.firebase.encoders.Encoder
|
||||
public final void encode(Object obj, ValueEncoderContext valueEncoderContext) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
valueEncoderContext.add((String) obj);
|
||||
return;
|
||||
default:
|
||||
JsonDataEncoderBuilder.lambda$static$2((Boolean) obj, valueEncoderContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
final int i4 = 1;
|
||||
BOOLEAN_ENCODER = new ValueEncoder() { // from class: com.google.firebase.encoders.json.b
|
||||
@Override // com.google.firebase.encoders.Encoder
|
||||
public final void encode(Object obj, ValueEncoderContext valueEncoderContext) {
|
||||
switch (i4) {
|
||||
case 0:
|
||||
valueEncoderContext.add((String) obj);
|
||||
return;
|
||||
default:
|
||||
JsonDataEncoderBuilder.lambda$static$2((Boolean) obj, valueEncoderContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public JsonDataEncoderBuilder() {
|
||||
registerEncoder(String.class, (ValueEncoder) STRING_ENCODER);
|
||||
registerEncoder(Boolean.class, (ValueEncoder) BOOLEAN_ENCODER);
|
||||
registerEncoder(Date.class, (ValueEncoder) TIMESTAMP_ENCODER);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static /* synthetic */ void lambda$static$0(Object obj, ObjectEncoderContext objectEncoderContext) throws IOException {
|
||||
throw new EncodingException("Couldn't find encoder for type " + obj.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static /* synthetic */ void lambda$static$2(Boolean bool, ValueEncoderContext valueEncoderContext) throws IOException {
|
||||
valueEncoderContext.add(bool.booleanValue());
|
||||
}
|
||||
|
||||
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) throws IOException {
|
||||
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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public JsonDataEncoderBuilder configureWith(Configurator configurator) {
|
||||
configurator.configure(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonDataEncoderBuilder ignoreNullValues(boolean z3) {
|
||||
this.ignoreNullValues = z3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonDataEncoderBuilder registerFallbackEncoder(ObjectEncoder<Object> objectEncoder) {
|
||||
this.fallbackEncoder = objectEncoder;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.config.EncoderConfig
|
||||
public <T> JsonDataEncoderBuilder registerEncoder(Class<T> cls, ObjectEncoder<? super T> objectEncoder) {
|
||||
this.objectEncoders.put(cls, objectEncoder);
|
||||
this.valueEncoders.remove(cls);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.config.EncoderConfig
|
||||
public <T> JsonDataEncoderBuilder registerEncoder(Class<T> cls, ValueEncoder<? super T> valueEncoder) {
|
||||
this.valueEncoders.put(cls, valueEncoder);
|
||||
this.objectEncoders.remove(cls);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
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.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: classes3.dex */
|
||||
public final class JsonValueObjectEncoderContext implements ObjectEncoderContext, ValueEncoderContext {
|
||||
private final ObjectEncoder<Object> fallbackEncoder;
|
||||
private final boolean ignoreNullValues;
|
||||
private final JsonWriter jsonWriter;
|
||||
private final Map<Class<?>, ObjectEncoder<?>> objectEncoders;
|
||||
private final Map<Class<?>, ValueEncoder<?>> valueEncoders;
|
||||
private JsonValueObjectEncoderContext childContext = null;
|
||||
private boolean active = true;
|
||||
|
||||
public JsonValueObjectEncoderContext(Writer writer, Map<Class<?>, ObjectEncoder<?>> map, Map<Class<?>, ValueEncoder<?>> map2, ObjectEncoder<Object> objectEncoder, boolean z3) {
|
||||
this.jsonWriter = new JsonWriter(writer);
|
||||
this.objectEncoders = map;
|
||||
this.valueEncoders = map2;
|
||||
this.fallbackEncoder = objectEncoder;
|
||||
this.ignoreNullValues = z3;
|
||||
}
|
||||
|
||||
private boolean cannotBeInline(Object obj) {
|
||||
return obj == null || obj.getClass().isArray() || (obj instanceof Collection) || (obj instanceof Date) || (obj instanceof Enum) || (obj instanceof Number);
|
||||
}
|
||||
|
||||
private JsonValueObjectEncoderContext internalAdd(String str, Object obj) throws IOException, EncodingException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
if (obj != null) {
|
||||
return add(obj, false);
|
||||
}
|
||||
this.jsonWriter.nullValue();
|
||||
return this;
|
||||
}
|
||||
|
||||
private JsonValueObjectEncoderContext internalAddIgnoreNullValues(String str, Object obj) throws IOException, EncodingException {
|
||||
if (obj == null) {
|
||||
return this;
|
||||
}
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
return add(obj, false);
|
||||
}
|
||||
|
||||
private void maybeUnNest() throws IOException {
|
||||
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 void close() throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.flush();
|
||||
}
|
||||
|
||||
public JsonValueObjectEncoderContext doEncode(ObjectEncoder<Object> objectEncoder, Object obj, boolean z3) throws IOException {
|
||||
if (!z3) {
|
||||
this.jsonWriter.beginObject();
|
||||
}
|
||||
objectEncoder.encode(obj, this);
|
||||
if (!z3) {
|
||||
this.jsonWriter.endObject();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext inline(Object obj) throws IOException {
|
||||
return add(obj, true);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext nested(String str) throws IOException {
|
||||
maybeUnNest();
|
||||
this.childContext = new JsonValueObjectEncoderContext(this);
|
||||
this.jsonWriter.name(str);
|
||||
this.jsonWriter.beginObject();
|
||||
return this.childContext;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext nested(FieldDescriptor fieldDescriptor) throws IOException {
|
||||
return nested(fieldDescriptor.getName());
|
||||
}
|
||||
|
||||
private JsonValueObjectEncoderContext(JsonValueObjectEncoderContext jsonValueObjectEncoderContext) {
|
||||
this.jsonWriter = jsonValueObjectEncoderContext.jsonWriter;
|
||||
this.objectEncoders = jsonValueObjectEncoderContext.objectEncoders;
|
||||
this.valueEncoders = jsonValueObjectEncoderContext.valueEncoders;
|
||||
this.fallbackEncoder = jsonValueObjectEncoderContext.fallbackEncoder;
|
||||
this.ignoreNullValues = jsonValueObjectEncoderContext.ignoreNullValues;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str, Object obj) throws IOException {
|
||||
if (this.ignoreNullValues) {
|
||||
return internalAddIgnoreNullValues(str, obj);
|
||||
}
|
||||
return internalAdd(str, obj);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str, double d4) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
return add(d4);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str, int i) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
return add(i);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str, long j4) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
return add(j4);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str, boolean z3) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.name(str);
|
||||
return add(z3);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj) throws IOException {
|
||||
return add(fieldDescriptor.getName(), obj);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, float f2) throws IOException {
|
||||
return add(fieldDescriptor.getName(), f2);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d4) throws IOException {
|
||||
return add(fieldDescriptor.getName(), d4);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, int i) throws IOException {
|
||||
return add(fieldDescriptor.getName(), i);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, long j4) throws IOException {
|
||||
return add(fieldDescriptor.getName(), j4);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, boolean z3) throws IOException {
|
||||
return add(fieldDescriptor.getName(), z3);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(String str) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(float f2) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(f2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(double d4) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(d4);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(int i) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(long j4) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(j4);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(boolean z3) throws IOException {
|
||||
maybeUnNest();
|
||||
this.jsonWriter.value(z3);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public JsonValueObjectEncoderContext add(byte[] bArr) throws IOException {
|
||||
maybeUnNest();
|
||||
if (bArr == null) {
|
||||
this.jsonWriter.nullValue();
|
||||
return this;
|
||||
}
|
||||
this.jsonWriter.value(Base64.encodeToString(bArr, 2));
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonValueObjectEncoderContext add(Object obj, boolean z3) throws IOException {
|
||||
if (z3 && cannotBeInline(obj)) {
|
||||
throw new EncodingException((obj == null ? null : obj.getClass()) + " cannot be encoded inline");
|
||||
}
|
||||
if (obj == null) {
|
||||
this.jsonWriter.nullValue();
|
||||
return this;
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
this.jsonWriter.value((Number) obj);
|
||||
return this;
|
||||
}
|
||||
int i = 0;
|
||||
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 e4) {
|
||||
throw new EncodingException(String.format("Only String keys are currently supported in maps, got %s of type %s instead.", key, key.getClass()), e4);
|
||||
}
|
||||
}
|
||||
this.jsonWriter.endObject();
|
||||
return this;
|
||||
}
|
||||
ObjectEncoder<?> objectEncoder = this.objectEncoders.get(obj.getClass());
|
||||
if (objectEncoder != null) {
|
||||
return doEncode(objectEncoder, obj, z3);
|
||||
}
|
||||
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());
|
||||
return this;
|
||||
}
|
||||
add(((Enum) obj).name());
|
||||
return this;
|
||||
}
|
||||
return doEncode(this.fallbackEncoder, obj, z3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.google.firebase.encoders.json;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001R\u0012\u0010\u0002\u001a\u00020\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0004\u0010\u0005¨\u0006\u0006"}, d2 = {"Lcom/google/firebase/encoders/json/NumberedEnum;", "", "number", "", "getNumber", "()I", "com.google.firebase-encoders-firebase-encoders-json"}, k = 1, mv = {1, 7, 1}, xi = 48)
|
||||
/* loaded from: classes3.dex */
|
||||
public interface NumberedEnum {
|
||||
int getNumber();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.google.firebase.encoders.json;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public final class R {
|
||||
private R() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.google.firebase.encoders.json;
|
||||
|
||||
import com.google.firebase.encoders.ObjectEncoder;
|
||||
import com.google.firebase.encoders.ObjectEncoderContext;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public final /* synthetic */ class a implements ObjectEncoder {
|
||||
@Override // com.google.firebase.encoders.Encoder
|
||||
public final void encode(Object obj, ObjectEncoderContext objectEncoderContext) {
|
||||
JsonDataEncoderBuilder.lambda$static$0(obj, objectEncoderContext);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import com.google.firebase.encoders.proto.Protobuf;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public final class AtProtobuf {
|
||||
private Protobuf.IntEncoding intEncoding = Protobuf.IntEncoding.DEFAULT;
|
||||
private int tag;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public static final class ProtobufImpl implements Protobuf {
|
||||
private final Protobuf.IntEncoding intEncoding;
|
||||
private final int tag;
|
||||
|
||||
public ProtobufImpl(int i, Protobuf.IntEncoding intEncoding) {
|
||||
this.tag = i;
|
||||
this.intEncoding = intEncoding;
|
||||
}
|
||||
|
||||
@Override // java.lang.annotation.Annotation
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
return Protobuf.class;
|
||||
}
|
||||
|
||||
@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 // 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;
|
||||
}
|
||||
|
||||
@Override // java.lang.annotation.Annotation
|
||||
public String toString() {
|
||||
return "@com.google.firebase.encoders.proto.Protobuf(tag=" + this.tag + "intEncoding=" + this.intEncoding + ')';
|
||||
}
|
||||
}
|
||||
|
||||
public static AtProtobuf builder() {
|
||||
return new AtProtobuf();
|
||||
}
|
||||
|
||||
public Protobuf build() {
|
||||
return new ProtobufImpl(this.tag, this.intEncoding);
|
||||
}
|
||||
|
||||
public AtProtobuf intEncoding(Protobuf.IntEncoding intEncoding) {
|
||||
this.intEncoding = intEncoding;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AtProtobuf tag(int i) {
|
||||
this.tag = i;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
final class LengthCountingOutputStream extends OutputStream {
|
||||
private 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 i4) {
|
||||
int i5;
|
||||
if (i >= 0 && i <= bArr.length && i4 >= 0 && (i5 = i + i4) <= bArr.length && i5 >= 0) {
|
||||
this.length += i4;
|
||||
return;
|
||||
}
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public interface ProtoEnum {
|
||||
int getNumber();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import com.google.firebase.encoders.annotations.ExtraProperty;
|
||||
|
||||
@ExtraProperty
|
||||
/* loaded from: classes3.dex */
|
||||
public @interface Protobuf {
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public enum IntEncoding {
|
||||
DEFAULT,
|
||||
SIGNED,
|
||||
FIXED
|
||||
}
|
||||
|
||||
IntEncoding intEncoding() default IntEncoding.DEFAULT;
|
||||
|
||||
int tag();
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import C.w;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
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 com.google.firebase.remoteconfig.FirebaseRemoteConfig;
|
||||
import java.io.IOException;
|
||||
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;
|
||||
import kotlinx.coroutines.scheduling.WorkQueueKt;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: classes3.dex */
|
||||
public final class ProtobufDataEncoderContext implements ObjectEncoderContext {
|
||||
private final ObjectEncoder<Object> fallbackEncoder;
|
||||
private final Map<Class<?>, ObjectEncoder<?>> objectEncoders;
|
||||
private OutputStream output;
|
||||
private final ProtobufValueEncoderContext valueEncoderContext = new ProtobufValueEncoderContext(this);
|
||||
private final Map<Class<?>, ValueEncoder<?>> valueEncoders;
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
private static final FieldDescriptor MAP_KEY_DESC = w.e(1, FieldDescriptor.builder("key"));
|
||||
private static final FieldDescriptor MAP_VALUE_DESC = w.e(2, FieldDescriptor.builder("value"));
|
||||
private static final ObjectEncoder<Map.Entry<Object, Object>> DEFAULT_MAP_ENCODER = new a(0);
|
||||
|
||||
/* renamed from: com.google.firebase.encoders.proto.ProtobufDataEncoderContext$1 */
|
||||
/* loaded from: classes3.dex */
|
||||
public static /* synthetic */ class AnonymousClass1 {
|
||||
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(OutputStream outputStream, Map<Class<?>, ObjectEncoder<?>> map, Map<Class<?>, ValueEncoder<?>> map2, ObjectEncoder<Object> objectEncoder) {
|
||||
this.output = outputStream;
|
||||
this.objectEncoders = map;
|
||||
this.valueEncoders = map2;
|
||||
this.fallbackEncoder = objectEncoder;
|
||||
}
|
||||
|
||||
private static ByteBuffer allocateBuffer(int i) {
|
||||
return ByteBuffer.allocate(i).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
private <T> long determineSize(ObjectEncoder<T> objectEncoder, T t2) throws IOException {
|
||||
LengthCountingOutputStream lengthCountingOutputStream = new LengthCountingOutputStream();
|
||||
try {
|
||||
OutputStream outputStream = this.output;
|
||||
this.output = lengthCountingOutputStream;
|
||||
try {
|
||||
objectEncoder.encode(t2, 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;
|
||||
}
|
||||
}
|
||||
|
||||
private <T> ProtobufDataEncoderContext doEncode(ObjectEncoder<T> objectEncoder, FieldDescriptor fieldDescriptor, T t2, boolean z3) throws IOException {
|
||||
long determineSize = determineSize(objectEncoder, t2);
|
||||
if (z3 && determineSize == 0) {
|
||||
return this;
|
||||
}
|
||||
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
|
||||
writeVarInt64(determineSize);
|
||||
objectEncoder.encode(t2, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
private 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");
|
||||
}
|
||||
|
||||
private static int getTag(FieldDescriptor fieldDescriptor) {
|
||||
Protobuf protobuf = (Protobuf) fieldDescriptor.getProperty(Protobuf.class);
|
||||
if (protobuf != null) {
|
||||
return protobuf.tag();
|
||||
}
|
||||
throw new EncodingException("Field has no @Protobuf config");
|
||||
}
|
||||
|
||||
public static /* synthetic */ void lambda$static$0(Map.Entry entry, ObjectEncoderContext objectEncoderContext) throws IOException {
|
||||
objectEncoderContext.add(MAP_KEY_DESC, entry.getKey());
|
||||
objectEncoderContext.add(MAP_VALUE_DESC, entry.getValue());
|
||||
}
|
||||
|
||||
private void writeVarInt32(int i) throws IOException {
|
||||
while ((i & (-128)) != 0) {
|
||||
this.output.write((i & WorkQueueKt.MASK) | 128);
|
||||
i >>>= 7;
|
||||
}
|
||||
this.output.write(i & WorkQueueKt.MASK);
|
||||
}
|
||||
|
||||
private void writeVarInt64(long j4) throws IOException {
|
||||
while (((-128) & j4) != 0) {
|
||||
this.output.write((((int) j4) & WorkQueueKt.MASK) | 128);
|
||||
j4 >>>= 7;
|
||||
}
|
||||
this.output.write(((int) j4) & WorkQueueKt.MASK);
|
||||
}
|
||||
|
||||
public ProtobufDataEncoderContext encode(Object obj) throws IOException {
|
||||
if (obj == null) {
|
||||
return this;
|
||||
}
|
||||
ObjectEncoder<?> objectEncoder = this.objectEncoders.get(obj.getClass());
|
||||
if (objectEncoder != null) {
|
||||
objectEncoder.encode(obj, this);
|
||||
return this;
|
||||
}
|
||||
throw new EncodingException("No encoder for " + obj.getClass());
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext inline(Object obj) throws IOException {
|
||||
return encode(obj);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext nested(String str) throws IOException {
|
||||
return nested(FieldDescriptor.of(str));
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext nested(FieldDescriptor fieldDescriptor) throws IOException {
|
||||
throw new EncodingException("nested() is not implemented for protobuf encoding.");
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(String str, Object obj) throws IOException {
|
||||
return add(FieldDescriptor.of(str), obj);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(String str, double d4) throws IOException {
|
||||
return add(FieldDescriptor.of(str), d4);
|
||||
}
|
||||
|
||||
private <T> ProtobufDataEncoderContext doEncode(ValueEncoder<T> valueEncoder, FieldDescriptor fieldDescriptor, T t2, boolean z3) throws IOException {
|
||||
this.valueEncoderContext.resetContext(fieldDescriptor, z3);
|
||||
valueEncoder.encode(t2, this.valueEncoderContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(String str, int i) throws IOException {
|
||||
return add(FieldDescriptor.of(str), i);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(String str, long j4) throws IOException {
|
||||
return add(FieldDescriptor.of(str), j4);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(String str, boolean z3) throws IOException {
|
||||
return add(FieldDescriptor.of(str), z3);
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj) throws IOException {
|
||||
return add(fieldDescriptor, obj, true);
|
||||
}
|
||||
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, Object obj, boolean z3) throws IOException {
|
||||
if (obj != null) {
|
||||
if (obj instanceof CharSequence) {
|
||||
CharSequence charSequence = (CharSequence) obj;
|
||||
if (!z3 || charSequence.length() != 0) {
|
||||
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
|
||||
byte[] bytes = charSequence.toString().getBytes(UTF_8);
|
||||
writeVarInt32(bytes.length);
|
||||
this.output.write(bytes);
|
||||
return this;
|
||||
}
|
||||
} else if (obj instanceof Collection) {
|
||||
Iterator it = ((Collection) obj).iterator();
|
||||
while (it.hasNext()) {
|
||||
add(fieldDescriptor, it.next(), false);
|
||||
}
|
||||
} else if (obj instanceof Map) {
|
||||
Iterator it2 = ((Map) obj).entrySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
doEncode((ObjectEncoder<FieldDescriptor>) DEFAULT_MAP_ENCODER, fieldDescriptor, (FieldDescriptor) it2.next(), false);
|
||||
}
|
||||
} else {
|
||||
if (obj instanceof Double) {
|
||||
return add(fieldDescriptor, ((Double) obj).doubleValue(), z3);
|
||||
}
|
||||
if (obj instanceof Float) {
|
||||
return add(fieldDescriptor, ((Float) obj).floatValue(), z3);
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
return add(fieldDescriptor, ((Number) obj).longValue(), z3);
|
||||
}
|
||||
if (obj instanceof Boolean) {
|
||||
return add(fieldDescriptor, ((Boolean) obj).booleanValue(), z3);
|
||||
}
|
||||
if (obj instanceof byte[]) {
|
||||
byte[] bArr = (byte[]) obj;
|
||||
if (!z3 || bArr.length != 0) {
|
||||
writeVarInt32((getTag(fieldDescriptor) << 3) | 2);
|
||||
writeVarInt32(bArr.length);
|
||||
this.output.write(bArr);
|
||||
return this;
|
||||
}
|
||||
} else {
|
||||
ObjectEncoder<?> objectEncoder = this.objectEncoders.get(obj.getClass());
|
||||
if (objectEncoder != null) {
|
||||
return doEncode((ObjectEncoder<FieldDescriptor>) objectEncoder, fieldDescriptor, (FieldDescriptor) obj, z3);
|
||||
}
|
||||
ValueEncoder<?> valueEncoder = this.valueEncoders.get(obj.getClass());
|
||||
if (valueEncoder != null) {
|
||||
return doEncode((ValueEncoder<FieldDescriptor>) valueEncoder, fieldDescriptor, (FieldDescriptor) obj, z3);
|
||||
}
|
||||
if (obj instanceof ProtoEnum) {
|
||||
return add(fieldDescriptor, ((ProtoEnum) obj).getNumber());
|
||||
}
|
||||
if (obj instanceof Enum) {
|
||||
return add(fieldDescriptor, ((Enum) obj).ordinal());
|
||||
}
|
||||
return doEncode((ObjectEncoder<FieldDescriptor>) this.fallbackEncoder, fieldDescriptor, (FieldDescriptor) obj, z3);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d4) throws IOException {
|
||||
return add(fieldDescriptor, d4, true);
|
||||
}
|
||||
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, double d4, boolean z3) throws IOException {
|
||||
if (z3 && d4 == FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) {
|
||||
return this;
|
||||
}
|
||||
writeVarInt32((getTag(fieldDescriptor) << 3) | 1);
|
||||
this.output.write(allocateBuffer(8).putDouble(d4).array());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, float f2) throws IOException {
|
||||
return add(fieldDescriptor, f2, true);
|
||||
}
|
||||
|
||||
public ObjectEncoderContext add(FieldDescriptor fieldDescriptor, float f2, boolean z3) throws IOException {
|
||||
if (z3 && f2 == BitmapDescriptorFactory.HUE_RED) {
|
||||
return this;
|
||||
}
|
||||
writeVarInt32((getTag(fieldDescriptor) << 3) | 5);
|
||||
this.output.write(allocateBuffer(4).putFloat(f2).array());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, int i) throws IOException {
|
||||
return add(fieldDescriptor, i, true);
|
||||
}
|
||||
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, int i, boolean z3) throws IOException {
|
||||
if (!z3 || i != 0) {
|
||||
Protobuf protobuf = getProtobuf(fieldDescriptor);
|
||||
int i4 = AnonymousClass1.$SwitchMap$com$google$firebase$encoders$proto$Protobuf$IntEncoding[protobuf.intEncoding().ordinal()];
|
||||
if (i4 == 1) {
|
||||
writeVarInt32(protobuf.tag() << 3);
|
||||
writeVarInt32(i);
|
||||
return this;
|
||||
}
|
||||
if (i4 == 2) {
|
||||
writeVarInt32(protobuf.tag() << 3);
|
||||
writeVarInt32((i << 1) ^ (i >> 31));
|
||||
return this;
|
||||
}
|
||||
if (i4 == 3) {
|
||||
writeVarInt32((protobuf.tag() << 3) | 5);
|
||||
this.output.write(allocateBuffer(4).putInt(i).array());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, long j4) throws IOException {
|
||||
return add(fieldDescriptor, j4, true);
|
||||
}
|
||||
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, long j4, boolean z3) throws IOException {
|
||||
if (!z3 || j4 != 0) {
|
||||
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(j4);
|
||||
return this;
|
||||
}
|
||||
if (i == 2) {
|
||||
writeVarInt32(protobuf.tag() << 3);
|
||||
writeVarInt64((j4 >> 63) ^ (j4 << 1));
|
||||
return this;
|
||||
}
|
||||
if (i == 3) {
|
||||
writeVarInt32((protobuf.tag() << 3) | 1);
|
||||
this.output.write(allocateBuffer(8).putLong(j4).array());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ObjectEncoderContext
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, boolean z3) throws IOException {
|
||||
return add(fieldDescriptor, z3, true);
|
||||
}
|
||||
|
||||
public ProtobufDataEncoderContext add(FieldDescriptor fieldDescriptor, boolean z3, boolean z4) throws IOException {
|
||||
return add(fieldDescriptor, z3 ? 1 : 0, z4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
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.ValueEncoder;
|
||||
import com.google.firebase.encoders.config.Configurator;
|
||||
import com.google.firebase.encoders.config.EncoderConfig;
|
||||
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 {
|
||||
private final ObjectEncoder<Object> fallbackEncoder;
|
||||
private final Map<Class<?>, ObjectEncoder<?>> objectEncoders;
|
||||
private final Map<Class<?>, ValueEncoder<?>> valueEncoders;
|
||||
|
||||
public ProtobufEncoder(Map<Class<?>, ObjectEncoder<?>> map, Map<Class<?>, ValueEncoder<?>> map2, ObjectEncoder<Object> objectEncoder) {
|
||||
this.objectEncoders = map;
|
||||
this.valueEncoders = map2;
|
||||
this.fallbackEncoder = objectEncoder;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public void encode(Object obj, OutputStream outputStream) throws IOException {
|
||||
new ProtobufDataEncoderContext(outputStream, this.objectEncoders, this.valueEncoders, this.fallbackEncoder).encode(obj);
|
||||
}
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public static final class Builder implements EncoderConfig<Builder> {
|
||||
private static final ObjectEncoder<Object> DEFAULT_FALLBACK_ENCODER = new a(1);
|
||||
private final Map<Class<?>, ObjectEncoder<?>> objectEncoders = new HashMap();
|
||||
private final Map<Class<?>, ValueEncoder<?>> valueEncoders = new HashMap();
|
||||
private ObjectEncoder<Object> fallbackEncoder = DEFAULT_FALLBACK_ENCODER;
|
||||
|
||||
public static /* synthetic */ void lambda$static$0(Object obj, ObjectEncoderContext objectEncoderContext) throws IOException {
|
||||
throw new EncodingException("Couldn't find encoder for type " + obj.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
public ProtobufEncoder build() {
|
||||
return new ProtobufEncoder(new HashMap(this.objectEncoders), new HashMap(this.valueEncoders), this.fallbackEncoder);
|
||||
}
|
||||
|
||||
public Builder configureWith(Configurator configurator) {
|
||||
configurator.configure(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder registerFallbackEncoder(ObjectEncoder<Object> objectEncoder) {
|
||||
this.fallbackEncoder = objectEncoder;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.config.EncoderConfig
|
||||
public <U> Builder registerEncoder(Class<U> cls, ObjectEncoder<? super U> objectEncoder) {
|
||||
this.objectEncoders.put(cls, objectEncoder);
|
||||
this.valueEncoders.remove(cls);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.config.EncoderConfig
|
||||
public <U> Builder registerEncoder(Class<U> cls, ValueEncoder<? super U> valueEncoder) {
|
||||
this.valueEncoders.put(cls, valueEncoder);
|
||||
this.objectEncoders.remove(cls);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode(Object obj) {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
encode(obj, byteArrayOutputStream);
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import com.google.firebase.encoders.EncodingException;
|
||||
import com.google.firebase.encoders.FieldDescriptor;
|
||||
import com.google.firebase.encoders.ValueEncoderContext;
|
||||
import java.io.IOException;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: classes3.dex */
|
||||
public class ProtobufValueEncoderContext implements ValueEncoderContext {
|
||||
private FieldDescriptor field;
|
||||
private final ProtobufDataEncoderContext objEncoderCtx;
|
||||
private boolean encoded = false;
|
||||
private boolean skipDefault = false;
|
||||
|
||||
public ProtobufValueEncoderContext(ProtobufDataEncoderContext protobufDataEncoderContext) {
|
||||
this.objEncoderCtx = protobufDataEncoderContext;
|
||||
}
|
||||
|
||||
private 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) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, str, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void resetContext(FieldDescriptor fieldDescriptor, boolean z3) {
|
||||
this.encoded = false;
|
||||
this.field = fieldDescriptor;
|
||||
this.skipDefault = z3;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(float f2) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, f2, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(double d4) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, d4, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(int i) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, i, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(long j4) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, j4, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(boolean z3) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, z3, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.ValueEncoderContext
|
||||
public ValueEncoderContext add(byte[] bArr) throws IOException {
|
||||
checkNotUsed();
|
||||
this.objEncoderCtx.add(this.field, bArr, this.skipDefault);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.google.firebase.encoders.proto;
|
||||
|
||||
import com.google.firebase.encoders.ObjectEncoder;
|
||||
import com.google.firebase.encoders.ObjectEncoderContext;
|
||||
import com.google.firebase.encoders.proto.ProtobufEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes3.dex */
|
||||
public final /* synthetic */ class a implements ObjectEncoder {
|
||||
|
||||
/* renamed from: a, reason: collision with root package name */
|
||||
public final /* synthetic */ int f5985a;
|
||||
|
||||
public /* synthetic */ a(int i) {
|
||||
this.f5985a = i;
|
||||
}
|
||||
|
||||
@Override // com.google.firebase.encoders.Encoder
|
||||
public final void encode(Object obj, ObjectEncoderContext objectEncoderContext) {
|
||||
switch (this.f5985a) {
|
||||
case 0:
|
||||
ProtobufDataEncoderContext.a((Map.Entry) obj, objectEncoderContext);
|
||||
return;
|
||||
default:
|
||||
ProtobufEncoder.Builder.a(obj, objectEncoderContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user