Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44036a76 authored by Artur Satayev's avatar Artur Satayev
Browse files

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
parent 1695301c
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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>"):
+13 −5
Original line number Diff line number Diff line
@@ -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()