File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1414
1515package  com .google .firebase .perf .transport ;
1616
17+ import  static  com .google .firebase .sessions .ProcessDetailsProvider .getProcessDetailsProvider ;
1718import  static  java .util .concurrent .TimeUnit .MILLISECONDS ;
1819import  static  java .util .concurrent .TimeUnit .MINUTES ;
1920
@@ -230,6 +231,8 @@ private void finishInitialization() {
230231    applicationInfoBuilder  = ApplicationInfo .newBuilder ();
231232    applicationInfoBuilder 
232233        .setGoogleAppId (firebaseApp .getOptions ().getApplicationId ())
234+         .setProcessName (
235+             getProcessDetailsProvider ().getCurrentProcessDetails (appContext ).getProcessName ())
233236        .setAndroidAppInfo (
234237            AndroidApplicationInfo .newBuilder ()
235238                .setPackageName (packageName )
Original file line number Diff line number Diff line change @@ -292,7 +292,7 @@ message GaugeMetadata {
292292// Additional metadata about an application and its state (including state of 
293293// the device at runtime) that is not provided by firebase data transport. 
294294// 
295- // Next tag: 8  
295+ // Next tag: 9  
296296message  ApplicationInfo  {
297297  // Identifier for the application that has been registered with firebase. 
298298  // Contains pantheon project number, platform and the hash of the (package 
@@ -316,6 +316,9 @@ message ApplicationInfo {
316316
317317  // A map of global-level custom attribute names to values. 
318318  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 ;
319322}
320323
321324// Additional metadata about an android application that is not provided by 
Original file line number Diff line number Diff line change 3030
3131import  android .content .Context ;
3232import  android .content .pm .PackageInfo ;
33+ import  android .os .Process ;
3334import  androidx .test .core .app .ApplicationProvider ;
3435import  com .google .android .datatransport .TransportFactory ;
3536import  com .google .android .gms .tasks .Tasks ;
@@ -1399,6 +1400,11 @@ private void initializeTransport(boolean shouldInitialize) {
13991400    if  (shouldInitialize ) {
14001401      // Set the version name since Firebase sessions needs it. 
14011402      Context  context  = ApplicationProvider .getApplicationContext ();
1403+ 
1404+       // For unit test, app context does not application info related to uid, so we have to force 
1405+       // set it through process info. 
1406+       context .getApplicationInfo ().uid  = Process .myUid ();
1407+ 
14021408      ShadowPackageManager  shadowPackageManager  = shadowOf (context .getPackageManager ());
14031409
14041410      PackageInfo  packageInfo  =
@@ -1468,6 +1474,8 @@ private static void validateApplicationInfo(
14681474        .isEqualTo (FAKE_FIREBASE_APPLICATION_ID );
14691475    assertThat (loggedPerfMetric .getApplicationInfo ().getApplicationProcessState ())
14701476        .isEqualTo (applicationProcessState );
1477+     assertThat (loggedPerfMetric .getApplicationInfo ().getProcessName ())
1478+         .isEqualTo ("com.google.firebase.perf.test" );
14711479    assertThat (loggedPerfMetric .getApplicationInfo ().hasAndroidAppInfo ()).isTrue ();
14721480  }
14731481
Original file line number Diff line number Diff line change @@ -28,7 +28,11 @@ import com.google.android.gms.common.util.ProcessUtils
2828 * 
2929 * @hide 
3030 */  
31- internal  object  ProcessDetailsProvider {
31+ object  ProcessDetailsProvider {
32+   @JvmStatic
33+   fun  getProcessDetailsProvider (): ProcessDetailsProvider  {
34+     return  this 
35+   }
3236  /* * Gets the details for all of this app's running processes. */ 
3337  fun  getAppProcessDetails (context :  Context ): List <ProcessDetails > {
3438    val  appUid =  context.applicationInfo.uid
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ internal data class DataCollectionStatus(
8181)
8282
8383/* * Container for information about the process */ 
84- internal   data class  ProcessDetails (
84+ data class  ProcessDetails (
8585  val  processName :  String ,
8686  val  pid :  Int ,
8787  val  importance :  Int ,
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments