blob: a6dd252281f5623ccca5f964151c433fe543ca49 [file] [log] [blame]
Adam Lesinskifab50872014-04-16 14:40:42 -07001/*
2 * Copyright (C) 2014 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 __AAPT_CONFIG_H
18#define __AAPT_CONFIG_H
19
20#include <set>
21#include <utils/String8.h>
22
23#include "ConfigDescription.h"
24
25/**
26 * Utility methods for dealing with configurations.
27 */
28namespace AaptConfig {
29
30/**
31 * Parse a string of the form 'fr-sw600dp-land' and fill in the
32 * given ResTable_config with resulting configuration parameters.
33 *
34 * The resulting configuration has the appropriate sdkVersion defined
35 * for backwards compatibility.
36 */
37bool parse(const android::String8& str, ConfigDescription* out = NULL);
38
39/**
40 * Parse a comma separated list of configuration strings. Duplicate configurations
41 * will be removed.
42 *
43 * Example input: "fr,de-land,fr-sw600dp-land"
44 */
45bool parseCommaSeparatedList(const android::String8& str, std::set<ConfigDescription>* outSet);
46
47/**
48 * If the configuration uses an axis that was added after
49 * the original Android release, make sure the SDK version
50 * is set accordingly.
51 */
52void applyVersionForCompatibility(ConfigDescription* config);
53
54// Individual axis
55bool parseMcc(const char* str, android::ResTable_config* out = NULL);
56bool parseMnc(const char* str, android::ResTable_config* out = NULL);
57bool parseLayoutDirection(const char* str, android::ResTable_config* out = NULL);
58bool parseSmallestScreenWidthDp(const char* str, android::ResTable_config* out = NULL);
59bool parseScreenWidthDp(const char* str, android::ResTable_config* out = NULL);
60bool parseScreenHeightDp(const char* str, android::ResTable_config* out = NULL);
61bool parseScreenLayoutSize(const char* str, android::ResTable_config* out = NULL);
62bool parseScreenLayoutLong(const char* str, android::ResTable_config* out = NULL);
Adam Lesinski2738c962015-05-14 14:25:36 -070063bool parseScreenRound(const char* name, android::ResTable_config* out = NULL);
Romain Guyc9ba5592017-01-18 16:34:42 -080064bool parseWideColorGamut(const char* name, android::ResTable_config* out = NULL);
65bool parseHdr(const char* name, android::ResTable_config* out = NULL);
Adam Lesinskifab50872014-04-16 14:40:42 -070066bool parseOrientation(const char* str, android::ResTable_config* out = NULL);
67bool parseUiModeType(const char* str, android::ResTable_config* out = NULL);
68bool parseUiModeNight(const char* str, android::ResTable_config* out = NULL);
69bool parseDensity(const char* str, android::ResTable_config* out = NULL);
70bool parseTouchscreen(const char* str, android::ResTable_config* out = NULL);
71bool parseKeysHidden(const char* str, android::ResTable_config* out = NULL);
72bool parseKeyboard(const char* str, android::ResTable_config* out = NULL);
73bool parseNavHidden(const char* str, android::ResTable_config* out = NULL);
74bool parseNavigation(const char* str, android::ResTable_config* out = NULL);
75bool parseScreenSize(const char* str, android::ResTable_config* out = NULL);
76bool parseVersion(const char* str, android::ResTable_config* out = NULL);
77
78android::String8 getVersion(const android::ResTable_config& config);
79
80/**
81 * Returns true if the two configurations only differ by the specified axis.
82 * The axis mask is a bitmask of CONFIG_* constants.
83 */
84bool isSameExcept(const android::ResTable_config& a, const android::ResTable_config& b, int configMask);
85
Adam Lesinskide7de472014-11-03 12:03:08 -080086/**
87 * Returns true if the configuration only has the density specified. In the case
88 * of 'anydpi', the version is ignored.
89 */
90bool isDensityOnly(const android::ResTable_config& config);
91
Adam Lesinskifab50872014-04-16 14:40:42 -070092} // namespace AaptConfig
93
94#endif // __AAPT_CONFIG_H