Apply encryption progress UI service 53/178353/4 accepted/tizen/4.0/unified/20180514.094000 accepted/tizen/unified/20180515.163434 submit/tizen/20180514.014354 submit/tizen/20180515.071846 submit/tizen_4.0/20180514.014607
authorseolheui kim <s414.kim@samsung.com>
Wed, 9 May 2018 12:31:43 +0000 (21:31 +0900)
committerseolheui kim <s414.kim@samsung.com>
Thu, 10 May 2018 10:01:34 +0000 (19:01 +0900)
Change-Id: Ibfe33fb459bf57a16a660bcabb9b9d34c878d7b0
Signed-off-by: seolheui kim <s414.kim@samsung.com>
server/internal-encryption.cpp
server/progress-bar.cpp

index 46f7942..bfac022 100644 (file)
@@ -233,32 +233,22 @@ void stopDependedSystemdUnits()
 
 void showProgressUI(const std::string type)
 {
-       ::tzplatform_set_user(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
-       std::string defaultUserHome(::tzplatform_getenv(TZ_USER_HOME));
-       ::tzplatform_reset_user();
-
-       try {
-               runtime::File shareDirectory("/opt/home/root/share");
-               if (!shareDirectory.exists()) {
-                       shareDirectory.makeDirectory(true);
-               }
+       dbus::Connection& systemDBus = dbus::Connection::getSystem();
+       std::string unit("ode-progress-ui@"+type+".service");
 
-               runtime::File elmConfigDir(shareDirectory.getPath() + "/.elementary");
-               if (!elmConfigDir.exists()) {
-                       runtime::File defaultElmConfigDir(defaultUserHome + "/share/.elementary");
-                       defaultElmConfigDir.copyTo(shareDirectory.getPath());
-               }
-       } catch (runtime::Exception &e) {
-               ERROR(SINK, "Failed to set up elm configuration: " + std::string(e.what()));
-       }
+       JobWatch watch(systemDBus);
+       INFO(SINK, "Start unit: " + unit);
 
-       std::vector<std::string> args = {
-               "ode", "progress", type, "Internal"
-       };
+       const char* job = NULL;
+       systemDBus.methodcall("org.freedesktop.systemd1",
+                                                       "/org/freedesktop/systemd1",
+                                                       "org.freedesktop.systemd1.Manager",
+                                                       "StartUnit",
+                                                       -1, "(o)", "(ss)", unit.c_str(), "replace").get("(o)", &job);
 
-       runtime::Process proc("/usr/bin/ode", args);
-       if (proc.execute() == -1)
-               ERROR(SINK, "Failed to execute progress UI");
+       INFO(SINK, "Waiting for job: " + std::string(job));
+       if (!watch.waitForJob(job))
+               throw runtime::Exception("Starting unit: " + unit + " failed");
 }
 
 unsigned int getOptions()
@@ -428,6 +418,9 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int
 
        auto encryptWorker = [masterKey, options, this]() {
                try {
+                       showProgressUI("Encrypting");
+                       ::sleep(1);
+
                        INFO(SINK, "Closing all known systemd services that might be using internal storage.");
                        stopKnownSystemdUnits();
 
@@ -442,8 +435,6 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int
                                unmountInternalStorage(source);
                        }
 
-                       showProgressUI("Encrypting");
-
                        INFO(SINK, "Encryption started.");
                        ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "error_partially_encrypted");
                        engine->encrypt(masterKey, options);
@@ -481,6 +472,9 @@ int InternalEncryptionServer::decrypt(const std::string& password)
 
        auto decryptWorker = [masterKey, this]() {
                try {
+                       showProgressUI("Decrypting");
+                       ::sleep(1);
+
                        if (engine->isMounted()) {
                                INFO(SINK, "Closing all known systemd services that might be using internal storage.");
                                stopKnownSystemdUnits();
@@ -498,8 +492,6 @@ int InternalEncryptionServer::decrypt(const std::string& password)
                                }
                        }
 
-                       showProgressUI("Decrypting");
-
                        INFO(SINK, "Decryption started.");
                        ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "error_partially_encrypted");
                        engine->decrypt(masterKey, getOptions());
index bb79711..6feef7c 100644 (file)
@@ -21,6 +21,7 @@ namespace ode {
 ProgressBar::ProgressBar(UpdateFunc const &updater)
        : updater(updater), updateValue(0)
 {
+       updater(0);
 }
 
 ProgressBar::~ProgressBar()