3 // Open Service Platform
4 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 // Licensed under the Apache License, Version 2.0 (the License);
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
20 * @file FSysPowerManager.h
21 * @brief This is the header file for the %PowerManager class.
23 * This header file contains the declarations of the %PowerManager class.
26 #ifndef _FSYS_POWER_MANAGER_H_
27 #define _FSYS_POWER_MANAGER_H_
29 #include <FBaseObject.h>
31 namespace Tizen { namespace System
34 class IScreenEventListener;
35 class IChargingEventListener;
36 class IBatteryEventListener;
41 * Defines the representation of the remaining charge in the battery.
47 BATTERY_FULL, // This enum value is deprecated. Instead of using this enum value, use BATTERY_LEVEL_FULL.
48 BATTERY_HIGH, // This enum value is deprecated. Instead of using this enum value, use BATTERY_LEVEL_HIGH.
49 BATTERY_LOW, // This enum value is deprecated. Instead of using this enum value, use BATTERY_LEVEL_LOW.
50 BATTERY_CRITICAL, // This enum value is deprecated. Instead of using this enum value, use BATTERY_LEVEL_CRITICAL.
51 BATTERY_EMPTY, // This enum value is deprecated. Instead of using this enum value, use BATTERY_LEVEL_EMPTY.
52 BATTERY_LEVEL_FULL = BATTERY_FULL,/**< The battery is fully charged */
53 BATTERY_LEVEL_HIGH = BATTERY_HIGH,/**< The battery has plenty of charge */
54 BATTERY_LEVEL_LOW = BATTERY_LOW,/**< The battery has little charge */
55 BATTERY_LEVEL_CRITICAL = BATTERY_CRITICAL,/**< The battery charge is at a critical state @n It is strongly recommended to stop using all multimedia features because they are not guaranteed to work correctly at this level. */
56 BATTERY_LEVEL_EMPTY = BATTERY_EMPTY, /**< The battery is empty @n It is strongly recommended to prepare for the safe termination of the application because the device will start a shutdown process soon after entering this level. */
62 * Defines the representation of the charge remaining in the battery.
68 POWER_STANDBY, // This enum value is deprecated. Instead of using this enum value, use POWER_MODE_STANDBY.
69 POWER_SLEEP, // This enum value is deprecated. Instead of using this enum value, use POWER_MODE_SLEEP.
70 POWER_MODE_STANDBY = POWER_STANDBY, /**< The battery is fully charged */
71 POWER_MODE_SLEEP = POWER_SLEEP, /**< The battery has plenty of charge */
76 * @brief This class provides methods for power management.
80 * @final This class is not intended for extension.
82 * The %PowerManager class provides methods for managing the device power state.
84 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/system/screen_power_mgmt.htm">Screen Power Management</a>.
88 class _OSP_EXPORT_ PowerManager
89 : public Tizen::Base::Object
94 * Changes the policy of the screen power management.
98 * @privilege %http://tizen.org/privilege/power
100 * @return An error code
101 * @param[in] keepOn Set to @c true if the screen remains in the 'ON' state until the application goes to the background, @n
102 * else @c false if the state of the screen is controlled by the default power control policy of the system
103 * @param[in] dimming Set to @c true if the screen is dimmed when there is no user input for a certain amount of time, @n
104 * else @c false if the screen is not dimmed
105 * @exception E_SUCCESS The method is successful.
106 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
107 * @exception E_SYSTEM A system error has occurred.
108 * @remarks The application should explicitly call this method again, if the screen is to be kept 'ON' after coming back from the background state.
110 static result KeepScreenOnState(bool keepOn, bool dimming = true);
113 * Restores the screen brightness control.
117 * @return An error code
118 * @exception E_SUCCESS The method is successful.
119 * @exception E_INVALID_STATE The brightness is never changed.
120 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
121 * @see SetScreenBrightness()
123 static result RestoreScreenBrightness(void);
126 * Sets the screen brightness level for an application.
129 * @privilege %http://tizen.org/privilege/power
131 * @return An error code
132 * @param[in] brightness The brightness level to set @n
133 * The parameter value can range between @c 1 (minimum) and @c 10 (maximum).
134 * @exception E_SUCCESS The method is successful.
135 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
136 * @exception E_OUT_OF_RANGE The specified @c brightness is out of range.
137 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
138 * @remarks This brightness level is only available when an application is running on the foreground. Even if the brightness is set to level 1, a black screen is not displayed. Level 1 is the minimum brightness level that can be set for an application.
139 * @see RestoreScreenBrightness()
142 static result SetScreenBrightness(int brightness);
144 * Gets the screen brightness level of an application.
148 * @return The brightness level of the current application
149 * @exception E_SUCCESS The method is successful.
150 * @exception E_SYSTEM A system error has occurred.
151 * @remarks The specific error code can be accessed using the GetLastResult() method.
152 * @remarks This method returns the screen brightness level set for an application. If the brightness level is not set, it will return the default system brightness level. @n
153 * In case of error, this method returns @c -1.
155 static int GetScreenBrightness(void);
158 * Checks whether the screen is on.
162 * @return @c true if the screen is on, @n
164 * @exception E_SUCCESS The method is successful.
165 * @exception E_SYSTEM A system error has occurred.
166 * @remarks The specific error code can be accessed using the GetLastResult() method.
167 * @remarks This method returns @c true when the screen is in the dimming state, and @c false in case of an error.
169 static bool IsScreenOn(void);
172 * Turns on the screen.
176 * @privilege %http://tizen.org/privilege/power
177 * @return An error code
178 * @exception E_SUCCESS The method is successful.
179 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
180 * @exception E_SYSTEM A system error has occurred.
182 static result TurnScreenOn(void);
185 * Turns off the screen.
189 * @privilege %http://tizen.org/privilege/power
190 * @return An error code
191 * @exception E_SUCCESS The method is successful.
192 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
193 * @exception E_SYSTEM A system error has occurred.
195 static result TurnScreenOff(void);
198 * Changes the policy of the CPU (Central Processing Unit) power management.
202 * @privilege %http://tizen.org/privilege/power
204 * @return An error code
205 * @param[in] enable Set to @c true to prevent the CPU from going into sleep mode, @n
206 * else @c false to let the state of the CPU follow the system default power management policy
207 * @exception E_SUCCESS The method is successful.
208 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
209 * @exception E_SYSTEM A system error has occurred.
211 static result KeepCpuAwake(bool enable);
214 * Sets the screen event listener.
218 * @param[in] listener The screen event listener
219 * @see IScreenEventListener
221 static void SetScreenEventListener(IScreenEventListener& listener);
224 * Sets the charging event listener.
228 * @param[in] listener The charging event listener
230 static void SetChargingEventListener(IChargingEventListener& listener);
233 * Sets the battery event listener.
237 * @return An error code
238 * @param[in] pListener The battery event listener
239 * @exception E_SUCCESS The method is successful.
240 * @exception E_SYSTEM A system error has occurred.
241 * @remarks If @c pListener is set to @c null, the pre-registered listener is unregistered.
243 static result SetBatteryEventListener(IBatteryEventListener* pListener);
246 * Gets the current charge remaining in the battery as a percentage.
250 * @return The percentage of the charge remaining in the battery.
251 * @exception E_SUCCESS The method is successful.
252 * @exception E_UNSUPPORTED_OPERATION The method is not supported by this device.
253 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
254 * @remakrs The specific error code can be accessed using the GetLastResult() method.
255 * @remarks The resolution of the level is @c 1 percentage. The range of the level is minimum @c 0 to maximum @c 100.
257 static int GetCurrentBatteryLevelInPercentage(void);
260 * Gets the current charging level of the battery.
264 * @return A value from the enumerator BatteryLevel indicating the current charging level
265 * @exception E_SUCCESS The method is successful.
266 * @exception E_UNSUPPORTED_OPERATION The method is not supported by this device.
267 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
268 * @remarks The specific error code can be accessed using the GetLastResult() method.
270 static BatteryLevel GetCurrentBatteryLevel(void);
273 * Checks whether the battery is currently charging.
277 * @return @c true if the charging cable is connected to the phone, @n
279 * @exception E_SUCCESS The method is successful.
280 * @exception E_UNSUPPORTED_OPERATION The method is not supported by this device.
281 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
282 * @remarks The specific error code can be accessed using the GetLastResult() method.
284 static bool IsCharging(void);
288 * This is the default constructor for this class. This default constructor is intentionally declared as private so that only the platform can create an instance.
292 * This is the destructor for this class. This destructor overrides Tizen::Base::Object::~Object().
294 virtual ~PowerManager(void);
297 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
299 PowerManager(const PowerManager& value);
302 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
304 PowerManager& operator = (const PowerManager& value);
307 friend class _PowerManagerImpl;
308 class _PowerManagerImpl* __pPowerManagerImpl;
313 #endif // _FSYS_POWER_MANAGER_H_