Remove grf_required_api_level

As we don't fix the grf window, we may not calculate the grf
expiration date and the required api level.
The verification of this will be covered by the tests at run time.

Bug: 176950752
Test: atest --host post_process_props_unittest
Change-Id: I1205f0d9a9da5bc508a49acbcbb7da581800bf45
This commit is contained in:
Justin Yun 2021-04-13 17:58:59 +09:00
parent dd74264737
commit 48aa78ed3c
2 changed files with 9 additions and 32 deletions

View file

@ -44,14 +44,12 @@ def mangle_build_prop(prop_list):
if not prop_list.get_value("persist.sys.usb.config"):
prop_list.put("persist.sys.usb.config", "none")
def validate_and_add_grf_props(prop_list, sdk_version):
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.
Also, validate the value of ro.board.api_level if defined. If the
ro.board.api_level property is not defined, define it with the required
vendor API level for the GRF policy.
Also, validate the value of ro.board.api_level if defined.
Returns:
True if the GRF properties are valid.
@ -74,10 +72,6 @@ def validate_and_add_grf_props(prop_list, sdk_version):
% (grf_api_level, sdk_version))
return False
grf_window = 4
grf_required_api_level = (grf_api_level
+ grf_window * ((sdk_version - grf_api_level) // grf_window))
if board_api_level:
board_api_level = int(board_api_level)
if board_api_level < grf_api_level or board_api_level > sdk_version:
@ -86,13 +80,6 @@ def validate_and_add_grf_props(prop_list, sdk_version):
"ro.build.version.sdk(%d)\n"
% (board_api_level, grf_api_level, sdk_version))
return False
if board_api_level < grf_required_api_level:
sys.stderr.write("error: ro.board.api_level(%d) must be greater than or "
"equal to %d based on GRF policy\n"
% (board_api_level, grf_required_api_level))
return False
else:
prop_list.put("ro.board.api_level", str(grf_required_api_level))
return True
@ -278,7 +265,7 @@ def main(argv):
mangle_build_prop(props)
if not override_optional_props(props, args.allow_dup):
sys.exit(1)
if not validate_and_add_grf_props(props, args.sdk_version):
if not validate_grf_props(props, args.sdk_version):
sys.exit(1)
if not validate(props):
sys.exit(1)

View file

@ -258,30 +258,20 @@ class PropListTestcase(unittest.TestCase):
props.put("ro.board.first_api_level","25")
# ro.board.first_api_level must be less than or equal to the sdk version
self.assertFalse(validate_and_add_grf_props(props, 20))
self.assertTrue(validate_and_add_grf_props(props, 26))
# ro.board.api_level is automatically set
self.assertEqual(props.get_value("ro.board.api_level"), "25")
self.assertFalse(validate_grf_props(props, 20))
self.assertTrue(validate_grf_props(props, 26))
self.assertTrue(validate_grf_props(props, 35))
props.get_all_props()[-1].make_as_comment()
self.assertTrue(validate_and_add_grf_props(props, 35))
# ro.board.api_level is automatically set to the required GRF version
self.assertEqual(props.get_value("ro.board.api_level"), "33")
props.get_all_props()[-1].make_as_comment()
# manually set ro.board.api_level to an invalid value
props.put("ro.board.api_level","20")
self.assertFalse(validate_and_add_grf_props(props, 26))
self.assertFalse(validate_grf_props(props, 26))
props.get_all_props()[-1].make_as_comment()
# manually set ro.board.api_level to a valid value
props.put("ro.board.api_level","26")
self.assertTrue(validate_and_add_grf_props(props, 26))
self.assertTrue(validate_grf_props(props, 26))
# ro.board.api_level must be less than or equal to the sdk version
self.assertFalse(validate_and_add_grf_props(props, 25))
# ro.board.api_level must be greater than or equal to the required GRF
# version
self.assertFalse(validate_and_add_grf_props(props, 30))
self.assertFalse(validate_grf_props(props, 25))
if __name__ == '__main__':
unittest.main(verbosity=2)