Remember userId to restart the previous Intent when the display is back.

Bug: 200040668
Test: check the logcat if Maps doesn't start with user 0.
Change-Id: I1aa9fc8ccd5df296e8a2e6744cfeffd3df3a1fe8
Merged-In: I1aa9fc8ccd5df296e8a2e6744cfeffd3df3a1fe8
diff --git a/service/src/com/android/car/cluster/ClusterHomeService.java b/service/src/com/android/car/cluster/ClusterHomeService.java
index b032d93..3af771a 100644
--- a/service/src/com/android/car/cluster/ClusterHomeService.java
+++ b/service/src/com/android/car/cluster/ClusterHomeService.java
@@ -84,6 +84,7 @@
     private Insets mInsets = Insets.NONE;
     private int mUiType = ClusterHomeManager.UI_TYPE_CLUSTER_HOME;
     private Intent mLastIntent;
+    private int mLastIntentUserId = UserHandle.USER_SYSTEM;
 
     private final RemoteCallbackList<IClusterHomeCallback> mClientCallbacks =
             new RemoteCallbackList<>();
@@ -126,6 +127,7 @@
     private void initClusterDisplay() {
         int clusterDisplayId = mOccupantZoneService.getDisplayIdForDriver(
                 CarOccupantZoneManager.DISPLAY_TYPE_INSTRUMENT_CLUSTER);
+        Slogf.d(TAG, "initClusterDisplay: displayId=%d", clusterDisplayId);
         if (clusterDisplayId == Display.INVALID_DISPLAY) {
             Slogf.i(TAG, "No cluster display is defined");
         }
@@ -152,7 +154,7 @@
         ActivityOptions activityOptions = ActivityOptions.makeBasic()
                 .setLaunchDisplayId(clusterDisplayId);
         mFixedActivityService.startFixedActivityModeForDisplayAndUser(
-                mLastIntent, activityOptions, clusterDisplayId, UserHandle.USER_SYSTEM);
+                mLastIntent, activityOptions, clusterDisplayId, mLastIntentUserId);
     }
 
     private final ICarOccupantZoneCallback mOccupantZoneCallback =
@@ -292,6 +294,7 @@
     @Override
     public boolean startFixedActivityModeAsUser(Intent intent,
             Bundle activityOptionsBundle, int userId) {
+        Slogf.d(TAG, "startFixedActivityModeAsUser: intent=%s, userId=%d", intent, userId);
         enforcePermission(Car.PERMISSION_CAR_INSTRUMENT_CLUSTER_CONTROL);
         if (!mServiceEnabled) throw new IllegalStateException("Service is not enabled");
         if (mClusterDisplayId == Display.INVALID_DISPLAY) {
@@ -302,6 +305,7 @@
         ActivityOptions activityOptions = ActivityOptions.fromBundle(activityOptionsBundle);
         activityOptions.setLaunchDisplayId(mClusterDisplayId);
         mLastIntent = intent;
+        mLastIntentUserId = userId;
         return mFixedActivityService.startFixedActivityModeForDisplayAndUser(
                 intent, activityOptions, mClusterDisplayId, userId);
     }