2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_CONFIGURATION_H
18 #define ANDROID_CONFIGURATION_H
20 #include <android/asset_manager.h>
26 struct AConfiguration;
27 typedef struct AConfiguration AConfiguration;
30 ACONFIGURATION_ORIENTATION_ANY = 0x0000,
31 ACONFIGURATION_ORIENTATION_PORT = 0x0001,
32 ACONFIGURATION_ORIENTATION_LAND = 0x0002,
33 ACONFIGURATION_ORIENTATION_SQUARE = 0x0003,
35 ACONFIGURATION_TOUCHSCREEN_ANY = 0x0000,
36 ACONFIGURATION_TOUCHSCREEN_NOTOUCH = 0x0001,
37 ACONFIGURATION_TOUCHSCREEN_STYLUS = 0x0002,
38 ACONFIGURATION_TOUCHSCREEN_FINGER = 0x0003,
40 ACONFIGURATION_DENSITY_DEFAULT = 0,
41 ACONFIGURATION_DENSITY_LOW = 120,
42 ACONFIGURATION_DENSITY_MEDIUM = 160,
43 ACONFIGURATION_DENSITY_TV = 213,
44 ACONFIGURATION_DENSITY_HIGH = 240,
45 ACONFIGURATION_DENSITY_XHIGH = 320,
46 ACONFIGURATION_DENSITY_XXHIGH = 480,
47 ACONFIGURATION_DENSITY_XXXHIGH = 640,
48 ACONFIGURATION_DENSITY_NONE = 0xffff,
50 ACONFIGURATION_KEYBOARD_ANY = 0x0000,
51 ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001,
52 ACONFIGURATION_KEYBOARD_QWERTY = 0x0002,
53 ACONFIGURATION_KEYBOARD_12KEY = 0x0003,
55 ACONFIGURATION_NAVIGATION_ANY = 0x0000,
56 ACONFIGURATION_NAVIGATION_NONAV = 0x0001,
57 ACONFIGURATION_NAVIGATION_DPAD = 0x0002,
58 ACONFIGURATION_NAVIGATION_TRACKBALL = 0x0003,
59 ACONFIGURATION_NAVIGATION_WHEEL = 0x0004,
61 ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000,
62 ACONFIGURATION_KEYSHIDDEN_NO = 0x0001,
63 ACONFIGURATION_KEYSHIDDEN_YES = 0x0002,
64 ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003,
66 ACONFIGURATION_NAVHIDDEN_ANY = 0x0000,
67 ACONFIGURATION_NAVHIDDEN_NO = 0x0001,
68 ACONFIGURATION_NAVHIDDEN_YES = 0x0002,
70 ACONFIGURATION_SCREENSIZE_ANY = 0x00,
71 ACONFIGURATION_SCREENSIZE_SMALL = 0x01,
72 ACONFIGURATION_SCREENSIZE_NORMAL = 0x02,
73 ACONFIGURATION_SCREENSIZE_LARGE = 0x03,
74 ACONFIGURATION_SCREENSIZE_XLARGE = 0x04,
76 ACONFIGURATION_SCREENLONG_ANY = 0x00,
77 ACONFIGURATION_SCREENLONG_NO = 0x1,
78 ACONFIGURATION_SCREENLONG_YES = 0x2,
80 ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00,
81 ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01,
82 ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02,
83 ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03,
84 ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04,
85 ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05,
87 ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00,
88 ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
89 ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
91 ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
93 ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
95 ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
97 ACONFIGURATION_LAYOUTDIR_ANY = 0x00,
98 ACONFIGURATION_LAYOUTDIR_LTR = 0x01,
99 ACONFIGURATION_LAYOUTDIR_RTL = 0x02,
101 ACONFIGURATION_MCC = 0x0001,
102 ACONFIGURATION_MNC = 0x0002,
103 ACONFIGURATION_LOCALE = 0x0004,
104 ACONFIGURATION_TOUCHSCREEN = 0x0008,
105 ACONFIGURATION_KEYBOARD = 0x0010,
106 ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020,
107 ACONFIGURATION_NAVIGATION = 0x0040,
108 ACONFIGURATION_ORIENTATION = 0x0080,
109 ACONFIGURATION_DENSITY = 0x0100,
110 ACONFIGURATION_SCREEN_SIZE = 0x0200,
111 ACONFIGURATION_VERSION = 0x0400,
112 ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
113 ACONFIGURATION_UI_MODE = 0x1000,
114 ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
115 ACONFIGURATION_LAYOUTDIR = 0x4000,
117 ACONFIGURATION_MNC_ZERO = 0xffff,
121 * Create a new AConfiguration, initialized with no values set.
123 AConfiguration* AConfiguration_new();
126 * Free an AConfiguration that was previously created with
127 * AConfiguration_new().
129 void AConfiguration_delete(AConfiguration* config);
132 * Create and return a new AConfiguration based on the current configuration in
133 * use in the given AssetManager.
135 void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am);
138 * Copy the contents of 'src' to 'dest'.
140 void AConfiguration_copy(AConfiguration* dest, AConfiguration* src);
143 * Return the current MCC set in the configuration. 0 if not set.
145 int32_t AConfiguration_getMcc(AConfiguration* config);
148 * Set the current MCC in the configuration. 0 to clear.
150 void AConfiguration_setMcc(AConfiguration* config, int32_t mcc);
153 * Return the current MNC set in the configuration. 0 if not set.
155 int32_t AConfiguration_getMnc(AConfiguration* config);
158 * Set the current MNC in the configuration. 0 to clear.
160 void AConfiguration_setMnc(AConfiguration* config, int32_t mnc);
163 * Return the current language code set in the configuration. The output will
164 * be filled with an array of two characters. They are not 0-terminated. If
165 * a language is not set, they will be 0.
167 void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage);
170 * Set the current language code in the configuration, from the first two
171 * characters in the string.
173 void AConfiguration_setLanguage(AConfiguration* config, const char* language);
176 * Return the current country code set in the configuration. The output will
177 * be filled with an array of two characters. They are not 0-terminated. If
178 * a country is not set, they will be 0.
180 void AConfiguration_getCountry(AConfiguration* config, char* outCountry);
183 * Set the current country code in the configuration, from the first two
184 * characters in the string.
186 void AConfiguration_setCountry(AConfiguration* config, const char* country);
189 * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration.
191 int32_t AConfiguration_getOrientation(AConfiguration* config);
194 * Set the current orientation in the configuration.
196 void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation);
199 * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration.
201 int32_t AConfiguration_getTouchscreen(AConfiguration* config);
204 * Set the current touchscreen in the configuration.
206 void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen);
209 * Return the current ACONFIGURATION_DENSITY_* set in the configuration.
211 int32_t AConfiguration_getDensity(AConfiguration* config);
214 * Set the current density in the configuration.
216 void AConfiguration_setDensity(AConfiguration* config, int32_t density);
219 * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration.
221 int32_t AConfiguration_getKeyboard(AConfiguration* config);
224 * Set the current keyboard in the configuration.
226 void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard);
229 * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration.
231 int32_t AConfiguration_getNavigation(AConfiguration* config);
234 * Set the current navigation in the configuration.
236 void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation);
239 * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration.
241 int32_t AConfiguration_getKeysHidden(AConfiguration* config);
244 * Set the current keys hidden in the configuration.
246 void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden);
249 * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration.
251 int32_t AConfiguration_getNavHidden(AConfiguration* config);
254 * Set the current nav hidden in the configuration.
256 void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden);
259 * Return the current SDK (API) version set in the configuration.
261 int32_t AConfiguration_getSdkVersion(AConfiguration* config);
264 * Set the current SDK version in the configuration.
266 void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion);
269 * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration.
271 int32_t AConfiguration_getScreenSize(AConfiguration* config);
274 * Set the current screen size in the configuration.
276 void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize);
279 * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration.
281 int32_t AConfiguration_getScreenLong(AConfiguration* config);
284 * Set the current screen long in the configuration.
286 void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong);
289 * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration.
291 int32_t AConfiguration_getUiModeType(AConfiguration* config);
294 * Set the current UI mode type in the configuration.
296 void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType);
299 * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration.
301 int32_t AConfiguration_getUiModeNight(AConfiguration* config);
304 * Set the current UI mode night in the configuration.
306 void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
309 * Return the current configuration screen width in dp units, or
310 * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
312 int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
315 * Set the configuration's current screen width in dp units.
317 void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
320 * Return the current configuration screen height in dp units, or
321 * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
323 int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
326 * Set the configuration's current screen width in dp units.
328 void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
331 * Return the configuration's smallest screen width in dp units, or
332 * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
334 int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
337 * Set the configuration's smallest screen width in dp units.
339 void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
342 * Return the configuration's layout direction, or
343 * ACONFIGURATION_LAYOUTDIR_ANY if not set.
345 int32_t AConfiguration_getLayoutDirection(AConfiguration* config);
348 * Set the configuration's layout direction.
350 void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value);
353 * Perform a diff between two configurations. Returns a bit mask of
354 * ACONFIGURATION_* constants, each bit set meaning that configuration element
355 * is different between them.
357 int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2);
360 * Determine whether 'base' is a valid configuration for use within the
361 * environment 'requested'. Returns 0 if there are any values in 'base'
362 * that conflict with 'requested'. Returns 1 if it does not conflict.
364 int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested);
367 * Determine whether the configuration in 'test' is better than the existing
368 * configuration in 'base'. If 'requested' is non-NULL, this decision is based
369 * on the overall configuration given there. If it is NULL, this decision is
370 * simply based on which configuration is more specific. Returns non-0 if
371 * 'test' is better than 'base'.
373 * This assumes you have already filtered the configurations with
374 * AConfiguration_match().
376 int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test,
377 AConfiguration* requested);
383 #endif // ANDROID_CONFIGURATION_H