diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-01-07 04:37:29 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-01-07 04:37:29 +0000 |
commit | ff2b673008c1233af0fcbb36c1625a275c11985f (patch) | |
tree | e692a6139ff461cc553228052ee52a7e5ed0c37d | |
parent | 012a9dd4f994def3647f52ca2bc3bea1c7e4bffe (diff) | |
parent | 803e79ddfde44167da8387a4b0d0ef4b1881206b (diff) | |
download | cts-ff2b673008c1233af0fcbb36c1625a275c11985f.tar.gz |
Merge "Provide getVsrApiLevel() to read the Vsr API level of DUT" into android12-tests-dev
-rw-r--r-- | common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java index 70c93629959..b8562abf6f7 100644 --- a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java +++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java @@ -38,13 +38,14 @@ public class PropertyUtil { * shipped. Property should be undefined for factory ROM products. */ public static final String FIRST_API_LEVEL = "ro.product.first_api_level"; + 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 BUILD_TYPE_PROPERTY = "ro.build.type"; + private static final String CAMERAX_EXTENSIONS_ENABLED = "ro.camerax.extensions.enabled"; 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.board.api_level"; - private static final String VENDOR_FIRST_API_LEVEL = "ro.board.first_api_level"; + private static final String VENDOR_BUILD_VERSION_SDK = "ro.vendor.build.version.sdk"; private static final String VNDK_VERSION = "ro.vndk.version"; - private static final String CAMERAX_EXTENSIONS_ENABLED = "ro.camerax.extensions.enabled"; public static final String GOOGLE_SETTINGS_QUERY = "content query --uri content://com.google.settings/partner"; @@ -89,6 +90,23 @@ public class PropertyUtil { } /** + * Return the API level that the VSR requirement must be fulfilled. It reads + * ro.product.first_api_level, ro.board.first_api_level, and ro.board.api_level + * to find the minimum required VSR api_level for the DUT. + */ + public static int getVsrApiLevel() { + // Api level properties of the board. The order of the properties must be kept. + String[] boardApiLevelProps = { BOARD_API_LEVEL, BOARD_FIRST_API_LEVEL, VENDOR_BUILD_VERSION_SDK }; + for (String apiLevelProp : boardApiLevelProps) { + int apiLevel = getPropertyInt(apiLevelProp); + if (apiLevel != INT_VALUE_IF_UNSET) { + return Math.min(apiLevel, getFirstApiLevel()); + } + } + return getFirstApiLevel(); + } + + /** * Return the API level of the vendor partition. It will read the following properties in order * and returns the value of the first defined property. If none of them are defined, or the * value is a VERSION CODENAME, returns the current API level which is defined in @@ -103,7 +121,7 @@ public class PropertyUtil { public static int getVendorApiLevel() { String[] vendorApiLevelProps = { // Use the properties in order. - VENDOR_API_LEVEL, VENDOR_FIRST_API_LEVEL, VNDK_VERSION, + BOARD_API_LEVEL, BOARD_FIRST_API_LEVEL, VNDK_VERSION, }; for (String prop : vendorApiLevelProps) { int apiLevel = getPropertyInt(prop); |