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,147 @@
package com.google.firebase.perf.session.gauges;
import android.os.Process;
import android.system.Os;
import android.system.OsConstants;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.v1.CpuMetricReading;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class CpuGaugeCollector {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public static final long MICROSECONDS_PER_SECOND = TimeUnit.SECONDS.toMicros(1);
public ScheduledFuture cpuMetricCollectorJob = null;
public long cpuMetricCollectionRateMs = -1;
public final ConcurrentLinkedQueue cpuMetricReadings = new ConcurrentLinkedQueue();
public final ScheduledExecutorService cpuMetricCollectorExecutor = Executors.newSingleThreadScheduledExecutor();
public final String procFileName = "/proc/" + Integer.toString(Process.myPid()) + "/stat";
public final long clockTicksPerSecond = getClockTicksPerSecond();
public static boolean isInvalidCollectionFrequency(long j) {
return j <= 0;
}
public void startCollecting(long j, Timer timer) {
long j2 = this.clockTicksPerSecond;
if (j2 == -1 || j2 == 0 || isInvalidCollectionFrequency(j)) {
return;
}
if (this.cpuMetricCollectorJob == null) {
scheduleCpuMetricCollectionWithRate(j, timer);
} else if (this.cpuMetricCollectionRateMs != j) {
stopCollecting();
scheduleCpuMetricCollectionWithRate(j, timer);
}
}
public void stopCollecting() {
ScheduledFuture scheduledFuture = this.cpuMetricCollectorJob;
if (scheduledFuture == null) {
return;
}
scheduledFuture.cancel(false);
this.cpuMetricCollectorJob = null;
this.cpuMetricCollectionRateMs = -1L;
}
public void collectOnce(Timer timer) {
scheduleCpuMetricCollectionOnce(timer);
}
public final synchronized void scheduleCpuMetricCollectionWithRate(long j, final Timer timer) {
this.cpuMetricCollectionRateMs = j;
try {
this.cpuMetricCollectorJob = this.cpuMetricCollectorExecutor.scheduleAtFixedRate(new Runnable() { // from class: com.google.firebase.perf.session.gauges.CpuGaugeCollector$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
CpuGaugeCollector.this.lambda$scheduleCpuMetricCollectionWithRate$0(timer);
}
}, 0L, j, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
logger.warn("Unable to start collecting Cpu Metrics: " + e.getMessage());
}
}
public final /* synthetic */ void lambda$scheduleCpuMetricCollectionWithRate$0(Timer timer) {
CpuMetricReading syncCollectCpuMetric = syncCollectCpuMetric(timer);
if (syncCollectCpuMetric != null) {
this.cpuMetricReadings.add(syncCollectCpuMetric);
}
}
public final synchronized void scheduleCpuMetricCollectionOnce(final Timer timer) {
try {
this.cpuMetricCollectorExecutor.schedule(new Runnable() { // from class: com.google.firebase.perf.session.gauges.CpuGaugeCollector$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
CpuGaugeCollector.this.lambda$scheduleCpuMetricCollectionOnce$1(timer);
}
}, 0L, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
logger.warn("Unable to collect Cpu Metric: " + e.getMessage());
}
}
public final /* synthetic */ void lambda$scheduleCpuMetricCollectionOnce$1(Timer timer) {
CpuMetricReading syncCollectCpuMetric = syncCollectCpuMetric(timer);
if (syncCollectCpuMetric != null) {
this.cpuMetricReadings.add(syncCollectCpuMetric);
}
}
public final CpuMetricReading syncCollectCpuMetric(Timer timer) {
if (timer == null) {
return null;
}
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(this.procFileName));
try {
long currentTimestampMicros = timer.getCurrentTimestampMicros();
String[] split = bufferedReader.readLine().split(" ");
CpuMetricReading cpuMetricReading = (CpuMetricReading) CpuMetricReading.newBuilder().setClientTimeUs(currentTimestampMicros).setSystemTimeUs(convertClockTicksToMicroseconds(Long.parseLong(split[14]) + Long.parseLong(split[16]))).setUserTimeUs(convertClockTicksToMicroseconds(Long.parseLong(split[13]) + Long.parseLong(split[15]))).build();
bufferedReader.close();
return cpuMetricReading;
} catch (Throwable th) {
try {
bufferedReader.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
throw th;
}
} catch (IOException e) {
logger.warn("Unable to read 'proc/[pid]/stat' file: " + e.getMessage());
return null;
} catch (ArrayIndexOutOfBoundsException e2) {
e = e2;
logger.warn("Unexpected '/proc/[pid]/stat' file format encountered: " + e.getMessage());
return null;
} catch (NullPointerException e3) {
e = e3;
logger.warn("Unexpected '/proc/[pid]/stat' file format encountered: " + e.getMessage());
return null;
} catch (NumberFormatException e4) {
e = e4;
logger.warn("Unexpected '/proc/[pid]/stat' file format encountered: " + e.getMessage());
return null;
}
}
public final long getClockTicksPerSecond() {
return Os.sysconf(OsConstants._SC_CLK_TCK);
}
public final long convertClockTicksToMicroseconds(long j) {
return Math.round((j / this.clockTicksPerSecond) * MICROSECONDS_PER_SECOND);
}
}

View File

@@ -0,0 +1,263 @@
package com.google.firebase.perf.session.gauges;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.firebase.components.Lazy;
import com.google.firebase.inject.Provider;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.session.PerfSession;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.v1.AndroidMemoryReading;
import com.google.firebase.perf.v1.ApplicationProcessState;
import com.google.firebase.perf.v1.CpuMetricReading;
import com.google.firebase.perf.v1.GaugeMetadata;
import com.google.firebase.perf.v1.GaugeMetric;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@Keep
/* loaded from: classes3.dex */
public class GaugeManager {
private static final long APPROX_NUMBER_OF_DATA_POINTS_PER_GAUGE_METRIC = 20;
private static final long INVALID_GAUGE_COLLECTION_FREQUENCY = -1;
private static final long TIME_TO_WAIT_BEFORE_FLUSHING_GAUGES_QUEUE_MS = 20;
private ApplicationProcessState applicationProcessState;
private final ConfigResolver configResolver;
private final Lazy cpuGaugeCollector;
@Nullable
private ScheduledFuture gaugeManagerDataCollectionJob;
private final Lazy gaugeManagerExecutor;
@Nullable
private GaugeMetadataManager gaugeMetadataManager;
private final Lazy memoryGaugeCollector;
@Nullable
private String sessionId;
private final TransportManager transportManager;
private static final AndroidLogger logger = AndroidLogger.getInstance();
private static final GaugeManager instance = new GaugeManager();
@SuppressLint({"ThreadPoolCreation"})
private GaugeManager() {
this(new Lazy(new Provider() { // from class: com.google.firebase.perf.session.gauges.GaugeManager$$ExternalSyntheticLambda2
@Override // com.google.firebase.inject.Provider
public final Object get() {
return Executors.newSingleThreadScheduledExecutor();
}
}), TransportManager.getInstance(), ConfigResolver.getInstance(), null, new Lazy(new Provider() { // from class: com.google.firebase.perf.session.gauges.GaugeManager$$ExternalSyntheticLambda3
@Override // com.google.firebase.inject.Provider
public final Object get() {
CpuGaugeCollector lambda$new$0;
lambda$new$0 = GaugeManager.lambda$new$0();
return lambda$new$0;
}
}), new Lazy(new Provider() { // from class: com.google.firebase.perf.session.gauges.GaugeManager$$ExternalSyntheticLambda4
@Override // com.google.firebase.inject.Provider
public final Object get() {
MemoryGaugeCollector lambda$new$1;
lambda$new$1 = GaugeManager.lambda$new$1();
return lambda$new$1;
}
}));
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ CpuGaugeCollector lambda$new$0() {
return new CpuGaugeCollector();
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ MemoryGaugeCollector lambda$new$1() {
return new MemoryGaugeCollector();
}
@VisibleForTesting
public GaugeManager(Lazy lazy, TransportManager transportManager, ConfigResolver configResolver, GaugeMetadataManager gaugeMetadataManager, Lazy lazy2, Lazy lazy3) {
this.gaugeManagerDataCollectionJob = null;
this.sessionId = null;
this.applicationProcessState = ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN;
this.gaugeManagerExecutor = lazy;
this.transportManager = transportManager;
this.configResolver = configResolver;
this.gaugeMetadataManager = gaugeMetadataManager;
this.cpuGaugeCollector = lazy2;
this.memoryGaugeCollector = lazy3;
}
public void initializeGaugeMetadataManager(Context context) {
this.gaugeMetadataManager = new GaugeMetadataManager(context);
}
public static synchronized GaugeManager getInstance() {
GaugeManager gaugeManager;
synchronized (GaugeManager.class) {
gaugeManager = instance;
}
return gaugeManager;
}
public void startCollectingGauges(PerfSession perfSession, final ApplicationProcessState applicationProcessState) {
if (this.sessionId != null) {
stopCollectingGauges();
}
long startCollectingGauges = startCollectingGauges(applicationProcessState, perfSession.getTimer());
if (startCollectingGauges == -1) {
logger.warn("Invalid gauge collection frequency. Unable to start collecting Gauges.");
return;
}
final String sessionId = perfSession.sessionId();
this.sessionId = sessionId;
this.applicationProcessState = applicationProcessState;
try {
long j = startCollectingGauges * 20;
this.gaugeManagerDataCollectionJob = ((ScheduledExecutorService) this.gaugeManagerExecutor.get()).scheduleAtFixedRate(new Runnable() { // from class: com.google.firebase.perf.session.gauges.GaugeManager$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
GaugeManager.this.lambda$startCollectingGauges$2(sessionId, applicationProcessState);
}
}, j, j, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
logger.warn("Unable to start collecting Gauges: " + e.getMessage());
}
}
private long startCollectingGauges(ApplicationProcessState applicationProcessState, Timer timer) {
long cpuGaugeCollectionFrequencyMs = getCpuGaugeCollectionFrequencyMs(applicationProcessState);
if (!startCollectingCpuMetrics(cpuGaugeCollectionFrequencyMs, timer)) {
cpuGaugeCollectionFrequencyMs = -1;
}
long memoryGaugeCollectionFrequencyMs = getMemoryGaugeCollectionFrequencyMs(applicationProcessState);
return startCollectingMemoryMetrics(memoryGaugeCollectionFrequencyMs, timer) ? cpuGaugeCollectionFrequencyMs == -1 ? memoryGaugeCollectionFrequencyMs : Math.min(cpuGaugeCollectionFrequencyMs, memoryGaugeCollectionFrequencyMs) : cpuGaugeCollectionFrequencyMs;
}
public void stopCollectingGauges() {
final String str = this.sessionId;
if (str == null) {
return;
}
final ApplicationProcessState applicationProcessState = this.applicationProcessState;
((CpuGaugeCollector) this.cpuGaugeCollector.get()).stopCollecting();
((MemoryGaugeCollector) this.memoryGaugeCollector.get()).stopCollecting();
ScheduledFuture scheduledFuture = this.gaugeManagerDataCollectionJob;
if (scheduledFuture != null) {
scheduledFuture.cancel(false);
}
((ScheduledExecutorService) this.gaugeManagerExecutor.get()).schedule(new Runnable() { // from class: com.google.firebase.perf.session.gauges.GaugeManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
GaugeManager.this.lambda$stopCollectingGauges$3(str, applicationProcessState);
}
}, 20L, TimeUnit.MILLISECONDS);
this.sessionId = null;
this.applicationProcessState = ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: syncFlush, reason: merged with bridge method [inline-methods] and merged with bridge method [inline-methods] */
public void lambda$stopCollectingGauges$3(String str, ApplicationProcessState applicationProcessState) {
GaugeMetric.Builder newBuilder = GaugeMetric.newBuilder();
while (!((CpuGaugeCollector) this.cpuGaugeCollector.get()).cpuMetricReadings.isEmpty()) {
newBuilder.addCpuMetricReadings((CpuMetricReading) ((CpuGaugeCollector) this.cpuGaugeCollector.get()).cpuMetricReadings.poll());
}
while (!((MemoryGaugeCollector) this.memoryGaugeCollector.get()).memoryMetricReadings.isEmpty()) {
newBuilder.addAndroidMemoryReadings((AndroidMemoryReading) ((MemoryGaugeCollector) this.memoryGaugeCollector.get()).memoryMetricReadings.poll());
}
newBuilder.setSessionId(str);
this.transportManager.log((GaugeMetric) newBuilder.build(), applicationProcessState);
}
public boolean logGaugeMetadata(String str, ApplicationProcessState applicationProcessState) {
if (this.gaugeMetadataManager == null) {
return false;
}
this.transportManager.log((GaugeMetric) GaugeMetric.newBuilder().setSessionId(str).setGaugeMetadata(getGaugeMetadata()).build(), applicationProcessState);
return true;
}
private GaugeMetadata getGaugeMetadata() {
return (GaugeMetadata) GaugeMetadata.newBuilder().setDeviceRamSizeKb(this.gaugeMetadataManager.getDeviceRamSizeKb()).setMaxAppJavaHeapMemoryKb(this.gaugeMetadataManager.getMaxAppJavaHeapMemoryKb()).setMaxEncouragedAppJavaHeapMemoryKb(this.gaugeMetadataManager.getMaxEncouragedAppJavaHeapMemoryKb()).build();
}
private boolean startCollectingCpuMetrics(long j, Timer timer) {
if (j == -1) {
logger.debug("Invalid Cpu Metrics collection frequency. Did not collect Cpu Metrics.");
return false;
}
((CpuGaugeCollector) this.cpuGaugeCollector.get()).startCollecting(j, timer);
return true;
}
private boolean startCollectingMemoryMetrics(long j, Timer timer) {
if (j == -1) {
logger.debug("Invalid Memory Metrics collection frequency. Did not collect Memory Metrics.");
return false;
}
((MemoryGaugeCollector) this.memoryGaugeCollector.get()).startCollecting(j, timer);
return true;
}
public void collectGaugeMetricOnce(Timer timer) {
collectGaugeMetricOnce((CpuGaugeCollector) this.cpuGaugeCollector.get(), (MemoryGaugeCollector) this.memoryGaugeCollector.get(), timer);
}
private static void collectGaugeMetricOnce(CpuGaugeCollector cpuGaugeCollector, MemoryGaugeCollector memoryGaugeCollector, Timer timer) {
cpuGaugeCollector.collectOnce(timer);
memoryGaugeCollector.collectOnce(timer);
}
/* renamed from: com.google.firebase.perf.session.gauges.GaugeManager$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$firebase$perf$v1$ApplicationProcessState;
static {
int[] iArr = new int[ApplicationProcessState.values().length];
$SwitchMap$com$google$firebase$perf$v1$ApplicationProcessState = iArr;
try {
iArr[ApplicationProcessState.BACKGROUND.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$firebase$perf$v1$ApplicationProcessState[ApplicationProcessState.FOREGROUND.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
private long getCpuGaugeCollectionFrequencyMs(ApplicationProcessState applicationProcessState) {
long sessionsCpuCaptureFrequencyBackgroundMs;
int i = AnonymousClass1.$SwitchMap$com$google$firebase$perf$v1$ApplicationProcessState[applicationProcessState.ordinal()];
if (i == 1) {
sessionsCpuCaptureFrequencyBackgroundMs = this.configResolver.getSessionsCpuCaptureFrequencyBackgroundMs();
} else {
sessionsCpuCaptureFrequencyBackgroundMs = i != 2 ? -1L : this.configResolver.getSessionsCpuCaptureFrequencyForegroundMs();
}
if (CpuGaugeCollector.isInvalidCollectionFrequency(sessionsCpuCaptureFrequencyBackgroundMs)) {
return -1L;
}
return sessionsCpuCaptureFrequencyBackgroundMs;
}
private long getMemoryGaugeCollectionFrequencyMs(ApplicationProcessState applicationProcessState) {
long sessionsMemoryCaptureFrequencyBackgroundMs;
int i = AnonymousClass1.$SwitchMap$com$google$firebase$perf$v1$ApplicationProcessState[applicationProcessState.ordinal()];
if (i == 1) {
sessionsMemoryCaptureFrequencyBackgroundMs = this.configResolver.getSessionsMemoryCaptureFrequencyBackgroundMs();
} else {
sessionsMemoryCaptureFrequencyBackgroundMs = i != 2 ? -1L : this.configResolver.getSessionsMemoryCaptureFrequencyForegroundMs();
}
if (MemoryGaugeCollector.isInvalidCollectionFrequency(sessionsMemoryCaptureFrequencyBackgroundMs)) {
return -1L;
}
return sessionsMemoryCaptureFrequencyBackgroundMs;
}
}

View File

@@ -0,0 +1,42 @@
package com.google.firebase.perf.session.gauges;
import android.app.ActivityManager;
import android.content.Context;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.StorageUnit;
import com.google.firebase.perf.util.Utils;
/* loaded from: classes3.dex */
public class GaugeMetadataManager {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final ActivityManager activityManager;
public final Context appContext;
public final ActivityManager.MemoryInfo memoryInfo;
public final Runtime runtime;
public GaugeMetadataManager(Context context) {
this(Runtime.getRuntime(), context);
}
public GaugeMetadataManager(Runtime runtime, Context context) {
this.runtime = runtime;
this.appContext = context;
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
this.activityManager = activityManager;
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
this.memoryInfo = memoryInfo;
activityManager.getMemoryInfo(memoryInfo);
}
public int getMaxAppJavaHeapMemoryKb() {
return Utils.saturatedIntCast(StorageUnit.BYTES.toKilobytes(this.runtime.maxMemory()));
}
public int getMaxEncouragedAppJavaHeapMemoryKb() {
return Utils.saturatedIntCast(StorageUnit.MEGABYTES.toKilobytes(this.activityManager.getMemoryClass()));
}
public int getDeviceRamSizeKb() {
return Utils.saturatedIntCast(StorageUnit.BYTES.toKilobytes(this.memoryInfo.totalMem));
}
}

View File

@@ -0,0 +1,117 @@
package com.google.firebase.perf.session.gauges;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.StorageUnit;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.util.Utils;
import com.google.firebase.perf.v1.AndroidMemoryReading;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class MemoryGaugeCollector {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public long memoryMetricCollectionRateMs;
public final ScheduledExecutorService memoryMetricCollectorExecutor;
public ScheduledFuture memoryMetricCollectorJob;
public final ConcurrentLinkedQueue memoryMetricReadings;
public final Runtime runtime;
public static boolean isInvalidCollectionFrequency(long j) {
return j <= 0;
}
public MemoryGaugeCollector() {
this(Executors.newSingleThreadScheduledExecutor(), Runtime.getRuntime());
}
public MemoryGaugeCollector(ScheduledExecutorService scheduledExecutorService, Runtime runtime) {
this.memoryMetricCollectorJob = null;
this.memoryMetricCollectionRateMs = -1L;
this.memoryMetricCollectorExecutor = scheduledExecutorService;
this.memoryMetricReadings = new ConcurrentLinkedQueue();
this.runtime = runtime;
}
public void startCollecting(long j, Timer timer) {
if (isInvalidCollectionFrequency(j)) {
return;
}
if (this.memoryMetricCollectorJob == null) {
scheduleMemoryMetricCollectionWithRate(j, timer);
} else if (this.memoryMetricCollectionRateMs != j) {
stopCollecting();
scheduleMemoryMetricCollectionWithRate(j, timer);
}
}
public void stopCollecting() {
ScheduledFuture scheduledFuture = this.memoryMetricCollectorJob;
if (scheduledFuture == null) {
return;
}
scheduledFuture.cancel(false);
this.memoryMetricCollectorJob = null;
this.memoryMetricCollectionRateMs = -1L;
}
public void collectOnce(Timer timer) {
scheduleMemoryMetricCollectionOnce(timer);
}
public final synchronized void scheduleMemoryMetricCollectionWithRate(long j, final Timer timer) {
this.memoryMetricCollectionRateMs = j;
try {
this.memoryMetricCollectorJob = this.memoryMetricCollectorExecutor.scheduleAtFixedRate(new Runnable() { // from class: com.google.firebase.perf.session.gauges.MemoryGaugeCollector$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
MemoryGaugeCollector.this.lambda$scheduleMemoryMetricCollectionWithRate$0(timer);
}
}, 0L, j, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
logger.warn("Unable to start collecting Memory Metrics: " + e.getMessage());
}
}
public final /* synthetic */ void lambda$scheduleMemoryMetricCollectionWithRate$0(Timer timer) {
AndroidMemoryReading syncCollectMemoryMetric = syncCollectMemoryMetric(timer);
if (syncCollectMemoryMetric != null) {
this.memoryMetricReadings.add(syncCollectMemoryMetric);
}
}
public final synchronized void scheduleMemoryMetricCollectionOnce(final Timer timer) {
try {
this.memoryMetricCollectorExecutor.schedule(new Runnable() { // from class: com.google.firebase.perf.session.gauges.MemoryGaugeCollector$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
MemoryGaugeCollector.this.lambda$scheduleMemoryMetricCollectionOnce$1(timer);
}
}, 0L, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
logger.warn("Unable to collect Memory Metric: " + e.getMessage());
}
}
public final /* synthetic */ void lambda$scheduleMemoryMetricCollectionOnce$1(Timer timer) {
AndroidMemoryReading syncCollectMemoryMetric = syncCollectMemoryMetric(timer);
if (syncCollectMemoryMetric != null) {
this.memoryMetricReadings.add(syncCollectMemoryMetric);
}
}
public final AndroidMemoryReading syncCollectMemoryMetric(Timer timer) {
if (timer == null) {
return null;
}
return (AndroidMemoryReading) AndroidMemoryReading.newBuilder().setClientTimeUs(timer.getCurrentTimestampMicros()).setUsedAppJavaHeapMemoryKb(getCurrentUsedAppJavaHeapMemoryKb()).build();
}
public final int getCurrentUsedAppJavaHeapMemoryKb() {
return Utils.saturatedIntCast(StorageUnit.BYTES.toKilobytes(this.runtime.totalMemory() - this.runtime.freeMemory()));
}
}