Ignore callback for null AppId case and optimize the loop body.
authorSeungWon Lee <lsw2000.lee@samsung.com>
Thu, 11 Jul 2013 00:35:25 +0000 (09:35 +0900)
committerSeungWon Lee <lsw2000.lee@samsung.com>
Thu, 11 Jul 2013 00:38:28 +0000 (09:38 +0900)
Change-Id: If4623eb0e0726aae9cdb8f5647523ea3dd7d694a
Signed-off-by: SeungWon Lee <lsw2000.lee@samsung.com>
src/app/FApp_AppManagerImpl.cpp

index d165d77..fe907a7 100755 (executable)
@@ -1068,6 +1068,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<IEnumeratorT<Tizen::App::IActiveAppEventListener* > > pEnum(__activeAppEventListenerList.GetEnumeratorN());
                if (pEnum.get())
                {
@@ -1077,10 +1085,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);
                                }
                        }
                }