Merge "Created class (CommonResults) for common result statuses." into rvc-dev
diff --git a/car-lib/src/android/car/user/CommonResults.java b/car-lib/src/android/car/user/CommonResults.java
new file mode 100644
index 0000000..9238a0b
--- /dev/null
+++ b/car-lib/src/android/car/user/CommonResults.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 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 android.car.user;
+
+/**
+ * Defines status for common result objects.
+ */
+final class CommonResults {
+
+    /**
+     * Operation was is successful for both HAL and Android.
+     */
+    public static final int STATUS_SUCCESSFUL = 1;
+
+    /**
+     * Operation failed on Android.
+     */
+    public static final int STATUS_ANDROID_FAILURE = 2;
+
+    /**
+     * Operation failed on HAL.
+     */
+    public static final int STATUS_HAL_FAILURE = 3;
+
+    /**
+     * Operation failed due to an error communication with HAL (like timeout).
+     */
+    public static final int STATUS_HAL_INTERNAL_FAILURE = 4;
+
+    /**
+     * Operation failed due to invalid request.
+     */
+    public static final int STATUS_INVALID_REQUEST = 5;
+
+    /**
+     * Reference for common status - anything higher than this can be used for custom status
+     */
+    static final int LAST_COMMON_STATUS = 100;
+
+    private CommonResults() {
+        throw new UnsupportedOperationException();
+    }
+}
diff --git a/car-lib/src/android/car/user/UserCreationResult.java b/car-lib/src/android/car/user/UserCreationResult.java
index d0f7aa1..a79abee 100644
--- a/car-lib/src/android/car/user/UserCreationResult.java
+++ b/car-lib/src/android/car/user/UserCreationResult.java
@@ -42,7 +42,7 @@
      *
      * @hide
      */
-    public static final int STATUS_SUCCESSFUL = 1;
+    public static final int STATUS_SUCCESSFUL = CommonResults.STATUS_SUCCESSFUL;
 
     /**
      * {@link Status} called when user creation failed on Android - HAL is not even called in this
@@ -50,7 +50,7 @@
      *
      * @hide
      */
-    public static final int STATUS_ANDROID_FAILURE = 2;
+    public static final int STATUS_ANDROID_FAILURE = CommonResults.STATUS_ANDROID_FAILURE;
 
     /**
      * {@link Status} called when user was created on Android but HAL returned a failure - the
@@ -58,7 +58,7 @@
      *
      * @hide
      */
-    public static final int STATUS_HAL_FAILURE = 3;
+    public static final int STATUS_HAL_FAILURE = CommonResults.STATUS_HAL_FAILURE;
 
     /**
      * {@link Status} called when user creation is failed for HAL for some internal error - the
@@ -66,7 +66,7 @@
      *
      * @hide
      */
-    public static final int STATUS_HAL_INTERNAL_FAILURE = 4;
+    public static final int STATUS_HAL_INTERNAL_FAILURE = CommonResults.STATUS_HAL_INTERNAL_FAILURE;
 
     /**
      * Gets the user switch result status.
diff --git a/car-lib/src/android/car/user/UserSwitchResult.java b/car-lib/src/android/car/user/UserSwitchResult.java
index 8c4c535..41da19b 100644
--- a/car-lib/src/android/car/user/UserSwitchResult.java
+++ b/car-lib/src/android/car/user/UserSwitchResult.java
@@ -38,63 +38,50 @@
 
     /**
      * When user switch is successful for both HAL and Android.
-     *
-     * @hide
      */
-    public static final int STATUS_SUCCESSFUL = 1;
+    public static final int STATUS_SUCCESSFUL = CommonResults.STATUS_SUCCESSFUL;
 
     /**
      * When user switch is only successful for Hal but not for Android. Hal user switch rollover
      * message have been sent.
-     *
-     * @hide
      */
-    public static final int STATUS_ANDROID_FAILURE = 2;
+    public static final int STATUS_ANDROID_FAILURE = CommonResults.STATUS_ANDROID_FAILURE;
 
     /**
      * When user switch fails for HAL. User switch for Android is not called.
-     *
-     * @hide
      */
-    public static final int STATUS_HAL_FAILURE = 3;
+    public static final int STATUS_HAL_FAILURE = CommonResults.STATUS_HAL_FAILURE;
 
     /**
      * When user switch fails for HAL for some internal error. User switch for Android is not
      * called.
-     *
-     * @hide
      */
-    public static final int STATUS_HAL_INTERNAL_FAILURE = 4;
-
-    /**
-     * When target user is same as current user.
-     *
-     * @hide
-     */
-    public static final int STATUS_ALREADY_REQUESTED_USER = 5;
-
-    /**
-     * When another user switch request for the same target user is in process.
-     *
-     * @hide
-     */
-    public static final int STATUS_TARGET_USER_ALREADY_BEING_SWITCHED_TO = 6;
-
-    /**
-     * When another user switch request for a new different target user is received. Previous
-     * request is abandoned.
-     *
-     * @hide
-     */
-    public static final int STATUS_TARGET_USER_ABANDONED_DUE_TO_A_NEW_REQUEST = 7;
+    public static final int STATUS_HAL_INTERNAL_FAILURE = CommonResults.STATUS_HAL_INTERNAL_FAILURE;
 
     /**
      * When given parameters or environment states are invalid for switching user. HAL or Android
      * user switch is not requested.
-     *
-     * @hide
      */
-    public static final int STATUS_INVALID_REQUEST = 8;
+    public static final int STATUS_INVALID_REQUEST = CommonResults.STATUS_INVALID_REQUEST;
+
+    /**
+     * When target user is same as current user.
+     */
+    public static final int STATUS_ALREADY_REQUESTED_USER =
+            CommonResults.LAST_COMMON_STATUS + 1;
+
+    /**
+     * When another user switch request for the same target user is in process.
+     */
+    public static final int STATUS_TARGET_USER_ALREADY_BEING_SWITCHED_TO =
+            CommonResults.LAST_COMMON_STATUS + 2;
+
+    /**
+     * When another user switch request for a new different target user is received. Previous
+     * request is abandoned.
+     */
+    public static final int STATUS_TARGET_USER_ABANDONED_DUE_TO_A_NEW_REQUEST =
+            CommonResults.LAST_COMMON_STATUS + 3;
 
     /**
      * Gets the user switch result status.