Merge "Do not send lifecycle metrics if timestamp is 0" into rvc-dev
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index d7de501..41fc8b3 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -1345,8 +1345,10 @@
handleNotifyAppUserLifecycleListeners(event);
});
- // Finally, update metrics.
- mUserMetrics.onEvent(eventType, timestampMs, fromUserId, toUserId);
+ if (timestampMs != 0) {
+ // Finally, update metrics.
+ mUserMetrics.onEvent(eventType, timestampMs, fromUserId, toUserId);
+ }
}
/**
diff --git a/tests/carservice_unit_test/src/com/android/car/user/CarUserServiceTest.java b/tests/carservice_unit_test/src/com/android/car/user/CarUserServiceTest.java
index 4dc2923..431b5cb 100644
--- a/tests/carservice_unit_test/src/com/android/car/user/CarUserServiceTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/user/CarUserServiceTest.java
@@ -136,6 +136,8 @@
private static final int NON_EXISTING_USER = 55; // must not be on mExistingUsers
+ private static final long DEFAULT_LIFECYCLE_TIMESTAMP = 1;
+
@Mock private Context mMockContext;
@Mock private Context mApplicationContext;
@Mock private LocationManager mLocationManager;
@@ -1341,7 +1343,7 @@
sendUserSwitchingEvent(mAdminUser.id, mRegularUser.id);
verify(mUserMetrics).onEvent(CarUserManager.USER_LIFECYCLE_EVENT_TYPE_SWITCHING,
- 0, mAdminUser.id, mRegularUser.id);
+ DEFAULT_LIFECYCLE_TIMESTAMP, mAdminUser.id, mRegularUser.id);
}
@Test
@@ -1740,7 +1742,8 @@
private void sendUserLifecycleEvent(@UserIdInt int fromUserId, @UserIdInt int toUserId,
@UserLifecycleEventType int eventType) {
- mCarUserService.onUserLifecycleEvent(eventType, /* timestampMs= */ 0, fromUserId, toUserId);
+ mCarUserService.onUserLifecycleEvent(eventType, DEFAULT_LIFECYCLE_TIMESTAMP, fromUserId,
+ toUserId);
}
private void sendUserUnlockedEvent(@UserIdInt int userId) {