Blacklist @TestApis by default.

If the signature has @UnsupportedAppUsage or @SystemApi annotation as well, those take precedence and the API would either be whitelisted or greylisted accordingly. All other, "pure" @TestApi signatures would be blacklisted and only allowed access in instrumented processes.

Test: manual
Bug: 133832325
Change-Id: I4684929caed8be7c42c91fed33ddd2a3b67ae19b
This commit is contained in:
Artur Satayev
2019-10-31 12:12:00 +00:00
parent 1695301cc9
commit 44036a7689
2 changed files with 13 additions and 7 deletions

View File

@@ -241,8 +241,6 @@ class FlagsDict:
flags = csv[1:]
if (FLAG_PUBLIC_API in flags) or (FLAG_SYSTEM_API in flags):
flags.append(FLAG_WHITELIST)
elif FLAG_TEST_API in flags:
flags.append(FLAG_GREYLIST)
self._dict[csv[0]].update(flags)
def assign_flag(self, flag, apis, source="<unknown>"):

View File

@@ -53,14 +53,22 @@ class TestHiddenapiListGeneration(unittest.TestCase):
# Test new additions.
flags.parse_and_merge_csv([
'A,' + FLAG_GREYLIST,
'B,' + FLAG_BLACKLIST + ',' + FLAG_GREYLIST_MAX_O ])
self.assertEqual(flags.generate_csv(),
[ 'A,' + FLAG_GREYLIST,
'B,' + FLAG_BLACKLIST + "," + FLAG_GREYLIST_MAX_O ])
'B,' + FLAG_BLACKLIST + ',' + FLAG_GREYLIST_MAX_O,
'C,' + FLAG_SYSTEM_API + ',' + FLAG_WHITELIST,
'D,' + FLAG_GREYLIST+ ',' + FLAG_TEST_API,
'E,' + FLAG_BLACKLIST+ ',' + FLAG_TEST_API,
])
self.assertEqual(flags.generate_csv(), [
'A,' + FLAG_GREYLIST,
'B,' + FLAG_BLACKLIST + "," + FLAG_GREYLIST_MAX_O,
'C,' + FLAG_SYSTEM_API + ',' + FLAG_WHITELIST,
'D,' + FLAG_GREYLIST+ ',' + FLAG_TEST_API,
'E,' + FLAG_BLACKLIST+ ',' + FLAG_TEST_API,
])
# Test unknown flag.
with self.assertRaises(AssertionError):
flags.parse_and_merge_csv([ 'C,foo' ])
flags.parse_and_merge_csv([ 'Z,foo' ])
def test_assign_flag(self):
flags = FlagsDict()