Read ro.vendor.api_level for VsrApiLevel am: 27093cca3a am: 6700b8b2df
Original change: https://android-review.googlesource.com/c/platform/test/suite_harness/+/2907003
Change-Id: Id61dabbc2d39e2297a027cf81fc784a02899682e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
index cbc0e69..881a0c8 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -41,6 +41,7 @@
private static final String BUILD_TYPE_PROPERTY = "ro.build.type";
private static final String MANUFACTURER_PROPERTY = "ro.product.manufacturer";
private static final String TAG_DEV_KEYS = "dev-keys";
+ private static final String VENDOR_API_LEVEL = "ro.vendor.api_level";
private static final String VNDK_VERSION = "ro.vndk.version";
/** Value to be returned by getPropertyInt() if property is not found */
@@ -81,11 +82,16 @@
/**
* Return the API level that the VSR requirement must be fulfilled. It reads
- * ro.product.first_api_level and ro.board.first_api_level to find the minimum required VSR
- * api_level for the DUT.
+ * ro.vendor.api_level. If not provided for old devices, read ro.product.first_api_level,
+ * ro.board.api_level and ro.board.first_api_level to find the minimum required VSR api level of
+ * the DUT.
*/
public static int getVsrApiLevel(ITestDevice device) throws DeviceNotAvailableException {
- // Api level properties of the board. The order of the properties must be kept.
+ int vendorApiLevel = getPropertyInt(device, VENDOR_API_LEVEL);
+ if (vendorApiLevel != INT_VALUE_IF_UNSET) {
+ return vendorApiLevel;
+ }
+ // Fallback to api level calculation for old devices.
String[] boardApiLevelProps = {BOARD_API_LEVEL, BOARD_FIRST_API_LEVEL};
for (String apiLevelProp : boardApiLevelProps) {
int apiLevel = getPropertyInt(device, apiLevelProp);
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/PropertyUtilTest.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/PropertyUtilTest.java
index ee01810..5593e92 100644
--- a/common/host-side/util/tests/src/com/android/compatibility/common/util/PropertyUtilTest.java
+++ b/common/host-side/util/tests/src/com/android/compatibility/common/util/PropertyUtilTest.java
@@ -33,9 +33,10 @@
/** Unit tests for {@link PropertyUtil} */
@RunWith(JUnit4.class)
public class PropertyUtilTest {
+ private static final String BOARD_API_LEVEL = "ro.board.api_level";
+ private static final String BOARD_FIRST_API_LEVEL = "ro.board.first_api_level";
private static final String FIRST_API_LEVEL = "ro.product.first_api_level";
- private static final String VENDOR_API_LEVEL = "ro.board.api_level";
- private static final String VENDOR_FIRST_API_LEVEL = "ro.board.first_api_level";
+ private static final String VENDOR_API_LEVEL = "ro.vendor.api_level";
private static final String VNDK_VERSION = "ro.vndk.version";
private ITestDevice mMockDevice;
@@ -60,24 +61,24 @@
}
@Test
- public void testGetVendorApiLevelFromVendorApiLevel() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn("31");
+ public void testGetVendorApiLevelFromBoardApiLevel() throws DeviceNotAvailableException {
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn("31");
assertEquals(31, PropertyUtil.getVendorApiLevel(mMockDevice));
}
@Test
- public void testGetVendorApiLevelFromVendorFirstApiLevel() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn("31");
+ public void testGetVendorApiLevelFromBoardFirstApiLevel() throws DeviceNotAvailableException {
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn("31");
assertEquals(31, PropertyUtil.getVendorApiLevel(mMockDevice));
}
@Test
public void testGetVendorApiLevelFromVndkVersion() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn(null);
when(mMockDevice.getProperty(VNDK_VERSION)).thenReturn("31");
assertEquals(31, PropertyUtil.getVendorApiLevel(mMockDevice));
@@ -85,17 +86,8 @@
@Test
public void testGetVendorApiLevelCurrent() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VNDK_VERSION)).thenReturn(null);
-
- assertEquals(PropertyUtil.API_LEVEL_CURRENT, PropertyUtil.getVendorApiLevel(mMockDevice));
- }
-
- @Test
- public void testGetVendorApiLevelCurrent2() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn(null);
when(mMockDevice.getProperty(VNDK_VERSION)).thenReturn("S");
assertEquals(PropertyUtil.API_LEVEL_CURRENT, PropertyUtil.getVendorApiLevel(mMockDevice));
@@ -103,15 +95,15 @@
@Test
public void testIsVendorApiLevelNewerThan() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn("30");
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn("30");
assertFalse(PropertyUtil.isVendorApiLevelNewerThan(mMockDevice, 30));
}
@Test
public void testIsVendorApiLevelAtLeast() throws DeviceNotAvailableException {
- when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn("30");
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn("30");
assertTrue(PropertyUtil.isVendorApiLevelAtLeast(mMockDevice, 30));
}
@@ -119,7 +111,8 @@
@Test
public void testGetVsrApiLevelEmptyBoardVersions() throws DeviceNotAvailableException {
when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn(null);
when(mMockDevice.getProperty(FIRST_API_LEVEL)).thenReturn("30");
assertEquals(30, PropertyUtil.getVsrApiLevel(mMockDevice));
@@ -128,9 +121,17 @@
@Test
public void testGetVsrApiLevelFromBoardVersions() throws DeviceNotAvailableException {
when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn(null);
- when(mMockDevice.getProperty(VENDOR_FIRST_API_LEVEL)).thenReturn("30");
+ when(mMockDevice.getProperty(BOARD_API_LEVEL)).thenReturn(null);
+ when(mMockDevice.getProperty(BOARD_FIRST_API_LEVEL)).thenReturn("30");
when(mMockDevice.getProperty(FIRST_API_LEVEL)).thenReturn("31");
assertEquals(30, PropertyUtil.getVsrApiLevel(mMockDevice));
}
+
+ @Test
+ public void testGetVsrApiLevelFromVendorApiLevel() throws DeviceNotAvailableException {
+ when(mMockDevice.getProperty(VENDOR_API_LEVEL)).thenReturn("202404");
+
+ assertEquals(202404, PropertyUtil.getVsrApiLevel(mMockDevice));
+ }
}