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_DeviceManagerImpl.cpp
19 * @brief This is the implementation file for _DeviceManagerImpl class.
23 #include <unique_ptr.h>
24 #include <system_info.h>
25 #include <runtime_info.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseRtEvent.h>
31 #include <FBaseRtIEventArg.h>
32 #include <FBaseStringComparer.h>
33 #include <FBaseSysLog.h>
34 #include <FSysIDeviceEventListener.h>
37 #include <FApp_AppInfo.h>
38 #include <FBase_NativeError.h>
39 #include <FIo_AppServiceIpcMessages.h>
40 #include <FIo_IpcClient.h>
41 #include <FSys_SystemInfoImpl.h>
42 #include <FSys_PowerManagerImpl.h>
44 #include "FSys_CommunicationDispatcherClient.h"
45 #include "FSys_DeviceManagerImpl.h"
46 #include "FSys_SystemServiceMessageClient.h"
48 #define VCONFKEY_APPSERVICE_MMC_STATUS "memory/appservice/mmc"
52 using namespace Tizen::App;
53 using namespace Tizen::Base;
54 using namespace Tizen::Base::Collection;
55 using namespace Tizen::Base::Runtime;
56 using namespace Tizen::Io;
58 namespace Tizen { namespace System
61 static const wchar_t* _DEVICE_MANAGER_SERVICE_ID = L"osp.devicemanager.service";
62 static const wchar_t* _DEVICE_MANAGER_SERVICE_ID_EX = L"osp.sys.ipcserver.devicemanager";
63 static const wchar_t* _DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open";
64 static const wchar_t* _DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close";
65 static const wchar_t* _DEVICE_MANAGER_COMMAND_STATUS = L"osp.devicemanager.command.status";
66 static const wchar_t* _DEVICE_MANAGER_COMMAND_EVENT = L"osp.devicemanager.command.event";
67 static const wchar_t* _DEVICE_MANAGER_BLUETOOTH = L"osp.devicemanager.bluetooth";
69 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_SERVICE_ID = 0;
70 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_COMMAND_ID = 1;
71 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_DEVICE_ID = 2;
72 const int _OSP_APP_SERVICE_IPC_MESSAGE_DATA = 3;
74 const int _DEVICE_MANAGER_BLUETOOTH_HEADSET = 0x01;
75 const int _DEVICE_MANAGER_CHARGER = 0x02;
76 const int _DEVICE_MANAGER_USB_CLIENT = 0x04;
77 const int _DEVICE_MANAGER_TV_OUT = 0x08;
78 const int _DEVICE_MANAGER_WIRED_HEADSET = 0x10;
79 const int _DEVICE_MANAGER_WIRED_HEADPHONE = 0x20;
80 const int _DEVICE_MANAGER_STORAGECARD = 0x40;
81 const int _DEVICE_MANAGER_KEYBOARD = 0x80;
83 static const wchar_t* _DEVICE_MANAGER_STATE_INSERTED = L"Inserted";
84 static const wchar_t* _DEVICE_MANAGER_STATE_REMOVED = L"Removed";
85 static const wchar_t* _DEVICE_MANAGER_STATE_MOUNTED = L"Mounted";
86 static const wchar_t* _DEVICE_MANAGER_STATE_UNMOUNTED = L"Unmounted";
87 static const wchar_t* _DEVICE_MANAGER_STATE_OPENED = L"Opened";
88 static const wchar_t* _DEVICE_MANAGER_STATE_CLOSED = L"Closed";
90 static const wchar_t* _SYSTEM_INFO_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
91 static const wchar_t* _SYSTEM_INFO_INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
92 static const wchar_t* _SYSTEM_INFO_TVOUT_SUPPORTED = L"http://tizen.org/feature/screen.output.rca";
93 static const wchar_t* _SYSTEM_INFO_HDMI = L"http://tizen.org/feature/screen.output.hdmi";
95 _DeviceManagerImpl* _DeviceManagerImpl::__pDeviceManagerImpl = null;
97 class _DeviceManagerEventArg : public IEventArg
100 _DeviceManagerEventArg()
103 DeviceType deviceType;
107 class _DeviceManagerEvent : public Event
110 virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
112 IDeviceEventListener* pListener = dynamic_cast<IDeviceEventListener*> (&listener);
113 const _DeviceManagerEventArg* pArg = dynamic_cast<const _DeviceManagerEventArg*>(&arg);
115 SysTryReturnVoidResult(NID_SYS, pListener != null && pArg != null, E_SYSTEM, "Parameters are not available.");
117 pListener->OnDeviceStateChanged(pArg->deviceType, pArg->state);
123 _DeviceManagerImpl::OnDeviceStateChanged(runtime_info_key_e key, void* pData)
125 if (__pDeviceManagerImpl != null)
127 __pDeviceManagerImpl->SendEvent(key);
132 _DeviceManagerImpl::InitDeviceManagerImpl(void)
134 static _DeviceManagerImpl deviceManagerImpl;
135 __pDeviceManagerImpl = &deviceManagerImpl;
138 _DeviceManagerImpl::GetInstance(void)
140 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
141 if(__pDeviceManagerImpl == null)
143 pthread_once(&once_block, InitDeviceManagerImpl);
145 return __pDeviceManagerImpl;
148 _DeviceManagerImpl::_DeviceManagerImpl()
150 , __headSetType(DEVICE_TYPE_WIRED_HEADPHONE)
151 , __bluetoothReferenceCount(0)
152 , __pSystemServiceMessageClient(null)
154 result r = E_SUCCESS;
155 int headsetState = 0;
157 static String DEVICE_MANAGER_SERVICE_ID(_DEVICE_MANAGER_SERVICE_ID);
159 if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
161 SysLog(NID_SYS, "Device Manager is service by common-service.");
162 _SystemServiceMessageClient* pSystemServiceMessageClient = _SystemServiceMessageClient::CreateInstance(_DEVICE_MANAGER_SERVICE_ID_EX);
163 SysTryCatch(NID_SYS, pSystemServiceMessageClient, r = E_SYSTEM, r, "It is failed to get system service message client.");
164 r = pSystemServiceMessageClient->RegisterListener(_DEVICE_MANAGER_SERVICE_ID_EX, *this);
165 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on Listener.");
166 SysLog(NID_SYS, "Device listner 0x%x", this);
168 __pSystemServiceMessageClient = pSystemServiceMessageClient;
169 __pIpcClient = __pSystemServiceMessageClient->GetIpcClient();
173 SysLog(NID_SYS, "Device Manager is service by app-service.");
174 _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
175 SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
177 r = pCommunicationDispatcherClient->RegisterCommunicationListener(DEVICE_MANAGER_SERVICE_ID, *this);
178 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
180 __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
183 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, OnDeviceStateChanged, null);
184 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register USB event");
186 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, OnDeviceStateChanged, null);
187 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register DEVICE_TYPE_CHARGER event");
189 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, OnDeviceStateChanged, null);
190 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register TV out event");
192 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, OnDeviceStateChanged, null);
193 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register audio jack event");
195 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, OnDeviceStateChanged, null);
196 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register sliding keyboard event");
198 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &headsetState);
199 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to get audio jack status");
201 if (headsetState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
203 __headSetType = DEVICE_TYPE_WIRED_HEADPHONE;
205 else if (headsetState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE)
207 __headSetType = DEVICE_TYPE_WIRED_HEADSET;
210 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
212 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, DeviceEventVConfCallBack, null);
216 ret = vconf_notify_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback, null);
218 SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register MMC event callback.");
220 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack, null);
221 SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register HDMI event");
223 __deviceEventList.Construct();
229 _DeviceManagerImpl::~_DeviceManagerImpl()
231 result r = E_SUCCESS;
233 _CommunicationDispatcherClient* pCommunicationDispatcherClient = null;
234 String key(_DEVICE_MANAGER_SERVICE_ID);
236 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED);
237 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister USB event");
239 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED);
240 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister TV out event");
242 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS);
243 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister audio jack event");
245 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED);
246 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister sliding keyboard event");
248 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
250 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, DeviceEventVConfCallBack);
254 ret = vconf_ignore_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback);
256 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister MMC event");
258 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack);
259 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister HDMI event");
261 if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
263 if (__pSystemServiceMessageClient)
265 delete __pSystemServiceMessageClient;
270 pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
271 SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
273 r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key);
274 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
282 _DeviceManagerImpl::DeviceEventVConfCallBack(keynode_t* node, void* userData)
288 if (strcmp(VCONFKEY_SYSMAN_MMC_STATUS, vconf_keynode_get_name(node)) == 0)
290 SysLog(NID_SYS, "MMC callback is occured");
291 if (__pDeviceManagerImpl != null)
293 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &value);
296 event = _DEVICE_MANAGER_STATE_MOUNTED;
300 event = _DEVICE_MANAGER_STATE_UNMOUNTED;
302 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_STORAGE_CARD, event);
305 else if(strcmp(VCONFKEY_SYSMAN_HDMI, vconf_keynode_get_name(node)) == 0)
307 if (__pDeviceManagerImpl != null)
309 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
312 event = _DEVICE_MANAGER_STATE_INSERTED;
316 event = _DEVICE_MANAGER_STATE_REMOVED;
318 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_HDMI, event);
325 _DeviceManagerImpl::MmcEventVconfCallback(keynode_t* node, void* userData)
327 if (strcmp(VCONFKEY_APPSERVICE_MMC_STATUS, vconf_keynode_get_name(node)) == 0)
329 SysLog(NID_SYS, "MMC event callback is called.");
330 if (__pDeviceManagerImpl != NULL)
334 int ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
335 SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
339 event = _DEVICE_MANAGER_STATE_MOUNTED;
343 event = _DEVICE_MANAGER_STATE_UNMOUNTED;
345 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_STORAGE_CARD, event);
351 _DeviceManagerImpl::SendEvent(DeviceType deviceType, String& state)
353 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(null);
355 if(__deviceEventList.GetCount() > 0)
357 pEnumerator.reset(__deviceEventList.GetEnumeratorN());
358 SysTryReturnVoidResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
360 while(pEnumerator->MoveNext() == E_SUCCESS)
362 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
363 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
364 SysTryReturnVoidResult(NID_SYS, pDeviceEventListenerContainer != null,E_SYSTEM, "Container is empty");
368 case DEVICE_TYPE_BLUETOOTH_HEADSET:
370 if(pDeviceEventListenerContainer->__bluetoothHeadset == false)
376 case DEVICE_TYPE_CHARGER:
378 if(pDeviceEventListenerContainer->__charger == false)
384 case DEVICE_TYPE_USB_CLIENT:
386 if(pDeviceEventListenerContainer->__usbClient == false)
392 case DEVICE_TYPE_TV_OUT:
394 if(pDeviceEventListenerContainer->__tvOut == false)
400 case DEVICE_TYPE_WIRED_HEADSET:
402 if(pDeviceEventListenerContainer->__wiredHeadset == false)
408 case DEVICE_TYPE_WIRED_HEADPHONE:
410 if(pDeviceEventListenerContainer->__wiredHeadphone == false)
416 case DEVICE_TYPE_STORAGE_CARD:
418 if(pDeviceEventListenerContainer->__storageCard == false)
424 case DEVICE_TYPE_KEYBOARD:
426 if(pDeviceEventListenerContainer->__keyboard == false)
432 case DEVICE_TYPE_HDMI:
434 if(pDeviceEventListenerContainer->__hdmi == false)
443 unique_ptr<_DeviceManagerEventArg> pDeviceManagerEventArg(new (std::nothrow) _DeviceManagerEventArg());
444 SysTryReturnVoidResult(NID_SYS, pDeviceManagerEventArg != null, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
446 pDeviceManagerEventArg->deviceType = deviceType;
447 pDeviceManagerEventArg->state = state;
449 if(pDeviceEventListenerContainer->__pEvent != null)
451 pDeviceEventListenerContainer->__pEvent->Fire(*(pDeviceManagerEventArg.release()));
458 _DeviceManagerImpl::RequireBluetoothEvent(void)
460 result r = E_SUCCESS;
462 SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "Ipc Client is not ready");
464 __bluetoothReferenceCount ++;
466 if(__bluetoothReferenceCount == 1)
468 ArrayList requestMessages;
469 ArrayList responseMessages;
471 r = requestMessages.Construct();
472 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
473 r = responseMessages.Construct();
474 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
476 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
477 String commandId = _DEVICE_MANAGER_COMMAND_OPEN;
478 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
480 r = requestMessages.Add(serviceId);
481 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
482 r = requestMessages.Add(commandId);
483 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
484 r = requestMessages.Add(deviceId);
486 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add device id (bluetooth)");
488 unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
489 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
491 r = __pIpcClient->SendRequest(pRequest.get());
492 SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "It is failed to add bluetooth id");
493 SysLog(NID_SYS, "It sent %ls", _DEVICE_MANAGER_COMMAND_OPEN);
495 responseMessages.RemoveAll(true);
501 _DeviceManagerImpl::ReleaseBluetoothEvent(void)
503 result r = E_SUCCESS;
504 SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "Ipc Client is not ready");
506 __bluetoothReferenceCount --;
507 SysTryReturnResult(NID_SYS, __bluetoothReferenceCount >= 0, E_SYSTEM, "Fail to manage reference count");
509 if(__bluetoothReferenceCount == 0)
511 ArrayList requestMessages;
512 ArrayList responseMessages;
514 r = requestMessages.Construct();
515 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
516 r = responseMessages.Construct();
517 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
519 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
520 String commandId = _DEVICE_MANAGER_COMMAND_CLOSE;
521 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
523 r = requestMessages.Add(serviceId);
524 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
525 r = requestMessages.Add(commandId);
526 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
527 r = requestMessages.Add(deviceId);
528 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
530 unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
531 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
533 r = __pIpcClient->SendRequest(pRequest.get());
534 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
536 responseMessages.RemoveAll(true);
542 _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEventListener* pListener)
544 result r = E_OBJ_NOT_FOUND;
545 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(null);
547 if(__deviceEventList.GetCount() > 0)
549 pEnumerator.reset(__deviceEventList.GetEnumeratorN());
550 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
552 while(pEnumerator->MoveNext() == E_SUCCESS)
554 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
555 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
556 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
557 if(pDeviceEventListenerContainer->__pListener == pListener)
561 case DEVICE_TYPE_BLUETOOTH_HEADSET:
563 if(pDeviceEventListenerContainer->__bluetoothHeadset == true)
565 r = E_OBJ_ALREADY_EXIST;
569 pDeviceEventListenerContainer->__bluetoothHeadset = true;
570 RequireBluetoothEvent();
575 case DEVICE_TYPE_CHARGER:
577 if(pDeviceEventListenerContainer->__charger == true)
579 r = E_OBJ_ALREADY_EXIST;
583 pDeviceEventListenerContainer->__charger = true;
588 case DEVICE_TYPE_USB_CLIENT:
590 if(pDeviceEventListenerContainer->__usbClient == true)
592 r = E_OBJ_ALREADY_EXIST;
596 pDeviceEventListenerContainer->__usbClient = true;
601 case DEVICE_TYPE_TV_OUT:
604 _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
608 if(!_AppInfo::IsOspCompat())
610 r = E_UNSUPPORTED_OPERATION;
614 r = E_DEVICE_UNAVAILABLE;
619 if(pDeviceEventListenerContainer->__tvOut == true)
621 r = E_OBJ_ALREADY_EXIST;
625 pDeviceEventListenerContainer->__tvOut = true;
630 case DEVICE_TYPE_WIRED_HEADSET:
632 if(pDeviceEventListenerContainer->__wiredHeadset == true)
634 r = E_OBJ_ALREADY_EXIST;
638 pDeviceEventListenerContainer->__wiredHeadset = true;
643 case DEVICE_TYPE_WIRED_HEADPHONE:
645 if(pDeviceEventListenerContainer->__wiredHeadphone == true)
647 r = E_OBJ_ALREADY_EXIST;
651 pDeviceEventListenerContainer->__wiredHeadphone = true;
656 case DEVICE_TYPE_STORAGE_CARD:
658 if(pDeviceEventListenerContainer->__storageCard == true)
660 r = E_OBJ_ALREADY_EXIST;
664 pDeviceEventListenerContainer->__storageCard = true;
669 case DEVICE_TYPE_KEYBOARD:
671 bool keyboard = false;
672 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
674 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
676 if (keyboard == false)
678 if(!_AppInfo::IsOspCompat())
680 return E_UNSUPPORTED_OPERATION;
684 return E_DEVICE_UNAVAILABLE;
688 if(pDeviceEventListenerContainer->__keyboard == true)
690 r = E_OBJ_ALREADY_EXIST;
694 pDeviceEventListenerContainer->__keyboard = true;
699 case DEVICE_TYPE_HDMI:
703 bool supported = false;
704 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
705 SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
707 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
708 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
709 SysTryReturnResult(NID_SYS, value >= 0, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
711 if(pDeviceEventListenerContainer->__hdmi == true)
713 r = E_OBJ_ALREADY_EXIST;
717 pDeviceEventListenerContainer->__hdmi = true;
730 _DeviceManagerImpl::AddDeviceEventListener(DeviceType deviceType, IDeviceEventListener* pListener)
732 SysTryReturnResult(NID_SYS, pListener != null, E_INVALID_ARG, "There is no listener isntance.");
733 SysTryReturnResult(NID_SYS, (deviceType >= DEVICE_TYPE_BLUETOOTH_HEADSET && deviceType <= DEVICE_TYPE_HDMI), E_INVALID_ARG, "There is no listener isntance.");
734 result r = E_SUCCESS;
736 if(deviceType == DEVICE_TYPE_TV_OUT)
739 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
740 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
744 if(!_AppInfo::IsOspCompat())
746 r = E_UNSUPPORTED_OPERATION;
750 r = E_DEVICE_UNAVAILABLE;
755 else if(deviceType == DEVICE_TYPE_KEYBOARD)
757 bool keyboard = false;
758 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
760 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
762 if (keyboard == false)
764 if(!_AppInfo::IsOspCompat())
766 r = E_UNSUPPORTED_OPERATION;
770 r = E_DEVICE_UNAVAILABLE;
775 else if(deviceType == DEVICE_TYPE_HDMI)
779 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
780 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
783 return E_UNSUPPORTED_OPERATION;
787 r = AddOnExistedListener(deviceType, pListener);
789 if(r == E_OBJ_NOT_FOUND)
791 unique_ptr<_DeviceEventListenerContainer> pDeviceEventContainer(new (std::nothrow) _DeviceEventListenerContainer());
792 SysTryReturnResult(NID_SYS, pDeviceEventContainer != null, E_OUT_OF_MEMORY, "It is failed to create instance of _DeviceEventListenerContainer");
794 unique_ptr<_DeviceManagerEvent> pDeviceManagerEvent(new (std::nothrow) _DeviceManagerEvent());
795 SysTryReturnResult(NID_SYS, pDeviceManagerEvent != null, E_OUT_OF_MEMORY, "It is failed to create instance of _DeviceManagerEvent");
797 pDeviceManagerEvent->AddListener(*pListener);
798 pDeviceEventContainer->__pListener = pListener;
799 pDeviceEventContainer->__pEvent = pDeviceManagerEvent.release();
803 case DEVICE_TYPE_BLUETOOTH_HEADSET:
805 pDeviceEventContainer->__bluetoothHeadset = true;
806 RequireBluetoothEvent();
809 case DEVICE_TYPE_CHARGER:
811 pDeviceEventContainer->__charger = true;
814 case DEVICE_TYPE_USB_CLIENT:
816 pDeviceEventContainer->__usbClient = true;
819 case DEVICE_TYPE_TV_OUT:
822 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
823 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
827 if(!_AppInfo::IsOspCompat())
829 return E_UNSUPPORTED_OPERATION;
833 return E_DEVICE_UNAVAILABLE;
837 pDeviceEventContainer->__tvOut = true;
840 case DEVICE_TYPE_WIRED_HEADSET:
842 pDeviceEventContainer->__wiredHeadset = true;
845 case DEVICE_TYPE_WIRED_HEADPHONE:
847 pDeviceEventContainer->__wiredHeadphone = true;
850 case DEVICE_TYPE_STORAGE_CARD:
852 pDeviceEventContainer->__storageCard = true;
855 case DEVICE_TYPE_KEYBOARD:
857 bool keyboard = false;
858 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
860 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
862 if (keyboard == false)
864 if(!_AppInfo::IsOspCompat())
866 return E_UNSUPPORTED_OPERATION;
870 return E_DEVICE_UNAVAILABLE;
874 pDeviceEventContainer->__keyboard = true;
877 case DEVICE_TYPE_HDMI:
881 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
882 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
885 return E_UNSUPPORTED_OPERATION;
887 pDeviceEventContainer->__hdmi = true;
892 __deviceEventList.Add(pDeviceEventContainer.release());
899 _DeviceManagerImpl::RemoveDeviceEventListener(DeviceType deviceType, IDeviceEventListener* pListener)
901 result r = E_SUCCESS;
903 SysTryReturnResult(NID_SYS, pListener != null, E_INVALID_ARG, "There is no listener isntance.");
904 SysTryReturnResult(NID_SYS, (deviceType >= DEVICE_TYPE_BLUETOOTH_HEADSET && deviceType <= DEVICE_TYPE_HDMI), E_INVALID_ARG, "There is no listener isntance.");
905 SysTryReturnResult(NID_SYS, __deviceEventList.GetCount() > 0, E_INVALID_ARG, "There is no registered listener.");
907 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(__deviceEventList.GetEnumeratorN());
909 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
911 if(deviceType == DEVICE_TYPE_TV_OUT)
914 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
915 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
919 if(!_AppInfo::IsOspCompat())
921 r = E_UNSUPPORTED_OPERATION;
925 r = E_DEVICE_UNAVAILABLE;
930 else if(deviceType == DEVICE_TYPE_KEYBOARD)
932 bool keyboard = false;
933 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
935 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
937 if (keyboard == false)
939 if(!_AppInfo::IsOspCompat())
941 r = E_UNSUPPORTED_OPERATION;
945 r = E_DEVICE_UNAVAILABLE;
949 else if(deviceType == DEVICE_TYPE_HDMI)
953 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
954 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
957 return E_UNSUPPORTED_OPERATION;
961 while(pEnumerator->MoveNext() == E_SUCCESS)
963 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
964 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
965 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
967 if(pDeviceEventListenerContainer->__pListener == pListener)
971 case DEVICE_TYPE_BLUETOOTH_HEADSET:
973 if(pDeviceEventListenerContainer->__bluetoothHeadset == false)
975 return E_OBJ_NOT_FOUND;
977 pDeviceEventListenerContainer->__bluetoothHeadset = false;
978 ReleaseBluetoothEvent();
981 case DEVICE_TYPE_CHARGER:
983 if(pDeviceEventListenerContainer->__charger == false)
985 return E_OBJ_NOT_FOUND;
987 pDeviceEventListenerContainer->__charger = false;
990 case DEVICE_TYPE_USB_CLIENT:
992 if(pDeviceEventListenerContainer->__usbClient == false)
994 return E_OBJ_NOT_FOUND;
996 pDeviceEventListenerContainer->__usbClient = false;
999 case DEVICE_TYPE_TV_OUT:
1001 if(pDeviceEventListenerContainer->__tvOut == false)
1003 return E_OBJ_NOT_FOUND;
1005 pDeviceEventListenerContainer->__tvOut = false;
1008 case DEVICE_TYPE_WIRED_HEADSET:
1010 if(pDeviceEventListenerContainer->__wiredHeadset == false)
1012 return E_OBJ_NOT_FOUND;
1014 pDeviceEventListenerContainer->__wiredHeadset = false;
1017 case DEVICE_TYPE_WIRED_HEADPHONE:
1019 if(pDeviceEventListenerContainer->__wiredHeadphone == false)
1021 return E_OBJ_NOT_FOUND;
1023 pDeviceEventListenerContainer->__wiredHeadphone = false;
1026 case DEVICE_TYPE_STORAGE_CARD:
1028 if(pDeviceEventListenerContainer->__storageCard == false)
1030 return E_OBJ_NOT_FOUND;
1032 pDeviceEventListenerContainer->__storageCard = false;
1035 case DEVICE_TYPE_KEYBOARD:
1037 if(pDeviceEventListenerContainer->__keyboard == false)
1039 return E_OBJ_NOT_FOUND;
1041 pDeviceEventListenerContainer->__keyboard = false;
1044 case DEVICE_TYPE_HDMI:
1046 if(pDeviceEventListenerContainer->__hdmi == false)
1048 return E_OBJ_NOT_FOUND;
1050 pDeviceEventListenerContainer->__hdmi = false;
1055 if(pDeviceEventListenerContainer->IsInvalid() == true)
1057 __deviceEventList.Remove(pDeviceEventListenerContainer);
1058 delete pDeviceEventListenerContainer;
1063 return E_OBJ_NOT_FOUND;
1067 _DeviceManagerImpl::RemoveAllDeviceEventListeners(void)
1069 result r = E_SUCCESS;
1071 IEnumeratorT<_DeviceEventListenerContainer*>* pEnumerator = __deviceEventList.GetEnumeratorN();
1072 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
1074 while(pEnumerator->MoveNext() == E_SUCCESS)
1076 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
1077 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
1078 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
1079 __deviceEventList.Remove(pDeviceEventListenerContainer);
1080 delete pDeviceEventListenerContainer;
1084 __bluetoothReferenceCount = 1;
1086 ReleaseBluetoothEvent();
1091 _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
1093 DeviceType type = DEVICE_TYPE_USB_CLIENT;
1100 case RUNTIME_INFO_KEY_USB_CONNECTED:
1102 flag = _DEVICE_MANAGER_USB_CLIENT;
1103 type = DEVICE_TYPE_USB_CLIENT;
1106 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &state);
1107 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state.");
1111 value = _DEVICE_MANAGER_STATE_INSERTED;
1115 value = _DEVICE_MANAGER_STATE_REMOVED;
1119 case RUNTIME_INFO_KEY_CHARGER_CONNECTED:
1121 flag = _DEVICE_MANAGER_CHARGER;
1122 type = DEVICE_TYPE_CHARGER;
1125 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &state);
1126 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state.");
1130 value = _DEVICE_MANAGER_STATE_INSERTED;
1134 value = _DEVICE_MANAGER_STATE_REMOVED;
1138 case RUNTIME_INFO_KEY_TV_OUT_CONNECTED:
1140 flag = _DEVICE_MANAGER_TV_OUT;
1141 type = DEVICE_TYPE_TV_OUT;
1144 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &state);
1145 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv connect state.");
1149 value = _DEVICE_MANAGER_STATE_INSERTED;
1153 value = _DEVICE_MANAGER_STATE_REMOVED;
1157 case RUNTIME_INFO_KEY_AUDIO_JACK_STATUS:
1160 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &state);
1161 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio connect state.");
1163 if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED)
1165 if (__headSetType == DEVICE_TYPE_WIRED_HEADPHONE)
1167 flag = _DEVICE_MANAGER_WIRED_HEADPHONE;
1168 type = DEVICE_TYPE_WIRED_HEADPHONE;
1172 flag = _DEVICE_MANAGER_WIRED_HEADSET;
1173 type = DEVICE_TYPE_WIRED_HEADSET;
1176 value = _DEVICE_MANAGER_STATE_REMOVED;
1180 if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
1182 __headSetType = DEVICE_TYPE_WIRED_HEADPHONE;
1183 flag = _DEVICE_MANAGER_WIRED_HEADPHONE;
1184 type = DEVICE_TYPE_WIRED_HEADPHONE;
1188 __headSetType = DEVICE_TYPE_WIRED_HEADSET;
1189 flag = _DEVICE_MANAGER_WIRED_HEADSET;
1190 type = DEVICE_TYPE_WIRED_HEADSET;
1192 value = _DEVICE_MANAGER_STATE_INSERTED;
1197 case RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED:
1199 flag = _DEVICE_MANAGER_KEYBOARD;
1200 type = DEVICE_TYPE_KEYBOARD;
1203 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, &state);
1204 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get built-in keyboard state.");
1208 value = _DEVICE_MANAGER_STATE_OPENED;
1212 value = _DEVICE_MANAGER_STATE_CLOSED;
1220 __pDeviceManagerImpl->SendEvent(type, value);
1225 _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
1227 result r = E_SUCCESS;
1231 SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "GetDeviceState Failed");
1236 case DEVICE_TYPE_BLUETOOTH_HEADSET:
1238 bool bluetooth = false;
1239 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_NETWORK_BLUETOOTH, bluetooth);
1240 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option.");
1241 if (bluetooth == false)
1243 if(!_AppInfo::IsOspCompat())
1245 return E_UNSUPPORTED_OPERATION;
1249 return E_DEVICE_UNAVAILABLE;
1253 ArrayList requestMessages;
1254 ArrayList responseMessages;
1256 requestMessages.Construct();
1257 responseMessages.Construct();
1259 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
1260 String commandId = _DEVICE_MANAGER_COMMAND_STATUS;
1261 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
1263 requestMessages.Add(serviceId);
1264 requestMessages.Add(commandId);
1265 requestMessages.Add(deviceId);
1267 unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
1269 r = __pIpcClient->SendRequest(*(pMsg.get()));
1271 String* pMessageData = (String*)responseMessages.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
1272 if (pMessageData != null)
1274 state = *pMessageData;
1276 responseMessages.RemoveAll(true);
1280 case DEVICE_TYPE_CHARGER:
1282 bool chargerState = false;
1283 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerState);
1284 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state");
1286 if (chargerState == true)
1288 state = _DEVICE_MANAGER_STATE_INSERTED;
1292 state = _DEVICE_MANAGER_STATE_REMOVED;
1297 case DEVICE_TYPE_USB_CLIENT:
1299 bool cableState = false;
1300 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &cableState);
1301 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state");
1303 if (cableState == true)
1305 state = _DEVICE_MANAGER_STATE_INSERTED;
1309 state = _DEVICE_MANAGER_STATE_REMOVED;
1314 case DEVICE_TYPE_TV_OUT:
1317 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
1318 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
1322 if(!_AppInfo::IsOspCompat())
1324 return E_UNSUPPORTED_OPERATION;
1328 return E_DEVICE_UNAVAILABLE;
1332 bool tvState = false;
1333 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &tvState);
1334 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv state");
1335 if (tvState == true)
1337 state = _DEVICE_MANAGER_STATE_INSERTED;
1341 state = _DEVICE_MANAGER_STATE_REMOVED;
1346 case DEVICE_TYPE_WIRED_HEADSET:
1349 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
1350 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
1352 if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE)
1354 state = _DEVICE_MANAGER_STATE_INSERTED;
1358 state = _DEVICE_MANAGER_STATE_REMOVED;
1363 case DEVICE_TYPE_WIRED_HEADPHONE:
1366 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
1367 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
1369 if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
1371 state = _DEVICE_MANAGER_STATE_INSERTED;
1375 state = _DEVICE_MANAGER_STATE_REMOVED;
1380 case DEVICE_TYPE_STORAGE_CARD:
1383 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
1385 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &value);
1389 ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
1391 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
1394 state = _DEVICE_MANAGER_STATE_MOUNTED;
1398 state = _DEVICE_MANAGER_STATE_UNMOUNTED;
1403 case DEVICE_TYPE_KEYBOARD:
1405 bool keyboard = false;
1406 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
1407 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get keyboard option.");
1408 if (keyboard == false)
1410 if(!_AppInfo::IsOspCompat())
1412 return E_UNSUPPORTED_OPERATION;
1416 return E_DEVICE_UNAVAILABLE;
1421 case DEVICE_TYPE_HDMI:
1424 bool supported = false;
1425 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
1426 SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
1428 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
1429 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
1432 state = _DEVICE_MANAGER_STATE_INSERTED;
1436 state = _DEVICE_MANAGER_STATE_REMOVED;
1440 return E_UNSUPPORTED_OPERATION;
1447 return E_INVALID_ARG;
1453 _DeviceManagerImpl::OnDataReceived(const ArrayList& data)
1455 StringComparer stringComparer;
1458 String* pServiceId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_SERVICE_ID);
1459 String* pCommandId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_COMMAND_ID);
1460 String* pDeviceId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_DEVICE_ID);
1461 String* pEventId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
1463 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
1464 String commandId = _DEVICE_MANAGER_COMMAND_EVENT;
1465 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
1467 SysTryReturnVoidResult(NID_SYS, pServiceId != null && pCommandId != null && pDeviceId != null && pEventId != null, E_SYSTEM, "There is no device data.");
1469 if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
1471 serviceId = _DEVICE_MANAGER_SERVICE_ID_EX;
1474 stringComparer.Compare(*pServiceId, serviceId, cmp);
1477 stringComparer.Compare(*pCommandId, commandId, cmp);
1480 stringComparer.Compare(*pDeviceId, deviceId, cmp);
1483 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_BLUETOOTH_HEADSET, *pEventId);
1489 } } // Tizen::System