bootstrap: Log & code clean up 53/260953/6
authorWoochanlee <wc0917.lee@samsung.com>
Wed, 7 Jul 2021 10:41:37 +0000 (19:41 +0900)
committerwoochan lee <wc0917.lee@samsung.com>
Thu, 8 Jul 2021 06:12:31 +0000 (06:12 +0000)
Change-Id: Idba082a3f2e3f6396cdfad101f4f843aedf042f4

13 files changed:
libaurum/inc/Aurum.h
org.tizen.aurum-bootstrap/inc/bootstrap.h
org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc
org.tizen.aurum-bootstrap/src/BootstrapServer.cc
org.tizen.aurum-bootstrap/src/Commands/CloseAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/GetAttributeCommand.cc
org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/KillServerCommand.cc
org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc
org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/SetValueCommand.cc
org.tizen.aurum-bootstrap/src/ObjectMapper.cc

index 63f6fcd..e94ac22 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef LOGE
 #define FONT_RED    "\033[31m"
 #define FONT_RESET  "\033[0m"
-#define LOGI_RED(fmt, arg...) \
+#define LOGE(fmt, arg...) \
     ({ do { \
         dlog_print(DLOG_ERROR, LOG_TAG, \
                    FONT_RED "%s: %s(%d) > " fmt FONT_RESET, \
index 429e4e5..e8e9905 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef LOGE
 #define FONT_RED    "\033[31m"
 #define FONT_RESET  "\033[0m"
-#define LOGI_RED(fmt, arg...) \
+#define LOGE(fmt, arg...) \
     ({ do { \
         dlog_print(DLOG_ERROR, LOG_TAG, \
                    FONT_RED "%s: %s(%d) > " fmt FONT_RESET, \
index e733b23..705b768 100644 (file)
@@ -6,12 +6,14 @@
 #include "Commands/PreCommand.h"
 
 #include "config.h"
+#include "bootstrap.h"
 
 using namespace grpc;
 using namespace aurum;
 
 aurumServiceImpl::aurumServiceImpl()
 {
+    LOGI("creates watcher instance (start to look up at_spi server)");
     AccessibleWatcher::getInstance();
 }
 
@@ -24,7 +26,11 @@ aurumServiceImpl::aurumServiceImpl()
     return rst;
 }
 
-aurumServiceImpl::~aurumServiceImpl() {}
+aurumServiceImpl::~aurumServiceImpl()
+{
+    LOGI("bootstrap service terminated");
+}
+
 ::grpc::Status aurumServiceImpl::aurumServiceImpl::killServer(
     ::grpc::ServerContext* context, const ::aurum::ReqEmpty* request,
     ::aurum::RspEmpty* response)
@@ -32,6 +38,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<KillServerCommand> cmd = std::make_unique<KillServerCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::aurumServiceImpl::findElement(
     ::grpc::ServerContext* context, const ::aurum::ReqFindElement* request,
     ::aurum::RspFindElement* response)
@@ -47,6 +54,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<ClickCommand> cmd = ClickCommand::createCommand(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getValue(::grpc::ServerContext*      context,
                                           const ::aurum::ReqGetValue* request,
                                           ::aurum::RspGetValue*       response)
@@ -54,6 +62,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetValueCommand> cmd = std::make_unique<GetValueCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::setValue(::grpc::ServerContext*      context,
                                           const ::aurum::ReqSetValue* request,
                                           ::aurum::RspSetValue*       response)
@@ -61,6 +70,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<SetValueCommand> cmd = std::make_unique<SetValueCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getAttribute(
     ::grpc::ServerContext* context, const ::aurum::ReqGetAttribute* request,
     ::aurum::RspGetAttribute* response)
@@ -68,6 +78,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetAttributeCommand> cmd = GetAttributeCommand::createCommand(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getSize(::grpc::ServerContext*     context,
                                          const ::aurum::ReqGetSize* request,
                                          ::aurum::RspGetSize*       response)
@@ -75,6 +86,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetSizeCommand> cmd = std::make_unique<GetSizeCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::clear(::grpc::ServerContext*   context,
                                        const ::aurum::ReqClear* request,
                                        ::aurum::RspClear*       response)
@@ -82,6 +94,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<ClearCommand> cmd = std::make_unique<ClearCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::installApp(
     ::grpc::ServerContext*                         context,
     ::grpc::ServerReader< ::aurum::ReqInstallApp>* request,
@@ -90,6 +103,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<InstallAppCommand> cmd = std::make_unique<InstallAppCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::removeApp(::grpc::ServerContext*       context,
                                            const ::aurum::ReqRemoveApp* request,
                                            ::aurum::RspRemoveApp* response)
@@ -97,6 +111,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<RemoveAppCommand> cmd = std::make_unique<RemoveAppCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getAppInfo(
     ::grpc::ServerContext* context, const ::aurum::ReqGetAppInfo* request,
     ::aurum::RspGetAppInfo* response)
@@ -104,6 +119,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetAppInfoCommand> cmd = std::make_unique<GetAppInfoCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::launchApp(::grpc::ServerContext*       context,
                                            const ::aurum::ReqLaunchApp* request,
                                            ::aurum::RspLaunchApp* response)
@@ -111,6 +127,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<LaunchAppCommand> cmd = std::make_unique<LaunchAppCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::closeApp(::grpc::ServerContext*      context,
                                           const ::aurum::ReqCloseApp* request,
                                           ::aurum::RspCloseApp*       response)
@@ -118,6 +135,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<CloseAppCommand> cmd = std::make_unique<CloseAppCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::touchDown(::grpc::ServerContext*       context,
                                            const ::aurum::ReqTouchDown* request,
                                            ::aurum::RspTouchDown* response)
@@ -125,6 +143,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<TouchDownCommand> cmd = std::make_unique<TouchDownCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::touchUp(::grpc::ServerContext*     context,
                                          const ::aurum::ReqTouchUp* request,
                                          ::aurum::RspTouchUp*       response)
@@ -132,6 +151,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<TouchUpCommand> cmd = std::make_unique<TouchUpCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::touchMove(::grpc::ServerContext*       context,
                                            const ::aurum::ReqTouchMove* request,
                                            ::aurum::RspTouchMove* response)
@@ -139,6 +159,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<TouchMoveCommand> cmd = std::make_unique<TouchMoveCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::longClick(::grpc::ServerContext*   context,
                                            const ::aurum::ReqClick* request,
                                            ::aurum::RspClick*       response)
@@ -146,6 +167,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<LongClickCommand> cmd = std::make_unique<LongClickCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::flick(::grpc::ServerContext*   context,
                                        const ::aurum::ReqFlick* request,
                                        ::aurum::RspFlick*       response)
@@ -153,6 +175,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<FlickCommand> cmd = std::make_unique<FlickCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getDeviceTime(
     ::grpc::ServerContext* context, const ::aurum::ReqGetDeviceTime* request,
     ::aurum::RspGetDeviceTime* response)
@@ -160,6 +183,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetDeviceTimeCommand> cmd = std::make_unique<GetDeviceTimeCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::getLocation(
     ::grpc::ServerContext* context, const ::aurum::ReqGetLocation* request,
     ::aurum::RspGetLocation* response)
@@ -167,6 +191,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<GetLocationCommand> cmd = std::make_unique<GetLocationCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::sendKey(::grpc::ServerContext* context,
                                          const ::aurum::ReqKey* request,
                                          ::aurum::RspKey*       response)
@@ -174,6 +199,7 @@ aurumServiceImpl::~aurumServiceImpl() {}
     std::unique_ptr<SendKeyCommand> cmd = std::make_unique<SendKeyCommand>(request, response);
     return execute(cmd.get());
 }
+
 ::grpc::Status aurumServiceImpl::takeScreenshot(::grpc::ServerContext* context,
                                                 const ::aurum::ReqTakeScreenshot* request,
                                                 ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer)
index 6ef11e2..0edd35d 100644 (file)
@@ -58,7 +58,7 @@ static void _service_app_control(app_control_h app_control, void *data)
 {
     ServiceContext *ctx = (ServiceContext*)data;
     if (!ctx)
-       LOGE("Service context is empty!");
+        LOGE("Service context is empty!");
 }
 
 int main(int argc, char **argv)
index f40f7cb..e1d0b51 100644 (file)
@@ -39,7 +39,7 @@ CloseAppCommand::CloseAppCommand(const ::aurum::ReqCloseApp* request,
 
 ::grpc::Status CloseAppCommand::executePost()
 {
-    LOGI("CloseAppCommand::executePost");
+    LOGI("Wait for 1500ms");
     std::this_thread::sleep_for(std::chrono::milliseconds{1500});
     return grpc::Status::OK;
 }
\ No newline at end of file
index 38a3686..cba8037 100644 (file)
@@ -17,8 +17,8 @@ GetAttributeCommand::GetAttributeCommand(
 std::unique_ptr<GetAttributeCommand> GetAttributeCommand::createCommand(const ::aurum::ReqGetAttribute* request,
                                                                         ::aurum::RspGetAttribute*       response)
 {
+    LOGI("GetAttribute --------------- ");
     ::aurum::ReqGetAttribute_RequestType type = request->attribute();
-
     LOGI("type : %d", type);
 
     if (type == ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_VISIBLE)
@@ -179,7 +179,6 @@ std::unique_ptr<GetAttributeCommand> GetAttributeCommand::createCommand(const ::
     return grpc::Status::OK;
 }
 
-
 ::grpc::Status GetShowingAttributeCommand::execute()
 {
     std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
@@ -193,8 +192,6 @@ std::unique_ptr<GetAttributeCommand> GetAttributeCommand::createCommand(const ::
     return grpc::Status::OK;
 }
 
-
-
 ::grpc::Status GetActiveAttributeCommand::execute()
 {
     std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
index f475da2..500557a 100644 (file)
@@ -40,7 +40,7 @@ InstallAppCommand::InstallAppCommand(
 
 ::grpc::Status InstallAppCommand::executePost()
 {
-    LOGI("InstallAppCommand::executePost");
+    LOGI("Wait for 5000ms");
     std::this_thread::sleep_for(std::chrono::milliseconds{5000});
     return grpc::Status::OK;
 }
\ No newline at end of file
index 8a8641f..72f9e3f 100644 (file)
@@ -9,7 +9,7 @@ KillServerCommand::KillServerCommand(const ::aurum::ReqEmpty* request,
 
 ::grpc::Status KillServerCommand::execute()
 {
-    LOGI("Kill Server ");
+    LOGI("Kill Server --------------- ");
 
     exit(1);
 
index b2a01c3..2d2ab15 100644 (file)
@@ -25,14 +25,14 @@ LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp* request,
 
     ret = app_control_create(&appControl);
     if (ret) {
-        LOGI("Launch Failed(1/3) Err Code : %ull", ret);
+        LOGE("Launch Failed(1/3) Err Code : %ull", ret);
         mResponse->set_status(::aurum::RspStatus::ERROR);
         return grpc::Status::OK;
     }
 
     ret = app_control_set_app_id(appControl, packageName.c_str());
     if (ret) {
-        LOGI("Launch Failed(2/3) Err Code : %ull", ret);
+        LOGE("Launch Failed(2/3) Err Code : %ull", ret);
         mResponse->set_status(::aurum::RspStatus::ERROR);
         app_control_destroy(appControl);
         return grpc::Status::OK;
@@ -40,7 +40,7 @@ LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp* request,
 
     ret = app_control_send_launch_request(appControl, NULL, NULL);
     if (ret) {
-        LOGI("Launch Failed(3/3) Err Code : %ull", ret);
+        LOGE("Launch Failed(3/3) Err Code : %ull", ret);
         mResponse->set_status(::aurum::RspStatus::ERROR);
         app_control_destroy(appControl);
         return grpc::Status::OK;
@@ -52,7 +52,7 @@ LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp* request,
 }
 ::grpc::Status LaunchAppCommand::executePost()
 {
-    LOGI("LaunchAppCommand::executePost");
+    LOGI("Wait for 2500ms");
     std::this_thread::sleep_for(std::chrono::milliseconds{2500});
     return grpc::Status::OK;
 }
index 2a2a5e1..f9b39f0 100644 (file)
@@ -8,10 +8,9 @@ PostCommand::PostCommand(Command *cmd) : mCommand{cmd} {}
 ::grpc::Status PostCommand::execute()
 {
     ::grpc::Status rst = mCommand->execute();
-    LOGI("PostCommand --------------- ");
+
     mCommand->executePost();
 
-    // do post-command
     return rst;
 }
 
index 218e3d5..7c20460 100644 (file)
@@ -33,7 +33,7 @@ RemoveAppCommand::RemoveAppCommand(const ::aurum::ReqRemoveApp* request,
 
 ::grpc::Status RemoveAppCommand::executePost()
 {
-     LOGI("RemoveAppCommand::executePost");
+    LOGI("Wait for 5000ms");
     std::this_thread::sleep_for(std::chrono::milliseconds{5000});
     return grpc::Status::OK;
 }
index 8e4e4ac..30538fe 100644 (file)
@@ -9,7 +9,8 @@ SetValueCommand::SetValueCommand(const ::aurum::ReqSetValue* request,
 
 ::grpc::Status SetValueCommand::execute()
 {
-    LOGI("SetValue (text:%s) --------------- ", mRequest->stringvalue().c_str());
+    LOGI("SetValue --------------- ");
+    LOGI("text:%s", mRequest->stringvalue().c_str());
     ObjectMapper* mObjMap = ObjectMapper::getInstance();
     std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
     if (obj) obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
index aa07fb5..fb741ef 100644 (file)
@@ -36,7 +36,7 @@ std::shared_ptr<UiObject> ObjectMapper::getElement(std::string key)
         LOGI("succeeded");
         return obj;
     }
-    LOGI("failed(object not found)");
+    LOGI("key is not exist in mObjectMap");
     return nullptr;
 }
 
@@ -48,7 +48,7 @@ std::string ObjectMapper::getElement(std::shared_ptr<UiObject> object)
         LOGI("succeeded");
         return mObjectMapReverse[value];
     }
-    LOGI("failed(object not found)");
+    LOGI("object is not exist in mObjectMapReverse");
     return std::string{""};
 }
 
@@ -100,16 +100,3 @@ void ObjectMapper::cleanUp()
     ss << std::endl;
     LOGI("%s", ss.str().c_str());
 }
-
-//    std::remove_if(mObjectMapReverse.begin(), mObjectMapReverse.end(), [](auto& pair){return !pair.first->isValid();});
-    //auto iter = std::find_if(mObjectMap.begin(), mObjectMap.end(), [](const std::pair<std::string, std::shared_ptr<UiObject>>& pair)->bool{
-        //return !pair.second->isValid();
-    //});
-/*
-    while ( iter != mObjectMap.end()) {
-        removeElement(iter->second);
-        iter = std::find_if(std::next(iter), mObjectMap.end(), [](const std::pair<std::string, std::shared_ptr<UiObject>>& pair)->bool{
-            return !pair.second->isValid();
-        });
-    }
-    */