Initial EventLogTags for CarService.

This CL defines a new project (car-internal-lib) that will contain
internal libraries (such as utilities used by CarService and
CarServiceHelperService).

It also creates a class (com.android.internal.car.EventLogTags)
for car-related event logs, and add the initial logs (for
CarService / ICarImpl and user-related components).

Bug: 149797595
Bug: 153900032

Test: adb logcat -b events -v color | egrep 'car_'

Change-Id: I987ebafdadc39de768d0f053d4c6ea18fd95b169
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index 7b96af7..b38343c 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -56,6 +56,7 @@
 import android.os.UserManager;
 import android.provider.Settings;
 import android.sysprop.CarProperties;
+import android.util.EventLog;
 import android.util.Log;
 import android.util.SparseArray;
 import android.util.TimingsTraceLog;
@@ -65,6 +66,7 @@
 import com.android.car.hal.UserHalService;
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.car.EventLogTags;
 import com.android.internal.os.IResultReceiver;
 import com.android.internal.util.FunctionalUtils;
 import com.android.internal.util.Preconditions;
@@ -537,6 +539,7 @@
     @Override
     public void setLifecycleListenerForUid(IResultReceiver listener) {
         int uid = Binder.getCallingUid();
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_SET_LIFECYCLE_LISTENER, uid);
         checkInteractAcrossUsersPermission("setLifecycleListenerForUid" + uid);
 
         try {
@@ -555,6 +558,7 @@
     @Override
     public void resetLifecycleListenerForUid() {
         int uid = Binder.getCallingUid();
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_RESET_LIFECYCLE_LISTENER, uid);
         checkInteractAcrossUsersPermission("resetLifecycleListenerForUid-" + uid);
         mHandler.post(() -> mAppLifecycleListeners.remove(uid));
     }
@@ -562,12 +566,17 @@
     @Override
     public void getInitialUserInfo(int requestType, int timeoutMs,
             @NonNull IResultReceiver receiver) {
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_INITIAL_USER_INFO_REQ, requestType,
+                timeoutMs);
         Objects.requireNonNull(receiver, "receiver cannot be null");
         checkManageUsersPermission("getInitialInfo");
         UsersInfo usersInfo = getUsersInfo();
         mHal.getInitialUserInfo(requestType, timeoutMs, usersInfo, (status, resp) -> {
             Bundle resultData = null;
             if (resp != null) {
+                EventLog.writeEvent(EventLogTags.CAR_USER_SVC_INITIAL_USER_INFO_RESP,
+                        status, resp.action, resp.userToSwitchOrCreate.userId,
+                        resp.userToSwitchOrCreate.flags, resp.userNameToCreate);
                 switch (resp.action) {
                     case InitialUserInfoResponseAction.SWITCH:
                         resultData = new Bundle();
@@ -588,6 +597,8 @@
                         // That's ok, it will be the same as DEFAULT...
                         Log.w(TAG_USER, "invalid response action on " + resp);
                 }
+            } else {
+                EventLog.writeEvent(EventLogTags.CAR_USER_SVC_INITIAL_USER_INFO_RESP, status);
             }
             sendResult(receiver, status, resultData);
         });
@@ -632,7 +643,8 @@
      * Sets the initial foreground user after the device boots or resumes from suspension.
      */
     public void setInitialUser(@Nullable UserInfo user) {
-        Log.i(TAG_USER, "setInitialUser: " + user);
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_SET_INITIAL_USER,
+                user == null ? UserHandle.USER_NULL : user.id);
         synchronized (mLockUser) {
             mInitialUser = user;
         }
@@ -652,6 +664,8 @@
      */
     public void getInitialUserInfo(int requestType,
             HalCallback<InitialUserInfoResponse> callback) {
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_INITIAL_USER_INFO_REQ, requestType,
+                mHalTimeoutMs);
         Objects.requireNonNull(callback, "callback cannot be null");
         checkManageUsersPermission("getInitialUserInfo");
         UsersInfo usersInfo = getUsersInfo();
@@ -668,6 +682,8 @@
     @Override
     public void switchUser(@UserIdInt int targetUserId, int timeoutMs,
             @NonNull IResultReceiver receiver) {
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_SWITCH_USER_REQ, targetUserId,
+                timeoutMs);
         checkManageUsersPermission("switchUser");
         Objects.requireNonNull(receiver);
         UserInfo targetUser = mUserManager.getUserInfo(targetUserId);
@@ -705,6 +721,8 @@
             resultData = new Bundle();
             int resultStatus = CarUserManager.USER_SWITCH_STATUS_HAL_INTERNAL_FAILURE;
             if (resp != null) {
+                EventLog.writeEvent(EventLogTags.CAR_USER_SVC_SWITCH_USER_REQ, status,
+                        resp.status, resp.messageType);
                 resultData.putInt(CarUserManager.BUNDLE_USER_SWITCH_STATUS, resp.status);
                 resultData.putInt(CarUserManager.BUNDLE_USER_SWITCH_MSG_TYPE, resp.messageType);
                 if (resp.errorMessage != null) {
@@ -734,6 +752,8 @@
                         resultStatus = CarUserManager.USER_SWITCH_STATUS_HAL_FAILURE;
                         break;
                 }
+            } else {
+                EventLog.writeEvent(EventLogTags.CAR_USER_SVC_SWITCH_USER_REQ, status);
             }
             sendResult(receiver, resultStatus, resultData);
         });
@@ -773,6 +793,8 @@
                 new android.hardware.automotive.vehicle.V2_0.UserInfo();
         halTargetUser.userId = targetUser.id;
         halTargetUser.flags = UserHalHelper.convertFlags(targetUser);
+        EventLog.writeEvent(EventLogTags.CAR_USER_SVC_POST_SWITCH_USER_REQ, requestId,
+                targetUserId, usersInfo.currentUser.userId);
         mHal.postSwitchResponse(requestId, halTargetUser, usersInfo);
     }