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