Fix serialport
authorJoohyun Kim <joohyune.kim@samsung.com>
Wed, 17 Apr 2013 13:12:24 +0000 (22:12 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Wed, 17 Apr 2013 13:20:03 +0000 (22:20 +0900)
Change-Id: Id5bd73677dd5aed7879ee447ffc0d650b28b8e9c
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
plugins/accessory-condition-handler/AccessoryMonitor.cpp
src/system/FSys_SystemInfo.cpp

index e6cb4aa..a8e45c0 100644 (file)
@@ -28,6 +28,7 @@ using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
+using namespace Tizen::System;
 
 namespace{
        const String SERIAL_COMMAND_OPEN(L"Open");
@@ -54,6 +55,7 @@ AccessoryMonitor::AccessoryMonitor()
 : __pAccessoryConditionHandler(null)
 , __pDataRouter(null)
 , __currentPid(0)
+, __pAccessoryManagerService(null)
 {
 }
 
@@ -71,15 +73,14 @@ result
 AccessoryMonitor::Construct(AccessoryConditionHandler* pConditionHandler)
 {
        result r = E_SUCCESS;
-       SysTryReturnResult(NID_APP, pConditionHandler != null, E_INVALID_ARG, "pConditionHandler is empty");
+       SysTryReturnResult(NID_SYS, pConditionHandler != null, E_INVALID_ARG, "pConditionHandler is empty");
 
        __pAccessoryConditionHandler = pConditionHandler;
-       SysTryReturnResult(NID_APP, __pDataRouter == null, E_INVALID_STATE, "AccessoryMonitor is already constructed.");
+       SysTryReturnResult(NID_SYS, __pDataRouter == null, E_INVALID_STATE, "AccessoryMonitor is already constructed.");
 
        __pDataRouter = _DataRouter::GetInstance();
        r = __pDataRouter->Construct(*this);
-       SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "DataRouter is not constructed.");
-
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "DataRouter is not constructed.");
        return E_SUCCESS;
 }
 
@@ -110,8 +111,9 @@ AccessoryMonitor::ReleaseInstance(void)
 void
 AccessoryMonitor::OnDataRouterDataReceivedN(const char* buffer, int length)
 {
-       SysLog(NID_IO, "serial data is forwarded to AccessoryMonitor class");
-       SysTryReturnVoidResult(NID_APP, buffer != null, E_INVALID_ARG, "[E_INVALID_ARG] buffer should not be null.");
+       result r = E_SUCCESS;
+       SysLog(NID_SYS, "serial data is forwarded to AccessoryMonitor class");
+       SysTryReturnVoidResult(NID_SYS, buffer != null, E_INVALID_ARG, "[E_INVALID_ARG] buffer should not be null.");
 
        bool primitiveCommand = false;
        if(__pAccessoryConditionHandler != null)
@@ -121,7 +123,7 @@ AccessoryMonitor::OnDataRouterDataReceivedN(const char* buffer, int length)
 
        if(primitiveCommand == false)
        {
-               SysLog(NID_IO, "Requested data is not command. it will be forwarded to current application");
+               SysLog(NID_SYS, "Requested data is not command. it will be forwarded to current application[%d]", __currentPid);
                if(__currentPid > 0)
                {
                        ArrayList* pDataList = new (std::nothrow) ArrayList();
@@ -144,11 +146,16 @@ AccessoryMonitor::OnDataRouterDataReceivedN(const char* buffer, int length)
                        pDataList->Add(*pCommand);
                        pDataList->Add(*pByteBuffer);
 
+
                        if(sendFunction!=null)
                        {
-                               SysLog(NID_IO, "Data is forwarded to [%d]", __currentPid);
+                               SysLog(NID_SYS, "Data is forwarded to [%d]", __currentPid);
                                sendFunction(__currentPid, pDataList);
                        }
+                       else
+                       {
+                               SysLog(NID_SYS, "sendFunction is empty.");
+                       }
 
                        pDataList->RemoveAll(true);
                        delete(pDataList);
@@ -159,13 +166,13 @@ AccessoryMonitor::OnDataRouterDataReceivedN(const char* buffer, int length)
 result
 AccessoryMonitor::SendData(char* buffer, int length)
 {
-       SysTryReturnResult(NID_APP, __pDataRouter != null, E_INVALID_STATE, "[E_INVALID_STATE] AccessoryMonitor is not constructed.");
+       SysTryReturnResult(NID_SYS, __pDataRouter != null, E_INVALID_STATE, "[E_INVALID_STATE] AccessoryMonitor is not constructed.");
        return __pDataRouter->Write(buffer, length);
 }
 void
 AccessoryMonitor::OnDataRouterStateChanged(_DataRouterState state)
 {
-       SysLog(NID_IO, "STATE is changed %d", (int)state);
+       SysLog(NID_SYS, "STATE is changed %d", (int)state);
 }
 
 int
@@ -177,6 +184,7 @@ AccessoryMonitor::GetClientPid()
 void
 AccessoryMonitor::SetClientPid(int pid)
 {
+       SysLog(NID_SYS, "Accessory Application's pid is %d.", pid);
        __currentPid = pid;
 }
 
@@ -189,6 +197,7 @@ extern "C"
 _OSP_EXPORT_ void
 RegisterSendData(SendDataFunction function)
 {
+       SysLog(NID_SYS, "Send function[%x] is registered for Accessory.", function);
        sendFunction = function;
 }
 
@@ -198,8 +207,11 @@ RemoveOwnerApplication(const AppId appId, int pid, const String& executableName)
        AccessoryMonitor* pAccessoryMonitor = AccessoryMonitor::GetInstance();
        if(pAccessoryMonitor != null)
        {
-               SysLog(NID_IO, "Accessory Owner is removed [%ls, %d, %ls]", appId.GetPointer(), pid, executableName.GetPointer());
-               pAccessoryMonitor->SetClientPid(0);
+               SysLog(NID_SYS, "Accessory Owner is removed [%ls, %d, %ls]", appId.GetPointer(), pid, executableName.GetPointer());
+               if(pAccessoryMonitor->GetClientPid() == pid)
+               {
+                       pAccessoryMonitor->SetClientPid(0);
+               }
        }
 }
 
@@ -210,20 +222,21 @@ OnRequestOccured(AppId appId, int pid, ArrayList* pRequest, ArrayList* pResponse
        AccessoryMonitor* pAccessoryMonitor = AccessoryMonitor::GetInstance();
 
        result r = E_SUCCESS;
-       SysTryCatch(NID_APP, pRequest != null, r = E_SYSTEM, E_SYSTEM, "There is no pRequest");
-       SysTryCatch(NID_APP, pResponse != null, r = E_SYSTEM, E_SYSTEM, "There is no pResponse");
-       SysTryCatch(NID_APP, pAccessoryMonitor != null, r = E_SYSTEM, E_SYSTEM, "AccessoryMonitor is not ready");
+       SysLog(NID_SYS, "Application[%ls/%d] requests to AccessoryMonitor.", appId.GetPointer(), pid);
+       SysTryCatch(NID_SYS, pRequest != null, r = E_SYSTEM, E_SYSTEM, "There is no pRequest");
+       SysTryCatch(NID_SYS, pResponse != null, r = E_SYSTEM, E_SYSTEM, "There is no pResponse");
+       SysTryCatch(NID_SYS, pAccessoryMonitor != null, r = E_SYSTEM, E_SYSTEM, "AccessoryMonitor is not ready");
 
        pCommand = static_cast< String* > (pRequest->GetAt(SERIAL_DATA_HEAD));
 
-       SysTryCatch(NID_APP, pCommand != null, , E_SYSTEM, "There is no command");
+       SysTryCatch(NID_SYS, pCommand != null, , E_SYSTEM, "There is no command");
 
-       SysLog(NID_IO, "Request: %ls", pCommand->GetPointer());
+       SysLog(NID_SYS, "Request: %ls", pCommand->GetPointer());
 
        if(pCommand->Equals(SERIAL_COMMAND_OPEN, true))
        {
-               SysLog(NID_IO, "Serial open is required");
-               SysTryCatch(NID_APP, pAccessoryMonitor->GetClientPid() == 0, , E_SYSTEM, "Serial port is already used by [%d]", pAccessoryMonitor->GetClientPid());
+               SysLog(NID_SYS, "Serial open is required to AccessoryMonitor.");
+               SysTryCatch(NID_SYS, pAccessoryMonitor->GetClientPid() == 0, , E_SYSTEM, "Serial port is already used by [%d]", pAccessoryMonitor->GetClientPid());
                pAccessoryMonitor->SetClientPid(pid);
                String* pResult = new (std::nothrow) String(SERIAL_COMMAND_OK);
 
@@ -231,10 +244,10 @@ OnRequestOccured(AppId appId, int pid, ArrayList* pRequest, ArrayList* pResponse
        }
        else
        {
-               SysTryCatch(NID_APP, pAccessoryMonitor->GetClientPid() > 0, , E_SYSTEM, "Serial port is not created");
+               SysTryCatch(NID_SYS, pAccessoryMonitor->GetClientPid() > 0, , E_SYSTEM, "Serial port is not created");
                if(pCommand->Equals(SERIAL_COMMAND_WRITE, true))
                {
-                       SysLog(NID_IO, "Serial write is required");
+                       SysLog(NID_SYS, "Serial write is required to AccessoryMonitor.");
                        char* buffer = null;
                        char* pIterator = null;
                        int length = 0;
@@ -263,12 +276,12 @@ OnRequestOccured(AppId appId, int pid, ArrayList* pRequest, ArrayList* pResponse
                }
                else if(pCommand->Equals(SERIAL_COMMAND_CLOSE, true))
                {
-                       SysLog(NID_IO, "Serial close is required");
+                       SysLog(NID_SYS, "Serial close is required to AccessoryMonitor.");
                        pAccessoryMonitor->SetClientPid(0);
                }
                else
                {
-                       SysLogException(NID_APP, E_SYSTEM, "Undefined command is pRequested by [%d]", pAccessoryMonitor->GetClientPid());
+                       SysLogException(NID_SYS, E_SYSTEM, "Undefined command is pRequested by [%d]", pAccessoryMonitor->GetClientPid());
                }
        }
 CATCH:
index 4b36d45..193e321 100644 (file)
@@ -780,7 +780,6 @@ _SystemInfo::CachingSystemInformation(void)
        reg.Flush();
 
        this->GetValue(_TELEPHONY, bValue);
-       SysLog(NID_SYS, "OSP_TEST telephony is %d.", bValue);
        if(bValue == true)
                systemValue = _SYSTEM_CACHING_TRUE;
        else
@@ -1614,12 +1613,10 @@ _SystemInfo::GetValue(const String& key, bool& value)
 
                if(strcasestr(device_name.machine, "emulated") != null)
                {
-                       SysLog(NID_SYS, "OSP_TEST This is emulator.");
                        value = File::IsFileExist(_TELEPHONY_SERVICE_BIN);
                }
                else
                {
-                       SysLog(NID_SYS, "OSP_TEST This is device.");
                        if(File::IsFileExist(_TELEPHONY_SERVICE_BIN) == true && File::IsFileExist(_TELEPHONY_MODEM_BIN) == true)
                        {
                                value = true;