Fix privilege issue for hybrid
authorDuyoung Jang <duyoung.jang@samsung.com>
Wed, 17 Jul 2013 07:11:13 +0000 (16:11 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Wed, 17 Jul 2013 07:16:33 +0000 (16:16 +0900)
Change-Id: I53683912818db16e913364eca37937eeedb8075c
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
src/app/inc/FAppPkg_PackageManagerImpl.h
src/app/package/FAppPkg_PackageInfoImpl.cpp
src/app/package/FAppPkg_PackageManagerImpl.cpp

index efd46cb..de9e9dd 100644 (file)
@@ -189,6 +189,8 @@ private:
        static int InstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
        static int UninstallationEventHandler(int reqId, const char* pType, const char* pPackageId, const char* pKey, const char* pVal, const void* pMsg, void* pData);
 
+       bool IsHybridPackage(const Tizen::Base::String& filePath) const;
+
 protected:
        friend class PackageManager;
 
index d88bda0..b55612b 100755 (executable)
@@ -1212,8 +1212,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_installed_time(__packageInfoHandle, &installedTime);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_installed_time(): installedTime = [%d]", installedTime);
-
                time_t dateTime = (time_t) installedTime;
                struct tm* pGmTime = null;
 
@@ -1223,7 +1221,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
                        DateTime tempTime;
                        tempTime.SetValue(pGmTime->tm_year + 1900, pGmTime->tm_mon + 1, pGmTime->tm_mday, pGmTime->tm_hour, pGmTime->tm_min, pGmTime->tm_sec);
                        __dateTime = tempTime;
-                       SysLog(NID_APP, "Time %d %d/%d, %d:%d:%d", tempTime.GetYear(), tempTime.GetMonth(), tempTime.GetDay(), tempTime.GetHour(), tempTime.GetMinute(), tempTime.GetSecond());
                }
        }
        else
index f047532..a68b41a 100755 (executable)
@@ -36,6 +36,7 @@
 #include <FBaseSysLog.h>
 #include <FIo.h>
 #include <FIoRegistry.h>
+#include <FSecPrivilegeInfo.h>
 #include <FSysSystemTime.h>
 #include <FBase_StringConverter.h>
 
@@ -49,7 +50,9 @@
 using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
 using namespace Tizen::Io;
+using namespace Tizen::Security;
 using namespace Tizen::System;
 
 namespace Tizen { namespace App { namespace Package
@@ -771,6 +774,33 @@ _PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const
                pPackageInfoImpl->SetAuthor(pPkgInfo->author);
                pPackageInfoImpl->SetMainAppId(pPkgInfo->pkg_name);
 
+               if (IsHybridPackage(filePath) == true)
+               {
+                       PackageInfo hybridServiceInfo;
+                       _PackageParser packageParser;
+
+                       res = packageParser.Construct(&hybridServiceInfo);
+                       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Construct() is failed. [%s]", pPackagePath.get());
+
+                       res = packageParser.Parse(filePath);
+                       SysTryReturn(NID_APP, res, null, E_PARSING_FAILED, "Parse() is failed. [%s]", pPackagePath.get());
+
+                       IList* pList = hybridServiceInfo.GetPrivilegeListN();
+                       if (pList)
+                       {
+                               for (int i = 0; i < pList->GetCount(); i++)
+                               {
+                                       PrivilegeInfo* pPrivilegeInfo = dynamic_cast < PrivilegeInfo* >(pList->GetAt(i));
+                                       if (pPrivilegeInfo)
+                                       {
+                                               String privilege = pPrivilegeInfo->GetId();
+                                               pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(privilege));
+                                               SysLog(NID_APP, "privilege[%ls] is added for hybrid.", privilege.GetPointer());
+                                       }
+                                }
+                       }
+               }
+
                if (pPkgInfo->privilege_list)
                {
                        GList* pList = null;
@@ -1318,6 +1348,33 @@ _PackageManagerImpl::PackageAppInfoMetadataHandler(const pkgmgrinfo_appinfo_h ha
        return 0;
 }
 
+bool
+_PackageManagerImpl::IsHybridPackage(const String& filePath) const
+{
+       SysTryReturn(NID_APP, filePath.IsEmpty() == false, false, E_INVALID_ARG, "filePath is empty.");
+
+       bool res = true;
+       FileUnzipper unzipper;
+       ZipEntry zipEntry;
+
+       result r = unzipper.Construct(filePath);
+       SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.Construct() failed.");
+
+       r = unzipper.GetEntry(L"info/manifest.xml", zipEntry);
+       if (!IsFailed(r))
+       {
+               SysLog(NID_APP, "It's hybrid package. [%ls]", filePath.GetPointer());
+               res = true;
+       }
+       else
+       {
+               SysLog(NID_APP, "It's not hybrid package. [%ls]", filePath.GetPointer());
+               res = false;
+       }
+
+       return res;
+}
+
 _PackageManagerImpl*
 _PackageManagerImpl::GetInstance(void)
 {