#include <new>
#include <system/media_key.h>
#include <bluetooth.h>
+#include <vconf.h>
#include <FBaseSysLog.h>
#include <FSys_DeviceManagerEventProvider.h>
IDeviceEventListener* pDeviceEventListener = pDeviceManager->GetEventListener();
- if(pDeviceManager->GetBluetoothStatus() != connected && pDeviceEventListener)
+ if(pDeviceEventListener)
{
if(connected == true)
{
pDeviceEventListener->OnDeviceStateChanged(DEVICE_TYPE_BLUETOOTH_HEADSET, bt_event);
}
pDeviceManager->SetBluetoothStatus(connected);
- SysLog(NID_SYS, "It is success to call OnDeviceStateChanged 0x%x.", pDeviceEventListener);
}
void app_media_key_handler(media_key_e key, media_key_event_e status, void* pUserData)
}
media_key_reserve(app_media_key_handler, null);
- SysLog(NID_SYS,"It is success.");
return r;
}
result
_DeviceManager::DeinitializeDevice(void)
{
- SysLog(NID_SYS,"It is success DeinitializeDevice.");
result r = E_SUCCESS;
media_key_release();
return r;
result
_DeviceManager::RegisterListner(IDeviceEventListener &listener)
{
- SysLog(NID_SYS,"RegisterListner 0x%x.", &listener);
__pDeviceManagerListener = &listener;
return E_SUCCESS;
}
result
_DeviceManager::UnregisterListner(IDeviceEventListener &listener)
{
- SysLog(NID_SYS,"UnregisterListner 0x%x.", &listener);
__pDeviceManagerListener = null;
return E_SUCCESS;
}
bool
_DeviceManager::GetBluetoothStatus(void)
{
+ int ret = -1;
+ int errorCode = vconf_get_int(VCONFKEY_BT_DEVICE, &ret);
+ SysTryReturn(NID_SYS, errorCode == 0, isBluetoothHeadSetConnected, E_SYSTEM, "It is failed to get bt status. errorCode [%d]", errorCode);
+
+ if (ret & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED || ret & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED)
+ {
+ isBluetoothHeadSetConnected = true;
+ }
+ else
+ {
+ isBluetoothHeadSetConnected = false;
+ }
return isBluetoothHeadSetConnected;
}
void
, __headSetType(DEVICE_TYPE_WIRED_HEADPHONE)
, __bluetoothReferenceCount(0)
, __pSystemServiceMessageClient(null)
+ , __isCommonService(true)
{
result r = E_SUCCESS;
int headsetState = 0;
int ret = 0;
static String DEVICE_MANAGER_SERVICE_ID(_DEVICE_MANAGER_SERVICE_ID);
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
+ if (Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
{
- SysLog(NID_SYS, "Device Manager is service by common-service.");
+ __isCommonService = true;
+ }
+
+ if (__isCommonService == true)
+ {
+ SysLog(NID_SYS, "Device Manager is serviced by common-service.");
_SystemServiceMessageClient* pSystemServiceMessageClient = _SystemServiceMessageClient::CreateInstance(_DEVICE_MANAGER_SERVICE_ID_EX);
SysTryCatch(NID_SYS, pSystemServiceMessageClient, r = E_SYSTEM, r, "It is failed to get system service message client.");
r = pSystemServiceMessageClient->RegisterListener(_DEVICE_MANAGER_SERVICE_ID_EX, *this);
SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on Listener.");
- SysLog(NID_SYS, "Device listner 0x%x", this);
__pSystemServiceMessageClient = pSystemServiceMessageClient;
__pIpcClient = __pSystemServiceMessageClient->GetIpcClient();
}
else
{
- SysLog(NID_SYS, "Device Manager is service by app-service.");
+ SysLog(NID_SYS, "Device Manager is serviced by app-service.");
_CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack);
SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister HDMI event");
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
+ if (__isCommonService == true)
{
if (__pSystemServiceMessageClient)
{
r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key);
SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
}
+
__pIpcClient = null;
CATCH:
SetLastResult(r);
{
result r = E_SUCCESS;
- SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "Ipc Client is not ready");
+ SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "Ipc Client is not ready");
__bluetoothReferenceCount ++;
unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
- r = __pIpcClient->SendRequest(pRequest.get());
+ r = GetIpcClient()->SendRequest(pRequest.get());
SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "It is failed to add bluetooth id");
SysLog(NID_SYS, "It sent %ls", _DEVICE_MANAGER_COMMAND_OPEN);
_DeviceManagerImpl::ReleaseBluetoothEvent(void)
{
result r = E_SUCCESS;
- SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "Ipc Client is not ready");
+ SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "Ipc Client is not ready");
__bluetoothReferenceCount --;
SysTryReturnResult(NID_SYS, __bluetoothReferenceCount >= 0, E_SYSTEM, "Fail to manage reference count");
unique_ptr<IoService_Request> pRequest(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send bluetooth event subscribe by IPC");
- r = __pIpcClient->SendRequest(pRequest.get());
+ r = GetIpcClient()->SendRequest(pRequest.get());
SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add bluetooth id");
responseMessages.RemoveAll(true);
return r;
}
+
+_IpcClient*
+_DeviceManagerImpl::GetIpcClient(void)
+{
+ if (__isCommonService == true)
+ {
+ return __pSystemServiceMessageClient->GetIpcClient();
+ }
+ return __pIpcClient;
+}
+
+
result
_DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEventListener* pListener)
{
int value = 0;
int ret = 0;
- SysTryReturnResult(NID_SYS, __pIpcClient != null, E_SYSTEM, "GetDeviceState Failed");
+ SysTryReturnResult(NID_SYS, GetIpcClient() != null, E_SYSTEM, "GetDeviceState Failed");
switch (deviceType)
{
unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
- r = __pIpcClient->SendRequest(*(pMsg.get()));
+ r = GetIpcClient()->SendRequest(*(pMsg.get()));
String* pMessageData = (String*)responseMessages.GetAt(_OSP_APP_SERVICE_IPC_MESSAGE_DATA);
if (pMessageData != null)
SysTryReturnVoidResult(NID_SYS, pServiceId != null && pCommandId != null && pDeviceId != null && pEventId != null, E_SYSTEM, "There is no device data.");
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_devicemanager") == true)
+ if (__isCommonService == true)
{
serviceId = _DEVICE_MANAGER_SERVICE_ID_EX;
}
result ReleaseBluetoothEvent(void);
+ Tizen::Io::_IpcClient* GetIpcClient(void);
+
static void OnDeviceStateChanged(runtime_info_key_e key, void* pData);
static void DeviceEventVConfCallBack(keynode_t* node, void* userData);
private:
Tizen::Io::_IpcClient* __pIpcClient;
-
DeviceType __headSetType;
-
int __bluetoothReferenceCount;
-
Tizen::Base::Collection::ArrayListT<_DeviceEventListenerContainer*> __deviceEventList;
-
static _DeviceManagerImpl* __pDeviceManagerImpl;
_SystemServiceMessageClient* __pSystemServiceMessageClient;
+ bool __isCommonService;
};
}} // Tizen::System
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.");
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_powermanager") == true)
+// 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
+/* 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.");
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_powermanager") == true)
+// 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
+/* 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();
_RuntimeClientEx::_RuntimeClientEx()
: __msgCount(0)
- , __pIpcClient(null)
, __pMessageClient(null)
{
result r = E_SUCCESS;
r = __pMessageClient->RegisterListener(RUNTIME_SERVICE_ID, *this);
SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on MessageClient.");
- __pIpcClient = __pMessageClient->GetIpcClient();
-
__asyncEventList.Construct();
CATCH:
SetLastResult(r);
SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on MessageClient.");
__asyncEventList.RemoveAll(true);
- __pIpcClient = null;
delete __pMessageClient;
CATCH:
SetLastResult(r);
requestMessages.Add(messageId);
unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
- r = __pIpcClient->SendRequest(*pMsg);
+ r = __pMessageClient->GetIpcClient()->SendRequest(*pMsg);
SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send request by IPC [%s]", GetErrorMessage(r));
String* pResult = (String*)responseMessages.GetAt(2);
private:
Tizen::Base::Collection::HashMap __asyncEventList;
int __msgCount;
- Tizen::Io::_IpcClient* __pIpcClient;
_SystemServiceMessageClient* __pMessageClient;
static _RuntimeClientEx* __pRuntimeClientEx;
};
SysLog(NID_SYS, "%ls", directoryPath.GetPointer());
if(r == E_SUCCESS)
{
- if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_runtime") == true)
+// if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_runtime") == true)
{
SysLog(NID_SYS, "Runtime is serviced by common-service.");
_RuntimeClientEx* pRuntimeClientEx = _RuntimeClientEx::GetInstance();
pRuntimeClientEx->GetDirectorySizeValueAsync(directoryPath, listener);
}
- else
+/* else
{
SysLog(NID_SYS, "Runtime is serviced by app-service.");
_RuntimeClient* pRuntimeClient = _RuntimeClient::GetInstance();
pRuntimeClient->GetDirectorySizeValueAsync(directoryPath, listener);
}
+*/
}
return r;
* @file FSys_SystemServiceMessageClient.cpp
* @brief This is the implementation file for _SystemServiceMessageClient class.
*/
+#include <unistd.h>
+#include <sys/types.h>
#include <FApp_AppInfo.h>
#include <FBaseSysLog.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <FBaseRtThread.h>
#include <FIo_AppServiceIpcMessages.h>
#include "FSys_SystemServiceMessageClient.h"
temp->RemoveAll(true);
}
+void
+_SystemServiceMessageClient::OnIpcServerDisconnected(_IpcClient& client)
+{
+ SysLogException(NID_SYS, E_SYSTEM, "The IpcServer was disconnected. [%ls].", client.GetName().GetPointer());
+ result r = E_SUCCESS;
+ std::unique_ptr< _IpcClient > pIpcClient(new (std::nothrow) _IpcClient());
+ SysTryReturn(NID_SYS, pIpcClient != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is failed to create IPC client");
+
+ int retry = 0;
+ do
+ {
+ r = pIpcClient->Construct(client.GetName(), this);
+ retry++;
+ Tizen::Base::Runtime::Thread::Sleep(1000);
+ }while (r != E_SUCCESS && retry < 10);
+
+ SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "Propagated. [%s]", GetErrorMessage(r));
+
+ __pIpcClient.reset(pIpcClient.release());
+}
+
}}
result UnregisterListener(const Tizen::Base::String key);
void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+ void OnIpcServerDisconnected(Tizen::Io::_IpcClient& client);
Tizen::Io::_IpcClient* GetIpcClient(void);
static _SystemServiceMessageClient* CreateInstance(const Tizen::Base::String id);