Set blocking status when package is installing 27/299927/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 12 Oct 2023 07:18:26 +0000 (16:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 12 Oct 2023 07:18:26 +0000 (16:18 +0900)
Currently, AMD tries to load the app info if the app info does not exist.
Unfortunately, the app info will be loaded even if the package is installing.
Before finishing the installation, the information is inserted to the database.
This patch is to prevent launching the application when the package is installing.

Change-Id: I63cc27987c49ba9cba350a89f24a1cd6c0f68e36
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/app_info/app_info_manager.cc
src/lib/app_info/app_info_manager.hh

index 5cbe33cfbdfdd1a7d482f73e99df7cfebadbcf77..cac3825ff25bcddfe488cb80ba4ac0ddb42ae64a 100644 (file)
@@ -250,9 +250,31 @@ int AppInfoManager::InsertAppInfo(uid_t uid, const std::string& appid) {
 
   PkgmgrEventInsertHandler(handle, chunk.get());
   pkgmgrinfo_appinfo_destroy_appinfo(handle);
+  info = chunk->Get(appid);
+  if (info == nullptr) {
+    _E("Failed to find appinfo. appid(%s)", appid.c_str());
+    return -1;
+  }
+
+  if (ShouldBeBlocking(info->GetPkgId()))
+    info->SetStatus("blocking");
+
   return 0;
 }
 
+bool AppInfoManager::ShouldBeBlocking(const std::string& pkgid) {
+  for (auto const& iter : pkg_events_) {
+    auto& event_args = iter.second;
+    if (event_args->GetPkgId() == pkgid) {
+      _W("The event of the package(%s) is %s",
+          pkgid.c_str(), event_args->GetEventName().c_str());
+      return true;
+    }
+  }
+
+  return false;
+}
+
 bool AppInfoManager::IsUpdating(const std::string& pkgid) {
   for (auto const& iter : pkg_events_) {
     auto& event_args = iter.second;
index 8f390bdcd531a4b03e9ce927828388e79f702684..5cd99804e1acef65505950ff20027c771afa1ce9 100644 (file)
@@ -55,6 +55,7 @@ class AppInfoManager : public PkgmgrClient::IEvent {
 
   std::shared_ptr<AppInfoChunk> PrepareAppInfoChunk(uid_t uid);
 
+  bool ShouldBeBlocking(const std::string& pkgid);
   void SetPackageBlocking(uid_t target_uid, const std::string& pkgid,
       const std::string& global, bool do_kill);
   void UnsetPackageBlocking(uid_t target_uid, const std::string& pkgid,