Correct REMOVE_USER change mode.
REMOVE_USER change mode should not be static. Correct it in our
doc to on_change. Updates VTS to allow both for backward
compatibility.
Test: Presubmit
Flag: EXEMPT doc VTS
Bug: 401350376
Change-Id: Ib0420d67aba97be18c564b4a3cc25402435068c6
diff --git a/automotive/vehicle/aidl/emu_metadata/android.hardware.automotive.vehicle-types-meta.json b/automotive/vehicle/aidl/emu_metadata/android.hardware.automotive.vehicle-types-meta.json
index 92681de..e7c03ad 100644
--- a/automotive/vehicle/aidl/emu_metadata/android.hardware.automotive.vehicle-types-meta.json
+++ b/automotive/vehicle/aidl/emu_metadata/android.hardware.automotive.vehicle-types-meta.json
@@ -1215,7 +1215,7 @@
{
"name": "REMOVE_USER",
"value": 299896586,
- "description": "Called by the Android System after an Android user was removed.\nThe HAL can use this property to remove its equivalent user.\nThis is write-only call - the Android System is not expecting a reply from the HAL. Hence, this request should not fail - if the equivalent HAL user cannot be removed, then HAL should mark it as inactive or recover in some other way.\nThe request is made by setting the VehiclePropValue with the contents defined by RemoveUserRequest.\nFor example, if system had 3 users (0, 10, and 11) and user 11 was removed, the request would be:\nint32[0]: 42 \/\/ request id int32[1]: 11 \/\/ (Android user id of the removed user) int32[2]: 0 \/\/ (Android user flags of the removed user) int32[3]: 10 \/\/ current user int32[4]: 0 \/\/ current user flags (none) int32[5]: 2 \/\/ number of users int32[6]: 0 \/\/ 1st user (user 0) int32[7]: 0 \/\/ 1st user flags (none) int32[8]: 10 \/\/ 2nd user (user 10) int32[9]: 0 \/\/ 2nd user flags (none)"
+ "description": "Called by the Android System after an Android user was removed.\nThe HAL can use this property to remove its equivalent user.\nThis is write-only call - the Android System is not expecting a reply from the HAL. Hence, this request should not fail - if the equivalent HAL user cannot be removed, then HAL should mark it as inactive or recover in some other way.\nThe request is made by setting the VehiclePropValue with the contents defined by RemoveUserRequest.\nFor example, if system had 3 users (0, 10, and 11) and user 11 was removed, the request would be:\nint32[0]: 42 \/\/ request id int32[1]: 11 \/\/ (Android user id of the removed user) int32[2]: 0 \/\/ (Android user flags of the removed user) int32[3]: 10 \/\/ current user int32[4]: 0 \/\/ current user flags (none) int32[5]: 2 \/\/ number of users int32[6]: 0 \/\/ 1st user (user 0) int32[7]: 0 \/\/ 1st user flags (none) int32[8]: 10 \/\/ 2nd user (user 10) int32[9]: 0 \/\/ 2nd user flags (none)\nBefore Android B, this property's change mode was defined as STATIC although the property value may be updated from Android side. For backward compatibility, we still allow STATIC as change mode, but for new implementations, ON_CHANGE should be used instead."
},
{
"name": "USER_IDENTIFICATION_ASSOCIATION",
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
index ca07ecf..685b010 100644
--- a/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
@@ -235,7 +235,7 @@
{VehicleProperty::INITIAL_USER_INFO, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::SWITCH_USER, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::CREATE_USER, VehiclePropertyChangeMode::ON_CHANGE},
- {VehicleProperty::REMOVE_USER, VehiclePropertyChangeMode::STATIC},
+ {VehicleProperty::REMOVE_USER, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::USER_IDENTIFICATION_ASSOCIATION, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::EVS_SERVICE_REQUEST, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::POWER_POLICY_REQ, VehiclePropertyChangeMode::ON_CHANGE},
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
index cf44887..39a9c42 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
@@ -233,7 +233,7 @@
Map.entry(VehicleProperty.INITIAL_USER_INFO, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.SWITCH_USER, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.CREATE_USER, VehiclePropertyChangeMode.ON_CHANGE),
- Map.entry(VehicleProperty.REMOVE_USER, VehiclePropertyChangeMode.STATIC),
+ Map.entry(VehicleProperty.REMOVE_USER, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.USER_IDENTIFICATION_ASSOCIATION, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.EVS_SERVICE_REQUEST, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.POWER_POLICY_REQ, VehiclePropertyChangeMode.ON_CHANGE),
diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
index 2f1b277..cf9ea10 100644
--- a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -5716,7 +5716,11 @@
* int32[8]: 10 // 2nd user (user 10)
* int32[9]: 0 // 2nd user flags (none)
*
- * @change_mode VehiclePropertyChangeMode.STATIC
+ * Before Android B, this property's change mode was defined as STATIC although the property
+ * value may be updated from Android side. For backward compatibility, we still allow STATIC
+ * as change mode, but for new implementations, ON_CHANGE should be used instead.
+ *
+ * @change_mode VehiclePropertyChangeMode.ON_CHANGE
* @access VehiclePropertyAccess.WRITE
* @version 2
*/
diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
index 7f5e06d..f249cf6 100644
--- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
+++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
@@ -1248,9 +1248,21 @@
}
}
- EXPECT_EQ(actualChangeMode, expectedChangeMode)
- << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
- expectedChangeMode, actualChangeMode);
+ if (actualPropId != toInt(VehicleProperty::REMOVE_USER)) {
+ EXPECT_EQ(actualChangeMode, expectedChangeMode)
+ << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
+ expectedChangeMode, actualChangeMode);
+ } else {
+ // Special logic for REMOVE_USER property. We allow both STATIC and ON_CHANGE change mode
+ // because historically we define the change mode to be STATIC which is incorrect, it should
+ // be on_change. For backward compatibility, we have to allow both.
+ EXPECT_THAT(actualChangeMode, ::testing::AnyOf(toInt(VehiclePropertyChangeMode::STATIC),
+ toInt(VehiclePropertyChangeMode::ON_CHANGE)))
+ << StringPrintf(
+ "Expect to get VehiclePropertyChangeMode as one of: "
+ "[STATIC, ON_CHANGE], got %i",
+ actualChangeMode);
+ }
std::unordered_set<std::string> annotations;
auto it = AnnotationsForVehicleProperty.find(param.propId);