From fe524865d653a6efdc322ce74d4a0aba473524bd Mon Sep 17 00:00:00 2001 From: "kyeongwoo.lee" Date: Wed, 26 Jun 2013 16:08:31 +0900 Subject: [PATCH] Fixed prevent issues Change-Id: Ib8358adadd410f18d095fe654ab157de0a733e61 --- src/FShell_AppWidgetContext.cpp | 35 +++++++++++++------------- src/FShell_AppWidgetManagerService.cpp | 6 ++--- src/OspAppWidgetService.cpp | 19 ++++++++++---- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index c36a171..e6c4c14 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -39,6 +39,7 @@ namespace Tizen { namespace Shell { namespace App { +using namespace std; using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -74,10 +75,10 @@ _AppWidgetContext::_AppWidgetContext(AppContext* pAppContext, const String& info __updateTimer.StartAsRepeatable(__updateMillis); } - __pPendingTouchEventList = new ArrayListT(); + __pPendingTouchEventList = new (nothrow) ArrayListT(); __pPendingTouchEventList->Construct(); - __pPendingEventList = new ArrayListT(); + __pPendingEventList = new (nothrow) ArrayListT(); __pPendingEventList->Construct(); } @@ -260,7 +261,7 @@ _AppWidgetContext::IsPaused(void) const void _AppWidgetContext::OnPopupCreated(double x, double y, int width, int height) { - __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(GetUserInfo(), GetProviderId(), GetInstanceId(), GetWidth(), GetHeight(), GetPriority(), this); + __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(GetUserInfo(), GetProviderId(), GetInstanceId(), GetWidth(), GetHeight(), GetPriority(), this); __pAppWidgetPopup->SetIpcClientId(GetClientId()); __pAppWidgetPopup->OnPopupCreated(x, y, width, height); } @@ -291,7 +292,7 @@ _AppWidgetContext::SendUpdateRequest(int width, int height, const String& argume { std::unique_ptr pArgs (CreateRequestArgsN()); - pArgs->Add(new String(ARG_KEY_ARGUMENT), new String(argument)); + pArgs->Add(new (nothrow) String(ARG_KEY_ARGUMENT), new (nothrow) String(argument)); return SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release()); } @@ -327,7 +328,7 @@ _AppWidgetContext::SendPendingEvent(void) r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg); result r1 = __pPendingEventList->RemoveAt(0); - SysTryLog(NID_SHELL, !IsFailed(r1), "Failed to execute remove context."); + SysTryLog(NID_SHELL, !IsFailed(r1), "Failed to remove the context."); delete pEvent; SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed."); @@ -365,7 +366,7 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub } else { - __pPendingTouchEventList->Add(new PendingTouchEvent(eventType, timeStamp, x, y)); + __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(eventType, timeStamp, x, y)); if( AppManager::GetInstance()->IsRunning(this->GetAppId() ) == false) { @@ -373,10 +374,10 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub std::unique_ptr pArgs (CreateRequestArgsN() ); // TODO: consider to remove these unused args. - pArgs->Add(new String(ARG_KEY_EVENT_TYPE), new String(Integer::ToString(eventType))); - pArgs->Add(new String(ARG_KEY_TIME_STAMP), new String(Double::ToString(timeStamp))); - pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x))); - pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y))); + pArgs->Add(new (nothrow) String(ARG_KEY_EVENT_TYPE), new (nothrow) String(Integer::ToString(eventType))); + pArgs->Add(new (nothrow) String(ARG_KEY_TIME_STAMP), new (nothrow) String(Double::ToString(timeStamp))); + pArgs->Add(new (nothrow) String(ARG_KEY_X), new (nothrow) String(Double::ToString(x))); + pArgs->Add(new (nothrow) String(ARG_KEY_Y), new (nothrow) String(Double::ToString(y))); return SendRequestToApp(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get()); } @@ -399,7 +400,7 @@ _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, if (!HasValidClientId() || __pAppContext->__isWaitingResult == true) { SysLog(NID_SHELL, "The application is running but IPC is not connected yet."); - __pPendingEventList->Add(new PendingEvent(*new String(operation), pArgs)); + __pPendingEventList->Add(new (nothrow) PendingEvent(operation, pArgs)); } else { @@ -446,14 +447,14 @@ _AppWidgetContext::SendAccessStatus(int accessStatus) Tizen::Base::Collection::HashMap* _AppWidgetContext::CreateRequestArgsN(void) { - HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); + HashMap* pArgs = new (nothrow) HashMap(SingleObjectDeleter); pArgs->Construct(); - pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(GetInstanceId())); - pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(GetProviderName())); - pArgs->Add(new String(ARG_KEY_USER_INFO), new String(GetUserInfo())); - pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(GetWidth()))); - pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(GetHeight()))); + pArgs->Add(new (nothrow) String(ARG_KEY_INSTANCE_ID), new (nothrow) String(GetInstanceId())); + pArgs->Add(new (nothrow) String(ARG_KEY_PROVIDER_NAME), new (nothrow) String(GetProviderName())); + pArgs->Add(new (nothrow) String(ARG_KEY_USER_INFO), new (nothrow) String(GetUserInfo())); + pArgs->Add(new (nothrow) String(ARG_KEY_WIDTH), new (nothrow) String(Integer::ToString(GetWidth()))); + pArgs->Add(new (nothrow) String(ARG_KEY_HEIGHT), new (nothrow) String(Integer::ToString(GetHeight()))); return pArgs; } diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index d32dd93..2261a44 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -758,10 +758,10 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + pAppWidgetContextEnum->GetValue(pAppWidgetContext); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext, E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - if (!pValue->IsRunning()) + if (!pAppWidgetContext->IsRunning()) { break; } diff --git a/src/OspAppWidgetService.cpp b/src/OspAppWidgetService.cpp index 0820901..286b3e3 100644 --- a/src/OspAppWidgetService.cpp +++ b/src/OspAppWidgetService.cpp @@ -86,18 +86,27 @@ OspAppWidgetService::OnBatteryLevelChanged(BatteryLevel batteryLevel) void OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData) { - if( operationId == OPERATION_MAIN) + if (operationId == OPERATION_MAIN) { static bool isServiceCreated = false; - if( isServiceCreated == false) + if (isServiceCreated == false) { String key(KEY_NAME); const String* pValue = dynamic_cast(pExtraData->GetValue(key)); - std::unique_ptr pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue)); - AppWidgetManagerService* pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get()); - AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed."); + AppWidgetManagerService* pSvc = null; + + if (pValue) + { + std::unique_ptr pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue)); + pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get()); + } + else + { + pSvc = AppWidgetManagerService::CreateInstance("osp-appwidget-service"); + } + AppAssertf(pSvc != null, "AppWidgetManagerService::GetInstance() failed."); isServiceCreated = true; } -- 2.34.1