--- /dev/null
+// Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/configuration/step_check_install_location.h"
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <cstring>
+#include <string>
+
+#include "common/installer_context.h"
+
+namespace {
+
+const char kInstalledInternally[] = "installed_internal";
+const char kInstalledExternally[] = "installed_external";
+const char kInstalledExtended[] = "installed_extended";
+
+const char kDefaultStorageVconfKey[] =
+ VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT;
+
+} // namespace
+
+namespace common_installer {
+namespace configuration {
+
+Step::Status StepCheckInstallLocation::process() {
+ manifest_x* manifest = context_->manifest_data.get();
+ if (!manifest->installed_storage || !strlen(manifest->installed_storage)) {
+ // int type vconf value:
+ // 0 means internal storage, 1 means external storage
+ int default_storage = 0;
+ if (vconf_get_int(kDefaultStorageVconfKey, &default_storage))
+ LOG(WARNING) << "Cannot get default storage type, set internal storage "
+ << "as default value";
+ if (default_storage == 0)
+ context_->storage.set(Storage::INTERNAL);
+ else if (default_storage == 1)
+ context_->storage.set(Storage::EXTERNAL);
+ else
+ context_->storage.set(Storage::EXTENDED);
+ } else {
+ if (!strcmp(manifest->installed_storage, kInstalledInternally)) {
+ context_->storage.set(Storage::INTERNAL);
+ } else if (!strcmp(manifest->installed_storage, kInstalledExternally)) {
+ context_->storage.set(Storage::EXTERNAL);
+ } else if (!strcmp(manifest->installed_storage, kInstalledExtended)) {
+ context_->storage.set(Storage::EXTENDED);
+ } else {
+ LOG(WARNING) << "Unknown installed storage: "
+ << manifest->installed_storage;
+ LOG(WARNING) << "Assume installed at internal storage";
+ context_->storage.set(Storage::INTERNAL);
+ }
+ }
+
+ return Status::OK;
+}
+
+} // namespace configuration
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_CONFIGURATION_STEP_CHECK_INSTALL_LOCATION_H_
+#define COMMON_STEP_CONFIGURATION_STEP_CHECK_INSTALL_LOCATION_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace configuration {
+
+class StepCheckInstallLocation : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ STEP_NAME(CheckInstallLocation)
+};
+
+} // namespace configuration
+} // namespace common_installer
+
+#endif // COMMON_STEP_CONFIGURATION_STEP_CHECK_INSTALL_LOCATION_H_