2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSys_PowerManager.cpp
19 * @brief This is the implementation file for _PowerManager class.
23 #include <system_info.h>
25 #include <FBaseSysLog.h>
26 #include "FSys_PowerManager.h"
28 using namespace Tizen::Base;
30 namespace Tizen { namespace System
33 _PowerManager::_PowerManager()
37 _PowerManager::~_PowerManager()
42 _PowerManager::ChangeBrightness(int brightness)
44 int ret = DEVICE_ERROR_NONE;
47 ret = device_get_max_brightness(0, &maxBrightness);
48 SysTryReturnResult(NID_SYS, ret == DEVICE_ERROR_NONE, E_SYSTEM, "It failed to get the device max brightness");
49 SysTryReturnResult(NID_SYS, (brightness >= 0 && brightness <= maxBrightness), E_OUT_OF_RANGE,
50 "[E_OUT_OF_RANGE] The specified brightness is out of range.[%d]", brightness);
54 ret = device_set_brightness_from_settings(0);
58 ret = device_set_brightness(0, brightness);
61 SysTryReturnResult(NID_SYS, ret == DEVICE_ERROR_NONE, E_SYSTEM, "It is failed to change brightness. error code [%d]", ret);