Improve aulctl tool 16/271016/7
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 14 Feb 2022 08:04:17 +0000 (17:04 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 15 Feb 2022 04:11:20 +0000 (04:11 +0000)
Changes:
 - Adds timestamp to status commands.
 - Changes output of list-dependencies command.
 - Adds description of aul-keys for boot sequence apis.
 - Moves boot_sequence sources to aulctl

Change-Id: I349ab1d29a2e9e147612053106bcaad6cf429514
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
16 files changed:
CMakeLists.txt
include/aul_key.h
src/aul_sock.c
tool/aulctl/CMakeLists.txt
tool/aulctl/boot_sequence/app_info.cc [moved from aul/boot_sequence/app_info.cc with 89% similarity]
tool/aulctl/boot_sequence/app_info.hh [moved from aul/boot_sequence/app_info.hh with 86% similarity]
tool/aulctl/boot_sequence/boot_sequence_manager.cc [moved from aul/boot_sequence/boot_sequence_manager.cc with 96% similarity]
tool/aulctl/boot_sequence/boot_sequence_manager.hh [moved from aul/boot_sequence/boot_sequence_manager.hh with 83% similarity]
tool/aulctl/operation/is_active_operation.cc
tool/aulctl/operation/list_apps_operation.cc
tool/aulctl/operation/list_dependencies_operation.cc
tool/aulctl/operation/reload_operation.cc
tool/aulctl/operation/start_operation.cc
tool/aulctl/operation/status_all_operation.cc
tool/aulctl/operation/status_once_operation.cc
tool/aulctl/operation/stop_operation.cc

index 4a977fe..75def48 100644 (file)
@@ -67,7 +67,6 @@ AUX_SOURCE_DIRECTORY(aul/app_info AUL_APP_INFO_SRCS)
 AUX_SOURCE_DIRECTORY(aul/common AUL_COMMON_SRCS)
 AUX_SOURCE_DIRECTORY(aul/component AUL_COMPONENT_SRCS)
 AUX_SOURCE_DIRECTORY(aul/socket AUL_SOCKET_SRCS)
-AUX_SOURCE_DIRECTORY(aul/boot_sequence AUL_BOOT_SEQUENCE_SRCS)
 
 ADD_LIBRARY(${TARGET_AUL} SHARED
   ${SRCS}
index 0ab3311..54524a0 100644 (file)
  */
 #define AUL_K_RESTART_EXTRA             "__AUL_RESTART_EXTRA__"
 
-#define AUL_K_SUB_STATUS                "__AUL_SUB_STATUS__"
-
-#define AUL_K_BOOT_SEQUENCE_CMD         "__AUL_BOOT_SEQUENCE_CMD__"
+/**
+ * @brief Definition for AUL: The priority of boot sequence app.
+ * @since_tizen 7.0
+ */
+#define AUL_K_BOOT_SEQUENCE_PRIORITY    "__AUL_BOOT_SEQUENCE_PRIORITY__"
 
-#define AUL_K_BOOT_SEQUENCE_LOGS        "__AUL_BOOT_SEQUENCE_LOGS__"
+/**
+ * @brief Definition for AUL: The flag of boot sequence app's reqdy wait.
+ * @since_tizen 7.0
+ */
+#define AUL_K_BOOT_SEQUENCE_READY_WAIT  "__AUL_BOOT_SEQUENCE_READY_WAIT__"
 
-#define AUL_K_BOOT_SEQUENCE_PRIORITY    "__AUL_BOOT_SEQUENCE_PRIORITY__"
+/**
+ * @brief Definition for AUL: The sub status of app.
+ * @since_tizen 7.0
+ */
+#define AUL_K_SUB_STATUS                "__AUL_SUB_STATUS__"
 
+/**
+ * @brief Definition for AUL: The appid list of boot sequence app's after dependency.
+ * @since_tizen 7.0
+ */
 #define AUL_K_BOOT_SEQUENCE_AFTER       "__AUL_BOOT_SEQUENCE_AFTER__"
 
+/**
+ * @brief Definition for AUL: The appid list of boot sequence app's before dependency.
+ * @since_tizen 7.0
+ */
 #define AUL_K_BOOT_SEQUENCE_BEFORE      "__AUL_BOOT_SEQUENCE_BEFORE__"
 
+/**
+ * @brief Definition for AUL: The appid list of boot sequence app's requires dependency.
+ * @since_tizen 7.0
+ */
 #define AUL_K_BOOT_SEQUENCE_REQUIRES    "__AUL_BOOT_SEQUENCE_REQUIRES__"
 
+/**
+ * @brief Definition for AUL: The appid list of boot sequence app's conflicts dependency.
+ * @since_tizen 7.0
+ */
 #define AUL_K_BOOT_SEQUENCE_CONFLICTS   "__AUL_BOOT_SEQUENCE_CONFLICTS__"
 
+/**
+ * @brief Definition for AUL: The args bundle data.
+ * @since_tizen 7.0
+ */
 #define AUL_K_ARGS                      "__AUL_ARGS__"
 
-#define AUL_K_BOOT_SEQUENCE_READY_WAIT  "__AUL_BOOT_SEQUENCE_READY_WAIT__"
-
+/**
+ * @brief Definition for AUL: The timeout.
+ * @since_tizen 7.0
+ */
 #define AUL_K_TIMEOUT                   "__AUL_TIMEOUT__"
+
+/**
+ * @brief Definition for AUL: The begin timestamp of boot sequence app's start.
+ * @since_tizen 7.0
+ */
+#define AUL_K_BEGIN_TIMESTAMP           "__AUL_BEGIN_TIMESTAMP__"
+
+/**
+ * @brief Definition for AUL: The end timestamp of boot sequence app's start.
+ * @since_tizen 7.0
+ */
+#define AUL_K_END_TIMESTAMP             "__AUL_END_TIMESTAMP__"
index fdab342..02f61e5 100644 (file)
@@ -810,7 +810,7 @@ retry_con:
        return fd;
 }
 
-int aul_sock_recv_pkt_with_cb(int fd,
+API int aul_sock_recv_pkt_with_cb(int fd,
                void (*callback)(app_pkt_t *pkt, void *data),
                void *user_data)
 {
index cc36a8b..1ef41b2 100644 (file)
@@ -1,10 +1,12 @@
 SET(TARGET_AULCTL "aulctl")
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} AULCTL_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/boot_sequence BS_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/operation OP_SRCS)
 
 ADD_EXECUTABLE(${TARGET_AULCTL}
   ${AULCTL_SRCS}
+  ${BS_SRCS}
   ${OP_SRCS}
 )
 
@@ -17,11 +19,11 @@ TARGET_LINK_LIBRARIES(${TARGET_AULCTL} PRIVATE
   ${TARGET_AUL_SERVER})
 
 TARGET_INCLUDE_DIRECTORIES(${TARGET_AULCTL} PUBLIC
+  ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../../
   ${CMAKE_CURRENT_SOURCE_DIR}/../../src
   ${CMAKE_CURRENT_SOURCE_DIR}/../../include
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../server
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../server/api)
+)
 
 APPLY_PKG_CONFIG(${TARGET_AULCTL} PUBLIC
   GLIB_DEPS
similarity index 89%
rename from aul/boot_sequence/app_info.cc
rename to tool/aulctl/boot_sequence/app_info.cc
index dc22cc8..046846b 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "aul/boot_sequence/app_info.hh"
+#include "app_info.hh"
 
 #include <bundle_internal.h>
 
@@ -132,6 +132,18 @@ AppInfo::Builder& AppInfo::Builder::SetSubState(
   return *this;
 }
 
+AppInfo::Builder& AppInfo::Builder::SetBeginTimestamp(
+    const tizen_base::Bundle& args) {
+  begin_timestamp_ = args.GetString(AUL_K_BEGIN_TIMESTAMP);
+  return *this;
+}
+
+AppInfo::Builder& AppInfo::Builder::SetEndTimestamp(
+    const tizen_base::Bundle& args) {
+  end_timestamp_ = args.GetString(AUL_K_END_TIMESTAMP);
+  return *this;
+}
+
 AppInfo* AppInfo::Builder::Build() const {
   return new (std::nothrow) AppInfo(
       std::move(appid_),
@@ -144,6 +156,8 @@ AppInfo* AppInfo::Builder::Build() const {
       std::move(args_),
       std::move(active_state_),
       std::move(sub_state_),
+      std::move(begin_timestamp_),
+      std::move(end_timestamp_),
       background_launch_,
       wait_until_ready_,
       timeout_);
@@ -154,6 +168,7 @@ AppInfo::AppInfo(std::string appid, uid_t uid, int priority,
     std::set<std::string> requires, std::set<std::string> conflicts,
     tizen_base::Bundle args,
     std::string active_state, std::string sub_state,
+    std::string begin_timestamp, std::string end_timestamp,
     bool background_launch, bool wait_until_ready, unsigned int timeout)
     : appid_(std::move(appid)),
       uid_(uid),
@@ -164,6 +179,9 @@ AppInfo::AppInfo(std::string appid, uid_t uid, int priority,
       conflicts_(std::move(conflicts)),
       args_(std::move(args)),
       active_state_(std::move(active_state)),
+      sub_state_(std::move(sub_state)),
+      begin_timestamp_(std::move(begin_timestamp)),
+      end_timestamp_(std::move(end_timestamp)),
       background_launch_(background_launch),
       wait_until_ready_(wait_until_ready),
       timeout_(timeout) {
@@ -245,6 +263,14 @@ const std::string& AppInfo::GetSubState() const {
   return sub_state_;
 }
 
+const std::string& AppInfo::GetBeginTimestamp() const {
+  return begin_timestamp_;
+}
+
+const std::string& AppInfo::GetEndTimestamp() const {
+  return end_timestamp_;
+}
+
 const std::string& AppInfo::GetStatusMessage() const {
   return status_msg_;
 }
similarity index 86%
rename from aul/boot_sequence/app_info.hh
rename to tool/aulctl/boot_sequence/app_info.hh
index 11b1925..924bad9 100644 (file)
  * limitations under the License.
  */
 
-/*
- * This header is only appfw internal api.
- * It is cpp header.
- */
-
-#ifndef AUL_INTERNAL_BOOT_SEQUENCE_APP_INFO_HH_
-#define AUL_INTERNAL_BOOT_SEQUENCE_APP_INFO_HH_
+#ifndef AULCTL_BOOT_SEQUENCE_APP_INFO_HH_
+#define AULCTL_BOOT_SEQUENCE_APP_INFO_HH_
 
 #include <bundle_cpp.h>
 
@@ -51,6 +46,9 @@ class AppInfo {
     Builder& SetTimeout(const tizen_base::Bundle& args);
     Builder& SetActiveState(const tizen_base::Bundle& args);
     Builder& SetSubState(const tizen_base::Bundle& args);
+    Builder& SetBeginTimestamp(const tizen_base::Bundle& args);
+    Builder& SetEndTimestamp(const tizen_base::Bundle& args);
+
     AppInfo* Build() const;
 
    private:
@@ -64,6 +62,8 @@ class AppInfo {
     tizen_base::Bundle args_;
     std::string active_state_;
     std::string sub_state_;
+    std::string begin_timestamp_;
+    std::string end_timestamp_;
     bool background_launch_;
     bool wait_until_ready_;
     unsigned int timeout_;
@@ -74,6 +74,7 @@ class AppInfo {
           std::set<std::string> requires, std::set<std::string> conflicts,
           tizen_base::Bundle args,
           std::string active_state, std::string sub_state,
+          std::string begin_timestamp, std::string end_timestamp,
           bool background_launch, bool wait_until_ready, unsigned int timeout);
 
   const std::string& GetAppId() const;
@@ -98,6 +99,8 @@ class AppInfo {
   unsigned int GetTimeout() const;
   const std::string& GetActiveState() const;
   const std::string& GetSubState() const;
+  const std::string& GetBeginTimestamp() const;
+  const std::string& GetEndTimestamp() const;
   const std::string& GetStatusMessage() const;
 
  private:
@@ -111,10 +114,12 @@ class AppInfo {
   std::vector<std::string> required_by_;
   tizen_base::Bundle args_;
   std::string active_state_;
+  std::string sub_state_;
+  std::string begin_timestamp_;
+  std::string end_timestamp_;
   bool background_launch_;
   bool wait_until_ready_;
   unsigned int timeout_;
-  std::string sub_state_ = "dead";
   std::string status_msg_;
 };
 
@@ -122,4 +127,4 @@ class AppInfo {
 
 }  // namespace aul::internal
 
-#endif  // AUL_INTERNAL_BOOT_SEQUENCE_APP_INFO_HH_
+#endif  // AULCTL_BOOT_SEQUENCE_APP_INFO_HH_
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence_manager.hh"
 
 #include <unistd.h>
 
@@ -40,7 +40,9 @@ AppInfoPtr BootSequenceManager::CreateAppInfoFromBundle(tizen_base::Bundle b) {
       .SetArgs(b)
       .SetTimeout(b)
       .SetActiveState(b)
-      .SetSubState(b);
+      .SetSubState(b)
+      .SetBeginTimestamp(b)
+      .SetEndTimestamp(b);
 
   return std::shared_ptr<AppInfo>(builder.Build());
 }
  * limitations under the License.
  */
 
-/*
- * This header is only appfw internal api.
- * It is cpp header.
- */
-
-#ifndef AUL_INTERNAL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
-#define AUL_INTERNAL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
+#ifndef AULCTL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
+#define AULCTL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
 
 #include <bundle_cpp.h>
 
@@ -29,7 +24,7 @@
 #include <vector>
 
 #include "include/aul_sock.h"
-#include "aul/boot_sequence/app_info.hh"
+#include "app_info.hh"
 
 namespace aul::internal {
 namespace boot_sequence {
@@ -59,4 +54,4 @@ class BootSequenceManager {
 }  // namespace boot_sequence
 }  // namespace aul::internal
 
-#endif  // AUL_INTERNAL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
+#endif  // AULCTL_BOOT_SEQUENCE_BOOT_SEQUENCE_MANAGER_HH_
index 8efd6d0..a75b973 100644 (file)
@@ -20,7 +20,7 @@
 #include <string>
 #include <utility>
 
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
index d8bfdeb..2d20a50 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <iostream>
 
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
index 6b233ae..a93b096 100644 (file)
@@ -24,7 +24,7 @@
 #include <string>
 #include <vector>
 
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
@@ -39,7 +39,6 @@ bool ListDependenciesOperation::Process() {
     return false;
   }
 
-  std::cout << uid_ << " user boot sequence app dependencies" << std::endl;
   std::map<std::string, internal::boot_sequence::AppInfoPtr> infos;
   std::map<std::string, int> req_cnt;
   for (auto& app : app_list) {
@@ -47,34 +46,38 @@ bool ListDependenciesOperation::Process() {
     if (req_cnt.find(app->GetAppId()) == req_cnt.end())
       req_cnt[app->GetAppId()] = 0;
 
-    for (auto &appid : app->AfterGet())
+    for (auto &appid : app->BeforeGet())
       req_cnt[appid]++;
   }
 
-  /* depth, appinfo */
-  std::stack<std::pair<int, internal::boot_sequence::AppInfoPtr>> stack;
+  std::stack<internal::boot_sequence::AppInfoPtr> stack;
   for (auto& [appid, cnt] : req_cnt) {
     if (cnt == 0 && infos.find(appid) != infos.end())
-      stack.emplace(0, infos[appid]);
+      stack.push(infos[appid]);
   }
 
   while (!stack.empty()) {
-    auto [cnt, app] = std::move(stack.top());
+    auto app = std::move(stack.top());
     stack.pop();
 
-    for (int i = 0; i < cnt; ++i)
-      std::cout << "+";
-
     std::cout << app->GetAppId() << std::endl;
-    for (auto& appid : app->AfterGet()) {
-      if (--req_cnt[appid] == 0 && infos.find(appid) != infos.end()) {
-        stack.emplace(cnt + 1, infos[appid]);
-      } else {
-        for (int i = 0; i < cnt + 1; ++i)
-          std::cout << "+";
-
-        std::cout << appid << std::endl;
-      }
+    std::cout << "  After: ";
+    for (auto& appid : app->AfterGet())
+      std::cout << appid << ' ';
+
+    std::cout << std::endl << "  Before: ";
+    for (auto& appid : app->BeforeGet())
+      std::cout << appid << ' ';
+
+    std::cout << std::endl << "  Conflicts: ";
+    for (auto& appid : app->ConflictsGet())
+      std::cout << appid << ' ';
+
+    std::cout << std::endl;
+    std::cout << "============================================" << std::endl;
+    for (auto& appid : app->BeforeGet()) {
+      if (--req_cnt[appid] == 0 && infos.find(appid) != infos.end())
+        stack.push(infos[appid]);
     }
   }
 
index 3d0079d..5d88c95 100644 (file)
@@ -19,7 +19,7 @@
 #include <iostream>
 
 #include "include/aul.h"
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
index e910be7..daaaf46 100644 (file)
@@ -19,7 +19,7 @@
 #include <iostream>
 
 #include "include/aul.h"
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
index c5864eb..7232f26 100644 (file)
@@ -24,7 +24,7 @@
 #include <utility>
 
 #include "aul/api/aul_app_context.h"
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {
 
@@ -41,6 +41,7 @@ bool StatusAllOperation::Process() {
     std::cout << "appid: " << app->GetAppId() << std::endl;
 
     std::cout << "status: " << app->GetActiveState() << std::endl;
+    std::cout << "sub status: " << app->GetSubState() << std::endl;
 
     aul_app_context_h context;
     int ret = aul_app_context_create(app->GetAppId().c_str(), &context);
@@ -55,6 +56,8 @@ bool StatusAllOperation::Process() {
       aul_app_context_destroy(context);
     }
 
+    std::cout << "begin: " << app->GetBeginTimestamp() << std::endl;
+    std::cout << "end: " << app->GetEndTimestamp() << std::endl;
     std::cout << "requires: ";
     for (auto& appid : app->RequiresGet())
       std::cout << appid << " ";
index 1a8c96e..5ec0d86 100644 (file)
@@ -20,7 +20,7 @@
 #include <string>
 #include <utility>
 
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 #include "aul_app_context.h"
 #include "aul_boot_sequence.h"
 
@@ -45,6 +45,7 @@ bool StatusOnceOperation::Process() {
     std::cout << "appid: " << app->GetAppId() << std::endl;
 
     std::cout << "status: " << app->GetActiveState() << std::endl;
+    std::cout << "sub status: " << app->GetSubState() << std::endl;
 
     aul_app_context_h context;
     int ret = aul_app_context_create(app->GetAppId().c_str(), &context);
@@ -59,6 +60,8 @@ bool StatusOnceOperation::Process() {
       aul_app_context_destroy(context);
     }
 
+    std::cout << "begin: " << app->GetBeginTimestamp() << std::endl;
+    std::cout << "end: " << app->GetEndTimestamp() << std::endl;
     std::cout << "requires: ";
     for (auto& appid : app->RequiresGet())
       std::cout << appid << " ";
index 2286ac9..20411ec 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "aul/api/aul_app_context.h"
 #include "include/aul.h"
-#include "aul/boot_sequence/boot_sequence_manager.hh"
+#include "boot_sequence/boot_sequence_manager.hh"
 
 namespace aul {