Add to showing external encryption popup after homescreen loading 95/143495/1
authorSungbae Yoo <sungbae.yoo@samsung.com>
Wed, 9 Aug 2017 07:01:22 +0000 (16:01 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 10 Aug 2017 06:40:26 +0000 (15:40 +0900)
Limitation: This doesn't wait for homescreen actually.
Just some delays after BootCompleted is received.

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I9703ff23717c9fd7f2a2a0d1bea67b85f64d1b7d

server/external-encryption.cpp

index c8b96bd..65373a2 100644 (file)
@@ -52,6 +52,7 @@ namespace {
 
 std::unique_ptr<EXTERNAL_ENGINE> engine;
 KeyManager::data mountKey;
+bool isBootCompleted = false;
 
 void killDependedApplications()
 {
@@ -97,7 +98,7 @@ void externalCallback(dbus::Variant parameters)
                if (value != NULL) {
                        std::string valueStr(value);
                        free(value);
-                       if (valueStr == "encrypted") {
+                       if (valueStr == "encrypted" && isBootCompleted) {
                                try {
                                        INFO(SINK, "Launch SD card password popup");
                                        AppBundle bundle;
@@ -113,6 +114,38 @@ void externalCallback(dbus::Variant parameters)
        }
 }
 
+void bootCompletionCallback(dbus::Variant parameters)
+{
+
+       auto waitForHomescreen = []() {
+               //For a delay until homescreen is totally loaded
+               sleep(8);
+
+               INFO(SINK, "Boot completed");
+
+               char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
+               if (value != NULL) {
+                       std::string valueStr(value);
+                       free(value);
+                       if (valueStr == "encrypted") {
+                               try {
+                                       INFO(SINK, "Launch SD card password popup");
+                                       AppBundle bundle;
+                                       bundle.add("viewtype", "SD_CARD_PASSWORD");
+                                       Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+                                       launchpad.launch("org.tizen.ode", bundle);
+                               } catch (runtime::Exception &e) {
+                                       ERROR(SINK, "Failed to launch SD card password popup");
+                               }
+                       }
+               }
+               isBootCompleted = true;
+       };
+
+       std::thread asyncWork(waitForHomescreen);
+       asyncWork.detach();
+}
+
 void externalAddEventReceiver()
 {
        dbus::Connection &systemDBus = dbus::Connection::getSystem();
@@ -122,6 +155,12 @@ void externalAddEventReceiver()
                                                                "org.tizen.system.storage.BlockManager",
                                                                "DeviceChanged",
                                                                externalCallback);
+
+       systemDBus.subscribeSignal("",
+                                                               "/Org/Tizen/System/Pass/Core",
+                                                               "org.tizen.system.pass.core",
+                                                               "BootingDone",
+                                                               bootCompletionCallback);
 }
 
 unsigned int getOptions()