Use BOARD_API_LEVEL to define ro.board.api_level
GRF devices must define the API level of which the SoC is first
shipped by setting BOARD_SHIPPING_API_LEVEL. As this is a permanent
value, vendors may not change this value even if they implement new
features under the GRF policy.
BOARD_API_LEVEL can be optionally defined in this case to manually
set the api level of the vendor implementation.
The current api level will be set to `ro.board.api_level` property.
Bug: 176950752
Test: atest --host post_process_props_unittest
Change-Id: Ib126c1a622ded9848650f3f60c0f15005867272d
diff --git a/tools/test_post_process_props.py b/tools/test_post_process_props.py
index 12d52e5..dd5f8ec 100644
--- a/tools/test_post_process_props.py
+++ b/tools/test_post_process_props.py
@@ -53,7 +53,7 @@
p.make_as_comment()
self.assertTrue(p.is_comment())
- self.assertTrue("# a comment\n#a=b", str(p))
+ self.assertEqual("# a comment\n#a=b", str(p))
class PropListTestcase(unittest.TestCase):
def setUp(self):
@@ -251,5 +251,37 @@
# because it's explicitly allowed
self.assertTrue(override_optional_props(props, allow_dup=True))
+ def test_validateGrfProps(self):
+ stderr_redirect = io.StringIO()
+ with contextlib.redirect_stderr(stderr_redirect):
+ props = PropList("hello")
+ 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")
+
+ 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))
+
+ 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))
+ # 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))
+
if __name__ == '__main__':
unittest.main(verbosity=2)