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"
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;
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.
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,
37 eHalLightID_Count
= 8 // This should stay at the end
40 eHalLightMode_User
= 0, // brightness is managed by user setting
41 eHalLightMode_Sensor
= 1, // brightness is managed by a light sensor
45 eHalLightFlash_None
= 0,
46 eHalLightFlash_Timed
= 1, // timed flashing. Use flashOnMS and flashOffMS for timing
47 eHalLightFlash_Hardware
= 2, // hardware assisted flashing
52 eHalShutdownMode_Unknown
= -1,
53 eHalShutdownMode_PowerOff
= 0,
54 eHalShutdownMode_Reboot
= 1,
55 eHalShutdownMode_Restart
= 2,
56 eHalShutdownMode_Count
= 3
62 SWITCH_DEVICE_UNKNOWN
= -1,
69 SWITCH_STATE_UNKNOWN
= -1,
72 SWITCH_STATE_HEADSET
, // Headphone with microphone
73 SWITCH_STATE_HEADPHONE
, // without microphone
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
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
,
100 * Values that can be passed to hal::SetCurrentThreadPriority(). These should be
101 * functional in nature, such as COMPOSITOR, instead of levels, like LOW/HIGH.
102 * This allows us to tune our priority scheme for the system in one place such
103 * that it makes sense holistically for the overall operating system. On gonk
104 * or android we may want different priority schemes than on windows, etc.
106 enum ThreadPriority
{
107 THREAD_PRIORITY_COMPOSITOR
,
112 * Convert a ProcessPriority enum value to a string. The strings returned by
113 * this function are statically allocated; do not attempt to free one!
115 * If you pass an unknown process priority, we fatally assert in debug
116 * builds and otherwise return "???".
119 ProcessPriorityToString(ProcessPriority aPriority
);
122 * Convert a ThreadPriority enum value to a string. The strings returned by
123 * this function are statically allocated; do not attempt to free one!
125 * If you pass an unknown process priority, we assert in debug builds
126 * and otherwise return "???".
129 ThreadPriorityToString(ThreadPriority aPriority
);
132 * Used by ModifyWakeLock
134 enum WakeLockControl
{
135 WAKE_LOCK_REMOVE_ONE
= -1,
136 WAKE_LOCK_NO_CHANGE
= 0,
137 WAKE_LOCK_ADD_ONE
= 1,
141 class FMRadioOperationInformation
;
143 enum FMRadioOperation
{
144 FM_RADIO_OPERATION_UNKNOWN
= -1,
145 FM_RADIO_OPERATION_ENABLE
,
146 FM_RADIO_OPERATION_DISABLE
,
147 FM_RADIO_OPERATION_SEEK
,
148 FM_RADIO_OPERATION_TUNE
,
149 NUM_FM_RADIO_OPERATION
152 enum FMRadioOperationStatus
{
153 FM_RADIO_OPERATION_STATUS_UNKNOWN
= -1,
154 FM_RADIO_OPERATION_STATUS_SUCCESS
,
155 FM_RADIO_OPERATION_STATUS_FAIL
,
156 NUM_FM_RADIO_OPERATION_STATUS
159 enum FMRadioSeekDirection
{
160 FM_RADIO_SEEK_DIRECTION_UNKNOWN
= -1,
161 FM_RADIO_SEEK_DIRECTION_UP
,
162 FM_RADIO_SEEK_DIRECTION_DOWN
,
163 NUM_FM_RADIO_SEEK_DIRECTION
166 enum FMRadioCountry
{
167 FM_RADIO_COUNTRY_UNKNOWN
= -1,
168 FM_RADIO_COUNTRY_US
, //USA
170 FM_RADIO_COUNTRY_JP_STANDARD
,
171 FM_RADIO_COUNTRY_JP_WIDE
,
172 FM_RADIO_COUNTRY_DE
, //Germany
173 FM_RADIO_COUNTRY_AW
, //Aruba
174 FM_RADIO_COUNTRY_AU
, //Australlia
175 FM_RADIO_COUNTRY_BS
, //Bahamas
176 FM_RADIO_COUNTRY_BD
, //Bangladesh
177 FM_RADIO_COUNTRY_CY
, //Cyprus
178 FM_RADIO_COUNTRY_VA
, //Vatican
179 FM_RADIO_COUNTRY_CO
, //Colombia
180 FM_RADIO_COUNTRY_KR
, //Korea
181 FM_RADIO_COUNTRY_DK
, //Denmark
182 FM_RADIO_COUNTRY_EC
, //Ecuador
183 FM_RADIO_COUNTRY_ES
, //Spain
184 FM_RADIO_COUNTRY_FI
, //Finland
185 FM_RADIO_COUNTRY_FR
, //France
186 FM_RADIO_COUNTRY_GM
, //Gambia
187 FM_RADIO_COUNTRY_HU
, //Hungary
188 FM_RADIO_COUNTRY_IN
, //India
189 FM_RADIO_COUNTRY_IR
, //Iran
190 FM_RADIO_COUNTRY_IT
, //Italy
191 FM_RADIO_COUNTRY_KW
, //Kuwait
192 FM_RADIO_COUNTRY_LT
, //Lithuania
193 FM_RADIO_COUNTRY_ML
, //Mali
194 FM_RADIO_COUNTRY_MA
, //Morocco
195 FM_RADIO_COUNTRY_NO
, //Norway
196 FM_RADIO_COUNTRY_NZ
, //New Zealand
197 FM_RADIO_COUNTRY_OM
, //Oman
198 FM_RADIO_COUNTRY_PG
, //Papua New Guinea
199 FM_RADIO_COUNTRY_NL
, //Netherlands
200 FM_RADIO_COUNTRY_QA
, //Qatar
201 FM_RADIO_COUNTRY_CZ
, //Czech Republic
202 FM_RADIO_COUNTRY_UK
, //United Kingdom of Great Britain and Northern Ireland
203 FM_RADIO_COUNTRY_RW
, //Rwandese Republic
204 FM_RADIO_COUNTRY_SN
, //Senegal
205 FM_RADIO_COUNTRY_SG
, //Singapore
206 FM_RADIO_COUNTRY_SI
, //Slovenia
207 FM_RADIO_COUNTRY_ZA
, //South Africa
208 FM_RADIO_COUNTRY_SE
, //Sweden
209 FM_RADIO_COUNTRY_CH
, //Switzerland
210 FM_RADIO_COUNTRY_TW
, //Taiwan
211 FM_RADIO_COUNTRY_TR
, //Turkey
212 FM_RADIO_COUNTRY_UA
, //Ukraine
213 FM_RADIO_COUNTRY_USER_DEFINED
,
217 class FMRadioRDSGroup
;
218 typedef Observer
<FMRadioOperationInformation
> FMRadioObserver
;
219 typedef Observer
<FMRadioRDSGroup
> FMRadioRDSObserver
;
221 } // namespace mozilla
226 * Light type serializer.
229 struct ParamTraits
<mozilla::hal::LightType
>
230 : public ContiguousEnumSerializer
<
231 mozilla::hal::LightType
,
232 mozilla::hal::eHalLightID_Backlight
,
233 mozilla::hal::eHalLightID_Count
>
237 * Light mode serializer.
240 struct ParamTraits
<mozilla::hal::LightMode
>
241 : public ContiguousEnumSerializer
<
242 mozilla::hal::LightMode
,
243 mozilla::hal::eHalLightMode_User
,
244 mozilla::hal::eHalLightMode_Count
>
248 * Flash mode serializer.
251 struct ParamTraits
<mozilla::hal::FlashMode
>
252 : public ContiguousEnumSerializer
<
253 mozilla::hal::FlashMode
,
254 mozilla::hal::eHalLightFlash_None
,
255 mozilla::hal::eHalLightFlash_Count
>
259 * Serializer for ShutdownMode.
262 struct ParamTraits
<mozilla::hal::ShutdownMode
>
263 : public ContiguousEnumSerializer
<
264 mozilla::hal::ShutdownMode
,
265 mozilla::hal::eHalShutdownMode_Unknown
,
266 mozilla::hal::eHalShutdownMode_Count
>
270 * WakeLockControl serializer.
273 struct ParamTraits
<mozilla::hal::WakeLockControl
>
274 : public ContiguousEnumSerializer
<
275 mozilla::hal::WakeLockControl
,
276 mozilla::hal::WAKE_LOCK_REMOVE_ONE
,
277 mozilla::hal::NUM_WAKE_LOCK
>
281 * Serializer for SwitchState
284 struct ParamTraits
<mozilla::hal::SwitchState
>:
285 public ContiguousEnumSerializer
<
286 mozilla::hal::SwitchState
,
287 mozilla::hal::SWITCH_STATE_UNKNOWN
,
288 mozilla::hal::NUM_SWITCH_STATE
> {
292 * Serializer for SwitchDevice
295 struct ParamTraits
<mozilla::hal::SwitchDevice
>:
296 public ContiguousEnumSerializer
<
297 mozilla::hal::SwitchDevice
,
298 mozilla::hal::SWITCH_DEVICE_UNKNOWN
,
299 mozilla::hal::NUM_SWITCH_DEVICE
> {
303 struct ParamTraits
<mozilla::hal::ProcessPriority
>:
304 public ContiguousEnumSerializer
<
305 mozilla::hal::ProcessPriority
,
306 mozilla::hal::PROCESS_PRIORITY_UNKNOWN
,
307 mozilla::hal::NUM_PROCESS_PRIORITY
> {
311 * Serializer for FMRadioOperation
314 struct ParamTraits
<mozilla::hal::FMRadioOperation
>:
315 public ContiguousEnumSerializer
<
316 mozilla::hal::FMRadioOperation
,
317 mozilla::hal::FM_RADIO_OPERATION_UNKNOWN
,
318 mozilla::hal::NUM_FM_RADIO_OPERATION
>
322 * Serializer for FMRadioOperationStatus
325 struct ParamTraits
<mozilla::hal::FMRadioOperationStatus
>:
326 public ContiguousEnumSerializer
<
327 mozilla::hal::FMRadioOperationStatus
,
328 mozilla::hal::FM_RADIO_OPERATION_STATUS_UNKNOWN
,
329 mozilla::hal::NUM_FM_RADIO_OPERATION_STATUS
>
333 * Serializer for FMRadioSeekDirection
336 struct ParamTraits
<mozilla::hal::FMRadioSeekDirection
>:
337 public ContiguousEnumSerializer
<
338 mozilla::hal::FMRadioSeekDirection
,
339 mozilla::hal::FM_RADIO_SEEK_DIRECTION_UNKNOWN
,
340 mozilla::hal::NUM_FM_RADIO_SEEK_DIRECTION
>
344 * Serializer for FMRadioCountry
347 struct ParamTraits
<mozilla::hal::FMRadioCountry
>:
348 public ContiguousEnumSerializer
<
349 mozilla::hal::FMRadioCountry
,
350 mozilla::hal::FM_RADIO_COUNTRY_UNKNOWN
,
351 mozilla::hal::NUM_FM_RADIO_COUNTRY
>
356 #endif // mozilla_hal_Types_h