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
60 static const wchar_t* _DEVICE_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.devicemanager";
61 static const wchar_t* _DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open";
62 static const wchar_t* _DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close";
63 static const wchar_t* _DEVICE_MANAGER_COMMAND_STATUS = L"osp.devicemanager.command.status";
64 static const wchar_t* _DEVICE_MANAGER_COMMAND_EVENT = L"osp.devicemanager.command.event";
65 static const wchar_t* _DEVICE_MANAGER_BLUETOOTH = L"osp.devicemanager.bluetooth";
67 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_SERVICE_ID = 0;
68 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_COMMAND_ID = 1;
69 const int _OSP_APP_SERVICE_IPC_MESSAGE_HEAD_DEVICE_ID = 2;
70 const int _OSP_APP_SERVICE_IPC_MESSAGE_DATA = 3;
72 const int _DEVICE_MANAGER_BLUETOOTH_HEADSET = 0x01;
73 const int _DEVICE_MANAGER_CHARGER = 0x02;
74 const int _DEVICE_MANAGER_USB_CLIENT = 0x04;
75 const int _DEVICE_MANAGER_TV_OUT = 0x08;
76 const int _DEVICE_MANAGER_WIRED_HEADSET = 0x10;
77 const int _DEVICE_MANAGER_WIRED_HEADPHONE = 0x20;
78 const int _DEVICE_MANAGER_STORAGECARD = 0x40;
79 const int _DEVICE_MANAGER_KEYBOARD = 0x80;
81 static const wchar_t* _DEVICE_MANAGER_STATE_INSERTED = L"Inserted";
82 static const wchar_t* _DEVICE_MANAGER_STATE_REMOVED = L"Removed";
83 static const wchar_t* _DEVICE_MANAGER_STATE_MOUNTED = L"Mounted";
84 static const wchar_t* _DEVICE_MANAGER_STATE_UNMOUNTED = L"Unmounted";
85 static const wchar_t* _DEVICE_MANAGER_STATE_OPENED = L"Opened";
86 static const wchar_t* _DEVICE_MANAGER_STATE_CLOSED = L"Closed";
88 static const wchar_t* _SYSTEM_INFO_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
89 static const wchar_t* _SYSTEM_INFO_INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
90 static const wchar_t* _SYSTEM_INFO_TVOUT_SUPPORTED = L"http://tizen.org/feature/screen.output.rca";
91 static const wchar_t* _SYSTEM_INFO_HDMI = L"http://tizen.org/feature/screen.output.hdmi";
93 _DeviceManagerImpl* _DeviceManagerImpl::__pDeviceManagerImpl = null;
95 class _DeviceManagerEventArg : public IEventArg
98 _DeviceManagerEventArg()
101 DeviceType deviceType;
105 class _DeviceManagerEvent : public Event
108 virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
110 IDeviceEventListener* pListener = dynamic_cast<IDeviceEventListener*> (&listener);
111 const _DeviceManagerEventArg* pArg = dynamic_cast<const _DeviceManagerEventArg*>(&arg);
113 SysTryReturnVoidResult(NID_SYS, pListener != null && pArg != null, E_SYSTEM, "Parameters are not available.");
115 pListener->OnDeviceStateChanged(pArg->deviceType, pArg->state);
121 _DeviceManagerImpl::OnDeviceStateChanged(runtime_info_key_e key, void* pData)
123 if (__pDeviceManagerImpl != null)
125 __pDeviceManagerImpl->SendEvent(key);
130 _DeviceManagerImpl::InitDeviceManagerImpl(void)
132 static _DeviceManagerImpl deviceManagerImpl;
133 __pDeviceManagerImpl = &deviceManagerImpl;
136 _DeviceManagerImpl::GetInstance(void)
138 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
139 if(__pDeviceManagerImpl == null)
141 pthread_once(&once_block, InitDeviceManagerImpl);
143 return __pDeviceManagerImpl;
146 _DeviceManagerImpl::_DeviceManagerImpl()
148 , __headSetType(DEVICE_TYPE_WIRED_HEADPHONE)
149 , __bluetoothReferenceCount(0)
150 , __pSystemServiceMessageClient(null)
152 result r = E_SUCCESS;
153 int headsetState = 0;
155 static String DEVICE_MANAGER_SERVICE_ID(_DEVICE_MANAGER_SERVICE_ID);
157 _SystemServiceMessageClient* pSystemServiceMessageClient = _SystemServiceMessageClient::CreateInstance(DEVICE_MANAGER_SERVICE_ID);
158 SysTryCatch(NID_SYS, pSystemServiceMessageClient, r = E_SYSTEM, r, "It is failed to get system service message client.");
159 r = pSystemServiceMessageClient->RegisterListener(DEVICE_MANAGER_SERVICE_ID, *this);
160 SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on Listener.");
162 __pSystemServiceMessageClient = pSystemServiceMessageClient;
163 __pIpcClient = __pSystemServiceMessageClient->GetIpcClient();
165 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, OnDeviceStateChanged, null);
166 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register USB event");
168 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, OnDeviceStateChanged, null);
169 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register DEVICE_TYPE_CHARGER event");
171 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, OnDeviceStateChanged, null);
172 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register TV out event");
174 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, OnDeviceStateChanged, null);
175 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register audio jack event");
177 ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, OnDeviceStateChanged, null);
178 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register sliding keyboard event");
180 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &headsetState);
181 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to get audio jack status");
183 if (headsetState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
185 __headSetType = DEVICE_TYPE_WIRED_HEADPHONE;
187 else if (headsetState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE)
189 __headSetType = DEVICE_TYPE_WIRED_HEADSET;
192 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
194 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, DeviceEventVConfCallBack, null);
198 ret = vconf_notify_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback, null);
200 SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register MMC event callback.");
202 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack, null);
203 SysTryCatch(NID_SYS, ret == 0, r = E_SYSTEM, r, "It is failed to register HDMI event");
205 __deviceEventList.Construct();
211 _DeviceManagerImpl::~_DeviceManagerImpl()
213 result r = E_SUCCESS;
215 _CommunicationDispatcherClient* pCommunicationDispatcherClient = null;
216 String key(_DEVICE_MANAGER_SERVICE_ID);
218 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED);
219 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister USB event");
221 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED);
222 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister TV out event");
224 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS);
225 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister audio jack event");
227 ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED);
228 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister sliding keyboard event");
230 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
232 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, DeviceEventVConfCallBack);
236 ret = vconf_ignore_key_changed(VCONFKEY_APPSERVICE_MMC_STATUS, MmcEventVconfCallback);
238 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister MMC event");
240 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack);
241 SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister HDMI event");
243 if (__pSystemServiceMessageClient)
245 delete __pSystemServiceMessageClient;
253 _DeviceManagerImpl::DeviceEventVConfCallBack(keynode_t* node, void* userData)
259 if (strcmp(VCONFKEY_SYSMAN_MMC_STATUS, vconf_keynode_get_name(node)) == 0)
261 SysLog(NID_SYS, "MMC callback is occured");
262 if (__pDeviceManagerImpl != null)
264 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &value);
267 event = _DEVICE_MANAGER_STATE_MOUNTED;
271 event = _DEVICE_MANAGER_STATE_UNMOUNTED;
273 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_STORAGE_CARD, event);
276 else if(strcmp(VCONFKEY_SYSMAN_HDMI, vconf_keynode_get_name(node)) == 0)
278 if (__pDeviceManagerImpl != null)
280 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
283 event = _DEVICE_MANAGER_STATE_INSERTED;
287 event = _DEVICE_MANAGER_STATE_REMOVED;
289 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_HDMI, event);
296 _DeviceManagerImpl::MmcEventVconfCallback(keynode_t* node, void* userData)
298 if (strcmp(VCONFKEY_APPSERVICE_MMC_STATUS, vconf_keynode_get_name(node)) == 0)
300 SysLog(NID_SYS, "MMC event callback is called.");
301 if (__pDeviceManagerImpl != NULL)
305 int ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
306 SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
310 event = _DEVICE_MANAGER_STATE_MOUNTED;
314 event = _DEVICE_MANAGER_STATE_UNMOUNTED;
316 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_STORAGE_CARD, event);
322 _DeviceManagerImpl::SendEvent(DeviceType deviceType, String& state)
324 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(null);
326 if(__deviceEventList.GetCount() > 0)
328 pEnumerator.reset(__deviceEventList.GetEnumeratorN());
329 SysTryReturnVoidResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
331 while(pEnumerator->MoveNext() == E_SUCCESS)
333 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
334 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
335 SysTryReturnVoidResult(NID_SYS, pDeviceEventListenerContainer != null,E_SYSTEM, "Container is empty");
339 case DEVICE_TYPE_BLUETOOTH_HEADSET:
341 if(pDeviceEventListenerContainer->__bluetoothHeadset == false)
347 case DEVICE_TYPE_CHARGER:
349 if(pDeviceEventListenerContainer->__charger == false)
355 case DEVICE_TYPE_USB_CLIENT:
357 if(pDeviceEventListenerContainer->__usbClient == false)
363 case DEVICE_TYPE_TV_OUT:
365 if(pDeviceEventListenerContainer->__tvOut == false)
371 case DEVICE_TYPE_WIRED_HEADSET:
373 if(pDeviceEventListenerContainer->__wiredHeadset == false)
379 case DEVICE_TYPE_WIRED_HEADPHONE:
381 if(pDeviceEventListenerContainer->__wiredHeadphone == false)
387 case DEVICE_TYPE_STORAGE_CARD:
389 if(pDeviceEventListenerContainer->__storageCard == false)
395 case DEVICE_TYPE_KEYBOARD:
397 if(pDeviceEventListenerContainer->__keyboard == false)
403 case DEVICE_TYPE_HDMI:
405 if(pDeviceEventListenerContainer->__hdmi == false)
414 unique_ptr<_DeviceManagerEventArg> pDeviceManagerEventArg(new (std::nothrow) _DeviceManagerEventArg());
415 SysTryReturnVoidResult(NID_SYS, pDeviceManagerEventArg != null, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
417 pDeviceManagerEventArg->deviceType = deviceType;
418 pDeviceManagerEventArg->state = state;
420 if(pDeviceEventListenerContainer->__pEvent != null)
422 pDeviceEventListenerContainer->__pEvent->Fire(*(pDeviceManagerEventArg.release()));
429 _DeviceManagerImpl::RequireBluetoothEvent(void)
431 result r = E_SUCCESS;
433 SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "Ipc Client is not ready");
435 __bluetoothReferenceCount ++;
437 if(__bluetoothReferenceCount == 1)
439 ArrayList requestMessages;
440 ArrayList responseMessages;
442 r = requestMessages.Construct();
443 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
444 r = responseMessages.Construct();
445 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
447 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
448 String commandId = _DEVICE_MANAGER_COMMAND_OPEN;
449 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
451 r = requestMessages.Add(serviceId);
452 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
453 r = requestMessages.Add(commandId);
454 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
455 r = requestMessages.Add(deviceId);
457 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add device id (bluetooth)");
459 unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
460 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
462 r = GetIpcClient()->SendRequest(pRequest.get());
463 SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "It is failed to add bluetooth id");
464 SysLog(NID_SYS, "It sent %ls", _DEVICE_MANAGER_COMMAND_OPEN);
466 responseMessages.RemoveAll(true);
472 _DeviceManagerImpl::ReleaseBluetoothEvent(void)
474 result r = E_SUCCESS;
475 SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "Ipc Client is not ready");
477 __bluetoothReferenceCount --;
478 SysTryReturnResult(NID_SYS, __bluetoothReferenceCount >= 0, E_SYSTEM, "Fail to manage reference count");
480 if(__bluetoothReferenceCount == 0)
482 ArrayList requestMessages;
483 ArrayList responseMessages;
485 r = requestMessages.Construct();
486 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create request instance");
487 r = responseMessages.Construct();
488 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to create response instance");
490 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
491 String commandId = _DEVICE_MANAGER_COMMAND_CLOSE;
492 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
494 r = requestMessages.Add(serviceId);
495 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add service id");
496 r = requestMessages.Add(commandId);
497 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add command id");
498 r = requestMessages.Add(deviceId);
499 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
501 unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
502 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
504 r = GetIpcClient()->SendRequest(pRequest.get());
505 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
507 responseMessages.RemoveAll(true);
514 _DeviceManagerImpl::GetIpcClient(void)
516 return __pSystemServiceMessageClient->GetIpcClient();
521 _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEventListener* pListener)
523 result r = E_OBJ_NOT_FOUND;
524 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(null);
526 if(__deviceEventList.GetCount() > 0)
528 pEnumerator.reset(__deviceEventList.GetEnumeratorN());
529 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
531 while(pEnumerator->MoveNext() == E_SUCCESS)
533 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
534 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
535 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
536 if(pDeviceEventListenerContainer->__pListener == pListener)
540 case DEVICE_TYPE_BLUETOOTH_HEADSET:
542 if(pDeviceEventListenerContainer->__bluetoothHeadset == true)
544 r = E_OBJ_ALREADY_EXIST;
548 pDeviceEventListenerContainer->__bluetoothHeadset = true;
549 RequireBluetoothEvent();
554 case DEVICE_TYPE_CHARGER:
556 if(pDeviceEventListenerContainer->__charger == true)
558 r = E_OBJ_ALREADY_EXIST;
562 pDeviceEventListenerContainer->__charger = true;
567 case DEVICE_TYPE_USB_CLIENT:
569 if(pDeviceEventListenerContainer->__usbClient == true)
571 r = E_OBJ_ALREADY_EXIST;
575 pDeviceEventListenerContainer->__usbClient = true;
580 case DEVICE_TYPE_TV_OUT:
583 _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
587 if(!_AppInfo::IsOspCompat())
589 r = E_UNSUPPORTED_OPERATION;
593 r = E_DEVICE_UNAVAILABLE;
598 if(pDeviceEventListenerContainer->__tvOut == true)
600 r = E_OBJ_ALREADY_EXIST;
604 pDeviceEventListenerContainer->__tvOut = true;
609 case DEVICE_TYPE_WIRED_HEADSET:
611 if(pDeviceEventListenerContainer->__wiredHeadset == true)
613 r = E_OBJ_ALREADY_EXIST;
617 pDeviceEventListenerContainer->__wiredHeadset = true;
622 case DEVICE_TYPE_WIRED_HEADPHONE:
624 if(pDeviceEventListenerContainer->__wiredHeadphone == true)
626 r = E_OBJ_ALREADY_EXIST;
630 pDeviceEventListenerContainer->__wiredHeadphone = true;
635 case DEVICE_TYPE_STORAGE_CARD:
637 if(pDeviceEventListenerContainer->__storageCard == true)
639 r = E_OBJ_ALREADY_EXIST;
643 pDeviceEventListenerContainer->__storageCard = true;
648 case DEVICE_TYPE_KEYBOARD:
650 bool keyboard = false;
651 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
653 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
655 if (keyboard == false)
657 if(!_AppInfo::IsOspCompat())
659 return E_UNSUPPORTED_OPERATION;
663 return E_DEVICE_UNAVAILABLE;
667 if(pDeviceEventListenerContainer->__keyboard == true)
669 r = E_OBJ_ALREADY_EXIST;
673 pDeviceEventListenerContainer->__keyboard = true;
678 case DEVICE_TYPE_HDMI:
682 bool supported = false;
683 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
684 SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
686 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
687 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
688 SysTryReturnResult(NID_SYS, value >= 0, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
690 if(pDeviceEventListenerContainer->__hdmi == true)
692 r = E_OBJ_ALREADY_EXIST;
696 pDeviceEventListenerContainer->__hdmi = true;
709 _DeviceManagerImpl::AddDeviceEventListener(DeviceType deviceType, IDeviceEventListener* pListener)
711 SysTryReturnResult(NID_SYS, pListener != null, E_INVALID_ARG, "There is no listener isntance.");
712 SysTryReturnResult(NID_SYS, (deviceType >= DEVICE_TYPE_BLUETOOTH_HEADSET && deviceType <= DEVICE_TYPE_HDMI), E_INVALID_ARG, "There is no listener isntance.");
713 result r = E_SUCCESS;
715 if(deviceType == DEVICE_TYPE_TV_OUT)
718 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
719 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
723 if(!_AppInfo::IsOspCompat())
725 r = E_UNSUPPORTED_OPERATION;
729 r = E_DEVICE_UNAVAILABLE;
734 else if(deviceType == DEVICE_TYPE_KEYBOARD)
736 bool keyboard = false;
737 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
739 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
741 if (keyboard == false)
743 if(!_AppInfo::IsOspCompat())
745 r = E_UNSUPPORTED_OPERATION;
749 r = E_DEVICE_UNAVAILABLE;
754 else if(deviceType == DEVICE_TYPE_HDMI)
758 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
759 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
762 return E_UNSUPPORTED_OPERATION;
766 r = AddOnExistedListener(deviceType, pListener);
768 if(r == E_OBJ_NOT_FOUND)
770 unique_ptr<_DeviceEventListenerContainer> pDeviceEventContainer(new (std::nothrow) _DeviceEventListenerContainer());
771 SysTryReturnResult(NID_SYS, pDeviceEventContainer != null, E_OUT_OF_MEMORY, "It is failed to create instance of _DeviceEventListenerContainer");
773 unique_ptr<_DeviceManagerEvent> pDeviceManagerEvent(new (std::nothrow) _DeviceManagerEvent());
774 SysTryReturnResult(NID_SYS, pDeviceManagerEvent != null, E_OUT_OF_MEMORY, "It is failed to create instance of _DeviceManagerEvent");
776 pDeviceManagerEvent->AddListener(*pListener);
777 pDeviceEventContainer->__pListener = pListener;
778 pDeviceEventContainer->__pEvent = pDeviceManagerEvent.release();
782 case DEVICE_TYPE_BLUETOOTH_HEADSET:
784 pDeviceEventContainer->__bluetoothHeadset = true;
785 RequireBluetoothEvent();
788 case DEVICE_TYPE_CHARGER:
790 pDeviceEventContainer->__charger = true;
793 case DEVICE_TYPE_USB_CLIENT:
795 pDeviceEventContainer->__usbClient = true;
798 case DEVICE_TYPE_TV_OUT:
801 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
802 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
806 if(!_AppInfo::IsOspCompat())
808 return E_UNSUPPORTED_OPERATION;
812 return E_DEVICE_UNAVAILABLE;
816 pDeviceEventContainer->__tvOut = true;
819 case DEVICE_TYPE_WIRED_HEADSET:
821 pDeviceEventContainer->__wiredHeadset = true;
824 case DEVICE_TYPE_WIRED_HEADPHONE:
826 pDeviceEventContainer->__wiredHeadphone = true;
829 case DEVICE_TYPE_STORAGE_CARD:
831 pDeviceEventContainer->__storageCard = true;
834 case DEVICE_TYPE_KEYBOARD:
836 bool keyboard = false;
837 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
839 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
841 if (keyboard == false)
843 if(!_AppInfo::IsOspCompat())
845 return E_UNSUPPORTED_OPERATION;
849 return E_DEVICE_UNAVAILABLE;
853 pDeviceEventContainer->__keyboard = true;
856 case DEVICE_TYPE_HDMI:
860 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
861 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
864 return E_UNSUPPORTED_OPERATION;
866 pDeviceEventContainer->__hdmi = true;
871 __deviceEventList.Add(pDeviceEventContainer.release());
878 _DeviceManagerImpl::RemoveDeviceEventListener(DeviceType deviceType, IDeviceEventListener* pListener)
880 result r = E_SUCCESS;
882 SysTryReturnResult(NID_SYS, pListener != null, E_INVALID_ARG, "There is no listener isntance.");
883 SysTryReturnResult(NID_SYS, (deviceType >= DEVICE_TYPE_BLUETOOTH_HEADSET && deviceType <= DEVICE_TYPE_HDMI), E_INVALID_ARG, "There is no listener isntance.");
884 SysTryReturnResult(NID_SYS, __deviceEventList.GetCount() > 0, E_INVALID_ARG, "There is no registered listener.");
886 unique_ptr< IEnumeratorT<_DeviceEventListenerContainer*> > pEnumerator(__deviceEventList.GetEnumeratorN());
888 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
890 if(deviceType == DEVICE_TYPE_TV_OUT)
893 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
894 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
898 if(!_AppInfo::IsOspCompat())
900 r = E_UNSUPPORTED_OPERATION;
904 r = E_DEVICE_UNAVAILABLE;
909 else if(deviceType == DEVICE_TYPE_KEYBOARD)
911 bool keyboard = false;
912 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
914 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option");
916 if (keyboard == false)
918 if(!_AppInfo::IsOspCompat())
920 r = E_UNSUPPORTED_OPERATION;
924 r = E_DEVICE_UNAVAILABLE;
928 else if(deviceType == DEVICE_TYPE_HDMI)
932 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
933 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
936 return E_UNSUPPORTED_OPERATION;
940 while(pEnumerator->MoveNext() == E_SUCCESS)
942 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
943 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
944 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
946 if(pDeviceEventListenerContainer->__pListener == pListener)
950 case DEVICE_TYPE_BLUETOOTH_HEADSET:
952 if(pDeviceEventListenerContainer->__bluetoothHeadset == false)
954 return E_OBJ_NOT_FOUND;
956 pDeviceEventListenerContainer->__bluetoothHeadset = false;
957 ReleaseBluetoothEvent();
960 case DEVICE_TYPE_CHARGER:
962 if(pDeviceEventListenerContainer->__charger == false)
964 return E_OBJ_NOT_FOUND;
966 pDeviceEventListenerContainer->__charger = false;
969 case DEVICE_TYPE_USB_CLIENT:
971 if(pDeviceEventListenerContainer->__usbClient == false)
973 return E_OBJ_NOT_FOUND;
975 pDeviceEventListenerContainer->__usbClient = false;
978 case DEVICE_TYPE_TV_OUT:
980 if(pDeviceEventListenerContainer->__tvOut == false)
982 return E_OBJ_NOT_FOUND;
984 pDeviceEventListenerContainer->__tvOut = false;
987 case DEVICE_TYPE_WIRED_HEADSET:
989 if(pDeviceEventListenerContainer->__wiredHeadset == false)
991 return E_OBJ_NOT_FOUND;
993 pDeviceEventListenerContainer->__wiredHeadset = false;
996 case DEVICE_TYPE_WIRED_HEADPHONE:
998 if(pDeviceEventListenerContainer->__wiredHeadphone == false)
1000 return E_OBJ_NOT_FOUND;
1002 pDeviceEventListenerContainer->__wiredHeadphone = false;
1005 case DEVICE_TYPE_STORAGE_CARD:
1007 if(pDeviceEventListenerContainer->__storageCard == false)
1009 return E_OBJ_NOT_FOUND;
1011 pDeviceEventListenerContainer->__storageCard = false;
1014 case DEVICE_TYPE_KEYBOARD:
1016 if(pDeviceEventListenerContainer->__keyboard == false)
1018 return E_OBJ_NOT_FOUND;
1020 pDeviceEventListenerContainer->__keyboard = false;
1023 case DEVICE_TYPE_HDMI:
1025 if(pDeviceEventListenerContainer->__hdmi == false)
1027 return E_OBJ_NOT_FOUND;
1029 pDeviceEventListenerContainer->__hdmi = false;
1034 if(pDeviceEventListenerContainer->IsInvalid() == true)
1036 __deviceEventList.Remove(pDeviceEventListenerContainer);
1037 delete pDeviceEventListenerContainer;
1042 return E_OBJ_NOT_FOUND;
1046 _DeviceManagerImpl::RemoveAllDeviceEventListeners(void)
1048 result r = E_SUCCESS;
1050 IEnumeratorT<_DeviceEventListenerContainer*>* pEnumerator = __deviceEventList.GetEnumeratorN();
1051 SysTryReturnResult(NID_SYS, pEnumerator != null, E_SYSTEM, "Enumerator is empty.");
1053 while(pEnumerator->MoveNext() == E_SUCCESS)
1055 _DeviceEventListenerContainer* pDeviceEventListenerContainer = null;
1056 pEnumerator->GetCurrent(pDeviceEventListenerContainer);
1057 SysTryReturnResult(NID_SYS, pDeviceEventListenerContainer != null, E_SYSTEM, "[E_SYSTEM] Device Event Container is empty.");
1058 __deviceEventList.Remove(pDeviceEventListenerContainer);
1059 delete pDeviceEventListenerContainer;
1063 __bluetoothReferenceCount = 1;
1065 ReleaseBluetoothEvent();
1070 _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
1072 DeviceType type = DEVICE_TYPE_USB_CLIENT;
1079 case RUNTIME_INFO_KEY_USB_CONNECTED:
1081 flag = _DEVICE_MANAGER_USB_CLIENT;
1082 type = DEVICE_TYPE_USB_CLIENT;
1085 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &state);
1086 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state.");
1090 value = _DEVICE_MANAGER_STATE_INSERTED;
1094 value = _DEVICE_MANAGER_STATE_REMOVED;
1098 case RUNTIME_INFO_KEY_CHARGER_CONNECTED:
1100 flag = _DEVICE_MANAGER_CHARGER;
1101 type = DEVICE_TYPE_CHARGER;
1104 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &state);
1105 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state.");
1109 value = _DEVICE_MANAGER_STATE_INSERTED;
1113 value = _DEVICE_MANAGER_STATE_REMOVED;
1117 case RUNTIME_INFO_KEY_TV_OUT_CONNECTED:
1119 flag = _DEVICE_MANAGER_TV_OUT;
1120 type = DEVICE_TYPE_TV_OUT;
1123 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &state);
1124 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv connect state.");
1128 value = _DEVICE_MANAGER_STATE_INSERTED;
1132 value = _DEVICE_MANAGER_STATE_REMOVED;
1136 case RUNTIME_INFO_KEY_AUDIO_JACK_STATUS:
1139 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &state);
1140 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio connect state.");
1142 if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED)
1144 if (__headSetType == DEVICE_TYPE_WIRED_HEADPHONE)
1146 flag = _DEVICE_MANAGER_WIRED_HEADPHONE;
1147 type = DEVICE_TYPE_WIRED_HEADPHONE;
1151 flag = _DEVICE_MANAGER_WIRED_HEADSET;
1152 type = DEVICE_TYPE_WIRED_HEADSET;
1155 value = _DEVICE_MANAGER_STATE_REMOVED;
1159 if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
1161 __headSetType = DEVICE_TYPE_WIRED_HEADPHONE;
1162 flag = _DEVICE_MANAGER_WIRED_HEADPHONE;
1163 type = DEVICE_TYPE_WIRED_HEADPHONE;
1167 __headSetType = DEVICE_TYPE_WIRED_HEADSET;
1168 flag = _DEVICE_MANAGER_WIRED_HEADSET;
1169 type = DEVICE_TYPE_WIRED_HEADSET;
1171 value = _DEVICE_MANAGER_STATE_INSERTED;
1176 case RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED:
1178 flag = _DEVICE_MANAGER_KEYBOARD;
1179 type = DEVICE_TYPE_KEYBOARD;
1182 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, &state);
1183 SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get built-in keyboard state.");
1187 value = _DEVICE_MANAGER_STATE_OPENED;
1191 value = _DEVICE_MANAGER_STATE_CLOSED;
1199 __pDeviceManagerImpl->SendEvent(type, value);
1204 _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
1206 result r = E_SUCCESS;
1210 SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "GetDeviceState Failed");
1215 case DEVICE_TYPE_BLUETOOTH_HEADSET:
1217 bool bluetooth = false;
1218 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_NETWORK_BLUETOOTH, bluetooth);
1219 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option.");
1220 if (bluetooth == false)
1222 if(!_AppInfo::IsOspCompat())
1224 return E_UNSUPPORTED_OPERATION;
1228 return E_DEVICE_UNAVAILABLE;
1232 ArrayList requestMessages;
1233 ArrayList responseMessages;
1235 requestMessages.Construct();
1236 responseMessages.Construct();
1238 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
1239 String commandId = _DEVICE_MANAGER_COMMAND_STATUS;
1240 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
1242 requestMessages.Add(serviceId);
1243 requestMessages.Add(commandId);
1244 requestMessages.Add(deviceId);
1246 unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
1248 r = GetIpcClient()->SendRequest(*(pMsg.get()));
1250 String* pMessageData = (String*)responseMessages.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
1251 if (pMessageData != null)
1253 state = *pMessageData;
1255 responseMessages.RemoveAll(true);
1259 case DEVICE_TYPE_CHARGER:
1261 bool chargerState = false;
1262 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &chargerState);
1263 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state");
1265 if (chargerState == true)
1267 state = _DEVICE_MANAGER_STATE_INSERTED;
1271 state = _DEVICE_MANAGER_STATE_REMOVED;
1276 case DEVICE_TYPE_USB_CLIENT:
1278 bool cableState = false;
1279 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &cableState);
1280 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state");
1282 if (cableState == true)
1284 state = _DEVICE_MANAGER_STATE_INSERTED;
1288 state = _DEVICE_MANAGER_STATE_REMOVED;
1293 case DEVICE_TYPE_TV_OUT:
1296 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_TVOUT_SUPPORTED, tvOut);
1297 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get tvout option.");
1301 if(!_AppInfo::IsOspCompat())
1303 return E_UNSUPPORTED_OPERATION;
1307 return E_DEVICE_UNAVAILABLE;
1311 bool tvState = false;
1312 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &tvState);
1313 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv state");
1314 if (tvState == true)
1316 state = _DEVICE_MANAGER_STATE_INSERTED;
1320 state = _DEVICE_MANAGER_STATE_REMOVED;
1325 case DEVICE_TYPE_WIRED_HEADSET:
1328 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
1329 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
1331 if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE)
1333 state = _DEVICE_MANAGER_STATE_INSERTED;
1337 state = _DEVICE_MANAGER_STATE_REMOVED;
1342 case DEVICE_TYPE_WIRED_HEADPHONE:
1345 ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &audioState);
1346 SysTryReturnResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio state");
1348 if (audioState == RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE)
1350 state = _DEVICE_MANAGER_STATE_INSERTED;
1354 state = _DEVICE_MANAGER_STATE_REMOVED;
1359 case DEVICE_TYPE_STORAGE_CARD:
1362 if (!_AppInfo::IsOspCompat() && !_AppInfo::IsVirtualRoot())
1364 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &value);
1368 ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
1370 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
1373 state = _DEVICE_MANAGER_STATE_MOUNTED;
1377 state = _DEVICE_MANAGER_STATE_UNMOUNTED;
1382 case DEVICE_TYPE_KEYBOARD:
1384 bool keyboard = false;
1385 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
1386 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get keyboard option.");
1387 if (keyboard == false)
1389 if(!_AppInfo::IsOspCompat())
1391 return E_UNSUPPORTED_OPERATION;
1395 return E_DEVICE_UNAVAILABLE;
1400 case DEVICE_TYPE_HDMI:
1403 bool supported = false;
1404 r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
1405 SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
1407 ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
1408 SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
1411 state = _DEVICE_MANAGER_STATE_INSERTED;
1415 state = _DEVICE_MANAGER_STATE_REMOVED;
1419 return E_UNSUPPORTED_OPERATION;
1426 return E_INVALID_ARG;
1432 _DeviceManagerImpl::OnDataReceived(const ArrayList& data)
1434 StringComparer stringComparer;
1437 String* pServiceId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_SERVICE_ID);
1438 String* pCommandId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_COMMAND_ID);
1439 String* pDeviceId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_HEAD_DEVICE_ID);
1440 String* pEventId = (String*) data.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
1442 String serviceId = _DEVICE_MANAGER_SERVICE_ID;
1443 String commandId = _DEVICE_MANAGER_COMMAND_EVENT;
1444 String deviceId = _DEVICE_MANAGER_BLUETOOTH;
1446 SysTryReturnVoidResult(NID_SYS, pServiceId != null && pCommandId != null && pDeviceId != null && pEventId != null, E_SYSTEM, "There is no device data.");
1448 stringComparer.Compare(*pServiceId, serviceId, cmp);
1451 stringComparer.Compare(*pCommandId, commandId, cmp);
1454 stringComparer.Compare(*pDeviceId, deviceId, cmp);
1457 __pDeviceManagerImpl->SendEvent(DEVICE_TYPE_BLUETOOTH_HEADSET, *pEventId);
1463 } } // Tizen::System