Merge "Allow setting future api level before REL" am: 52fdcf5457
Original change: https://android-review.googlesource.com/c/platform/build/+/2527081 Change-Id: I71f5e276257d16b1df32d762599d13a9f97f24aa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
9358c91d08
2 changed files with 24 additions and 7 deletions
|
@ -43,7 +43,7 @@ def validate_grf_props(prop_list, sdk_version):
|
|||
"""Validate GRF properties if exist.
|
||||
|
||||
If ro.board.first_api_level is defined, check if its value is valid for the
|
||||
sdk version.
|
||||
sdk version. This is only for the release version.
|
||||
Also, validate the value of ro.board.api_level if defined.
|
||||
|
||||
Returns:
|
||||
|
@ -51,6 +51,7 @@ def validate_grf_props(prop_list, sdk_version):
|
|||
"""
|
||||
grf_api_level = prop_list.get_value("ro.board.first_api_level")
|
||||
board_api_level = prop_list.get_value("ro.board.api_level")
|
||||
platform_version_codename = prop_list.get_value("ro.build.version.codename")
|
||||
|
||||
if not grf_api_level:
|
||||
if board_api_level:
|
||||
|
@ -61,6 +62,18 @@ def validate_grf_props(prop_list, sdk_version):
|
|||
return True
|
||||
|
||||
grf_api_level = int(grf_api_level)
|
||||
if board_api_level:
|
||||
board_api_level = int(board_api_level)
|
||||
if board_api_level < grf_api_level:
|
||||
sys.stderr.write("error: ro.board.api_level(%d) must be greater than "
|
||||
"ro.board.first_api_level(%d)\n"
|
||||
% (board_api_level, grf_api_level))
|
||||
return False
|
||||
|
||||
# skip sdk version validation for dev-stage non-REL devices
|
||||
if platform_version_codename != "REL":
|
||||
return True
|
||||
|
||||
if grf_api_level > sdk_version:
|
||||
sys.stderr.write("error: ro.board.first_api_level(%d) must be less than "
|
||||
"or equal to ro.build.version.sdk(%d)\n"
|
||||
|
@ -68,12 +81,10 @@ def validate_grf_props(prop_list, sdk_version):
|
|||
return False
|
||||
|
||||
if board_api_level:
|
||||
board_api_level = int(board_api_level)
|
||||
if board_api_level < grf_api_level or board_api_level > sdk_version:
|
||||
sys.stderr.write("error: ro.board.api_level(%d) must be neither less "
|
||||
"than ro.board.first_api_level(%d) nor greater than "
|
||||
"ro.build.version.sdk(%d)\n"
|
||||
% (board_api_level, grf_api_level, sdk_version))
|
||||
if board_api_level > sdk_version:
|
||||
sys.stderr.write("error: ro.board.api_level(%d) must be less than or "
|
||||
"equal to ro.build.version.sdk(%d)\n"
|
||||
% (board_api_level, sdk_version))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
@ -256,6 +256,7 @@ class PropListTestcase(unittest.TestCase):
|
|||
with contextlib.redirect_stderr(stderr_redirect):
|
||||
props = PropList("hello")
|
||||
props.put("ro.board.first_api_level","25")
|
||||
props.put("ro.build.version.codename", "REL")
|
||||
|
||||
# ro.board.first_api_level must be less than or equal to the sdk version
|
||||
self.assertFalse(validate_grf_props(props, 20))
|
||||
|
@ -273,5 +274,10 @@ class PropListTestcase(unittest.TestCase):
|
|||
# ro.board.api_level must be less than or equal to the sdk version
|
||||
self.assertFalse(validate_grf_props(props, 25))
|
||||
|
||||
# allow setting future api_level before release
|
||||
props.get_all_props()[-2].make_as_comment()
|
||||
props.put("ro.build.version.codename", "NonRel")
|
||||
self.assertTrue(validate_grf_props(props, 24))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
||||
|
|
Loading…
Reference in a new issue