hiddenapi: Support 'core-platform-api' flag
Add support for parsing @CorePlatformApi stubs and encoding it in
hiddenapi dex flags of the corresponding fields/methods.
(1) The CL refactors hiddenapi::ApiList class to store a second value:
a bit vector of "domain API" flags. These are intended for encoding
membership in a set of API stubs only available to certain callers,
e.g. @CorePlatformApi when platform code calls core platform or
@TestApi for CTS tests.
(2) Parse @CorePlatformApi stubs and set domain flags for its members.
(3) Parse the flags at runtime and set kAccCorePlatformApi access flag
on the corresponding ArtField/ArtMethod objects.
Bug: 119068555
Test: m appcompat
Test: dexlayout -b <core-oj jar> | grep 'CORE-PLATFORM-API'
Change-Id: Idbfa6d3af7459258a5a0b6da7c03c037a577eb75
diff --git a/tools/veridex/hidden_api.cc b/tools/veridex/hidden_api.cc
index 2af7b50..1dae93a 100644
--- a/tools/veridex/hidden_api.cc
+++ b/tools/veridex/hidden_api.cc
@@ -30,13 +30,12 @@
std::ifstream in(filename);
for (std::string str; std::getline(in, str);) {
std::vector<std::string> values = android::base::Split(str, ",");
- CHECK_EQ(values.size(), 2u) << "Currently only signature and one flag are supported";
-
const std::string& signature = values[0];
- const std::string& flag_str = values[1];
- hiddenapi::ApiList membership = hiddenapi::ApiList::FromName(flag_str);
- CHECK(membership.IsValid()) << "Unknown ApiList name: " << flag_str;
+ hiddenapi::ApiList membership;
+ bool success = hiddenapi::ApiList::FromNames(values.begin() + 1, values.end(), &membership);
+ CHECK(success) << "Unknown ApiList flag: " << str;
+ CHECK(membership.IsValid()) << "Invalid ApiList: " << membership;
if (sdk_uses_only != (membership == hiddenapi::ApiList::Whitelist())) {
// Either we want only SDK uses and this is not a whitelist entry,