xref: /aosp_15_r20/frameworks/base/tools/aapt/AaptConfig.h (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1*d57664e9SAndroid Build Coastguard Worker /*
2*d57664e9SAndroid Build Coastguard Worker  * Copyright (C) 2014 The Android Open Source Project
3*d57664e9SAndroid Build Coastguard Worker  *
4*d57664e9SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*d57664e9SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*d57664e9SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*d57664e9SAndroid Build Coastguard Worker  *
8*d57664e9SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*d57664e9SAndroid Build Coastguard Worker  *
10*d57664e9SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*d57664e9SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*d57664e9SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*d57664e9SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*d57664e9SAndroid Build Coastguard Worker  * limitations under the License.
15*d57664e9SAndroid Build Coastguard Worker  */
16*d57664e9SAndroid Build Coastguard Worker 
17*d57664e9SAndroid Build Coastguard Worker #ifndef __AAPT_CONFIG_H
18*d57664e9SAndroid Build Coastguard Worker #define __AAPT_CONFIG_H
19*d57664e9SAndroid Build Coastguard Worker 
20*d57664e9SAndroid Build Coastguard Worker #include <set>
21*d57664e9SAndroid Build Coastguard Worker #include <utils/String8.h>
22*d57664e9SAndroid Build Coastguard Worker 
23*d57664e9SAndroid Build Coastguard Worker #include "ConfigDescription.h"
24*d57664e9SAndroid Build Coastguard Worker 
25*d57664e9SAndroid Build Coastguard Worker /**
26*d57664e9SAndroid Build Coastguard Worker  * Utility methods for dealing with configurations.
27*d57664e9SAndroid Build Coastguard Worker  */
28*d57664e9SAndroid Build Coastguard Worker namespace AaptConfig {
29*d57664e9SAndroid Build Coastguard Worker 
30*d57664e9SAndroid Build Coastguard Worker /**
31*d57664e9SAndroid Build Coastguard Worker  * Parse a string of the form 'fr-sw600dp-land' and fill in the
32*d57664e9SAndroid Build Coastguard Worker  * given ResTable_config with resulting configuration parameters.
33*d57664e9SAndroid Build Coastguard Worker  *
34*d57664e9SAndroid Build Coastguard Worker  * The resulting configuration has the appropriate sdkVersion defined
35*d57664e9SAndroid Build Coastguard Worker  * for backwards compatibility.
36*d57664e9SAndroid Build Coastguard Worker  */
37*d57664e9SAndroid Build Coastguard Worker bool parse(const android::String8& str, ConfigDescription* out = NULL);
38*d57664e9SAndroid Build Coastguard Worker 
39*d57664e9SAndroid Build Coastguard Worker /**
40*d57664e9SAndroid Build Coastguard Worker  * Parse a comma separated list of configuration strings. Duplicate configurations
41*d57664e9SAndroid Build Coastguard Worker  * will be removed.
42*d57664e9SAndroid Build Coastguard Worker  *
43*d57664e9SAndroid Build Coastguard Worker  * Example input: "fr,de-land,fr-sw600dp-land"
44*d57664e9SAndroid Build Coastguard Worker  */
45*d57664e9SAndroid Build Coastguard Worker bool parseCommaSeparatedList(const android::String8& str, std::set<ConfigDescription>* outSet);
46*d57664e9SAndroid Build Coastguard Worker 
47*d57664e9SAndroid Build Coastguard Worker /**
48*d57664e9SAndroid Build Coastguard Worker  * If the configuration uses an axis that was added after
49*d57664e9SAndroid Build Coastguard Worker  * the original Android release, make sure the SDK version
50*d57664e9SAndroid Build Coastguard Worker  * is set accordingly.
51*d57664e9SAndroid Build Coastguard Worker  */
52*d57664e9SAndroid Build Coastguard Worker void applyVersionForCompatibility(ConfigDescription* config);
53*d57664e9SAndroid Build Coastguard Worker 
54*d57664e9SAndroid Build Coastguard Worker // Individual axis
55*d57664e9SAndroid Build Coastguard Worker bool parseMcc(const char* str, android::ResTable_config* out = NULL);
56*d57664e9SAndroid Build Coastguard Worker bool parseMnc(const char* str, android::ResTable_config* out = NULL);
57*d57664e9SAndroid Build Coastguard Worker bool parseLayoutDirection(const char* str, android::ResTable_config* out = NULL);
58*d57664e9SAndroid Build Coastguard Worker bool parseSmallestScreenWidthDp(const char* str, android::ResTable_config* out = NULL);
59*d57664e9SAndroid Build Coastguard Worker bool parseScreenWidthDp(const char* str, android::ResTable_config* out = NULL);
60*d57664e9SAndroid Build Coastguard Worker bool parseScreenHeightDp(const char* str, android::ResTable_config* out = NULL);
61*d57664e9SAndroid Build Coastguard Worker bool parseScreenLayoutSize(const char* str, android::ResTable_config* out = NULL);
62*d57664e9SAndroid Build Coastguard Worker bool parseScreenLayoutLong(const char* str, android::ResTable_config* out = NULL);
63*d57664e9SAndroid Build Coastguard Worker bool parseScreenRound(const char* name, android::ResTable_config* out = NULL);
64*d57664e9SAndroid Build Coastguard Worker bool parseWideColorGamut(const char* name, android::ResTable_config* out = NULL);
65*d57664e9SAndroid Build Coastguard Worker bool parseHdr(const char* name, android::ResTable_config* out = NULL);
66*d57664e9SAndroid Build Coastguard Worker bool parseOrientation(const char* str, android::ResTable_config* out = NULL);
67*d57664e9SAndroid Build Coastguard Worker bool parseUiModeType(const char* str, android::ResTable_config* out = NULL);
68*d57664e9SAndroid Build Coastguard Worker bool parseUiModeNight(const char* str, android::ResTable_config* out = NULL);
69*d57664e9SAndroid Build Coastguard Worker bool parseDensity(const char* str, android::ResTable_config* out = NULL);
70*d57664e9SAndroid Build Coastguard Worker bool parseTouchscreen(const char* str, android::ResTable_config* out = NULL);
71*d57664e9SAndroid Build Coastguard Worker bool parseKeysHidden(const char* str, android::ResTable_config* out = NULL);
72*d57664e9SAndroid Build Coastguard Worker bool parseKeyboard(const char* str, android::ResTable_config* out = NULL);
73*d57664e9SAndroid Build Coastguard Worker bool parseNavHidden(const char* str, android::ResTable_config* out = NULL);
74*d57664e9SAndroid Build Coastguard Worker bool parseNavigation(const char* str, android::ResTable_config* out = NULL);
75*d57664e9SAndroid Build Coastguard Worker bool parseScreenSize(const char* str, android::ResTable_config* out = NULL);
76*d57664e9SAndroid Build Coastguard Worker bool parseVersion(const char* str, android::ResTable_config* out = NULL);
77*d57664e9SAndroid Build Coastguard Worker 
78*d57664e9SAndroid Build Coastguard Worker android::String8 getVersion(const android::ResTable_config& config);
79*d57664e9SAndroid Build Coastguard Worker 
80*d57664e9SAndroid Build Coastguard Worker /**
81*d57664e9SAndroid Build Coastguard Worker  * Returns true if the two configurations only differ by the specified axis.
82*d57664e9SAndroid Build Coastguard Worker  * The axis mask is a bitmask of CONFIG_* constants.
83*d57664e9SAndroid Build Coastguard Worker  */
84*d57664e9SAndroid Build Coastguard Worker bool isSameExcept(const android::ResTable_config& a, const android::ResTable_config& b, int configMask);
85*d57664e9SAndroid Build Coastguard Worker 
86*d57664e9SAndroid Build Coastguard Worker /**
87*d57664e9SAndroid Build Coastguard Worker  * Returns true if the configuration only has the density specified. In the case
88*d57664e9SAndroid Build Coastguard Worker  * of 'anydpi', the version is ignored.
89*d57664e9SAndroid Build Coastguard Worker  */
90*d57664e9SAndroid Build Coastguard Worker bool isDensityOnly(const android::ResTable_config& config);
91*d57664e9SAndroid Build Coastguard Worker 
92*d57664e9SAndroid Build Coastguard Worker } // namespace AaptConfig
93*d57664e9SAndroid Build Coastguard Worker 
94*d57664e9SAndroid Build Coastguard Worker #endif // __AAPT_CONFIG_H
95