Bumping manifests a=b2g-bump
[gecko.git] / hal / HalTypes.h
blob12cfcad516c458f6288d86e1914446955b7ede39
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_hal_Types_h
7 #define mozilla_hal_Types_h
9 #include "ipc/IPCMessageUtils.h"
10 #include "mozilla/Observer.h"
12 namespace mozilla {
13 namespace hal {
15 /**
16 * These constants specify special values for content process IDs. You can get
17 * a content process ID by calling ContentChild::GetID() or
18 * ContentParent::GetChildID().
20 const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
21 const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
23 /**
24 * These are defined by libhardware, specifically, hardware/libhardware/include/hardware/lights.h
25 * in the gonk subsystem.
26 * If these change and are exposed to JS, make sure nsIHal.idl is updated as well.
28 enum LightType {
29 eHalLightID_Backlight = 0,
30 eHalLightID_Keyboard = 1,
31 eHalLightID_Buttons = 2,
32 eHalLightID_Battery = 3,
33 eHalLightID_Notifications = 4,
34 eHalLightID_Attention = 5,
35 eHalLightID_Bluetooth = 6,
36 eHalLightID_Wifi = 7,
37 eHalLightID_Count = 8 // This should stay at the end
39 enum LightMode {
40 eHalLightMode_User = 0, // brightness is managed by user setting
41 eHalLightMode_Sensor = 1, // brightness is managed by a light sensor
42 eHalLightMode_Count
44 enum FlashMode {
45 eHalLightFlash_None = 0,
46 eHalLightFlash_Timed = 1, // timed flashing. Use flashOnMS and flashOffMS for timing
47 eHalLightFlash_Hardware = 2, // hardware assisted flashing
48 eHalLightFlash_Count
51 enum ShutdownMode {
52 eHalShutdownMode_Unknown = -1,
53 eHalShutdownMode_PowerOff = 0,
54 eHalShutdownMode_Reboot = 1,
55 eHalShutdownMode_Restart = 2,
56 eHalShutdownMode_Count = 3
59 class SwitchEvent;
61 enum SwitchDevice {
62 SWITCH_DEVICE_UNKNOWN = -1,
63 SWITCH_HEADPHONES,
64 SWITCH_USB,
65 NUM_SWITCH_DEVICE
68 enum SwitchState {
69 SWITCH_STATE_UNKNOWN = -1,
70 SWITCH_STATE_ON,
71 SWITCH_STATE_OFF,
72 SWITCH_STATE_HEADSET, // Headphone with microphone
73 SWITCH_STATE_HEADPHONE, // without microphone
74 NUM_SWITCH_STATE
77 typedef Observer<SwitchEvent> SwitchObserver;
79 // Note that we rely on the order of this enum's entries. Higher priorities
80 // should have larger int values.
81 enum ProcessPriority {
82 PROCESS_PRIORITY_UNKNOWN = -1,
83 PROCESS_PRIORITY_BACKGROUND,
84 PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
85 PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
86 PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
87 // The special class for the preallocated process, high memory priority but
88 // low CPU priority.
89 PROCESS_PRIORITY_PREALLOC,
90 // Any priority greater than or equal to FOREGROUND is considered
91 // "foreground" for the purposes of priority testing, for example
92 // CurrentProcessIsForeground().
93 PROCESS_PRIORITY_FOREGROUND,
94 PROCESS_PRIORITY_FOREGROUND_HIGH,
95 PROCESS_PRIORITY_MASTER,
96 NUM_PROCESS_PRIORITY
99 enum ProcessCPUPriority {
100 PROCESS_CPU_PRIORITY_LOW,
101 PROCESS_CPU_PRIORITY_NORMAL,
102 NUM_PROCESS_CPU_PRIORITY
106 * Values that can be passed to hal::SetCurrentThreadPriority(). These should be
107 * functional in nature, such as COMPOSITOR, instead of levels, like LOW/HIGH.
108 * This allows us to tune our priority scheme for the system in one place such
109 * that it makes sense holistically for the overall operating system. On gonk
110 * or android we may want different priority schemes than on windows, etc.
112 enum ThreadPriority {
113 THREAD_PRIORITY_COMPOSITOR,
114 NUM_THREAD_PRIORITY
118 * Convert a ProcessPriority enum value (with an optional ProcessCPUPriority)
119 * to a string. The strings returned by this function are statically
120 * allocated; do not attempt to free one!
122 * If you pass an unknown process priority, we fatally assert in debug
123 * builds and otherwise return "???".
125 const char*
126 ProcessPriorityToString(ProcessPriority aPriority);
128 const char*
129 ProcessPriorityToString(ProcessPriority aPriority,
130 ProcessCPUPriority aCPUPriority);
133 * Convert a ThreadPriority enum value to a string. The strings returned by
134 * this function are statically allocated; do not attempt to free one!
136 * If you pass an unknown process priority, we assert in debug builds
137 * and otherwise return "???".
139 const char *
140 ThreadPriorityToString(ThreadPriority aPriority);
143 * Used by ModifyWakeLock
145 enum WakeLockControl {
146 WAKE_LOCK_REMOVE_ONE = -1,
147 WAKE_LOCK_NO_CHANGE = 0,
148 WAKE_LOCK_ADD_ONE = 1,
149 NUM_WAKE_LOCK
152 class FMRadioOperationInformation;
154 enum FMRadioOperation {
155 FM_RADIO_OPERATION_UNKNOWN = -1,
156 FM_RADIO_OPERATION_ENABLE,
157 FM_RADIO_OPERATION_DISABLE,
158 FM_RADIO_OPERATION_SEEK,
159 FM_RADIO_OPERATION_TUNE,
160 NUM_FM_RADIO_OPERATION
163 enum FMRadioOperationStatus {
164 FM_RADIO_OPERATION_STATUS_UNKNOWN = -1,
165 FM_RADIO_OPERATION_STATUS_SUCCESS,
166 FM_RADIO_OPERATION_STATUS_FAIL,
167 NUM_FM_RADIO_OPERATION_STATUS
170 enum FMRadioSeekDirection {
171 FM_RADIO_SEEK_DIRECTION_UNKNOWN = -1,
172 FM_RADIO_SEEK_DIRECTION_UP,
173 FM_RADIO_SEEK_DIRECTION_DOWN,
174 NUM_FM_RADIO_SEEK_DIRECTION
177 enum FMRadioCountry {
178 FM_RADIO_COUNTRY_UNKNOWN = -1,
179 FM_RADIO_COUNTRY_US, //USA
180 FM_RADIO_COUNTRY_EU,
181 FM_RADIO_COUNTRY_JP_STANDARD,
182 FM_RADIO_COUNTRY_JP_WIDE,
183 FM_RADIO_COUNTRY_DE, //Germany
184 FM_RADIO_COUNTRY_AW, //Aruba
185 FM_RADIO_COUNTRY_AU, //Australlia
186 FM_RADIO_COUNTRY_BS, //Bahamas
187 FM_RADIO_COUNTRY_BD, //Bangladesh
188 FM_RADIO_COUNTRY_CY, //Cyprus
189 FM_RADIO_COUNTRY_VA, //Vatican
190 FM_RADIO_COUNTRY_CO, //Colombia
191 FM_RADIO_COUNTRY_KR, //Korea
192 FM_RADIO_COUNTRY_DK, //Denmark
193 FM_RADIO_COUNTRY_EC, //Ecuador
194 FM_RADIO_COUNTRY_ES, //Spain
195 FM_RADIO_COUNTRY_FI, //Finland
196 FM_RADIO_COUNTRY_FR, //France
197 FM_RADIO_COUNTRY_GM, //Gambia
198 FM_RADIO_COUNTRY_HU, //Hungary
199 FM_RADIO_COUNTRY_IN, //India
200 FM_RADIO_COUNTRY_IR, //Iran
201 FM_RADIO_COUNTRY_IT, //Italy
202 FM_RADIO_COUNTRY_KW, //Kuwait
203 FM_RADIO_COUNTRY_LT, //Lithuania
204 FM_RADIO_COUNTRY_ML, //Mali
205 FM_RADIO_COUNTRY_MA, //Morocco
206 FM_RADIO_COUNTRY_NO, //Norway
207 FM_RADIO_COUNTRY_NZ, //New Zealand
208 FM_RADIO_COUNTRY_OM, //Oman
209 FM_RADIO_COUNTRY_PG, //Papua New Guinea
210 FM_RADIO_COUNTRY_NL, //Netherlands
211 FM_RADIO_COUNTRY_QA, //Qatar
212 FM_RADIO_COUNTRY_CZ, //Czech Republic
213 FM_RADIO_COUNTRY_UK, //United Kingdom of Great Britain and Northern Ireland
214 FM_RADIO_COUNTRY_RW, //Rwandese Republic
215 FM_RADIO_COUNTRY_SN, //Senegal
216 FM_RADIO_COUNTRY_SG, //Singapore
217 FM_RADIO_COUNTRY_SI, //Slovenia
218 FM_RADIO_COUNTRY_ZA, //South Africa
219 FM_RADIO_COUNTRY_SE, //Sweden
220 FM_RADIO_COUNTRY_CH, //Switzerland
221 FM_RADIO_COUNTRY_TW, //Taiwan
222 FM_RADIO_COUNTRY_TR, //Turkey
223 FM_RADIO_COUNTRY_UA, //Ukraine
224 FM_RADIO_COUNTRY_USER_DEFINED,
225 NUM_FM_RADIO_COUNTRY
228 typedef Observer<FMRadioOperationInformation> FMRadioObserver;
229 } // namespace hal
230 } // namespace mozilla
232 namespace IPC {
235 * Light type serializer.
237 template <>
238 struct ParamTraits<mozilla::hal::LightType>
239 : public ContiguousEnumSerializer<
240 mozilla::hal::LightType,
241 mozilla::hal::eHalLightID_Backlight,
242 mozilla::hal::eHalLightID_Count>
246 * Light mode serializer.
248 template <>
249 struct ParamTraits<mozilla::hal::LightMode>
250 : public ContiguousEnumSerializer<
251 mozilla::hal::LightMode,
252 mozilla::hal::eHalLightMode_User,
253 mozilla::hal::eHalLightMode_Count>
257 * Flash mode serializer.
259 template <>
260 struct ParamTraits<mozilla::hal::FlashMode>
261 : public ContiguousEnumSerializer<
262 mozilla::hal::FlashMode,
263 mozilla::hal::eHalLightFlash_None,
264 mozilla::hal::eHalLightFlash_Count>
268 * Serializer for ShutdownMode.
270 template <>
271 struct ParamTraits<mozilla::hal::ShutdownMode>
272 : public ContiguousEnumSerializer<
273 mozilla::hal::ShutdownMode,
274 mozilla::hal::eHalShutdownMode_Unknown,
275 mozilla::hal::eHalShutdownMode_Count>
279 * WakeLockControl serializer.
281 template <>
282 struct ParamTraits<mozilla::hal::WakeLockControl>
283 : public ContiguousEnumSerializer<
284 mozilla::hal::WakeLockControl,
285 mozilla::hal::WAKE_LOCK_REMOVE_ONE,
286 mozilla::hal::NUM_WAKE_LOCK>
290 * Serializer for SwitchState
292 template <>
293 struct ParamTraits<mozilla::hal::SwitchState>:
294 public ContiguousEnumSerializer<
295 mozilla::hal::SwitchState,
296 mozilla::hal::SWITCH_STATE_UNKNOWN,
297 mozilla::hal::NUM_SWITCH_STATE> {
301 * Serializer for SwitchDevice
303 template <>
304 struct ParamTraits<mozilla::hal::SwitchDevice>:
305 public ContiguousEnumSerializer<
306 mozilla::hal::SwitchDevice,
307 mozilla::hal::SWITCH_DEVICE_UNKNOWN,
308 mozilla::hal::NUM_SWITCH_DEVICE> {
311 template <>
312 struct ParamTraits<mozilla::hal::ProcessPriority>:
313 public ContiguousEnumSerializer<
314 mozilla::hal::ProcessPriority,
315 mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
316 mozilla::hal::NUM_PROCESS_PRIORITY> {
320 * Serializer for FMRadioOperation
322 template <>
323 struct ParamTraits<mozilla::hal::FMRadioOperation>:
324 public ContiguousEnumSerializer<
325 mozilla::hal::FMRadioOperation,
326 mozilla::hal::FM_RADIO_OPERATION_UNKNOWN,
327 mozilla::hal::NUM_FM_RADIO_OPERATION>
331 * Serializer for FMRadioOperationStatus
333 template <>
334 struct ParamTraits<mozilla::hal::FMRadioOperationStatus>:
335 public ContiguousEnumSerializer<
336 mozilla::hal::FMRadioOperationStatus,
337 mozilla::hal::FM_RADIO_OPERATION_STATUS_UNKNOWN,
338 mozilla::hal::NUM_FM_RADIO_OPERATION_STATUS>
342 * Serializer for FMRadioSeekDirection
344 template <>
345 struct ParamTraits<mozilla::hal::FMRadioSeekDirection>:
346 public ContiguousEnumSerializer<
347 mozilla::hal::FMRadioSeekDirection,
348 mozilla::hal::FM_RADIO_SEEK_DIRECTION_UNKNOWN,
349 mozilla::hal::NUM_FM_RADIO_SEEK_DIRECTION>
353 * Serializer for FMRadioCountry
355 template <>
356 struct ParamTraits<mozilla::hal::FMRadioCountry>:
357 public ContiguousEnumSerializer<
358 mozilla::hal::FMRadioCountry,
359 mozilla::hal::FM_RADIO_COUNTRY_UNKNOWN,
360 mozilla::hal::NUM_FM_RADIO_COUNTRY>
363 } // namespace IPC
365 #endif // mozilla_hal_Types_h