fix P130408-1578 : fix multiple process for submode service launch
authorYoung Ik Cho <youngik.cho@samsung.com>
Mon, 8 Apr 2013 13:52:46 +0000 (22:52 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Mon, 8 Apr 2013 13:52:46 +0000 (22:52 +0900)
Change-Id: I31f8567942c7e52e214d9c3105f2f8c7d35e29bb
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppResourceImpl.h [changed mode: 0755->0644]

index 3d48a30..09b5d33 100644 (file)
@@ -542,6 +542,29 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
        return r;
 }
 
+static bool
+_IsDefaultApplication(const AppId& packageId, const String& appId)
+{
+       const String& execName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(packageId);
+
+       int index = -1;
+       result r = appId.IndexOf(L'.', 0, index);
+       if (r != E_SUCCESS)
+       {
+               return false;
+       }
+
+       String tmp;
+       appId.SubString(index + 1, tmp);
+       if (tmp == execName)
+       {
+               SysLog(NID_APP, "Default application %ls", tmp.GetPointer());
+               return true;
+       }
+
+       return false;
+}
+
 int
 _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
 {
@@ -551,12 +574,12 @@ _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
        String actualAppId = appId;
        if (appId.GetLength() == 10)
        {
-               const String& name = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
+               const String& execName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
 
-               if (!name.IsEmpty())
+               if (!execName.IsEmpty())
                {
                        actualAppId.Append(L'.');
-                       actualAppId.Append(name);
+                       actualAppId.Append(execName);
                }
        }
 
@@ -571,19 +594,24 @@ _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, int req)
        int pid = -1;
        bundle* kb = NULL;
        String tempId;
+
        actualAppId.SubString(0, 10, tempId);
-       tempId += L'.';
-       tempId += L"_AppControl";
 
-       // [INFO] Ugly solution for submode support
-       pArg->UpdateAppId(tempId);
-       kb = pArg->GetBundle();
-       
-       pid = appsvc_run_service(kb, req, LaunchResultCb, this);
-       if (pid > 0)
+       if (_IsDefaultApplication(tempId, appId))
        {
-               SysLog(NID_APP, "Submode launch successful");
-               return pid;
+               tempId += L'.';
+               tempId += L"_AppControl";
+
+               // [INFO] Ugly solution for submode support
+               pArg->UpdateAppId(tempId);
+               kb = pArg->GetBundle();
+
+               pid = appsvc_run_service(kb, req, LaunchResultCb, this);
+               if (pid > 0)
+               {
+                       SysLog(NID_APP, "Submode launch successful");
+                       return pid;
+               }
        }
 
        pArg->UpdateAppId(actualAppId);
old mode 100755 (executable)
new mode 100644 (file)