Emit 'unmount' signal before it stop the units 87/197687/13
authorseolheui, kim <s414.kim@samsung.com>
Tue, 15 Jan 2019 10:03:30 +0000 (19:03 +0900)
committerseolheui, kim <s414.kim@samsung.com>
Thu, 24 Jan 2019 06:58:38 +0000 (15:58 +0900)
Change-Id: Idf91f3321a51878abf295c81e7b88e6c0c815158
Signed-off-by: seolheui, kim <s414.kim@samsung.com>
server/internal-encryption.cpp

index d27fda9..8f40090 100644 (file)
@@ -37,6 +37,7 @@
 #include <klay/file-user.h>
 #include <klay/filesystem.h>
 #include <klay/dbus/connection.h>
+#include <klay/dbus/signal.h>
 #include <klay/error.h>
 #include <systemd/sd-bus.h>
 
@@ -56,6 +57,16 @@ namespace ode {
 namespace {
 
 const char *PRIVILEGE_PLATFORM = "http://tizen.org/privilege/internal/default/platform";
+const std::string ODE_OBJECT_PATH = "/Org/Tizen/OnDeviceEncryption";
+const std::string ODE_INTERFACE_EVENT = "org.tizen.OnDeviceEncryption.Event";
+const std::string ODE_SIGNAL_NAME = "unmount";
+const std::string manifest =
+       "<node>"
+       "       <interface name='" + ODE_INTERFACE_EVENT + "'>"
+       "       <signal name='" + ODE_SIGNAL_NAME + "'>"
+       "       </signal>"
+       "       </interface>"
+       "</node>";
 
 // watches systemd jobs
 class JobWatch {
@@ -152,6 +163,15 @@ void stopSystemdUnits()
        std::vector<std::string> preprocessUnits;
        std::set<std::string> unitsToStop;
 
+       try {
+               systemDBus.emitSignal("",
+                                               ODE_OBJECT_PATH,
+                                               ODE_INTERFACE_EVENT,
+                                               ODE_SIGNAL_NAME, "()", nullptr);
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, "Failed to emit signal : " + std::string(e.what()));
+       }
+
        auto stopUnit = [&systemDBus](const std::string &unit) {
                JobWatch watch(systemDBus);
                WARN(SINK, "Stopping unit: " + unit);
@@ -390,6 +410,13 @@ InternalEncryptionServer::InternalEncryptionServer(ServerContext& srv,
                                                        std::to_string(v).c_str());
                })
        ));
+
+       try {
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.registerObject(ODE_OBJECT_PATH, manifest, nullptr, nullptr);
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, e.what());
+       }
 }
 
 InternalEncryptionServer::~InternalEncryptionServer()