| Adam Lesinski | fab5087 | 2014-04-16 14:40:42 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 | */ | 
|  | 28 | namespace 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 | */ | 
|  | 37 | bool 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 | */ | 
|  | 45 | bool 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 | */ | 
|  | 52 | void applyVersionForCompatibility(ConfigDescription* config); | 
|  | 53 |  | 
|  | 54 | // Individual axis | 
|  | 55 | bool parseMcc(const char* str, android::ResTable_config* out = NULL); | 
|  | 56 | bool parseMnc(const char* str, android::ResTable_config* out = NULL); | 
|  | 57 | bool parseLayoutDirection(const char* str, android::ResTable_config* out = NULL); | 
|  | 58 | bool parseSmallestScreenWidthDp(const char* str, android::ResTable_config* out = NULL); | 
|  | 59 | bool parseScreenWidthDp(const char* str, android::ResTable_config* out = NULL); | 
|  | 60 | bool parseScreenHeightDp(const char* str, android::ResTable_config* out = NULL); | 
|  | 61 | bool parseScreenLayoutSize(const char* str, android::ResTable_config* out = NULL); | 
|  | 62 | bool parseScreenLayoutLong(const char* str, android::ResTable_config* out = NULL); | 
| Adam Lesinski | 2738c96 | 2015-05-14 14:25:36 -0700 | [diff] [blame] | 63 | bool parseScreenRound(const char* name, android::ResTable_config* out = NULL); | 
| Romain Guy | c9ba559 | 2017-01-18 16:34:42 -0800 | [diff] [blame] | 64 | bool parseWideColorGamut(const char* name, android::ResTable_config* out = NULL); | 
|  | 65 | bool parseHdr(const char* name, android::ResTable_config* out = NULL); | 
| Adam Lesinski | fab5087 | 2014-04-16 14:40:42 -0700 | [diff] [blame] | 66 | bool parseOrientation(const char* str, android::ResTable_config* out = NULL); | 
|  | 67 | bool parseUiModeType(const char* str, android::ResTable_config* out = NULL); | 
|  | 68 | bool parseUiModeNight(const char* str, android::ResTable_config* out = NULL); | 
|  | 69 | bool parseDensity(const char* str, android::ResTable_config* out = NULL); | 
|  | 70 | bool parseTouchscreen(const char* str, android::ResTable_config* out = NULL); | 
|  | 71 | bool parseKeysHidden(const char* str, android::ResTable_config* out = NULL); | 
|  | 72 | bool parseKeyboard(const char* str, android::ResTable_config* out = NULL); | 
|  | 73 | bool parseNavHidden(const char* str, android::ResTable_config* out = NULL); | 
|  | 74 | bool parseNavigation(const char* str, android::ResTable_config* out = NULL); | 
|  | 75 | bool parseScreenSize(const char* str, android::ResTable_config* out = NULL); | 
|  | 76 | bool parseVersion(const char* str, android::ResTable_config* out = NULL); | 
|  | 77 |  | 
|  | 78 | android::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 | */ | 
|  | 84 | bool isSameExcept(const android::ResTable_config& a, const android::ResTable_config& b, int configMask); | 
|  | 85 |  | 
| Adam Lesinski | de7de47 | 2014-11-03 12:03:08 -0800 | [diff] [blame] | 86 | /** | 
|  | 87 | * Returns true if the configuration only has the density specified. In the case | 
|  | 88 | * of 'anydpi', the version is ignored. | 
|  | 89 | */ | 
|  | 90 | bool isDensityOnly(const android::ResTable_config& config); | 
|  | 91 |  | 
| Adam Lesinski | fab5087 | 2014-04-16 14:40:42 -0700 | [diff] [blame] | 92 | } // namespace AaptConfig | 
|  | 93 |  | 
|  | 94 | #endif // __AAPT_CONFIG_H |