Merge 07262f3fbb04aaea5f6238c19038cbb48e099c53 on remote branch

Change-Id: Ib17a601b7e9878e3a68d021785cb19becb10e6b4
diff --git a/builtInServices/Android.bp b/builtInServices/Android.bp
index eeda2da..a50f652 100644
--- a/builtInServices/Android.bp
+++ b/builtInServices/Android.bp
@@ -15,7 +15,7 @@
     ],
     static_libs: [
         "android.car.watchdoglib",
-        "android.automotive.watchdog.internal-V1-java",
+        "android.automotive.watchdog.internal-V2-java",
     ],
     api_lint: {
         enabled: true,
diff --git a/builtInServices/src/com/android/annotation/AddedIn.java b/builtInServices/src/com/android/annotation/AddedIn.java
new file mode 100644
index 0000000..6cfceb4
--- /dev/null
+++ b/builtInServices/src/com/android/annotation/AddedIn.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.annotation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import android.car.builtin.annotation.PlatformVersion;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Defines in which version of platform this method / type / field was added.
+ *
+ * <p>Annotation should be used for APIs exposed to CarService module by {@code android.car.builtin}
+ *
+ * @hide
+ */
+@Retention(RUNTIME)
+@Target({ANNOTATION_TYPE, FIELD, TYPE, METHOD})
+public @interface AddedIn {
+    PlatformVersion value();
+}
diff --git a/builtInServices/src/com/android/internal/car/CarServiceHelperInterface.java b/builtInServices/src/com/android/internal/car/CarServiceHelperInterface.java
index 362fd07..e9a58a9 100644
--- a/builtInServices/src/com/android/internal/car/CarServiceHelperInterface.java
+++ b/builtInServices/src/com/android/internal/car/CarServiceHelperInterface.java
@@ -18,8 +18,11 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.os.UserHandle;
 
+import com.android.annotation.AddedIn;
+
 import java.io.File;
 
 /**
@@ -32,12 +35,14 @@
     /**
      * Sets safety mode
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void setSafetyMode(boolean safe);
 
     /**
      * Creates user even when disallowed
      */
     @Nullable
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     UserHandle createUserEvenWhenDisallowed(@Nullable String name, @NonNull String userType,
             int flags);
 
@@ -45,5 +50,6 @@
      * Dumps service stacks
      */
     @Nullable
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     File dumpServiceStacks();
 }
diff --git a/builtInServices/src/com/android/internal/car/CarServiceHelperService.java b/builtInServices/src/com/android/internal/car/CarServiceHelperService.java
index 4e2333c..3d9301b 100644
--- a/builtInServices/src/com/android/internal/car/CarServiceHelperService.java
+++ b/builtInServices/src/com/android/internal/car/CarServiceHelperService.java
@@ -15,6 +15,7 @@
  */
 package com.android.internal.car;
 
+import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_CREATED;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_POST_UNLOCKED;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_STARTING;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_STOPPED;
@@ -205,7 +206,11 @@
                 @Override
                 public void onUserCreated(UserInfo user, Object token) {
                     if (DBG) Slogf.d(TAG, "onUserCreated(): %s", user.toFullString());
+                    mCarServiceHelperServiceUpdatable.sendUserLifecycleEvent(
+                            USER_LIFECYCLE_EVENT_TYPE_CREATED, /* userFrom= */ null,
+                            user.getUserHandle());
                 }
+
                 @Override
                 public void onUserRemoved(UserInfo user) {
                     if (DBG) Slogf.d(TAG, "onUserRemoved(): $s", user.toFullString());
@@ -496,7 +501,9 @@
         pids.add(Process.myPid());
 
         return ActivityManagerService.dumpStackTraces(
-                pids, null, null, getInterestingNativePids(), null);
+                pids, /* processCpuTracker= */ null, /* lastPids= */ null,
+                getInterestingNativePids(), /* logExceptionCreatingFile= */ null,
+                /* subject= */ null, /* criticalEventSection= */ null);
     }
 
     private void handleClientsNotResponding(@NonNull List<ProcessIdentifier> processIdentifiers) {
diff --git a/builtInServices/src/com/android/internal/car/CarServiceHelperServiceUpdatable.java b/builtInServices/src/com/android/internal/car/CarServiceHelperServiceUpdatable.java
index 175da48..3409c15 100644
--- a/builtInServices/src/com/android/internal/car/CarServiceHelperServiceUpdatable.java
+++ b/builtInServices/src/com/android/internal/car/CarServiceHelperServiceUpdatable.java
@@ -18,9 +18,11 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.os.Bundle;
 import android.os.UserHandle;
 
+import com.android.annotation.AddedIn;
 import com.android.server.wm.CarLaunchParamsModifierUpdatable;
 
 import java.io.PrintWriter;
@@ -35,18 +37,25 @@
 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
 public interface CarServiceHelperServiceUpdatable {
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void onUserRemoved(@NonNull UserHandle userHandle);
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void onStart();
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void dump(@NonNull PrintWriter pw, @Nullable String[] args);
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void sendUserLifecycleEvent(int eventType, @Nullable UserHandle userFrom,
             @NonNull UserHandle userTo);
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void onFactoryReset(@NonNull BiConsumer<Integer, Bundle> processFactoryReset);
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void initBootUser();
 
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     CarLaunchParamsModifierUpdatable getCarLaunchParamsModifierUpdatable();
 }
diff --git a/builtInServices/src/com/android/server/wm/ActivityOptionsWrapper.java b/builtInServices/src/com/android/server/wm/ActivityOptionsWrapper.java
index f9dc751..b67e190 100644
--- a/builtInServices/src/com/android/server/wm/ActivityOptionsWrapper.java
+++ b/builtInServices/src/com/android/server/wm/ActivityOptionsWrapper.java
@@ -18,8 +18,11 @@
 
 import android.annotation.SystemApi;
 import android.app.ActivityOptions;
+import android.car.builtin.annotation.PlatformVersion;
 import android.window.WindowContainerToken;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of {@link ActivityOptions}.
  * @hide
@@ -33,6 +36,7 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static ActivityOptionsWrapper create(ActivityOptions options) {
         if (options == null) return null;
         return new ActivityOptionsWrapper(options);
@@ -42,6 +46,7 @@
      * Gets the underlying {@link ActivityOptions} that is wrapped by this instance.
      */
     // Exposed the original object in order to allow to use the public accessors.
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityOptions getOptions() {
         return mOptions;
     }
@@ -49,6 +54,7 @@
     /**
      * Gets {@link TaskDisplayAreaWrapper} to launch the Activity into
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayAreaWrapper getLaunchTaskDisplayArea() {
         WindowContainerToken daToken = mOptions.getLaunchTaskDisplayArea();
         if (daToken == null) return null;
@@ -57,6 +63,7 @@
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mOptions.toString();
     }
diff --git a/builtInServices/src/com/android/server/wm/ActivityRecordWrapper.java b/builtInServices/src/com/android/server/wm/ActivityRecordWrapper.java
index bd15a54..210995f 100644
--- a/builtInServices/src/com/android/server/wm/ActivityRecordWrapper.java
+++ b/builtInServices/src/com/android/server/wm/ActivityRecordWrapper.java
@@ -18,9 +18,12 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.content.ComponentName;
 import android.content.pm.ActivityInfo;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of {@link ActivityRecord}.
  * @hide
@@ -34,12 +37,14 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static ActivityRecordWrapper create(@Nullable ActivityRecord activityRecord) {
         if (activityRecord == null) return null;
         return new ActivityRecordWrapper(activityRecord);
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityRecord getActivityRecord() {
         return mActivityRecord;
     }
@@ -47,6 +52,7 @@
     /**
      * Gets which user this Activity is running for.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public int getUserId() {
         return mActivityRecord.mUserId;
     }
@@ -54,6 +60,7 @@
     /**
      * Gets the actual {@link ComponentName} of this Activity.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ComponentName getComponentName() {
         if (mActivityRecord.info == null) return null;
         return mActivityRecord.info.getComponentName();
@@ -62,6 +69,7 @@
     /**
      * Gets the {@link TaskDisplayAreaWrapper} where this is located.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayAreaWrapper getDisplayArea() {
         return TaskDisplayAreaWrapper.create(mActivityRecord.getDisplayArea());
     }
@@ -69,6 +77,7 @@
     /**
      * Returns whether this Activity is not displayed.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public boolean isNoDisplay() {
         return mActivityRecord.noDisplay;
     }
@@ -76,6 +85,7 @@
     /**
      * Gets {@link TaskDisplayAreaWrapper} where the handover Activity is supposed to launch
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayAreaWrapper getHandoverTaskDisplayArea() {
         return TaskDisplayAreaWrapper.create(mActivityRecord.mHandoverTaskDisplayArea);
     }
@@ -83,6 +93,7 @@
     /**
      * Gets {@code displayId} where the handover Activity is supposed to launch
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public int getHandoverLaunchDisplayId() {
         return mActivityRecord.mHandoverLaunchDisplayId;
     }
@@ -90,6 +101,7 @@
     /**
      * Returns whether this Activity allows to be embedded in the other Activity.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public boolean allowingEmbedded() {
         if (mActivityRecord.info == null) return false;
         return (mActivityRecord.info.flags & ActivityInfo.FLAG_ALLOW_EMBEDDED) != 0;
@@ -98,11 +110,13 @@
     /**
      * Returns whether the display where this Activity is located is trusted.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public boolean isDisplayTrusted() {
         return mActivityRecord.getDisplayContent().isTrusted();
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mActivityRecord.toString();
     }
diff --git a/builtInServices/src/com/android/server/wm/CalculateParams.java b/builtInServices/src/com/android/server/wm/CalculateParams.java
index 8b4faff..0973882 100644
--- a/builtInServices/src/com/android/server/wm/CalculateParams.java
+++ b/builtInServices/src/com/android/server/wm/CalculateParams.java
@@ -18,9 +18,12 @@
 
 import android.annotation.SystemApi;
 import android.app.ActivityOptions;
+import android.car.builtin.annotation.PlatformVersion;
 import android.content.pm.ActivityInfo;
 import android.view.WindowLayout;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of the parameters of {@code LaunchParamsController.LaunchParamsModifier.onCalculate()}
  * @hide
@@ -41,6 +44,7 @@
     private CalculateParams() {}
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static CalculateParams create(Task task, ActivityInfo.WindowLayout layout,
             ActivityRecord actvity, ActivityRecord source,
             ActivityOptions options, ActivityStarter.Request request, int phase,
@@ -64,6 +68,7 @@
     /**
      * Gets the {@link TaskWrapper} currently being positioned.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskWrapper getTask() {
         return mTask;
     }
@@ -71,6 +76,7 @@
     /**
      * Gets the specified {@link WindowLayoutWrapper}.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public WindowLayoutWrapper getWindowLayout() {
         return mLayout;
     }
@@ -78,6 +84,7 @@
     /**
      * Gets the {@link ActivityRecordWrapper} currently being positioned.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityRecordWrapper getActivity() {
         return mActivity;
     }
@@ -85,6 +92,7 @@
     /**
      * Gets the {@link ActivityRecordWrapper} from which activity was started from.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityRecordWrapper getSource() {
         return mSource;
     }
@@ -92,6 +100,7 @@
     /**
      * Gets the {@link ActivityOptionsWrapper} specified for the activity.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityOptionsWrapper getOptions() {
         return mOptions;
     }
@@ -99,6 +108,7 @@
     /**
      * Gets the optional {@link RequestWrapper} from the activity starter.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public RequestWrapper getRequest() {
         return mRequest;
     }
@@ -107,6 +117,7 @@
      * Gets the {@link LaunchParamsController.LaunchParamsModifier.Phase} that the resolution should
      * finish.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public int getPhase() {
         return mPhase;
     }
@@ -114,6 +125,7 @@
     /**
      * Gets the current {@link LaunchParamsWrapper}.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public LaunchParamsWrapper getCurrentParams() {
         return mCurrentParams;
     }
@@ -121,6 +133,7 @@
     /**
      * Gets the resulting {@link LaunchParamsWrapper}.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public LaunchParamsWrapper getOutParams() {
         return mOutParams;
     }
@@ -128,6 +141,7 @@
     /**
      * Returns whether the current system supports the multiple display.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public boolean supportsMultiDisplay() {
         return mSupportsMultiDisplay;
     }
diff --git a/builtInServices/src/com/android/server/wm/CarDisplayAreaPolicyProvider.java b/builtInServices/src/com/android/server/wm/CarDisplayAreaPolicyProvider.java
index ea4a4bf..96a90bc 100644
--- a/builtInServices/src/com/android/server/wm/CarDisplayAreaPolicyProvider.java
+++ b/builtInServices/src/com/android/server/wm/CarDisplayAreaPolicyProvider.java
@@ -16,6 +16,7 @@
 
 package com.android.server.wm;
 
+import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
@@ -83,14 +84,17 @@
         TaskDisplayArea backgroundTaskDisplayArea = new TaskDisplayArea(content, wmService,
                 "BackgroundTaskDisplayArea", BACKGROUND_TASK_CONTAINER,
                 /* createdByOrganizer= */ false, /* canHostHomeTask= */ false);
+        backgroundTaskDisplayArea.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
 
         TaskDisplayArea controlBarDisplayArea = new TaskDisplayArea(content, wmService,
                 "ControlBarTaskDisplayArea", CONTROL_BAR_DISPLAY_AREA,
                 /* createdByOrganizer= */ false, /* canHostHomeTask= */ false);
+        controlBarDisplayArea.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
 
         TaskDisplayArea voicePlateTaskDisplayArea = new TaskDisplayArea(content, wmService,
                 "VoicePlateTaskDisplayArea", FEATURE_VOICE_PLATE,
                 /* createdByOrganizer= */ false, /* canHostHomeTask= */ false);
+        // voicePlatTaskDisplayArea needs to be in full screen windowing mode.
 
         List<TaskDisplayArea> backgroundTdaList = new ArrayList<>();
         backgroundTdaList.add(voicePlateTaskDisplayArea);
@@ -115,6 +119,8 @@
         // Default application launches here
         RootDisplayArea defaultAppsRoot = new DisplayAreaGroup(wmService,
                 "FeatureForegroundApplication", FOREGROUND_DISPLAY_AREA_ROOT);
+        defaultAppsRoot.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
+
         TaskDisplayArea defaultAppTaskDisplayArea = new TaskDisplayArea(content, wmService,
                 "DefaultApplicationTaskDisplayArea", DEFAULT_APP_TASK_CONTAINER);
         List<TaskDisplayArea> firstTdaList = new ArrayList<>();
diff --git a/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierInterface.java b/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierInterface.java
index 8550c55..2627c74 100644
--- a/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierInterface.java
+++ b/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierInterface.java
@@ -19,9 +19,12 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.graphics.Rect;
 import android.view.Display;
 
+import com.android.annotation.AddedIn;
+
 import java.util.List;
 
 /**
@@ -39,16 +42,19 @@
      * Returns {@link TaskDisplayAreaWrapper} of the given {@code featureId} in the given
      * {@code displayId}.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     @Nullable TaskDisplayAreaWrapper findTaskDisplayArea(int displayId, int featureId);
 
     /**
      * Returns the default {@link TaskDisplayAreaWrapper} of the given {@code displayId}.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     @Nullable TaskDisplayAreaWrapper getDefaultTaskDisplayAreaOnDisplay(int displayId);
 
     /**
      * Returns the list of fallback {@link TaskDisplayAreaWrapper} from the source of the request.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     @NonNull List<TaskDisplayAreaWrapper> getFallbackDisplayAreasForActivity(
             @NonNull ActivityRecordWrapper activityRecord, @Nullable RequestWrapper request);
 
diff --git a/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierUpdatable.java b/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierUpdatable.java
index 3abf54e..6ea45e2 100644
--- a/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierUpdatable.java
+++ b/builtInServices/src/com/android/server/wm/CarLaunchParamsModifierUpdatable.java
@@ -21,6 +21,7 @@
 import android.annotation.SystemApi;
 import android.annotation.UserIdInt;
 import android.car.app.CarActivityManager;
+import android.car.builtin.annotation.PlatformVersion;
 import android.content.ComponentName;
 import android.hardware.display.DisplayManager;
 import android.os.ServiceSpecificException;
@@ -31,6 +32,7 @@
 import android.view.Display;
 import android.window.DisplayAreaOrganizer;
 
+import com.android.annotation.AddedIn;
 import com.android.internal.annotations.GuardedBy;
 
 import java.util.ArrayList;
@@ -46,20 +48,25 @@
 public interface CarLaunchParamsModifierUpdatable {
 
     /** Returns {@link DisplayManager.DisplayListener} of CarLaunchParamsModifierUpdatable. */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     DisplayManager.DisplayListener getDisplayListener();
 
     /** Notifies user switching. */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void handleCurrentUserSwitching(@UserIdInt int newUserId);
 
     /** Notifies user starting. */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void handleUserStarting(@UserIdInt int startingUser);
 
     /** Notifies user stopped. */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     void handleUserStopped(@UserIdInt int stoppedUser);
 
     /**
      * Calculates {@code outParams} based on the given arguments.
      * See {@code LaunchParamsController.LaunchParamsModifier.onCalculate()} for the detail.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     int calculate(CalculateParams params);
 }
diff --git a/builtInServices/src/com/android/server/wm/LaunchParamsWrapper.java b/builtInServices/src/com/android/server/wm/LaunchParamsWrapper.java
index 344961f..8d36a5b 100644
--- a/builtInServices/src/com/android/server/wm/LaunchParamsWrapper.java
+++ b/builtInServices/src/com/android/server/wm/LaunchParamsWrapper.java
@@ -18,8 +18,11 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.graphics.Rect;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of {@link com.android.server.wm.LaunchParamsController.LaunchParams}.
  * @hide
@@ -27,16 +30,19 @@
 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
 public final class LaunchParamsWrapper {
     /** Returned when the modifier does not want to influence the bounds calculation */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static int RESULT_SKIP = LaunchParamsController.LaunchParamsModifier.RESULT_SKIP;
     /**
      * Returned when the modifier has changed the bounds and would like its results to be the
      * final bounds applied.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static int RESULT_DONE = LaunchParamsController.LaunchParamsModifier.RESULT_DONE;
     /**
      * Returned when the modifier has changed the bounds but is okay with other modifiers
      * influencing the bounds.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static int RESULT_CONTINUE = LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE;
 
     private final LaunchParamsController.LaunchParams mLaunchParams;
@@ -46,6 +52,7 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static LaunchParamsWrapper create(
             @Nullable LaunchParamsController.LaunchParams launchParams) {
         if (launchParams == null) return null;
@@ -55,6 +62,7 @@
     /**
      * Gets the {@link TaskDisplayAreaWrapper} the {@link Task} would prefer to be on.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayAreaWrapper getPreferredTaskDisplayArea() {
         return TaskDisplayAreaWrapper.create(mLaunchParams.mPreferredTaskDisplayArea);
     }
@@ -62,6 +70,7 @@
     /**
      * Sets the {@link TaskDisplayAreaWrapper} the {@link Task} would prefer to be on.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public void setPreferredTaskDisplayArea(TaskDisplayAreaWrapper tda) {
         mLaunchParams.mPreferredTaskDisplayArea = tda.getTaskDisplayArea();
     }
@@ -69,6 +78,7 @@
     /**
      * Gets the windowing mode to be in.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public int getWindowingMode() {
         return mLaunchParams.mWindowingMode;
     }
@@ -76,6 +86,7 @@
     /**
      * Sets the windowing mode to be in.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public void setWindowingMode(int windowingMode) {
         mLaunchParams.mWindowingMode = windowingMode;
     }
@@ -83,6 +94,7 @@
     /**
      *  Gets the bounds within the parent container.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public Rect getBounds() {
         return mLaunchParams.mBounds;
     }
@@ -90,11 +102,13 @@
     /**
      *  Sets the bounds within the parent container.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public void setBounds(Rect bounds) {
         mLaunchParams.mBounds.set(bounds);
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return "LaunchParams{" +
                 "mPreferredTaskDisplayArea=" + mLaunchParams.mPreferredTaskDisplayArea +
diff --git a/builtInServices/src/com/android/server/wm/RequestWrapper.java b/builtInServices/src/com/android/server/wm/RequestWrapper.java
index d6e1795..2bda2f1 100644
--- a/builtInServices/src/com/android/server/wm/RequestWrapper.java
+++ b/builtInServices/src/com/android/server/wm/RequestWrapper.java
@@ -18,6 +18,9 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
+
+import com.android.annotation.AddedIn;
 
 /**
  * Wrapper of {@link com.android.server.wm.ActivityStarter.Request}.
@@ -32,17 +35,20 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static RequestWrapper create(@Nullable ActivityStarter.Request request) {
         if (request == null) return null;
         return new RequestWrapper(request);
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public ActivityStarter.Request getRequest() {
         return mRequest;
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mRequest.toString();
     }
diff --git a/builtInServices/src/com/android/server/wm/TaskDisplayAreaWrapper.java b/builtInServices/src/com/android/server/wm/TaskDisplayAreaWrapper.java
index 9faef06..d703246 100644
--- a/builtInServices/src/com/android/server/wm/TaskDisplayAreaWrapper.java
+++ b/builtInServices/src/com/android/server/wm/TaskDisplayAreaWrapper.java
@@ -18,8 +18,11 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.view.Display;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of {@link TaskDisplayArea}.
  * @hide
@@ -33,12 +36,14 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static TaskDisplayAreaWrapper create(@Nullable TaskDisplayArea taskDisplayArea) {
         if (taskDisplayArea == null) return null;
         return new TaskDisplayAreaWrapper(taskDisplayArea);
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayArea getTaskDisplayArea() {
         return mTaskDisplayArea;
     }
@@ -46,11 +51,13 @@
     /**
      * Gets the display this {@link TaskDisplayAreaWrapper} is on.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public Display getDisplay() {
         return mTaskDisplayArea.getDisplayContent().getDisplay();
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mTaskDisplayArea.toString();
     }
diff --git a/builtInServices/src/com/android/server/wm/TaskWrapper.java b/builtInServices/src/com/android/server/wm/TaskWrapper.java
index 3a2c682..3759f91 100644
--- a/builtInServices/src/com/android/server/wm/TaskWrapper.java
+++ b/builtInServices/src/com/android/server/wm/TaskWrapper.java
@@ -18,6 +18,9 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
+
+import com.android.annotation.AddedIn;
 
 /**
  * Wrapper of {@link Task}.
@@ -32,6 +35,7 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static TaskWrapper create(@Nullable Task task) {
         if (task == null) return null;
         return new TaskWrapper(task);
@@ -40,6 +44,7 @@
     /**
      * Gets the {@code userId} of this {@link Task} is created for
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public int getUserId() {
         return mTask.mUserId;
     }
@@ -47,6 +52,7 @@
     /**
      * Gets the root {@link TaskWrapper} of the this.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskWrapper getRootTask() {
         return create(mTask.getRootTask());
     }
@@ -54,11 +60,13 @@
     /**
      * Gets the {@link TaskDisplayAreaWrapper} this {@link Task} is on.
      */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public TaskDisplayAreaWrapper getTaskDisplayArea() {
         return TaskDisplayAreaWrapper.create(mTask.getTaskDisplayArea());
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mTask.toString();
     }
diff --git a/builtInServices/src/com/android/server/wm/WindowLayoutWrapper.java b/builtInServices/src/com/android/server/wm/WindowLayoutWrapper.java
index e028a20..f55ce99 100644
--- a/builtInServices/src/com/android/server/wm/WindowLayoutWrapper.java
+++ b/builtInServices/src/com/android/server/wm/WindowLayoutWrapper.java
@@ -18,8 +18,11 @@
 
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
+import android.car.builtin.annotation.PlatformVersion;
 import android.content.pm.ActivityInfo;
 
+import com.android.annotation.AddedIn;
+
 /**
  * Wrapper of {@link android.content.pm.ActivityInfo.WindowLayout}.
  * @hide
@@ -33,12 +36,14 @@
     }
 
     /** @hide */
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public static WindowLayoutWrapper create(@Nullable ActivityInfo.WindowLayout layout) {
         if (layout == null) return null;
         return new WindowLayoutWrapper(layout);
     }
 
     @Override
+    @AddedIn(PlatformVersion.TIRAMISU_0)
     public String toString() {
         return mLayout.toString();
     }
diff --git a/builtInServices/tests/src/com/android/server/wm/AnnotationTest.java b/builtInServices/tests/src/com/android/server/wm/AnnotationTest.java
new file mode 100644
index 0000000..8360985
--- /dev/null
+++ b/builtInServices/tests/src/com/android/server/wm/AnnotationTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wm;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import com.android.annotation.AddedIn;
+
+import static android.car.test.util.AnnotationHelper.checkForAnnotation;
+
+import org.junit.Test;
+
+public class AnnotationTest {
+    private static final String[] CAR_SERVICE_HELPER_SERVICE_CLASSES = new String[] {
+            "com.android.internal.car.CarServiceHelperInterface",
+            "com.android.internal.car.CarServiceHelperServiceUpdatable",
+            "com.android.server.wm.ActivityOptionsWrapper",
+            "com.android.server.wm.ActivityRecordWrapper",
+            "com.android.server.wm.CalculateParams",
+            "com.android.server.wm.CarLaunchParamsModifierInterface",
+            "com.android.server.wm.CarLaunchParamsModifierUpdatable",
+            "com.android.server.wm.LaunchParamsWrapper",
+            "com.android.server.wm.RequestWrapper",
+            "com.android.server.wm.TaskDisplayAreaWrapper",
+            "com.android.server.wm.TaskWrapper",
+            "com.android.server.wm.WindowLayoutWrapper"
+            };
+    @Test
+    public void testCarHelperServiceAPIAddedInAnnotation() throws Exception {
+        checkForAnnotation(CAR_SERVICE_HELPER_SERVICE_CLASSES, AddedIn.class);
+    }
+}
+
diff --git a/updatableServices/src/com/android/internal/car/updatable/CarServiceProxy.java b/updatableServices/src/com/android/internal/car/updatable/CarServiceProxy.java
index 0824755..da3db22 100644
--- a/updatableServices/src/com/android/internal/car/updatable/CarServiceProxy.java
+++ b/updatableServices/src/com/android/internal/car/updatable/CarServiceProxy.java
@@ -16,6 +16,8 @@
 
 package com.android.internal.car.updatable;
 
+import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_CREATED;
+import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_REMOVED;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_STARTING;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_STOPPED;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_STOPPING;
@@ -197,7 +199,7 @@
         boolean user0IsCurrent = lastSwitchedUser == USER_SYSTEM;
         // If user0Lifecycle is 0, then no life-cycle event received yet.
         if (user0Lifecycle != 0) {
-            sendAllLifecyleToUser(USER_SYSTEM, user0Lifecycle,
+            sendAllLifecycleToUser(USER_SYSTEM, user0Lifecycle,
                     user0IsCurrent);
         }
         lastUserLifecycle.delete(USER_SYSTEM);
@@ -207,7 +209,7 @@
             int currentUserLifecycle = lastUserLifecycle.get(lastSwitchedUser);
             // If currentUserLifecycle is 0, then no life-cycle event received yet.
             if (currentUserLifecycle != 0) {
-                sendAllLifecyleToUser(lastSwitchedUser, currentUserLifecycle,
+                sendAllLifecycleToUser(lastSwitchedUser, currentUserLifecycle,
                         /* isCurrentUser= */ true);
             }
         }
@@ -218,15 +220,34 @@
         for (int i = 0; i < lastUserLifecycle.size(); i++) {
             int userId = lastUserLifecycle.keyAt(i);
             int lifecycle = lastUserLifecycle.valueAt(i);
-            sendAllLifecyleToUser(userId, lifecycle, /* isCurrentUser= */ false);
+            sendAllLifecycleToUser(userId, lifecycle, /* isCurrentUser= */ false);
         }
     }
 
-    private void sendAllLifecyleToUser(@UserIdInt int userId, int lifecycle,
+    private void sendAllLifecycleToUser(@UserIdInt int userId, int lifecycle,
             boolean isCurrentUser) {
         if (DBG) {
-            Slogf.d(TAG, "sendAllLifecyleToUser, user:" + userId + " lifecycle:" + lifecycle);
+            Slogf.d(TAG, "sendAllLifecycleToUser, user:" + userId + " lifecycle:" + lifecycle);
         }
+
+        // User created and user removed are unrelated to the user switching/unlocking flow.
+        // Return early to prevent them from going into the following logic
+        // that makes assumptions about the sequence of lifecycle event types
+        // following numerical order.
+        if (lifecycle == USER_LIFECYCLE_EVENT_TYPE_CREATED) {
+            sendUserLifecycleEventInternal(USER_LIFECYCLE_EVENT_TYPE_CREATED,
+                    UserManagerHelper.USER_NULL, userId);
+            return;
+        }
+
+        if (lifecycle == USER_LIFECYCLE_EVENT_TYPE_REMOVED) {
+            sendUserLifecycleEventInternal(USER_LIFECYCLE_EVENT_TYPE_REMOVED,
+                    UserManagerHelper.USER_NULL, userId);
+            return;
+        }
+
+        // The following logic makes assumptions about the sequence of lifecycle event types
+        // following numerical order.
         if (lifecycle >= USER_LIFECYCLE_EVENT_TYPE_STARTING) {
             sendUserLifecycleEventInternal(USER_LIFECYCLE_EVENT_TYPE_STARTING,
                     UserManagerHelper.USER_NULL, userId);
@@ -401,8 +422,11 @@
         Preconditions.checkArgument((value instanceof UserHandle),
                 "Invalid value for ON_USER_REMOVED: %s", value);
         UserHandle user = (UserHandle) value;
+        // TODO(235524989): Consolidating logging with other lifecycle events,
+        // including user metrics.
         if (DBG) Slogf.d(TAG, "Sending onUserRemoved(): " + user);
-        mCarService.onUserRemoved(user);
+        mCarService.onUserLifecycleEvent(USER_LIFECYCLE_EVENT_TYPE_REMOVED,
+                UserManagerHelper.USER_NULL, user.getIdentifier());
     }
 
     /**
diff --git a/updatableServices/tests/src/com/android/internal/car/updatable/CarServiceProxyTest.java b/updatableServices/tests/src/com/android/internal/car/updatable/CarServiceProxyTest.java
index 714cf55..39781c5 100644
--- a/updatableServices/tests/src/com/android/internal/car/updatable/CarServiceProxyTest.java
+++ b/updatableServices/tests/src/com/android/internal/car/updatable/CarServiceProxyTest.java
@@ -15,6 +15,7 @@
  */
 package com.android.internal.car.updatable;
 
+import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_REMOVED;
 import static com.android.car.internal.common.CommonConstants.USER_LIFECYCLE_EVENT_TYPE_SWITCHING;
 
 import static org.mockito.Mockito.any;
@@ -27,6 +28,7 @@
 import android.car.test.util.UserTestingHelper.UserInfoBuilder;
 import android.content.pm.UserInfo;
 import android.os.RemoteException;
+import android.os.UserHandle;
 
 import com.android.car.internal.ICarSystemServerClient;
 import com.android.server.SystemService.TargetUser;
@@ -115,7 +117,7 @@
 
         verifyInitBootUserCalled();
         verifySendLifecycleEventCalled(USER_LIFECYCLE_EVENT_TYPE_SWITCHING);
-        verifyOnUserRemovedCalled();
+        verifyLifecycleEventCalledForUserRemoval();
     }
 
     @Test
@@ -124,14 +126,14 @@
 
         callOnUserRemoved();
 
-        verifyOnUserRemovedCalled();
+        verifyLifecycleEventCalledForUserRemoval();
     }
 
     @Test
     public void testOnUserRemoved_CarServiceNull() throws RemoteException {
         callOnUserRemoved();
 
-        verifyOnUserRemovedNeverCalled();
+        verifySendLifecycleEventNeverCalled();
     }
 
     @Test
@@ -203,10 +205,13 @@
         verify(mCarService, never()).onUserLifecycleEvent(anyInt(), anyInt(), anyInt());
     }
 
-    private void verifyOnUserRemovedCalled() throws RemoteException {
-        verify(mCarService).onUserRemoved(mRemovedUser1.getUserHandle());
-        verify(mCarService).onUserRemoved(mRemovedUser2.getUserHandle());
-        verify(mCarService).onUserRemoved(mRemovedUser3.getUserHandle());
+    private void verifyLifecycleEventCalledForUserRemoval() throws RemoteException {
+        verify(mCarService).onUserLifecycleEvent(USER_LIFECYCLE_EVENT_TYPE_REMOVED,
+                UserHandle.USER_NULL, mRemovedUser1.getUserHandle().getIdentifier());
+        verify(mCarService).onUserLifecycleEvent(USER_LIFECYCLE_EVENT_TYPE_REMOVED,
+                UserHandle.USER_NULL, mRemovedUser2.getUserHandle().getIdentifier());
+        verify(mCarService).onUserLifecycleEvent(USER_LIFECYCLE_EVENT_TYPE_REMOVED,
+                UserHandle.USER_NULL, mRemovedUser3.getUserHandle().getIdentifier());
     }
 
     private void verifyOnUserRemovedNeverCalled() throws RemoteException {
diff --git a/updatableServices/tests/src/com/android/server/wm/CarLaunchParamsModifierUpdatableTest.java b/updatableServices/tests/src/com/android/server/wm/CarLaunchParamsModifierUpdatableTest.java
index 13dc733..1f1b627 100644
--- a/updatableServices/tests/src/com/android/server/wm/CarLaunchParamsModifierUpdatableTest.java
+++ b/updatableServices/tests/src/com/android/server/wm/CarLaunchParamsModifierUpdatableTest.java
@@ -202,7 +202,7 @@
                 mContext, mInputManagerService, /* showBootMsgs= */ false, /* onlyCore= */ false,
                 /* policy= */ null, mActivityTaskManagerService,
                 /* displayWindowSettingsProvider= */ null, () -> new SurfaceControl.Transaction(),
-                /* surfaceFactory= */ null, /* surfaceControlFactory= */ null);
+                /* surfaceControlFactory= */ null);
         mActivityTaskManagerService.mWindowManager = mWindowManagerService;
         mRootWindowContainer.mWindowManager = mWindowManagerService;