setting/providers/FSys_SettingVibrationProvider.cpp
runtime/FSys_RuntimeInfo.cpp
device/FSys_DeviceManager.cpp
+ power/FSys_PowerManager.cpp
)
INCLUDE(FindPkgConfig)
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_PowerManager.h
+ * @brief This is the header file for the _PowerManager class.
+ */
+
+#ifndef _FSYS_SERVICE_SYS_POWER_MANAGER__H_
+#define _FSYS_SERVICE_SYS_POWER_MANAGER__H_
+
+#include <FApp.h>
+#include <FBase.h>
+
+namespace Tizen { namespace System
+{
+class _OSP_EXPORT_ _PowerManager
+{
+public:
+ static result ChangeBrightness(int brightness);
+private:
+ _PowerManager();
+ virtual ~_PowerManager();
+};
+
+} } // Tizen::System
+
+#endif // _FSYS_SERVICE_SYS_POWER_MANAGER__H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_PowerManager.cpp
+ * @brief This is the implementation file for _PowerManager class.
+ */
+
+#include <device.h>
+#include <system_info.h>
+
+#include <FBaseSysLog.h>
+#include "FSys_PowerManager.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace System
+{
+
+_PowerManager::_PowerManager()
+{
+}
+
+_PowerManager::~_PowerManager()
+{
+}
+
+result
+_PowerManager::ChangeBrightness(int brightness)
+{
+ int ret = DEVICE_ERROR_NONE;
+ int maxBrightness;
+
+ ret = device_get_max_brightness(0, &maxBrightness);
+ SysTryReturnResult(NID_SYS, ret == DEVICE_ERROR_NONE, E_SYSTEM, "It failed to get the device max brightness");
+ SysTryReturnResult(NID_SYS, (brightness >= 0 && brightness <= maxBrightness), E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] The specified brightness is out of range.[%d]", brightness);
+
+ if (brightness == 0)
+ {
+ ret = device_set_brightness_from_settings(0);
+ }
+ else
+ {
+ ret = device_set_brightness(0, brightness);
+ }
+
+ SysTryReturnResult(NID_SYS, ret == DEVICE_ERROR_NONE, E_SYSTEM, "It is failed to change brightness. error code [%d]", ret);
+
+ return E_SUCCESS;
+}
+} } // Tizen::System
#include <runtime_info.h>
#include <vconf.h>
+#include <FIo.h>
#include <FAppIActiveAppEventListener.h>
#include <FBaseSysLog.h>
#include <FBaseColArrayListT.h>
static const int _APPID_LENGTH = 10;
static const int _DEACTIVATED_BRIGHTNESS_CONTROL = -1;
static const float _BRIGHTNESS_RESOLUTION = 10.0;
+static const wchar_t* POWER_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.powermanager";
#ifndef VCONFKEY_SERVICE_READY
#define VCONFKEY_SERVICE_READY "memory/deviced/boot_power_on"
unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient());
SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
- r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
+ if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_powermanager") == true)
+ {
+ SysLog(NID_SYS, "PowerManager is serviced by common-service");
+ r = pIpcClient->Construct(POWER_MANAGER_SERVICE_ID);
+ }
+ else
+ {
+ r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
+ }
SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to create IpcClient", GetErrorMessage(r));
requestMessage.Construct();
unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient());
SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
- r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
+ if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_powermanager") == true)
+ {
+ SysLog(NID_SYS, "PowerManager is serviced by common-service");
+ r = pIpcClient->Construct(POWER_MANAGER_SERVICE_ID);
+ }
+ else
+ {
+ r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
+ }
SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to create IpcClient", GetErrorMessage(r));
requestMessage.Construct();