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 #ifndef IDMAP2_TESTS_R_H
18 #define IDMAP2_TESTS_R_H
19 
20 #include <idmap2/ResourceUtils.h>
21 
22 namespace android::idmap2 {
23 
hexify(ResourceId id)24 static std::string hexify(ResourceId id) {
25   std::stringstream stream;
26   stream << std::hex << static_cast<uint32_t>(id);
27   return stream.str();
28 }
29 
30 // clang-format off
31 namespace R::target {
32   namespace integer {
33     constexpr ResourceId int1 = 0x7f010000;
34 
35     namespace literal {
36       inline const std::string int1 = hexify(R::target::integer::int1);
37     }
38   }
39 
40   namespace string {
41     constexpr ResourceId not_overlayable = 0x7f020003;
42     constexpr ResourceId other = 0x7f020004;
43     constexpr ResourceId policy_actor = 0x7f020005;
44     constexpr ResourceId policy_odm = 0x7f020006;
45     constexpr ResourceId policy_oem = 0x7f020007;
46     constexpr ResourceId policy_product = 0x7f020008;
47     constexpr ResourceId policy_public = 0x7f020009;
48     constexpr ResourceId policy_signature = 0x7f02000a;
49     constexpr ResourceId policy_system = 0x7f02000b;
50     constexpr ResourceId policy_system_vendor = 0x7f02000c;
51     constexpr ResourceId str1 = 0x7f02000d;
52     constexpr ResourceId str3 = 0x7f02000f;
53     constexpr ResourceId str4 = 0x7f020010;
54 
55     namespace literal {
56       inline const std::string str1 = hexify(R::target::string::str1);
57       inline const std::string str3 = hexify(R::target::string::str3);
58       inline const std::string str4 = hexify(R::target::string::str4);
59     }
60   }
61 }
62 
63 namespace R::overlay {
64   namespace integer {
65     constexpr ResourceId int1 = 0x7f010000;
66   }
67   namespace string {
68     constexpr ResourceId str1 = 0x7f020000;
69     constexpr ResourceId str3 = 0x7f020001;
70     constexpr ResourceId str4 = 0x7f020002;
71   }
72 }
73 
74 namespace R::overlay_shared {
75   namespace integer {
76     constexpr ResourceId int1 = 0x00010000;
77   }
78   namespace string {
79     constexpr ResourceId str1 = 0x00020000;
80     constexpr ResourceId str3 = 0x00020001;
81     constexpr ResourceId str4 = 0x00020002;
82   }
83 }
84 
85 namespace R::system_overlay::string {
86   constexpr ResourceId policy_public = 0x7f010000;
87   constexpr ResourceId policy_system = 0x7f010001;
88   constexpr ResourceId policy_system_vendor = 0x7f010002;
89 }
90 
91 namespace R::system_overlay_invalid::string {
92   constexpr ResourceId not_overlayable = 0x7f010000;
93   constexpr ResourceId other = 0x7f010001;
94   constexpr ResourceId policy_actor = 0x7f010002;
95   constexpr ResourceId policy_odm = 0x7f010003;
96   constexpr ResourceId policy_oem = 0x7f010004;
97   constexpr ResourceId policy_product = 0x7f010005;
98   constexpr ResourceId policy_public = 0x7f010006;
99   constexpr ResourceId policy_signature = 0x7f010007;
100   constexpr ResourceId policy_system = 0x7f010008;
101   constexpr ResourceId policy_system_vendor = 0x7f010009;
102 };
103 // clang-format on
104 
105 }  // namespace android::idmap2
106 
107 #endif  // IDMAP2_TESTS_R_H
108