diff --git a/tools/post_process_props.py b/tools/post_process_props.py index 38d17a81db..31a460d008 100755 --- a/tools/post_process_props.py +++ b/tools/post_process_props.py @@ -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 diff --git a/tools/test_post_process_props.py b/tools/test_post_process_props.py index 236f9edfdf..439fc9f8b9 100644 --- a/tools/test_post_process_props.py +++ b/tools/test_post_process_props.py @@ -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)