blob: 4d683fbe1db65a77d23032426950bb186673e3cf [file] [log] [blame]
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -07001/*
2 * Copyright (C) 2010 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 ANDROID_CONFIGURATION_H
18#define ANDROID_CONFIGURATION_H
19
20#include <android/asset_manager.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26struct AConfiguration;
27typedef struct AConfiguration AConfiguration;
28
29enum {
30 ACONFIGURATION_ORIENTATION_ANY = 0x0000,
31 ACONFIGURATION_ORIENTATION_PORT = 0x0001,
32 ACONFIGURATION_ORIENTATION_LAND = 0x0002,
33 ACONFIGURATION_ORIENTATION_SQUARE = 0x0003,
34
35 ACONFIGURATION_TOUCHSCREEN_ANY = 0x0000,
36 ACONFIGURATION_TOUCHSCREEN_NOTOUCH = 0x0001,
37 ACONFIGURATION_TOUCHSCREEN_STYLUS = 0x0002,
38 ACONFIGURATION_TOUCHSCREEN_FINGER = 0x0003,
39
40 ACONFIGURATION_DENSITY_DEFAULT = 0,
41 ACONFIGURATION_DENSITY_LOW = 120,
42 ACONFIGURATION_DENSITY_MEDIUM = 160,
Dianne Hackbornb96cbbd2011-05-27 13:40:26 -070043 ACONFIGURATION_DENSITY_TV = 213,
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -070044 ACONFIGURATION_DENSITY_HIGH = 240,
45 ACONFIGURATION_DENSITY_NONE = 0xffff,
46
47 ACONFIGURATION_KEYBOARD_ANY = 0x0000,
48 ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001,
49 ACONFIGURATION_KEYBOARD_QWERTY = 0x0002,
50 ACONFIGURATION_KEYBOARD_12KEY = 0x0003,
51
52 ACONFIGURATION_NAVIGATION_ANY = 0x0000,
53 ACONFIGURATION_NAVIGATION_NONAV = 0x0001,
54 ACONFIGURATION_NAVIGATION_DPAD = 0x0002,
55 ACONFIGURATION_NAVIGATION_TRACKBALL = 0x0003,
56 ACONFIGURATION_NAVIGATION_WHEEL = 0x0004,
57
58 ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000,
59 ACONFIGURATION_KEYSHIDDEN_NO = 0x0001,
60 ACONFIGURATION_KEYSHIDDEN_YES = 0x0002,
61 ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003,
62
63 ACONFIGURATION_NAVHIDDEN_ANY = 0x0000,
64 ACONFIGURATION_NAVHIDDEN_NO = 0x0001,
65 ACONFIGURATION_NAVHIDDEN_YES = 0x0002,
66
67 ACONFIGURATION_SCREENSIZE_ANY = 0x00,
68 ACONFIGURATION_SCREENSIZE_SMALL = 0x01,
69 ACONFIGURATION_SCREENSIZE_NORMAL = 0x02,
70 ACONFIGURATION_SCREENSIZE_LARGE = 0x03,
71 ACONFIGURATION_SCREENSIZE_XLARGE = 0x04,
72
73 ACONFIGURATION_SCREENLONG_ANY = 0x00,
74 ACONFIGURATION_SCREENLONG_NO = 0x1,
75 ACONFIGURATION_SCREENLONG_YES = 0x2,
76
77 ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00,
78 ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01,
79 ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02,
80 ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03,
Dianne Hackborne360bb62011-05-20 16:11:04 -070081 ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04,
Joe Onorato44fcb832011-12-14 20:59:30 -080082 ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05,
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -070083
84 ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00,
Tobias Haamel2b9785a2010-09-30 10:57:24 +020085 ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
86 ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -070087
Dianne Hackborn69cb8752011-05-19 18:13:32 -070088 ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
89
90 ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
91
92 ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
93
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -070094 ACONFIGURATION_MCC = 0x0001,
95 ACONFIGURATION_MNC = 0x0002,
96 ACONFIGURATION_LOCALE = 0x0004,
97 ACONFIGURATION_TOUCHSCREEN = 0x0008,
98 ACONFIGURATION_KEYBOARD = 0x0010,
99 ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020,
100 ACONFIGURATION_NAVIGATION = 0x0040,
101 ACONFIGURATION_ORIENTATION = 0x0080,
102 ACONFIGURATION_DENSITY = 0x0100,
103 ACONFIGURATION_SCREEN_SIZE = 0x0200,
104 ACONFIGURATION_VERSION = 0x0400,
105 ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
106 ACONFIGURATION_UI_MODE = 0x1000,
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700107 ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -0700108};
109
110/**
111 * Create a new AConfiguration, initialized with no values set.
112 */
113AConfiguration* AConfiguration_new();
114
115/**
116 * Free an AConfiguration that was previously created with
117 * AConfiguration_new().
118 */
119void AConfiguration_delete(AConfiguration* config);
120
121/**
122 * Create and return a new AConfiguration based on the current configuration in
123 * use in the given AssetManager.
124 */
125void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am);
126
127/**
128 * Copy the contents of 'src' to 'dest'.
129 */
130void AConfiguration_copy(AConfiguration* dest, AConfiguration* src);
131
132/**
133 * Return the current MCC set in the configuration. 0 if not set.
134 */
135int32_t AConfiguration_getMcc(AConfiguration* config);
136
137/**
138 * Set the current MCC in the configuration. 0 to clear.
139 */
140void AConfiguration_setMcc(AConfiguration* config, int32_t mcc);
141
142/**
143 * Return the current MNC set in the configuration. 0 if not set.
144 */
145int32_t AConfiguration_getMnc(AConfiguration* config);
146
147/**
148 * Set the current MNC in the configuration. 0 to clear.
149 */
150void AConfiguration_setMnc(AConfiguration* config, int32_t mnc);
151
152/**
153 * Return the current language code set in the configuration. The output will
154 * be filled with an array of two characters. They are not 0-terminated. If
155 * a language is not set, they will be 0.
156 */
157void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage);
158
159/**
160 * Set the current language code in the configuration, from the first two
161 * characters in the string.
162 */
163void AConfiguration_setLanguage(AConfiguration* config, const char* language);
164
165/**
166 * Return the current country code set in the configuration. The output will
167 * be filled with an array of two characters. They are not 0-terminated. If
168 * a country is not set, they will be 0.
169 */
170void AConfiguration_getCountry(AConfiguration* config, char* outCountry);
171
172/**
173 * Set the current country code in the configuration, from the first two
174 * characters in the string.
175 */
176void AConfiguration_setCountry(AConfiguration* config, const char* country);
177
178/**
179 * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration.
180 */
181int32_t AConfiguration_getOrientation(AConfiguration* config);
182
183/**
184 * Set the current orientation in the configuration.
185 */
186void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation);
187
188/**
189 * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration.
190 */
191int32_t AConfiguration_getTouchscreen(AConfiguration* config);
192
193/**
194 * Set the current touchscreen in the configuration.
195 */
196void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen);
197
198/**
199 * Return the current ACONFIGURATION_DENSITY_* set in the configuration.
200 */
201int32_t AConfiguration_getDensity(AConfiguration* config);
202
203/**
204 * Set the current density in the configuration.
205 */
206void AConfiguration_setDensity(AConfiguration* config, int32_t density);
207
208/**
209 * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration.
210 */
211int32_t AConfiguration_getKeyboard(AConfiguration* config);
212
213/**
214 * Set the current keyboard in the configuration.
215 */
216void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard);
217
218/**
219 * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration.
220 */
221int32_t AConfiguration_getNavigation(AConfiguration* config);
222
223/**
224 * Set the current navigation in the configuration.
225 */
226void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation);
227
228/**
229 * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration.
230 */
231int32_t AConfiguration_getKeysHidden(AConfiguration* config);
232
233/**
234 * Set the current keys hidden in the configuration.
235 */
236void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden);
237
238/**
239 * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration.
240 */
241int32_t AConfiguration_getNavHidden(AConfiguration* config);
242
243/**
244 * Set the current nav hidden in the configuration.
245 */
246void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden);
247
248/**
249 * Return the current SDK (API) version set in the configuration.
250 */
251int32_t AConfiguration_getSdkVersion(AConfiguration* config);
252
253/**
254 * Set the current SDK version in the configuration.
255 */
256void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion);
257
258/**
259 * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration.
260 */
261int32_t AConfiguration_getScreenSize(AConfiguration* config);
262
263/**
264 * Set the current screen size in the configuration.
265 */
266void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize);
267
268/**
269 * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration.
270 */
271int32_t AConfiguration_getScreenLong(AConfiguration* config);
272
273/**
274 * Set the current screen long in the configuration.
275 */
276void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong);
277
278/**
279 * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration.
280 */
281int32_t AConfiguration_getUiModeType(AConfiguration* config);
282
283/**
284 * Set the current UI mode type in the configuration.
285 */
286void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType);
287
288/**
289 * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration.
290 */
291int32_t AConfiguration_getUiModeNight(AConfiguration* config);
292
293/**
294 * Set the current UI mode night in the configuration.
295 */
296void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
297
298/**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700299 * Return the current configuration screen width in dp units, or
300 * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
301 */
302int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
303
304/**
305 * Set the configuration's current screen width in dp units.
306 */
307void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
308
309/**
310 * Return the current configuration screen height in dp units, or
311 * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
312 */
313int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
314
315/**
316 * Set the configuration's current screen width in dp units.
317 */
318void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
319
320/**
321 * Return the configuration's smallest screen width in dp units, or
322 * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
323 */
324int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
325
326/**
327 * Set the configuration's smallest screen width in dp units.
328 */
329void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
330
331/**
Dianne Hackborn08d5b8f2010-08-04 11:12:40 -0700332 * Perform a diff between two configurations. Returns a bit mask of
333 * ACONFIGURATION_* constants, each bit set meaning that configuration element
334 * is different between them.
335 */
336int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2);
337
338/**
339 * Determine whether 'base' is a valid configuration for use within the
340 * environment 'requested'. Returns 0 if there are any values in 'base'
341 * that conflict with 'requested'. Returns 1 if it does not conflict.
342 */
343int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested);
344
345/**
346 * Determine whether the configuration in 'test' is better than the existing
347 * configuration in 'base'. If 'requested' is non-NULL, this decision is based
348 * on the overall configuration given there. If it is NULL, this decision is
349 * simply based on which configuration is more specific. Returns non-0 if
350 * 'test' is better than 'base'.
351 *
352 * This assumes you have already filtered the configurations with
353 * AConfiguration_match().
354 */
355int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test,
356 AConfiguration* requested);
357
358#ifdef __cplusplus
359};
360#endif
361
362#endif // ANDROID_CONFIGURATION_H