Handle pre-loaded app in file-unit 84/75884/2
authorKyungwook Tak <k.tak@samsung.com>
Wed, 22 Jun 2016 05:26:13 +0000 (14:26 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Wed, 22 Jun 2016 07:30:37 +0000 (16:30 +0900)
Change-Id: Id3d4973448f3f27aa3fb9beb31bb05868c9fe4b8
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/file-system.cpp
src/framework/service/file-system.h

index 9d25331..668061e 100644 (file)
@@ -86,6 +86,15 @@ int File::getPkgTypes(const std::string &user, const std::string &pkgid)
 
        auto type = static_cast<int>(Type::Package);
 
+       bool isPreloaded = false;
+       ret = ::pkgmgrinfo_pkginfo_is_preload(handle, &isPreloaded);
+
+       if (ret != PMINFO_R_OK)
+               ERROR("Failed to ::pkgmgrinfo_pkginfo_is_preload: " << ret);
+
+       if (isPreloaded)
+               type |= static_cast<int>(Type::PreLoaded);
+
        ::pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
 
        return type;
@@ -111,7 +120,10 @@ bool File::isInApp(const std::string &path)
                        continue;
                }
 
-               return File::getPkgTypes(pkgUser, pkgId) != 0;
+               auto type = File::getPkgTypes(pkgUser, pkgId);
+
+               return (type & static_cast<int>(Type::Package)) &&
+                          (!(type & static_cast<int>(Type::PreLoaded)));
        }
 
        return false;
@@ -140,7 +152,10 @@ std::string File::getPkgPath(const std::string &path)
                        continue;
                }
 
-               return File::getPkgTypes(pkgUser, pkgId) != 0 ? pkgPath : path;
+               auto type = File::getPkgTypes(pkgUser, pkgId);
+
+               return ((type & static_cast<int>(Type::Package)) &&
+                          (!(type & static_cast<int>(Type::PreLoaded)))) ? pkgPath : path;
        }
 
        return path;
@@ -179,7 +194,8 @@ const std::string &File::getPath() const noexcept
 
 bool File::isInApp() const noexcept
 {
-       return this->m_type & static_cast<int>(Type::Package);
+       return (this->m_type & static_cast<int>(Type::Package)) &&
+                  (!(this->m_type & static_cast<int>(Type::PreLoaded)));
 }
 
 bool File::isDir() const noexcept
index e679865..b59c6e9 100644 (file)
@@ -59,8 +59,9 @@ private:
        enum class Type : int {
                Modified  = (1 << 0),
                Package   = (1 << 1),
-               File      = (1 << 2),
-               Directory = (1 << 3),
+               PreLoaded = (1 << 2),
+               File      = (1 << 3),
+               Directory = (1 << 4)
        };
 
        static FilePtr createInternal(const std::string &fpath, time_t modifiedSince,