blob: 97d4c42a3de8141f0a7bf8830804d058d27a3849 [file] [log] [blame]
Mathias Agopiane1c61d32012-03-23 14:19:36 -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,
43 ACONFIGURATION_DENSITY_TV = 213,
44 ACONFIGURATION_DENSITY_HIGH = 240,
45 ACONFIGURATION_DENSITY_XHIGH = 320,
46 ACONFIGURATION_DENSITY_XXHIGH = 480,
Dianne Hackborn6303d062013-02-12 15:36:31 -080047 ACONFIGURATION_DENSITY_XXXHIGH = 640,
Mathias Agopiane1c61d32012-03-23 14:19:36 -070048 ACONFIGURATION_DENSITY_NONE = 0xffff,
49
50 ACONFIGURATION_KEYBOARD_ANY = 0x0000,
51 ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001,
52 ACONFIGURATION_KEYBOARD_QWERTY = 0x0002,
53 ACONFIGURATION_KEYBOARD_12KEY = 0x0003,
54
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,
60
61 ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000,
62 ACONFIGURATION_KEYSHIDDEN_NO = 0x0001,
63 ACONFIGURATION_KEYSHIDDEN_YES = 0x0002,
64 ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003,
65
66 ACONFIGURATION_NAVHIDDEN_ANY = 0x0000,
67 ACONFIGURATION_NAVHIDDEN_NO = 0x0001,
68 ACONFIGURATION_NAVHIDDEN_YES = 0x0002,
69
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,
75
76 ACONFIGURATION_SCREENLONG_ANY = 0x00,
77 ACONFIGURATION_SCREENLONG_NO = 0x1,
78 ACONFIGURATION_SCREENLONG_YES = 0x2,
79
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,
John Spurlockad98ad02014-04-03 16:39:17 -040086 ACONFIGURATION_UI_MODE_TYPE_WATCH = 0x06,
Mathias Agopiane1c61d32012-03-23 14:19:36 -070087
88 ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00,
89 ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
90 ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
91
92 ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
93
94 ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
95
96 ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
97
Fabrice Di Meglio8855e6f2012-06-20 15:47:21 -070098 ACONFIGURATION_LAYOUTDIR_ANY = 0x00,
99 ACONFIGURATION_LAYOUTDIR_LTR = 0x01,
100 ACONFIGURATION_LAYOUTDIR_RTL = 0x02,
101
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700102 ACONFIGURATION_MCC = 0x0001,
103 ACONFIGURATION_MNC = 0x0002,
104 ACONFIGURATION_LOCALE = 0x0004,
105 ACONFIGURATION_TOUCHSCREEN = 0x0008,
106 ACONFIGURATION_KEYBOARD = 0x0010,
107 ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020,
108 ACONFIGURATION_NAVIGATION = 0x0040,
109 ACONFIGURATION_ORIENTATION = 0x0080,
110 ACONFIGURATION_DENSITY = 0x0100,
111 ACONFIGURATION_SCREEN_SIZE = 0x0200,
112 ACONFIGURATION_VERSION = 0x0400,
113 ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
114 ACONFIGURATION_UI_MODE = 0x1000,
115 ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
Fabrice Di Meglio8855e6f2012-06-20 15:47:21 -0700116 ACONFIGURATION_LAYOUTDIR = 0x4000,
Johan Redestig8df483c2013-05-30 08:30:42 +0200117
118 ACONFIGURATION_MNC_ZERO = 0xffff,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700119};
120
121/**
122 * Create a new AConfiguration, initialized with no values set.
123 */
124AConfiguration* AConfiguration_new();
125
126/**
127 * Free an AConfiguration that was previously created with
128 * AConfiguration_new().
129 */
130void AConfiguration_delete(AConfiguration* config);
131
132/**
133 * Create and return a new AConfiguration based on the current configuration in
134 * use in the given AssetManager.
135 */
136void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am);
137
138/**
139 * Copy the contents of 'src' to 'dest'.
140 */
141void AConfiguration_copy(AConfiguration* dest, AConfiguration* src);
142
143/**
144 * Return the current MCC set in the configuration. 0 if not set.
145 */
146int32_t AConfiguration_getMcc(AConfiguration* config);
147
148/**
149 * Set the current MCC in the configuration. 0 to clear.
150 */
151void AConfiguration_setMcc(AConfiguration* config, int32_t mcc);
152
153/**
154 * Return the current MNC set in the configuration. 0 if not set.
155 */
156int32_t AConfiguration_getMnc(AConfiguration* config);
157
158/**
159 * Set the current MNC in the configuration. 0 to clear.
160 */
161void AConfiguration_setMnc(AConfiguration* config, int32_t mnc);
162
163/**
164 * Return the current language code set in the configuration. The output will
165 * be filled with an array of two characters. They are not 0-terminated. If
166 * a language is not set, they will be 0.
167 */
168void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage);
169
170/**
171 * Set the current language code in the configuration, from the first two
172 * characters in the string.
173 */
174void AConfiguration_setLanguage(AConfiguration* config, const char* language);
175
176/**
177 * Return the current country code set in the configuration. The output will
178 * be filled with an array of two characters. They are not 0-terminated. If
179 * a country is not set, they will be 0.
180 */
181void AConfiguration_getCountry(AConfiguration* config, char* outCountry);
182
183/**
184 * Set the current country code in the configuration, from the first two
185 * characters in the string.
186 */
187void AConfiguration_setCountry(AConfiguration* config, const char* country);
188
189/**
190 * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration.
191 */
192int32_t AConfiguration_getOrientation(AConfiguration* config);
193
194/**
195 * Set the current orientation in the configuration.
196 */
197void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation);
198
199/**
200 * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration.
201 */
202int32_t AConfiguration_getTouchscreen(AConfiguration* config);
203
204/**
205 * Set the current touchscreen in the configuration.
206 */
207void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen);
208
209/**
210 * Return the current ACONFIGURATION_DENSITY_* set in the configuration.
211 */
212int32_t AConfiguration_getDensity(AConfiguration* config);
213
214/**
215 * Set the current density in the configuration.
216 */
217void AConfiguration_setDensity(AConfiguration* config, int32_t density);
218
219/**
220 * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration.
221 */
222int32_t AConfiguration_getKeyboard(AConfiguration* config);
223
224/**
225 * Set the current keyboard in the configuration.
226 */
227void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard);
228
229/**
230 * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration.
231 */
232int32_t AConfiguration_getNavigation(AConfiguration* config);
233
234/**
235 * Set the current navigation in the configuration.
236 */
237void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation);
238
239/**
240 * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration.
241 */
242int32_t AConfiguration_getKeysHidden(AConfiguration* config);
243
244/**
245 * Set the current keys hidden in the configuration.
246 */
247void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden);
248
249/**
250 * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration.
251 */
252int32_t AConfiguration_getNavHidden(AConfiguration* config);
253
254/**
255 * Set the current nav hidden in the configuration.
256 */
257void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden);
258
259/**
260 * Return the current SDK (API) version set in the configuration.
261 */
262int32_t AConfiguration_getSdkVersion(AConfiguration* config);
263
264/**
265 * Set the current SDK version in the configuration.
266 */
267void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion);
268
269/**
270 * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration.
271 */
272int32_t AConfiguration_getScreenSize(AConfiguration* config);
273
274/**
275 * Set the current screen size in the configuration.
276 */
277void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize);
278
279/**
280 * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration.
281 */
282int32_t AConfiguration_getScreenLong(AConfiguration* config);
283
284/**
285 * Set the current screen long in the configuration.
286 */
287void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong);
288
289/**
290 * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration.
291 */
292int32_t AConfiguration_getUiModeType(AConfiguration* config);
293
294/**
295 * Set the current UI mode type in the configuration.
296 */
297void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType);
298
299/**
300 * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration.
301 */
302int32_t AConfiguration_getUiModeNight(AConfiguration* config);
303
304/**
305 * Set the current UI mode night in the configuration.
306 */
307void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
308
309/**
310 * Return the current configuration screen width in dp units, or
311 * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
312 */
313int32_t AConfiguration_getScreenWidthDp(AConfiguration* config);
314
315/**
316 * Set the configuration's current screen width in dp units.
317 */
318void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value);
319
320/**
321 * Return the current configuration screen height in dp units, or
322 * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set.
323 */
324int32_t AConfiguration_getScreenHeightDp(AConfiguration* config);
325
326/**
327 * Set the configuration's current screen width in dp units.
328 */
329void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value);
330
331/**
332 * Return the configuration's smallest screen width in dp units, or
333 * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set.
334 */
335int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config);
336
337/**
338 * Set the configuration's smallest screen width in dp units.
339 */
340void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
341
342/**
Fabrice Di Meglio8855e6f2012-06-20 15:47:21 -0700343 * Return the configuration's layout direction, or
344 * ACONFIGURATION_LAYOUTDIR_ANY if not set.
345 */
346int32_t AConfiguration_getLayoutDirection(AConfiguration* config);
347
348/**
349 * Set the configuration's layout direction.
350 */
351void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value);
352
353/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700354 * Perform a diff between two configurations. Returns a bit mask of
355 * ACONFIGURATION_* constants, each bit set meaning that configuration element
356 * is different between them.
357 */
358int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2);
359
360/**
361 * Determine whether 'base' is a valid configuration for use within the
362 * environment 'requested'. Returns 0 if there are any values in 'base'
363 * that conflict with 'requested'. Returns 1 if it does not conflict.
364 */
365int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested);
366
367/**
368 * Determine whether the configuration in 'test' is better than the existing
369 * configuration in 'base'. If 'requested' is non-NULL, this decision is based
370 * on the overall configuration given there. If it is NULL, this decision is
371 * simply based on which configuration is more specific. Returns non-0 if
372 * 'test' is better than 'base'.
373 *
374 * This assumes you have already filtered the configurations with
375 * AConfiguration_match().
376 */
377int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test,
378 AConfiguration* requested);
379
380#ifdef __cplusplus
381};
382#endif
383
384#endif // ANDROID_CONFIGURATION_H