From e25914594e372bb4ee6a12d67d7d6d1e355b8db2 Mon Sep 17 00:00:00 2001 From: Mayank Garg Date: Tue, 9 Jun 2020 12:47:25 -0700 Subject: [PATCH] Added an event before clearning user journey Bug: 141388849 Bug: 146505521 Bug: 150788910 Test: statsd_testdrive 264 265 Change-Id: I5fd44b22ea94aacc7060e7afcfce6cd2824b97da --- .../com/android/server/am/UserController.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index ea7059894f381..f2c4e4428af26 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -2515,7 +2515,7 @@ class UserController implements Handler.Callback { showUserSwitchDialog(fromToUserPair); break; case CLEAR_USER_JOURNEY_SESSION_MSG: - clearSessionId(msg.arg1); + logAndClearSessionId(msg.arg1); break; } return false; @@ -2629,6 +2629,21 @@ class UserController implements Handler.Callback { } } + /** + * Log a final event of the {@link UserJourneySession} and clear it. + */ + private void logAndClearSessionId(@UserIdInt int userId) { + synchronized (mUserIdToUserJourneyMap) { + final UserJourneySession userJourneySession = mUserIdToUserJourneyMap.get(userId); + if (userJourneySession != null) { + FrameworkStatsLog.write(FrameworkStatsLog.USER_LIFECYCLE_EVENT_OCCURRED, + userJourneySession.mSessionId, userId, USER_LIFECYCLE_EVENT_UNKNOWN, + USER_LIFECYCLE_EVENT_STATE_NONE); + } + clearSessionId(userId); + } + } + /** * Helper class to store user journey and session id. *