Add GetRequestTypeString() to print request type 36/200236/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 20 Feb 2019 10:52:11 +0000 (19:52 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 20 Feb 2019 10:52:11 +0000 (19:52 +0900)
Change-Id: Icb089a5eb63ef05fcd4e543f3a78995804528675
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/external_storage.cc
src/common/request.cc
src/common/request.h

index 8604c23..5b01685 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <manifest_parser/utils/logging.h>
 
+#include "common/request.h"
 #include "common/utils/byte_size_literals.h"
 #include "common/utils/file_util.h"
 
@@ -115,7 +116,8 @@ bool ExternalStorage::Finalize(bool success) {
                                                             uid_);
     break;
   default:
-    LOG(ERROR) << "Not supported installation mode";
+    LOG(ERROR) << "Not supported installation mode ("
+               << GetRequestTypeString(type_) << ")";
   }
   return ret == APP2EXT_STATUS_SUCCESS;
 }
@@ -220,7 +222,8 @@ bool ExternalStorage::Initialize(
                                                            uid_);
     break;
   default:
-    LOG(ERROR) << "Installation type is not supported by external installation";
+    LOG(ERROR) << "Installation type (" << GetRequestTypeString(type_) << ")"
+               << " is not supported by external installation";
     ret = -1;
     break;
   }
index d1b98a1..ed404a3 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "common/request.h"
 
+#include <map>
+#include <string>
 #include <tzplatform_config.h>
 #include <unistd.h>
 
@@ -13,6 +15,39 @@ namespace bf = boost::filesystem;
 
 namespace common_installer {
 
+const std::map<RequestType, const char*> kRequestTypeStringMap = {
+  {RequestType::Unknown, "Unknown"},
+  {RequestType::Install, "Install"},
+  {RequestType::Update, "Update"},
+  {RequestType::Uninstall, "Uninstall"},
+  {RequestType::Reinstall, "Reinstall"},
+  {RequestType::Delta, "Delta"},
+  {RequestType::Move, "Move"},
+  {RequestType::Recovery, "Recovery"},
+  {RequestType::RecoveryUpdate, "RecoveryUpdate"},
+  {RequestType::MountInstall, "MountInstall"},
+  {RequestType::MountUpdate, "MountUpdate"},
+  {RequestType::ManifestDirectInstall, "ManifestDirectInstall"},
+  {RequestType::ManifestDirectUpdate, "ManifestDirectUpdate"},
+  {RequestType::ManifestPartialInstall, "ManifestPartialInstall"},
+  {RequestType::ManifestPartialUpdate, "ManifestPartialUpdate"},
+  {RequestType::PartialUninstall, "PartialUninstall"},
+  {RequestType::ReadonlyUpdateInstall, "ReadonlyUpdateInstall"},
+  {RequestType::ReadonlyUpdateUninstall, "ReadonlyUpdateUninstall"},
+  {RequestType::DisablePkg, "DisablePkg"},
+  {RequestType::EnablePkg, "EnablePkg"},
+  {RequestType::MigrateExtImg, "MigrateExtImg"},
+  {RequestType::RecoverDB, "RecoverDB"},
+};
+
+std::string GetRequestTypeString(RequestType request_type) {
+  const auto& it = kRequestTypeStringMap.find(request_type);
+  if (it == kRequestTypeStringMap.end())
+    return "Unknown";
+  else
+    return it->second;
+}
+
 RequestMode GetRequestMode(uid_t uid) {
   return (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) ?
       RequestMode::GLOBAL : RequestMode::USER;
index 92e4f0c..db1bab6 100644 (file)
@@ -44,6 +44,13 @@ enum class RequestMode : int {
 };
 
 /**
+ * Get string of given request type
+ *
+ * \return request mode
+ */
+std::string GetRequestTypeString(RequestType request_type);
+
+/**
  * Get mode for current request (GLOBAL/USER)
  *
  * \return request mode