summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Yun <justinyun@google.com>2024-01-14 22:49:29 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-14 22:49:29 +0000
commit6700b8b2df9c4d98ca05b8b5372a1ddc729a3ea9 (patch)
treec0075e2d0e45655eacdf075727e7946f7cab9b22
parentbf8419c9adfdcd20a7bc3058882e4162a37c726a (diff)
parent27093cca3abe9082781e00f4fef5a42bb977b8c5 (diff)
downloadsuite_harness-6700b8b2df9c4d98ca05b8b5372a1ddc729a3ea9.tar.gz
Read ro.vendor.api_level for VsrApiLevel am: 27093cca3a
Original change: https://android-review.googlesource.com/c/platform/test/suite_harness/+/2907003 Change-Id: I308995958bdf54182d33d92a156dfeabc6065985 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java12
-rw-r--r--common/host-side/util/tests/src/com/android/compatibility/common/util/PropertyUtilTest.java51
2 files changed, 35 insertions, 28 deletions
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 cbc0e697..881a0c88 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 @@ public class PropertyUtil {
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 @@ public class PropertyUtil {
/**
* 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 ee018109..5593e92b 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 @@ import org.mockito.Mockito;
/** 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 @@ public class PropertyUtilTest {
}
@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 @@ public class PropertyUtilTest {
@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 @@ public class PropertyUtilTest {
@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 @@ public class PropertyUtilTest {
@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 @@ public class PropertyUtilTest {
@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));
+ }
}