File tree 5 files changed +21
-3
lines changed
java/com/google/firebase/perf/transport
test/java/com/google/firebase/perf/transport
firebase-sessions/src/main/kotlin/com/google/firebase/sessions
5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 14
14
15
15
package com .google .firebase .perf .transport ;
16
16
17
+ import static com .google .firebase .sessions .ProcessDetailsProvider .getProcessDetailsProvider ;
17
18
import static java .util .concurrent .TimeUnit .MILLISECONDS ;
18
19
import static java .util .concurrent .TimeUnit .MINUTES ;
19
20
@@ -230,6 +231,8 @@ private void finishInitialization() {
230
231
applicationInfoBuilder = ApplicationInfo .newBuilder ();
231
232
applicationInfoBuilder
232
233
.setGoogleAppId (firebaseApp .getOptions ().getApplicationId ())
234
+ .setProcessName (
235
+ getProcessDetailsProvider ().getCurrentProcessDetails (appContext ).getProcessName ())
233
236
.setAndroidAppInfo (
234
237
AndroidApplicationInfo .newBuilder ()
235
238
.setPackageName (packageName )
Original file line number Diff line number Diff line change @@ -292,7 +292,7 @@ message GaugeMetadata {
292
292
// Additional metadata about an application and its state (including state of
293
293
// the device at runtime) that is not provided by firebase data transport.
294
294
//
295
- // Next tag: 8
295
+ // Next tag: 9
296
296
message ApplicationInfo {
297
297
// Identifier for the application that has been registered with firebase.
298
298
// Contains pantheon project number, platform and the hash of the (package
@@ -316,6 +316,9 @@ message ApplicationInfo {
316
316
317
317
// A map of global-level custom attribute names to values.
318
318
map <string , string > custom_attributes = 6 ;
319
+
320
+ // The name of process that initiate the event. Currently only populated for Android apps.
321
+ optional string process_name = 8 ;
319
322
}
320
323
321
324
// Additional metadata about an android application that is not provided by
Original file line number Diff line number Diff line change 28
28
import static org .mockito .MockitoAnnotations .initMocks ;
29
29
import static org .robolectric .Shadows .shadowOf ;
30
30
31
+ import android .app .ActivityManager ;
31
32
import android .content .Context ;
32
33
import android .content .pm .PackageInfo ;
33
34
import androidx .test .core .app .ApplicationProvider ;
@@ -1399,6 +1400,11 @@ private void initializeTransport(boolean shouldInitialize) {
1399
1400
if (shouldInitialize ) {
1400
1401
// Set the version name since Firebase sessions needs it.
1401
1402
Context context = ApplicationProvider .getApplicationContext ();
1403
+
1404
+ ActivityManager activityManager =
1405
+ (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
1406
+ context .getApplicationInfo ().uid = activityManager .getRunningAppProcesses ().get (0 ).uid ;
1407
+
1402
1408
ShadowPackageManager shadowPackageManager = shadowOf (context .getPackageManager ());
1403
1409
1404
1410
PackageInfo packageInfo =
@@ -1468,6 +1474,8 @@ private static void validateApplicationInfo(
1468
1474
.isEqualTo (FAKE_FIREBASE_APPLICATION_ID );
1469
1475
assertThat (loggedPerfMetric .getApplicationInfo ().getApplicationProcessState ())
1470
1476
.isEqualTo (applicationProcessState );
1477
+ assertThat (loggedPerfMetric .getApplicationInfo ().getProcessName ())
1478
+ .isEqualTo ("com.google.firebase.perf.test" );
1471
1479
assertThat (loggedPerfMetric .getApplicationInfo ().hasAndroidAppInfo ()).isTrue ();
1472
1480
}
1473
1481
Original file line number Diff line number Diff line change @@ -28,7 +28,11 @@ import com.google.android.gms.common.util.ProcessUtils
28
28
*
29
29
* @hide
30
30
*/
31
- internal object ProcessDetailsProvider {
31
+ object ProcessDetailsProvider {
32
+ @JvmStatic
33
+ fun getProcessDetailsProvider (): ProcessDetailsProvider {
34
+ return this
35
+ }
32
36
/* * Gets the details for all of this app's running processes. */
33
37
fun getAppProcessDetails (context : Context ): List <ProcessDetails > {
34
38
val appUid = context.applicationInfo.uid
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ internal data class DataCollectionStatus(
81
81
)
82
82
83
83
/* * Container for information about the process */
84
- internal data class ProcessDetails (
84
+ data class ProcessDetails (
85
85
val processName : String ,
86
86
val pid : Int ,
87
87
val importance : Int ,
You can’t perform that action at this time.
0 commit comments