1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <string> 18 #include <vector> 19 20 #include "Result.h" 21 #include "androidfw/ResourceTypes.h" 22 #include "androidfw/StringPiece.h" 23 24 #ifndef IDMAP2_INCLUDE_IDMAP2_POLICIES_H_ 25 #define IDMAP2_INCLUDE_IDMAP2_POLICIES_H_ 26 27 namespace android::idmap2 { 28 29 constexpr const char* kPolicyOdm = "odm"; 30 constexpr const char* kPolicyOem = "oem"; 31 constexpr const char* kPolicyProduct = "product"; 32 constexpr const char* kPolicyPublic = "public"; 33 constexpr const char* kPolicySignature = "signature"; 34 constexpr const char* kPolicySystem = "system"; 35 constexpr const char* kPolicyVendor = "vendor"; 36 37 using PolicyFlags = ResTable_overlayable_policy_header::PolicyFlags; 38 using PolicyBitmask = uint32_t; 39 40 // Parses the string representations of policies into a bitmask. 41 Result<PolicyBitmask> PoliciesToBitmask(const std::vector<std::string>& policies); 42 43 // Retrieves the string representations of policies in the bitmask. 44 std::vector<std::string> BitmaskToPolicies(const PolicyBitmask& bitmask); 45 46 } // namespace android::idmap2 47 48 #endif // IDMAP2_INCLUDE_IDMAP2_POLICIES_H_ 49