From 86951b192bc698e49669e4827b366969745d7e15 Mon Sep 17 00:00:00 2001 From: SeungWon Lee Date: Thu, 11 Jul 2013 09:35:25 +0900 Subject: [PATCH] Ignore callback for null AppId case and optimize the loop body. Change-Id: If4623eb0e0726aae9cdb8f5647523ea3dd7d694a Signed-off-by: SeungWon Lee --- src/app/FApp_AppManagerImpl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/FApp_AppManagerImpl.cpp b/src/app/FApp_AppManagerImpl.cpp index 6b08626..f696327 100755 --- a/src/app/FApp_AppManagerImpl.cpp +++ b/src/app/FApp_AppManagerImpl.cpp @@ -1062,6 +1062,14 @@ _AppManagerImpl::FireActiveAppEvent(unsigned int xid, int pid, char* pAppName) if (oldPid != pid) { oldPid = pid; + char pkgname[255] = {0, }; + if ((AUL_R_OK != aul_app_get_pkgname_bypid(pid, pkgname, 255)) || pkgname[0] == 0) + { + SysSecureLog(NID_APP, "Failed to get the package name from pid=%x pAppName=%s", pid, pAppName ? pAppName : "null"); + return; + } + AppId appId(_Aul::GetRealAppId(String(pkgname))); + std::unique_ptr > pEnum(__activeAppEventListenerList.GetEnumeratorN()); if (pEnum.get()) { @@ -1071,10 +1079,7 @@ _AppManagerImpl::FireActiveAppEvent(unsigned int xid, int pid, char* pAppName) pEnum->GetCurrent(pListener); if (pListener) { - char pkgname[255] = {0, }; - aul_app_get_pkgname_bypid(pid, pkgname, 255); - // TODO: Translate it to package name --> AppId - pListener->OnActiveAppChanged(AppId(pkgname)); + pListener->OnActiveAppChanged(appId); } } } -- 2.7.4