summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2021-04-22 12:55:40 -0400
committerGitHub <noreply@github.com>2021-04-22 12:55:40 -0400
commitcd037d934d44c23e1d77b47b10e319b063f8150a (patch)
tree0380bceb3277066d07eb75ee930d380ce16c546f
parent32f9550551bcd10e084c051057cf204c80f68cd4 (diff)
downloadsdl_core-cd037d934d44c23e1d77b47b10e319b063f8150a.tar.gz
Store resumption data in storage folder (#3686)
* fix: store app info JSON file in AppStorageFolder * Update test cases to store app info JSON file in AppStorageFolder Co-authored-by: Sho Amano <samano@xevo.com>
-rw-r--r--src/appMain/smartDeviceLink.ini2
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc9
-rw-r--r--src/components/application_manager/test/app_launch/app_launch_data_json_test.cc14
-rw-r--r--src/components/resumption/src/last_state_impl.cc24
-rw-r--r--src/components/resumption/test/last_state_test.cc7
5 files changed, 40 insertions, 16 deletions
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index da85809197..d19f7ef7a1 100644
--- a/src/appMain/smartDeviceLink.ini
+++ b/src/appMain/smartDeviceLink.ini
@@ -158,7 +158,7 @@ ListFilesRequest = 5
HelpCommand = Help
[AppInfo]
-; The path for applications info storage.
+; The file name for applications info storage.
AppInfoStorage = app_info.dat
[Security Manager]
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index c7bb4b3210..7a12db09ff 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -3041,11 +3041,14 @@ void ApplicationManagerImpl::HeadUnitReset(
void ApplicationManagerImpl::ClearAppsPersistentData() {
SDL_LOG_AUTO_TRACE();
typedef std::vector<std::string> FilesList;
- const std::string apps_info_storage_file = get_settings().app_info_storage();
- file_system::DeleteFile(apps_info_storage_file);
-
const std::string storage_folder = get_settings().app_storage_folder();
+ const std::string apps_info_storage_file =
+ !storage_folder.empty()
+ ? storage_folder + "/" + get_settings().app_info_storage()
+ : get_settings().app_info_storage();
+ file_system::DeleteFile(apps_info_storage_file);
+
FilesList files = file_system::ListFiles(storage_folder);
FilesList::iterator element_to_skip =
std::find(files.begin(), files.end(), "policy.sqlite");
diff --git a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc
index f7bd636a66..240b5f7d01 100644
--- a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc
+++ b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc
@@ -60,17 +60,17 @@ using namespace file_system;
using namespace app_launch;
const std::string kAppStorageFolder = "app_storage_folder";
-const std::string kAppStorageFile = "./app_info.dat";
const std::string kAppInfoStorage = "app_info_storage";
class AppLaunchDataJsonTest : public ::testing::Test {
private:
virtual void SetUp() {
- ::file_system::DeleteFile(kAppStorageFile);
+ const std::string storage_file = kAppStorageFolder + "/" + kAppInfoStorage;
+ ::file_system::DeleteFile(storage_file);
last_state_wrapper_ = std::make_shared<resumption::LastStateWrapperImpl>(
std::make_shared<resumption::LastStateImpl>(kAppStorageFolder,
kAppInfoStorage));
- ASSERT_TRUE(::file_system::CreateFile(kAppStorageFile));
+ ASSERT_TRUE(::file_system::CreateFile(storage_file));
NiceMock<app_launch_test::MockAppLaunchSettings> mock_app_launch_settings_;
ON_CALL(mock_app_launch_settings_, max_number_of_ios_device())
@@ -85,10 +85,14 @@ class AppLaunchDataJsonTest : public ::testing::Test {
res_json_.get()->Clear();
}
- static void SetUpTestCase() {}
+ static void SetUpTestCase() {
+ ::file_system::RemoveDirectory(kAppStorageFolder);
+ ::file_system::CreateDirectoryRecursively(kAppStorageFolder);
+ }
static void TearDownTestCase() {
- ::file_system::DeleteFile(kAppStorageFile);
+ const std::string storage_file = kAppStorageFolder + "/" + kAppInfoStorage;
+ ::file_system::DeleteFile(storage_file);
::file_system::RemoveDirectory(kAppStorageFolder);
}
diff --git a/src/components/resumption/src/last_state_impl.cc b/src/components/resumption/src/last_state_impl.cc
index 185535c50d..2083369a8e 100644
--- a/src/components/resumption/src/last_state_impl.cc
+++ b/src/components/resumption/src/last_state_impl.cc
@@ -61,12 +61,17 @@ void LastStateImpl::SaveStateToFileSystem() {
styled_string = dictionary_.toStyledString();
}
+ const std::string full_path =
+ !app_storage_folder_.empty()
+ ? app_storage_folder_ + "/" + app_info_storage_
+ : app_info_storage_;
+
const std::vector<uint8_t> char_vector_pdata(styled_string.begin(),
styled_string.end());
DCHECK(file_system::CreateDirectoryRecursively(app_storage_folder_));
SDL_LOG_INFO("LastState::SaveStateToFileSystem[DEPRECATED] "
- << app_info_storage_ << styled_string);
- DCHECK(file_system::Write(app_info_storage_, char_vector_pdata));
+ << full_path << styled_string);
+ DCHECK(file_system::Write(full_path, char_vector_pdata));
}
void LastStateImpl::SaveToFileSystem() {
@@ -78,17 +83,26 @@ void LastStateImpl::SaveToFileSystem() {
styled_string = dictionary_.toStyledString();
}
+ const std::string full_path =
+ !app_storage_folder_.empty()
+ ? app_storage_folder_ + "/" + app_info_storage_
+ : app_info_storage_;
+
const std::vector<uint8_t> char_vector_pdata(styled_string.begin(),
styled_string.end());
DCHECK(file_system::CreateDirectoryRecursively(app_storage_folder_));
SDL_LOG_INFO("LastState::SaveToFileSystem " << app_info_storage_
- << styled_string);
- DCHECK(file_system::Write(app_info_storage_, char_vector_pdata));
+ << full_path);
+ DCHECK(file_system::Write(full_path, char_vector_pdata));
}
void LastStateImpl::LoadFromFileSystem() {
+ const std::string full_path =
+ !app_storage_folder_.empty()
+ ? app_storage_folder_ + "/" + app_info_storage_
+ : app_info_storage_;
std::string buffer;
- const bool result = file_system::ReadFile(app_info_storage_, buffer);
+ const bool result = file_system::ReadFile(full_path, buffer);
utils::JsonReader reader;
if (result && reader.parse(buffer, &dictionary_)) {
diff --git a/src/components/resumption/test/last_state_test.cc b/src/components/resumption/test/last_state_test.cc
index 61c227bbf3..c242f18099 100644
--- a/src/components/resumption/test/last_state_test.cc
+++ b/src/components/resumption/test/last_state_test.cc
@@ -50,12 +50,15 @@ class LastStateTest : public ::testing::Test {
protected:
LastStateTest()
: empty_dictionary_("null\n")
- , app_info_dat_file_("app_info.dat")
+ , app_info_dat_file_(kAppStorageFolder + "/" + kAppInfoStorageFile)
, last_state_(kAppStorageFolder, kAppInfoStorageFile) {}
static void SetUpTestCase() {
- file_system::DeleteFile(kAppInfoStorageFile);
+ const std::string storage_file =
+ kAppStorageFolder + "/" + kAppInfoStorageFile;
+ file_system::DeleteFile(storage_file);
file_system::RemoveDirectory(kAppStorageFolder);
+ file_system::CreateDirectoryRecursively(kAppStorageFolder);
}
void SetUp() OVERRIDE {