Skip to content

Commit 17ab9ec

Browse files
Merging from Master
2 parents 0438346 + 39ce055 commit 17ab9ec

File tree

65 files changed

+1979
-1719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1979
-1719
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/FirebasePerfRegistrar.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ public List<Component<?>> getComponents() {
5151
.add(Dependency.required(FirebaseInstallationsApi.class))
5252
.add(Dependency.requiredProvider(TransportFactory.class))
5353
.factory(FirebasePerfRegistrar::providesFirebasePerformance)
54-
// Since the SDK is eager(auto starts at app start), we use "lazy" dependency for some
55-
// components that are not required during initialization so as not to force initialize
56-
// them at app startup (refer
57-
// https://github.com/google/guice/wiki/InjectingProviders#providers-for-lazy-loading).
58-
.eagerInDefaultApp()
5954
.build(),
55+
/**
56+
* Fireperf SDK is lazily by {@link FirebasePerformanceInitializer} during {@link
57+
* com.google.firebase.perf.application.AppStateMonitor#onActivityResumed(Activity)}. we use
58+
* "lazy" dependency for some components that are not required during initialization so as
59+
* not to force initialize them at app startup (refer
60+
* https://github.com/google/guice/wiki/InjectingProviders#providers-for-lazy-loading)*
61+
*/
6062
LibraryVersionComponent.create("fire-perf", BuildConfig.VERSION_NAME));
6163
}
6264

firebase-perf/src/main/java/com/google/firebase/perf/FirebasePerformance.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ public static FirebasePerformance getInstance() {
180180
TransportManager.getInstance()
181181
.initialize(firebaseApp, firebaseInstallationsApi, transportFactoryProvider);
182182

183-
Context context = firebaseApp.getApplicationContext();
183+
Context appContext = firebaseApp.getApplicationContext();
184184
// TODO(b/110178816): Explore moving off of main thread.
185-
mMetadataBundle = extractMetadata(context);
185+
mMetadataBundle = extractMetadata(appContext);
186186

187187
remoteConfigManager.setFirebaseRemoteConfigProvider(firebaseRemoteConfigProvider);
188188
this.configResolver = configResolver;
189189
this.configResolver.setMetadataBundle(mMetadataBundle);
190-
this.configResolver.setApplicationContext(context);
191-
gaugeManager.setApplicationContext(context);
190+
this.configResolver.setApplicationContext(appContext);
191+
gaugeManager.setApplicationContext(appContext);
192192

193193
mPerformanceCollectionForceEnabledState = configResolver.getIsPerformanceCollectionEnabled();
194194
}
@@ -439,16 +439,16 @@ public HttpMetric newHttpMetric(@NonNull URL url, @NonNull @HttpMethod String ht
439439
/**
440440
* Extracts the metadata bundle from the ApplicationContext.
441441
*
442-
* @param context The ApplicationContext.
442+
* @param appContext The ApplicationContext.
443443
* @return A shallow copy of the bundle containing the metadata extracted from the context.
444444
*/
445-
private static ImmutableBundle extractMetadata(Context context) {
445+
private static ImmutableBundle extractMetadata(Context appContext) {
446446
Bundle bundle = null;
447447
try {
448448
ApplicationInfo ai =
449-
context
449+
appContext
450450
.getPackageManager()
451-
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
451+
.getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA);
452452

453453
bundle = ai.metaData;
454454
} catch (NameNotFoundException | NullPointerException e) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.perf;
16+
17+
import com.google.firebase.perf.application.AppStateMonitor;
18+
19+
/**
20+
* FirebasePerformanceInitializer to initialize FirebasePerformance during app cold start
21+
*
22+
* @hide
23+
*/
24+
public final class FirebasePerformanceInitializer implements AppStateMonitor.AppColdStartCallback {
25+
26+
@Override
27+
public void onAppColdStart() {
28+
// Initialize FirebasePerformance when app cold starts.
29+
FirebasePerformance.getInstance();
30+
}
31+
}

0 commit comments

Comments
 (0)