michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_hal_Types_h michael@0: #define mozilla_hal_Types_h michael@0: michael@0: #include "ipc/IPCMessageUtils.h" michael@0: #include "mozilla/Observer.h" michael@0: michael@0: namespace mozilla { michael@0: namespace hal { michael@0: michael@0: /** michael@0: * These constants specify special values for content process IDs. You can get michael@0: * a content process ID by calling ContentChild::GetID() or michael@0: * ContentParent::GetChildID(). michael@0: */ michael@0: const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1); michael@0: const uint64_t CONTENT_PROCESS_ID_MAIN = 0; michael@0: michael@0: /** michael@0: * These are defined by libhardware, specifically, hardware/libhardware/include/hardware/lights.h michael@0: * in the gonk subsystem. michael@0: * If these change and are exposed to JS, make sure nsIHal.idl is updated as well. michael@0: */ michael@0: enum LightType { michael@0: eHalLightID_Backlight = 0, michael@0: eHalLightID_Keyboard = 1, michael@0: eHalLightID_Buttons = 2, michael@0: eHalLightID_Battery = 3, michael@0: eHalLightID_Notifications = 4, michael@0: eHalLightID_Attention = 5, michael@0: eHalLightID_Bluetooth = 6, michael@0: eHalLightID_Wifi = 7, michael@0: eHalLightID_Count = 8 // This should stay at the end michael@0: }; michael@0: enum LightMode { michael@0: eHalLightMode_User = 0, // brightness is managed by user setting michael@0: eHalLightMode_Sensor = 1, // brightness is managed by a light sensor michael@0: eHalLightMode_Count michael@0: }; michael@0: enum FlashMode { michael@0: eHalLightFlash_None = 0, michael@0: eHalLightFlash_Timed = 1, // timed flashing. Use flashOnMS and flashOffMS for timing michael@0: eHalLightFlash_Hardware = 2, // hardware assisted flashing michael@0: eHalLightFlash_Count michael@0: }; michael@0: michael@0: enum ShutdownMode { michael@0: eHalShutdownMode_Unknown = -1, michael@0: eHalShutdownMode_PowerOff = 0, michael@0: eHalShutdownMode_Reboot = 1, michael@0: eHalShutdownMode_Restart = 2, michael@0: eHalShutdownMode_Count = 3 michael@0: }; michael@0: michael@0: class SwitchEvent; michael@0: michael@0: enum SwitchDevice { michael@0: SWITCH_DEVICE_UNKNOWN = -1, michael@0: SWITCH_HEADPHONES, michael@0: SWITCH_USB, michael@0: NUM_SWITCH_DEVICE michael@0: }; michael@0: michael@0: enum SwitchState { michael@0: SWITCH_STATE_UNKNOWN = -1, michael@0: SWITCH_STATE_ON, michael@0: SWITCH_STATE_OFF, michael@0: SWITCH_STATE_HEADSET, // Headphone with microphone michael@0: SWITCH_STATE_HEADPHONE, // without microphone michael@0: NUM_SWITCH_STATE michael@0: }; michael@0: michael@0: typedef Observer SwitchObserver; michael@0: michael@0: // Note that we rely on the order of this enum's entries. Higher priorities michael@0: // should have larger int values. michael@0: enum ProcessPriority { michael@0: PROCESS_PRIORITY_UNKNOWN = -1, michael@0: PROCESS_PRIORITY_BACKGROUND, michael@0: PROCESS_PRIORITY_BACKGROUND_HOMESCREEN, michael@0: PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE, michael@0: PROCESS_PRIORITY_FOREGROUND_KEYBOARD, michael@0: // The special class for the preallocated process, high memory priority but michael@0: // low CPU priority. michael@0: PROCESS_PRIORITY_PREALLOC, michael@0: // Any priority greater than or equal to FOREGROUND is considered michael@0: // "foreground" for the purposes of priority testing, for example michael@0: // CurrentProcessIsForeground(). michael@0: PROCESS_PRIORITY_FOREGROUND, michael@0: PROCESS_PRIORITY_FOREGROUND_HIGH, michael@0: PROCESS_PRIORITY_MASTER, michael@0: NUM_PROCESS_PRIORITY michael@0: }; michael@0: michael@0: enum ProcessCPUPriority { michael@0: PROCESS_CPU_PRIORITY_LOW, michael@0: PROCESS_CPU_PRIORITY_NORMAL, michael@0: NUM_PROCESS_CPU_PRIORITY michael@0: }; michael@0: michael@0: // Convert a ProcessPriority enum value (with an optional ProcessCPUPriority) michael@0: // to a string. The strings returned by this function are statically michael@0: // allocated; do not attempt to free one! michael@0: // michael@0: // If you pass an unknown process priority (or NUM_PROCESS_PRIORITY), we michael@0: // fatally assert in debug builds and otherwise return "???". michael@0: const char* michael@0: ProcessPriorityToString(ProcessPriority aPriority); michael@0: michael@0: const char* michael@0: ProcessPriorityToString(ProcessPriority aPriority, michael@0: ProcessCPUPriority aCPUPriority); michael@0: michael@0: /** michael@0: * Used by ModifyWakeLock michael@0: */ michael@0: enum WakeLockControl { michael@0: WAKE_LOCK_REMOVE_ONE = -1, michael@0: WAKE_LOCK_NO_CHANGE = 0, michael@0: WAKE_LOCK_ADD_ONE = 1, michael@0: NUM_WAKE_LOCK michael@0: }; michael@0: michael@0: class FMRadioOperationInformation; michael@0: michael@0: enum FMRadioOperation { michael@0: FM_RADIO_OPERATION_UNKNOWN = -1, michael@0: FM_RADIO_OPERATION_ENABLE, michael@0: FM_RADIO_OPERATION_DISABLE, michael@0: FM_RADIO_OPERATION_SEEK, michael@0: FM_RADIO_OPERATION_TUNE, michael@0: NUM_FM_RADIO_OPERATION michael@0: }; michael@0: michael@0: enum FMRadioOperationStatus { michael@0: FM_RADIO_OPERATION_STATUS_UNKNOWN = -1, michael@0: FM_RADIO_OPERATION_STATUS_SUCCESS, michael@0: FM_RADIO_OPERATION_STATUS_FAIL, michael@0: NUM_FM_RADIO_OPERATION_STATUS michael@0: }; michael@0: michael@0: enum FMRadioSeekDirection { michael@0: FM_RADIO_SEEK_DIRECTION_UNKNOWN = -1, michael@0: FM_RADIO_SEEK_DIRECTION_UP, michael@0: FM_RADIO_SEEK_DIRECTION_DOWN, michael@0: NUM_FM_RADIO_SEEK_DIRECTION michael@0: }; michael@0: michael@0: enum FMRadioCountry { michael@0: FM_RADIO_COUNTRY_UNKNOWN = -1, michael@0: FM_RADIO_COUNTRY_US, //USA michael@0: FM_RADIO_COUNTRY_EU, michael@0: FM_RADIO_COUNTRY_JP_STANDARD, michael@0: FM_RADIO_COUNTRY_JP_WIDE, michael@0: FM_RADIO_COUNTRY_DE, //Germany michael@0: FM_RADIO_COUNTRY_AW, //Aruba michael@0: FM_RADIO_COUNTRY_AU, //Australlia michael@0: FM_RADIO_COUNTRY_BS, //Bahamas michael@0: FM_RADIO_COUNTRY_BD, //Bangladesh michael@0: FM_RADIO_COUNTRY_CY, //Cyprus michael@0: FM_RADIO_COUNTRY_VA, //Vatican michael@0: FM_RADIO_COUNTRY_CO, //Colombia michael@0: FM_RADIO_COUNTRY_KR, //Korea michael@0: FM_RADIO_COUNTRY_DK, //Denmark michael@0: FM_RADIO_COUNTRY_EC, //Ecuador michael@0: FM_RADIO_COUNTRY_ES, //Spain michael@0: FM_RADIO_COUNTRY_FI, //Finland michael@0: FM_RADIO_COUNTRY_FR, //France michael@0: FM_RADIO_COUNTRY_GM, //Gambia michael@0: FM_RADIO_COUNTRY_HU, //Hungary michael@0: FM_RADIO_COUNTRY_IN, //India michael@0: FM_RADIO_COUNTRY_IR, //Iran michael@0: FM_RADIO_COUNTRY_IT, //Italy michael@0: FM_RADIO_COUNTRY_KW, //Kuwait michael@0: FM_RADIO_COUNTRY_LT, //Lithuania michael@0: FM_RADIO_COUNTRY_ML, //Mali michael@0: FM_RADIO_COUNTRY_MA, //Morocco michael@0: FM_RADIO_COUNTRY_NO, //Norway michael@0: FM_RADIO_COUNTRY_NZ, //New Zealand michael@0: FM_RADIO_COUNTRY_OM, //Oman michael@0: FM_RADIO_COUNTRY_PG, //Papua New Guinea michael@0: FM_RADIO_COUNTRY_NL, //Netherlands michael@0: FM_RADIO_COUNTRY_QA, //Qatar michael@0: FM_RADIO_COUNTRY_CZ, //Czech Republic michael@0: FM_RADIO_COUNTRY_UK, //United Kingdom of Great Britain and Northern Ireland michael@0: FM_RADIO_COUNTRY_RW, //Rwandese Republic michael@0: FM_RADIO_COUNTRY_SN, //Senegal michael@0: FM_RADIO_COUNTRY_SG, //Singapore michael@0: FM_RADIO_COUNTRY_SI, //Slovenia michael@0: FM_RADIO_COUNTRY_ZA, //South Africa michael@0: FM_RADIO_COUNTRY_SE, //Sweden michael@0: FM_RADIO_COUNTRY_CH, //Switzerland michael@0: FM_RADIO_COUNTRY_TW, //Taiwan michael@0: FM_RADIO_COUNTRY_TR, //Turkey michael@0: FM_RADIO_COUNTRY_UA, //Ukraine michael@0: FM_RADIO_COUNTRY_USER_DEFINED, michael@0: NUM_FM_RADIO_COUNTRY michael@0: }; michael@0: michael@0: typedef Observer FMRadioObserver; michael@0: } // namespace hal michael@0: } // namespace mozilla michael@0: michael@0: namespace IPC { michael@0: michael@0: /** michael@0: * Light type serializer. michael@0: */ michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::hal::LightType, michael@0: mozilla::hal::eHalLightID_Backlight, michael@0: mozilla::hal::eHalLightID_Count> michael@0: {}; michael@0: michael@0: /** michael@0: * Light mode serializer. michael@0: */ michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::hal::LightMode, michael@0: mozilla::hal::eHalLightMode_User, michael@0: mozilla::hal::eHalLightMode_Count> michael@0: {}; michael@0: michael@0: /** michael@0: * Flash mode serializer. michael@0: */ michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::hal::FlashMode, michael@0: mozilla::hal::eHalLightFlash_None, michael@0: mozilla::hal::eHalLightFlash_Count> michael@0: {}; michael@0: michael@0: /** michael@0: * Serializer for ShutdownMode. michael@0: */ michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::hal::ShutdownMode, michael@0: mozilla::hal::eHalShutdownMode_Unknown, michael@0: mozilla::hal::eHalShutdownMode_Count> michael@0: {}; michael@0: michael@0: /** michael@0: * WakeLockControl serializer. michael@0: */ michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::hal::WakeLockControl, michael@0: mozilla::hal::WAKE_LOCK_REMOVE_ONE, michael@0: mozilla::hal::NUM_WAKE_LOCK> michael@0: {}; michael@0: michael@0: /** michael@0: * Serializer for SwitchState michael@0: */ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::SwitchState, michael@0: mozilla::hal::SWITCH_STATE_UNKNOWN, michael@0: mozilla::hal::NUM_SWITCH_STATE> { michael@0: }; michael@0: michael@0: /** michael@0: * Serializer for SwitchDevice michael@0: */ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::SwitchDevice, michael@0: mozilla::hal::SWITCH_DEVICE_UNKNOWN, michael@0: mozilla::hal::NUM_SWITCH_DEVICE> { michael@0: }; michael@0: michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::ProcessPriority, michael@0: mozilla::hal::PROCESS_PRIORITY_UNKNOWN, michael@0: mozilla::hal::NUM_PROCESS_PRIORITY> { michael@0: }; michael@0: michael@0: /** michael@0: * Serializer for FMRadioOperation michael@0: */ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::FMRadioOperation, michael@0: mozilla::hal::FM_RADIO_OPERATION_UNKNOWN, michael@0: mozilla::hal::NUM_FM_RADIO_OPERATION> michael@0: {}; michael@0: michael@0: /** michael@0: * Serializer for FMRadioOperationStatus michael@0: */ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::FMRadioOperationStatus, michael@0: mozilla::hal::FM_RADIO_OPERATION_STATUS_UNKNOWN, michael@0: mozilla::hal::NUM_FM_RADIO_OPERATION_STATUS> michael@0: {}; michael@0: michael@0: /** michael@0: * Serializer for FMRadioSeekDirection michael@0: */ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::FMRadioSeekDirection, michael@0: mozilla::hal::FM_RADIO_SEEK_DIRECTION_UNKNOWN, michael@0: mozilla::hal::NUM_FM_RADIO_SEEK_DIRECTION> michael@0: {}; michael@0: michael@0: /** michael@0: * Serializer for FMRadioCountry michael@0: **/ michael@0: template <> michael@0: struct ParamTraits: michael@0: public ContiguousEnumSerializer< michael@0: mozilla::hal::FMRadioCountry, michael@0: mozilla::hal::FM_RADIO_COUNTRY_UNKNOWN, michael@0: mozilla::hal::NUM_FM_RADIO_COUNTRY> michael@0: {}; michael@0: michael@0: } // namespace IPC michael@0: michael@0: #endif // mozilla_hal_Types_h