Fix CtsStrictJavaPackagesTestCases
- Refactored the newly added com.android.car.internal library
- Move common constants to andorid.car and dynamically added required constants to CarServiceHeleprService
Bug: 166680653
Bug: 164173744
Test: atest CtsStrictJavaPackagesTestCases
atest CarServiceTest
atest CarServiceUnitTest
Change-Id: I446f95d045b57059b80e117abafd97c4d8fdcac1
diff --git a/car-internal-lib/Android.bp b/car-internal-lib/Android.bp
index fb4ef81..b80bd14 100644
--- a/car-internal-lib/Android.bp
+++ b/car-internal-lib/Android.bp
@@ -22,7 +22,6 @@
name: "com.android.car.internal.all",
srcs: [
"src/com/android/car/internal/EventLogTags.logtags",
- "src/com/android/car/internal/CommonConstants.java",
"src/com/android/car/internal/UserHelperLite.java",
],
}
diff --git a/car-lib/Android.bp b/car-lib/Android.bp
index cc2bb8d..14c006d 100644
--- a/car-lib/Android.bp
+++ b/car-lib/Android.bp
@@ -65,12 +65,18 @@
srcs: ["src/android/car/navigation/navigation_state.proto"]
}
-// library to access settings from CarSettings
+// library to access settings from CarSettings
java_library {
name: "android.car.settings",
srcs: ["src/android/car/settings/CarSettings.java"]
}
+// library to access common constants between carlibrary and system server.
+java_library {
+ name: "android.car.constants",
+ srcs: ["src/android/car/Constants/CommonConstants.java"]
+}
+
java_library {
name: "android.car",
srcs: [
diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java
index f611568..f3099d1 100644
--- a/car-lib/src/android/car/Car.java
+++ b/car-lib/src/android/car/Car.java
@@ -33,6 +33,7 @@
import android.car.annotation.OptionalFeature;
import android.car.cluster.CarInstrumentClusterManager;
import android.car.cluster.ClusterActivityState;
+import android.car.constants.CommonConstants;
import android.car.content.pm.CarPackageManager;
import android.car.diagnostic.CarDiagnosticManager;
import android.car.drivingstate.CarDrivingStateManager;
@@ -743,7 +744,7 @@
"android.media.session.BROWSE_SERVICE";
/** @hide */
- public static final String CAR_SERVICE_INTERFACE_NAME = "android.car.ICar";
+ public static final String CAR_SERVICE_INTERFACE_NAME = CommonConstants.CAR_SERVICE_INTERFACE;
private static final String CAR_SERVICE_PACKAGE = "com.android.car";
diff --git a/car-internal-lib/src/com/android/car/internal/CommonConstants.java b/car-lib/src/android/car/Constants/CommonConstants.java
similarity index 67%
rename from car-internal-lib/src/com/android/car/internal/CommonConstants.java
rename to car-lib/src/android/car/Constants/CommonConstants.java
index 48427ad..a80f00e 100644
--- a/car-internal-lib/src/com/android/car/internal/CommonConstants.java
+++ b/car-lib/src/android/car/Constants/CommonConstants.java
@@ -14,10 +14,12 @@
* limitations under the License.
*/
-package com.android.car.internal;
+package android.car.constants;
/**
- * Provides common constants for CarService, CarServiceHelperService and other packages.
+ * Provides common constants for Car library, Car Service, and System Server.
+ *
+ * @hide
*/
public final class CommonConstants {
@@ -26,6 +28,7 @@
}
// CarUserManagerConstants
+
public static final int USER_LIFECYCLE_EVENT_TYPE_STARTING = 1;
public static final int USER_LIFECYCLE_EVENT_TYPE_SWITCHING = 2;
public static final int USER_LIFECYCLE_EVENT_TYPE_UNLOCKING = 3;
@@ -33,16 +36,6 @@
public static final int USER_LIFECYCLE_EVENT_TYPE_STOPPING = 5;
public static final int USER_LIFECYCLE_EVENT_TYPE_STOPPED = 6;
- public static final String BUNDLE_PARAM_ACTION = "action";
- public static final String BUNDLE_PARAM_PREVIOUS_USER_ID = "previous_user";
-
- // CarUserServiceConstants
- public static final String BUNDLE_USER_ID = "user.id";
- public static final String BUNDLE_USER_FLAGS = "user.flags";
- public static final String BUNDLE_USER_NAME = "user.name";
- public static final String BUNDLE_USER_LOCALES = "user.locales";
- public static final String BUNDLE_INITIAL_INFO_ACTION = "initial_info.action";
-
// CarService Constants
public static final String CAR_SERVICE_INTERFACE = "android.car.ICar";
}
diff --git a/car-lib/src/android/car/user/CarUserManager.java b/car-lib/src/android/car/user/CarUserManager.java
index 3018618..41e5974 100644
--- a/car-lib/src/android/car/user/CarUserManager.java
+++ b/car-lib/src/android/car/user/CarUserManager.java
@@ -33,6 +33,7 @@
import android.car.Car;
import android.car.CarManagerBase;
import android.car.ICarUserService;
+import android.car.constants.CommonConstants;
import android.car.util.concurrent.AndroidAsyncFuture;
import android.car.util.concurrent.AsyncFuture;
import android.content.pm.UserInfo;
@@ -48,7 +49,6 @@
import android.util.EventLog;
import android.util.Log;
-import com.android.car.internal.CommonConstants;
import com.android.car.internal.EventLogTags;
import com.android.car.internal.UserHelperLite;
import com.android.internal.annotations.GuardedBy;
@@ -176,11 +176,9 @@
public @interface UserLifecycleEventType{}
/** @hide */
- public static final String BUNDLE_PARAM_ACTION =
- CommonConstants.BUNDLE_PARAM_ACTION;
+ public static final String BUNDLE_PARAM_ACTION = "action";
/** @hide */
- public static final String BUNDLE_PARAM_PREVIOUS_USER_ID =
- CommonConstants.BUNDLE_PARAM_PREVIOUS_USER_ID;
+ public static final String BUNDLE_PARAM_PREVIOUS_USER_ID = "previous_user";
private final Object mLock = new Object();
private final ICarUserService mService;
diff --git a/service/Android.bp b/service/Android.bp
index 4e76ab7..3954c5a 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -68,7 +68,6 @@
libs: ["android.car"],
static_libs: common_lib_deps + [
- "com.android.car.internal.all",
"com.android.car.internal.system",
],
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index 604a59c..ef372fc 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -81,7 +81,6 @@
import com.android.car.CarServiceUtils;
import com.android.car.R;
import com.android.car.hal.UserHalService;
-import com.android.car.internal.CommonConstants;
import com.android.car.internal.EventLogTags;
import com.android.car.internal.UserHelperLite;
import com.android.car.power.CarPowerManagementService;
@@ -120,21 +119,19 @@
private static final String TAG = TAG_USER;
/** {@code int} extra used to represent a user id in a {@link IResultReceiver} response. */
- public static final String BUNDLE_USER_ID = CommonConstants.BUNDLE_USER_ID;
+ public static final String BUNDLE_USER_ID = "user.id";
/** {@code int} extra used to represent user flags in a {@link IResultReceiver} response. */
- public static final String BUNDLE_USER_FLAGS = CommonConstants.BUNDLE_USER_FLAGS;
+ public static final String BUNDLE_USER_FLAGS = "user.flags";
/** {@code String} extra used to represent a user name in a {@link IResultReceiver} response. */
- public static final String BUNDLE_USER_NAME = CommonConstants.BUNDLE_USER_NAME;
+ public static final String BUNDLE_USER_NAME = "user.name";
/**
* {@code int} extra used to represent the user locales in a {@link IResultReceiver} response.
*/
- public static final String BUNDLE_USER_LOCALES =
- CommonConstants.BUNDLE_USER_LOCALES;
+ public static final String BUNDLE_USER_LOCALES = "user.locales";
/**
* {@code int} extra used to represent the info action in a {@link IResultReceiver} response.
*/
- public static final String BUNDLE_INITIAL_INFO_ACTION =
- CommonConstants.BUNDLE_INITIAL_INFO_ACTION;
+ public static final String BUNDLE_INITIAL_INFO_ACTION = "initial_info.action";
public static final String VEHICLE_HAL_NOT_SUPPORTED = "Vehicle Hal not supported.";