Initial import of ADIF API reverse-engineering toolkit

This commit is contained in:
2025-12-16 08:37:56 +01:00
commit 60388529c1
11486 changed files with 1086536 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.encoders.FieldDescriptor;
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.remoteconfig.RemoteConfigConstants;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import java.io.IOException;
/* loaded from: classes3.dex */
public final class AutoRolloutAssignmentEncoder implements Configurator {
public static final int CODEGEN_VERSION = 2;
public static final Configurator CONFIG = new AutoRolloutAssignmentEncoder();
/* loaded from: classes3.dex */
public static final class RolloutAssignmentEncoder implements ObjectEncoder<RolloutAssignment> {
static final RolloutAssignmentEncoder INSTANCE = new RolloutAssignmentEncoder();
private static final FieldDescriptor ROLLOUTID_DESCRIPTOR = FieldDescriptor.of(ConfigContainer.ROLLOUT_METADATA_ID);
private static final FieldDescriptor PARAMETERKEY_DESCRIPTOR = FieldDescriptor.of("parameterKey");
private static final FieldDescriptor PARAMETERVALUE_DESCRIPTOR = FieldDescriptor.of("parameterValue");
private static final FieldDescriptor VARIANTID_DESCRIPTOR = FieldDescriptor.of("variantId");
private static final FieldDescriptor TEMPLATEVERSION_DESCRIPTOR = FieldDescriptor.of(RemoteConfigConstants.ResponseFieldKey.TEMPLATE_VERSION_NUMBER);
private RolloutAssignmentEncoder() {
}
@Override // com.google.firebase.encoders.Encoder
public void encode(RolloutAssignment rolloutAssignment, ObjectEncoderContext objectEncoderContext) throws IOException {
objectEncoderContext.add(ROLLOUTID_DESCRIPTOR, rolloutAssignment.getRolloutId());
objectEncoderContext.add(PARAMETERKEY_DESCRIPTOR, rolloutAssignment.getParameterKey());
objectEncoderContext.add(PARAMETERVALUE_DESCRIPTOR, rolloutAssignment.getParameterValue());
objectEncoderContext.add(VARIANTID_DESCRIPTOR, rolloutAssignment.getVariantId());
objectEncoderContext.add(TEMPLATEVERSION_DESCRIPTOR, rolloutAssignment.getTemplateVersion());
}
}
private AutoRolloutAssignmentEncoder() {
}
@Override // com.google.firebase.encoders.config.Configurator
public void configure(EncoderConfig<?> encoderConfig) {
RolloutAssignmentEncoder rolloutAssignmentEncoder = RolloutAssignmentEncoder.INSTANCE;
encoderConfig.registerEncoder(RolloutAssignment.class, rolloutAssignmentEncoder);
encoderConfig.registerEncoder(AutoValue_RolloutAssignment.class, rolloutAssignmentEncoder);
}
}

View File

@@ -0,0 +1,89 @@
package com.google.firebase.crashlytics.internal.metadata;
import C.w;
/* loaded from: classes3.dex */
final class AutoValue_RolloutAssignment extends RolloutAssignment {
private final String parameterKey;
private final String parameterValue;
private final String rolloutId;
private final long templateVersion;
private final String variantId;
public AutoValue_RolloutAssignment(String str, String str2, String str3, String str4, long j4) {
if (str == null) {
throw new NullPointerException("Null rolloutId");
}
this.rolloutId = str;
if (str2 == null) {
throw new NullPointerException("Null parameterKey");
}
this.parameterKey = str2;
if (str3 == null) {
throw new NullPointerException("Null parameterValue");
}
this.parameterValue = str3;
if (str4 == null) {
throw new NullPointerException("Null variantId");
}
this.variantId = str4;
this.templateVersion = j4;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof RolloutAssignment) {
RolloutAssignment rolloutAssignment = (RolloutAssignment) obj;
if (this.rolloutId.equals(rolloutAssignment.getRolloutId()) && this.parameterKey.equals(rolloutAssignment.getParameterKey()) && this.parameterValue.equals(rolloutAssignment.getParameterValue()) && this.variantId.equals(rolloutAssignment.getVariantId()) && this.templateVersion == rolloutAssignment.getTemplateVersion()) {
return true;
}
}
return false;
}
@Override // com.google.firebase.crashlytics.internal.metadata.RolloutAssignment
public String getParameterKey() {
return this.parameterKey;
}
@Override // com.google.firebase.crashlytics.internal.metadata.RolloutAssignment
public String getParameterValue() {
return this.parameterValue;
}
@Override // com.google.firebase.crashlytics.internal.metadata.RolloutAssignment
public String getRolloutId() {
return this.rolloutId;
}
@Override // com.google.firebase.crashlytics.internal.metadata.RolloutAssignment
public long getTemplateVersion() {
return this.templateVersion;
}
@Override // com.google.firebase.crashlytics.internal.metadata.RolloutAssignment
public String getVariantId() {
return this.variantId;
}
public int hashCode() {
int hashCode = (((((((this.rolloutId.hashCode() ^ 1000003) * 1000003) ^ this.parameterKey.hashCode()) * 1000003) ^ this.parameterValue.hashCode()) * 1000003) ^ this.variantId.hashCode()) * 1000003;
long j4 = this.templateVersion;
return ((int) (j4 ^ (j4 >>> 32))) ^ hashCode;
}
public String toString() {
StringBuilder sb = new StringBuilder("RolloutAssignment{rolloutId=");
sb.append(this.rolloutId);
sb.append(", parameterKey=");
sb.append(this.parameterKey);
sb.append(", parameterValue=");
sb.append(this.parameterValue);
sb.append(", variantId=");
sb.append(this.variantId);
sb.append(", templateVersion=");
return w.q(sb, this.templateVersion, "}");
}
}

View File

@@ -0,0 +1,15 @@
package com.google.firebase.crashlytics.internal.metadata;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public interface FileLogStore {
void closeLogFile();
void deleteLogFile();
byte[] getLogAsBytes();
String getLogAsString();
void writeToLog(long j4, String str);
}

View File

@@ -0,0 +1,76 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class KeysMap {
private final Map<String, String> keys = new HashMap();
private final int maxEntries;
private final int maxEntryLength;
public KeysMap(int i, int i4) {
this.maxEntries = i;
this.maxEntryLength = i4;
}
private String sanitizeKey(String str) {
if (str != null) {
return sanitizeString(str, this.maxEntryLength);
}
throw new IllegalArgumentException("Custom attribute key must not be null.");
}
public static String sanitizeString(String str, int i) {
if (str == null) {
return str;
}
String trim = str.trim();
return trim.length() > i ? trim.substring(0, i) : trim;
}
public synchronized Map<String, String> getKeys() {
return Collections.unmodifiableMap(new HashMap(this.keys));
}
public synchronized boolean setKey(String str, String str2) {
String sanitizeKey = sanitizeKey(str);
if (this.keys.size() >= this.maxEntries && !this.keys.containsKey(sanitizeKey)) {
Logger.getLogger().w("Ignored entry \"" + str + "\" when adding custom keys. Maximum allowable: " + this.maxEntries);
return false;
}
String sanitizeString = sanitizeString(str2, this.maxEntryLength);
if (CommonUtils.nullSafeEquals(this.keys.get(sanitizeKey), sanitizeString)) {
return false;
}
Map<String, String> map = this.keys;
if (str2 == null) {
sanitizeString = "";
}
map.put(sanitizeKey, sanitizeString);
return true;
}
public synchronized void setKeys(Map<String, String> map) {
try {
int i = 0;
for (Map.Entry<String, String> entry : map.entrySet()) {
String sanitizeKey = sanitizeKey(entry.getKey());
if (this.keys.size() >= this.maxEntries && !this.keys.containsKey(sanitizeKey)) {
i++;
}
String value = entry.getValue();
this.keys.put(sanitizeKey, value == null ? "" : sanitizeString(value, this.maxEntryLength));
}
if (i > 0) {
Logger.getLogger().w("Ignored " + i + " entries when adding custom keys. Maximum allowable: " + this.maxEntries);
}
} catch (Throwable th) {
throw th;
}
}
}

View File

@@ -0,0 +1,84 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.persistence.FileStore;
import java.io.File;
/* loaded from: classes3.dex */
public class LogFileManager {
private static final String LOGFILE_NAME = "userlog";
static final int MAX_LOG_SIZE = 65536;
private static final NoopLogStore NOOP_LOG_STORE = new NoopLogStore();
private FileLogStore currentLog;
private final FileStore fileStore;
/* loaded from: classes3.dex */
public static final class NoopLogStore implements FileLogStore {
private NoopLogStore() {
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void closeLogFile() {
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void deleteLogFile() {
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public byte[] getLogAsBytes() {
return null;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public String getLogAsString() {
return null;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void writeToLog(long j4, String str) {
}
}
public LogFileManager(FileStore fileStore) {
this.fileStore = fileStore;
this.currentLog = NOOP_LOG_STORE;
}
private File getWorkingFileForSession(String str) {
return this.fileStore.getSessionFile(str, LOGFILE_NAME);
}
public void clearLog() {
this.currentLog.deleteLogFile();
}
public byte[] getBytesForLog() {
return this.currentLog.getLogAsBytes();
}
public String getLogString() {
return this.currentLog.getLogAsString();
}
public final void setCurrentSession(String str) {
this.currentLog.closeLogFile();
this.currentLog = NOOP_LOG_STORE;
if (str == null) {
return;
}
setLogFile(getWorkingFileForSession(str), MAX_LOG_SIZE);
}
public void setLogFile(File file, int i) {
this.currentLog = new QueueFileLogStore(file, i);
}
public void writeToLog(long j4, String str) {
this.currentLog.writeToLog(j4, str);
}
public LogFileManager(FileStore fileStore, String str) {
this(fileStore);
setCurrentSession(str);
}
}

View File

@@ -0,0 +1,356 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import com.google.firebase.crashlytics.internal.persistence.FileStore;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class MetaDataStore {
private static final String KEY_USER_ID = "userId";
private static final Charset UTF_8 = Charset.forName("UTF-8");
private final FileStore fileStore;
public MetaDataStore(FileStore fileStore) {
this.fileStore = fileStore;
}
private static Map<String, String> jsonToKeysData(String str) throws JSONException {
JSONObject jSONObject = new JSONObject(str);
HashMap hashMap = new HashMap();
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
hashMap.put(next, valueOrNull(jSONObject, next));
}
return hashMap;
}
private static List<RolloutAssignment> jsonToRolloutsState(String str) throws JSONException {
JSONArray jSONArray = new JSONObject(str).getJSONArray("rolloutsState");
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
String string = jSONArray.getString(i);
try {
arrayList.add(RolloutAssignment.create(string));
} catch (Exception e4) {
Logger.getLogger().w("Failed de-serializing rollouts state. " + string, e4);
}
}
return arrayList;
}
private String jsonToUserId(String str) throws JSONException {
return valueOrNull(new JSONObject(str), KEY_USER_ID);
}
private static String keysDataToJson(Map<String, String> map) {
return new JSONObject(map).toString();
}
private static String rolloutsStateToJson(List<RolloutAssignment> list) {
HashMap hashMap = new HashMap();
JSONArray jSONArray = new JSONArray();
for (int i = 0; i < list.size(); i++) {
try {
jSONArray.put(new JSONObject(RolloutAssignment.ROLLOUT_ASSIGNMENT_JSON_ENCODER.encode(list.get(i))));
} catch (JSONException e4) {
Logger.getLogger().w("Exception parsing rollout assignment!", e4);
}
}
hashMap.put("rolloutsState", jSONArray);
return new JSONObject(hashMap).toString();
}
private static void safeDeleteCorruptFile(File file) {
if (file.exists() && file.delete()) {
Logger.getLogger().i("Deleted corrupt file: " + file.getAbsolutePath());
}
}
private static String userIdToJson(String str) throws JSONException {
return new JSONObject(str) { // from class: com.google.firebase.crashlytics.internal.metadata.MetaDataStore.1
final /* synthetic */ String val$userId;
{
this.val$userId = str;
put(MetaDataStore.KEY_USER_ID, str);
}
}.toString();
}
private static String valueOrNull(JSONObject jSONObject, String str) {
if (jSONObject.isNull(str)) {
return null;
}
return jSONObject.optString(str, null);
}
public File getInternalKeysFileForSession(String str) {
return this.fileStore.getSessionFile(str, UserMetadata.INTERNAL_KEYDATA_FILENAME);
}
public File getKeysFileForSession(String str) {
return this.fileStore.getSessionFile(str, UserMetadata.KEYDATA_FILENAME);
}
public File getRolloutsStateForSession(String str) {
return this.fileStore.getSessionFile(str, UserMetadata.ROLLOUTS_STATE_FILENAME);
}
public File getUserDataFileForSession(String str) {
return this.fileStore.getSessionFile(str, UserMetadata.USERDATA_FILENAME);
}
public Map<String, String> readKeyData(String str) {
return readKeyData(str, false);
}
public List<RolloutAssignment> readRolloutsState(String str) {
FileInputStream fileInputStream;
File rolloutsStateForSession = getRolloutsStateForSession(str);
if (!rolloutsStateForSession.exists() || rolloutsStateForSession.length() == 0) {
safeDeleteCorruptFile(rolloutsStateForSession);
return Collections.EMPTY_LIST;
}
FileInputStream fileInputStream2 = null;
try {
try {
fileInputStream = new FileInputStream(rolloutsStateForSession);
} catch (Exception e4) {
e = e4;
}
} catch (Throwable th) {
th = th;
}
try {
List<RolloutAssignment> jsonToRolloutsState = jsonToRolloutsState(CommonUtils.streamToString(fileInputStream));
Logger.getLogger().d("Loaded rollouts state:\n" + jsonToRolloutsState + "\nfor session " + str);
CommonUtils.closeOrLog(fileInputStream, "Failed to close rollouts state file.");
return jsonToRolloutsState;
} catch (Exception e5) {
e = e5;
fileInputStream2 = fileInputStream;
Logger.getLogger().w("Error deserializing rollouts state.", e);
safeDeleteCorruptFile(rolloutsStateForSession);
CommonUtils.closeOrLog(fileInputStream2, "Failed to close rollouts state file.");
return Collections.EMPTY_LIST;
} catch (Throwable th2) {
th = th2;
fileInputStream2 = fileInputStream;
CommonUtils.closeOrLog(fileInputStream2, "Failed to close rollouts state file.");
throw th;
}
}
/* JADX WARN: Type inference failed for: r3v1, types: [int] */
public String readUserId(String str) {
FileInputStream fileInputStream;
File userDataFileForSession = getUserDataFileForSession(str);
Closeable closeable = null;
if (userDataFileForSession.exists()) {
?? r32 = (userDataFileForSession.length() > 0L ? 1 : (userDataFileForSession.length() == 0L ? 0 : -1));
try {
if (r32 != 0) {
try {
fileInputStream = new FileInputStream(userDataFileForSession);
try {
String jsonToUserId = jsonToUserId(CommonUtils.streamToString(fileInputStream));
Logger.getLogger().d("Loaded userId " + jsonToUserId + " for session " + str);
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return jsonToUserId;
} catch (Exception e4) {
e = e4;
Logger.getLogger().w("Error deserializing user metadata.", e);
safeDeleteCorruptFile(userDataFileForSession);
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return null;
}
} catch (Exception e5) {
e = e5;
fileInputStream = null;
} catch (Throwable th) {
th = th;
CommonUtils.closeOrLog(closeable, "Failed to close user metadata file.");
throw th;
}
}
} catch (Throwable th2) {
th = th2;
closeable = r32;
}
}
Logger.getLogger().d("No userId set for session " + str);
safeDeleteCorruptFile(userDataFileForSession);
return null;
}
public void writeKeyData(String str, Map<String, String> map) {
writeKeyData(str, map, false);
}
/* JADX WARN: Not initialized variable reg: 1, insn: 0x0031: MOVE (r6 I:??[OBJECT, ARRAY]) = (r1 I:??[OBJECT, ARRAY]), block:B:20:0x0031 */
public void writeRolloutState(String str, List<RolloutAssignment> list) {
BufferedWriter bufferedWriter;
Exception e4;
Closeable closeable;
File rolloutsStateForSession = getRolloutsStateForSession(str);
if (list.isEmpty()) {
safeDeleteCorruptFile(rolloutsStateForSession);
return;
}
Closeable closeable2 = null;
try {
try {
String rolloutsStateToJson = rolloutsStateToJson(list);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(rolloutsStateForSession), UTF_8));
try {
bufferedWriter.write(rolloutsStateToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close rollouts state file.");
} catch (Exception e5) {
e4 = e5;
Logger.getLogger().w("Error serializing rollouts state.", e4);
safeDeleteCorruptFile(rolloutsStateForSession);
CommonUtils.closeOrLog(bufferedWriter, "Failed to close rollouts state file.");
}
} catch (Throwable th) {
th = th;
closeable2 = closeable;
CommonUtils.closeOrLog(closeable2, "Failed to close rollouts state file.");
throw th;
}
} catch (Exception e6) {
bufferedWriter = null;
e4 = e6;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(closeable2, "Failed to close rollouts state file.");
throw th;
}
}
public void writeUserData(String str, String str2) {
String userIdToJson;
BufferedWriter bufferedWriter;
File userDataFileForSession = getUserDataFileForSession(str);
BufferedWriter bufferedWriter2 = null;
try {
try {
userIdToJson = userIdToJson(str2);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(userDataFileForSession), UTF_8));
} catch (Exception e4) {
e = e4;
}
} catch (Throwable th) {
th = th;
}
try {
bufferedWriter.write(userIdToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close user metadata file.");
} catch (Exception e5) {
e = e5;
bufferedWriter2 = bufferedWriter;
Logger.getLogger().w("Error serializing user metadata.", e);
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close user metadata file.");
} catch (Throwable th2) {
th = th2;
bufferedWriter2 = bufferedWriter;
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close user metadata file.");
throw th;
}
}
/* JADX WARN: Multi-variable type inference failed */
public Map<String, String> readKeyData(String str, boolean z3) {
FileInputStream fileInputStream;
Exception e4;
File internalKeysFileForSession = z3 != 0 ? getInternalKeysFileForSession(str) : getKeysFileForSession(str);
if (internalKeysFileForSession.exists() && internalKeysFileForSession.length() != 0) {
Closeable closeable = null;
try {
try {
fileInputStream = new FileInputStream(internalKeysFileForSession);
try {
Map<String, String> jsonToKeysData = jsonToKeysData(CommonUtils.streamToString(fileInputStream));
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return jsonToKeysData;
} catch (Exception e5) {
e4 = e5;
Logger.getLogger().w("Error deserializing user metadata.", e4);
safeDeleteCorruptFile(internalKeysFileForSession);
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return Collections.EMPTY_MAP;
}
} catch (Throwable th) {
th = th;
closeable = z3;
CommonUtils.closeOrLog(closeable, "Failed to close user metadata file.");
throw th;
}
} catch (Exception e6) {
fileInputStream = null;
e4 = e6;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(closeable, "Failed to close user metadata file.");
throw th;
}
} else {
safeDeleteCorruptFile(internalKeysFileForSession);
return Collections.EMPTY_MAP;
}
}
public void writeKeyData(String str, Map<String, String> map, boolean z3) {
BufferedWriter bufferedWriter;
Exception e4;
File internalKeysFileForSession = z3 ? getInternalKeysFileForSession(str) : getKeysFileForSession(str);
BufferedWriter bufferedWriter2 = null;
try {
String keysDataToJson = keysDataToJson(map);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(internalKeysFileForSession), UTF_8));
try {
try {
bufferedWriter.write(keysDataToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close key/value metadata file.");
} catch (Exception e5) {
e4 = e5;
Logger.getLogger().w("Error serializing key/value metadata.", e4);
safeDeleteCorruptFile(internalKeysFileForSession);
CommonUtils.closeOrLog(bufferedWriter, "Failed to close key/value metadata file.");
}
} catch (Throwable th) {
th = th;
bufferedWriter2 = bufferedWriter;
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close key/value metadata file.");
throw th;
}
} catch (Exception e6) {
bufferedWriter = null;
e4 = e6;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close key/value metadata file.");
throw th;
}
}
}

View File

@@ -0,0 +1,430 @@
package com.google.firebase.crashlytics.internal.metadata;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import kotlin.UByte;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class QueueFile implements Closeable {
static final int HEADER_LENGTH = 16;
private static final int INITIAL_LENGTH = 4096;
private static final Logger LOGGER = Logger.getLogger(QueueFile.class.getName());
private final byte[] buffer;
private int elementCount;
int fileLength;
private Element first;
private Element last;
private final RandomAccessFile raf;
/* loaded from: classes3.dex */
public static class Element {
static final int HEADER_LENGTH = 4;
static final Element NULL = new Element(0, 0);
final int length;
final int position;
public Element(int i, int i4) {
this.position = i;
this.length = i4;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append("[position = ");
sb.append(this.position);
sb.append(", length = ");
return com.google.android.gms.measurement.internal.a.m(sb, this.length, "]");
}
}
/* loaded from: classes3.dex */
public final class ElementInputStream extends InputStream {
private int position;
private int remaining;
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i4) throws IOException {
QueueFile.nonNull(bArr, "buffer");
if ((i | i4) >= 0 && i4 <= bArr.length - i) {
int i5 = this.remaining;
if (i5 <= 0) {
return -1;
}
if (i4 > i5) {
i4 = i5;
}
QueueFile.this.ringRead(this.position, bArr, i, i4);
this.position = QueueFile.this.wrapPosition(this.position + i4);
this.remaining -= i4;
return i4;
}
throw new ArrayIndexOutOfBoundsException();
}
private ElementInputStream(Element element) {
this.position = QueueFile.this.wrapPosition(element.position + 4);
this.remaining = element.length;
}
@Override // java.io.InputStream
public int read() throws IOException {
if (this.remaining == 0) {
return -1;
}
QueueFile.this.raf.seek(this.position);
int read = QueueFile.this.raf.read();
this.position = QueueFile.this.wrapPosition(this.position + 1);
this.remaining--;
return read;
}
}
/* loaded from: classes3.dex */
public interface ElementReader {
void read(InputStream inputStream, int i) throws IOException;
}
public QueueFile(File file) throws IOException {
this.buffer = new byte[16];
if (!file.exists()) {
initialize(file);
}
this.raf = open(file);
readHeader();
}
private void expandIfNecessary(int i) throws IOException {
int i4 = i + 4;
int remainingBytes = remainingBytes();
if (remainingBytes >= i4) {
return;
}
int i5 = this.fileLength;
do {
remainingBytes += i5;
i5 <<= 1;
} while (remainingBytes < i4);
setLength(i5);
Element element = this.last;
int wrapPosition = wrapPosition(element.position + 4 + element.length);
if (wrapPosition < this.first.position) {
FileChannel channel = this.raf.getChannel();
channel.position(this.fileLength);
long j4 = wrapPosition - 4;
if (channel.transferTo(16L, j4, channel) != j4) {
throw new AssertionError("Copied insufficient number of bytes!");
}
}
int i6 = this.last.position;
int i7 = this.first.position;
if (i6 < i7) {
int i8 = (this.fileLength + i6) - 16;
writeHeader(i5, this.elementCount, i7, i8);
this.last = new Element(i8, this.last.length);
} else {
writeHeader(i5, this.elementCount, i7, i6);
}
this.fileLength = i5;
}
private static void initialize(File file) throws IOException {
File file2 = new File(file.getPath() + ".tmp");
RandomAccessFile open = open(file2);
try {
open.setLength(4096L);
open.seek(0L);
byte[] bArr = new byte[16];
writeInts(bArr, 4096, 0, 0, 0);
open.write(bArr);
open.close();
if (!file2.renameTo(file)) {
throw new IOException("Rename failed!");
}
} catch (Throwable th) {
open.close();
throw th;
}
}
/* JADX INFO: Access modifiers changed from: private */
public static <T> T nonNull(T t2, String str) {
if (t2 != null) {
return t2;
}
throw new NullPointerException(str);
}
private static RandomAccessFile open(File file) throws FileNotFoundException {
return new RandomAccessFile(file, "rwd");
}
private Element readElement(int i) throws IOException {
if (i == 0) {
return Element.NULL;
}
this.raf.seek(i);
return new Element(i, this.raf.readInt());
}
private void readHeader() throws IOException {
this.raf.seek(0L);
this.raf.readFully(this.buffer);
int readInt = readInt(this.buffer, 0);
this.fileLength = readInt;
if (readInt > this.raf.length()) {
throw new IOException("File is truncated. Expected length: " + this.fileLength + ", Actual length: " + this.raf.length());
}
this.elementCount = readInt(this.buffer, 4);
int readInt2 = readInt(this.buffer, 8);
int readInt3 = readInt(this.buffer, 12);
this.first = readElement(readInt2);
this.last = readElement(readInt3);
}
private static int readInt(byte[] bArr, int i) {
return ((bArr[i] & UByte.MAX_VALUE) << 24) + ((bArr[i + 1] & UByte.MAX_VALUE) << 16) + ((bArr[i + 2] & UByte.MAX_VALUE) << 8) + (bArr[i + 3] & UByte.MAX_VALUE);
}
private int remainingBytes() {
return this.fileLength - usedBytes();
}
/* JADX INFO: Access modifiers changed from: private */
public void ringRead(int i, byte[] bArr, int i4, int i5) throws IOException {
int wrapPosition = wrapPosition(i);
int i6 = wrapPosition + i5;
int i7 = this.fileLength;
if (i6 <= i7) {
this.raf.seek(wrapPosition);
this.raf.readFully(bArr, i4, i5);
return;
}
int i8 = i7 - wrapPosition;
this.raf.seek(wrapPosition);
this.raf.readFully(bArr, i4, i8);
this.raf.seek(16L);
this.raf.readFully(bArr, i4 + i8, i5 - i8);
}
private void ringWrite(int i, byte[] bArr, int i4, int i5) throws IOException {
int wrapPosition = wrapPosition(i);
int i6 = wrapPosition + i5;
int i7 = this.fileLength;
if (i6 <= i7) {
this.raf.seek(wrapPosition);
this.raf.write(bArr, i4, i5);
return;
}
int i8 = i7 - wrapPosition;
this.raf.seek(wrapPosition);
this.raf.write(bArr, i4, i8);
this.raf.seek(16L);
this.raf.write(bArr, i4 + i8, i5 - i8);
}
private void setLength(int i) throws IOException {
this.raf.setLength(i);
this.raf.getChannel().force(true);
}
/* JADX INFO: Access modifiers changed from: private */
public int wrapPosition(int i) {
int i4 = this.fileLength;
return i < i4 ? i : (i + 16) - i4;
}
private void writeHeader(int i, int i4, int i5, int i6) throws IOException {
writeInts(this.buffer, i, i4, i5, i6);
this.raf.seek(0L);
this.raf.write(this.buffer);
}
private static void writeInt(byte[] bArr, int i, int i4) {
bArr[i] = (byte) (i4 >> 24);
bArr[i + 1] = (byte) (i4 >> 16);
bArr[i + 2] = (byte) (i4 >> 8);
bArr[i + 3] = (byte) i4;
}
private static void writeInts(byte[] bArr, int... iArr) {
int i = 0;
for (int i4 : iArr) {
writeInt(bArr, i, i4);
i += 4;
}
}
public void add(byte[] bArr) throws IOException {
add(bArr, 0, bArr.length);
}
public synchronized void clear() throws IOException {
try {
writeHeader(4096, 0, 0, 0);
this.elementCount = 0;
Element element = Element.NULL;
this.first = element;
this.last = element;
if (this.fileLength > 4096) {
setLength(4096);
}
this.fileLength = 4096;
} catch (Throwable th) {
throw th;
}
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public synchronized void close() throws IOException {
this.raf.close();
}
public synchronized void forEach(ElementReader elementReader) throws IOException {
int i = this.first.position;
for (int i4 = 0; i4 < this.elementCount; i4++) {
Element readElement = readElement(i);
elementReader.read(new ElementInputStream(readElement), readElement.length);
i = wrapPosition(readElement.position + 4 + readElement.length);
}
}
public boolean hasSpaceFor(int i, int i4) {
return (usedBytes() + 4) + i <= i4;
}
public synchronized boolean isEmpty() {
return this.elementCount == 0;
}
public synchronized byte[] peek() throws IOException {
if (isEmpty()) {
return null;
}
Element element = this.first;
int i = element.length;
byte[] bArr = new byte[i];
ringRead(element.position + 4, bArr, 0, i);
return bArr;
}
public synchronized void remove() throws IOException {
try {
if (isEmpty()) {
throw new NoSuchElementException();
}
if (this.elementCount == 1) {
clear();
} else {
Element element = this.first;
int wrapPosition = wrapPosition(element.position + 4 + element.length);
ringRead(wrapPosition, this.buffer, 0, 4);
int readInt = readInt(this.buffer, 0);
writeHeader(this.fileLength, this.elementCount - 1, wrapPosition, this.last.position);
this.elementCount--;
this.first = new Element(wrapPosition, readInt);
}
} catch (Throwable th) {
throw th;
}
}
public synchronized int size() {
return this.elementCount;
}
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append("[fileLength=");
sb.append(this.fileLength);
sb.append(", size=");
sb.append(this.elementCount);
sb.append(", first=");
sb.append(this.first);
sb.append(", last=");
sb.append(this.last);
sb.append(", element lengths=[");
try {
forEach(new ElementReader() { // from class: com.google.firebase.crashlytics.internal.metadata.QueueFile.1
boolean first = true;
@Override // com.google.firebase.crashlytics.internal.metadata.QueueFile.ElementReader
public void read(InputStream inputStream, int i) throws IOException {
if (this.first) {
this.first = false;
} else {
sb.append(", ");
}
sb.append(i);
}
});
} catch (IOException e4) {
LOGGER.log(Level.WARNING, "read error", (Throwable) e4);
}
sb.append("]]");
return sb.toString();
}
public int usedBytes() {
if (this.elementCount == 0) {
return 16;
}
Element element = this.last;
int i = element.position;
int i4 = this.first.position;
return i >= i4 ? (i - i4) + 4 + element.length + 16 : (((i + 4) + element.length) + this.fileLength) - i4;
}
public synchronized void add(byte[] bArr, int i, int i4) throws IOException {
int wrapPosition;
try {
nonNull(bArr, "buffer");
if ((i | i4) >= 0 && i4 <= bArr.length - i) {
expandIfNecessary(i4);
boolean isEmpty = isEmpty();
if (isEmpty) {
wrapPosition = 16;
} else {
Element element = this.last;
wrapPosition = wrapPosition(element.position + 4 + element.length);
}
Element element2 = new Element(wrapPosition, i4);
writeInt(this.buffer, 0, i4);
ringWrite(element2.position, this.buffer, 0, 4);
ringWrite(element2.position + 4, bArr, i, i4);
writeHeader(this.fileLength, this.elementCount + 1, isEmpty ? element2.position : this.first.position, element2.position);
this.last = element2;
this.elementCount++;
if (isEmpty) {
this.first = element2;
}
} else {
throw new IndexOutOfBoundsException();
}
} catch (Throwable th) {
throw th;
}
}
public QueueFile(RandomAccessFile randomAccessFile) throws IOException {
this.buffer = new byte[16];
this.raf = randomAccessFile;
readHeader();
}
public synchronized void peek(ElementReader elementReader) throws IOException {
if (this.elementCount > 0) {
elementReader.read(new ElementInputStream(this.first), this.first.length);
}
}
}

View File

@@ -0,0 +1,134 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import com.google.firebase.crashlytics.internal.metadata.QueueFile;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Locale;
/* loaded from: classes3.dex */
class QueueFileLogStore implements FileLogStore {
private static final Charset UTF_8 = Charset.forName("UTF-8");
private QueueFile logFile;
private final int maxLogSize;
private final File workingFile;
/* loaded from: classes3.dex */
public static class LogBytes {
public final byte[] bytes;
public final int offset;
public LogBytes(byte[] bArr, int i) {
this.bytes = bArr;
this.offset = i;
}
}
public QueueFileLogStore(File file, int i) {
this.workingFile = file;
this.maxLogSize = i;
}
private void doWriteToLog(long j4, String str) {
if (this.logFile == null) {
return;
}
if (str == null) {
str = "null";
}
try {
int i = this.maxLogSize / 4;
if (str.length() > i) {
str = "..." + str.substring(str.length() - i);
}
this.logFile.add(String.format(Locale.US, "%d %s%n", Long.valueOf(j4), str.replaceAll("\r", " ").replaceAll("\n", " ")).getBytes(UTF_8));
while (!this.logFile.isEmpty() && this.logFile.usedBytes() > this.maxLogSize) {
this.logFile.remove();
}
} catch (IOException e4) {
Logger.getLogger().e("There was a problem writing to the Crashlytics log.", e4);
}
}
private LogBytes getLogBytes() {
if (!this.workingFile.exists()) {
return null;
}
openLogFile();
QueueFile queueFile = this.logFile;
if (queueFile == null) {
return null;
}
final int[] iArr = {0};
final byte[] bArr = new byte[queueFile.usedBytes()];
try {
this.logFile.forEach(new QueueFile.ElementReader() { // from class: com.google.firebase.crashlytics.internal.metadata.QueueFileLogStore.1
@Override // com.google.firebase.crashlytics.internal.metadata.QueueFile.ElementReader
public void read(InputStream inputStream, int i) throws IOException {
try {
inputStream.read(bArr, iArr[0], i);
int[] iArr2 = iArr;
iArr2[0] = iArr2[0] + i;
} finally {
inputStream.close();
}
}
});
} catch (IOException e4) {
Logger.getLogger().e("A problem occurred while reading the Crashlytics log file.", e4);
}
return new LogBytes(bArr, iArr[0]);
}
private void openLogFile() {
if (this.logFile == null) {
try {
this.logFile = new QueueFile(this.workingFile);
} catch (IOException e4) {
Logger.getLogger().e("Could not open log file: " + this.workingFile, e4);
}
}
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void closeLogFile() {
CommonUtils.closeOrLog(this.logFile, "There was a problem closing the Crashlytics log file.");
this.logFile = null;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void deleteLogFile() {
closeLogFile();
this.workingFile.delete();
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public byte[] getLogAsBytes() {
LogBytes logBytes = getLogBytes();
if (logBytes == null) {
return null;
}
int i = logBytes.offset;
byte[] bArr = new byte[i];
System.arraycopy(logBytes.bytes, 0, bArr, 0, i);
return bArr;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public String getLogAsString() {
byte[] logAsBytes = getLogAsBytes();
if (logAsBytes != null) {
return new String(logAsBytes, UTF_8);
}
return null;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void writeToLog(long j4, String str) {
openLogFile();
doWriteToLog(j4, str);
}
}

View File

@@ -0,0 +1,46 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.auto.value.AutoValue;
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport;
import com.google.firebase.encoders.DataEncoder;
import com.google.firebase.encoders.annotations.Encodable;
import com.google.firebase.encoders.json.JsonDataEncoderBuilder;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import org.json.JSONException;
import org.json.JSONObject;
@AutoValue
@Encodable
/* loaded from: classes3.dex */
public abstract class RolloutAssignment {
private static final int MAX_PARAMETER_VALUE_LENGTH = 256;
public static final DataEncoder ROLLOUT_ASSIGNMENT_JSON_ENCODER = new JsonDataEncoderBuilder().configureWith(AutoRolloutAssignmentEncoder.CONFIG).build();
public static RolloutAssignment create(String str, String str2, String str3, String str4, long j4) {
return new AutoValue_RolloutAssignment(str, str2, validate(str3), str4, j4);
}
private static String validate(String str) {
return str.length() > MAX_PARAMETER_VALUE_LENGTH ? str.substring(0, MAX_PARAMETER_VALUE_LENGTH) : str;
}
public abstract String getParameterKey();
public abstract String getParameterValue();
public abstract String getRolloutId();
public abstract long getTemplateVersion();
public abstract String getVariantId();
public CrashlyticsReport.Session.Event.RolloutAssignment toReportProto() {
return CrashlyticsReport.Session.Event.RolloutAssignment.builder().setRolloutVariant(CrashlyticsReport.Session.Event.RolloutAssignment.RolloutVariant.builder().setVariantId(getVariantId()).setRolloutId(getRolloutId()).build()).setParameterKey(getParameterKey()).setParameterValue(getParameterValue()).setTemplateVersion(getTemplateVersion()).build();
}
public static RolloutAssignment create(String str) throws JSONException {
JSONObject jSONObject = new JSONObject(str);
return create(jSONObject.getString(ConfigContainer.ROLLOUT_METADATA_ID), jSONObject.getString("parameterKey"), jSONObject.getString("parameterValue"), jSONObject.getString("variantId"), jSONObject.getLong(RemoteConfigConstants.ResponseFieldKey.TEMPLATE_VERSION_NUMBER));
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes3.dex */
public class RolloutAssignmentList {
static final String ROLLOUTS_STATE = "rolloutsState";
private final int maxEntries;
private final List<RolloutAssignment> rolloutsState = new ArrayList();
public RolloutAssignmentList(int i) {
this.maxEntries = i;
}
public List<CrashlyticsReport.Session.Event.RolloutAssignment> getReportRolloutsState() {
List<RolloutAssignment> rolloutAssignmentList = getRolloutAssignmentList();
ArrayList arrayList = new ArrayList();
for (int i = 0; i < rolloutAssignmentList.size(); i++) {
arrayList.add(rolloutAssignmentList.get(i).toReportProto());
}
return arrayList;
}
public synchronized List<RolloutAssignment> getRolloutAssignmentList() {
return Collections.unmodifiableList(new ArrayList(this.rolloutsState));
}
public synchronized boolean updateRolloutAssignmentList(List<RolloutAssignment> list) {
this.rolloutsState.clear();
if (list.size() <= this.maxEntries) {
return this.rolloutsState.addAll(list);
}
Logger.getLogger().w("Ignored 0 entries when adding rollout assignments. Maximum allowable: " + this.maxEntries);
return this.rolloutsState.addAll(list.subList(0, this.maxEntries));
}
}

View File

@@ -0,0 +1,238 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import com.google.firebase.crashlytics.internal.common.CrashlyticsBackgroundWorker;
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport;
import com.google.firebase.crashlytics.internal.persistence.FileStore;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicMarkableReference;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes3.dex */
public class UserMetadata {
public static final String INTERNAL_KEYDATA_FILENAME = "internal-keys";
public static final String KEYDATA_FILENAME = "keys";
public static final int MAX_ATTRIBUTES = 64;
public static final int MAX_ATTRIBUTE_SIZE = 1024;
public static final int MAX_INTERNAL_KEY_SIZE = 8192;
public static final int MAX_ROLLOUT_ASSIGNMENTS = 128;
public static final String ROLLOUTS_STATE_FILENAME = "rollouts-state";
public static final String USERDATA_FILENAME = "user-data";
private final CrashlyticsBackgroundWorker backgroundWorker;
private final MetaDataStore metaDataStore;
private String sessionIdentifier;
private final SerializeableKeysMap customKeys = new SerializeableKeysMap(false);
private final SerializeableKeysMap internalKeys = new SerializeableKeysMap(true);
private final RolloutAssignmentList rolloutsState = new RolloutAssignmentList(128);
private final AtomicMarkableReference<String> userId = new AtomicMarkableReference<>(null, false);
/* loaded from: classes3.dex */
public class SerializeableKeysMap {
private final boolean isInternal;
final AtomicMarkableReference<KeysMap> map;
private final AtomicReference<Callable<Void>> queuedSerializer = new AtomicReference<>(null);
public SerializeableKeysMap(boolean z3) {
this.isInternal = z3;
this.map = new AtomicMarkableReference<>(new KeysMap(64, z3 ? 8192 : 1024), false);
}
public /* synthetic */ Void lambda$scheduleSerializationTaskIfNeeded$0() throws Exception {
this.queuedSerializer.set(null);
serializeIfMarked();
return null;
}
private void scheduleSerializationTaskIfNeeded() {
b bVar = new b(this, 0);
AtomicReference<Callable<Void>> atomicReference = this.queuedSerializer;
while (!atomicReference.compareAndSet(null, bVar)) {
if (atomicReference.get() != null) {
return;
}
}
UserMetadata.this.backgroundWorker.submit(bVar);
}
private void serializeIfMarked() {
Map<String, String> map;
synchronized (this) {
try {
if (this.map.isMarked()) {
map = this.map.getReference().getKeys();
AtomicMarkableReference<KeysMap> atomicMarkableReference = this.map;
atomicMarkableReference.set(atomicMarkableReference.getReference(), false);
} else {
map = null;
}
} catch (Throwable th) {
throw th;
}
}
if (map != null) {
UserMetadata.this.metaDataStore.writeKeyData(UserMetadata.this.sessionIdentifier, map, this.isInternal);
}
}
public Map<String, String> getKeys() {
return this.map.getReference().getKeys();
}
public boolean setKey(String str, String str2) {
synchronized (this) {
try {
if (!this.map.getReference().setKey(str, str2)) {
return false;
}
AtomicMarkableReference<KeysMap> atomicMarkableReference = this.map;
atomicMarkableReference.set(atomicMarkableReference.getReference(), true);
scheduleSerializationTaskIfNeeded();
return true;
} catch (Throwable th) {
throw th;
}
}
}
public void setKeys(Map<String, String> map) {
synchronized (this) {
this.map.getReference().setKeys(map);
AtomicMarkableReference<KeysMap> atomicMarkableReference = this.map;
atomicMarkableReference.set(atomicMarkableReference.getReference(), true);
}
scheduleSerializationTaskIfNeeded();
}
}
public UserMetadata(String str, FileStore fileStore, CrashlyticsBackgroundWorker crashlyticsBackgroundWorker) {
this.sessionIdentifier = str;
this.metaDataStore = new MetaDataStore(fileStore);
this.backgroundWorker = crashlyticsBackgroundWorker;
}
public /* synthetic */ Object lambda$setUserId$0() throws Exception {
serializeUserDataIfNeeded();
return null;
}
public /* synthetic */ Object lambda$updateRolloutsState$1(List list) throws Exception {
this.metaDataStore.writeRolloutState(this.sessionIdentifier, list);
return null;
}
public static UserMetadata loadFromExistingSession(String str, FileStore fileStore, CrashlyticsBackgroundWorker crashlyticsBackgroundWorker) {
MetaDataStore metaDataStore = new MetaDataStore(fileStore);
UserMetadata userMetadata = new UserMetadata(str, fileStore, crashlyticsBackgroundWorker);
userMetadata.customKeys.map.getReference().setKeys(metaDataStore.readKeyData(str, false));
userMetadata.internalKeys.map.getReference().setKeys(metaDataStore.readKeyData(str, true));
userMetadata.userId.set(metaDataStore.readUserId(str), false);
userMetadata.rolloutsState.updateRolloutAssignmentList(metaDataStore.readRolloutsState(str));
return userMetadata;
}
public static String readUserId(String str, FileStore fileStore) {
return new MetaDataStore(fileStore).readUserId(str);
}
private void serializeUserDataIfNeeded() {
boolean z3;
String str;
synchronized (this.userId) {
try {
z3 = false;
if (this.userId.isMarked()) {
str = getUserId();
this.userId.set(str, false);
z3 = true;
} else {
str = null;
}
} catch (Throwable th) {
throw th;
}
}
if (z3) {
this.metaDataStore.writeUserData(this.sessionIdentifier, str);
}
}
public Map<String, String> getCustomKeys() {
return this.customKeys.getKeys();
}
public Map<String, String> getInternalKeys() {
return this.internalKeys.getKeys();
}
public List<CrashlyticsReport.Session.Event.RolloutAssignment> getRolloutsState() {
return this.rolloutsState.getReportRolloutsState();
}
public String getUserId() {
return this.userId.getReference();
}
public boolean setCustomKey(String str, String str2) {
return this.customKeys.setKey(str, str2);
}
public void setCustomKeys(Map<String, String> map) {
this.customKeys.setKeys(map);
}
public boolean setInternalKey(String str, String str2) {
return this.internalKeys.setKey(str, str2);
}
public void setNewSession(String str) {
synchronized (this.sessionIdentifier) {
try {
this.sessionIdentifier = str;
Map<String, String> keys = this.customKeys.getKeys();
List<RolloutAssignment> rolloutAssignmentList = this.rolloutsState.getRolloutAssignmentList();
if (getUserId() != null) {
this.metaDataStore.writeUserData(str, getUserId());
}
if (!keys.isEmpty()) {
this.metaDataStore.writeKeyData(str, keys);
}
if (!rolloutAssignmentList.isEmpty()) {
this.metaDataStore.writeRolloutState(str, rolloutAssignmentList);
}
} catch (Throwable th) {
throw th;
}
}
}
public void setUserId(String str) {
String sanitizeString = KeysMap.sanitizeString(str, 1024);
synchronized (this.userId) {
try {
if (CommonUtils.nullSafeEquals(sanitizeString, this.userId.getReference())) {
return;
}
this.userId.set(sanitizeString, true);
this.backgroundWorker.submit(new b(this, 1));
} catch (Throwable th) {
throw th;
}
}
}
public boolean updateRolloutsState(List<RolloutAssignment> list) {
synchronized (this.rolloutsState) {
try {
if (!this.rolloutsState.updateRolloutAssignmentList(list)) {
return false;
}
this.backgroundWorker.submit(new a(0, this, this.rolloutsState.getRolloutAssignmentList()));
return true;
} catch (Throwable th) {
throw th;
}
}
}
}

View File

@@ -0,0 +1,43 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
import com.google.firebase.remoteconfig.internal.ConfigCacheClient;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import java.util.List;
import java.util.concurrent.Callable;
/* loaded from: classes3.dex */
public final /* synthetic */ class a implements Callable {
/* renamed from: a, reason: collision with root package name */
public final /* synthetic */ int f5972a;
/* renamed from: b, reason: collision with root package name */
public final /* synthetic */ Object f5973b;
/* renamed from: c, reason: collision with root package name */
public final /* synthetic */ Object f5974c;
public /* synthetic */ a(int i, Object obj, Object obj2) {
this.f5972a = i;
this.f5973b = obj;
this.f5974c = obj2;
}
@Override // java.util.concurrent.Callable
public final Object call() {
Object lambda$updateRolloutsState$1;
Void lambda$setConfigSettingsAsync$5;
switch (this.f5972a) {
case 0:
lambda$updateRolloutsState$1 = ((UserMetadata) this.f5973b).lambda$updateRolloutsState$1((List) this.f5974c);
return lambda$updateRolloutsState$1;
case 1:
lambda$setConfigSettingsAsync$5 = ((FirebaseRemoteConfig) this.f5973b).lambda$setConfigSettingsAsync$5((FirebaseRemoteConfigSettings) this.f5974c);
return lambda$setConfigSettingsAsync$5;
default:
return ConfigCacheClient.b((ConfigCacheClient) this.f5973b, (ConfigContainer) this.f5974c);
}
}
}

View File

@@ -0,0 +1,31 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
import java.util.concurrent.Callable;
/* loaded from: classes3.dex */
public final /* synthetic */ class b implements Callable {
/* renamed from: a, reason: collision with root package name */
public final /* synthetic */ int f5975a;
/* renamed from: b, reason: collision with root package name */
public final /* synthetic */ Object f5976b;
public /* synthetic */ b(Object obj, int i) {
this.f5975a = i;
this.f5976b = obj;
}
@Override // java.util.concurrent.Callable
public final Object call() {
int i = this.f5975a;
Object obj = this.f5976b;
switch (i) {
case 0:
return UserMetadata.SerializeableKeysMap.a((UserMetadata.SerializeableKeysMap) obj);
default:
return UserMetadata.b((UserMetadata) obj);
}
}
}