Determine package by removable attribute 05/112305/1
authorKyungwook Tak <k.tak@samsung.com>
Tue, 31 Jan 2017 05:33:13 +0000 (14:33 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Tue, 31 Jan 2017 05:33:35 +0000 (14:33 +0900)
Change-Id: Ic398d0a9056ee2bcef7f17d0813f15da9cb85816
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/file-system.cpp
src/framework/service/file-system.h

index 9ae2380..7be7cef 100644 (file)
@@ -66,6 +66,15 @@ int File::getPkgTypes(const std::string &user, const std::string &pkgid)
        if (isPreloaded)
                type |= static_cast<int>(Type::PreLoaded);
 
+       bool isRemovable = false;
+       ret = ::pkgmgrinfo_pkginfo_is_removable(handle, &isRemovable);
+
+       if (ret != PMINFO_R_OK)
+               ERROR("Failed to ::pkgmgrinfo_pkginfo_is_removable: " << ret);
+
+       if (isRemovable)
+               type |= static_cast<int>(Type::Removable);
+
        ::pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
 
        return type;
@@ -95,9 +104,8 @@ std::string File::getPkgPath(const std::string &path)
                }
 
                auto type = File::getPkgTypes(pkgUser, pkgId);
-
                return ((type & static_cast<int>(Type::Package)) &&
-                          (!(type & static_cast<int>(Type::PreLoaded)))) ? pkgPath : path;
+                          ((type & static_cast<int>(Type::Removable)))) ? pkgPath : path;
        }
 
        return path;
@@ -117,11 +125,14 @@ File::File(const std::string &fpath, const FilePtr &parentdir, int type,
 
                        if (parentdir->isPreloaded())
                                this->m_type |= static_cast<int>(File::Type::PreLoaded);
+                       if (parentdir->isRemovable())
+                               this->m_type |= static_cast<int>(File::Type::Removable);
 
                        return;
                } else if (!this->isDir()) {
                        this->m_type &= ~(static_cast<int>(File::Type::Package) |
-                                                         static_cast<int>(File::Type::PreLoaded));
+                                                         static_cast<int>(File::Type::PreLoaded) |
+                                                         static_cast<int>(File::Type::Removable));
                }
        }
 
index 7166c47..9278deb 100644 (file)
@@ -44,7 +44,7 @@ public:
 
        inline bool isInApp() const noexcept
        {
-               return this->isPackage() && !this->isPreloaded();
+               return this->isPackage() && this->isRemovable();
        }
 
        inline bool isPackage() const noexcept
@@ -52,6 +52,11 @@ public:
                return this->m_type & static_cast<int>(Type::Package);
        }
 
+       inline bool isRemovable() const noexcept
+       {
+               return this->m_type & static_cast<int>(Type::Removable);
+       }
+
        inline bool isPreloaded() const noexcept
        {
                return this->m_type & static_cast<int>(Type::PreLoaded);
@@ -112,8 +117,9 @@ private:
                Modified  = (1 << 0),
                Package   = (1 << 1),
                PreLoaded = (1 << 2),
-               File      = (1 << 3),
-               Directory = (1 << 4)
+               Removable = (1 << 3),
+               File      = (1 << 4),
+               Directory = (1 << 5)
        };
 
        static FilePtr createInternal(const std::string &fpath, const FilePtr &parentdir,