Add decompiled APK source code (JADX)

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

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

View File

@@ -0,0 +1,37 @@
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;
/* loaded from: classes3.dex */
public final class AutoRolloutAssignmentEncoder implements Configurator {
public static final Configurator CONFIG = new 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);
}
public static final class RolloutAssignmentEncoder implements ObjectEncoder {
public static final RolloutAssignmentEncoder INSTANCE = new RolloutAssignmentEncoder();
public static final FieldDescriptor ROLLOUTID_DESCRIPTOR = FieldDescriptor.of("rolloutId");
public static final FieldDescriptor PARAMETERKEY_DESCRIPTOR = FieldDescriptor.of("parameterKey");
public static final FieldDescriptor PARAMETERVALUE_DESCRIPTOR = FieldDescriptor.of("parameterValue");
public static final FieldDescriptor VARIANTID_DESCRIPTOR = FieldDescriptor.of("variantId");
public static final FieldDescriptor TEMPLATEVERSION_DESCRIPTOR = FieldDescriptor.of("templateVersion");
@Override // com.google.firebase.encoders.ObjectEncoder
public void encode(RolloutAssignment rolloutAssignment, ObjectEncoderContext objectEncoderContext) {
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());
}
}
}

View File

@@ -0,0 +1,76 @@
package com.google.firebase.crashlytics.internal.metadata;
/* loaded from: classes3.dex */
public final class AutoValue_RolloutAssignment extends RolloutAssignment {
public final String parameterKey;
public final String parameterValue;
public final String rolloutId;
public final long templateVersion;
public final String variantId;
@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 AutoValue_RolloutAssignment(String str, String str2, String str3, String str4, long j) {
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 = j;
}
public String toString() {
return "RolloutAssignment{rolloutId=" + this.rolloutId + ", parameterKey=" + this.parameterKey + ", parameterValue=" + this.parameterValue + ", variantId=" + this.variantId + ", templateVersion=" + this.templateVersion + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof RolloutAssignment)) {
return false;
}
RolloutAssignment rolloutAssignment = (RolloutAssignment) obj;
return this.rolloutId.equals(rolloutAssignment.getRolloutId()) && this.parameterKey.equals(rolloutAssignment.getParameterKey()) && this.parameterValue.equals(rolloutAssignment.getParameterValue()) && this.variantId.equals(rolloutAssignment.getVariantId()) && this.templateVersion == rolloutAssignment.getTemplateVersion();
}
public int hashCode() {
int hashCode = (((((((this.rolloutId.hashCode() ^ 1000003) * 1000003) ^ this.parameterKey.hashCode()) * 1000003) ^ this.parameterValue.hashCode()) * 1000003) ^ this.variantId.hashCode()) * 1000003;
long j = this.templateVersion;
return hashCode ^ ((int) (j ^ (j >>> 32)));
}
}

View File

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

View File

@@ -0,0 +1,75 @@
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;
/* loaded from: classes3.dex */
public class KeysMap {
public final Map keys = new HashMap();
public final int maxEntries;
public final int maxEntryLength;
public KeysMap(int i, int i2) {
this.maxEntries = i;
this.maxEntryLength = i2;
}
public synchronized Map 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((String) this.keys.get(sanitizeKey), sanitizeString)) {
return false;
}
Map map = this.keys;
if (str2 == null) {
sanitizeString = "";
}
map.put(sanitizeKey, sanitizeString);
return true;
}
public synchronized void setKeys(Map map) {
try {
int i = 0;
for (Map.Entry entry : map.entrySet()) {
String sanitizeKey = sanitizeKey((String) entry.getKey());
if (this.keys.size() >= this.maxEntries && !this.keys.containsKey(sanitizeKey)) {
i++;
}
String str = (String) entry.getValue();
this.keys.put(sanitizeKey, str == null ? "" : sanitizeString(str, this.maxEntryLength));
}
if (i > 0) {
Logger.getLogger().w("Ignored " + i + " entries when adding custom keys. Maximum allowable: " + this.maxEntries);
}
} catch (Throwable th) {
throw th;
}
}
public final String sanitizeKey(String str) {
if (str == null) {
throw new IllegalArgumentException("Custom attribute key must not be null.");
}
return sanitizeString(str, this.maxEntryLength);
}
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;
}
}

View File

@@ -0,0 +1,81 @@
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 {
public static final NoopLogStore NOOP_LOG_STORE = new NoopLogStore();
public FileLogStore currentLog;
public final FileStore fileStore;
public LogFileManager(FileStore fileStore) {
this.fileStore = fileStore;
this.currentLog = NOOP_LOG_STORE;
}
public LogFileManager(FileStore fileStore, String str) {
this(fileStore);
setCurrentSession(str);
}
public final void setCurrentSession(String str) {
this.currentLog.closeLogFile();
this.currentLog = NOOP_LOG_STORE;
if (str == null) {
return;
}
setLogFile(getWorkingFileForSession(str), 65536);
}
public void writeToLog(long j, String str) {
this.currentLog.writeToLog(j, str);
}
public byte[] getBytesForLog() {
return this.currentLog.getLogAsBytes();
}
public String getLogString() {
return this.currentLog.getLogAsString();
}
public void clearLog() {
this.currentLog.deleteLogFile();
}
public void setLogFile(File file, int i) {
this.currentLog = new QueueFileLogStore(file, i);
}
public final File getWorkingFileForSession(String str) {
return this.fileStore.getSessionFile(str, "userlog");
}
public static final class NoopLogStore implements FileLogStore {
@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 j, String str) {
}
public NoopLogStore() {
}
}
}

View File

@@ -0,0 +1,344 @@
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;
/* loaded from: classes3.dex */
public class MetaDataStore {
public static final Charset UTF_8 = Charset.forName("UTF-8");
public final FileStore fileStore;
public MetaDataStore(FileStore fileStore) {
this.fileStore = fileStore;
}
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 e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
bufferedWriter.write(userIdToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close user metadata file.");
} catch (Exception e2) {
e = e2;
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;
}
}
public String readUserId(String str) {
FileInputStream fileInputStream;
File userDataFileForSession = getUserDataFileForSession(str);
FileInputStream fileInputStream2 = null;
if (!userDataFileForSession.exists() || userDataFileForSession.length() == 0) {
Logger.getLogger().d("No userId set for session " + str);
safeDeleteCorruptFile(userDataFileForSession);
return null;
}
try {
fileInputStream = new FileInputStream(userDataFileForSession);
try {
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 e) {
e = e;
Logger.getLogger().w("Error deserializing user metadata.", e);
safeDeleteCorruptFile(userDataFileForSession);
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return null;
}
} catch (Throwable th) {
th = th;
fileInputStream2 = fileInputStream;
CommonUtils.closeOrLog(fileInputStream2, "Failed to close user metadata file.");
throw th;
}
} catch (Exception e2) {
e = e2;
fileInputStream = null;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(fileInputStream2, "Failed to close user metadata file.");
throw th;
}
}
public void writeKeyData(String str, Map map) {
writeKeyData(str, map, false);
}
public void writeKeyData(String str, Map map, boolean z) {
String keysDataToJson;
BufferedWriter bufferedWriter;
File internalKeysFileForSession = z ? getInternalKeysFileForSession(str) : getKeysFileForSession(str);
BufferedWriter bufferedWriter2 = null;
try {
try {
keysDataToJson = keysDataToJson(map);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(internalKeysFileForSession), UTF_8));
} catch (Throwable th) {
th = th;
}
} catch (Exception e) {
e = e;
}
try {
bufferedWriter.write(keysDataToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close key/value metadata file.");
} catch (Exception e2) {
e = e2;
bufferedWriter2 = bufferedWriter;
Logger.getLogger().w("Error serializing key/value metadata.", e);
safeDeleteCorruptFile(internalKeysFileForSession);
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close key/value metadata file.");
} catch (Throwable th2) {
th = th2;
bufferedWriter2 = bufferedWriter;
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close key/value metadata file.");
throw th;
}
}
/* JADX WARN: Type inference failed for: r1v0, types: [long] */
public Map readKeyData(String str, boolean z) {
FileInputStream fileInputStream;
Exception e;
File internalKeysFileForSession = z ? getInternalKeysFileForSession(str) : getKeysFileForSession(str);
if (internalKeysFileForSession.exists()) {
?? length = internalKeysFileForSession.length();
if (length != 0) {
Closeable closeable = null;
try {
try {
fileInputStream = new FileInputStream(internalKeysFileForSession);
try {
Map jsonToKeysData = jsonToKeysData(CommonUtils.streamToString(fileInputStream));
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return jsonToKeysData;
} catch (Exception e2) {
e = e2;
Logger.getLogger().w("Error deserializing user metadata.", e);
safeDeleteCorruptFile(internalKeysFileForSession);
CommonUtils.closeOrLog(fileInputStream, "Failed to close user metadata file.");
return Collections.emptyMap();
}
} catch (Throwable th) {
th = th;
closeable = length;
CommonUtils.closeOrLog(closeable, "Failed to close user metadata file.");
throw th;
}
} catch (Exception e3) {
fileInputStream = null;
e = e3;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(closeable, "Failed to close user metadata file.");
throw th;
}
}
}
safeDeleteCorruptFile(internalKeysFileForSession);
return Collections.emptyMap();
}
public List readRolloutsState(String str) {
FileInputStream fileInputStream;
File rolloutsStateForSession = getRolloutsStateForSession(str);
if (!rolloutsStateForSession.exists() || rolloutsStateForSession.length() == 0) {
safeDeleteCorruptFile(rolloutsStateForSession);
return Collections.emptyList();
}
FileInputStream fileInputStream2 = null;
try {
try {
fileInputStream = new FileInputStream(rolloutsStateForSession);
} catch (Exception e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
List 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 e2) {
e = e2;
fileInputStream2 = fileInputStream;
Logger.getLogger().w("Error deserializing rollouts state.", e);
safeDeleteCorruptFile(rolloutsStateForSession);
CommonUtils.closeOrLog(fileInputStream2, "Failed to close rollouts state file.");
return Collections.emptyList();
} catch (Throwable th2) {
th = th2;
fileInputStream2 = fileInputStream;
CommonUtils.closeOrLog(fileInputStream2, "Failed to close rollouts state file.");
throw th;
}
}
public void writeRolloutState(String str, List list) {
String rolloutsStateToJson;
BufferedWriter bufferedWriter;
File rolloutsStateForSession = getRolloutsStateForSession(str);
if (list.isEmpty()) {
safeDeleteCorruptFile(rolloutsStateForSession);
return;
}
BufferedWriter bufferedWriter2 = null;
try {
try {
rolloutsStateToJson = rolloutsStateToJson(list);
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(rolloutsStateForSession), UTF_8));
} catch (Throwable th) {
th = th;
}
} catch (Exception e) {
e = e;
}
try {
bufferedWriter.write(rolloutsStateToJson);
bufferedWriter.flush();
CommonUtils.closeOrLog(bufferedWriter, "Failed to close rollouts state file.");
} catch (Exception e2) {
e = e2;
bufferedWriter2 = bufferedWriter;
Logger.getLogger().w("Error serializing rollouts state.", e);
safeDeleteCorruptFile(rolloutsStateForSession);
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close rollouts state file.");
} catch (Throwable th2) {
th = th2;
bufferedWriter2 = bufferedWriter;
CommonUtils.closeOrLog(bufferedWriter2, "Failed to close rollouts state file.");
throw th;
}
}
public File getUserDataFileForSession(String str) {
return this.fileStore.getSessionFile(str, "user-data");
}
public File getKeysFileForSession(String str) {
return this.fileStore.getSessionFile(str, "keys");
}
public File getInternalKeysFileForSession(String str) {
return this.fileStore.getSessionFile(str, "internal-keys");
}
public File getRolloutsStateForSession(String str) {
return this.fileStore.getSessionFile(str, "rollouts-state");
}
public final String jsonToUserId(String str) {
return valueOrNull(new JSONObject(str), "userId");
}
public static String userIdToJson(String str) {
return new JSONObject(str) { // from class: com.google.firebase.crashlytics.internal.metadata.MetaDataStore.1
public final /* synthetic */ String val$userId;
{
this.val$userId = str;
put("userId", str);
}
}.toString();
}
public static Map jsonToKeysData(String str) {
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;
}
public static String keysDataToJson(Map map) {
return new JSONObject(map).toString();
}
public static List jsonToRolloutsState(String str) {
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 e) {
Logger.getLogger().w("Failed de-serializing rollouts state. " + string, e);
}
}
return arrayList;
}
public static String rolloutsStateToJson(List 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 e) {
Logger.getLogger().w("Exception parsing rollout assignment!", e);
}
}
hashMap.put("rolloutsState", jSONArray);
return new JSONObject(hashMap).toString();
}
public static String valueOrNull(JSONObject jSONObject, String str) {
if (jSONObject.isNull(str)) {
return null;
}
return jSONObject.optString(str, null);
}
public static void safeDeleteCorruptFile(File file) {
if (file.exists() && file.delete()) {
Logger.getLogger().i("Deleted corrupt file: " + file.getAbsolutePath());
}
}
}

View File

@@ -0,0 +1,386 @@
package com.google.firebase.crashlytics.internal.metadata;
import android.support.v4.media.session.PlaybackStateCompat;
import com.ironsource.v8;
import java.io.Closeable;
import java.io.File;
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;
/* loaded from: classes3.dex */
public class QueueFile implements Closeable {
public static final Logger LOGGER = Logger.getLogger(QueueFile.class.getName());
public final byte[] buffer = new byte[16];
public int elementCount;
public int fileLength;
public Element first;
public Element last;
public final RandomAccessFile raf;
public interface ElementReader {
void read(InputStream inputStream, int i);
}
public final int wrapPosition(int i) {
int i2 = this.fileLength;
return i < i2 ? i : (i + 16) - i2;
}
public QueueFile(File file) {
if (!file.exists()) {
initialize(file);
}
this.raf = open(file);
readHeader();
}
public static void writeInt(byte[] bArr, int i, int i2) {
bArr[i] = (byte) (i2 >> 24);
bArr[i + 1] = (byte) (i2 >> 16);
bArr[i + 2] = (byte) (i2 >> 8);
bArr[i + 3] = (byte) i2;
}
public static void writeInts(byte[] bArr, int... iArr) {
int i = 0;
for (int i2 : iArr) {
writeInt(bArr, i, i2);
i += 4;
}
}
public static int readInt(byte[] bArr, int i) {
return ((bArr[i] & 255) << 24) + ((bArr[i + 1] & 255) << 16) + ((bArr[i + 2] & 255) << 8) + (bArr[i + 3] & 255);
}
public final void readHeader() {
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);
}
public final void writeHeader(int i, int i2, int i3, int i4) {
writeInts(this.buffer, i, i2, i3, i4);
this.raf.seek(0L);
this.raf.write(this.buffer);
}
public final Element readElement(int i) {
if (i == 0) {
return Element.NULL;
}
this.raf.seek(i);
return new Element(i, this.raf.readInt());
}
public static void initialize(File file) {
File file2 = new File(file.getPath() + ".tmp");
RandomAccessFile open = open(file2);
try {
open.setLength(PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM);
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;
}
}
public static RandomAccessFile open(File file) {
return new RandomAccessFile(file, "rwd");
}
public final void ringWrite(int i, byte[] bArr, int i2, int i3) {
int wrapPosition = wrapPosition(i);
int i4 = wrapPosition + i3;
int i5 = this.fileLength;
if (i4 <= i5) {
this.raf.seek(wrapPosition);
this.raf.write(bArr, i2, i3);
return;
}
int i6 = i5 - wrapPosition;
this.raf.seek(wrapPosition);
this.raf.write(bArr, i2, i6);
this.raf.seek(16L);
this.raf.write(bArr, i2 + i6, i3 - i6);
}
public final void ringRead(int i, byte[] bArr, int i2, int i3) {
int wrapPosition = wrapPosition(i);
int i4 = wrapPosition + i3;
int i5 = this.fileLength;
if (i4 <= i5) {
this.raf.seek(wrapPosition);
this.raf.readFully(bArr, i2, i3);
return;
}
int i6 = i5 - wrapPosition;
this.raf.seek(wrapPosition);
this.raf.readFully(bArr, i2, i6);
this.raf.seek(16L);
this.raf.readFully(bArr, i2 + i6, i3 - i6);
}
public void add(byte[] bArr) {
add(bArr, 0, bArr.length);
}
public synchronized void add(byte[] bArr, int i, int i2) {
int wrapPosition;
try {
nonNull(bArr, "buffer");
if ((i | i2) < 0 || i2 > bArr.length - i) {
throw new IndexOutOfBoundsException();
}
expandIfNecessary(i2);
boolean isEmpty = isEmpty();
if (isEmpty) {
wrapPosition = 16;
} else {
Element element = this.last;
wrapPosition = wrapPosition(element.position + 4 + element.length);
}
Element element2 = new Element(wrapPosition, i2);
writeInt(this.buffer, 0, i2);
ringWrite(element2.position, this.buffer, 0, 4);
ringWrite(element2.position + 4, bArr, i, i2);
writeHeader(this.fileLength, this.elementCount + 1, isEmpty ? element2.position : this.first.position, element2.position);
this.last = element2;
this.elementCount++;
if (isEmpty) {
this.first = element2;
}
} catch (Throwable th) {
throw th;
}
}
public int usedBytes() {
if (this.elementCount == 0) {
return 16;
}
Element element = this.last;
int i = element.position;
int i2 = this.first.position;
if (i >= i2) {
return (i - i2) + 4 + element.length + 16;
}
return (((i + 4) + element.length) + this.fileLength) - i2;
}
public final int remainingBytes() {
return this.fileLength - usedBytes();
}
public synchronized boolean isEmpty() {
return this.elementCount == 0;
}
public final void expandIfNecessary(int i) {
int i2 = i + 4;
int remainingBytes = remainingBytes();
if (remainingBytes >= i2) {
return;
}
int i3 = this.fileLength;
do {
remainingBytes += i3;
i3 <<= 1;
} while (remainingBytes < i2);
setLength(i3);
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 j = wrapPosition - 4;
if (channel.transferTo(16L, j, channel) != j) {
throw new AssertionError("Copied insufficient number of bytes!");
}
}
int i4 = this.last.position;
int i5 = this.first.position;
if (i4 < i5) {
int i6 = (this.fileLength + i4) - 16;
writeHeader(i3, this.elementCount, i5, i6);
this.last = new Element(i6, this.last.length);
} else {
writeHeader(i3, this.elementCount, i5, i4);
}
this.fileLength = i3;
}
public final void setLength(int i) {
this.raf.setLength(i);
this.raf.getChannel().force(true);
}
public synchronized void forEach(ElementReader elementReader) {
int i = this.first.position;
for (int i2 = 0; i2 < this.elementCount; i2++) {
Element readElement = readElement(i);
elementReader.read(new ElementInputStream(readElement), readElement.length);
i = wrapPosition(readElement.position + 4 + readElement.length);
}
}
public static Object nonNull(Object obj, String str) {
if (obj != null) {
return obj;
}
throw new NullPointerException(str);
}
public final class ElementInputStream extends InputStream {
public int position;
public int remaining;
public ElementInputStream(Element element) {
this.position = QueueFile.this.wrapPosition(element.position + 4);
this.remaining = element.length;
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) {
QueueFile.nonNull(bArr, "buffer");
if ((i | i2) < 0 || i2 > bArr.length - i) {
throw new ArrayIndexOutOfBoundsException();
}
int i3 = this.remaining;
if (i3 <= 0) {
return -1;
}
if (i2 > i3) {
i2 = i3;
}
QueueFile.this.ringRead(this.position, bArr, i, i2);
this.position = QueueFile.this.wrapPosition(this.position + i2);
this.remaining -= i2;
return i2;
}
@Override // java.io.InputStream
public int read() {
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;
}
}
public synchronized void remove() {
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 void clear() {
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() {
this.raf.close();
}
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append('[');
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
public boolean first = true;
@Override // com.google.firebase.crashlytics.internal.metadata.QueueFile.ElementReader
public void read(InputStream inputStream, int i) {
if (this.first) {
this.first = false;
} else {
sb.append(", ");
}
sb.append(i);
}
});
} catch (IOException e) {
LOGGER.log(Level.WARNING, "read error", (Throwable) e);
}
sb.append("]]");
return sb.toString();
}
public static class Element {
public static final Element NULL = new Element(0, 0);
public final int length;
public final int position;
public Element(int i, int i2) {
this.position = i;
this.length = i2;
}
public String toString() {
return getClass().getSimpleName() + "[position = " + this.position + ", length = " + this.length + v8.i.e;
}
}
}

View File

@@ -0,0 +1,133 @@
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 */
public class QueueFileLogStore implements FileLogStore {
public static final Charset UTF_8 = Charset.forName("UTF-8");
public QueueFile logFile;
public final int maxLogSize;
public final File workingFile;
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;
}
@Override // com.google.firebase.crashlytics.internal.metadata.FileLogStore
public void writeToLog(long j, String str) {
openLogFile();
doWriteToLog(j, str);
}
@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;
}
public final 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) {
try {
inputStream.read(bArr, iArr[0], i);
int[] iArr2 = iArr;
iArr2[0] = iArr2[0] + i;
} finally {
inputStream.close();
}
}
});
} catch (IOException e) {
Logger.getLogger().e("A problem occurred while reading the Crashlytics log file.", e);
}
return new LogBytes(bArr, iArr[0]);
}
@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();
}
public final void openLogFile() {
if (this.logFile == null) {
try {
this.logFile = new QueueFile(this.workingFile);
} catch (IOException e) {
Logger.getLogger().e("Could not open log file: " + this.workingFile, e);
}
}
}
public final void doWriteToLog(long j, 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(j), str.replaceAll("\r", " ").replaceAll("\n", " ")).getBytes(UTF_8));
while (!this.logFile.isEmpty() && this.logFile.usedBytes() > this.maxLogSize) {
this.logFile.remove();
}
} catch (IOException e) {
Logger.getLogger().e("There was a problem writing to the Crashlytics log.", e);
}
}
}

View File

@@ -0,0 +1,38 @@
package com.google.firebase.crashlytics.internal.metadata;
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport;
import com.google.firebase.encoders.DataEncoder;
import com.google.firebase.encoders.json.JsonDataEncoderBuilder;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public abstract class RolloutAssignment {
public static final DataEncoder ROLLOUT_ASSIGNMENT_JSON_ENCODER = new JsonDataEncoderBuilder().configureWith(AutoRolloutAssignmentEncoder.CONFIG).build();
public abstract String getParameterKey();
public abstract String getParameterValue();
public abstract String getRolloutId();
public abstract long getTemplateVersion();
public abstract String getVariantId();
public static RolloutAssignment create(String str, String str2, String str3, String str4, long j) {
return new AutoValue_RolloutAssignment(str, str2, validate(str3), str4, j);
}
public static RolloutAssignment create(String str) {
JSONObject jSONObject = new JSONObject(str);
return create(jSONObject.getString("rolloutId"), jSONObject.getString("parameterKey"), jSONObject.getString("parameterValue"), jSONObject.getString("variantId"), jSONObject.getLong("templateVersion"));
}
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 String validate(String str) {
return str.length() > 256 ? str.substring(0, 256) : str;
}
}

View File

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

View File

@@ -0,0 +1,235 @@
package com.google.firebase.crashlytics.internal.metadata;
import androidx.lifecycle.LifecycleKt$$ExternalSyntheticBackportWithForwarding0;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import com.google.firebase.crashlytics.internal.common.CrashlyticsBackgroundWorker;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
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 final CrashlyticsBackgroundWorker backgroundWorker;
public final MetaDataStore metaDataStore;
public String sessionIdentifier;
public final SerializeableKeysMap customKeys = new SerializeableKeysMap(false);
public final SerializeableKeysMap internalKeys = new SerializeableKeysMap(true);
public final RolloutAssignmentList rolloutsState = new RolloutAssignmentList(128);
public final AtomicMarkableReference userId = new AtomicMarkableReference(null, false);
public static String readUserId(String str, FileStore fileStore) {
return new MetaDataStore(fileStore).readUserId(str);
}
public static UserMetadata loadFromExistingSession(String str, FileStore fileStore, CrashlyticsBackgroundWorker crashlyticsBackgroundWorker) {
MetaDataStore metaDataStore = new MetaDataStore(fileStore);
UserMetadata userMetadata = new UserMetadata(str, fileStore, crashlyticsBackgroundWorker);
((KeysMap) userMetadata.customKeys.map.getReference()).setKeys(metaDataStore.readKeyData(str, false));
((KeysMap) 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 UserMetadata(String str, FileStore fileStore, CrashlyticsBackgroundWorker crashlyticsBackgroundWorker) {
this.sessionIdentifier = str;
this.metaDataStore = new MetaDataStore(fileStore);
this.backgroundWorker = crashlyticsBackgroundWorker;
}
public void setNewSession(String str) {
synchronized (this.sessionIdentifier) {
try {
this.sessionIdentifier = str;
Map keys = this.customKeys.getKeys();
List 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 String getUserId() {
return (String) this.userId.getReference();
}
public void setUserId(String str) {
String sanitizeString = KeysMap.sanitizeString(str, 1024);
synchronized (this.userId) {
try {
if (CommonUtils.nullSafeEquals(sanitizeString, (String) this.userId.getReference())) {
return;
}
this.userId.set(sanitizeString, true);
this.backgroundWorker.submit(new Callable() { // from class: com.google.firebase.crashlytics.internal.metadata.UserMetadata$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
Object lambda$setUserId$0;
lambda$setUserId$0 = UserMetadata.this.lambda$setUserId$0();
return lambda$setUserId$0;
}
});
} catch (Throwable th) {
throw th;
}
}
}
public final /* synthetic */ Object lambda$setUserId$0() {
serializeUserDataIfNeeded();
return null;
}
public Map getCustomKeys() {
return this.customKeys.getKeys();
}
public boolean setCustomKey(String str, String str2) {
return this.customKeys.setKey(str, str2);
}
public Map getInternalKeys() {
return this.internalKeys.getKeys();
}
public boolean setInternalKey(String str, String str2) {
return this.internalKeys.setKey(str, str2);
}
public List getRolloutsState() {
return this.rolloutsState.getReportRolloutsState();
}
public boolean updateRolloutsState(List list) {
synchronized (this.rolloutsState) {
try {
if (!this.rolloutsState.updateRolloutAssignmentList(list)) {
return false;
}
final List rolloutAssignmentList = this.rolloutsState.getRolloutAssignmentList();
this.backgroundWorker.submit(new Callable() { // from class: com.google.firebase.crashlytics.internal.metadata.UserMetadata$$ExternalSyntheticLambda1
@Override // java.util.concurrent.Callable
public final Object call() {
Object lambda$updateRolloutsState$1;
lambda$updateRolloutsState$1 = UserMetadata.this.lambda$updateRolloutsState$1(rolloutAssignmentList);
return lambda$updateRolloutsState$1;
}
});
return true;
} catch (Throwable th) {
throw th;
}
}
}
public final /* synthetic */ Object lambda$updateRolloutsState$1(List list) {
this.metaDataStore.writeRolloutState(this.sessionIdentifier, list);
return null;
}
public final void serializeUserDataIfNeeded() {
boolean z;
String str;
synchronized (this.userId) {
try {
z = false;
if (this.userId.isMarked()) {
str = getUserId();
this.userId.set(str, false);
z = true;
} else {
str = null;
}
} catch (Throwable th) {
throw th;
}
}
if (z) {
this.metaDataStore.writeUserData(this.sessionIdentifier, str);
}
}
public class SerializeableKeysMap {
public final boolean isInternal;
public final AtomicMarkableReference map;
public final AtomicReference queuedSerializer = new AtomicReference(null);
public SerializeableKeysMap(boolean z) {
this.isInternal = z;
this.map = new AtomicMarkableReference(new KeysMap(64, z ? 8192 : 1024), false);
}
public Map getKeys() {
return ((KeysMap) this.map.getReference()).getKeys();
}
public boolean setKey(String str, String str2) {
synchronized (this) {
try {
if (!((KeysMap) this.map.getReference()).setKey(str, str2)) {
return false;
}
AtomicMarkableReference atomicMarkableReference = this.map;
atomicMarkableReference.set((KeysMap) atomicMarkableReference.getReference(), true);
scheduleSerializationTaskIfNeeded();
return true;
} catch (Throwable th) {
throw th;
}
}
}
public final void scheduleSerializationTaskIfNeeded() {
Callable callable = new Callable() { // from class: com.google.firebase.crashlytics.internal.metadata.UserMetadata$SerializeableKeysMap$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
Void lambda$scheduleSerializationTaskIfNeeded$0;
lambda$scheduleSerializationTaskIfNeeded$0 = UserMetadata.SerializeableKeysMap.this.lambda$scheduleSerializationTaskIfNeeded$0();
return lambda$scheduleSerializationTaskIfNeeded$0;
}
};
if (LifecycleKt$$ExternalSyntheticBackportWithForwarding0.m(this.queuedSerializer, null, callable)) {
UserMetadata.this.backgroundWorker.submit(callable);
}
}
public final /* synthetic */ Void lambda$scheduleSerializationTaskIfNeeded$0() {
this.queuedSerializer.set(null);
serializeIfMarked();
return null;
}
public final void serializeIfMarked() {
Map map;
synchronized (this) {
try {
if (this.map.isMarked()) {
map = ((KeysMap) this.map.getReference()).getKeys();
AtomicMarkableReference atomicMarkableReference = this.map;
atomicMarkableReference.set((KeysMap) atomicMarkableReference.getReference(), false);
} else {
map = null;
}
} catch (Throwable th) {
throw th;
}
}
if (map != null) {
UserMetadata.this.metaDataStore.writeKeyData(UserMetadata.this.sessionIdentifier, map, this.isInternal);
}
}
}
}