Fix loading default appcontrol information 16/245816/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Oct 2020 05:29:38 +0000 (14:29 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Oct 2020 06:01:30 +0000 (15:01 +0900)
The initial value of the user state can be "online". If the value is not
"opening", AMD doesn't load default appcontrol information from
appsvc database.
After this patch is applied, AMD tries to load default appcontrol
inforamtion when the user state is "opening" or "online" or "active".

Change-Id: I09de3dd57d44abc6e4961a936c94f482f24c9e93
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_app_control.cc
src/lib/app_control/appsvc_manager.cc

index 68994617592b3d2c7bcf59423338de2816905e00..eb9f277d4a79589ae24feba1264754730cefe2fd 100644 (file)
@@ -160,7 +160,7 @@ static int __on_app_property_unset_app_control_default_app(const char* msg,
 static int __on_login_monitor_login(const char* msg,
     int arg1, int arg2, void* arg3, bundle* arg4) {
   uid_state state = static_cast<uid_state>(arg2);
-  if (state == UID_STATE_OPENING) {
+  if (state & (UID_STATE_OPENING | UID_STATE_ONLINE | UID_STATE_ACTIVE)) {
     uid_t uid = static_cast<uid_t>(arg1);
     AppSvcManager::GetInst().LoadAppSvc(uid);
   }
index 96ed1aa482a87e2e0747f220bae0ae9be2e16139..9e798629992faf11bc8f597728ed90a9e3bf80f1 100644 (file)
@@ -52,20 +52,7 @@ void AppSvcManager::RemoveAppSvc(uid_t uid, const std::string& app_id) {
 }
 
 void AppSvcManager::LoadAppSvc(uid_t uid) {
-  if (!PrepareAppSvcChunk(uid))
-    return;
-
-  AppSvcDB db(uid);
-  try {
-    db.Open();
-    if (!db.IntegrityCheck())
-      return;
-
-    for (auto& kv : db.Select())
-      AddAppSvc(uid, kv.first, kv.second);
-  } catch (Exception& e) {
-    _E("Exception(%d) occurs", e.GetErrorCode());
-  }
+  PrepareAppSvcChunk(uid);
 }
 
 std::string AppSvcManager::GetDefaultAppId(uid_t uid,
@@ -88,6 +75,18 @@ bool AppSvcManager::PrepareAppSvcChunk(uid_t uid) {
   }
 
   appsvc_chunk_[uid] = std::shared_ptr<AppSvcChunk>(chunk);
+  AppSvcDB db(uid);
+  try {
+    db.Open();
+    if (!db.IntegrityCheck())
+      return true;
+
+    for (auto& kv : db.Select())
+      appsvc_chunk_[uid]->Add(kv.first, kv.second);
+  } catch (Exception& e) {
+    _E("Exception(%d) occurs", e.GetErrorCode());
+  }
+
   return true;
 }