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,8 @@
package com.google.firebase.perf;
/* loaded from: classes3.dex */
public abstract class BuildConfig {
public static final Boolean ENFORCE_DEFAULT_LOG_SRC = Boolean.FALSE;
public static final String FIREPERF_VERSION_NAME = "21.0.1";
public static final String TRANSPORT_LOG_SRC = "FIREPERF";
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf;
import android.content.Context;
import com.google.firebase.FirebaseApp;
import com.google.firebase.StartupTime;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.metrics.AppStartTrace;
import com.google.firebase.perf.session.SessionManager;
import java.util.concurrent.Executor;
/* loaded from: classes3.dex */
public class FirebasePerfEarly {
public FirebasePerfEarly(FirebaseApp firebaseApp, StartupTime startupTime, Executor executor) {
Context applicationContext = firebaseApp.getApplicationContext();
ConfigResolver.getInstance().setApplicationContext(applicationContext);
AppStateMonitor appStateMonitor = AppStateMonitor.getInstance();
appStateMonitor.registerActivityLifecycleCallbacks(applicationContext);
appStateMonitor.registerForAppColdStart(new FirebasePerformanceInitializer());
if (startupTime != null) {
AppStartTrace appStartTrace = AppStartTrace.getInstance();
appStartTrace.registerActivityLifecycleCallbacks(applicationContext);
executor.execute(new AppStartTrace.StartFromBackgroundRunnable(appStartTrace));
}
SessionManager.getInstance().initializeGaugeCollection();
}
}

View File

@@ -0,0 +1,16 @@
package com.google.firebase.perf;
import androidx.annotation.Keep;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
@Keep
/* loaded from: classes3.dex */
public final class FirebasePerfKtxRegistrar implements ComponentRegistrar {
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component> getComponents() {
return CollectionsKt__CollectionsKt.emptyList();
}
}

View File

@@ -0,0 +1,60 @@
package com.google.firebase.perf;
import androidx.annotation.Keep;
import com.google.android.datatransport.TransportFactory;
import com.google.firebase.FirebaseApp;
import com.google.firebase.StartupTime;
import com.google.firebase.annotations.concurrent.UiThread;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentContainer;
import com.google.firebase.components.ComponentFactory;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.components.Dependency;
import com.google.firebase.components.Qualified;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.perf.injection.components.DaggerFirebasePerformanceComponent;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule;
import com.google.firebase.platforminfo.LibraryVersionComponent;
import com.google.firebase.remoteconfig.RemoteConfigComponent;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
@Keep
/* loaded from: classes3.dex */
public class FirebasePerfRegistrar implements ComponentRegistrar {
private static final String EARLY_LIBRARY_NAME = "fire-perf-early";
private static final String LIBRARY_NAME = "fire-perf";
@Override // com.google.firebase.components.ComponentRegistrar
@Keep
public List<Component> getComponents() {
final Qualified qualified = Qualified.qualified(UiThread.class, Executor.class);
return Arrays.asList(Component.builder(FirebasePerformance.class).name(LIBRARY_NAME).add(Dependency.required(FirebaseApp.class)).add(Dependency.requiredProvider(RemoteConfigComponent.class)).add(Dependency.required(FirebaseInstallationsApi.class)).add(Dependency.requiredProvider(TransportFactory.class)).add(Dependency.required(FirebasePerfEarly.class)).factory(new ComponentFactory() { // from class: com.google.firebase.perf.FirebasePerfRegistrar$$ExternalSyntheticLambda0
@Override // com.google.firebase.components.ComponentFactory
public final Object create(ComponentContainer componentContainer) {
FirebasePerformance providesFirebasePerformance;
providesFirebasePerformance = FirebasePerfRegistrar.providesFirebasePerformance(componentContainer);
return providesFirebasePerformance;
}
}).build(), Component.builder(FirebasePerfEarly.class).name(EARLY_LIBRARY_NAME).add(Dependency.required(FirebaseApp.class)).add(Dependency.optionalProvider(StartupTime.class)).add(Dependency.required(qualified)).eagerInDefaultApp().factory(new ComponentFactory() { // from class: com.google.firebase.perf.FirebasePerfRegistrar$$ExternalSyntheticLambda1
@Override // com.google.firebase.components.ComponentFactory
public final Object create(ComponentContainer componentContainer) {
FirebasePerfEarly lambda$getComponents$0;
lambda$getComponents$0 = FirebasePerfRegistrar.lambda$getComponents$0(Qualified.this, componentContainer);
return lambda$getComponents$0;
}
}).build(), LibraryVersionComponent.create(LIBRARY_NAME, "21.0.1"));
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ FirebasePerfEarly lambda$getComponents$0(Qualified qualified, ComponentContainer componentContainer) {
return new FirebasePerfEarly((FirebaseApp) componentContainer.get(FirebaseApp.class), (StartupTime) componentContainer.getProvider(StartupTime.class).get(), (Executor) componentContainer.get(qualified));
}
/* JADX INFO: Access modifiers changed from: private */
public static FirebasePerformance providesFirebasePerformance(ComponentContainer componentContainer) {
componentContainer.get(FirebasePerfEarly.class);
return DaggerFirebasePerformanceComponent.builder().firebasePerformanceModule(new FirebasePerformanceModule((FirebaseApp) componentContainer.get(FirebaseApp.class), (FirebaseInstallationsApi) componentContainer.get(FirebaseInstallationsApi.class), componentContainer.getProvider(RemoteConfigComponent.class), componentContainer.getProvider(TransportFactory.class))).build().getFirebasePerformance();
}
}

View File

@@ -0,0 +1,114 @@
package com.google.firebase.perf;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.google.firebase.FirebaseApp;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.config.RemoteConfigManager;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.logging.ConsoleUrlGenerator;
import com.google.firebase.perf.session.SessionManager;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.ImmutableBundle;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/* loaded from: classes3.dex */
public class FirebasePerformance {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final ConfigResolver configResolver;
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallationsApi;
public final Provider firebaseRemoteConfigProvider;
public final Map mCustomAttributes = new ConcurrentHashMap();
public final ImmutableBundle mMetadataBundle;
public Boolean mPerformanceCollectionForceEnabledState;
public final Provider transportFactoryProvider;
public static FirebasePerformance getInstance() {
return (FirebasePerformance) FirebaseApp.getInstance().get(FirebasePerformance.class);
}
public FirebasePerformance(FirebaseApp firebaseApp, Provider provider, FirebaseInstallationsApi firebaseInstallationsApi, Provider provider2, RemoteConfigManager remoteConfigManager, ConfigResolver configResolver, SessionManager sessionManager) {
this.mPerformanceCollectionForceEnabledState = null;
this.firebaseApp = firebaseApp;
this.firebaseRemoteConfigProvider = provider;
this.firebaseInstallationsApi = firebaseInstallationsApi;
this.transportFactoryProvider = provider2;
if (firebaseApp == null) {
this.mPerformanceCollectionForceEnabledState = Boolean.FALSE;
this.configResolver = configResolver;
this.mMetadataBundle = new ImmutableBundle(new Bundle());
return;
}
TransportManager.getInstance().initialize(firebaseApp, firebaseInstallationsApi, provider2);
Context applicationContext = firebaseApp.getApplicationContext();
ImmutableBundle extractMetadata = extractMetadata(applicationContext);
this.mMetadataBundle = extractMetadata;
remoteConfigManager.setFirebaseRemoteConfigProvider(provider);
this.configResolver = configResolver;
configResolver.setMetadataBundle(extractMetadata);
configResolver.setApplicationContext(applicationContext);
sessionManager.setApplicationContext(applicationContext);
this.mPerformanceCollectionForceEnabledState = configResolver.getIsPerformanceCollectionEnabled();
AndroidLogger androidLogger = logger;
if (androidLogger.isLogcatEnabled() && isPerformanceCollectionEnabled()) {
androidLogger.info(String.format("Firebase Performance Monitoring is successfully initialized! In a minute, visit the Firebase console to view your data: %s", ConsoleUrlGenerator.generateDashboardUrl(firebaseApp.getOptions().getProjectId(), applicationContext.getPackageName())));
}
}
public void setPerformanceCollectionEnabled(boolean z) {
setPerformanceCollectionEnabled(Boolean.valueOf(z));
}
public synchronized void setPerformanceCollectionEnabled(Boolean bool) {
try {
FirebaseApp.getInstance();
if (this.configResolver.getIsPerformanceCollectionDeactivated().booleanValue()) {
logger.info("Firebase Performance is permanently disabled");
return;
}
this.configResolver.setIsPerformanceCollectionEnabled(bool);
if (bool != null) {
this.mPerformanceCollectionForceEnabledState = bool;
} else {
this.mPerformanceCollectionForceEnabledState = this.configResolver.getIsPerformanceCollectionEnabled();
}
if (Boolean.TRUE.equals(this.mPerformanceCollectionForceEnabledState)) {
logger.info("Firebase Performance is Enabled");
} else if (Boolean.FALSE.equals(this.mPerformanceCollectionForceEnabledState)) {
logger.info("Firebase Performance is Disabled");
}
} catch (IllegalStateException unused) {
}
}
public boolean isPerformanceCollectionEnabled() {
Boolean bool = this.mPerformanceCollectionForceEnabledState;
if (bool != null) {
return bool.booleanValue();
}
return FirebaseApp.getInstance().isDataCollectionDefaultEnabled();
}
public Map getAttributes() {
return new HashMap(this.mCustomAttributes);
}
public static ImmutableBundle extractMetadata(Context context) {
Bundle bundle;
try {
bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
} catch (PackageManager.NameNotFoundException | NullPointerException e) {
StringBuilder sb = new StringBuilder();
sb.append("No perf enable meta data found ");
sb.append(e.getMessage());
bundle = null;
}
return bundle != null ? new ImmutableBundle(bundle) : new ImmutableBundle();
}
}

View File

@@ -0,0 +1,18 @@
package com.google.firebase.perf;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.logging.AndroidLogger;
/* loaded from: classes3.dex */
public final class FirebasePerformanceInitializer implements AppStateMonitor.AppColdStartCallback {
public static final AndroidLogger logger = AndroidLogger.getInstance();
@Override // com.google.firebase.perf.application.AppStateMonitor.AppColdStartCallback
public void onAppColdStart() {
try {
FirebasePerformance.getInstance();
} catch (IllegalStateException e) {
logger.warn("FirebaseApp is not initialized. Firebase Performance will not be collecting any performance metrics until initialized. %s", e);
}
}
}

View File

@@ -0,0 +1,42 @@
package com.google.firebase.perf;
import com.google.firebase.FirebaseApp;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.config.RemoteConfigManager;
import com.google.firebase.perf.session.SessionManager;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformance_Factory implements Provider {
public final Provider configResolverProvider;
public final Provider firebaseAppProvider;
public final Provider firebaseInstallationsApiProvider;
public final Provider firebaseRemoteConfigProvider;
public final Provider remoteConfigManagerProvider;
public final Provider sessionManagerProvider;
public final Provider transportFactoryProvider;
public FirebasePerformance_Factory(Provider provider, Provider provider2, Provider provider3, Provider provider4, Provider provider5, Provider provider6, Provider provider7) {
this.firebaseAppProvider = provider;
this.firebaseRemoteConfigProvider = provider2;
this.firebaseInstallationsApiProvider = provider3;
this.transportFactoryProvider = provider4;
this.remoteConfigManagerProvider = provider5;
this.configResolverProvider = provider6;
this.sessionManagerProvider = provider7;
}
@Override // javax.inject.Provider
public FirebasePerformance get() {
return newInstance((FirebaseApp) this.firebaseAppProvider.get(), (com.google.firebase.inject.Provider) this.firebaseRemoteConfigProvider.get(), (FirebaseInstallationsApi) this.firebaseInstallationsApiProvider.get(), (com.google.firebase.inject.Provider) this.transportFactoryProvider.get(), (RemoteConfigManager) this.remoteConfigManagerProvider.get(), (ConfigResolver) this.configResolverProvider.get(), (SessionManager) this.sessionManagerProvider.get());
}
public static FirebasePerformance_Factory create(Provider provider, Provider provider2, Provider provider3, Provider provider4, Provider provider5, Provider provider6, Provider provider7) {
return new FirebasePerformance_Factory(provider, provider2, provider3, provider4, provider5, provider6, provider7);
}
public static FirebasePerformance newInstance(FirebaseApp firebaseApp, com.google.firebase.inject.Provider provider, FirebaseInstallationsApi firebaseInstallationsApi, com.google.firebase.inject.Provider provider2, RemoteConfigManager remoteConfigManager, ConfigResolver configResolver, SessionManager sessionManager) {
return new FirebasePerformance(firebaseApp, provider, firebaseInstallationsApi, provider2, remoteConfigManager, configResolver, sessionManager);
}
}

View File

@@ -0,0 +1,323 @@
package com.google.firebase.perf.application;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.FrameMetricsCalculator;
import com.google.firebase.perf.metrics.Trace;
import com.google.firebase.perf.session.SessionManager;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Constants$CounterNames;
import com.google.firebase.perf.util.Constants$TraceNames;
import com.google.firebase.perf.util.Optional;
import com.google.firebase.perf.util.ScreenTraceUtil;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.v1.ApplicationProcessState;
import com.google.firebase.perf.v1.TraceMetric;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes3.dex */
public class AppStateMonitor implements Application.ActivityLifecycleCallbacks {
public static volatile AppStateMonitor instance;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final WeakHashMap activityToFragmentStateMonitorMap;
public final WeakHashMap activityToRecorderMap;
public final WeakHashMap activityToResumedMap;
public final WeakHashMap activityToScreenTraceMap;
public Set appColdStartSubscribers;
public final Set appStateSubscribers;
public final Clock clock;
public final ConfigResolver configResolver;
public ApplicationProcessState currentAppState;
public boolean isColdStart;
public boolean isRegisteredForLifecycleCallbacks;
public final Map metricToCountMap;
public Timer resumeTime;
public final boolean screenPerformanceRecordingSupported;
public Timer stopTime;
public final TransportManager transportManager;
public final AtomicInteger tsnsCount;
public interface AppColdStartCallback {
void onAppColdStart();
}
public interface AppStateCallback {
void onUpdateAppState(ApplicationProcessState applicationProcessState);
}
public ApplicationProcessState getAppState() {
return this.currentAppState;
}
public boolean isColdStart() {
return this.isColdStart;
}
public boolean isScreenTraceSupported() {
return this.screenPerformanceRecordingSupported;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
public static AppStateMonitor getInstance() {
if (instance == null) {
synchronized (AppStateMonitor.class) {
try {
if (instance == null) {
instance = new AppStateMonitor(TransportManager.getInstance(), new Clock());
}
} finally {
}
}
}
return instance;
}
public AppStateMonitor(TransportManager transportManager, Clock clock) {
this(transportManager, clock, ConfigResolver.getInstance(), isScreenPerformanceRecordingSupported());
}
public AppStateMonitor(TransportManager transportManager, Clock clock, ConfigResolver configResolver, boolean z) {
this.activityToResumedMap = new WeakHashMap();
this.activityToRecorderMap = new WeakHashMap();
this.activityToFragmentStateMonitorMap = new WeakHashMap();
this.activityToScreenTraceMap = new WeakHashMap();
this.metricToCountMap = new HashMap();
this.appStateSubscribers = new HashSet();
this.appColdStartSubscribers = new HashSet();
this.tsnsCount = new AtomicInteger(0);
this.currentAppState = ApplicationProcessState.BACKGROUND;
this.isRegisteredForLifecycleCallbacks = false;
this.isColdStart = true;
this.transportManager = transportManager;
this.clock = clock;
this.configResolver = configResolver;
this.screenPerformanceRecordingSupported = z;
}
public synchronized void registerActivityLifecycleCallbacks(Context context) {
if (this.isRegisteredForLifecycleCallbacks) {
return;
}
Context applicationContext = context.getApplicationContext();
if (applicationContext instanceof Application) {
((Application) applicationContext).registerActivityLifecycleCallbacks(this);
this.isRegisteredForLifecycleCallbacks = true;
}
}
public void incrementCount(String str, long j) {
synchronized (this.metricToCountMap) {
try {
Long l = (Long) this.metricToCountMap.get(str);
if (l == null) {
this.metricToCountMap.put(str, Long.valueOf(j));
} else {
this.metricToCountMap.put(str, Long.valueOf(l.longValue() + j));
}
} catch (Throwable th) {
throw th;
}
}
}
public void incrementTsnsCount(int i) {
this.tsnsCount.addAndGet(i);
}
public final void startFrameMonitoring(Activity activity) {
if (isScreenTraceSupported() && this.configResolver.isPerformanceMonitoringEnabled()) {
FrameMetricsRecorder frameMetricsRecorder = new FrameMetricsRecorder(activity);
this.activityToRecorderMap.put(activity, frameMetricsRecorder);
if (activity instanceof FragmentActivity) {
FragmentStateMonitor fragmentStateMonitor = new FragmentStateMonitor(this.clock, this.transportManager, this, frameMetricsRecorder);
this.activityToFragmentStateMonitorMap.put(activity, fragmentStateMonitor);
((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(fragmentStateMonitor, true);
}
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
startFrameMonitoring(activity);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
this.activityToRecorderMap.remove(activity);
if (this.activityToFragmentStateMonitorMap.containsKey(activity)) {
((FragmentActivity) activity).getSupportFragmentManager().unregisterFragmentLifecycleCallbacks((FragmentManager.FragmentLifecycleCallbacks) this.activityToFragmentStateMonitorMap.remove(activity));
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public synchronized void onActivityStarted(Activity activity) {
try {
if (isScreenTraceSupported() && this.configResolver.isPerformanceMonitoringEnabled()) {
if (!this.activityToRecorderMap.containsKey(activity)) {
startFrameMonitoring(activity);
}
((FrameMetricsRecorder) this.activityToRecorderMap.get(activity)).start();
Trace trace = new Trace(getScreenTraceName(activity), this.transportManager, this.clock, this);
trace.start();
this.activityToScreenTraceMap.put(activity, trace);
}
} catch (Throwable th) {
throw th;
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public synchronized void onActivityStopped(Activity activity) {
try {
if (isScreenTraceSupported()) {
sendScreenTrace(activity);
}
if (this.activityToResumedMap.containsKey(activity)) {
this.activityToResumedMap.remove(activity);
if (this.activityToResumedMap.isEmpty()) {
this.stopTime = this.clock.getTime();
sendSessionLog(Constants$TraceNames.FOREGROUND_TRACE_NAME.toString(), this.resumeTime, this.stopTime);
updateAppState(ApplicationProcessState.BACKGROUND);
}
}
} catch (Throwable th) {
throw th;
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public synchronized void onActivityResumed(Activity activity) {
try {
if (this.activityToResumedMap.isEmpty()) {
this.resumeTime = this.clock.getTime();
this.activityToResumedMap.put(activity, Boolean.TRUE);
if (this.isColdStart) {
updateAppState(ApplicationProcessState.FOREGROUND);
sendAppColdStartUpdate();
this.isColdStart = false;
} else {
sendSessionLog(Constants$TraceNames.BACKGROUND_TRACE_NAME.toString(), this.stopTime, this.resumeTime);
updateAppState(ApplicationProcessState.FOREGROUND);
}
} else {
this.activityToResumedMap.put(activity, Boolean.TRUE);
}
} catch (Throwable th) {
throw th;
}
}
public void registerForAppState(WeakReference weakReference) {
synchronized (this.appStateSubscribers) {
this.appStateSubscribers.add(weakReference);
}
}
public void unregisterForAppState(WeakReference weakReference) {
synchronized (this.appStateSubscribers) {
this.appStateSubscribers.remove(weakReference);
}
}
public void registerForAppColdStart(AppColdStartCallback appColdStartCallback) {
synchronized (this.appColdStartSubscribers) {
this.appColdStartSubscribers.add(appColdStartCallback);
}
}
public final void updateAppState(ApplicationProcessState applicationProcessState) {
this.currentAppState = applicationProcessState;
synchronized (this.appStateSubscribers) {
try {
Iterator it = this.appStateSubscribers.iterator();
while (it.hasNext()) {
AppStateCallback appStateCallback = (AppStateCallback) ((WeakReference) it.next()).get();
if (appStateCallback != null) {
appStateCallback.onUpdateAppState(this.currentAppState);
} else {
it.remove();
}
}
} catch (Throwable th) {
throw th;
}
}
}
public final void sendAppColdStartUpdate() {
synchronized (this.appColdStartSubscribers) {
try {
for (AppColdStartCallback appColdStartCallback : this.appColdStartSubscribers) {
if (appColdStartCallback != null) {
appColdStartCallback.onAppColdStart();
}
}
} catch (Throwable th) {
throw th;
}
}
}
public final void sendScreenTrace(Activity activity) {
Trace trace = (Trace) this.activityToScreenTraceMap.get(activity);
if (trace == null) {
return;
}
this.activityToScreenTraceMap.remove(activity);
Optional stop = ((FrameMetricsRecorder) this.activityToRecorderMap.get(activity)).stop();
if (!stop.isAvailable()) {
logger.warn("Failed to record frame data for %s.", activity.getClass().getSimpleName());
} else {
ScreenTraceUtil.addFrameCounters(trace, (FrameMetricsCalculator.PerfFrameMetrics) stop.get());
trace.stop();
}
}
public final void sendSessionLog(String str, Timer timer, Timer timer2) {
if (this.configResolver.isPerformanceMonitoringEnabled()) {
TraceMetric.Builder addPerfSessions = TraceMetric.newBuilder().setName(str).setClientStartTimeUs(timer.getMicros()).setDurationUs(timer.getDurationMicros(timer2)).addPerfSessions(SessionManager.getInstance().perfSession().build());
int andSet = this.tsnsCount.getAndSet(0);
synchronized (this.metricToCountMap) {
try {
addPerfSessions.putAllCounters(this.metricToCountMap);
if (andSet != 0) {
addPerfSessions.putCounters(Constants$CounterNames.TRACE_STARTED_NOT_STOPPED.toString(), andSet);
}
this.metricToCountMap.clear();
} catch (Throwable th) {
throw th;
}
}
this.transportManager.log((TraceMetric) addPerfSessions.build(), ApplicationProcessState.FOREGROUND_BACKGROUND);
}
}
public static boolean isScreenPerformanceRecordingSupported() {
return FrameMetricsRecorder.isFrameMetricsRecordingSupported();
}
public static String getScreenTraceName(Activity activity) {
return "_st_" + activity.getClass().getSimpleName();
}
}

View File

@@ -0,0 +1,68 @@
package com.google.firebase.perf.application;
import androidx.annotation.VisibleForTesting;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.v1.ApplicationProcessState;
import java.lang.ref.WeakReference;
/* loaded from: classes3.dex */
public abstract class AppStateUpdateHandler implements AppStateMonitor.AppStateCallback {
private final WeakReference<AppStateMonitor.AppStateCallback> appStateCallback;
private final AppStateMonitor appStateMonitor;
private ApplicationProcessState currentAppState;
private boolean isRegisteredForAppState;
public ApplicationProcessState getAppState() {
return this.currentAppState;
}
@VisibleForTesting
public WeakReference<AppStateMonitor.AppStateCallback> getAppStateCallback() {
return this.appStateCallback;
}
public AppStateUpdateHandler() {
this(AppStateMonitor.getInstance());
}
public AppStateUpdateHandler(AppStateMonitor appStateMonitor) {
this.isRegisteredForAppState = false;
this.currentAppState = ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN;
this.appStateMonitor = appStateMonitor;
this.appStateCallback = new WeakReference<>(this);
}
public void registerForAppState() {
if (this.isRegisteredForAppState) {
return;
}
this.currentAppState = this.appStateMonitor.getAppState();
this.appStateMonitor.registerForAppState(this.appStateCallback);
this.isRegisteredForAppState = true;
}
public void unregisterForAppState() {
if (this.isRegisteredForAppState) {
this.appStateMonitor.unregisterForAppState(this.appStateCallback);
this.isRegisteredForAppState = false;
}
}
public void incrementTsnsCount(int i) {
this.appStateMonitor.incrementTsnsCount(i);
}
@Override // com.google.firebase.perf.application.AppStateMonitor.AppStateCallback
public void onUpdateAppState(ApplicationProcessState applicationProcessState) {
ApplicationProcessState applicationProcessState2 = this.currentAppState;
ApplicationProcessState applicationProcessState3 = ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN;
if (applicationProcessState2 == applicationProcessState3) {
this.currentAppState = applicationProcessState;
} else {
if (applicationProcessState2 == applicationProcessState || applicationProcessState == applicationProcessState3) {
return;
}
this.currentAppState = ApplicationProcessState.FOREGROUND_BACKGROUND;
}
}
}

View File

@@ -0,0 +1,74 @@
package com.google.firebase.perf.application;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.FrameMetricsCalculator;
import com.google.firebase.perf.metrics.Trace;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Optional;
import com.google.firebase.perf.util.ScreenTraceUtil;
import java.util.WeakHashMap;
/* loaded from: classes3.dex */
public class FragmentStateMonitor extends FragmentManager.FragmentLifecycleCallbacks {
private static final AndroidLogger logger = AndroidLogger.getInstance();
private final FrameMetricsRecorder activityFramesRecorder;
private final AppStateMonitor appStateMonitor;
private final Clock clock;
private final WeakHashMap<Fragment, Trace> fragmentToTraceMap = new WeakHashMap<>();
private final TransportManager transportManager;
@VisibleForTesting
public WeakHashMap<Fragment, Trace> getFragmentToTraceMap() {
return this.fragmentToTraceMap;
}
public FragmentStateMonitor(Clock clock, TransportManager transportManager, AppStateMonitor appStateMonitor, FrameMetricsRecorder frameMetricsRecorder) {
this.clock = clock;
this.transportManager = transportManager;
this.appStateMonitor = appStateMonitor;
this.activityFramesRecorder = frameMetricsRecorder;
}
public String getFragmentScreenTraceName(Fragment fragment) {
return "_st_" + fragment.getClass().getSimpleName();
}
@Override // androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks
public void onFragmentResumed(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment) {
super.onFragmentResumed(fragmentManager, fragment);
logger.debug("FragmentMonitor %s.onFragmentResumed", fragment.getClass().getSimpleName());
Trace trace = new Trace(getFragmentScreenTraceName(fragment), this.transportManager, this.clock, this.appStateMonitor);
trace.start();
trace.putAttribute("Parent_fragment", fragment.getParentFragment() == null ? "No parent" : fragment.getParentFragment().getClass().getSimpleName());
if (fragment.getActivity() != null) {
trace.putAttribute("Hosting_activity", fragment.getActivity().getClass().getSimpleName());
}
this.fragmentToTraceMap.put(fragment, trace);
this.activityFramesRecorder.startFragment(fragment);
}
@Override // androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks
public void onFragmentPaused(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment) {
super.onFragmentPaused(fragmentManager, fragment);
AndroidLogger androidLogger = logger;
androidLogger.debug("FragmentMonitor %s.onFragmentPaused ", fragment.getClass().getSimpleName());
if (!this.fragmentToTraceMap.containsKey(fragment)) {
androidLogger.warn("FragmentMonitor: missed a fragment trace from %s", fragment.getClass().getSimpleName());
return;
}
Trace trace = this.fragmentToTraceMap.get(fragment);
this.fragmentToTraceMap.remove(fragment);
Optional stopFragment = this.activityFramesRecorder.stopFragment(fragment);
if (!stopFragment.isAvailable()) {
androidLogger.warn("onFragmentPaused: recorder failed to trace %s", fragment.getClass().getSimpleName());
} else {
ScreenTraceUtil.addFrameCounters(trace, (FrameMetricsCalculator.PerfFrameMetrics) stopFragment.get());
trace.stop();
}
}
}

View File

@@ -0,0 +1,121 @@
package com.google.firebase.perf.application;
import android.app.Activity;
import android.os.Build;
import android.util.SparseIntArray;
import androidx.core.app.FrameMetricsAggregator;
import androidx.fragment.app.Fragment;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.FrameMetricsCalculator;
import com.google.firebase.perf.util.Optional;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes3.dex */
public class FrameMetricsRecorder {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final Activity activity;
public final Map fragmentSnapshotMap;
public final FrameMetricsAggregator frameMetricsAggregator;
public boolean isRecording;
public static boolean isFrameMetricsRecordingSupported() {
return true;
}
public FrameMetricsRecorder(Activity activity) {
this(activity, new FrameMetricsAggregator(), new HashMap());
}
public FrameMetricsRecorder(Activity activity, FrameMetricsAggregator frameMetricsAggregator, Map map) {
this.isRecording = false;
this.activity = activity;
this.frameMetricsAggregator = frameMetricsAggregator;
this.fragmentSnapshotMap = map;
}
public void start() {
if (this.isRecording) {
logger.debug("FrameMetricsAggregator is already recording %s", this.activity.getClass().getSimpleName());
} else {
this.frameMetricsAggregator.add(this.activity);
this.isRecording = true;
}
}
public Optional stop() {
if (!this.isRecording) {
logger.debug("Cannot stop because no recording was started");
return Optional.absent();
}
if (!this.fragmentSnapshotMap.isEmpty()) {
logger.debug("Sub-recordings are still ongoing! Sub-recordings should be stopped first before stopping Activity screen trace.");
this.fragmentSnapshotMap.clear();
}
Optional snapshot = snapshot();
try {
this.frameMetricsAggregator.remove(this.activity);
} catch (IllegalArgumentException | NullPointerException e) {
if ((e instanceof NullPointerException) && Build.VERSION.SDK_INT > 28) {
throw e;
}
logger.warn("View not hardware accelerated. Unable to collect FrameMetrics. %s", e.toString());
snapshot = Optional.absent();
}
this.frameMetricsAggregator.reset();
this.isRecording = false;
return snapshot;
}
public void startFragment(Fragment fragment) {
if (!this.isRecording) {
logger.debug("Cannot start sub-recording because FrameMetricsAggregator is not recording");
return;
}
if (this.fragmentSnapshotMap.containsKey(fragment)) {
logger.debug("Cannot start sub-recording because one is already ongoing with the key %s", fragment.getClass().getSimpleName());
return;
}
Optional snapshot = snapshot();
if (!snapshot.isAvailable()) {
logger.debug("startFragment(%s): snapshot() failed", fragment.getClass().getSimpleName());
} else {
this.fragmentSnapshotMap.put(fragment, (FrameMetricsCalculator.PerfFrameMetrics) snapshot.get());
}
}
public Optional stopFragment(Fragment fragment) {
if (!this.isRecording) {
logger.debug("Cannot stop sub-recording because FrameMetricsAggregator is not recording");
return Optional.absent();
}
if (!this.fragmentSnapshotMap.containsKey(fragment)) {
logger.debug("Sub-recording associated with key %s was not started or does not exist", fragment.getClass().getSimpleName());
return Optional.absent();
}
FrameMetricsCalculator.PerfFrameMetrics perfFrameMetrics = (FrameMetricsCalculator.PerfFrameMetrics) this.fragmentSnapshotMap.remove(fragment);
Optional snapshot = snapshot();
if (!snapshot.isAvailable()) {
logger.debug("stopFragment(%s): snapshot() failed", fragment.getClass().getSimpleName());
return Optional.absent();
}
return Optional.of(((FrameMetricsCalculator.PerfFrameMetrics) snapshot.get()).deltaFrameMetricsFromSnapshot(perfFrameMetrics));
}
public final Optional snapshot() {
if (!this.isRecording) {
logger.debug("No recording has been started.");
return Optional.absent();
}
SparseIntArray[] metrics = this.frameMetricsAggregator.getMetrics();
if (metrics == null) {
logger.debug("FrameMetricsAggregator.mMetrics is uninitialized.");
return Optional.absent();
}
if (metrics[0] == null) {
logger.debug("FrameMetricsAggregator.mMetrics[TOTAL_INDEX] is uninitialized.");
return Optional.absent();
}
return Optional.of(FrameMetricsCalculator.calculateFrameMetrics(metrics));
}
}

View File

@@ -0,0 +1,483 @@
package com.google.firebase.perf.config;
import android.content.Context;
import com.google.firebase.perf.BuildConfig;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.ImmutableBundle;
import com.google.firebase.perf.util.Optional;
import com.google.firebase.perf.util.Utils;
/* loaded from: classes3.dex */
public class ConfigResolver {
public static volatile ConfigResolver instance;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public DeviceCacheManager deviceCacheManager;
public ImmutableBundle metadataBundle;
public final RemoteConfigManager remoteConfigManager;
public final boolean isEventCountValid(long j) {
return j >= 0;
}
public final boolean isGaugeCaptureFrequencyMsValid(long j) {
return j >= 0;
}
public final boolean isSamplingRateValid(double d) {
return 0.0d <= d && d <= 1.0d;
}
public final boolean isSessionsMaxDurationMinutesValid(long j) {
return j > 0;
}
public final boolean isTimeRangeSecValid(long j) {
return j > 0;
}
public void setMetadataBundle(ImmutableBundle immutableBundle) {
this.metadataBundle = immutableBundle;
}
public ConfigResolver(RemoteConfigManager remoteConfigManager, ImmutableBundle immutableBundle, DeviceCacheManager deviceCacheManager) {
this.remoteConfigManager = remoteConfigManager == null ? RemoteConfigManager.getInstance() : remoteConfigManager;
this.metadataBundle = immutableBundle == null ? new ImmutableBundle() : immutableBundle;
this.deviceCacheManager = deviceCacheManager == null ? DeviceCacheManager.getInstance() : deviceCacheManager;
}
public static synchronized ConfigResolver getInstance() {
ConfigResolver configResolver;
synchronized (ConfigResolver.class) {
try {
if (instance == null) {
instance = new ConfigResolver(null, null, null);
}
configResolver = instance;
} catch (Throwable th) {
throw th;
}
}
return configResolver;
}
public void setApplicationContext(Context context) {
logger.setLogcatEnabled(Utils.isDebugLoggingEnabled(context));
this.deviceCacheManager.setContext(context);
}
public boolean isPerformanceMonitoringEnabled() {
Boolean isPerformanceCollectionEnabled = getIsPerformanceCollectionEnabled();
return (isPerformanceCollectionEnabled == null || isPerformanceCollectionEnabled.booleanValue()) && getIsServiceCollectionEnabled();
}
public Boolean getIsPerformanceCollectionEnabled() {
if (getIsPerformanceCollectionDeactivated().booleanValue()) {
return Boolean.FALSE;
}
ConfigurationConstants$CollectionEnabled configurationConstants$CollectionEnabled = ConfigurationConstants$CollectionEnabled.getInstance();
Optional deviceCacheBoolean = getDeviceCacheBoolean(configurationConstants$CollectionEnabled);
if (deviceCacheBoolean.isAvailable()) {
return (Boolean) deviceCacheBoolean.get();
}
Optional metadataBoolean = getMetadataBoolean(configurationConstants$CollectionEnabled);
if (metadataBoolean.isAvailable()) {
return (Boolean) metadataBoolean.get();
}
return null;
}
public Boolean getIsPerformanceCollectionDeactivated() {
ConfigurationConstants$CollectionDeactivated configurationConstants$CollectionDeactivated = ConfigurationConstants$CollectionDeactivated.getInstance();
Optional metadataBoolean = getMetadataBoolean(configurationConstants$CollectionDeactivated);
if (metadataBoolean.isAvailable()) {
return (Boolean) metadataBoolean.get();
}
return configurationConstants$CollectionDeactivated.getDefault();
}
public void setIsPerformanceCollectionEnabled(Boolean bool) {
String deviceCacheFlag;
if (getIsPerformanceCollectionDeactivated().booleanValue() || (deviceCacheFlag = ConfigurationConstants$CollectionEnabled.getInstance().getDeviceCacheFlag()) == null) {
return;
}
if (bool != null) {
this.deviceCacheManager.setValue(deviceCacheFlag, Boolean.TRUE.equals(bool));
} else {
this.deviceCacheManager.clear(deviceCacheFlag);
}
}
public boolean getIsServiceCollectionEnabled() {
return getIsSdkEnabled() && !getIsSdkVersionDisabled();
}
public final boolean getIsSdkEnabled() {
ConfigurationConstants$SdkEnabled configurationConstants$SdkEnabled = ConfigurationConstants$SdkEnabled.getInstance();
Optional remoteConfigBoolean = getRemoteConfigBoolean(configurationConstants$SdkEnabled);
if (remoteConfigBoolean.isAvailable()) {
if (this.remoteConfigManager.isLastFetchFailed()) {
return false;
}
this.deviceCacheManager.setValue(configurationConstants$SdkEnabled.getDeviceCacheFlag(), ((Boolean) remoteConfigBoolean.get()).booleanValue());
return ((Boolean) remoteConfigBoolean.get()).booleanValue();
}
Optional deviceCacheBoolean = getDeviceCacheBoolean(configurationConstants$SdkEnabled);
if (deviceCacheBoolean.isAvailable()) {
return ((Boolean) deviceCacheBoolean.get()).booleanValue();
}
return configurationConstants$SdkEnabled.getDefault().booleanValue();
}
public final boolean getIsSdkVersionDisabled() {
ConfigurationConstants$SdkDisabledVersions configurationConstants$SdkDisabledVersions = ConfigurationConstants$SdkDisabledVersions.getInstance();
Optional remoteConfigString = getRemoteConfigString(configurationConstants$SdkDisabledVersions);
if (remoteConfigString.isAvailable()) {
this.deviceCacheManager.setValue(configurationConstants$SdkDisabledVersions.getDeviceCacheFlag(), (String) remoteConfigString.get());
return isFireperfSdkVersionInList((String) remoteConfigString.get());
}
Optional deviceCacheString = getDeviceCacheString(configurationConstants$SdkDisabledVersions);
if (deviceCacheString.isAvailable()) {
return isFireperfSdkVersionInList((String) deviceCacheString.get());
}
return isFireperfSdkVersionInList(configurationConstants$SdkDisabledVersions.getDefault());
}
public final boolean isFireperfSdkVersionInList(String str) {
if (str.trim().isEmpty()) {
return false;
}
for (String str2 : str.split(";")) {
if (str2.trim().equals(BuildConfig.FIREPERF_VERSION_NAME)) {
return true;
}
}
return false;
}
public double getTraceSamplingRate() {
ConfigurationConstants$TraceSamplingRate configurationConstants$TraceSamplingRate = ConfigurationConstants$TraceSamplingRate.getInstance();
Optional remoteConfigDouble = getRemoteConfigDouble(configurationConstants$TraceSamplingRate);
if (remoteConfigDouble.isAvailable() && isSamplingRateValid(((Double) remoteConfigDouble.get()).doubleValue())) {
this.deviceCacheManager.setValue(configurationConstants$TraceSamplingRate.getDeviceCacheFlag(), ((Double) remoteConfigDouble.get()).doubleValue());
return ((Double) remoteConfigDouble.get()).doubleValue();
}
Optional deviceCacheDouble = getDeviceCacheDouble(configurationConstants$TraceSamplingRate);
if (deviceCacheDouble.isAvailable() && isSamplingRateValid(((Double) deviceCacheDouble.get()).doubleValue())) {
return ((Double) deviceCacheDouble.get()).doubleValue();
}
if (this.remoteConfigManager.isLastFetchFailed()) {
return configurationConstants$TraceSamplingRate.getDefaultOnRcFetchFail().doubleValue();
}
return configurationConstants$TraceSamplingRate.getDefault().doubleValue();
}
public double getNetworkRequestSamplingRate() {
ConfigurationConstants$NetworkRequestSamplingRate configurationConstants$NetworkRequestSamplingRate = ConfigurationConstants$NetworkRequestSamplingRate.getInstance();
Optional remoteConfigDouble = getRemoteConfigDouble(configurationConstants$NetworkRequestSamplingRate);
if (remoteConfigDouble.isAvailable() && isSamplingRateValid(((Double) remoteConfigDouble.get()).doubleValue())) {
this.deviceCacheManager.setValue(configurationConstants$NetworkRequestSamplingRate.getDeviceCacheFlag(), ((Double) remoteConfigDouble.get()).doubleValue());
return ((Double) remoteConfigDouble.get()).doubleValue();
}
Optional deviceCacheDouble = getDeviceCacheDouble(configurationConstants$NetworkRequestSamplingRate);
if (deviceCacheDouble.isAvailable() && isSamplingRateValid(((Double) deviceCacheDouble.get()).doubleValue())) {
return ((Double) deviceCacheDouble.get()).doubleValue();
}
if (this.remoteConfigManager.isLastFetchFailed()) {
return configurationConstants$NetworkRequestSamplingRate.getDefaultOnRcFetchFail().doubleValue();
}
return configurationConstants$NetworkRequestSamplingRate.getDefault().doubleValue();
}
public double getSessionsSamplingRate() {
ConfigurationConstants$SessionsSamplingRate configurationConstants$SessionsSamplingRate = ConfigurationConstants$SessionsSamplingRate.getInstance();
Optional metadataDouble = getMetadataDouble(configurationConstants$SessionsSamplingRate);
if (metadataDouble.isAvailable()) {
double doubleValue = ((Double) metadataDouble.get()).doubleValue() / 100.0d;
if (isSamplingRateValid(doubleValue)) {
return doubleValue;
}
}
Optional remoteConfigDouble = getRemoteConfigDouble(configurationConstants$SessionsSamplingRate);
if (remoteConfigDouble.isAvailable() && isSamplingRateValid(((Double) remoteConfigDouble.get()).doubleValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsSamplingRate.getDeviceCacheFlag(), ((Double) remoteConfigDouble.get()).doubleValue());
return ((Double) remoteConfigDouble.get()).doubleValue();
}
Optional deviceCacheDouble = getDeviceCacheDouble(configurationConstants$SessionsSamplingRate);
if (deviceCacheDouble.isAvailable() && isSamplingRateValid(((Double) deviceCacheDouble.get()).doubleValue())) {
return ((Double) deviceCacheDouble.get()).doubleValue();
}
if (this.remoteConfigManager.isLastFetchFailed()) {
return configurationConstants$SessionsSamplingRate.getDefaultOnRcFetchFail().doubleValue();
}
return configurationConstants$SessionsSamplingRate.getDefault().doubleValue();
}
public long getSessionsCpuCaptureFrequencyForegroundMs() {
ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs configurationConstants$SessionsCpuCaptureFrequencyForegroundMs = ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs.getInstance();
Optional metadataLong = getMetadataLong(configurationConstants$SessionsCpuCaptureFrequencyForegroundMs);
if (metadataLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) metadataLong.get()).longValue())) {
return ((Long) metadataLong.get()).longValue();
}
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$SessionsCpuCaptureFrequencyForegroundMs);
if (remoteConfigLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsCpuCaptureFrequencyForegroundMs.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$SessionsCpuCaptureFrequencyForegroundMs);
if (deviceCacheLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
if (this.remoteConfigManager.isLastFetchFailed()) {
return configurationConstants$SessionsCpuCaptureFrequencyForegroundMs.getDefaultOnRcFetchFail().longValue();
}
return configurationConstants$SessionsCpuCaptureFrequencyForegroundMs.getDefault().longValue();
}
public long getSessionsCpuCaptureFrequencyBackgroundMs() {
ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs = ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs.getInstance();
Optional metadataLong = getMetadataLong(configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs);
if (metadataLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) metadataLong.get()).longValue())) {
return ((Long) metadataLong.get()).longValue();
}
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs);
if (remoteConfigLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs);
if (deviceCacheLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs.getDefault().longValue();
}
public long getSessionsMemoryCaptureFrequencyForegroundMs() {
ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs = ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs.getInstance();
Optional metadataLong = getMetadataLong(configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs);
if (metadataLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) metadataLong.get()).longValue())) {
return ((Long) metadataLong.get()).longValue();
}
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs);
if (remoteConfigLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs);
if (deviceCacheLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
if (this.remoteConfigManager.isLastFetchFailed()) {
return configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs.getDefaultOnRcFetchFail().longValue();
}
return configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs.getDefault().longValue();
}
public long getSessionsMemoryCaptureFrequencyBackgroundMs() {
ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs = ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs.getInstance();
Optional metadataLong = getMetadataLong(configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs);
if (metadataLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) metadataLong.get()).longValue())) {
return ((Long) metadataLong.get()).longValue();
}
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs);
if (remoteConfigLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs);
if (deviceCacheLong.isAvailable() && isGaugeCaptureFrequencyMsValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs.getDefault().longValue();
}
public long getSessionsMaxDurationMinutes() {
ConfigurationConstants$SessionsMaxDurationMinutes configurationConstants$SessionsMaxDurationMinutes = ConfigurationConstants$SessionsMaxDurationMinutes.getInstance();
Optional metadataLong = getMetadataLong(configurationConstants$SessionsMaxDurationMinutes);
if (metadataLong.isAvailable() && isSessionsMaxDurationMinutesValid(((Long) metadataLong.get()).longValue())) {
return ((Long) metadataLong.get()).longValue();
}
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$SessionsMaxDurationMinutes);
if (remoteConfigLong.isAvailable() && isSessionsMaxDurationMinutesValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$SessionsMaxDurationMinutes.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$SessionsMaxDurationMinutes);
if (deviceCacheLong.isAvailable() && isSessionsMaxDurationMinutesValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$SessionsMaxDurationMinutes.getDefault().longValue();
}
public long getTraceEventCountForeground() {
ConfigurationConstants$TraceEventCountForeground configurationConstants$TraceEventCountForeground = ConfigurationConstants$TraceEventCountForeground.getInstance();
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$TraceEventCountForeground);
if (remoteConfigLong.isAvailable() && isEventCountValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$TraceEventCountForeground.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$TraceEventCountForeground);
if (deviceCacheLong.isAvailable() && isEventCountValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$TraceEventCountForeground.getDefault().longValue();
}
public long getTraceEventCountBackground() {
ConfigurationConstants$TraceEventCountBackground configurationConstants$TraceEventCountBackground = ConfigurationConstants$TraceEventCountBackground.getInstance();
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$TraceEventCountBackground);
if (remoteConfigLong.isAvailable() && isEventCountValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$TraceEventCountBackground.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$TraceEventCountBackground);
if (deviceCacheLong.isAvailable() && isEventCountValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$TraceEventCountBackground.getDefault().longValue();
}
public long getNetworkEventCountForeground() {
ConfigurationConstants$NetworkEventCountForeground configurationConstants$NetworkEventCountForeground = ConfigurationConstants$NetworkEventCountForeground.getInstance();
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$NetworkEventCountForeground);
if (remoteConfigLong.isAvailable() && isEventCountValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$NetworkEventCountForeground.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$NetworkEventCountForeground);
if (deviceCacheLong.isAvailable() && isEventCountValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$NetworkEventCountForeground.getDefault().longValue();
}
public long getNetworkEventCountBackground() {
ConfigurationConstants$NetworkEventCountBackground configurationConstants$NetworkEventCountBackground = ConfigurationConstants$NetworkEventCountBackground.getInstance();
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$NetworkEventCountBackground);
if (remoteConfigLong.isAvailable() && isEventCountValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$NetworkEventCountBackground.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$NetworkEventCountBackground);
if (deviceCacheLong.isAvailable() && isEventCountValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$NetworkEventCountBackground.getDefault().longValue();
}
public long getRateLimitSec() {
ConfigurationConstants$RateLimitSec configurationConstants$RateLimitSec = ConfigurationConstants$RateLimitSec.getInstance();
Optional remoteConfigLong = getRemoteConfigLong(configurationConstants$RateLimitSec);
if (remoteConfigLong.isAvailable() && isTimeRangeSecValid(((Long) remoteConfigLong.get()).longValue())) {
this.deviceCacheManager.setValue(configurationConstants$RateLimitSec.getDeviceCacheFlag(), ((Long) remoteConfigLong.get()).longValue());
return ((Long) remoteConfigLong.get()).longValue();
}
Optional deviceCacheLong = getDeviceCacheLong(configurationConstants$RateLimitSec);
if (deviceCacheLong.isAvailable() && isTimeRangeSecValid(((Long) deviceCacheLong.get()).longValue())) {
return ((Long) deviceCacheLong.get()).longValue();
}
return configurationConstants$RateLimitSec.getDefault().longValue();
}
public String getAndCacheLogSourceName() {
String logSourceName;
ConfigurationConstants$LogSourceName configurationConstants$LogSourceName = ConfigurationConstants$LogSourceName.getInstance();
if (BuildConfig.ENFORCE_DEFAULT_LOG_SRC.booleanValue()) {
return configurationConstants$LogSourceName.getDefault();
}
String remoteConfigFlag = configurationConstants$LogSourceName.getRemoteConfigFlag();
long longValue = remoteConfigFlag != null ? ((Long) this.remoteConfigManager.getRemoteConfigValueOrDefault(remoteConfigFlag, -1L)).longValue() : -1L;
String deviceCacheFlag = configurationConstants$LogSourceName.getDeviceCacheFlag();
if (ConfigurationConstants$LogSourceName.isLogSourceKnown(longValue) && (logSourceName = ConfigurationConstants$LogSourceName.getLogSourceName(longValue)) != null) {
this.deviceCacheManager.setValue(deviceCacheFlag, logSourceName);
return logSourceName;
}
Optional deviceCacheString = getDeviceCacheString(configurationConstants$LogSourceName);
if (deviceCacheString.isAvailable()) {
return (String) deviceCacheString.get();
}
return configurationConstants$LogSourceName.getDefault();
}
public double getFragmentSamplingRate() {
ConfigurationConstants$FragmentSamplingRate configurationConstants$FragmentSamplingRate = ConfigurationConstants$FragmentSamplingRate.getInstance();
Optional metadataDouble = getMetadataDouble(configurationConstants$FragmentSamplingRate);
if (metadataDouble.isAvailable()) {
double doubleValue = ((Double) metadataDouble.get()).doubleValue() / 100.0d;
if (isSamplingRateValid(doubleValue)) {
return doubleValue;
}
}
Optional remoteConfigDouble = getRemoteConfigDouble(configurationConstants$FragmentSamplingRate);
if (remoteConfigDouble.isAvailable() && isSamplingRateValid(((Double) remoteConfigDouble.get()).doubleValue())) {
this.deviceCacheManager.setValue(configurationConstants$FragmentSamplingRate.getDeviceCacheFlag(), ((Double) remoteConfigDouble.get()).doubleValue());
return ((Double) remoteConfigDouble.get()).doubleValue();
}
Optional deviceCacheDouble = getDeviceCacheDouble(configurationConstants$FragmentSamplingRate);
if (deviceCacheDouble.isAvailable() && isSamplingRateValid(((Double) deviceCacheDouble.get()).doubleValue())) {
return ((Double) deviceCacheDouble.get()).doubleValue();
}
return configurationConstants$FragmentSamplingRate.getDefault().doubleValue();
}
public boolean getIsExperimentTTIDEnabled() {
ConfigurationConstants$ExperimentTTID configurationConstants$ExperimentTTID = ConfigurationConstants$ExperimentTTID.getInstance();
Optional metadataBoolean = getMetadataBoolean(configurationConstants$ExperimentTTID);
if (metadataBoolean.isAvailable()) {
return ((Boolean) metadataBoolean.get()).booleanValue();
}
Optional remoteConfigBoolean = getRemoteConfigBoolean(configurationConstants$ExperimentTTID);
if (remoteConfigBoolean.isAvailable()) {
this.deviceCacheManager.setValue(configurationConstants$ExperimentTTID.getDeviceCacheFlag(), ((Boolean) remoteConfigBoolean.get()).booleanValue());
return ((Boolean) remoteConfigBoolean.get()).booleanValue();
}
Optional deviceCacheBoolean = getDeviceCacheBoolean(configurationConstants$ExperimentTTID);
if (deviceCacheBoolean.isAvailable()) {
return ((Boolean) deviceCacheBoolean.get()).booleanValue();
}
return configurationConstants$ExperimentTTID.getDefault().booleanValue();
}
public final Optional getMetadataBoolean(ConfigurationFlag configurationFlag) {
return this.metadataBundle.getBoolean(configurationFlag.getMetadataFlag());
}
public final Optional getMetadataDouble(ConfigurationFlag configurationFlag) {
return this.metadataBundle.getDouble(configurationFlag.getMetadataFlag());
}
public final Optional getMetadataLong(ConfigurationFlag configurationFlag) {
return this.metadataBundle.getLong(configurationFlag.getMetadataFlag());
}
public final Optional getRemoteConfigDouble(ConfigurationFlag configurationFlag) {
return this.remoteConfigManager.getDouble(configurationFlag.getRemoteConfigFlag());
}
public final Optional getRemoteConfigLong(ConfigurationFlag configurationFlag) {
return this.remoteConfigManager.getLong(configurationFlag.getRemoteConfigFlag());
}
public final Optional getRemoteConfigBoolean(ConfigurationFlag configurationFlag) {
return this.remoteConfigManager.getBoolean(configurationFlag.getRemoteConfigFlag());
}
public final Optional getRemoteConfigString(ConfigurationFlag configurationFlag) {
return this.remoteConfigManager.getString(configurationFlag.getRemoteConfigFlag());
}
public final Optional getDeviceCacheDouble(ConfigurationFlag configurationFlag) {
return this.deviceCacheManager.getDouble(configurationFlag.getDeviceCacheFlag());
}
public final Optional getDeviceCacheLong(ConfigurationFlag configurationFlag) {
return this.deviceCacheManager.getLong(configurationFlag.getDeviceCacheFlag());
}
public final Optional getDeviceCacheBoolean(ConfigurationFlag configurationFlag) {
return this.deviceCacheManager.getBoolean(configurationFlag.getDeviceCacheFlag());
}
public final Optional getDeviceCacheString(ConfigurationFlag configurationFlag) {
return this.deviceCacheManager.getString(configurationFlag.getDeviceCacheFlag());
}
}

View File

@@ -0,0 +1,30 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$CollectionDeactivated extends ConfigurationFlag {
public static ConfigurationConstants$CollectionDeactivated instance;
public Boolean getDefault() {
return Boolean.FALSE;
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "firebase_performance_collection_deactivated";
}
public static synchronized ConfigurationConstants$CollectionDeactivated getInstance() {
ConfigurationConstants$CollectionDeactivated configurationConstants$CollectionDeactivated;
synchronized (ConfigurationConstants$CollectionDeactivated.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$CollectionDeactivated();
}
configurationConstants$CollectionDeactivated = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$CollectionDeactivated;
}
}

View File

@@ -0,0 +1,31 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$CollectionEnabled extends ConfigurationFlag {
public static ConfigurationConstants$CollectionEnabled instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "isEnabled";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "firebase_performance_collection_enabled";
}
public static synchronized ConfigurationConstants$CollectionEnabled getInstance() {
ConfigurationConstants$CollectionEnabled configurationConstants$CollectionEnabled;
synchronized (ConfigurationConstants$CollectionEnabled.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$CollectionEnabled();
}
configurationConstants$CollectionEnabled = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$CollectionEnabled;
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$ExperimentTTID extends ConfigurationFlag {
public static ConfigurationConstants$ExperimentTTID instance;
public Boolean getDefault() {
return Boolean.FALSE;
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.ExperimentTTID";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "experiment_app_start_ttid";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_experiment_app_start_ttid";
}
public static synchronized ConfigurationConstants$ExperimentTTID getInstance() {
ConfigurationConstants$ExperimentTTID configurationConstants$ExperimentTTID;
synchronized (ConfigurationConstants$ExperimentTTID.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$ExperimentTTID();
}
configurationConstants$ExperimentTTID = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$ExperimentTTID;
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$FragmentSamplingRate extends ConfigurationFlag {
public static ConfigurationConstants$FragmentSamplingRate instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.FragmentSamplingRate";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "fragment_sampling_percentage";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_vc_fragment_sampling_rate";
}
public static synchronized ConfigurationConstants$FragmentSamplingRate getInstance() {
ConfigurationConstants$FragmentSamplingRate configurationConstants$FragmentSamplingRate;
synchronized (ConfigurationConstants$FragmentSamplingRate.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$FragmentSamplingRate();
}
configurationConstants$FragmentSamplingRate = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$FragmentSamplingRate;
}
public Double getDefault() {
return Double.valueOf(0.0d);
}
}

View File

@@ -0,0 +1,56 @@
package com.google.firebase.perf.config;
import com.google.firebase.perf.BuildConfig;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$LogSourceName extends ConfigurationFlag {
public static final Map LOG_SOURCE_MAP = Collections.unmodifiableMap(new HashMap() { // from class: com.google.firebase.perf.config.ConfigurationConstants$LogSourceName.1
{
put(461L, "FIREPERF_AUTOPUSH");
put(462L, "FIREPERF");
put(675L, "FIREPERF_INTERNAL_LOW");
put(676L, "FIREPERF_INTERNAL_HIGH");
}
});
public static ConfigurationConstants$LogSourceName instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.LogSourceName";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_log_source";
}
public static synchronized ConfigurationConstants$LogSourceName getInstance() {
ConfigurationConstants$LogSourceName configurationConstants$LogSourceName;
synchronized (ConfigurationConstants$LogSourceName.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$LogSourceName();
}
configurationConstants$LogSourceName = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$LogSourceName;
}
public static String getLogSourceName(long j) {
return (String) LOG_SOURCE_MAP.get(Long.valueOf(j));
}
public static boolean isLogSourceKnown(long j) {
return LOG_SOURCE_MAP.containsKey(Long.valueOf(j));
}
public String getDefault() {
return BuildConfig.TRANSPORT_LOG_SRC;
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$NetworkEventCountBackground extends ConfigurationFlag {
public static ConfigurationConstants$NetworkEventCountBackground instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.NetworkEventCountBackground";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_rl_network_event_count_bg";
}
public static synchronized ConfigurationConstants$NetworkEventCountBackground getInstance() {
ConfigurationConstants$NetworkEventCountBackground configurationConstants$NetworkEventCountBackground;
synchronized (ConfigurationConstants$NetworkEventCountBackground.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$NetworkEventCountBackground();
}
configurationConstants$NetworkEventCountBackground = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$NetworkEventCountBackground;
}
public Long getDefault() {
return 70L;
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$NetworkEventCountForeground extends ConfigurationFlag {
public static ConfigurationConstants$NetworkEventCountForeground instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.NetworkEventCountForeground";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_rl_network_event_count_fg";
}
public static synchronized ConfigurationConstants$NetworkEventCountForeground getInstance() {
ConfigurationConstants$NetworkEventCountForeground configurationConstants$NetworkEventCountForeground;
synchronized (ConfigurationConstants$NetworkEventCountForeground.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$NetworkEventCountForeground();
}
configurationConstants$NetworkEventCountForeground = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$NetworkEventCountForeground;
}
public Long getDefault() {
return 700L;
}
}

View File

@@ -0,0 +1,39 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$NetworkRequestSamplingRate extends ConfigurationFlag {
public static ConfigurationConstants$NetworkRequestSamplingRate instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.NetworkRequestSamplingRate";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_vc_network_request_sampling_rate";
}
public static synchronized ConfigurationConstants$NetworkRequestSamplingRate getInstance() {
ConfigurationConstants$NetworkRequestSamplingRate configurationConstants$NetworkRequestSamplingRate;
synchronized (ConfigurationConstants$NetworkRequestSamplingRate.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$NetworkRequestSamplingRate();
}
configurationConstants$NetworkRequestSamplingRate = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$NetworkRequestSamplingRate;
}
public Double getDefault() {
return Double.valueOf(1.0d);
}
public Double getDefaultOnRcFetchFail() {
return Double.valueOf(getDefault().doubleValue() / 1000.0d);
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$RateLimitSec extends ConfigurationFlag {
public static ConfigurationConstants$RateLimitSec instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.TimeLimitSec";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_rl_time_limit_sec";
}
public static synchronized ConfigurationConstants$RateLimitSec getInstance() {
ConfigurationConstants$RateLimitSec configurationConstants$RateLimitSec;
synchronized (ConfigurationConstants$RateLimitSec.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$RateLimitSec();
}
configurationConstants$RateLimitSec = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$RateLimitSec;
}
public Long getDefault() {
return 600L;
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SdkDisabledVersions extends ConfigurationFlag {
public static ConfigurationConstants$SdkDisabledVersions instance;
public String getDefault() {
return "";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SdkDisabledVersions";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_disabled_android_versions";
}
public static synchronized ConfigurationConstants$SdkDisabledVersions getInstance() {
ConfigurationConstants$SdkDisabledVersions configurationConstants$SdkDisabledVersions;
synchronized (ConfigurationConstants$SdkDisabledVersions.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SdkDisabledVersions();
}
configurationConstants$SdkDisabledVersions = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SdkDisabledVersions;
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SdkEnabled extends ConfigurationFlag {
public static ConfigurationConstants$SdkEnabled instance;
public Boolean getDefault() {
return Boolean.TRUE;
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SdkEnabled";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_enabled";
}
public static synchronized ConfigurationConstants$SdkEnabled getInstance() {
ConfigurationConstants$SdkEnabled configurationConstants$SdkEnabled;
synchronized (ConfigurationConstants$SdkEnabled.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SdkEnabled();
}
configurationConstants$SdkEnabled = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SdkEnabled;
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs extends ConfigurationFlag {
public static ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionsCpuCaptureFrequencyBackgroundMs";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_cpu_capture_frequency_bg_ms";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_session_gauge_cpu_capture_frequency_bg_ms";
}
public static synchronized ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs getInstance() {
ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs;
synchronized (ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsCpuCaptureFrequencyBackgroundMs();
}
configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsCpuCaptureFrequencyBackgroundMs;
}
public Long getDefault() {
return 0L;
}
}

View File

@@ -0,0 +1,44 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs extends ConfigurationFlag {
public static ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionsCpuCaptureFrequencyForegroundMs";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_cpu_capture_frequency_fg_ms";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_session_gauge_cpu_capture_frequency_fg_ms";
}
public static synchronized ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs getInstance() {
ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs configurationConstants$SessionsCpuCaptureFrequencyForegroundMs;
synchronized (ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsCpuCaptureFrequencyForegroundMs();
}
configurationConstants$SessionsCpuCaptureFrequencyForegroundMs = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsCpuCaptureFrequencyForegroundMs;
}
public Long getDefault() {
return 100L;
}
public Long getDefaultOnRcFetchFail() {
return Long.valueOf(getDefault().longValue() * 3);
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsMaxDurationMinutes extends ConfigurationFlag {
public static ConfigurationConstants$SessionsMaxDurationMinutes instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionsMaxDurationMinutes";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_max_length_minutes";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_session_max_duration_min";
}
public static synchronized ConfigurationConstants$SessionsMaxDurationMinutes getInstance() {
ConfigurationConstants$SessionsMaxDurationMinutes configurationConstants$SessionsMaxDurationMinutes;
synchronized (ConfigurationConstants$SessionsMaxDurationMinutes.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsMaxDurationMinutes();
}
configurationConstants$SessionsMaxDurationMinutes = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsMaxDurationMinutes;
}
public Long getDefault() {
return 240L;
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs extends ConfigurationFlag {
public static ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionsMemoryCaptureFrequencyBackgroundMs";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_memory_capture_frequency_bg_ms";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_session_gauge_memory_capture_frequency_bg_ms";
}
public static synchronized ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs getInstance() {
ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs;
synchronized (ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs();
}
configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsMemoryCaptureFrequencyBackgroundMs;
}
public Long getDefault() {
return 0L;
}
}

View File

@@ -0,0 +1,44 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs extends ConfigurationFlag {
public static ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionsMemoryCaptureFrequencyForegroundMs";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_memory_capture_frequency_fg_ms";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_session_gauge_memory_capture_frequency_fg_ms";
}
public static synchronized ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs getInstance() {
ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs;
synchronized (ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsMemoryCaptureFrequencyForegroundMs();
}
configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsMemoryCaptureFrequencyForegroundMs;
}
public Long getDefault() {
return 100L;
}
public Long getDefaultOnRcFetchFail() {
return Long.valueOf(getDefault().longValue() * 3);
}
}

View File

@@ -0,0 +1,44 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$SessionsSamplingRate extends ConfigurationFlag {
public static ConfigurationConstants$SessionsSamplingRate instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.SessionSamplingRate";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getMetadataFlag() {
return "sessions_sampling_percentage";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_vc_session_sampling_rate";
}
public static synchronized ConfigurationConstants$SessionsSamplingRate getInstance() {
ConfigurationConstants$SessionsSamplingRate configurationConstants$SessionsSamplingRate;
synchronized (ConfigurationConstants$SessionsSamplingRate.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$SessionsSamplingRate();
}
configurationConstants$SessionsSamplingRate = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$SessionsSamplingRate;
}
public Double getDefault() {
return Double.valueOf(0.01d);
}
public Double getDefaultOnRcFetchFail() {
return Double.valueOf(getDefault().doubleValue() / 1000.0d);
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$TraceEventCountBackground extends ConfigurationFlag {
public static ConfigurationConstants$TraceEventCountBackground instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.TraceEventCountBackground";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_rl_trace_event_count_bg";
}
public static synchronized ConfigurationConstants$TraceEventCountBackground getInstance() {
ConfigurationConstants$TraceEventCountBackground configurationConstants$TraceEventCountBackground;
synchronized (ConfigurationConstants$TraceEventCountBackground.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$TraceEventCountBackground();
}
configurationConstants$TraceEventCountBackground = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$TraceEventCountBackground;
}
public Long getDefault() {
return 30L;
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$TraceEventCountForeground extends ConfigurationFlag {
public static ConfigurationConstants$TraceEventCountForeground instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.TraceEventCountForeground";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_rl_trace_event_count_fg";
}
public static synchronized ConfigurationConstants$TraceEventCountForeground getInstance() {
ConfigurationConstants$TraceEventCountForeground configurationConstants$TraceEventCountForeground;
synchronized (ConfigurationConstants$TraceEventCountForeground.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$TraceEventCountForeground();
}
configurationConstants$TraceEventCountForeground = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$TraceEventCountForeground;
}
public Long getDefault() {
return 300L;
}
}

View File

@@ -0,0 +1,39 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public final class ConfigurationConstants$TraceSamplingRate extends ConfigurationFlag {
public static ConfigurationConstants$TraceSamplingRate instance;
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getDeviceCacheFlag() {
return "com.google.firebase.perf.TraceSamplingRate";
}
@Override // com.google.firebase.perf.config.ConfigurationFlag
public String getRemoteConfigFlag() {
return "fpr_vc_trace_sampling_rate";
}
public static synchronized ConfigurationConstants$TraceSamplingRate getInstance() {
ConfigurationConstants$TraceSamplingRate configurationConstants$TraceSamplingRate;
synchronized (ConfigurationConstants$TraceSamplingRate.class) {
try {
if (instance == null) {
instance = new ConfigurationConstants$TraceSamplingRate();
}
configurationConstants$TraceSamplingRate = instance;
} catch (Throwable th) {
throw th;
}
}
return configurationConstants$TraceSamplingRate;
}
public Double getDefault() {
return Double.valueOf(1.0d);
}
public Double getDefaultOnRcFetchFail() {
return Double.valueOf(getDefault().doubleValue() / 1000.0d);
}
}

View File

@@ -0,0 +1,16 @@
package com.google.firebase.perf.config;
/* loaded from: classes3.dex */
public abstract class ConfigurationFlag {
public String getDeviceCacheFlag() {
return null;
}
public String getMetadataFlag() {
return null;
}
public String getRemoteConfigFlag() {
return null;
}
}

View File

@@ -0,0 +1,227 @@
package com.google.firebase.perf.config;
import android.content.Context;
import android.content.SharedPreferences;
import com.google.firebase.FirebaseApp;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/* loaded from: classes3.dex */
public class DeviceCacheManager {
public static DeviceCacheManager instance;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final ExecutorService serialExecutor;
public volatile SharedPreferences sharedPref;
public DeviceCacheManager(ExecutorService executorService) {
this.serialExecutor = executorService;
}
public static synchronized DeviceCacheManager getInstance() {
DeviceCacheManager deviceCacheManager;
synchronized (DeviceCacheManager.class) {
try {
if (instance == null) {
instance = new DeviceCacheManager(Executors.newSingleThreadExecutor());
}
deviceCacheManager = instance;
} catch (Throwable th) {
throw th;
}
}
return deviceCacheManager;
}
public synchronized void setContext(final Context context) {
if (this.sharedPref == null && context != null) {
this.serialExecutor.execute(new Runnable() { // from class: com.google.firebase.perf.config.DeviceCacheManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
DeviceCacheManager.this.lambda$setContext$0(context);
}
});
}
}
public final /* synthetic */ void lambda$setContext$0(Context context) {
if (this.sharedPref != null || context == null) {
return;
}
this.sharedPref = context.getSharedPreferences("FirebasePerfSharedPrefs", 0);
}
public Optional getBoolean(String str) {
if (str == null) {
logger.debug("Key is null when getting boolean value on device cache.");
return Optional.absent();
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return Optional.absent();
}
}
if (!this.sharedPref.contains(str)) {
return Optional.absent();
}
try {
return Optional.of(Boolean.valueOf(this.sharedPref.getBoolean(str, false)));
} catch (ClassCastException e) {
logger.debug("Key %s from sharedPreferences has type other than long: %s", str, e.getMessage());
return Optional.absent();
}
}
public void clear(String str) {
if (str == null) {
logger.debug("Key is null. Cannot clear nullable key");
} else {
this.sharedPref.edit().remove(str).apply();
}
}
public boolean setValue(String str, boolean z) {
if (str == null) {
logger.debug("Key is null when setting boolean value on device cache.");
return false;
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return false;
}
}
this.sharedPref.edit().putBoolean(str, z).apply();
return true;
}
public Optional getString(String str) {
if (str == null) {
logger.debug("Key is null when getting String value on device cache.");
return Optional.absent();
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return Optional.absent();
}
}
if (!this.sharedPref.contains(str)) {
return Optional.absent();
}
try {
return Optional.of(this.sharedPref.getString(str, ""));
} catch (ClassCastException e) {
logger.debug("Key %s from sharedPreferences has type other than String: %s", str, e.getMessage());
return Optional.absent();
}
}
public boolean setValue(String str, String str2) {
if (str == null) {
logger.debug("Key is null when setting String value on device cache.");
return false;
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return false;
}
}
if (str2 == null) {
this.sharedPref.edit().remove(str).apply();
return true;
}
this.sharedPref.edit().putString(str, str2).apply();
return true;
}
public Optional getDouble(String str) {
if (str == null) {
logger.debug("Key is null when getting double value on device cache.");
return Optional.absent();
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return Optional.absent();
}
}
if (!this.sharedPref.contains(str)) {
return Optional.absent();
}
try {
try {
return Optional.of(Double.valueOf(Double.longBitsToDouble(this.sharedPref.getLong(str, 0L))));
} catch (ClassCastException unused) {
return Optional.of(Double.valueOf(Float.valueOf(this.sharedPref.getFloat(str, 0.0f)).doubleValue()));
}
} catch (ClassCastException e) {
logger.debug("Key %s from sharedPreferences has type other than double: %s", str, e.getMessage());
return Optional.absent();
}
}
public boolean setValue(String str, double d) {
if (str == null) {
logger.debug("Key is null when setting double value on device cache.");
return false;
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return false;
}
}
this.sharedPref.edit().putLong(str, Double.doubleToRawLongBits(d)).apply();
return true;
}
public Optional getLong(String str) {
if (str == null) {
logger.debug("Key is null when getting long value on device cache.");
return Optional.absent();
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return Optional.absent();
}
}
if (!this.sharedPref.contains(str)) {
return Optional.absent();
}
try {
return Optional.of(Long.valueOf(this.sharedPref.getLong(str, 0L)));
} catch (ClassCastException e) {
logger.debug("Key %s from sharedPreferences has type other than long: %s", str, e.getMessage());
return Optional.absent();
}
}
public boolean setValue(String str, long j) {
if (str == null) {
logger.debug("Key is null when setting long value on device cache.");
return false;
}
if (this.sharedPref == null) {
setContext(getFirebaseApplicationContext());
if (this.sharedPref == null) {
return false;
}
}
this.sharedPref.edit().putLong(str, j).apply();
return true;
}
public final Context getFirebaseApplicationContext() {
try {
FirebaseApp.getInstance();
return FirebaseApp.getInstance().getApplicationContext();
} catch (IllegalStateException unused) {
return null;
}
}
}

View File

@@ -0,0 +1,305 @@
package com.google.firebase.perf.config;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.FirebaseApp;
import com.google.firebase.StartupTime;
import com.google.firebase.inject.Provider;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Optional;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
import com.google.firebase.remoteconfig.RemoteConfigComponent;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Keep
/* loaded from: classes3.dex */
public class RemoteConfigManager {
private static final long FETCH_NEVER_HAPPENED_TIMESTAMP_MS = 0;
private static final String FIREPERF_FRC_NAMESPACE_NAME = "fireperf";
private static final long MIN_APP_START_CONFIG_FETCH_DELAY_MS = 5000;
private static final int RANDOM_APP_START_CONFIG_FETCH_DELAY_MS = 25000;
private final ConcurrentHashMap<String, FirebaseRemoteConfigValue> allRcConfigMap;
private final long appStartConfigFetchDelayInMs;
private final long appStartTimeInMs;
private final DeviceCacheManager cache;
private final Executor executor;
@Nullable
private FirebaseRemoteConfig firebaseRemoteConfig;
private long firebaseRemoteConfigLastFetchTimestampMs;
@Nullable
private Provider firebaseRemoteConfigProvider;
private static final AndroidLogger logger = AndroidLogger.getInstance();
private static final RemoteConfigManager instance = new RemoteConfigManager();
private static final long TIME_AFTER_WHICH_A_FETCH_IS_CONSIDERED_STALE_MS = TimeUnit.HOURS.toMillis(12);
public static RemoteConfigManager getInstance() {
return instance;
}
private boolean hasAppStartConfigFetchDelayElapsed(long j) {
return j - this.appStartTimeInMs >= this.appStartConfigFetchDelayInMs;
}
private boolean hasLastFetchBecomeStale(long j) {
return j - this.firebaseRemoteConfigLastFetchTimestampMs > TIME_AFTER_WHICH_A_FETCH_IS_CONSIDERED_STALE_MS;
}
public void setFirebaseRemoteConfigProvider(@Nullable Provider provider) {
this.firebaseRemoteConfigProvider = provider;
}
@SuppressLint({"ThreadPoolCreation"})
private RemoteConfigManager() {
this(DeviceCacheManager.getInstance(), new ThreadPoolExecutor(0, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue()), null, new Random().nextInt(25000) + 5000, getInitialStartupMillis());
}
@VisibleForTesting
public static long getInitialStartupMillis() {
StartupTime startupTime = (StartupTime) FirebaseApp.getInstance().get(StartupTime.class);
if (startupTime != null) {
return startupTime.getEpochMillis();
}
return System.currentTimeMillis();
}
@VisibleForTesting
public RemoteConfigManager(DeviceCacheManager deviceCacheManager, Executor executor, FirebaseRemoteConfig firebaseRemoteConfig, long j, long j2) {
ConcurrentHashMap<String, FirebaseRemoteConfigValue> concurrentHashMap;
this.firebaseRemoteConfigLastFetchTimestampMs = 0L;
this.cache = deviceCacheManager;
this.executor = executor;
this.firebaseRemoteConfig = firebaseRemoteConfig;
if (firebaseRemoteConfig == null) {
concurrentHashMap = new ConcurrentHashMap<>();
} else {
concurrentHashMap = new ConcurrentHashMap<>((Map<? extends String, ? extends FirebaseRemoteConfigValue>) firebaseRemoteConfig.getAll());
}
this.allRcConfigMap = concurrentHashMap;
this.appStartTimeInMs = j2;
this.appStartConfigFetchDelayInMs = j;
}
public Optional getDouble(String str) {
if (str == null) {
logger.debug("The key to get Remote Config double value is null.");
return Optional.absent();
}
FirebaseRemoteConfigValue remoteConfigValue = getRemoteConfigValue(str);
if (remoteConfigValue != null) {
try {
return Optional.of(Double.valueOf(remoteConfigValue.asDouble()));
} catch (IllegalArgumentException unused) {
if (!remoteConfigValue.asString().isEmpty()) {
logger.debug("Could not parse value: '%s' for key: '%s'.", remoteConfigValue.asString(), str);
}
}
}
return Optional.absent();
}
public Optional getLong(String str) {
if (str == null) {
logger.debug("The key to get Remote Config long value is null.");
return Optional.absent();
}
FirebaseRemoteConfigValue remoteConfigValue = getRemoteConfigValue(str);
if (remoteConfigValue != null) {
try {
return Optional.of(Long.valueOf(remoteConfigValue.asLong()));
} catch (IllegalArgumentException unused) {
if (!remoteConfigValue.asString().isEmpty()) {
logger.debug("Could not parse value: '%s' for key: '%s'.", remoteConfigValue.asString(), str);
}
}
}
return Optional.absent();
}
public Optional getBoolean(String str) {
if (str == null) {
logger.debug("The key to get Remote Config boolean value is null.");
return Optional.absent();
}
FirebaseRemoteConfigValue remoteConfigValue = getRemoteConfigValue(str);
if (remoteConfigValue != null) {
try {
return Optional.of(Boolean.valueOf(remoteConfigValue.asBoolean()));
} catch (IllegalArgumentException unused) {
if (!remoteConfigValue.asString().isEmpty()) {
logger.debug("Could not parse value: '%s' for key: '%s'.", remoteConfigValue.asString(), str);
}
}
}
return Optional.absent();
}
public Optional getString(String str) {
if (str == null) {
logger.debug("The key to get Remote Config String value is null.");
return Optional.absent();
}
FirebaseRemoteConfigValue remoteConfigValue = getRemoteConfigValue(str);
if (remoteConfigValue != null) {
return Optional.of(remoteConfigValue.asString());
}
return Optional.absent();
}
/* JADX WARN: Multi-variable type inference failed */
public <T> T getRemoteConfigValueOrDefault(String str, T t) {
Object obj;
FirebaseRemoteConfigValue remoteConfigValue = getRemoteConfigValue(str);
if (remoteConfigValue == null) {
return t;
}
try {
if (t instanceof Boolean) {
obj = Boolean.valueOf(remoteConfigValue.asBoolean());
} else if (t instanceof Double) {
obj = Double.valueOf(remoteConfigValue.asDouble());
} else {
if (!(t instanceof Long) && !(t instanceof Integer)) {
if (t instanceof String) {
obj = remoteConfigValue.asString();
} else {
T t2 = (T) remoteConfigValue.asString();
try {
logger.debug("No matching type found for the defaultValue: '%s', using String.", t);
return t2;
} catch (IllegalArgumentException unused) {
t = t2;
if (remoteConfigValue.asString().isEmpty()) {
return t;
}
logger.debug("Could not parse value: '%s' for key: '%s'.", remoteConfigValue.asString(), str);
return t;
}
}
}
obj = Long.valueOf(remoteConfigValue.asLong());
}
return obj;
} catch (IllegalArgumentException unused2) {
}
}
private FirebaseRemoteConfigValue getRemoteConfigValue(String str) {
triggerRemoteConfigFetchIfNecessary();
if (!isFirebaseRemoteConfigAvailable() || !this.allRcConfigMap.containsKey(str)) {
return null;
}
FirebaseRemoteConfigValue firebaseRemoteConfigValue = this.allRcConfigMap.get(str);
if (firebaseRemoteConfigValue.getSource() != 2) {
return null;
}
logger.debug("Fetched value: '%s' for key: '%s' from Firebase Remote Config.", firebaseRemoteConfigValue.asString(), str);
return firebaseRemoteConfigValue;
}
public boolean isLastFetchFailed() {
FirebaseRemoteConfig firebaseRemoteConfig = this.firebaseRemoteConfig;
return firebaseRemoteConfig == null || firebaseRemoteConfig.getInfo().getLastFetchStatus() == 1 || this.firebaseRemoteConfig.getInfo().getLastFetchStatus() == 2;
}
private void triggerRemoteConfigFetchIfNecessary() {
if (isFirebaseRemoteConfigAvailable()) {
if (this.allRcConfigMap.isEmpty()) {
this.allRcConfigMap.putAll(this.firebaseRemoteConfig.getAll());
}
if (shouldFetchAndActivateRemoteConfigValues()) {
triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch();
}
}
}
private void triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch() {
this.firebaseRemoteConfigLastFetchTimestampMs = getCurrentSystemTimeMillis();
this.firebaseRemoteConfig.fetchAndActivate().addOnSuccessListener(this.executor, new OnSuccessListener() { // from class: com.google.firebase.perf.config.RemoteConfigManager$$ExternalSyntheticLambda0
@Override // com.google.android.gms.tasks.OnSuccessListener
public final void onSuccess(Object obj) {
RemoteConfigManager.this.lambda$triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch$0((Boolean) obj);
}
}).addOnFailureListener(this.executor, new OnFailureListener() { // from class: com.google.firebase.perf.config.RemoteConfigManager$$ExternalSyntheticLambda1
@Override // com.google.android.gms.tasks.OnFailureListener
public final void onFailure(Exception exc) {
RemoteConfigManager.this.lambda$triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch$1(exc);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch$0(Boolean bool) {
syncConfigValues(this.firebaseRemoteConfig.getAll());
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$triggerFirebaseRemoteConfigFetchAndActivateOnSuccessfulFetch$1(Exception exc) {
logger.warn("Call to Remote Config failed: %s. This may cause a degraded experience with Firebase Performance. Please reach out to Firebase Support https://firebase.google.com/support/", exc);
this.firebaseRemoteConfigLastFetchTimestampMs = 0L;
}
@VisibleForTesting
public void syncConfigValues(Map<String, FirebaseRemoteConfigValue> map) {
this.allRcConfigMap.putAll(map);
for (String str : this.allRcConfigMap.keySet()) {
if (!map.containsKey(str)) {
this.allRcConfigMap.remove(str);
}
}
ConfigurationConstants$ExperimentTTID configurationConstants$ExperimentTTID = ConfigurationConstants$ExperimentTTID.getInstance();
FirebaseRemoteConfigValue firebaseRemoteConfigValue = this.allRcConfigMap.get(configurationConstants$ExperimentTTID.getRemoteConfigFlag());
if (firebaseRemoteConfigValue != null) {
try {
this.cache.setValue(configurationConstants$ExperimentTTID.getDeviceCacheFlag(), firebaseRemoteConfigValue.asBoolean());
return;
} catch (Exception unused) {
logger.debug("ExperimentTTID remote config flag has invalid value, expected boolean.");
return;
}
}
logger.debug("ExperimentTTID remote config flag does not exist.");
}
@VisibleForTesting
public long getCurrentSystemTimeMillis() {
return System.currentTimeMillis();
}
public boolean isFirebaseRemoteConfigAvailable() {
Provider provider;
RemoteConfigComponent remoteConfigComponent;
if (this.firebaseRemoteConfig == null && (provider = this.firebaseRemoteConfigProvider) != null && (remoteConfigComponent = (RemoteConfigComponent) provider.get()) != null) {
this.firebaseRemoteConfig = remoteConfigComponent.get(FIREPERF_FRC_NAMESPACE_NAME);
}
return this.firebaseRemoteConfig != null;
}
private boolean shouldFetchAndActivateRemoteConfigValues() {
long currentSystemTimeMillis = getCurrentSystemTimeMillis();
return hasAppStartConfigFetchDelayElapsed(currentSystemTimeMillis) && hasLastFetchBecomeStale(currentSystemTimeMillis);
}
@VisibleForTesting
public static int getVersionCode(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException unused) {
return 0;
}
}
}

View File

@@ -0,0 +1,69 @@
package com.google.firebase.perf.injection.components;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.FirebasePerformance_Factory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesConfigResolverFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesFirebaseAppFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesSessionManagerFactory;
import com.google.firebase.perf.injection.modules.FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory;
import dagger.internal.DoubleCheck;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class DaggerFirebasePerformanceComponent implements FirebasePerformanceComponent {
public Provider firebasePerformanceProvider;
public Provider providesConfigResolverProvider;
public Provider providesFirebaseAppProvider;
public Provider providesFirebaseInstallationsProvider;
public Provider providesRemoteConfigComponentProvider;
public Provider providesRemoteConfigManagerProvider;
public Provider providesSessionManagerProvider;
public Provider providesTransportFactoryProvider;
public DaggerFirebasePerformanceComponent(FirebasePerformanceModule firebasePerformanceModule) {
initialize(firebasePerformanceModule);
}
public static Builder builder() {
return new Builder();
}
public final void initialize(FirebasePerformanceModule firebasePerformanceModule) {
this.providesFirebaseAppProvider = FirebasePerformanceModule_ProvidesFirebaseAppFactory.create(firebasePerformanceModule);
this.providesRemoteConfigComponentProvider = FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory.create(firebasePerformanceModule);
this.providesFirebaseInstallationsProvider = FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory.create(firebasePerformanceModule);
this.providesTransportFactoryProvider = FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory.create(firebasePerformanceModule);
this.providesRemoteConfigManagerProvider = FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory.create(firebasePerformanceModule);
this.providesConfigResolverProvider = FirebasePerformanceModule_ProvidesConfigResolverFactory.create(firebasePerformanceModule);
FirebasePerformanceModule_ProvidesSessionManagerFactory create = FirebasePerformanceModule_ProvidesSessionManagerFactory.create(firebasePerformanceModule);
this.providesSessionManagerProvider = create;
this.firebasePerformanceProvider = DoubleCheck.provider(FirebasePerformance_Factory.create(this.providesFirebaseAppProvider, this.providesRemoteConfigComponentProvider, this.providesFirebaseInstallationsProvider, this.providesTransportFactoryProvider, this.providesRemoteConfigManagerProvider, this.providesConfigResolverProvider, create));
}
@Override // com.google.firebase.perf.injection.components.FirebasePerformanceComponent
public FirebasePerformance getFirebasePerformance() {
return (FirebasePerformance) this.firebasePerformanceProvider.get();
}
public static final class Builder {
public FirebasePerformanceModule firebasePerformanceModule;
public Builder() {
}
public Builder firebasePerformanceModule(FirebasePerformanceModule firebasePerformanceModule) {
this.firebasePerformanceModule = (FirebasePerformanceModule) Preconditions.checkNotNull(firebasePerformanceModule);
return this;
}
public FirebasePerformanceComponent build() {
Preconditions.checkBuilderRequirement(this.firebasePerformanceModule, FirebasePerformanceModule.class);
return new DaggerFirebasePerformanceComponent(this.firebasePerformanceModule);
}
}
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.perf.injection.components;
import com.google.firebase.perf.FirebasePerformance;
/* loaded from: classes3.dex */
public interface FirebasePerformanceComponent {
FirebasePerformance getFirebasePerformance();
}

View File

@@ -0,0 +1,51 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.FirebaseApp;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.config.RemoteConfigManager;
import com.google.firebase.perf.session.SessionManager;
/* loaded from: classes3.dex */
public class FirebasePerformanceModule {
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallations;
public final Provider remoteConfigComponentProvider;
public final Provider transportFactoryProvider;
public FirebaseApp providesFirebaseApp() {
return this.firebaseApp;
}
public FirebaseInstallationsApi providesFirebaseInstallations() {
return this.firebaseInstallations;
}
public Provider providesRemoteConfigComponent() {
return this.remoteConfigComponentProvider;
}
public Provider providesTransportFactoryProvider() {
return this.transportFactoryProvider;
}
public FirebasePerformanceModule(FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, Provider provider, Provider provider2) {
this.firebaseApp = firebaseApp;
this.firebaseInstallations = firebaseInstallationsApi;
this.remoteConfigComponentProvider = provider;
this.transportFactoryProvider = provider2;
}
public RemoteConfigManager providesRemoteConfigManager() {
return RemoteConfigManager.getInstance();
}
public ConfigResolver providesConfigResolver() {
return ConfigResolver.getInstance();
}
public SessionManager providesSessionManager() {
return SessionManager.getInstance();
}
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.perf.config.ConfigResolver;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesConfigResolverFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesConfigResolverFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public ConfigResolver get() {
return providesConfigResolver(this.module);
}
public static FirebasePerformanceModule_ProvidesConfigResolverFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesConfigResolverFactory(firebasePerformanceModule);
}
public static ConfigResolver providesConfigResolver(FirebasePerformanceModule firebasePerformanceModule) {
return (ConfigResolver) Preconditions.checkNotNull(firebasePerformanceModule.providesConfigResolver(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.FirebaseApp;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesFirebaseAppFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesFirebaseAppFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public FirebaseApp get() {
return providesFirebaseApp(this.module);
}
public static FirebasePerformanceModule_ProvidesFirebaseAppFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesFirebaseAppFactory(firebasePerformanceModule);
}
public static FirebaseApp providesFirebaseApp(FirebasePerformanceModule firebasePerformanceModule) {
return (FirebaseApp) Preconditions.checkNotNull(firebasePerformanceModule.providesFirebaseApp(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.installations.FirebaseInstallationsApi;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public FirebaseInstallationsApi get() {
return providesFirebaseInstallations(this.module);
}
public static FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory(firebasePerformanceModule);
}
public static FirebaseInstallationsApi providesFirebaseInstallations(FirebasePerformanceModule firebasePerformanceModule) {
return (FirebaseInstallationsApi) Preconditions.checkNotNull(firebasePerformanceModule.providesFirebaseInstallations(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,26 @@
package com.google.firebase.perf.injection.modules;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public com.google.firebase.inject.Provider get() {
return providesRemoteConfigComponent(this.module);
}
public static FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory(firebasePerformanceModule);
}
public static com.google.firebase.inject.Provider providesRemoteConfigComponent(FirebasePerformanceModule firebasePerformanceModule) {
return (com.google.firebase.inject.Provider) Preconditions.checkNotNull(firebasePerformanceModule.providesRemoteConfigComponent(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.perf.config.RemoteConfigManager;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public RemoteConfigManager get() {
return providesRemoteConfigManager(this.module);
}
public static FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory(firebasePerformanceModule);
}
public static RemoteConfigManager providesRemoteConfigManager(FirebasePerformanceModule firebasePerformanceModule) {
return (RemoteConfigManager) Preconditions.checkNotNull(firebasePerformanceModule.providesRemoteConfigManager(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,27 @@
package com.google.firebase.perf.injection.modules;
import com.google.firebase.perf.session.SessionManager;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesSessionManagerFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesSessionManagerFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public SessionManager get() {
return providesSessionManager(this.module);
}
public static FirebasePerformanceModule_ProvidesSessionManagerFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesSessionManagerFactory(firebasePerformanceModule);
}
public static SessionManager providesSessionManager(FirebasePerformanceModule firebasePerformanceModule) {
return (SessionManager) Preconditions.checkNotNull(firebasePerformanceModule.providesSessionManager(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,26 @@
package com.google.firebase.perf.injection.modules;
import dagger.internal.Preconditions;
import javax.inject.Provider;
/* loaded from: classes3.dex */
public final class FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory implements Provider {
public final FirebasePerformanceModule module;
public FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory(FirebasePerformanceModule firebasePerformanceModule) {
this.module = firebasePerformanceModule;
}
@Override // javax.inject.Provider
public com.google.firebase.inject.Provider get() {
return providesTransportFactoryProvider(this.module);
}
public static FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory create(FirebasePerformanceModule firebasePerformanceModule) {
return new FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory(firebasePerformanceModule);
}
public static com.google.firebase.inject.Provider providesTransportFactoryProvider(FirebasePerformanceModule firebasePerformanceModule) {
return (com.google.firebase.inject.Provider) Preconditions.checkNotNull(firebasePerformanceModule.providesTransportFactoryProvider(), "Cannot return null from a non-@Nullable @Provides method");
}
}

View File

@@ -0,0 +1,16 @@
package com.google.firebase.perf.ktx;
import androidx.annotation.Keep;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
@Keep
/* loaded from: classes3.dex */
public final class FirebasePerfKtxRegistrar implements ComponentRegistrar {
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component> getComponents() {
return CollectionsKt__CollectionsKt.emptyList();
}
}

View File

@@ -0,0 +1,89 @@
package com.google.firebase.perf.logging;
import java.util.Locale;
/* loaded from: classes3.dex */
public class AndroidLogger {
public static volatile AndroidLogger instance;
public boolean isLogcatEnabled;
public final LogWrapper logWrapper;
public boolean isLogcatEnabled() {
return this.isLogcatEnabled;
}
public void setLogcatEnabled(boolean z) {
this.isLogcatEnabled = z;
}
public static AndroidLogger getInstance() {
if (instance == null) {
synchronized (AndroidLogger.class) {
try {
if (instance == null) {
instance = new AndroidLogger();
}
} finally {
}
}
}
return instance;
}
public AndroidLogger(LogWrapper logWrapper) {
this.isLogcatEnabled = false;
this.logWrapper = logWrapper == null ? LogWrapper.getInstance() : logWrapper;
}
public AndroidLogger() {
this(null);
}
public void debug(String str) {
if (this.isLogcatEnabled) {
this.logWrapper.d(str);
}
}
public void debug(String str, Object... objArr) {
if (this.isLogcatEnabled) {
this.logWrapper.d(String.format(Locale.ENGLISH, str, objArr));
}
}
public void info(String str) {
if (this.isLogcatEnabled) {
this.logWrapper.i(str);
}
}
public void info(String str, Object... objArr) {
if (this.isLogcatEnabled) {
this.logWrapper.i(String.format(Locale.ENGLISH, str, objArr));
}
}
public void warn(String str) {
if (this.isLogcatEnabled) {
this.logWrapper.w(str);
}
}
public void warn(String str, Object... objArr) {
if (this.isLogcatEnabled) {
this.logWrapper.w(String.format(Locale.ENGLISH, str, objArr));
}
}
public void error(String str) {
if (this.isLogcatEnabled) {
this.logWrapper.e(str);
}
}
public void error(String str, Object... objArr) {
if (this.isLogcatEnabled) {
this.logWrapper.e(String.format(Locale.ENGLISH, str, objArr));
}
}
}

View File

@@ -0,0 +1,20 @@
package com.google.firebase.perf.logging;
/* loaded from: classes3.dex */
public abstract class ConsoleUrlGenerator {
public static String generateDashboardUrl(String str, String str2) {
return String.format("%s/trends?utm_source=%s&utm_medium=%s", getRootUrl(str, str2), "perf-android-sdk", "android-ide");
}
public static String generateCustomTraceUrl(String str, String str2, String str3) {
return String.format("%s/troubleshooting/trace/DURATION_TRACE/%s?utm_source=%s&utm_medium=%s", getRootUrl(str, str2), str3, "perf-android-sdk", "android-ide");
}
public static String generateScreenTraceUrl(String str, String str2, String str3) {
return String.format("%s/troubleshooting/trace/SCREEN_TRACE/%s?utm_source=%s&utm_medium=%s", getRootUrl(str, str2), str3, "perf-android-sdk", "android-ide");
}
public static String getRootUrl(String str, String str2) {
return String.format("%s/project/%s/performance/app/android:%s", "https://console.firebase.google.com", str, str2);
}
}

View File

@@ -0,0 +1,37 @@
package com.google.firebase.perf.logging;
import android.util.Log;
/* loaded from: classes3.dex */
public class LogWrapper {
public static LogWrapper instance;
public void d(String str) {
}
public void i(String str) {
}
public static synchronized LogWrapper getInstance() {
LogWrapper logWrapper;
synchronized (LogWrapper.class) {
try {
if (instance == null) {
instance = new LogWrapper();
}
logWrapper = instance;
} catch (Throwable th) {
throw th;
}
}
return logWrapper;
}
public void w(String str) {
Log.w("FirebasePerformance", str);
}
public void e(String str) {
Log.e("FirebasePerformance", str);
}
}

View File

@@ -0,0 +1,488 @@
package com.google.firebase.perf.metrics;
import android.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.Process;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ProcessLifecycleOwner;
import com.facebook.internal.security.CertificateUtil;
import com.google.firebase.FirebaseApp;
import com.google.firebase.StartupTime;
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.session.SessionManager;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Constants$TraceNames;
import com.google.firebase.perf.util.FirstDrawDoneListener;
import com.google.firebase.perf.util.PreDrawListener;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.v1.ApplicationProcessState;
import com.google.firebase.perf.v1.TraceMetric;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class AppStartTrace implements Application.ActivityLifecycleCallbacks, LifecycleObserver {
private static final int CORE_POOL_SIZE = 0;
private static final int MAX_POOL_SIZE = 1;
private static ExecutorService executorService;
private static volatile AppStartTrace instance;
private Context appContext;
private WeakReference<Activity> appStartActivity;
private final Clock clock;
private final ConfigResolver configResolver;
private final TraceMetric.Builder experimentTtid;
@Nullable
private final Timer firebaseClassLoadTime;
private WeakReference<Activity> launchActivity;
@Nullable
private final Timer processStartTime;
private PerfSession startSession;
private final TransportManager transportManager;
@NonNull
private static final Timer PERF_CLASS_LOAD_TIME = new Clock().getTime();
private static final long MAX_LATENCY_BEFORE_UI_INIT = TimeUnit.MINUTES.toMicros(1);
private boolean isRegisteredForLifecycleCallbacks = false;
private boolean isTooLateToInitUI = false;
private Timer onCreateTime = null;
private Timer onStartTime = null;
private Timer onResumeTime = null;
private Timer firstForegroundTime = null;
@Nullable
private Timer firstBackgroundTime = null;
private Timer preDrawPostTime = null;
private Timer preDrawPostAtFrontOfQueueTime = null;
private Timer onDrawPostAtFrontOfQueueTime = null;
private boolean isStartedFromBackground = false;
private int onDrawCount = 0;
private final DrawCounter onDrawCounterListener = new DrawCounter();
private boolean systemForegroundCheck = false;
@NonNull
private Timer getClassLoadTimeCompat() {
Timer timer = this.firebaseClassLoadTime;
return timer != null ? timer : PERF_CLASS_LOAD_TIME;
}
@Keep
public static void setLauncherActivityOnCreateTime(String str) {
}
@Keep
public static void setLauncherActivityOnResumeTime(String str) {
}
@Keep
public static void setLauncherActivityOnStartTime(String str) {
}
@VisibleForTesting
public Timer getOnCreateTime() {
return this.onCreateTime;
}
@VisibleForTesting
public Timer getOnResumeTime() {
return this.onResumeTime;
}
@VisibleForTesting
public Timer getOnStartTime() {
return this.onStartTime;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
}
@VisibleForTesting
public void setIsStartFromBackground() {
this.isStartedFromBackground = true;
}
public static /* synthetic */ int access$308(AppStartTrace appStartTrace) {
int i = appStartTrace.onDrawCount;
appStartTrace.onDrawCount = i + 1;
return i;
}
public static AppStartTrace getInstance() {
return instance != null ? instance : getInstance(TransportManager.getInstance(), new Clock());
}
@SuppressLint({"ThreadPoolCreation"})
public static AppStartTrace getInstance(TransportManager transportManager, Clock clock) {
if (instance == null) {
synchronized (AppStartTrace.class) {
try {
if (instance == null) {
instance = new AppStartTrace(transportManager, clock, ConfigResolver.getInstance(), new ThreadPoolExecutor(0, 1, MAX_LATENCY_BEFORE_UI_INIT + 10, TimeUnit.SECONDS, new LinkedBlockingQueue()));
}
} finally {
}
}
}
return instance;
}
/* JADX WARN: Multi-variable type inference failed */
public AppStartTrace(@NonNull TransportManager transportManager, @NonNull Clock clock, @NonNull ConfigResolver configResolver, @NonNull ExecutorService executorService2) {
this.transportManager = transportManager;
this.clock = clock;
this.configResolver = configResolver;
executorService = executorService2;
this.experimentTtid = TraceMetric.newBuilder().setName("_experiment_app_start_ttid");
this.processStartTime = Timer.ofElapsedRealtime(Process.getStartElapsedRealtime());
StartupTime startupTime = (StartupTime) FirebaseApp.getInstance().get(StartupTime.class);
this.firebaseClassLoadTime = startupTime != null ? Timer.ofElapsedRealtime(startupTime.getElapsedRealtime()) : null;
}
public synchronized void registerActivityLifecycleCallbacks(@NonNull Context context) {
boolean z;
try {
if (this.isRegisteredForLifecycleCallbacks) {
return;
}
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
Context applicationContext = context.getApplicationContext();
if (applicationContext instanceof Application) {
((Application) applicationContext).registerActivityLifecycleCallbacks(this);
if (!this.systemForegroundCheck && !isAnyAppProcessInForeground(applicationContext)) {
z = false;
this.systemForegroundCheck = z;
this.isRegisteredForLifecycleCallbacks = true;
this.appContext = applicationContext;
}
z = true;
this.systemForegroundCheck = z;
this.isRegisteredForLifecycleCallbacks = true;
this.appContext = applicationContext;
}
} catch (Throwable th) {
throw th;
}
}
public synchronized void unregisterActivityLifecycleCallbacks() {
if (this.isRegisteredForLifecycleCallbacks) {
ProcessLifecycleOwner.get().getLifecycle().removeObserver(this);
((Application) this.appContext).unregisterActivityLifecycleCallbacks(this);
this.isRegisteredForLifecycleCallbacks = false;
}
}
@NonNull
private Timer getStartTimerCompat() {
Timer timer = this.processStartTime;
return timer != null ? timer : getClassLoadTimeCompat();
}
/* JADX INFO: Access modifiers changed from: private */
public void recordPreDraw() {
if (this.preDrawPostTime != null) {
return;
}
this.preDrawPostTime = this.clock.getTime();
this.experimentTtid.setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(this.preDrawPostTime));
logExperimentTrace(this.experimentTtid);
}
/* JADX INFO: Access modifiers changed from: private */
public void recordPreDrawFrontOfQueue() {
if (this.preDrawPostAtFrontOfQueueTime != null) {
return;
}
this.preDrawPostAtFrontOfQueueTime = this.clock.getTime();
this.experimentTtid.addSubtraces((TraceMetric) TraceMetric.newBuilder().setName("_experiment_preDrawFoQ").setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(this.preDrawPostAtFrontOfQueueTime)).build());
logExperimentTrace(this.experimentTtid);
}
/* JADX INFO: Access modifiers changed from: private */
public void recordOnDrawFrontOfQueue() {
if (this.onDrawPostAtFrontOfQueueTime != null) {
return;
}
this.onDrawPostAtFrontOfQueueTime = this.clock.getTime();
this.experimentTtid.addSubtraces((TraceMetric) TraceMetric.newBuilder().setName("_experiment_onDrawFoQ").setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(this.onDrawPostAtFrontOfQueueTime)).build());
if (this.processStartTime != null) {
this.experimentTtid.addSubtraces((TraceMetric) TraceMetric.newBuilder().setName("_experiment_procStart_to_classLoad").setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(getClassLoadTimeCompat())).build());
}
this.experimentTtid.putCustomAttributes("systemDeterminedForeground", this.systemForegroundCheck ? "true" : "false");
this.experimentTtid.putCounters("onDrawCount", this.onDrawCount);
this.experimentTtid.addPerfSessions(this.startSession.build());
logExperimentTrace(this.experimentTtid);
}
/* JADX WARN: Removed duplicated region for block: B:16:0x003e A[Catch: all -> 0x001a, TRY_LEAVE, TryCatch #0 {all -> 0x001a, blocks: (B:3:0x0001, B:5:0x0005, B:8:0x000a, B:10:0x000f, B:14:0x001d, B:16:0x003e), top: B:2:0x0001 }] */
@Override // android.app.Application.ActivityLifecycleCallbacks
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public synchronized void onActivityCreated(android.app.Activity r4, android.os.Bundle r5) {
/*
r3 = this;
monitor-enter(r3)
boolean r5 = r3.isStartedFromBackground // Catch: java.lang.Throwable -> L1a
if (r5 != 0) goto L42
com.google.firebase.perf.util.Timer r5 = r3.onCreateTime // Catch: java.lang.Throwable -> L1a
if (r5 == 0) goto La
goto L42
La:
boolean r5 = r3.systemForegroundCheck // Catch: java.lang.Throwable -> L1a
r0 = 1
if (r5 != 0) goto L1c
android.content.Context r5 = r3.appContext // Catch: java.lang.Throwable -> L1a
boolean r5 = isAnyAppProcessInForeground(r5) // Catch: java.lang.Throwable -> L1a
if (r5 == 0) goto L18
goto L1c
L18:
r5 = 0
goto L1d
L1a:
r4 = move-exception
goto L44
L1c:
r5 = r0
L1d:
r3.systemForegroundCheck = r5 // Catch: java.lang.Throwable -> L1a
java.lang.ref.WeakReference r5 = new java.lang.ref.WeakReference // Catch: java.lang.Throwable -> L1a
r5.<init>(r4) // Catch: java.lang.Throwable -> L1a
r3.launchActivity = r5 // Catch: java.lang.Throwable -> L1a
com.google.firebase.perf.util.Clock r4 = r3.clock // Catch: java.lang.Throwable -> L1a
com.google.firebase.perf.util.Timer r4 = r4.getTime() // Catch: java.lang.Throwable -> L1a
r3.onCreateTime = r4 // Catch: java.lang.Throwable -> L1a
com.google.firebase.perf.util.Timer r4 = r3.getStartTimerCompat() // Catch: java.lang.Throwable -> L1a
com.google.firebase.perf.util.Timer r5 = r3.onCreateTime // Catch: java.lang.Throwable -> L1a
long r4 = r4.getDurationMicros(r5) // Catch: java.lang.Throwable -> L1a
long r1 = com.google.firebase.perf.metrics.AppStartTrace.MAX_LATENCY_BEFORE_UI_INIT // Catch: java.lang.Throwable -> L1a
int r4 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1))
if (r4 <= 0) goto L40
r3.isTooLateToInitUI = r0 // Catch: java.lang.Throwable -> L1a
L40:
monitor-exit(r3)
return
L42:
monitor-exit(r3)
return
L44:
monitor-exit(r3)
throw r4
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.perf.metrics.AppStartTrace.onActivityCreated(android.app.Activity, android.os.Bundle):void");
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public synchronized void onActivityStarted(Activity activity) {
if (!this.isStartedFromBackground && this.onStartTime == null && !this.isTooLateToInitUI) {
this.onStartTime = this.clock.getTime();
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public synchronized void onActivityResumed(Activity activity) {
try {
if (!this.isStartedFromBackground && !this.isTooLateToInitUI) {
boolean isExperimentTTIDEnabled = this.configResolver.getIsExperimentTTIDEnabled();
if (isExperimentTTIDEnabled) {
View findViewById = activity.findViewById(R.id.content);
findViewById.getViewTreeObserver().addOnDrawListener(this.onDrawCounterListener);
FirstDrawDoneListener.registerForNextDraw(findViewById, new Runnable() { // from class: com.google.firebase.perf.metrics.AppStartTrace$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
AppStartTrace.this.recordOnDrawFrontOfQueue();
}
});
PreDrawListener.registerForNextDraw(findViewById, new Runnable() { // from class: com.google.firebase.perf.metrics.AppStartTrace$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
AppStartTrace.this.recordPreDraw();
}
}, new Runnable() { // from class: com.google.firebase.perf.metrics.AppStartTrace$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
AppStartTrace.this.recordPreDrawFrontOfQueue();
}
});
}
if (this.onResumeTime != null) {
return;
}
this.appStartActivity = new WeakReference<>(activity);
this.onResumeTime = this.clock.getTime();
this.startSession = SessionManager.getInstance().perfSession();
AndroidLogger.getInstance().debug("onResume(): " + activity.getClass().getName() + ": " + getClassLoadTimeCompat().getDurationMicros(this.onResumeTime) + " microseconds");
executorService.execute(new Runnable() { // from class: com.google.firebase.perf.metrics.AppStartTrace$$ExternalSyntheticLambda3
@Override // java.lang.Runnable
public final void run() {
AppStartTrace.this.logAppStartTrace();
}
});
if (!isExperimentTTIDEnabled) {
unregisterActivityLifecycleCallbacks();
}
}
} finally {
}
}
private void logExperimentTrace(final TraceMetric.Builder builder) {
if (this.preDrawPostTime == null || this.preDrawPostAtFrontOfQueueTime == null || this.onDrawPostAtFrontOfQueueTime == null) {
return;
}
executorService.execute(new Runnable() { // from class: com.google.firebase.perf.metrics.AppStartTrace$$ExternalSyntheticLambda4
@Override // java.lang.Runnable
public final void run() {
AppStartTrace.this.lambda$logExperimentTrace$0(builder);
}
});
unregisterActivityLifecycleCallbacks();
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$logExperimentTrace$0(TraceMetric.Builder builder) {
this.transportManager.log((TraceMetric) builder.build(), ApplicationProcessState.FOREGROUND_BACKGROUND);
}
/* JADX INFO: Access modifiers changed from: private */
public void logAppStartTrace() {
TraceMetric.Builder durationUs = TraceMetric.newBuilder().setName(Constants$TraceNames.APP_START_TRACE_NAME.toString()).setClientStartTimeUs(getClassLoadTimeCompat().getMicros()).setDurationUs(getClassLoadTimeCompat().getDurationMicros(this.onResumeTime));
ArrayList arrayList = new ArrayList(3);
arrayList.add((TraceMetric) TraceMetric.newBuilder().setName(Constants$TraceNames.ON_CREATE_TRACE_NAME.toString()).setClientStartTimeUs(getClassLoadTimeCompat().getMicros()).setDurationUs(getClassLoadTimeCompat().getDurationMicros(this.onCreateTime)).build());
if (this.onStartTime != null) {
TraceMetric.Builder newBuilder = TraceMetric.newBuilder();
newBuilder.setName(Constants$TraceNames.ON_START_TRACE_NAME.toString()).setClientStartTimeUs(this.onCreateTime.getMicros()).setDurationUs(this.onCreateTime.getDurationMicros(this.onStartTime));
arrayList.add((TraceMetric) newBuilder.build());
TraceMetric.Builder newBuilder2 = TraceMetric.newBuilder();
newBuilder2.setName(Constants$TraceNames.ON_RESUME_TRACE_NAME.toString()).setClientStartTimeUs(this.onStartTime.getMicros()).setDurationUs(this.onStartTime.getDurationMicros(this.onResumeTime));
arrayList.add((TraceMetric) newBuilder2.build());
}
durationUs.addAllSubtraces(arrayList).addPerfSessions(this.startSession.build());
this.transportManager.log((TraceMetric) durationUs.build(), ApplicationProcessState.FOREGROUND_BACKGROUND);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
if (this.isStartedFromBackground || this.isTooLateToInitUI || !this.configResolver.getIsExperimentTTIDEnabled()) {
return;
}
activity.findViewById(R.id.content).getViewTreeObserver().removeOnDrawListener(this.onDrawCounterListener);
}
@Keep
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onAppEnteredForeground() {
if (this.isStartedFromBackground || this.isTooLateToInitUI || this.firstForegroundTime != null) {
return;
}
this.firstForegroundTime = this.clock.getTime();
this.experimentTtid.addSubtraces((TraceMetric) TraceMetric.newBuilder().setName("_experiment_firstForegrounding").setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(this.firstForegroundTime)).build());
}
@Keep
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onAppEnteredBackground() {
if (this.isStartedFromBackground || this.isTooLateToInitUI || this.firstBackgroundTime != null) {
return;
}
this.firstBackgroundTime = this.clock.getTime();
this.experimentTtid.addSubtraces((TraceMetric) TraceMetric.newBuilder().setName("_experiment_firstBackgrounding").setClientStartTimeUs(getStartTimerCompat().getMicros()).setDurationUs(getStartTimerCompat().getDurationMicros(this.firstBackgroundTime)).build());
}
public static boolean isAnyAppProcessInForeground(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
if (activityManager == null) {
return true;
}
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager.getRunningAppProcesses();
if (runningAppProcesses == null) {
return false;
}
String packageName = context.getPackageName();
String str = packageName + CertificateUtil.DELIMITER;
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
if (runningAppProcessInfo.importance == 100 && (runningAppProcessInfo.processName.equals(packageName) || runningAppProcessInfo.processName.startsWith(str))) {
return true;
}
}
return false;
}
public static boolean isScreenOn(Context context) {
PowerManager powerManager = (PowerManager) context.getSystemService("power");
if (powerManager == null) {
return true;
}
return powerManager.isInteractive();
}
public static class StartFromBackgroundRunnable implements Runnable {
public final AppStartTrace trace;
public StartFromBackgroundRunnable(AppStartTrace appStartTrace) {
this.trace = appStartTrace;
}
@Override // java.lang.Runnable
public void run() {
if (this.trace.onCreateTime == null) {
this.trace.isStartedFromBackground = true;
}
}
}
public final class DrawCounter implements ViewTreeObserver.OnDrawListener {
public DrawCounter() {
}
@Override // android.view.ViewTreeObserver.OnDrawListener
public void onDraw() {
AppStartTrace.access$308(AppStartTrace.this);
}
}
@Nullable
@VisibleForTesting
public Activity getLaunchActivity() {
return this.launchActivity.get();
}
@Nullable
@VisibleForTesting
public Activity getAppStartActivity() {
return this.appStartActivity.get();
}
}

View File

@@ -0,0 +1,59 @@
package com.google.firebase.perf.metrics;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.concurrent.atomic.AtomicLong;
/* loaded from: classes3.dex */
public class Counter implements Parcelable {
public static final Parcelable.Creator<Counter> CREATOR = new Parcelable.Creator() { // from class: com.google.firebase.perf.metrics.Counter.1
@Override // android.os.Parcelable.Creator
public Counter createFromParcel(Parcel parcel) {
return new Counter(parcel);
}
@Override // android.os.Parcelable.Creator
public Counter[] newArray(int i) {
return new Counter[i];
}
};
public final AtomicLong count;
public final String name;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public String getName() {
return this.name;
}
public Counter(String str) {
this.name = str;
this.count = new AtomicLong(0L);
}
public Counter(Parcel parcel) {
this.name = parcel.readString();
this.count = new AtomicLong(parcel.readLong());
}
public void increment(long j) {
this.count.addAndGet(j);
}
public long getCount() {
return this.count.get();
}
public void setCount(long j) {
this.count.set(j);
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.name);
parcel.writeLong(this.count.get());
}
}

View File

@@ -0,0 +1,64 @@
package com.google.firebase.perf.metrics;
import android.util.SparseIntArray;
/* loaded from: classes3.dex */
public abstract class FrameMetricsCalculator {
public static class PerfFrameMetrics {
public int frozenFrames;
public int slowFrames;
public int totalFrames;
public int getFrozenFrames() {
return this.frozenFrames;
}
public int getSlowFrames() {
return this.slowFrames;
}
public int getTotalFrames() {
return this.totalFrames;
}
public PerfFrameMetrics(int i, int i2, int i3) {
this.totalFrames = i;
this.slowFrames = i2;
this.frozenFrames = i3;
}
public PerfFrameMetrics deltaFrameMetricsFromSnapshot(PerfFrameMetrics perfFrameMetrics) {
return new PerfFrameMetrics(this.totalFrames - perfFrameMetrics.getTotalFrames(), this.slowFrames - perfFrameMetrics.getSlowFrames(), this.frozenFrames - perfFrameMetrics.getFrozenFrames());
}
}
public static PerfFrameMetrics calculateFrameMetrics(SparseIntArray[] sparseIntArrayArr) {
int i;
int i2;
SparseIntArray sparseIntArray;
int i3 = 0;
if (sparseIntArrayArr == null || (sparseIntArray = sparseIntArrayArr[0]) == null) {
i = 0;
i2 = 0;
} else {
int i4 = 0;
i = 0;
i2 = 0;
while (i3 < sparseIntArray.size()) {
int keyAt = sparseIntArray.keyAt(i3);
int valueAt = sparseIntArray.valueAt(i3);
i4 += valueAt;
if (keyAt > 700) {
i2 += valueAt;
}
if (keyAt > 16) {
i += valueAt;
}
i3++;
}
i3 = i4;
}
return new PerfFrameMetrics(i3, i, i2);
}
}

View File

@@ -0,0 +1,248 @@
package com.google.firebase.perf.metrics;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.application.AppStateUpdateHandler;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.network.NetworkRequestMetricBuilderUtil;
import com.google.firebase.perf.session.PerfSession;
import com.google.firebase.perf.session.SessionAwareObject;
import com.google.firebase.perf.session.SessionManager;
import com.google.firebase.perf.session.gauges.GaugeManager;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Utils;
import com.google.firebase.perf.v1.NetworkRequestMetric;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/* loaded from: classes3.dex */
public final class NetworkRequestMetricBuilder extends AppStateUpdateHandler implements SessionAwareObject {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final NetworkRequestMetric.Builder builder;
public final GaugeManager gaugeManager;
public boolean isManualNetworkRequestMetric;
public boolean isReportSent;
public final List sessions;
public final TransportManager transportManager;
public String userAgent;
public final WeakReference weakReference;
public NetworkRequestMetricBuilder setUserAgent(String str) {
this.userAgent = str;
return this;
}
@Override // com.google.firebase.perf.session.SessionAwareObject
public void updateSession(PerfSession perfSession) {
if (perfSession == null) {
logger.warn("Unable to add new SessionId to the Network Trace. Continuing without it.");
} else {
if (!hasStarted() || isStopped()) {
return;
}
this.sessions.add(perfSession);
}
}
public static NetworkRequestMetricBuilder builder(TransportManager transportManager) {
return new NetworkRequestMetricBuilder(transportManager);
}
public NetworkRequestMetricBuilder(TransportManager transportManager) {
this(transportManager, AppStateMonitor.getInstance(), GaugeManager.getInstance());
}
public NetworkRequestMetricBuilder(TransportManager transportManager, AppStateMonitor appStateMonitor, GaugeManager gaugeManager) {
super(appStateMonitor);
this.builder = NetworkRequestMetric.newBuilder();
this.weakReference = new WeakReference(this);
this.transportManager = transportManager;
this.gaugeManager = gaugeManager;
this.sessions = Collections.synchronizedList(new ArrayList());
registerForAppState();
}
public NetworkRequestMetricBuilder setUrl(String str) {
if (str != null) {
this.builder.setUrl(Utils.truncateURL(Utils.stripSensitiveInfo(str), 2000));
}
return this;
}
public NetworkRequestMetricBuilder setHttpMethod(String str) {
NetworkRequestMetric.HttpMethod httpMethod;
if (str != null) {
NetworkRequestMetric.HttpMethod httpMethod2 = NetworkRequestMetric.HttpMethod.HTTP_METHOD_UNKNOWN;
String upperCase = str.toUpperCase();
upperCase.hashCode();
switch (upperCase) {
case "OPTIONS":
httpMethod = NetworkRequestMetric.HttpMethod.OPTIONS;
break;
case "GET":
httpMethod = NetworkRequestMetric.HttpMethod.GET;
break;
case "PUT":
httpMethod = NetworkRequestMetric.HttpMethod.PUT;
break;
case "HEAD":
httpMethod = NetworkRequestMetric.HttpMethod.HEAD;
break;
case "POST":
httpMethod = NetworkRequestMetric.HttpMethod.POST;
break;
case "PATCH":
httpMethod = NetworkRequestMetric.HttpMethod.PATCH;
break;
case "TRACE":
httpMethod = NetworkRequestMetric.HttpMethod.TRACE;
break;
case "CONNECT":
httpMethod = NetworkRequestMetric.HttpMethod.CONNECT;
break;
case "DELETE":
httpMethod = NetworkRequestMetric.HttpMethod.DELETE;
break;
default:
httpMethod = NetworkRequestMetric.HttpMethod.HTTP_METHOD_UNKNOWN;
break;
}
this.builder.setHttpMethod(httpMethod);
}
return this;
}
public NetworkRequestMetricBuilder setHttpResponseCode(int i) {
this.builder.setHttpResponseCode(i);
return this;
}
public boolean hasHttpResponseCode() {
return this.builder.hasHttpResponseCode();
}
public NetworkRequestMetricBuilder setRequestPayloadBytes(long j) {
this.builder.setRequestPayloadBytes(j);
return this;
}
public NetworkRequestMetricBuilder setRequestStartTimeMicros(long j) {
PerfSession perfSession = SessionManager.getInstance().perfSession();
SessionManager.getInstance().registerForSessionUpdates(this.weakReference);
this.builder.setClientStartTimeUs(j);
updateSession(perfSession);
if (perfSession.isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.collectGaugeMetricOnce(perfSession.getTimer());
}
return this;
}
public NetworkRequestMetricBuilder setTimeToRequestCompletedMicros(long j) {
this.builder.setTimeToRequestCompletedUs(j);
return this;
}
public NetworkRequestMetricBuilder setTimeToResponseInitiatedMicros(long j) {
this.builder.setTimeToResponseInitiatedUs(j);
return this;
}
public long getTimeToResponseInitiatedMicros() {
return this.builder.getTimeToResponseInitiatedUs();
}
public NetworkRequestMetricBuilder setTimeToResponseCompletedMicros(long j) {
this.builder.setTimeToResponseCompletedUs(j);
if (SessionManager.getInstance().perfSession().isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.collectGaugeMetricOnce(SessionManager.getInstance().perfSession().getTimer());
}
return this;
}
public NetworkRequestMetricBuilder setResponsePayloadBytes(long j) {
this.builder.setResponsePayloadBytes(j);
return this;
}
public NetworkRequestMetricBuilder setResponseContentType(String str) {
if (str == null) {
this.builder.clearResponseContentType();
return this;
}
if (isValidContentType(str)) {
this.builder.setResponseContentType(str);
} else {
logger.warn("The content type of the response is not a valid content-type:" + str);
}
return this;
}
public NetworkRequestMetricBuilder setNetworkClientErrorReason() {
this.builder.setNetworkClientErrorReason(NetworkRequestMetric.NetworkClientErrorReason.GENERIC_CLIENT_ERROR);
return this;
}
public NetworkRequestMetric build() {
SessionManager.getInstance().unregisterForSessionUpdates(this.weakReference);
unregisterForAppState();
com.google.firebase.perf.v1.PerfSession[] buildAndSort = PerfSession.buildAndSort(getSessions());
if (buildAndSort != null) {
this.builder.addAllPerfSessions(Arrays.asList(buildAndSort));
}
NetworkRequestMetric networkRequestMetric = (NetworkRequestMetric) this.builder.build();
if (!NetworkRequestMetricBuilderUtil.isAllowedUserAgent(this.userAgent)) {
logger.debug("Dropping network request from a 'User-Agent' that is not allowed");
return networkRequestMetric;
}
if (this.isReportSent) {
if (this.isManualNetworkRequestMetric) {
logger.debug("This metric has already been queued for transmission. Please create a new HttpMetric for each request/response");
}
return networkRequestMetric;
}
this.transportManager.log(networkRequestMetric, getAppState());
this.isReportSent = true;
return networkRequestMetric;
}
private boolean isStopped() {
return this.builder.hasTimeToResponseCompletedUs();
}
private boolean hasStarted() {
return this.builder.hasClientStartTimeUs();
}
public List getSessions() {
List unmodifiableList;
synchronized (this.sessions) {
try {
ArrayList arrayList = new ArrayList();
for (PerfSession perfSession : this.sessions) {
if (perfSession != null) {
arrayList.add(perfSession);
}
}
unmodifiableList = Collections.unmodifiableList(arrayList);
} catch (Throwable th) {
throw th;
}
}
return unmodifiableList;
}
public static boolean isValidContentType(String str) {
if (str.length() > 128) {
return false;
}
for (int i = 0; i < str.length(); i++) {
char charAt = str.charAt(i);
if (charAt <= 31 || charAt > 127) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,375 @@
package com.google.firebase.perf.metrics;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.application.AppStateUpdateHandler;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
import com.google.firebase.perf.session.PerfSession;
import com.google.firebase.perf.session.SessionAwareObject;
import com.google.firebase.perf.session.SessionManager;
import com.google.firebase.perf.session.gauges.GaugeManager;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Timer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/* loaded from: classes3.dex */
public class Trace extends AppStateUpdateHandler implements Parcelable, SessionAwareObject {
public final Clock clock;
public final Map counterNameToCounterMap;
public final Map customAttributesMap;
public Timer endTime;
public final GaugeManager gaugeManager;
public final String name;
public final Trace parent;
public final WeakReference sessionAwareObject;
public final List sessions;
public Timer startTime;
public final List subtraces;
public final TransportManager transportManager;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public static final Map traceNameToTraceMap = new ConcurrentHashMap();
@Keep
public static final Parcelable.Creator<Trace> CREATOR = new Parcelable.Creator() { // from class: com.google.firebase.perf.metrics.Trace.1
@Override // android.os.Parcelable.Creator
public Trace createFromParcel(Parcel parcel) {
return new Trace(parcel, false);
}
@Override // android.os.Parcelable.Creator
public Trace[] newArray(int i) {
return new Trace[i];
}
};
public static final Parcelable.Creator CREATOR_DATAONLY = new Parcelable.Creator() { // from class: com.google.firebase.perf.metrics.Trace.2
@Override // android.os.Parcelable.Creator
public Trace createFromParcel(Parcel parcel) {
return new Trace(parcel, true);
}
@Override // android.os.Parcelable.Creator
public Trace[] newArray(int i) {
return new Trace[i];
}
};
@Override // android.os.Parcelable
@Keep
public int describeContents() {
return 0;
}
public Map getCounters() {
return this.counterNameToCounterMap;
}
public Timer getEndTime() {
return this.endTime;
}
public String getName() {
return this.name;
}
public Timer getStartTime() {
return this.startTime;
}
public List getSubtraces() {
return this.subtraces;
}
public boolean hasStarted() {
return this.startTime != null;
}
public boolean isStopped() {
return this.endTime != null;
}
@Override // com.google.firebase.perf.session.SessionAwareObject
public void updateSession(PerfSession perfSession) {
if (perfSession == null) {
logger.warn("Unable to add new SessionId to the Trace. Continuing without it.");
} else {
if (!hasStarted() || isStopped()) {
return;
}
this.sessions.add(perfSession);
}
}
public Trace(String str, TransportManager transportManager, Clock clock, AppStateMonitor appStateMonitor) {
this(str, transportManager, clock, appStateMonitor, GaugeManager.getInstance());
}
public Trace(String str, TransportManager transportManager, Clock clock, AppStateMonitor appStateMonitor, GaugeManager gaugeManager) {
super(appStateMonitor);
this.sessionAwareObject = new WeakReference(this);
this.parent = null;
this.name = str.trim();
this.subtraces = new ArrayList();
this.counterNameToCounterMap = new ConcurrentHashMap();
this.customAttributesMap = new ConcurrentHashMap();
this.clock = clock;
this.transportManager = transportManager;
this.sessions = Collections.synchronizedList(new ArrayList());
this.gaugeManager = gaugeManager;
}
public Trace(Parcel parcel, boolean z) {
super(z ? null : AppStateMonitor.getInstance());
this.sessionAwareObject = new WeakReference(this);
this.parent = (Trace) parcel.readParcelable(Trace.class.getClassLoader());
this.name = parcel.readString();
ArrayList arrayList = new ArrayList();
this.subtraces = arrayList;
parcel.readList(arrayList, Trace.class.getClassLoader());
ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
this.counterNameToCounterMap = concurrentHashMap;
this.customAttributesMap = new ConcurrentHashMap();
parcel.readMap(concurrentHashMap, Counter.class.getClassLoader());
this.startTime = (Timer) parcel.readParcelable(Timer.class.getClassLoader());
this.endTime = (Timer) parcel.readParcelable(Timer.class.getClassLoader());
List synchronizedList = Collections.synchronizedList(new ArrayList());
this.sessions = synchronizedList;
parcel.readList(synchronizedList, PerfSession.class.getClassLoader());
if (z) {
this.transportManager = null;
this.clock = null;
this.gaugeManager = null;
} else {
this.transportManager = TransportManager.getInstance();
this.clock = new Clock();
this.gaugeManager = GaugeManager.getInstance();
}
}
@Keep
public void start() {
if (!ConfigResolver.getInstance().isPerformanceMonitoringEnabled()) {
logger.debug("Trace feature is disabled.");
return;
}
String validateTraceName = PerfMetricValidator.validateTraceName(this.name);
if (validateTraceName != null) {
logger.error("Cannot start trace '%s'. Trace name is invalid.(%s)", this.name, validateTraceName);
return;
}
if (this.startTime != null) {
logger.error("Trace '%s' has already started, should not start again!", this.name);
return;
}
this.startTime = this.clock.getTime();
registerForAppState();
PerfSession perfSession = SessionManager.getInstance().perfSession();
SessionManager.getInstance().registerForSessionUpdates(this.sessionAwareObject);
updateSession(perfSession);
if (perfSession.isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.collectGaugeMetricOnce(perfSession.getTimer());
}
}
@Keep
public void stop() {
if (!hasStarted()) {
logger.error("Trace '%s' has not been started so unable to stop!", this.name);
return;
}
if (isStopped()) {
logger.error("Trace '%s' has already stopped, should not stop again!", this.name);
return;
}
SessionManager.getInstance().unregisterForSessionUpdates(this.sessionAwareObject);
unregisterForAppState();
Timer time = this.clock.getTime();
this.endTime = time;
if (this.parent == null) {
setEndTimeOfLastStage(time);
if (!this.name.isEmpty()) {
this.transportManager.log(new TraceMetricBuilder(this).build(), getAppState());
if (SessionManager.getInstance().perfSession().isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.collectGaugeMetricOnce(SessionManager.getInstance().perfSession().getTimer());
return;
}
return;
}
logger.error("Trace name is empty, no log is sent to server");
}
}
public final void setEndTimeOfLastStage(Timer timer) {
if (this.subtraces.isEmpty()) {
return;
}
Trace trace = (Trace) this.subtraces.get(this.subtraces.size() - 1);
if (trace.endTime == null) {
trace.endTime = timer;
}
}
public final Counter obtainOrCreateCounterByName(String str) {
Counter counter = (Counter) this.counterNameToCounterMap.get(str);
if (counter != null) {
return counter;
}
Counter counter2 = new Counter(str);
this.counterNameToCounterMap.put(str, counter2);
return counter2;
}
@Keep
public void incrementMetric(@NonNull String str, long j) {
String validateMetricName = PerfMetricValidator.validateMetricName(str);
if (validateMetricName != null) {
logger.error("Cannot increment metric '%s'. Metric name is invalid.(%s)", str, validateMetricName);
return;
}
if (!hasStarted()) {
logger.warn("Cannot increment metric '%s' for trace '%s' because it's not started", str, this.name);
} else {
if (isStopped()) {
logger.warn("Cannot increment metric '%s' for trace '%s' because it's been stopped", str, this.name);
return;
}
Counter obtainOrCreateCounterByName = obtainOrCreateCounterByName(str.trim());
obtainOrCreateCounterByName.increment(j);
logger.debug("Incrementing metric '%s' to %d on trace '%s'", str, Long.valueOf(obtainOrCreateCounterByName.getCount()), this.name);
}
}
@Keep
public long getLongMetric(@NonNull String str) {
Counter counter = str != null ? (Counter) this.counterNameToCounterMap.get(str.trim()) : null;
if (counter == null) {
return 0L;
}
return counter.getCount();
}
@Keep
public void putMetric(@NonNull String str, long j) {
String validateMetricName = PerfMetricValidator.validateMetricName(str);
if (validateMetricName != null) {
logger.error("Cannot set value for metric '%s'. Metric name is invalid.(%s)", str, validateMetricName);
return;
}
if (!hasStarted()) {
logger.warn("Cannot set value for metric '%s' for trace '%s' because it's not started", str, this.name);
} else if (isStopped()) {
logger.warn("Cannot set value for metric '%s' for trace '%s' because it's been stopped", str, this.name);
} else {
obtainOrCreateCounterByName(str.trim()).setCount(j);
logger.debug("Setting metric '%s' to '%s' on trace '%s'", str, Long.valueOf(j), this.name);
}
}
public void finalize() {
try {
if (isActive()) {
logger.warn("Trace '%s' is started but not stopped when it is destructed!", this.name);
incrementTsnsCount(1);
}
} finally {
super.finalize();
}
}
public boolean isActive() {
return hasStarted() && !isStopped();
}
@Override // android.os.Parcelable
@Keep
public void writeToParcel(@NonNull Parcel parcel, int i) {
parcel.writeParcelable(this.parent, 0);
parcel.writeString(this.name);
parcel.writeList(this.subtraces);
parcel.writeMap(this.counterNameToCounterMap);
parcel.writeParcelable(this.startTime, 0);
parcel.writeParcelable(this.endTime, 0);
synchronized (this.sessions) {
parcel.writeList(this.sessions);
}
}
@Keep
public void putAttribute(@NonNull String str, @NonNull String str2) {
boolean z = false;
try {
str = str.trim();
str2 = str2.trim();
checkAttribute(str, str2);
logger.debug("Setting attribute '%s' to '%s' on trace '%s'", str, str2, this.name);
z = true;
} catch (Exception e) {
logger.error("Can not set attribute '%s' with value '%s' (%s)", str, str2, e.getMessage());
}
if (z) {
this.customAttributesMap.put(str, str2);
}
}
public final void checkAttribute(String str, String str2) {
if (isStopped()) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Trace '%s' has been stopped", this.name));
}
if (!this.customAttributesMap.containsKey(str) && this.customAttributesMap.size() >= 5) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Exceeds max limit of number of attributes - %d", 5));
}
PerfMetricValidator.validateAttribute(str, str2);
}
@Keep
public void removeAttribute(@NonNull String str) {
if (isStopped()) {
logger.error("Can't remove a attribute from a Trace that's stopped.");
} else {
this.customAttributesMap.remove(str);
}
}
@Nullable
@Keep
public String getAttribute(@NonNull String str) {
return (String) this.customAttributesMap.get(str);
}
@NonNull
@Keep
public Map<String, String> getAttributes() {
return new HashMap(this.customAttributesMap);
}
public List getSessions() {
List unmodifiableList;
synchronized (this.sessions) {
try {
ArrayList arrayList = new ArrayList();
for (PerfSession perfSession : this.sessions) {
if (perfSession != null) {
arrayList.add(perfSession);
}
}
unmodifiableList = Collections.unmodifiableList(arrayList);
} catch (Throwable th) {
throw th;
}
}
return unmodifiableList;
}
}

View File

@@ -0,0 +1,36 @@
package com.google.firebase.perf.metrics;
import com.google.firebase.perf.v1.PerfSession;
import com.google.firebase.perf.v1.TraceMetric;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes3.dex */
public class TraceMetricBuilder {
public final Trace trace;
public TraceMetricBuilder(Trace trace) {
this.trace = trace;
}
public TraceMetric build() {
TraceMetric.Builder durationUs = TraceMetric.newBuilder().setName(this.trace.getName()).setClientStartTimeUs(this.trace.getStartTime().getMicros()).setDurationUs(this.trace.getStartTime().getDurationMicros(this.trace.getEndTime()));
for (Counter counter : this.trace.getCounters().values()) {
durationUs.putCounters(counter.getName(), counter.getCount());
}
List subtraces = this.trace.getSubtraces();
if (!subtraces.isEmpty()) {
Iterator it = subtraces.iterator();
while (it.hasNext()) {
durationUs.addSubtraces(new TraceMetricBuilder((Trace) it.next()).build());
}
}
durationUs.putAllCustomAttributes(this.trace.getAttributes());
PerfSession[] buildAndSort = com.google.firebase.perf.session.PerfSession.buildAndSort(this.trace.getSessions());
if (buildAndSort != null) {
durationUs.addAllPerfSessions(Arrays.asList(buildAndSort));
}
return (TraceMetric) durationUs.build();
}
}

View File

@@ -0,0 +1,55 @@
package com.google.firebase.perf.metrics.validator;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.v1.ApplicationInfo;
/* loaded from: classes3.dex */
public class FirebasePerfApplicationInfoValidator extends PerfMetricValidator {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final ApplicationInfo applicationInfo;
public FirebasePerfApplicationInfoValidator(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
}
@Override // com.google.firebase.perf.metrics.validator.PerfMetricValidator
public boolean isValidPerfMetric() {
if (isValidApplicationInfo()) {
return true;
}
logger.warn("ApplicationInfo is invalid");
return false;
}
public final boolean isValidApplicationInfo() {
ApplicationInfo applicationInfo = this.applicationInfo;
if (applicationInfo == null) {
logger.warn("ApplicationInfo is null");
return false;
}
if (!applicationInfo.hasGoogleAppId()) {
logger.warn("GoogleAppId is null");
return false;
}
if (!this.applicationInfo.hasAppInstanceId()) {
logger.warn("AppInstanceId is null");
return false;
}
if (!this.applicationInfo.hasApplicationProcessState()) {
logger.warn("ApplicationProcessState is null");
return false;
}
if (!this.applicationInfo.hasAndroidAppInfo()) {
return true;
}
if (!this.applicationInfo.getAndroidAppInfo().hasPackageName()) {
logger.warn("AndroidAppInfo.packageName is null");
return false;
}
if (this.applicationInfo.getAndroidAppInfo().hasSdkVersion()) {
return true;
}
logger.warn("AndroidAppInfo.sdkVersion is null");
return false;
}
}

View File

@@ -0,0 +1,17 @@
package com.google.firebase.perf.metrics.validator;
import com.google.firebase.perf.v1.GaugeMetric;
/* loaded from: classes3.dex */
public final class FirebasePerfGaugeMetricValidator extends PerfMetricValidator {
public final GaugeMetric gaugeMetric;
public FirebasePerfGaugeMetricValidator(GaugeMetric gaugeMetric) {
this.gaugeMetric = gaugeMetric;
}
@Override // com.google.firebase.perf.metrics.validator.PerfMetricValidator
public boolean isValidPerfMetric() {
return this.gaugeMetric.hasSessionId() && (this.gaugeMetric.getCpuMetricReadingsCount() > 0 || this.gaugeMetric.getAndroidMemoryReadingsCount() > 0 || (this.gaugeMetric.hasGaugeMetadata() && this.gaugeMetric.getGaugeMetadata().hasMaxAppJavaHeapMemoryKb()));
}
}

View File

@@ -0,0 +1,154 @@
package com.google.firebase.perf.metrics.validator;
import android.content.Context;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.URLAllowlist;
import com.google.firebase.perf.v1.NetworkRequestMetric;
import java.net.URI;
/* loaded from: classes3.dex */
public final class FirebasePerfNetworkValidator extends PerfMetricValidator {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final Context appContext;
public final NetworkRequestMetric networkMetric;
public final boolean isValidHttpResponseCode(int i) {
return i > 0;
}
public final boolean isValidPayload(long j) {
return j >= 0;
}
public final boolean isValidPort(int i) {
return i == -1 || i > 0;
}
public final boolean isValidTime(long j) {
return j >= 0;
}
public final boolean isValidUserInfo(String str) {
return str == null;
}
public FirebasePerfNetworkValidator(NetworkRequestMetric networkRequestMetric, Context context) {
this.appContext = context;
this.networkMetric = networkRequestMetric;
}
@Override // com.google.firebase.perf.metrics.validator.PerfMetricValidator
public boolean isValidPerfMetric() {
if (isEmptyUrl(this.networkMetric.getUrl())) {
logger.warn("URL is missing:" + this.networkMetric.getUrl());
return false;
}
URI resultUrl = getResultUrl(this.networkMetric.getUrl());
if (resultUrl == null) {
logger.warn("URL cannot be parsed");
return false;
}
if (!isAllowlisted(resultUrl, this.appContext)) {
logger.warn("URL fails allowlist rule: " + resultUrl);
return false;
}
if (!isValidHost(resultUrl.getHost())) {
logger.warn("URL host is null or invalid");
return false;
}
if (!isValidScheme(resultUrl.getScheme())) {
logger.warn("URL scheme is null or invalid");
return false;
}
if (!isValidUserInfo(resultUrl.getUserInfo())) {
logger.warn("URL user info is null");
return false;
}
if (!isValidPort(resultUrl.getPort())) {
logger.warn("URL port is less than or equal to 0");
return false;
}
if (!isValidHttpMethod(this.networkMetric.hasHttpMethod() ? this.networkMetric.getHttpMethod() : null)) {
logger.warn("HTTP Method is null or invalid: " + this.networkMetric.getHttpMethod());
return false;
}
if (this.networkMetric.hasHttpResponseCode() && !isValidHttpResponseCode(this.networkMetric.getHttpResponseCode())) {
logger.warn("HTTP ResponseCode is a negative value:" + this.networkMetric.getHttpResponseCode());
return false;
}
if (this.networkMetric.hasRequestPayloadBytes() && !isValidPayload(this.networkMetric.getRequestPayloadBytes())) {
logger.warn("Request Payload is a negative value:" + this.networkMetric.getRequestPayloadBytes());
return false;
}
if (this.networkMetric.hasResponsePayloadBytes() && !isValidPayload(this.networkMetric.getResponsePayloadBytes())) {
logger.warn("Response Payload is a negative value:" + this.networkMetric.getResponsePayloadBytes());
return false;
}
if (!this.networkMetric.hasClientStartTimeUs() || this.networkMetric.getClientStartTimeUs() <= 0) {
logger.warn("Start time of the request is null, or zero, or a negative value:" + this.networkMetric.getClientStartTimeUs());
return false;
}
if (this.networkMetric.hasTimeToRequestCompletedUs() && !isValidTime(this.networkMetric.getTimeToRequestCompletedUs())) {
logger.warn("Time to complete the request is a negative value:" + this.networkMetric.getTimeToRequestCompletedUs());
return false;
}
if (this.networkMetric.hasTimeToResponseInitiatedUs() && !isValidTime(this.networkMetric.getTimeToResponseInitiatedUs())) {
logger.warn("Time from the start of the request to the start of the response is null or a negative value:" + this.networkMetric.getTimeToResponseInitiatedUs());
return false;
}
if (!this.networkMetric.hasTimeToResponseCompletedUs() || this.networkMetric.getTimeToResponseCompletedUs() <= 0) {
logger.warn("Time from the start of the request to the end of the response is null, negative or zero:" + this.networkMetric.getTimeToResponseCompletedUs());
return false;
}
if (this.networkMetric.hasHttpResponseCode()) {
return true;
}
logger.warn("Did not receive a HTTP Response Code");
return false;
}
public final boolean isEmptyUrl(String str) {
return isBlank(str);
}
public final URI getResultUrl(String str) {
if (str == null) {
return null;
}
try {
return URI.create(str);
} catch (IllegalArgumentException | IllegalStateException e) {
logger.warn("getResultUrl throws exception %s", e.getMessage());
return null;
}
}
public final boolean isAllowlisted(URI uri, Context context) {
if (uri == null) {
return false;
}
return URLAllowlist.isURLAllowlisted(uri, context);
}
public final boolean isValidHost(String str) {
return (str == null || isBlank(str) || str.length() > 255) ? false : true;
}
public final boolean isValidScheme(String str) {
if (str == null) {
return false;
}
return "http".equalsIgnoreCase(str) || "https".equalsIgnoreCase(str);
}
public boolean isValidHttpMethod(NetworkRequestMetric.HttpMethod httpMethod) {
return (httpMethod == null || httpMethod == NetworkRequestMetric.HttpMethod.HTTP_METHOD_UNKNOWN) ? false : true;
}
public final boolean isBlank(String str) {
if (str == null) {
return true;
}
return str.trim().isEmpty();
}
}

View File

@@ -0,0 +1,161 @@
package com.google.firebase.perf.metrics.validator;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Constants$CounterNames;
import com.google.firebase.perf.v1.TraceMetric;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes3.dex */
public final class FirebasePerfTraceValidator extends PerfMetricValidator {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final TraceMetric traceMetric;
public final boolean isValidCounterValue(Long l) {
return l != null;
}
public FirebasePerfTraceValidator(TraceMetric traceMetric) {
this.traceMetric = traceMetric;
}
@Override // com.google.firebase.perf.metrics.validator.PerfMetricValidator
public boolean isValidPerfMetric() {
if (!isValidTrace(this.traceMetric, 0)) {
logger.warn("Invalid Trace:" + this.traceMetric.getName());
return false;
}
if (!hasCounters(this.traceMetric) || areCountersValid(this.traceMetric)) {
return true;
}
logger.warn("Invalid Counters for Trace:" + this.traceMetric.getName());
return false;
}
public final boolean hasCounters(TraceMetric traceMetric) {
if (traceMetric.getCountersCount() > 0) {
return true;
}
Iterator it = traceMetric.getSubtracesList().iterator();
while (it.hasNext()) {
if (((TraceMetric) it.next()).getCountersCount() > 0) {
return true;
}
}
return false;
}
public final boolean areCountersValid(TraceMetric traceMetric) {
return areCountersValid(traceMetric, 0);
}
public final boolean areCountersValid(TraceMetric traceMetric, int i) {
if (traceMetric == null) {
return false;
}
if (i > 1) {
logger.warn("Exceed MAX_SUBTRACE_DEEP:1");
return false;
}
for (Map.Entry entry : traceMetric.getCountersMap().entrySet()) {
if (!isValidCounterId((String) entry.getKey())) {
logger.warn("invalid CounterId:" + ((String) entry.getKey()));
return false;
}
if (!isValidCounterValue((Long) entry.getValue())) {
logger.warn("invalid CounterValue:" + entry.getValue());
return false;
}
}
Iterator it = traceMetric.getSubtracesList().iterator();
while (it.hasNext()) {
if (!areCountersValid((TraceMetric) it.next(), i + 1)) {
return false;
}
}
return true;
}
public final boolean isScreenTrace(TraceMetric traceMetric) {
return traceMetric.getName().startsWith("_st_");
}
public final boolean isValidScreenTrace(TraceMetric traceMetric) {
Long l = (Long) traceMetric.getCountersMap().get(Constants$CounterNames.FRAMES_TOTAL.toString());
return l != null && l.compareTo((Long) 0L) > 0;
}
public final boolean isValidTrace(TraceMetric traceMetric, int i) {
if (traceMetric == null) {
logger.warn("TraceMetric is null");
return false;
}
if (i > 1) {
logger.warn("Exceed MAX_SUBTRACE_DEEP:1");
return false;
}
if (!isValidTraceId(traceMetric.getName())) {
logger.warn("invalid TraceId:" + traceMetric.getName());
return false;
}
if (!isValidTraceDuration(traceMetric)) {
logger.warn("invalid TraceDuration:" + traceMetric.getDurationUs());
return false;
}
if (!traceMetric.hasClientStartTimeUs()) {
logger.warn("clientStartTimeUs is null.");
return false;
}
if (isScreenTrace(traceMetric) && !isValidScreenTrace(traceMetric)) {
logger.warn("non-positive totalFrames in screen trace " + traceMetric.getName());
return false;
}
Iterator it = traceMetric.getSubtracesList().iterator();
while (it.hasNext()) {
if (!isValidTrace((TraceMetric) it.next(), i + 1)) {
return false;
}
}
return areAllAttributesValid(traceMetric.getCustomAttributesMap());
}
public final boolean isValidTraceId(String str) {
if (str == null) {
return false;
}
String trim = str.trim();
return !trim.isEmpty() && trim.length() <= 100;
}
public final boolean isValidTraceDuration(TraceMetric traceMetric) {
return traceMetric != null && traceMetric.getDurationUs() > 0;
}
public final boolean isValidCounterId(String str) {
if (str == null) {
return false;
}
String trim = str.trim();
if (trim.isEmpty()) {
logger.warn("counterId is empty");
return false;
}
if (trim.length() <= 100) {
return true;
}
logger.warn("counterId exceeded max length 100");
return false;
}
public final boolean areAllAttributesValid(Map map) {
for (Map.Entry entry : map.entrySet()) {
try {
PerfMetricValidator.validateAttribute((String) entry.getKey(), (String) entry.getValue());
} catch (IllegalArgumentException e) {
logger.warn(e.getLocalizedMessage());
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,105 @@
package com.google.firebase.perf.metrics.validator;
import android.content.Context;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Constants$CounterNames;
import com.google.firebase.perf.util.Constants$TraceNames;
import com.google.firebase.perf.v1.PerfMetric;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
/* loaded from: classes3.dex */
public abstract class PerfMetricValidator {
public abstract boolean isValidPerfMetric();
public static List getValidators(PerfMetric perfMetric, Context context) {
ArrayList arrayList = new ArrayList();
if (perfMetric.hasTraceMetric()) {
arrayList.add(new FirebasePerfTraceValidator(perfMetric.getTraceMetric()));
}
if (perfMetric.hasNetworkRequestMetric()) {
arrayList.add(new FirebasePerfNetworkValidator(perfMetric.getNetworkRequestMetric(), context));
}
if (perfMetric.hasApplicationInfo()) {
arrayList.add(new FirebasePerfApplicationInfoValidator(perfMetric.getApplicationInfo()));
}
if (perfMetric.hasGaugeMetric()) {
arrayList.add(new FirebasePerfGaugeMetricValidator(perfMetric.getGaugeMetric()));
}
return arrayList;
}
public static boolean isValid(PerfMetric perfMetric, Context context) {
List validators = getValidators(perfMetric, context);
if (validators.isEmpty()) {
AndroidLogger.getInstance().debug("No validators found for PerfMetric.");
return false;
}
Iterator it = validators.iterator();
while (it.hasNext()) {
if (!((PerfMetricValidator) it.next()).isValidPerfMetric()) {
return false;
}
}
return true;
}
public static String validateTraceName(String str) {
if (str == null) {
return "Trace name must not be null";
}
if (str.length() > 100) {
return String.format(Locale.US, "Trace name must not exceed %d characters", 100);
}
if (!str.startsWith("_")) {
return null;
}
for (Constants$TraceNames constants$TraceNames : Constants$TraceNames.values()) {
if (constants$TraceNames.toString().equals(str)) {
return null;
}
}
if (str.startsWith("_st_")) {
return null;
}
return "Trace name must not start with '_'";
}
public static String validateMetricName(String str) {
if (str == null) {
return "Metric name must not be null";
}
if (str.length() > 100) {
return String.format(Locale.US, "Metric name must not exceed %d characters", 100);
}
if (!str.startsWith("_")) {
return null;
}
for (Constants$CounterNames constants$CounterNames : Constants$CounterNames.values()) {
if (constants$CounterNames.toString().equals(str)) {
return null;
}
}
return "Metric name must not start with '_'";
}
public static void validateAttribute(String str, String str2) {
if (str == null || str.length() == 0) {
throw new IllegalArgumentException("Attribute key must not be null or empty");
}
if (str2 == null || str2.length() == 0) {
throw new IllegalArgumentException("Attribute value must not be null or empty");
}
if (str.length() > 40) {
throw new IllegalArgumentException(String.format(Locale.US, "Attribute key length must not exceed %d characters", 40));
}
if (str2.length() > 100) {
throw new IllegalArgumentException(String.format(Locale.US, "Attribute value length must not exceed %d characters", 100));
}
if (!str.matches("^(?!(firebase_|google_|ga_))[A-Za-z][A-Za-z_0-9]*")) {
throw new IllegalArgumentException("Attribute key must start with letter, must only contain alphanumeric characters and underscore and must not start with \"firebase_\", \"google_\" and \"ga_");
}
}
}

View File

@@ -0,0 +1,249 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.protocol.HttpContext;
/* loaded from: classes3.dex */
public class FirebasePerfHttpClient {
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest) throws IOException {
return execute(httpClient, httpUriRequest, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, HttpContext httpContext) throws IOException {
return execute(httpClient, httpUriRequest, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler<T> responseHandler) throws IOException {
return (T) execute(httpClient, httpUriRequest, responseHandler, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler<T> responseHandler, HttpContext httpContext) throws IOException {
return (T) execute(httpClient, httpUriRequest, responseHandler, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest) throws IOException {
return execute(httpClient, httpHost, httpRequest, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) throws IOException {
return execute(httpClient, httpHost, httpRequest, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler) throws IOException {
return (T) execute(httpClient, httpHost, httpRequest, responseHandler, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler, HttpContext httpContext) throws IOException {
return (T) execute(httpClient, httpHost, httpRequest, responseHandler, httpContext, new Timer(), TransportManager.getInstance());
}
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpUriRequest);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpUriRequest, httpContext);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler responseHandler, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpUriRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder));
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler responseHandler, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpUriRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder), httpContext);
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpHost, httpRequest);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpHost, httpRequest, httpContext);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler responseHandler, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpHost, httpRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder));
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler responseHandler, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpHost, httpRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder), httpContext);
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
}

View File

@@ -0,0 +1,80 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/* loaded from: classes3.dex */
public class FirebasePerfOkHttpClient {
@Keep
public static Response execute(Call call) throws IOException {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(TransportManager.getInstance());
Timer timer = new Timer();
long micros = timer.getMicros();
try {
Response execute = call.execute();
sendNetworkMetric(execute, builder, micros, timer.getDurationMicros());
return execute;
} catch (IOException e) {
Request request = call.request();
if (request != null) {
HttpUrl url = request.url();
if (url != null) {
builder.setUrl(url.url().toString());
}
if (request.method() != null) {
builder.setHttpMethod(request.method());
}
}
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static void enqueue(Call call, Callback callback) {
Timer timer = new Timer();
call.enqueue(new InstrumentOkHttpEnqueueCallback(callback, TransportManager.getInstance(), timer, timer.getMicros()));
}
public static void sendNetworkMetric(Response response, NetworkRequestMetricBuilder networkRequestMetricBuilder, long j, long j2) {
Request request = response.request();
if (request == null) {
return;
}
networkRequestMetricBuilder.setUrl(request.url().url().toString());
networkRequestMetricBuilder.setHttpMethod(request.method());
if (request.body() != null) {
long contentLength = request.body().contentLength();
if (contentLength != -1) {
networkRequestMetricBuilder.setRequestPayloadBytes(contentLength);
}
}
ResponseBody body = response.body();
if (body != null) {
long contentLength2 = body.contentLength();
if (contentLength2 != -1) {
networkRequestMetricBuilder.setResponsePayloadBytes(contentLength2);
}
MediaType contentType = body.contentType();
if (contentType != null) {
networkRequestMetricBuilder.setResponseContentType(contentType.toString());
}
}
networkRequestMetricBuilder.setHttpResponseCode(response.code());
networkRequestMetricBuilder.setRequestStartTimeMicros(j);
networkRequestMetricBuilder.setTimeToResponseCompletedMicros(j2);
networkRequestMetricBuilder.build();
}
}

View File

@@ -0,0 +1,108 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.util.URLWrapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import javax.net.ssl.HttpsURLConnection;
/* loaded from: classes3.dex */
public class FirebasePerfUrlConnection {
@Keep
public static InputStream openStream(URL url) throws IOException {
return openStream(new URLWrapper(url), TransportManager.getInstance(), new Timer());
}
public static InputStream openStream(URLWrapper uRLWrapper, TransportManager transportManager, Timer timer) {
if (!TransportManager.getInstance().isInitialized()) {
return uRLWrapper.openConnection().getInputStream();
}
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getInputStream();
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getInputStream();
}
return openConnection.getInputStream();
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static Object getContent(URL url) throws IOException {
return getContent(new URLWrapper(url), TransportManager.getInstance(), new Timer());
}
@Keep
public static Object getContent(URL url, Class[] clsArr) throws IOException {
return getContent(new URLWrapper(url), clsArr, TransportManager.getInstance(), new Timer());
}
public static Object getContent(URLWrapper uRLWrapper, TransportManager transportManager, Timer timer) {
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getContent();
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getContent();
}
return openConnection.getContent();
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object getContent(URLWrapper uRLWrapper, Class[] clsArr, TransportManager transportManager, Timer timer) {
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getContent(clsArr);
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getContent(clsArr);
}
return openConnection.getContent(clsArr);
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static Object instrument(Object obj) throws IOException {
if (obj instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) obj, new Timer(), NetworkRequestMetricBuilder.builder(TransportManager.getInstance()));
}
return obj instanceof HttpURLConnection ? new InstrHttpURLConnection((HttpURLConnection) obj, new Timer(), NetworkRequestMetricBuilder.builder(TransportManager.getInstance())) : obj;
}
}

View File

@@ -0,0 +1,179 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes3.dex */
public final class InstrHttpInputStream extends InputStream {
public final InputStream inputStream;
public final NetworkRequestMetricBuilder networkMetricBuilder;
public long timeToResponseInitiated;
public final Timer timer;
public long bytesRead = -1;
public long timeToResponseLastRead = -1;
public InstrHttpInputStream(InputStream inputStream, NetworkRequestMetricBuilder networkRequestMetricBuilder, Timer timer) {
this.timer = timer;
this.inputStream = inputStream;
this.networkMetricBuilder = networkRequestMetricBuilder;
this.timeToResponseInitiated = networkRequestMetricBuilder.getTimeToResponseInitiatedMicros();
}
@Override // java.io.InputStream
public int available() {
try {
return this.inputStream.available();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() {
long durationMicros = this.timer.getDurationMicros();
if (this.timeToResponseLastRead == -1) {
this.timeToResponseLastRead = durationMicros;
}
try {
this.inputStream.close();
long j = this.bytesRead;
if (j != -1) {
this.networkMetricBuilder.setResponsePayloadBytes(j);
}
long j2 = this.timeToResponseInitiated;
if (j2 != -1) {
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(j2);
}
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timeToResponseLastRead);
this.networkMetricBuilder.build();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream
public void mark(int i) {
this.inputStream.mark(i);
}
@Override // java.io.InputStream
public boolean markSupported() {
return this.inputStream.markSupported();
}
@Override // java.io.InputStream
public int read() {
try {
int read = this.inputStream.read();
long durationMicros = this.timer.getDurationMicros();
if (this.timeToResponseInitiated == -1) {
this.timeToResponseInitiated = durationMicros;
}
if (read == -1 && this.timeToResponseLastRead == -1) {
this.timeToResponseLastRead = durationMicros;
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
this.networkMetricBuilder.build();
} else {
long j = this.bytesRead + 1;
this.bytesRead = j;
this.networkMetricBuilder.setResponsePayloadBytes(j);
}
return read;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) {
try {
int read = this.inputStream.read(bArr, i, i2);
long durationMicros = this.timer.getDurationMicros();
if (this.timeToResponseInitiated == -1) {
this.timeToResponseInitiated = durationMicros;
}
if (read == -1 && this.timeToResponseLastRead == -1) {
this.timeToResponseLastRead = durationMicros;
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
this.networkMetricBuilder.build();
} else {
long j = this.bytesRead + read;
this.bytesRead = j;
this.networkMetricBuilder.setResponsePayloadBytes(j);
}
return read;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream
public int read(byte[] bArr) {
try {
int read = this.inputStream.read(bArr);
long durationMicros = this.timer.getDurationMicros();
if (this.timeToResponseInitiated == -1) {
this.timeToResponseInitiated = durationMicros;
}
if (read == -1 && this.timeToResponseLastRead == -1) {
this.timeToResponseLastRead = durationMicros;
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
this.networkMetricBuilder.build();
} else {
long j = this.bytesRead + read;
this.bytesRead = j;
this.networkMetricBuilder.setResponsePayloadBytes(j);
}
return read;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream
public void reset() {
try {
this.inputStream.reset();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.InputStream
public long skip(long j) {
try {
long skip = this.inputStream.skip(j);
long durationMicros = this.timer.getDurationMicros();
if (this.timeToResponseInitiated == -1) {
this.timeToResponseInitiated = durationMicros;
}
if (skip == -1 && this.timeToResponseLastRead == -1) {
this.timeToResponseLastRead = durationMicros;
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
} else {
long j2 = this.bytesRead + skip;
this.bytesRead = j2;
this.networkMetricBuilder.setResponsePayloadBytes(j2);
}
return skip;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
}

View File

@@ -0,0 +1,89 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import java.io.OutputStream;
/* loaded from: classes3.dex */
public final class InstrHttpOutputStream extends OutputStream {
public long bytesWritten = -1;
public NetworkRequestMetricBuilder networkMetricBuilder;
public final OutputStream outputStream;
public final Timer timer;
public InstrHttpOutputStream(OutputStream outputStream, NetworkRequestMetricBuilder networkRequestMetricBuilder, Timer timer) {
this.outputStream = outputStream;
this.networkMetricBuilder = networkRequestMetricBuilder;
this.timer = timer;
}
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() {
long j = this.bytesWritten;
if (j != -1) {
this.networkMetricBuilder.setRequestPayloadBytes(j);
}
this.networkMetricBuilder.setTimeToRequestCompletedMicros(this.timer.getDurationMicros());
try {
this.outputStream.close();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream, java.io.Flushable
public void flush() {
try {
this.outputStream.flush();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(int i) {
try {
this.outputStream.write(i);
long j = this.bytesWritten + 1;
this.bytesWritten = j;
this.networkMetricBuilder.setRequestPayloadBytes(j);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(byte[] bArr) {
try {
this.outputStream.write(bArr);
long length = this.bytesWritten + bArr.length;
this.bytesWritten = length;
this.networkMetricBuilder.setRequestPayloadBytes(length);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(byte[] bArr, int i, int i2) {
try {
this.outputStream.write(bArr, i, i2);
long j = this.bytesWritten + i2;
this.bytesWritten = j;
this.networkMetricBuilder.setRequestPayloadBytes(j);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
}

View File

@@ -0,0 +1,298 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Permission;
import java.util.Map;
/* loaded from: classes3.dex */
public final class InstrHttpURLConnection extends HttpURLConnection {
public final InstrURLConnectionBase delegate;
public InstrHttpURLConnection(HttpURLConnection httpURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
super(httpURLConnection.getURL());
this.delegate = new InstrURLConnectionBase(httpURLConnection, timer, networkRequestMetricBuilder);
}
@Override // java.net.URLConnection
public void connect() {
this.delegate.connect();
}
@Override // java.net.HttpURLConnection
public void disconnect() {
this.delegate.disconnect();
}
@Override // java.net.URLConnection
public Object getContent() {
return this.delegate.getContent();
}
@Override // java.net.URLConnection
public Object getContent(Class[] clsArr) {
return this.delegate.getContent(clsArr);
}
@Override // java.net.URLConnection
public InputStream getInputStream() {
return this.delegate.getInputStream();
}
@Override // java.net.URLConnection
public long getLastModified() {
return this.delegate.getLastModified();
}
@Override // java.net.URLConnection
public OutputStream getOutputStream() {
return this.delegate.getOutputStream();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public Permission getPermission() {
return this.delegate.getPermission();
}
@Override // java.net.HttpURLConnection
public int getResponseCode() {
return this.delegate.getResponseCode();
}
@Override // java.net.HttpURLConnection
public String getResponseMessage() {
return this.delegate.getResponseMessage();
}
@Override // java.net.URLConnection
public long getExpiration() {
return this.delegate.getExpiration();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderField(int i) {
return this.delegate.getHeaderField(i);
}
@Override // java.net.URLConnection
public String getHeaderField(String str) {
return this.delegate.getHeaderField(str);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public long getHeaderFieldDate(String str, long j) {
return this.delegate.getHeaderFieldDate(str, j);
}
@Override // java.net.URLConnection
public int getHeaderFieldInt(String str, int i) {
return this.delegate.getHeaderFieldInt(str, i);
}
@Override // java.net.URLConnection
public long getHeaderFieldLong(String str, long j) {
return this.delegate.getHeaderFieldLong(str, j);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderFieldKey(int i) {
return this.delegate.getHeaderFieldKey(i);
}
@Override // java.net.URLConnection
public Map getHeaderFields() {
return this.delegate.getHeaderFields();
}
@Override // java.net.URLConnection
public String getContentEncoding() {
return this.delegate.getContentEncoding();
}
@Override // java.net.URLConnection
public int getContentLength() {
return this.delegate.getContentLength();
}
@Override // java.net.URLConnection
public long getContentLengthLong() {
return this.delegate.getContentLengthLong();
}
@Override // java.net.URLConnection
public String getContentType() {
return this.delegate.getContentType();
}
@Override // java.net.URLConnection
public long getDate() {
return this.delegate.getDate();
}
@Override // java.net.URLConnection
public void addRequestProperty(String str, String str2) {
this.delegate.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override // java.net.URLConnection
public boolean getAllowUserInteraction() {
return this.delegate.getAllowUserInteraction();
}
@Override // java.net.URLConnection
public int getConnectTimeout() {
return this.delegate.getConnectTimeout();
}
@Override // java.net.URLConnection
public boolean getDefaultUseCaches() {
return this.delegate.getDefaultUseCaches();
}
@Override // java.net.URLConnection
public boolean getDoInput() {
return this.delegate.getDoInput();
}
@Override // java.net.URLConnection
public boolean getDoOutput() {
return this.delegate.getDoOutput();
}
@Override // java.net.HttpURLConnection
public InputStream getErrorStream() {
return this.delegate.getErrorStream();
}
@Override // java.net.URLConnection
public long getIfModifiedSince() {
return this.delegate.getIfModifiedSince();
}
@Override // java.net.HttpURLConnection
public boolean getInstanceFollowRedirects() {
return this.delegate.getInstanceFollowRedirects();
}
@Override // java.net.URLConnection
public int getReadTimeout() {
return this.delegate.getReadTimeout();
}
@Override // java.net.HttpURLConnection
public String getRequestMethod() {
return this.delegate.getRequestMethod();
}
@Override // java.net.URLConnection
public Map getRequestProperties() {
return this.delegate.getRequestProperties();
}
@Override // java.net.URLConnection
public String getRequestProperty(String str) {
return this.delegate.getRequestProperty(str);
}
@Override // java.net.URLConnection
public URL getURL() {
return this.delegate.getURL();
}
@Override // java.net.URLConnection
public boolean getUseCaches() {
return this.delegate.getUseCaches();
}
public int hashCode() {
return this.delegate.hashCode();
}
@Override // java.net.URLConnection
public void setAllowUserInteraction(boolean z) {
this.delegate.setAllowUserInteraction(z);
}
@Override // java.net.HttpURLConnection
public void setChunkedStreamingMode(int i) {
this.delegate.setChunkedStreamingMode(i);
}
@Override // java.net.URLConnection
public void setConnectTimeout(int i) {
this.delegate.setConnectTimeout(i);
}
@Override // java.net.URLConnection
public void setDefaultUseCaches(boolean z) {
this.delegate.setDefaultUseCaches(z);
}
@Override // java.net.URLConnection
public void setDoInput(boolean z) {
this.delegate.setDoInput(z);
}
@Override // java.net.URLConnection
public void setDoOutput(boolean z) {
this.delegate.setDoOutput(z);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(int i) {
this.delegate.setFixedLengthStreamingMode(i);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(long j) {
this.delegate.setFixedLengthStreamingMode(j);
}
@Override // java.net.URLConnection
public void setIfModifiedSince(long j) {
this.delegate.setIfModifiedSince(j);
}
@Override // java.net.HttpURLConnection
public void setInstanceFollowRedirects(boolean z) {
this.delegate.setInstanceFollowRedirects(z);
}
@Override // java.net.URLConnection
public void setReadTimeout(int i) {
this.delegate.setReadTimeout(i);
}
@Override // java.net.HttpURLConnection
public void setRequestMethod(String str) {
this.delegate.setRequestMethod(str);
}
@Override // java.net.URLConnection
public void setRequestProperty(String str, String str2) {
this.delegate.setRequestProperty(str, str2);
}
@Override // java.net.URLConnection
public void setUseCaches(boolean z) {
this.delegate.setUseCaches(z);
}
@Override // java.net.URLConnection
public String toString() {
return this.delegate.toString();
}
@Override // java.net.HttpURLConnection
public boolean usingProxy() {
return this.delegate.usingProxy();
}
}

View File

@@ -0,0 +1,349 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.Permission;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
/* loaded from: classes3.dex */
public final class InstrHttpsURLConnection extends HttpsURLConnection {
public final InstrURLConnectionBase delegate;
public final HttpsURLConnection httpsURLConnection;
public InstrHttpsURLConnection(HttpsURLConnection httpsURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
super(httpsURLConnection.getURL());
this.httpsURLConnection = httpsURLConnection;
this.delegate = new InstrURLConnectionBase(httpsURLConnection, timer, networkRequestMetricBuilder);
}
@Override // java.net.URLConnection
public void connect() {
this.delegate.connect();
}
@Override // java.net.HttpURLConnection
public void disconnect() {
this.delegate.disconnect();
}
@Override // java.net.URLConnection
public Object getContent() {
return this.delegate.getContent();
}
@Override // java.net.URLConnection
public Object getContent(Class[] clsArr) {
return this.delegate.getContent(clsArr);
}
@Override // java.net.URLConnection
public InputStream getInputStream() {
return this.delegate.getInputStream();
}
@Override // java.net.URLConnection
public long getLastModified() {
return this.delegate.getLastModified();
}
@Override // java.net.URLConnection
public OutputStream getOutputStream() {
return this.delegate.getOutputStream();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public Permission getPermission() {
return this.delegate.getPermission();
}
@Override // java.net.HttpURLConnection
public int getResponseCode() {
return this.delegate.getResponseCode();
}
@Override // java.net.HttpURLConnection
public String getResponseMessage() {
return this.delegate.getResponseMessage();
}
@Override // java.net.URLConnection
public long getExpiration() {
return this.delegate.getExpiration();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderField(int i) {
return this.delegate.getHeaderField(i);
}
@Override // java.net.URLConnection
public String getHeaderField(String str) {
return this.delegate.getHeaderField(str);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public long getHeaderFieldDate(String str, long j) {
return this.delegate.getHeaderFieldDate(str, j);
}
@Override // java.net.URLConnection
public int getHeaderFieldInt(String str, int i) {
return this.delegate.getHeaderFieldInt(str, i);
}
@Override // java.net.URLConnection
public long getHeaderFieldLong(String str, long j) {
return this.delegate.getHeaderFieldLong(str, j);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderFieldKey(int i) {
return this.delegate.getHeaderFieldKey(i);
}
@Override // java.net.URLConnection
public Map getHeaderFields() {
return this.delegate.getHeaderFields();
}
@Override // java.net.URLConnection
public String getContentEncoding() {
return this.delegate.getContentEncoding();
}
@Override // java.net.URLConnection
public int getContentLength() {
return this.delegate.getContentLength();
}
@Override // java.net.URLConnection
public long getContentLengthLong() {
return this.delegate.getContentLengthLong();
}
@Override // java.net.URLConnection
public String getContentType() {
return this.delegate.getContentType();
}
@Override // java.net.URLConnection
public long getDate() {
return this.delegate.getDate();
}
@Override // java.net.URLConnection
public void addRequestProperty(String str, String str2) {
this.delegate.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override // java.net.URLConnection
public boolean getAllowUserInteraction() {
return this.delegate.getAllowUserInteraction();
}
@Override // java.net.URLConnection
public int getConnectTimeout() {
return this.delegate.getConnectTimeout();
}
@Override // java.net.URLConnection
public boolean getDefaultUseCaches() {
return this.delegate.getDefaultUseCaches();
}
@Override // java.net.URLConnection
public boolean getDoInput() {
return this.delegate.getDoInput();
}
@Override // java.net.URLConnection
public boolean getDoOutput() {
return this.delegate.getDoOutput();
}
@Override // java.net.HttpURLConnection
public InputStream getErrorStream() {
return this.delegate.getErrorStream();
}
@Override // java.net.URLConnection
public long getIfModifiedSince() {
return this.delegate.getIfModifiedSince();
}
@Override // java.net.HttpURLConnection
public boolean getInstanceFollowRedirects() {
return this.delegate.getInstanceFollowRedirects();
}
@Override // java.net.URLConnection
public int getReadTimeout() {
return this.delegate.getReadTimeout();
}
@Override // java.net.HttpURLConnection
public String getRequestMethod() {
return this.delegate.getRequestMethod();
}
@Override // java.net.URLConnection
public Map getRequestProperties() {
return this.delegate.getRequestProperties();
}
@Override // java.net.URLConnection
public String getRequestProperty(String str) {
return this.delegate.getRequestProperty(str);
}
@Override // java.net.URLConnection
public URL getURL() {
return this.delegate.getURL();
}
@Override // java.net.URLConnection
public boolean getUseCaches() {
return this.delegate.getUseCaches();
}
public int hashCode() {
return this.delegate.hashCode();
}
@Override // java.net.URLConnection
public void setAllowUserInteraction(boolean z) {
this.delegate.setAllowUserInteraction(z);
}
@Override // java.net.HttpURLConnection
public void setChunkedStreamingMode(int i) {
this.delegate.setChunkedStreamingMode(i);
}
@Override // java.net.URLConnection
public void setConnectTimeout(int i) {
this.delegate.setConnectTimeout(i);
}
@Override // java.net.URLConnection
public void setDefaultUseCaches(boolean z) {
this.delegate.setDefaultUseCaches(z);
}
@Override // java.net.URLConnection
public void setDoInput(boolean z) {
this.delegate.setDoInput(z);
}
@Override // java.net.URLConnection
public void setDoOutput(boolean z) {
this.delegate.setDoOutput(z);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(int i) {
this.delegate.setFixedLengthStreamingMode(i);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(long j) {
this.delegate.setFixedLengthStreamingMode(j);
}
@Override // java.net.URLConnection
public void setIfModifiedSince(long j) {
this.delegate.setIfModifiedSince(j);
}
@Override // java.net.HttpURLConnection
public void setInstanceFollowRedirects(boolean z) {
this.delegate.setInstanceFollowRedirects(z);
}
@Override // java.net.URLConnection
public void setReadTimeout(int i) {
this.delegate.setReadTimeout(i);
}
@Override // java.net.HttpURLConnection
public void setRequestMethod(String str) {
this.delegate.setRequestMethod(str);
}
@Override // java.net.URLConnection
public void setRequestProperty(String str, String str2) {
this.delegate.setRequestProperty(str, str2);
}
@Override // java.net.URLConnection
public void setUseCaches(boolean z) {
this.delegate.setUseCaches(z);
}
@Override // java.net.URLConnection
public String toString() {
return this.delegate.toString();
}
@Override // java.net.HttpURLConnection
public boolean usingProxy() {
return this.delegate.usingProxy();
}
@Override // javax.net.ssl.HttpsURLConnection
public String getCipherSuite() {
return this.httpsURLConnection.getCipherSuite();
}
@Override // javax.net.ssl.HttpsURLConnection
public HostnameVerifier getHostnameVerifier() {
return this.httpsURLConnection.getHostnameVerifier();
}
@Override // javax.net.ssl.HttpsURLConnection
public Certificate[] getLocalCertificates() {
return this.httpsURLConnection.getLocalCertificates();
}
@Override // javax.net.ssl.HttpsURLConnection
public Principal getLocalPrincipal() {
return this.httpsURLConnection.getLocalPrincipal();
}
@Override // javax.net.ssl.HttpsURLConnection
public Principal getPeerPrincipal() {
return this.httpsURLConnection.getPeerPrincipal();
}
@Override // javax.net.ssl.HttpsURLConnection
public Certificate[] getServerCertificates() {
return this.httpsURLConnection.getServerCertificates();
}
@Override // javax.net.ssl.HttpsURLConnection
public SSLSocketFactory getSSLSocketFactory() {
return this.httpsURLConnection.getSSLSocketFactory();
}
@Override // javax.net.ssl.HttpsURLConnection
public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
this.httpsURLConnection.setHostnameVerifier(hostnameVerifier);
}
@Override // javax.net.ssl.HttpsURLConnection
public void setSSLSocketFactory(SSLSocketFactory sSLSocketFactory) {
this.httpsURLConnection.setSSLSocketFactory(sSLSocketFactory);
}
}

View File

@@ -0,0 +1,393 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Permission;
import java.util.Map;
/* loaded from: classes3.dex */
public class InstrURLConnectionBase {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final HttpURLConnection httpUrlConnection;
public final NetworkRequestMetricBuilder networkMetricBuilder;
public long timeRequestedInMicros = -1;
public long timeToResponseInitiatedInMicros = -1;
public final Timer timer;
public InstrURLConnectionBase(HttpURLConnection httpURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
this.httpUrlConnection = httpURLConnection;
this.networkMetricBuilder = networkRequestMetricBuilder;
this.timer = timer;
networkRequestMetricBuilder.setUrl(httpURLConnection.getURL().toString());
}
public void connect() {
if (this.timeRequestedInMicros == -1) {
this.timer.reset();
long micros = this.timer.getMicros();
this.timeRequestedInMicros = micros;
this.networkMetricBuilder.setRequestStartTimeMicros(micros);
}
try {
this.httpUrlConnection.connect();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public void disconnect() {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
this.httpUrlConnection.disconnect();
}
public Object getContent() {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
try {
Object content = this.httpUrlConnection.getContent();
if (content instanceof InputStream) {
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
return new InstrHttpInputStream((InputStream) content, this.networkMetricBuilder, this.timer);
}
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
this.networkMetricBuilder.setResponsePayloadBytes(this.httpUrlConnection.getContentLength());
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
return content;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public Object getContent(Class[] clsArr) {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
try {
Object content = this.httpUrlConnection.getContent(clsArr);
if (content instanceof InputStream) {
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
return new InstrHttpInputStream((InputStream) content, this.networkMetricBuilder, this.timer);
}
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
this.networkMetricBuilder.setResponsePayloadBytes(this.httpUrlConnection.getContentLength());
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
return content;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public InputStream getInputStream() {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
try {
InputStream inputStream = this.httpUrlConnection.getInputStream();
return inputStream != null ? new InstrHttpInputStream(inputStream, this.networkMetricBuilder, this.timer) : inputStream;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public long getLastModified() {
updateRequestInfo();
return this.httpUrlConnection.getLastModified();
}
public OutputStream getOutputStream() {
try {
OutputStream outputStream = this.httpUrlConnection.getOutputStream();
return outputStream != null ? new InstrHttpOutputStream(outputStream, this.networkMetricBuilder, this.timer) : outputStream;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public Permission getPermission() {
try {
return this.httpUrlConnection.getPermission();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public int getResponseCode() {
updateRequestInfo();
if (this.timeToResponseInitiatedInMicros == -1) {
long durationMicros = this.timer.getDurationMicros();
this.timeToResponseInitiatedInMicros = durationMicros;
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(durationMicros);
}
try {
int responseCode = this.httpUrlConnection.getResponseCode();
this.networkMetricBuilder.setHttpResponseCode(responseCode);
return responseCode;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public String getResponseMessage() {
updateRequestInfo();
if (this.timeToResponseInitiatedInMicros == -1) {
long durationMicros = this.timer.getDurationMicros();
this.timeToResponseInitiatedInMicros = durationMicros;
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(durationMicros);
}
try {
String responseMessage = this.httpUrlConnection.getResponseMessage();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
return responseMessage;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public long getExpiration() {
updateRequestInfo();
return this.httpUrlConnection.getExpiration();
}
public String getHeaderField(int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderField(i);
}
public String getHeaderField(String str) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderField(str);
}
public long getHeaderFieldDate(String str, long j) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldDate(str, j);
}
public int getHeaderFieldInt(String str, int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldInt(str, i);
}
public long getHeaderFieldLong(String str, long j) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldLong(str, j);
}
public String getHeaderFieldKey(int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldKey(i);
}
public Map getHeaderFields() {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFields();
}
public String getContentEncoding() {
updateRequestInfo();
return this.httpUrlConnection.getContentEncoding();
}
public int getContentLength() {
updateRequestInfo();
return this.httpUrlConnection.getContentLength();
}
public long getContentLengthLong() {
updateRequestInfo();
return this.httpUrlConnection.getContentLengthLong();
}
public String getContentType() {
updateRequestInfo();
return this.httpUrlConnection.getContentType();
}
public long getDate() {
updateRequestInfo();
return this.httpUrlConnection.getDate();
}
public void addRequestProperty(String str, String str2) {
this.httpUrlConnection.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.httpUrlConnection.equals(obj);
}
public boolean getAllowUserInteraction() {
return this.httpUrlConnection.getAllowUserInteraction();
}
public int getConnectTimeout() {
return this.httpUrlConnection.getConnectTimeout();
}
public boolean getDefaultUseCaches() {
return this.httpUrlConnection.getDefaultUseCaches();
}
public boolean getDoInput() {
return this.httpUrlConnection.getDoInput();
}
public boolean getDoOutput() {
return this.httpUrlConnection.getDoOutput();
}
public InputStream getErrorStream() {
updateRequestInfo();
try {
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
} catch (IOException unused) {
logger.debug("IOException thrown trying to obtain the response code");
}
InputStream errorStream = this.httpUrlConnection.getErrorStream();
return errorStream != null ? new InstrHttpInputStream(errorStream, this.networkMetricBuilder, this.timer) : errorStream;
}
public long getIfModifiedSince() {
return this.httpUrlConnection.getIfModifiedSince();
}
public boolean getInstanceFollowRedirects() {
return this.httpUrlConnection.getInstanceFollowRedirects();
}
public int getReadTimeout() {
return this.httpUrlConnection.getReadTimeout();
}
public String getRequestMethod() {
return this.httpUrlConnection.getRequestMethod();
}
public Map getRequestProperties() {
return this.httpUrlConnection.getRequestProperties();
}
public String getRequestProperty(String str) {
return this.httpUrlConnection.getRequestProperty(str);
}
public URL getURL() {
return this.httpUrlConnection.getURL();
}
public boolean getUseCaches() {
return this.httpUrlConnection.getUseCaches();
}
public int hashCode() {
return this.httpUrlConnection.hashCode();
}
public void setAllowUserInteraction(boolean z) {
this.httpUrlConnection.setAllowUserInteraction(z);
}
public void setChunkedStreamingMode(int i) {
this.httpUrlConnection.setChunkedStreamingMode(i);
}
public void setConnectTimeout(int i) {
this.httpUrlConnection.setConnectTimeout(i);
}
public void setDefaultUseCaches(boolean z) {
this.httpUrlConnection.setDefaultUseCaches(z);
}
public void setDoInput(boolean z) {
this.httpUrlConnection.setDoInput(z);
}
public void setDoOutput(boolean z) {
this.httpUrlConnection.setDoOutput(z);
}
public void setFixedLengthStreamingMode(int i) {
this.httpUrlConnection.setFixedLengthStreamingMode(i);
}
public void setFixedLengthStreamingMode(long j) {
this.httpUrlConnection.setFixedLengthStreamingMode(j);
}
public void setIfModifiedSince(long j) {
this.httpUrlConnection.setIfModifiedSince(j);
}
public void setInstanceFollowRedirects(boolean z) {
this.httpUrlConnection.setInstanceFollowRedirects(z);
}
public void setReadTimeout(int i) {
this.httpUrlConnection.setReadTimeout(i);
}
public void setRequestMethod(String str) {
this.httpUrlConnection.setRequestMethod(str);
}
public void setRequestProperty(String str, String str2) {
if ("User-Agent".equalsIgnoreCase(str)) {
this.networkMetricBuilder.setUserAgent(str2);
}
this.httpUrlConnection.setRequestProperty(str, str2);
}
public void setUseCaches(boolean z) {
this.httpUrlConnection.setUseCaches(z);
}
public String toString() {
return this.httpUrlConnection.toString();
}
public boolean usingProxy() {
return this.httpUrlConnection.usingProxy();
}
public final void updateRequestInfo() {
if (this.timeRequestedInMicros == -1) {
this.timer.reset();
long micros = this.timer.getMicros();
this.timeRequestedInMicros = micros;
this.networkMetricBuilder.setRequestStartTimeMicros(micros);
}
String requestMethod = getRequestMethod();
if (requestMethod != null) {
this.networkMetricBuilder.setHttpMethod(requestMethod);
} else if (getDoOutput()) {
this.networkMetricBuilder.setHttpMethod("POST");
} else {
this.networkMetricBuilder.setHttpMethod("GET");
}
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
/* loaded from: classes3.dex */
public class InstrumentApacheHttpResponseHandler implements ResponseHandler {
public final NetworkRequestMetricBuilder networkMetricBuilder;
public final ResponseHandler responseHandlerDelegate;
public final Timer timer;
public InstrumentApacheHttpResponseHandler(ResponseHandler responseHandler, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
this.responseHandlerDelegate = responseHandler;
this.timer = timer;
this.networkMetricBuilder = networkRequestMetricBuilder;
}
@Override // org.apache.http.client.ResponseHandler
public Object handleResponse(HttpResponse httpResponse) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.setHttpResponseCode(httpResponse.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpResponse);
if (apacheHttpMessageContentLength != null) {
this.networkMetricBuilder.setResponsePayloadBytes(apacheHttpMessageContentLength.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(httpResponse);
if (apacheHttpResponseContentType != null) {
this.networkMetricBuilder.setResponseContentType(apacheHttpResponseContentType);
}
this.networkMetricBuilder.build();
return this.responseHandlerDelegate.handleResponse(httpResponse);
}
}

View File

@@ -0,0 +1,50 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.Request;
import okhttp3.Response;
/* loaded from: classes3.dex */
public class InstrumentOkHttpEnqueueCallback implements Callback {
public final Callback callback;
public final NetworkRequestMetricBuilder networkMetricBuilder;
public final long startTimeMicros;
public final Timer timer;
public InstrumentOkHttpEnqueueCallback(Callback callback, TransportManager transportManager, Timer timer, long j) {
this.callback = callback;
this.networkMetricBuilder = NetworkRequestMetricBuilder.builder(transportManager);
this.startTimeMicros = j;
this.timer = timer;
}
@Override // okhttp3.Callback
public void onFailure(Call call, IOException iOException) {
Request request = call.request();
if (request != null) {
HttpUrl url = request.url();
if (url != null) {
this.networkMetricBuilder.setUrl(url.url().toString());
}
if (request.method() != null) {
this.networkMetricBuilder.setHttpMethod(request.method());
}
}
this.networkMetricBuilder.setRequestStartTimeMicros(this.startTimeMicros);
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
this.callback.onFailure(call, iOException);
}
@Override // okhttp3.Callback
public void onResponse(Call call, Response response) {
FirebasePerfOkHttpClient.sendNetworkMetric(response, this.networkMetricBuilder, this.startTimeMicros, this.timer.getDurationMicros());
this.callback.onResponse(call, response);
}
}

View File

@@ -0,0 +1,46 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpMessage;
import org.apache.http.HttpResponse;
/* loaded from: classes3.dex */
public abstract class NetworkRequestMetricBuilderUtil {
public static final Pattern FLG_USER_AGENT_PATTERN = Pattern.compile("(^|.*\\s)datatransport/\\S+ android/($|\\s.*)");
public static Long getApacheHttpMessageContentLength(HttpMessage httpMessage) {
try {
Header firstHeader = httpMessage.getFirstHeader("content-length");
if (firstHeader != null) {
return Long.valueOf(Long.parseLong(firstHeader.getValue()));
}
return null;
} catch (NumberFormatException unused) {
AndroidLogger.getInstance().debug("The content-length value is not a valid number");
return null;
}
}
public static String getApacheHttpResponseContentType(HttpResponse httpResponse) {
String value;
Header firstHeader = httpResponse.getFirstHeader("content-type");
if (firstHeader == null || (value = firstHeader.getValue()) == null) {
return null;
}
return value;
}
public static void logError(NetworkRequestMetricBuilder networkRequestMetricBuilder) {
if (!networkRequestMetricBuilder.hasHttpResponseCode()) {
networkRequestMetricBuilder.setNetworkClientErrorReason();
}
networkRequestMetricBuilder.build();
}
public static boolean isAllowedUserAgent(String str) {
return str == null || !FLG_USER_AGENT_PATTERN.matcher(str).matches();
}
}

View File

@@ -0,0 +1,120 @@
package com.google.firebase.perf.session;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.v1.PerfSession;
import com.google.firebase.perf.v1.SessionVerbosity;
import java.util.List;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class PerfSession implements Parcelable {
public static final Parcelable.Creator<PerfSession> CREATOR = new Parcelable.Creator() { // from class: com.google.firebase.perf.session.PerfSession.1
@Override // android.os.Parcelable.Creator
public PerfSession createFromParcel(Parcel parcel) {
return new PerfSession(parcel);
}
@Override // android.os.Parcelable.Creator
public PerfSession[] newArray(int i) {
return new PerfSession[i];
}
};
public final Timer creationTime;
public boolean isGaugeAndEventCollectionEnabled;
public final String sessionId;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public Timer getTimer() {
return this.creationTime;
}
public boolean isGaugeAndEventCollectionEnabled() {
return this.isGaugeAndEventCollectionEnabled;
}
public boolean isVerbose() {
return this.isGaugeAndEventCollectionEnabled;
}
public String sessionId() {
return this.sessionId;
}
public void setGaugeAndEventCollectionEnabled(boolean z) {
this.isGaugeAndEventCollectionEnabled = z;
}
public static PerfSession createWithId(String str) {
PerfSession perfSession = new PerfSession(str.replace("-", ""), new Clock());
perfSession.setGaugeAndEventCollectionEnabled(shouldCollectGaugesAndEvents());
return perfSession;
}
public PerfSession(String str, Clock clock) {
this.isGaugeAndEventCollectionEnabled = false;
this.sessionId = str;
this.creationTime = clock.getTime();
}
public PerfSession(Parcel parcel) {
this.isGaugeAndEventCollectionEnabled = false;
this.sessionId = parcel.readString();
this.isGaugeAndEventCollectionEnabled = parcel.readByte() != 0;
this.creationTime = (Timer) parcel.readParcelable(Timer.class.getClassLoader());
}
public boolean isSessionRunningTooLong() {
return TimeUnit.MICROSECONDS.toMinutes(this.creationTime.getDurationMicros()) > ConfigResolver.getInstance().getSessionsMaxDurationMinutes();
}
public com.google.firebase.perf.v1.PerfSession build() {
PerfSession.Builder sessionId = com.google.firebase.perf.v1.PerfSession.newBuilder().setSessionId(this.sessionId);
if (this.isGaugeAndEventCollectionEnabled) {
sessionId.addSessionVerbosity(SessionVerbosity.GAUGES_AND_SYSTEM_EVENTS);
}
return (com.google.firebase.perf.v1.PerfSession) sessionId.build();
}
public static com.google.firebase.perf.v1.PerfSession[] buildAndSort(List list) {
if (list.isEmpty()) {
return null;
}
com.google.firebase.perf.v1.PerfSession[] perfSessionArr = new com.google.firebase.perf.v1.PerfSession[list.size()];
com.google.firebase.perf.v1.PerfSession build = ((PerfSession) list.get(0)).build();
boolean z = false;
for (int i = 1; i < list.size(); i++) {
com.google.firebase.perf.v1.PerfSession build2 = ((PerfSession) list.get(i)).build();
if (!z && ((PerfSession) list.get(i)).isVerbose()) {
perfSessionArr[0] = build2;
perfSessionArr[i] = build;
z = true;
} else {
perfSessionArr[i] = build2;
}
}
if (!z) {
perfSessionArr[0] = build;
}
return perfSessionArr;
}
public static boolean shouldCollectGaugesAndEvents() {
ConfigResolver configResolver = ConfigResolver.getInstance();
return configResolver.isPerformanceMonitoringEnabled() && Math.random() < configResolver.getSessionsSamplingRate();
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.sessionId);
parcel.writeByte(this.isGaugeAndEventCollectionEnabled ? (byte) 1 : (byte) 0);
parcel.writeParcelable(this.creationTime, 0);
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.perf.session;
/* loaded from: classes3.dex */
public interface SessionAwareObject {
void updateSession(PerfSession perfSession);
}

View File

@@ -0,0 +1,156 @@
package com.google.firebase.perf.session;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.Keep;
import androidx.annotation.VisibleForTesting;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.application.AppStateUpdateHandler;
import com.google.firebase.perf.session.gauges.GaugeManager;
import com.google.firebase.perf.v1.ApplicationProcessState;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@Keep
/* loaded from: classes3.dex */
public class SessionManager extends AppStateUpdateHandler {
@SuppressLint({"StaticFieldLeak"})
private static final SessionManager instance = new SessionManager();
private final AppStateMonitor appStateMonitor;
private final Set<WeakReference<SessionAwareObject>> clients;
private final GaugeManager gaugeManager;
private PerfSession perfSession;
private Future syncInitFuture;
public static SessionManager getInstance() {
return instance;
}
@VisibleForTesting
public Future getSyncInitFuture() {
return this.syncInitFuture;
}
public final PerfSession perfSession() {
return this.perfSession;
}
@VisibleForTesting
public void setPerfSession(PerfSession perfSession) {
this.perfSession = perfSession;
}
private SessionManager() {
this(GaugeManager.getInstance(), PerfSession.createWithId(UUID.randomUUID().toString()), AppStateMonitor.getInstance());
}
@VisibleForTesting
public SessionManager(GaugeManager gaugeManager, PerfSession perfSession, AppStateMonitor appStateMonitor) {
this.clients = new HashSet();
this.gaugeManager = gaugeManager;
this.perfSession = perfSession;
this.appStateMonitor = appStateMonitor;
registerForAppState();
}
public void setApplicationContext(final Context context) {
final PerfSession perfSession = this.perfSession;
this.syncInitFuture = Executors.newSingleThreadExecutor().submit(new Runnable() { // from class: com.google.firebase.perf.session.SessionManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
SessionManager.this.lambda$setApplicationContext$0(context, perfSession);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$setApplicationContext$0(Context context, PerfSession perfSession) {
this.gaugeManager.initializeGaugeMetadataManager(context);
if (perfSession.isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.logGaugeMetadata(perfSession.sessionId(), ApplicationProcessState.FOREGROUND);
}
}
@Override // com.google.firebase.perf.application.AppStateUpdateHandler, com.google.firebase.perf.application.AppStateMonitor.AppStateCallback
public void onUpdateAppState(ApplicationProcessState applicationProcessState) {
super.onUpdateAppState(applicationProcessState);
if (this.appStateMonitor.isColdStart()) {
return;
}
if (applicationProcessState == ApplicationProcessState.FOREGROUND) {
updatePerfSession(PerfSession.createWithId(UUID.randomUUID().toString()));
} else if (this.perfSession.isSessionRunningTooLong()) {
updatePerfSession(PerfSession.createWithId(UUID.randomUUID().toString()));
} else {
startOrStopCollectingGauges(applicationProcessState);
}
}
public void stopGaugeCollectionIfSessionRunningTooLong() {
if (this.perfSession.isSessionRunningTooLong()) {
this.gaugeManager.stopCollectingGauges();
}
}
public void updatePerfSession(PerfSession perfSession) {
if (perfSession.sessionId() == this.perfSession.sessionId()) {
return;
}
this.perfSession = perfSession;
synchronized (this.clients) {
try {
Iterator<WeakReference<SessionAwareObject>> it = this.clients.iterator();
while (it.hasNext()) {
SessionAwareObject sessionAwareObject = it.next().get();
if (sessionAwareObject != null) {
sessionAwareObject.updateSession(perfSession);
} else {
it.remove();
}
}
} catch (Throwable th) {
throw th;
}
}
logGaugeMetadataIfCollectionEnabled(this.appStateMonitor.getAppState());
startOrStopCollectingGauges(this.appStateMonitor.getAppState());
}
public void initializeGaugeCollection() {
ApplicationProcessState applicationProcessState = ApplicationProcessState.FOREGROUND;
logGaugeMetadataIfCollectionEnabled(applicationProcessState);
startOrStopCollectingGauges(applicationProcessState);
}
public void registerForSessionUpdates(WeakReference<SessionAwareObject> weakReference) {
synchronized (this.clients) {
this.clients.add(weakReference);
}
}
public void unregisterForSessionUpdates(WeakReference<SessionAwareObject> weakReference) {
synchronized (this.clients) {
this.clients.remove(weakReference);
}
}
private void logGaugeMetadataIfCollectionEnabled(ApplicationProcessState applicationProcessState) {
if (this.perfSession.isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.logGaugeMetadata(this.perfSession.sessionId(), applicationProcessState);
}
}
private void startOrStopCollectingGauges(ApplicationProcessState applicationProcessState) {
if (this.perfSession.isGaugeAndEventCollectionEnabled()) {
this.gaugeManager.startCollectingGauges(this.perfSession, applicationProcessState);
} else {
this.gaugeManager.stopCollectingGauges();
}
}
}

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()));
}
}

View File

@@ -0,0 +1,48 @@
package com.google.firebase.perf.transport;
import com.google.android.datatransport.Encoding;
import com.google.android.datatransport.Event;
import com.google.android.datatransport.Transformer;
import com.google.android.datatransport.Transport;
import com.google.android.datatransport.TransportFactory;
import com.google.firebase.inject.Provider;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.v1.PerfMetric;
/* loaded from: classes3.dex */
public final class FlgTransport {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public Transport flgTransport;
public final Provider flgTransportFactoryProvider;
public final String logSourceName;
public FlgTransport(Provider provider, String str) {
this.logSourceName = str;
this.flgTransportFactoryProvider = provider;
}
public void log(PerfMetric perfMetric) {
if (!initializeFlgTransportClient()) {
logger.warn("Unable to dispatch event because Flg Transport is not available");
} else {
this.flgTransport.send(Event.ofData(perfMetric));
}
}
public final boolean initializeFlgTransportClient() {
if (this.flgTransport == null) {
TransportFactory transportFactory = (TransportFactory) this.flgTransportFactoryProvider.get();
if (transportFactory != null) {
this.flgTransport = transportFactory.getTransport(this.logSourceName, PerfMetric.class, Encoding.of("proto"), new Transformer() { // from class: com.google.firebase.perf.transport.FlgTransport$$ExternalSyntheticLambda0
@Override // com.google.android.datatransport.Transformer
public final Object apply(Object obj) {
return ((PerfMetric) obj).toByteArray();
}
});
} else {
logger.warn("Flg TransportFactory is not available at the moment");
}
}
return this.flgTransport != null;
}
}

View File

@@ -0,0 +1,15 @@
package com.google.firebase.perf.transport;
import com.google.firebase.perf.v1.ApplicationProcessState;
import com.google.firebase.perf.v1.PerfMetric;
/* loaded from: classes3.dex */
public final class PendingPerfEvent {
public final ApplicationProcessState appState;
public final PerfMetric.Builder perfMetricBuilder;
public PendingPerfEvent(PerfMetric.Builder builder, ApplicationProcessState applicationProcessState) {
this.perfMetricBuilder = builder;
this.appState = applicationProcessState;
}
}

View File

@@ -0,0 +1,209 @@
package com.google.firebase.perf.transport;
import android.content.Context;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.util.Clock;
import com.google.firebase.perf.util.Constants$TraceNames;
import com.google.firebase.perf.util.Rate;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.util.Utils;
import com.google.firebase.perf.v1.PerfMetric;
import com.google.firebase.perf.v1.PerfSession;
import com.google.firebase.perf.v1.SessionVerbosity;
import com.unity3d.ads.core.domain.InitializeAndroidBoldSDK;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public final class RateLimiter {
public final ConfigResolver configResolver;
public final double fragmentBucketId;
public boolean isLogcatEnabled;
public RateLimiterImpl networkLimiter;
public final double samplingBucketId;
public RateLimiterImpl traceLimiter;
public RateLimiter(Context context, Rate rate, long j) {
this(rate, j, new Clock(), getSamplingBucketId(), getSamplingBucketId(), ConfigResolver.getInstance());
this.isLogcatEnabled = Utils.isDebugLoggingEnabled(context);
}
public static double getSamplingBucketId() {
return new Random().nextDouble();
}
public RateLimiter(Rate rate, long j, Clock clock, double d, double d2, ConfigResolver configResolver) {
this.traceLimiter = null;
this.networkLimiter = null;
boolean z = false;
this.isLogcatEnabled = false;
Utils.checkArgument(0.0d <= d && d < 1.0d, "Sampling bucket ID should be in range [0.0, 1.0).");
if (0.0d <= d2 && d2 < 1.0d) {
z = true;
}
Utils.checkArgument(z, "Fragment sampling bucket ID should be in range [0.0, 1.0).");
this.samplingBucketId = d;
this.fragmentBucketId = d2;
this.configResolver = configResolver;
this.traceLimiter = new RateLimiterImpl(rate, j, clock, configResolver, "Trace", this.isLogcatEnabled);
this.networkLimiter = new RateLimiterImpl(rate, j, clock, configResolver, InitializeAndroidBoldSDK.MSG_NETWORK, this.isLogcatEnabled);
}
public final boolean isDeviceAllowedToSendTraces() {
return this.samplingBucketId < this.configResolver.getTraceSamplingRate();
}
public final boolean isDeviceAllowedToSendNetworkEvents() {
return this.samplingBucketId < this.configResolver.getNetworkRequestSamplingRate();
}
public final boolean isDeviceAllowedToSendFragmentScreenTraces() {
return this.fragmentBucketId < this.configResolver.getFragmentSamplingRate();
}
public boolean isFragmentScreenTrace(PerfMetric perfMetric) {
return perfMetric.hasTraceMetric() && perfMetric.getTraceMetric().getName().startsWith("_st_") && perfMetric.getTraceMetric().containsCustomAttributes("Hosting_activity");
}
public boolean isEventRateLimited(PerfMetric perfMetric) {
if (!isRateLimitApplicable(perfMetric)) {
return false;
}
if (perfMetric.hasNetworkRequestMetric()) {
return !this.networkLimiter.check(perfMetric);
}
if (perfMetric.hasTraceMetric()) {
return !this.traceLimiter.check(perfMetric);
}
return true;
}
public boolean isEventSampled(PerfMetric perfMetric) {
if (perfMetric.hasTraceMetric() && !isDeviceAllowedToSendTraces() && !hasVerboseSessions(perfMetric.getTraceMetric().getPerfSessionsList())) {
return false;
}
if (!isFragmentScreenTrace(perfMetric) || isDeviceAllowedToSendFragmentScreenTraces() || hasVerboseSessions(perfMetric.getTraceMetric().getPerfSessionsList())) {
return !perfMetric.hasNetworkRequestMetric() || isDeviceAllowedToSendNetworkEvents() || hasVerboseSessions(perfMetric.getNetworkRequestMetric().getPerfSessionsList());
}
return false;
}
public final boolean hasVerboseSessions(List list) {
return list.size() > 0 && ((PerfSession) list.get(0)).getSessionVerbosityCount() > 0 && ((PerfSession) list.get(0)).getSessionVerbosity(0) == SessionVerbosity.GAUGES_AND_SYSTEM_EVENTS;
}
public boolean isRateLimitApplicable(PerfMetric perfMetric) {
return (!perfMetric.hasTraceMetric() || (!(perfMetric.getTraceMetric().getName().equals(Constants$TraceNames.FOREGROUND_TRACE_NAME.toString()) || perfMetric.getTraceMetric().getName().equals(Constants$TraceNames.BACKGROUND_TRACE_NAME.toString())) || perfMetric.getTraceMetric().getCountersCount() <= 0)) && !perfMetric.hasGaugeMetric();
}
public void changeRate(boolean z) {
this.traceLimiter.changeRate(z);
this.networkLimiter.changeRate(z);
}
public static class RateLimiterImpl {
public long backgroundCapacity;
public Rate backgroundRate;
public long capacity;
public final Clock clock;
public long foregroundCapacity;
public Rate foregroundRate;
public final boolean isLogcatEnabled;
public Timer lastTimeTokenReplenished;
public Rate rate;
public double tokenCount;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public static final long MICROS_IN_A_SECOND = TimeUnit.SECONDS.toMicros(1);
public RateLimiterImpl(Rate rate, long j, Clock clock, ConfigResolver configResolver, String str, boolean z) {
this.clock = clock;
this.capacity = j;
this.rate = rate;
this.tokenCount = j;
this.lastTimeTokenReplenished = clock.getTime();
setRateByReadingRemoteConfigValues(configResolver, str, z);
this.isLogcatEnabled = z;
}
public synchronized boolean check(PerfMetric perfMetric) {
try {
Timer time = this.clock.getTime();
double durationMicros = (this.lastTimeTokenReplenished.getDurationMicros(time) * this.rate.getTokensPerSeconds()) / MICROS_IN_A_SECOND;
if (durationMicros > 0.0d) {
this.tokenCount = Math.min(this.tokenCount + durationMicros, this.capacity);
this.lastTimeTokenReplenished = time;
}
double d = this.tokenCount;
if (d >= 1.0d) {
this.tokenCount = d - 1.0d;
return true;
}
if (this.isLogcatEnabled) {
logger.warn("Exceeded log rate limit, dropping the log.");
}
return false;
} catch (Throwable th) {
throw th;
}
}
public synchronized void changeRate(boolean z) {
try {
this.rate = z ? this.foregroundRate : this.backgroundRate;
this.capacity = z ? this.foregroundCapacity : this.backgroundCapacity;
} catch (Throwable th) {
throw th;
}
}
public final void setRateByReadingRemoteConfigValues(ConfigResolver configResolver, String str, boolean z) {
long flimitSec = getFlimitSec(configResolver, str);
long flimitEvents = getFlimitEvents(configResolver, str);
TimeUnit timeUnit = TimeUnit.SECONDS;
Rate rate = new Rate(flimitEvents, flimitSec, timeUnit);
this.foregroundRate = rate;
this.foregroundCapacity = flimitEvents;
if (z) {
logger.debug("Foreground %s logging rate:%f, burst capacity:%d", str, rate, Long.valueOf(flimitEvents));
}
long blimitSec = getBlimitSec(configResolver, str);
long blimitEvents = getBlimitEvents(configResolver, str);
Rate rate2 = new Rate(blimitEvents, blimitSec, timeUnit);
this.backgroundRate = rate2;
this.backgroundCapacity = blimitEvents;
if (z) {
logger.debug("Background %s logging rate:%f, capacity:%d", str, rate2, Long.valueOf(blimitEvents));
}
}
public static long getFlimitSec(ConfigResolver configResolver, String str) {
if (str == "Trace") {
return configResolver.getRateLimitSec();
}
return configResolver.getRateLimitSec();
}
public static long getFlimitEvents(ConfigResolver configResolver, String str) {
if (str == "Trace") {
return configResolver.getTraceEventCountForeground();
}
return configResolver.getNetworkEventCountForeground();
}
public static long getBlimitSec(ConfigResolver configResolver, String str) {
if (str == "Trace") {
return configResolver.getRateLimitSec();
}
return configResolver.getRateLimitSec();
}
public static long getBlimitEvents(ConfigResolver configResolver, String str) {
if (str == "Trace") {
return configResolver.getTraceEventCountBackground();
}
return configResolver.getNetworkEventCountBackground();
}
}
}

View File

@@ -0,0 +1,394 @@
package com.google.firebase.perf.transport;
import android.content.Context;
import android.content.pm.PackageManager;
import com.google.firebase.FirebaseApp;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.perf.BuildConfig;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.application.AppStateMonitor;
import com.google.firebase.perf.config.ConfigResolver;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.logging.ConsoleUrlGenerator;
import com.google.firebase.perf.metrics.validator.PerfMetricValidator;
import com.google.firebase.perf.session.SessionManager;
import com.google.firebase.perf.util.Constants$CounterNames;
import com.google.firebase.perf.util.Rate;
import com.google.firebase.perf.v1.AndroidApplicationInfo;
import com.google.firebase.perf.v1.ApplicationInfo;
import com.google.firebase.perf.v1.ApplicationProcessState;
import com.google.firebase.perf.v1.GaugeMetric;
import com.google.firebase.perf.v1.NetworkRequestMetric;
import com.google.firebase.perf.v1.PerfMetric;
import com.google.firebase.perf.v1.PerfMetricOrBuilder;
import com.google.firebase.perf.v1.TraceMetric;
import java.lang.ref.WeakReference;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/* loaded from: classes3.dex */
public class TransportManager implements AppStateMonitor.AppStateCallback {
public Context appContext;
public AppStateMonitor appStateMonitor;
public ApplicationInfo.Builder applicationInfoBuilder;
public final Map cacheMap;
public ConfigResolver configResolver;
public FirebaseApp firebaseApp;
public FirebaseInstallationsApi firebaseInstallationsApi;
public FirebasePerformance firebasePerformance;
public FlgTransport flgTransport;
public Provider flgTransportFactoryProvider;
public String packageName;
public String projectId;
public RateLimiter rateLimiter;
public static final AndroidLogger logger = AndroidLogger.getInstance();
public static final TransportManager instance = new TransportManager();
public final ConcurrentLinkedQueue pendingEventsQueue = new ConcurrentLinkedQueue();
public final AtomicBoolean isTransportInitialized = new AtomicBoolean(false);
public boolean isForegroundState = false;
public ExecutorService executorService = new ThreadPoolExecutor(0, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue());
public static TransportManager getInstance() {
return instance;
}
public TransportManager() {
ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
this.cacheMap = concurrentHashMap;
concurrentHashMap.put("KEY_AVAILABLE_TRACES_FOR_CACHING", 50);
concurrentHashMap.put("KEY_AVAILABLE_NETWORK_REQUESTS_FOR_CACHING", 50);
concurrentHashMap.put("KEY_AVAILABLE_GAUGES_FOR_CACHING", 50);
}
public void initialize(FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, Provider provider) {
this.firebaseApp = firebaseApp;
this.projectId = firebaseApp.getOptions().getProjectId();
this.firebaseInstallationsApi = firebaseInstallationsApi;
this.flgTransportFactoryProvider = provider;
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.syncInit();
}
});
}
public final void syncInit() {
Context applicationContext = this.firebaseApp.getApplicationContext();
this.appContext = applicationContext;
this.packageName = applicationContext.getPackageName();
this.configResolver = ConfigResolver.getInstance();
this.rateLimiter = new RateLimiter(this.appContext, new Rate(100L, 1L, TimeUnit.MINUTES), 500L);
this.appStateMonitor = AppStateMonitor.getInstance();
this.flgTransport = new FlgTransport(this.flgTransportFactoryProvider, this.configResolver.getAndCacheLogSourceName());
finishInitialization();
}
public final void finishInitialization() {
this.appStateMonitor.registerForAppState(new WeakReference(instance));
ApplicationInfo.Builder newBuilder = ApplicationInfo.newBuilder();
this.applicationInfoBuilder = newBuilder;
newBuilder.setGoogleAppId(this.firebaseApp.getOptions().getApplicationId()).setAndroidAppInfo(AndroidApplicationInfo.newBuilder().setPackageName(this.packageName).setSdkVersion(BuildConfig.FIREPERF_VERSION_NAME).setVersionName(getVersionName(this.appContext)));
this.isTransportInitialized.set(true);
while (!this.pendingEventsQueue.isEmpty()) {
final PendingPerfEvent pendingPerfEvent = (PendingPerfEvent) this.pendingEventsQueue.poll();
if (pendingPerfEvent != null) {
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda5
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.lambda$finishInitialization$0(pendingPerfEvent);
}
});
}
}
}
public final /* synthetic */ void lambda$finishInitialization$0(PendingPerfEvent pendingPerfEvent) {
syncLog(pendingPerfEvent.perfMetricBuilder, pendingPerfEvent.appState);
}
@Override // com.google.firebase.perf.application.AppStateMonitor.AppStateCallback
public void onUpdateAppState(ApplicationProcessState applicationProcessState) {
this.isForegroundState = applicationProcessState == ApplicationProcessState.FOREGROUND;
if (isInitialized()) {
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda3
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.lambda$onUpdateAppState$1();
}
});
}
}
public final /* synthetic */ void lambda$onUpdateAppState$1() {
this.rateLimiter.changeRate(this.isForegroundState);
}
public boolean isInitialized() {
return this.isTransportInitialized.get();
}
public void log(final TraceMetric traceMetric, final ApplicationProcessState applicationProcessState) {
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.lambda$log$2(traceMetric, applicationProcessState);
}
});
}
public final /* synthetic */ void lambda$log$2(TraceMetric traceMetric, ApplicationProcessState applicationProcessState) {
syncLog(PerfMetric.newBuilder().setTraceMetric(traceMetric), applicationProcessState);
}
public void log(final NetworkRequestMetric networkRequestMetric, final ApplicationProcessState applicationProcessState) {
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.lambda$log$3(networkRequestMetric, applicationProcessState);
}
});
}
public final /* synthetic */ void lambda$log$3(NetworkRequestMetric networkRequestMetric, ApplicationProcessState applicationProcessState) {
syncLog(PerfMetric.newBuilder().setNetworkRequestMetric(networkRequestMetric), applicationProcessState);
}
public void log(final GaugeMetric gaugeMetric, final ApplicationProcessState applicationProcessState) {
this.executorService.execute(new Runnable() { // from class: com.google.firebase.perf.transport.TransportManager$$ExternalSyntheticLambda4
@Override // java.lang.Runnable
public final void run() {
TransportManager.this.lambda$log$4(gaugeMetric, applicationProcessState);
}
});
}
public final /* synthetic */ void lambda$log$4(GaugeMetric gaugeMetric, ApplicationProcessState applicationProcessState) {
syncLog(PerfMetric.newBuilder().setGaugeMetric(gaugeMetric), applicationProcessState);
}
public final void syncLog(PerfMetric.Builder builder, ApplicationProcessState applicationProcessState) {
if (!isInitialized()) {
if (isAllowedToCache(builder)) {
logger.debug("Transport is not initialized yet, %s will be queued for to be dispatched later", getLogcatMsg(builder));
this.pendingEventsQueue.add(new PendingPerfEvent(builder, applicationProcessState));
return;
}
return;
}
PerfMetric applicationInfoAndBuild = setApplicationInfoAndBuild(builder, applicationProcessState);
if (isAllowedToDispatch(applicationInfoAndBuild)) {
dispatchLog(applicationInfoAndBuild);
SessionManager.getInstance().stopGaugeCollectionIfSessionRunningTooLong();
}
}
public final boolean isAllowedToCache(PerfMetricOrBuilder perfMetricOrBuilder) {
int intValue = ((Integer) this.cacheMap.get("KEY_AVAILABLE_TRACES_FOR_CACHING")).intValue();
int intValue2 = ((Integer) this.cacheMap.get("KEY_AVAILABLE_NETWORK_REQUESTS_FOR_CACHING")).intValue();
int intValue3 = ((Integer) this.cacheMap.get("KEY_AVAILABLE_GAUGES_FOR_CACHING")).intValue();
if (perfMetricOrBuilder.hasTraceMetric() && intValue > 0) {
this.cacheMap.put("KEY_AVAILABLE_TRACES_FOR_CACHING", Integer.valueOf(intValue - 1));
return true;
}
if (perfMetricOrBuilder.hasNetworkRequestMetric() && intValue2 > 0) {
this.cacheMap.put("KEY_AVAILABLE_NETWORK_REQUESTS_FOR_CACHING", Integer.valueOf(intValue2 - 1));
return true;
}
if (perfMetricOrBuilder.hasGaugeMetric() && intValue3 > 0) {
this.cacheMap.put("KEY_AVAILABLE_GAUGES_FOR_CACHING", Integer.valueOf(intValue3 - 1));
return true;
}
logger.debug("%s is not allowed to cache. Cache exhausted the limit (availableTracesForCaching: %d, availableNetworkRequestsForCaching: %d, availableGaugesForCaching: %d).", getLogcatMsg(perfMetricOrBuilder), Integer.valueOf(intValue), Integer.valueOf(intValue2), Integer.valueOf(intValue3));
return false;
}
public final boolean isAllowedToDispatch(PerfMetric perfMetric) {
if (!this.configResolver.isPerformanceMonitoringEnabled()) {
logger.info("Performance collection is not enabled, dropping %s", getLogcatMsg(perfMetric));
return false;
}
if (!perfMetric.getApplicationInfo().hasAppInstanceId()) {
logger.warn("App Instance ID is null or empty, dropping %s", getLogcatMsg(perfMetric));
return false;
}
if (!PerfMetricValidator.isValid(perfMetric, this.appContext)) {
logger.warn("Unable to process the PerfMetric (%s) due to missing or invalid values. See earlier log statements for additional information on the specific missing/invalid values.", getLogcatMsg(perfMetric));
return false;
}
if (!this.rateLimiter.isEventSampled(perfMetric)) {
incrementDropCount(perfMetric);
logger.info("Event dropped due to device sampling - %s", getLogcatMsg(perfMetric));
return false;
}
if (!this.rateLimiter.isEventRateLimited(perfMetric)) {
return true;
}
incrementDropCount(perfMetric);
logger.info("Rate limited (per device) - %s", getLogcatMsg(perfMetric));
return false;
}
public final void dispatchLog(PerfMetric perfMetric) {
if (perfMetric.hasTraceMetric()) {
logger.info("Logging %s. In a minute, visit the Firebase console to view your data: %s", getLogcatMsg(perfMetric), getConsoleUrl(perfMetric.getTraceMetric()));
} else {
logger.info("Logging %s", getLogcatMsg(perfMetric));
}
this.flgTransport.log(perfMetric);
}
public static String getVersionName(Context context) {
try {
String str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
return str == null ? "" : str;
} catch (PackageManager.NameNotFoundException unused) {
return "";
}
}
public final PerfMetric setApplicationInfoAndBuild(PerfMetric.Builder builder, ApplicationProcessState applicationProcessState) {
updateFirebaseInstallationIdIfPossibleAndNeeded();
ApplicationInfo.Builder applicationProcessState2 = this.applicationInfoBuilder.setApplicationProcessState(applicationProcessState);
if (builder.hasTraceMetric() || builder.hasNetworkRequestMetric()) {
applicationProcessState2 = ((ApplicationInfo.Builder) applicationProcessState2.mo856clone()).putAllCustomAttributes(getGlobalCustomAttributes());
}
return (PerfMetric) builder.setApplicationInfo(applicationProcessState2).build();
}
public final Map getGlobalCustomAttributes() {
updateFirebasePerformanceIfPossibleAndNeeded();
FirebasePerformance firebasePerformance = this.firebasePerformance;
if (firebasePerformance != null) {
return firebasePerformance.getAttributes();
}
return Collections.emptyMap();
}
public final void updateFirebasePerformanceIfPossibleAndNeeded() {
if (this.firebasePerformance == null && isInitialized()) {
this.firebasePerformance = FirebasePerformance.getInstance();
}
}
/* JADX WARN: Removed duplicated region for block: B:13:0x0063 */
/* JADX WARN: Removed duplicated region for block: B:15:0x0069 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void updateFirebaseInstallationIdIfPossibleAndNeeded() {
/*
r4 = this;
com.google.firebase.perf.config.ConfigResolver r0 = r4.configResolver
boolean r0 = r0.isPerformanceMonitoringEnabled()
if (r0 == 0) goto L70
com.google.firebase.perf.v1.ApplicationInfo$Builder r0 = r4.applicationInfoBuilder
boolean r0 = r0.hasAppInstanceId()
if (r0 == 0) goto L15
boolean r0 = r4.isForegroundState
if (r0 != 0) goto L15
return
L15:
com.google.firebase.installations.FirebaseInstallationsApi r0 = r4.firebaseInstallationsApi // Catch: java.util.concurrent.TimeoutException -> L27 java.lang.InterruptedException -> L29 java.util.concurrent.ExecutionException -> L2b
com.google.android.gms.tasks.Task r0 = r0.getId() // Catch: java.util.concurrent.TimeoutException -> L27 java.lang.InterruptedException -> L29 java.util.concurrent.ExecutionException -> L2b
java.util.concurrent.TimeUnit r1 = java.util.concurrent.TimeUnit.MILLISECONDS // Catch: java.util.concurrent.TimeoutException -> L27 java.lang.InterruptedException -> L29 java.util.concurrent.ExecutionException -> L2b
r2 = 60000(0xea60, double:2.9644E-319)
java.lang.Object r0 = com.google.android.gms.tasks.Tasks.await(r0, r2, r1) // Catch: java.util.concurrent.TimeoutException -> L27 java.lang.InterruptedException -> L29 java.util.concurrent.ExecutionException -> L2b
java.lang.String r0 = (java.lang.String) r0 // Catch: java.util.concurrent.TimeoutException -> L27 java.lang.InterruptedException -> L29 java.util.concurrent.ExecutionException -> L2b
goto L5d
L27:
r0 = move-exception
goto L2d
L29:
r0 = move-exception
goto L3d
L2b:
r0 = move-exception
goto L4d
L2d:
com.google.firebase.perf.logging.AndroidLogger r1 = com.google.firebase.perf.transport.TransportManager.logger
java.lang.String r0 = r0.getMessage()
java.lang.Object[] r0 = new java.lang.Object[]{r0}
java.lang.String r2 = "Task to retrieve Installation Id is timed out: %s"
r1.error(r2, r0)
goto L5c
L3d:
com.google.firebase.perf.logging.AndroidLogger r1 = com.google.firebase.perf.transport.TransportManager.logger
java.lang.String r0 = r0.getMessage()
java.lang.Object[] r0 = new java.lang.Object[]{r0}
java.lang.String r2 = "Task to retrieve Installation Id is interrupted: %s"
r1.error(r2, r0)
goto L5c
L4d:
com.google.firebase.perf.logging.AndroidLogger r1 = com.google.firebase.perf.transport.TransportManager.logger
java.lang.String r0 = r0.getMessage()
java.lang.Object[] r0 = new java.lang.Object[]{r0}
java.lang.String r2 = "Unable to retrieve Installation Id: %s"
r1.error(r2, r0)
L5c:
r0 = 0
L5d:
boolean r1 = android.text.TextUtils.isEmpty(r0)
if (r1 != 0) goto L69
com.google.firebase.perf.v1.ApplicationInfo$Builder r1 = r4.applicationInfoBuilder
r1.setAppInstanceId(r0)
goto L70
L69:
com.google.firebase.perf.logging.AndroidLogger r0 = com.google.firebase.perf.transport.TransportManager.logger
java.lang.String r1 = "Firebase Installation Id is empty, contact Firebase Support for debugging."
r0.warn(r1)
L70:
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.perf.transport.TransportManager.updateFirebaseInstallationIdIfPossibleAndNeeded():void");
}
public final void incrementDropCount(PerfMetric perfMetric) {
if (perfMetric.hasTraceMetric()) {
this.appStateMonitor.incrementCount(Constants$CounterNames.TRACE_EVENT_RATE_LIMITED.toString(), 1L);
} else if (perfMetric.hasNetworkRequestMetric()) {
this.appStateMonitor.incrementCount(Constants$CounterNames.NETWORK_TRACE_EVENT_RATE_LIMITED.toString(), 1L);
}
}
public static String getLogcatMsg(PerfMetricOrBuilder perfMetricOrBuilder) {
if (perfMetricOrBuilder.hasTraceMetric()) {
return getLogcatMsg(perfMetricOrBuilder.getTraceMetric());
}
if (perfMetricOrBuilder.hasNetworkRequestMetric()) {
return getLogcatMsg(perfMetricOrBuilder.getNetworkRequestMetric());
}
return perfMetricOrBuilder.hasGaugeMetric() ? getLogcatMsg(perfMetricOrBuilder.getGaugeMetric()) : "log";
}
public static String getLogcatMsg(TraceMetric traceMetric) {
return String.format(Locale.ENGLISH, "trace metric: %s (duration: %sms)", traceMetric.getName(), new DecimalFormat("#.####").format(traceMetric.getDurationUs() / 1000.0d));
}
public static String getLogcatMsg(NetworkRequestMetric networkRequestMetric) {
return String.format(Locale.ENGLISH, "network request trace: %s (responseCode: %s, responseTime: %sms)", networkRequestMetric.getUrl(), networkRequestMetric.hasHttpResponseCode() ? String.valueOf(networkRequestMetric.getHttpResponseCode()) : "UNKNOWN", new DecimalFormat("#.####").format((networkRequestMetric.hasTimeToResponseCompletedUs() ? networkRequestMetric.getTimeToResponseCompletedUs() : 0L) / 1000.0d));
}
public static String getLogcatMsg(GaugeMetric gaugeMetric) {
return String.format(Locale.ENGLISH, "gauges (hasMetadata: %b, cpuGaugeCount: %d, memoryGaugeCount: %d)", Boolean.valueOf(gaugeMetric.hasGaugeMetadata()), Integer.valueOf(gaugeMetric.getCpuMetricReadingsCount()), Integer.valueOf(gaugeMetric.getAndroidMemoryReadingsCount()));
}
public final String getConsoleUrl(TraceMetric traceMetric) {
String name = traceMetric.getName();
if (name.startsWith("_st_")) {
return ConsoleUrlGenerator.generateScreenTraceUrl(this.projectId, this.packageName, name);
}
return ConsoleUrlGenerator.generateCustomTraceUrl(this.projectId, this.packageName, name);
}
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.perf.util;
/* loaded from: classes3.dex */
public class Clock {
public Timer getTime() {
return new Timer();
}
}

View File

@@ -0,0 +1,24 @@
package com.google.firebase.perf.util;
import androidx.annotation.NonNull;
/* loaded from: classes3.dex */
public enum Constants$CounterNames {
TRACE_EVENT_RATE_LIMITED("_fstec"),
NETWORK_TRACE_EVENT_RATE_LIMITED("_fsntc"),
TRACE_STARTED_NOT_STOPPED("_tsns"),
FRAMES_TOTAL("_fr_tot"),
FRAMES_SLOW("_fr_slo"),
FRAMES_FROZEN("_fr_fzn");
private String mName;
@Override // java.lang.Enum
public String toString() {
return this.mName;
}
Constants$CounterNames(@NonNull String str) {
this.mName = str;
}
}

View File

@@ -0,0 +1,24 @@
package com.google.firebase.perf.util;
import androidx.annotation.NonNull;
/* loaded from: classes3.dex */
public enum Constants$TraceNames {
APP_START_TRACE_NAME("_as"),
ON_CREATE_TRACE_NAME("_astui"),
ON_START_TRACE_NAME("_astfd"),
ON_RESUME_TRACE_NAME("_asti"),
FOREGROUND_TRACE_NAME("_fs"),
BACKGROUND_TRACE_NAME("_bs");
private String mName;
@Override // java.lang.Enum
public String toString() {
return this.mName;
}
Constants$TraceNames(@NonNull String str) {
this.mName = str;
}
}

View File

@@ -0,0 +1,42 @@
package com.google.firebase.perf.util;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewTreeObserver;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes3.dex */
public class FirstDrawDoneListener implements ViewTreeObserver.OnDrawListener {
public final Runnable callback;
public final Handler mainThreadHandler = new Handler(Looper.getMainLooper());
public final AtomicReference viewReference;
public static void registerForNextDraw(View view, Runnable runnable) {
view.getViewTreeObserver().addOnDrawListener(new FirstDrawDoneListener(view, runnable));
}
public FirstDrawDoneListener(View view, Runnable runnable) {
this.viewReference = new AtomicReference(view);
this.callback = runnable;
}
@Override // android.view.ViewTreeObserver.OnDrawListener
public void onDraw() {
final View view = (View) this.viewReference.getAndSet(null);
if (view == null) {
return;
}
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // from class: com.google.firebase.perf.util.FirstDrawDoneListener$$ExternalSyntheticLambda0
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
public final void onGlobalLayout() {
FirstDrawDoneListener.this.lambda$onDraw$0(view);
}
});
this.mainThreadHandler.postAtFrontOfQueue(this.callback);
}
public final /* synthetic */ void lambda$onDraw$0(View view) {
view.getViewTreeObserver().removeOnDrawListener(this);
}
}

View File

@@ -0,0 +1,71 @@
package com.google.firebase.perf.util;
import android.os.Bundle;
import com.google.firebase.perf.logging.AndroidLogger;
/* loaded from: classes3.dex */
public final class ImmutableBundle {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final Bundle bundle;
public ImmutableBundle() {
this(new Bundle());
}
public ImmutableBundle(Bundle bundle) {
this.bundle = (Bundle) bundle.clone();
}
public boolean containsKey(String str) {
return str != null && this.bundle.containsKey(str);
}
public Optional getBoolean(String str) {
if (!containsKey(str)) {
return Optional.absent();
}
try {
return Optional.fromNullable((Boolean) this.bundle.get(str));
} catch (ClassCastException e) {
logger.debug("Metadata key %s contains type other than boolean: %s", str, e.getMessage());
return Optional.absent();
}
}
public Optional getDouble(String str) {
if (!containsKey(str)) {
return Optional.absent();
}
Object obj = this.bundle.get(str);
if (obj == null) {
return Optional.absent();
}
if (obj instanceof Float) {
return Optional.of(Double.valueOf(((Float) obj).doubleValue()));
}
if (obj instanceof Double) {
return Optional.of((Double) obj);
}
logger.debug("Metadata key %s contains type other than double: %s", str);
return Optional.absent();
}
public Optional getLong(String str) {
if (getInt(str).isAvailable()) {
return Optional.of(Long.valueOf(((Integer) r3.get()).intValue()));
}
return Optional.absent();
}
public final Optional getInt(String str) {
if (!containsKey(str)) {
return Optional.absent();
}
try {
return Optional.fromNullable((Integer) this.bundle.get(str));
} catch (ClassCastException e) {
logger.debug("Metadata key %s contains type other than int: %s", str, e.getMessage());
return Optional.absent();
}
}
}

View File

@@ -0,0 +1,43 @@
package com.google.firebase.perf.util;
import java.util.NoSuchElementException;
/* loaded from: classes3.dex */
public final class Optional {
public final Object value;
public boolean isAvailable() {
return this.value != null;
}
public Optional() {
this.value = null;
}
public Optional(Object obj) {
if (obj == null) {
throw new NullPointerException("value for optional is empty.");
}
this.value = obj;
}
public static Optional absent() {
return new Optional();
}
public static Optional of(Object obj) {
return new Optional(obj);
}
public static Optional fromNullable(Object obj) {
return obj == null ? absent() : of(obj);
}
public Object get() {
Object obj = this.value;
if (obj != null) {
return obj;
}
throw new NoSuchElementException("No value present");
}
}

View File

@@ -0,0 +1,37 @@
package com.google.firebase.perf.util;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewTreeObserver;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes3.dex */
public class PreDrawListener implements ViewTreeObserver.OnPreDrawListener {
public final Runnable callbackBoQ;
public final Runnable callbackFoQ;
public final Handler mainThreadHandler = new Handler(Looper.getMainLooper());
public final AtomicReference viewReference;
public static void registerForNextDraw(View view, Runnable runnable, Runnable runnable2) {
view.getViewTreeObserver().addOnPreDrawListener(new PreDrawListener(view, runnable, runnable2));
}
public PreDrawListener(View view, Runnable runnable, Runnable runnable2) {
this.viewReference = new AtomicReference(view);
this.callbackBoQ = runnable;
this.callbackFoQ = runnable2;
}
@Override // android.view.ViewTreeObserver.OnPreDrawListener
public boolean onPreDraw() {
View view = (View) this.viewReference.getAndSet(null);
if (view == null) {
return true;
}
view.getViewTreeObserver().removeOnPreDrawListener(this);
this.mainThreadHandler.post(this.callbackBoQ);
this.mainThreadHandler.postAtFrontOfQueue(this.callbackFoQ);
return true;
}
}

View File

@@ -0,0 +1,52 @@
package com.google.firebase.perf.util;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class Rate {
public long numTimeUnits;
public long numTokensPerTotalTimeUnit;
public TimeUnit timeUnit;
public Rate(long j, long j2, TimeUnit timeUnit) {
this.numTokensPerTotalTimeUnit = j;
this.numTimeUnits = j2;
this.timeUnit = timeUnit;
}
/* renamed from: com.google.firebase.perf.util.Rate$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$java$util$concurrent$TimeUnit;
static {
int[] iArr = new int[TimeUnit.values().length];
$SwitchMap$java$util$concurrent$TimeUnit = iArr;
try {
iArr[TimeUnit.NANOSECONDS.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$java$util$concurrent$TimeUnit[TimeUnit.MICROSECONDS.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$java$util$concurrent$TimeUnit[TimeUnit.MILLISECONDS.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
public double getTokensPerSeconds() {
int i = AnonymousClass1.$SwitchMap$java$util$concurrent$TimeUnit[this.timeUnit.ordinal()];
if (i == 1) {
return (this.numTokensPerTotalTimeUnit / this.numTimeUnits) * TimeUnit.SECONDS.toNanos(1L);
}
if (i == 2) {
return (this.numTokensPerTotalTimeUnit / this.numTimeUnits) * TimeUnit.SECONDS.toMicros(1L);
}
if (i == 3) {
return (this.numTokensPerTotalTimeUnit / this.numTimeUnits) * TimeUnit.SECONDS.toMillis(1L);
}
return this.numTokensPerTotalTimeUnit / this.timeUnit.toSeconds(this.numTimeUnits);
}
}

View File

@@ -0,0 +1,24 @@
package com.google.firebase.perf.util;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.FrameMetricsCalculator;
import com.google.firebase.perf.metrics.Trace;
/* loaded from: classes3.dex */
public abstract class ScreenTraceUtil {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public static Trace addFrameCounters(Trace trace, FrameMetricsCalculator.PerfFrameMetrics perfFrameMetrics) {
if (perfFrameMetrics.getTotalFrames() > 0) {
trace.putMetric(Constants$CounterNames.FRAMES_TOTAL.toString(), perfFrameMetrics.getTotalFrames());
}
if (perfFrameMetrics.getSlowFrames() > 0) {
trace.putMetric(Constants$CounterNames.FRAMES_SLOW.toString(), perfFrameMetrics.getSlowFrames());
}
if (perfFrameMetrics.getFrozenFrames() > 0) {
trace.putMetric(Constants$CounterNames.FRAMES_FROZEN.toString(), perfFrameMetrics.getFrozenFrames());
}
logger.debug("Screen trace: " + trace.getName() + " _fr_tot:" + perfFrameMetrics.getTotalFrames() + " _fr_slo:" + perfFrameMetrics.getSlowFrames() + " _fr_fzn:" + perfFrameMetrics.getFrozenFrames());
return trace;
}
}

View File

@@ -0,0 +1,65 @@
package com.google.firebase.perf.util;
import android.support.v4.media.session.PlaybackStateCompat;
/* loaded from: classes3.dex */
public enum StorageUnit {
TERABYTES(1099511627776L) { // from class: com.google.firebase.perf.util.StorageUnit.1
@Override // com.google.firebase.perf.util.StorageUnit
public long convert(long j, StorageUnit storageUnit) {
return storageUnit.toTerabytes(j);
}
},
GIGABYTES(1073741824) { // from class: com.google.firebase.perf.util.StorageUnit.2
@Override // com.google.firebase.perf.util.StorageUnit
public long convert(long j, StorageUnit storageUnit) {
return storageUnit.toGigabytes(j);
}
},
MEGABYTES(PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED) { // from class: com.google.firebase.perf.util.StorageUnit.3
@Override // com.google.firebase.perf.util.StorageUnit
public long convert(long j, StorageUnit storageUnit) {
return storageUnit.toMegabytes(j);
}
},
KILOBYTES(PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) { // from class: com.google.firebase.perf.util.StorageUnit.4
@Override // com.google.firebase.perf.util.StorageUnit
public long convert(long j, StorageUnit storageUnit) {
return storageUnit.toKilobytes(j);
}
},
BYTES(1) { // from class: com.google.firebase.perf.util.StorageUnit.5
@Override // com.google.firebase.perf.util.StorageUnit
public long convert(long j, StorageUnit storageUnit) {
return storageUnit.toBytes(j);
}
};
long numBytes;
public abstract long convert(long j, StorageUnit storageUnit);
public long toBytes(long j) {
return j * this.numBytes;
}
StorageUnit(long j) {
this.numBytes = j;
}
public long toKilobytes(long j) {
return (j * this.numBytes) / KILOBYTES.numBytes;
}
public long toMegabytes(long j) {
return (j * this.numBytes) / MEGABYTES.numBytes;
}
public long toGigabytes(long j) {
return (j * this.numBytes) / GIGABYTES.numBytes;
}
public long toTerabytes(long j) {
return (j * this.numBytes) / TERABYTES.numBytes;
}
}

View File

@@ -0,0 +1,81 @@
package com.google.firebase.perf.util;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class Timer implements Parcelable {
public static final Parcelable.Creator<Timer> CREATOR = new Parcelable.Creator() { // from class: com.google.firebase.perf.util.Timer.1
@Override // android.os.Parcelable.Creator
public Timer createFromParcel(Parcel parcel) {
return new Timer(parcel);
}
@Override // android.os.Parcelable.Creator
public Timer[] newArray(int i) {
return new Timer[i];
}
};
public long elapsedRealtimeMicros;
public long wallClockMicros;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public long getMicros() {
return this.wallClockMicros;
}
public static Timer ofElapsedRealtime(long j) {
long micros = TimeUnit.MILLISECONDS.toMicros(j);
return new Timer(wallClockMicros() + (micros - elapsedRealtimeMicros()), micros);
}
public static long wallClockMicros() {
return TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());
}
public static long elapsedRealtimeMicros() {
return TimeUnit.NANOSECONDS.toMicros(SystemClock.elapsedRealtimeNanos());
}
public Timer() {
this(wallClockMicros(), elapsedRealtimeMicros());
}
public Timer(long j, long j2) {
this.wallClockMicros = j;
this.elapsedRealtimeMicros = j2;
}
public Timer(Parcel parcel) {
this(parcel.readLong(), parcel.readLong());
}
public void reset() {
this.wallClockMicros = wallClockMicros();
this.elapsedRealtimeMicros = elapsedRealtimeMicros();
}
public long getDurationMicros() {
return getDurationMicros(new Timer());
}
public long getDurationMicros(Timer timer) {
return timer.elapsedRealtimeMicros - this.elapsedRealtimeMicros;
}
public long getCurrentTimestampMicros() {
return this.wallClockMicros + getDurationMicros();
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeLong(this.wallClockMicros);
parcel.writeLong(this.elapsedRealtimeMicros);
}
}

View File

@@ -0,0 +1,33 @@
package com.google.firebase.perf.util;
import android.content.Context;
import android.content.res.Resources;
import com.google.firebase.perf.logging.AndroidLogger;
import java.net.URI;
/* loaded from: classes3.dex */
public abstract class URLAllowlist {
public static String[] allowlistedDomains;
public static boolean isURLAllowlisted(URI uri, Context context) {
Resources resources = context.getResources();
int identifier = resources.getIdentifier("firebase_performance_whitelisted_domains", "array", context.getPackageName());
if (identifier == 0) {
return true;
}
AndroidLogger.getInstance().debug("Detected domain allowlist, only allowlisted domains will be measured.");
if (allowlistedDomains == null) {
allowlistedDomains = resources.getStringArray(identifier);
}
String host = uri.getHost();
if (host == null) {
return true;
}
for (String str : allowlistedDomains) {
if (host.contains(str)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,21 @@
package com.google.firebase.perf.util;
import java.net.URL;
import java.net.URLConnection;
/* loaded from: classes3.dex */
public class URLWrapper {
public final URL url;
public URLWrapper(URL url) {
this.url = url;
}
public URLConnection openConnection() {
return this.url.openConnection();
}
public String toString() {
return this.url.toString();
}
}

View File

@@ -0,0 +1,65 @@
package com.google.firebase.perf.util;
import android.content.Context;
import android.content.pm.PackageManager;
import com.google.firebase.perf.logging.AndroidLogger;
import okhttp3.HttpUrl;
/* loaded from: classes3.dex */
public abstract class Utils {
public static Boolean isDebugLoggingEnabled;
public static int saturatedIntCast(long j) {
if (j > 2147483647L) {
return Integer.MAX_VALUE;
}
if (j < -2147483648L) {
return Integer.MIN_VALUE;
}
return (int) j;
}
public static String stripSensitiveInfo(String str) {
HttpUrl parse = HttpUrl.parse(str);
return parse != null ? parse.newBuilder().username("").password("").query(null).fragment(null).toString() : str;
}
public static String truncateURL(String str, int i) {
int lastIndexOf;
if (str.length() <= i) {
return str;
}
if (str.charAt(i) == '/') {
return str.substring(0, i);
}
HttpUrl parse = HttpUrl.parse(str);
if (parse == null) {
return str.substring(0, i);
}
if (parse.encodedPath().lastIndexOf(47) >= 0 && (lastIndexOf = str.lastIndexOf(47, i - 1)) >= 0) {
return str.substring(0, lastIndexOf);
}
return str.substring(0, i);
}
public static boolean isDebugLoggingEnabled(Context context) {
Boolean bool = isDebugLoggingEnabled;
if (bool != null) {
return bool.booleanValue();
}
try {
Boolean valueOf = Boolean.valueOf(context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getBoolean("firebase_performance_logcat_enabled", false));
isDebugLoggingEnabled = valueOf;
return valueOf.booleanValue();
} catch (PackageManager.NameNotFoundException | NullPointerException e) {
AndroidLogger.getInstance().debug("No perf logcat meta data found " + e.getMessage());
return false;
}
}
public static void checkArgument(boolean z, String str) {
if (!z) {
throw new IllegalArgumentException(str);
}
}
}

View File

@@ -0,0 +1,160 @@
package com.google.firebase.perf.v1;
import com.google.protobuf.GeneratedMessageLite;
import com.google.protobuf.MessageLiteOrBuilder;
import com.google.protobuf.Parser;
/* loaded from: classes3.dex */
public final class AndroidApplicationInfo extends GeneratedMessageLite implements MessageLiteOrBuilder {
private static final AndroidApplicationInfo DEFAULT_INSTANCE;
public static final int PACKAGE_NAME_FIELD_NUMBER = 1;
private static volatile Parser<AndroidApplicationInfo> PARSER = null;
public static final int SDK_VERSION_FIELD_NUMBER = 2;
public static final int VERSION_NAME_FIELD_NUMBER = 3;
private int bitField0_;
private String packageName_ = "";
private String sdkVersion_ = "";
private String versionName_ = "";
public static AndroidApplicationInfo getDefaultInstance() {
return DEFAULT_INSTANCE;
}
public boolean hasPackageName() {
return (this.bitField0_ & 1) != 0;
}
public boolean hasSdkVersion() {
return (this.bitField0_ & 2) != 0;
}
public final void setPackageName(String str) {
str.getClass();
this.bitField0_ |= 1;
this.packageName_ = str;
}
public final void setSdkVersion(String str) {
str.getClass();
this.bitField0_ |= 2;
this.sdkVersion_ = str;
}
public final void setVersionName(String str) {
str.getClass();
this.bitField0_ |= 4;
this.versionName_ = str;
}
public static Builder newBuilder() {
return (Builder) DEFAULT_INSTANCE.createBuilder();
}
public static final class Builder extends GeneratedMessageLite.Builder implements MessageLiteOrBuilder {
public /* synthetic */ Builder(AnonymousClass1 anonymousClass1) {
this();
}
public Builder() {
super(AndroidApplicationInfo.DEFAULT_INSTANCE);
}
public Builder setPackageName(String str) {
copyOnWrite();
((AndroidApplicationInfo) this.instance).setPackageName(str);
return this;
}
public Builder setSdkVersion(String str) {
copyOnWrite();
((AndroidApplicationInfo) this.instance).setSdkVersion(str);
return this;
}
public Builder setVersionName(String str) {
copyOnWrite();
((AndroidApplicationInfo) this.instance).setVersionName(str);
return this;
}
}
/* renamed from: com.google.firebase.perf.v1.AndroidApplicationInfo$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke;
static {
int[] iArr = new int[GeneratedMessageLite.MethodToInvoke.values().length];
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke = iArr;
try {
iArr[GeneratedMessageLite.MethodToInvoke.NEW_MUTABLE_INSTANCE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.NEW_BUILDER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.BUILD_MESSAGE_INFO.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_DEFAULT_INSTANCE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_PARSER.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_MEMOIZED_IS_INITIALIZED.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.SET_MEMOIZED_IS_INITIALIZED.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
}
}
@Override // com.google.protobuf.GeneratedMessageLite
public final Object dynamicMethod(GeneratedMessageLite.MethodToInvoke methodToInvoke, Object obj, Object obj2) {
AnonymousClass1 anonymousClass1 = null;
switch (AnonymousClass1.$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[methodToInvoke.ordinal()]) {
case 1:
return new AndroidApplicationInfo();
case 2:
return new Builder(anonymousClass1);
case 3:
return GeneratedMessageLite.newMessageInfo(DEFAULT_INSTANCE, "\u0001\u0003\u0000\u0001\u0001\u0003\u0003\u0000\u0000\u0000\u0001ဈ\u0000\u0002ဈ\u0001\u0003ဈ\u0002", new Object[]{"bitField0_", "packageName_", "sdkVersion_", "versionName_"});
case 4:
return DEFAULT_INSTANCE;
case 5:
Parser<AndroidApplicationInfo> parser = PARSER;
if (parser == null) {
synchronized (AndroidApplicationInfo.class) {
try {
parser = PARSER;
if (parser == null) {
parser = new GeneratedMessageLite.DefaultInstanceBasedParser<>(DEFAULT_INSTANCE);
PARSER = parser;
}
} finally {
}
}
}
return parser;
case 6:
return (byte) 1;
case 7:
return null;
default:
throw new UnsupportedOperationException();
}
}
static {
AndroidApplicationInfo androidApplicationInfo = new AndroidApplicationInfo();
DEFAULT_INSTANCE = androidApplicationInfo;
GeneratedMessageLite.registerDefaultInstance(AndroidApplicationInfo.class, androidApplicationInfo);
}
}

View File

@@ -0,0 +1,132 @@
package com.google.firebase.perf.v1;
import com.google.protobuf.GeneratedMessageLite;
import com.google.protobuf.MessageLiteOrBuilder;
import com.google.protobuf.Parser;
/* loaded from: classes3.dex */
public final class AndroidMemoryReading extends GeneratedMessageLite implements MessageLiteOrBuilder {
public static final int CLIENT_TIME_US_FIELD_NUMBER = 1;
private static final AndroidMemoryReading DEFAULT_INSTANCE;
private static volatile Parser<AndroidMemoryReading> PARSER = null;
public static final int USED_APP_JAVA_HEAP_MEMORY_KB_FIELD_NUMBER = 2;
private int bitField0_;
private long clientTimeUs_;
private int usedAppJavaHeapMemoryKb_;
public final void setClientTimeUs(long j) {
this.bitField0_ |= 1;
this.clientTimeUs_ = j;
}
public final void setUsedAppJavaHeapMemoryKb(int i) {
this.bitField0_ |= 2;
this.usedAppJavaHeapMemoryKb_ = i;
}
public static Builder newBuilder() {
return (Builder) DEFAULT_INSTANCE.createBuilder();
}
public static final class Builder extends GeneratedMessageLite.Builder implements MessageLiteOrBuilder {
public /* synthetic */ Builder(AnonymousClass1 anonymousClass1) {
this();
}
public Builder() {
super(AndroidMemoryReading.DEFAULT_INSTANCE);
}
public Builder setClientTimeUs(long j) {
copyOnWrite();
((AndroidMemoryReading) this.instance).setClientTimeUs(j);
return this;
}
public Builder setUsedAppJavaHeapMemoryKb(int i) {
copyOnWrite();
((AndroidMemoryReading) this.instance).setUsedAppJavaHeapMemoryKb(i);
return this;
}
}
/* renamed from: com.google.firebase.perf.v1.AndroidMemoryReading$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke;
static {
int[] iArr = new int[GeneratedMessageLite.MethodToInvoke.values().length];
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke = iArr;
try {
iArr[GeneratedMessageLite.MethodToInvoke.NEW_MUTABLE_INSTANCE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.NEW_BUILDER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.BUILD_MESSAGE_INFO.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_DEFAULT_INSTANCE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_PARSER.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_MEMOIZED_IS_INITIALIZED.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.SET_MEMOIZED_IS_INITIALIZED.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
}
}
@Override // com.google.protobuf.GeneratedMessageLite
public final Object dynamicMethod(GeneratedMessageLite.MethodToInvoke methodToInvoke, Object obj, Object obj2) {
AnonymousClass1 anonymousClass1 = null;
switch (AnonymousClass1.$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[methodToInvoke.ordinal()]) {
case 1:
return new AndroidMemoryReading();
case 2:
return new Builder(anonymousClass1);
case 3:
return GeneratedMessageLite.newMessageInfo(DEFAULT_INSTANCE, "\u0001\u0002\u0000\u0001\u0001\u0002\u0002\u0000\u0000\u0000\u0001ဂ\u0000\u0002င\u0001", new Object[]{"bitField0_", "clientTimeUs_", "usedAppJavaHeapMemoryKb_"});
case 4:
return DEFAULT_INSTANCE;
case 5:
Parser<AndroidMemoryReading> parser = PARSER;
if (parser == null) {
synchronized (AndroidMemoryReading.class) {
try {
parser = PARSER;
if (parser == null) {
parser = new GeneratedMessageLite.DefaultInstanceBasedParser<>(DEFAULT_INSTANCE);
PARSER = parser;
}
} finally {
}
}
}
return parser;
case 6:
return (byte) 1;
case 7:
return null;
default:
throw new UnsupportedOperationException();
}
}
static {
AndroidMemoryReading androidMemoryReading = new AndroidMemoryReading();
DEFAULT_INSTANCE = androidMemoryReading;
GeneratedMessageLite.registerDefaultInstance(AndroidMemoryReading.class, androidMemoryReading);
}
}

View File

@@ -0,0 +1,223 @@
package com.google.firebase.perf.v1;
import com.google.firebase.perf.v1.AndroidApplicationInfo;
import com.google.protobuf.GeneratedMessageLite;
import com.google.protobuf.MapEntryLite;
import com.google.protobuf.MapFieldLite;
import com.google.protobuf.MessageLiteOrBuilder;
import com.google.protobuf.Parser;
import com.google.protobuf.WireFormat;
import java.util.Map;
/* loaded from: classes3.dex */
public final class ApplicationInfo extends GeneratedMessageLite implements MessageLiteOrBuilder {
public static final int ANDROID_APP_INFO_FIELD_NUMBER = 3;
public static final int APPLICATION_PROCESS_STATE_FIELD_NUMBER = 5;
public static final int APP_INSTANCE_ID_FIELD_NUMBER = 2;
public static final int CUSTOM_ATTRIBUTES_FIELD_NUMBER = 6;
private static final ApplicationInfo DEFAULT_INSTANCE;
public static final int GOOGLE_APP_ID_FIELD_NUMBER = 1;
private static volatile Parser<ApplicationInfo> PARSER;
private AndroidApplicationInfo androidAppInfo_;
private int applicationProcessState_;
private int bitField0_;
private MapFieldLite<String, String> customAttributes_ = MapFieldLite.emptyMapField();
private String googleAppId_ = "";
private String appInstanceId_ = "";
public static ApplicationInfo getDefaultInstance() {
return DEFAULT_INSTANCE;
}
public boolean hasAndroidAppInfo() {
return (this.bitField0_ & 4) != 0;
}
public boolean hasAppInstanceId() {
return (this.bitField0_ & 2) != 0;
}
public boolean hasApplicationProcessState() {
return (this.bitField0_ & 8) != 0;
}
public boolean hasGoogleAppId() {
return (this.bitField0_ & 1) != 0;
}
public final void setGoogleAppId(String str) {
str.getClass();
this.bitField0_ |= 1;
this.googleAppId_ = str;
}
public final void setAppInstanceId(String str) {
str.getClass();
this.bitField0_ |= 2;
this.appInstanceId_ = str;
}
public AndroidApplicationInfo getAndroidAppInfo() {
AndroidApplicationInfo androidApplicationInfo = this.androidAppInfo_;
return androidApplicationInfo == null ? AndroidApplicationInfo.getDefaultInstance() : androidApplicationInfo;
}
public final void setAndroidAppInfo(AndroidApplicationInfo androidApplicationInfo) {
androidApplicationInfo.getClass();
this.androidAppInfo_ = androidApplicationInfo;
this.bitField0_ |= 4;
}
public final void setApplicationProcessState(ApplicationProcessState applicationProcessState) {
this.applicationProcessState_ = applicationProcessState.getNumber();
this.bitField0_ |= 8;
}
public static final class CustomAttributesDefaultEntryHolder {
public static final MapEntryLite defaultEntry;
static {
WireFormat.FieldType fieldType = WireFormat.FieldType.STRING;
defaultEntry = MapEntryLite.newDefaultInstance(fieldType, "", fieldType, "");
}
}
public final MapFieldLite internalGetMutableCustomAttributes() {
if (!this.customAttributes_.isMutable()) {
this.customAttributes_ = this.customAttributes_.mutableCopy();
}
return this.customAttributes_;
}
public final Map getMutableCustomAttributesMap() {
return internalGetMutableCustomAttributes();
}
public static Builder newBuilder() {
return (Builder) DEFAULT_INSTANCE.createBuilder();
}
public static final class Builder extends GeneratedMessageLite.Builder implements MessageLiteOrBuilder {
public /* synthetic */ Builder(AnonymousClass1 anonymousClass1) {
this();
}
public Builder() {
super(ApplicationInfo.DEFAULT_INSTANCE);
}
public Builder setGoogleAppId(String str) {
copyOnWrite();
((ApplicationInfo) this.instance).setGoogleAppId(str);
return this;
}
public boolean hasAppInstanceId() {
return ((ApplicationInfo) this.instance).hasAppInstanceId();
}
public Builder setAppInstanceId(String str) {
copyOnWrite();
((ApplicationInfo) this.instance).setAppInstanceId(str);
return this;
}
public Builder setAndroidAppInfo(AndroidApplicationInfo.Builder builder) {
copyOnWrite();
((ApplicationInfo) this.instance).setAndroidAppInfo((AndroidApplicationInfo) builder.build());
return this;
}
public Builder setApplicationProcessState(ApplicationProcessState applicationProcessState) {
copyOnWrite();
((ApplicationInfo) this.instance).setApplicationProcessState(applicationProcessState);
return this;
}
public Builder putAllCustomAttributes(Map map) {
copyOnWrite();
((ApplicationInfo) this.instance).getMutableCustomAttributesMap().putAll(map);
return this;
}
}
/* renamed from: com.google.firebase.perf.v1.ApplicationInfo$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke;
static {
int[] iArr = new int[GeneratedMessageLite.MethodToInvoke.values().length];
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke = iArr;
try {
iArr[GeneratedMessageLite.MethodToInvoke.NEW_MUTABLE_INSTANCE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.NEW_BUILDER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.BUILD_MESSAGE_INFO.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_DEFAULT_INSTANCE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_PARSER.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.GET_MEMOIZED_IS_INITIALIZED.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[GeneratedMessageLite.MethodToInvoke.SET_MEMOIZED_IS_INITIALIZED.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
}
}
@Override // com.google.protobuf.GeneratedMessageLite
public final Object dynamicMethod(GeneratedMessageLite.MethodToInvoke methodToInvoke, Object obj, Object obj2) {
AnonymousClass1 anonymousClass1 = null;
switch (AnonymousClass1.$SwitchMap$com$google$protobuf$GeneratedMessageLite$MethodToInvoke[methodToInvoke.ordinal()]) {
case 1:
return new ApplicationInfo();
case 2:
return new Builder(anonymousClass1);
case 3:
return GeneratedMessageLite.newMessageInfo(DEFAULT_INSTANCE, "\u0001\u0005\u0000\u0001\u0001\u0006\u0005\u0001\u0000\u0000\u0001ဈ\u0000\u0002ဈ\u0001\u0003ဉ\u0002\u0005ဌ\u0003\u00062", new Object[]{"bitField0_", "googleAppId_", "appInstanceId_", "androidAppInfo_", "applicationProcessState_", ApplicationProcessState.internalGetVerifier(), "customAttributes_", CustomAttributesDefaultEntryHolder.defaultEntry});
case 4:
return DEFAULT_INSTANCE;
case 5:
Parser<ApplicationInfo> parser = PARSER;
if (parser == null) {
synchronized (ApplicationInfo.class) {
try {
parser = PARSER;
if (parser == null) {
parser = new GeneratedMessageLite.DefaultInstanceBasedParser<>(DEFAULT_INSTANCE);
PARSER = parser;
}
} finally {
}
}
}
return parser;
case 6:
return (byte) 1;
case 7:
return null;
default:
throw new UnsupportedOperationException();
}
}
static {
ApplicationInfo applicationInfo = new ApplicationInfo();
DEFAULT_INSTANCE = applicationInfo;
GeneratedMessageLite.registerDefaultInstance(ApplicationInfo.class, applicationInfo);
}
}

View File

@@ -0,0 +1,70 @@
package com.google.firebase.perf.v1;
import com.google.protobuf.Internal;
/* loaded from: classes3.dex */
public enum ApplicationProcessState implements Internal.EnumLite {
APPLICATION_PROCESS_STATE_UNKNOWN(0),
FOREGROUND(1),
BACKGROUND(2),
FOREGROUND_BACKGROUND(3);
public static final int APPLICATION_PROCESS_STATE_UNKNOWN_VALUE = 0;
public static final int BACKGROUND_VALUE = 2;
public static final int FOREGROUND_BACKGROUND_VALUE = 3;
public static final int FOREGROUND_VALUE = 1;
private static final Internal.EnumLiteMap<ApplicationProcessState> internalValueMap = new Internal.EnumLiteMap() { // from class: com.google.firebase.perf.v1.ApplicationProcessState.1
@Override // com.google.protobuf.Internal.EnumLiteMap
public ApplicationProcessState findValueByNumber(int i) {
return ApplicationProcessState.forNumber(i);
}
};
private final int value;
public static ApplicationProcessState forNumber(int i) {
if (i == 0) {
return APPLICATION_PROCESS_STATE_UNKNOWN;
}
if (i == 1) {
return FOREGROUND;
}
if (i == 2) {
return BACKGROUND;
}
if (i != 3) {
return null;
}
return FOREGROUND_BACKGROUND;
}
public static Internal.EnumLiteMap<ApplicationProcessState> internalGetValueMap() {
return internalValueMap;
}
@Override // com.google.protobuf.Internal.EnumLite
public final int getNumber() {
return this.value;
}
@Deprecated
public static ApplicationProcessState valueOf(int i) {
return forNumber(i);
}
public static Internal.EnumVerifier internalGetVerifier() {
return ApplicationProcessStateVerifier.INSTANCE;
}
public static final class ApplicationProcessStateVerifier implements Internal.EnumVerifier {
public static final Internal.EnumVerifier INSTANCE = new ApplicationProcessStateVerifier();
@Override // com.google.protobuf.Internal.EnumVerifier
public boolean isInRange(int i) {
return ApplicationProcessState.forNumber(i) != null;
}
}
ApplicationProcessState(int i) {
this.value = i;
}
}

Some files were not shown because too many files have changed in this diff Show More