removed redundant code
[platform/framework/native/appfw.git] / src / app / FApp_Aul.cpp
index d5cf730..6abde09 100644 (file)
@@ -30,6 +30,7 @@
 #include <bundle.h>
 #include <appsvc/appsvc.h>
 #include <vconf.h>
+#include <pkgmgr-info.h>
 
 #include <FBaseObject.h>
 #include <FBaseString.h>
@@ -282,27 +283,43 @@ _Aul::IsInstalled(const AppId& appId)
 }
 
 
+String
+_Aul::GetMainAppId(const char* appid)
+{
+       pkgmgrinfo_appinfo_h handle = NULL;
+       int ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+       {
+               return String();
+       }
+
+       char* mainid = NULL;
+       ret = pkgmgrinfo_appinfo_get_submode_mainid(handle, &mainid);
+       SysTryLog(NID_APP, ret == PMINFO_R_OK, "Cannot get main id for %s.", appid);
+
+       const String tmp = String(mainid);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return tmp;
+}
+
+
 AppId
 _Aul::GetRealAppId(const AppId& appId)
 {
        String temp;
-       // [INFO] ugly code for submode callee
        appId.SubString(11, temp);
        if (temp == String(SUBMODE_NAME))
        {
-               String id;
-               appId.SubString(0, 10, id);
-               const String& name = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(id);
-
-               const String retVal = id + L'.' + name;
-               SysLog(NID_APP, "Converted caller Id is %ls", retVal.GetPointer());
-
-               return retVal;
-       }
-       else
-       {
-               return appId;
+               std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+               const String& main = GetMainAppId(pAppId.get());
+               if (!main.IsEmpty())
+               {
+                       SysLog(NID_APP, "main Id is %ls", main.GetPointer());
+                       return main;
+               }
        }
+
+       return appId;
 }
 
 } } // Tizen::App