SET (${this_target}_SOURCE_FILES
system/FSys_SystemInfo.cpp
dev/FSys_DeviceManager.cpp
+ power/FSys_PowerManager.cpp
)
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
capi-system-media-key
capi-network-bluetooth
+ capi-system-device
)
FOREACH(flag ${pkgs_CFLAGS})
TARGET_LINK_LIBRARIES(${this_target} osp-appfw)
TARGET_LINK_LIBRARIES(${this_target} capi-network-bluetooth)
TARGET_LINK_LIBRARIES(${this_target} capi-system-media-key)
+TARGET_LINK_LIBRARIES(${this_target} capi-system-device)
SET_TARGET_PROPERTIES(${this_target}
PROPERTIES
--- /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_IPowerManager.h
+ * @brief This is the header file of the _IPowerManager class.
+ *
+ * This header file contains the declarations of the _IPowerManager class.
+ */
+#include <FBase.h>
+#include <FSystem.h>
+
+#ifndef _FSYS_INTERNAL_IPOWER_MANAGER_H_
+#define _FSYS_INTERNAL_IPOWER_MANAGER_H_
+
+namespace Tizen { namespace System {
+
+/**
+ * @class _IPowerManager
+ * @brief This class contains implementaion of device control.
+ * @since 2.1
+ */
+class _OSP_EXPORT_ _IPowerManager
+{
+protected:
+ virtual ~_IPowerManager(void) {};
+public:
+ virtual result ChangeBrightness(int brightness) = 0;
+}; //_IPowerManager
+
+}} //Tizen::System
+#endif /* _FSYS_INTERNAL_IPOWER_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.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>
+#include "FSys_IPowerManager.h"
+
+namespace Tizen { namespace System
+{
+class _PowerManager
+ : public _IPowerManager
+{
+public:
+ static _PowerManager* GetInstance(void);
+ result ChangeBrightness(int brightness);
+
+private:
+ _PowerManager();
+ virtual ~_PowerManager();
+
+private:
+ static _PowerManager* __pPowerManager;
+};
+
+} } // 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 <unique_ptr.h>
+#include <new>
+
+#include <device.h>
+#include <system_info.h>
+
+#include <FBaseSysLog.h>
+
+#include "FSys_PowerManager.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace {
+ static const int _POWER_COMMAND_ID = 1;
+}
+
+namespace Tizen { namespace System
+{
+
+_PowerManager* _PowerManager::__pPowerManager = null;
+
+_PowerManager::_PowerManager()
+{
+}
+
+_PowerManager::~_PowerManager()
+{
+}
+
+_PowerManager*
+_PowerManager::GetInstance()
+{
+
+ if(__pPowerManager == null)
+ {
+ __pPowerManager = new (std::nothrow) _PowerManager();
+ }
+
+ return __pPowerManager;
+}
+
+result
+_PowerManager::ChangeBrightness(int brightness)
+{
+
+ int ret = DEVICE_ERROR_NONE;
+ result r = E_OBJ_NOT_FOUND;
+
+ if (brightness > 0)
+ {
+ SysLog(NID_SYS, "Brightness is [%d]", brightness);
+ ret = device_set_brightness(0, brightness);
+ if(ret == DEVICE_ERROR_NONE)
+ {
+ r = E_SUCCESS;
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to change brightness.");
+ r = E_SYSTEM;
+ }
+ }
+ else if (brightness == 0)
+ {
+ SysLog(NID_SYS, "Current Active App does not have brightness.");
+ ret = device_set_brightness_from_settings(0);
+ r = E_SUCCESS;
+ }
+
+ return r;
+}
+
+
+extern "C" _OSP_EXPORT_ _IPowerManager* PowerManager_CreateInstance()
+{
+ return _PowerManager::GetInstance();
+}
+} } // Tizen::System
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"
#endif
SysTryReturn(NID_SYS, IsActive() == true, E_SUCCESS, r, "It is not active app.");
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);
+ r = pIpcClient->Construct(_POWER_MANAGER_SERVICE_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);
+ r = pIpcClient->Construct(_POWER_MANAGER_SERVICE_ID);
SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] It failed to create IpcClient", GetErrorMessage(r));
requestMessage.Construct();