Fix autoset during mic process 45/257845/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 May 2021 07:32:22 +0000 (16:32 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 May 2021 07:32:22 +0000 (16:32 +0900)
During image creation, theme provider is not running, so plugin should
set current theme directly.

Change-Id: I95012e7d198c890517567dd89af1bbfe2f52fb03
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme_plugin/theme_metadata_plugin.cc

index 38662a7..8a43969 100644 (file)
@@ -19,6 +19,7 @@
 #include "theme/utils/logging.h"
 #include "theme/loader/theme_info.h"
 #include "theme_plugin/theme_parser.h"
+#include "theme_provider/theme_info_proxy.h"
 
 using ttm::loader::ThemeInfo;
 using ttm::plugin::ThemeParser;
@@ -180,8 +181,23 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(
   if (AutosetData::GetInst().autoset_id.empty())
     return 0;
   ttm::dbus::RequestBroker& broker = ttm::dbus::RequestBroker::GetInst();
-  if (!broker.GetConnection())
-    return 0;
+  if (!broker.GetConnection()) {
+    // in case of root, this installation processed during image creation or
+    // platform update.
+    // TODO(jeremy.jang): Fix to not invoke broker API directly
+    if (getuid() == 0) {
+      ttm::provider::ThemeInfoProxy proxy("/opt/dbspace/.tizen_theme.db");
+      if (!proxy.SetCurrentTheme(AutosetData::GetInst().autoset_id)) {
+        LOG(ERROR) << "Failed to force set current theme id";
+        return -1;
+      } else {
+        return 0;
+      }
+    } else {
+      LOG(ERROR) << "Cannot connect with theme-provider";
+      return 0;
+    }
+  }
   tizen_base::Bundle b;
   b.Add(ttm::dbus::kCmdDataKey, AutosetData::GetInst().autoset_id);
   tizen_base::Bundle reply = broker.SendData(ttm::dbus::Command::SET_ID, b);