Commit 45c60e12 authored by Yusuke Sato's avatar Yusuke Sato Committed by Chromium LUCI CQ

arc: Stop exporting GenerateUpgradeProps() function

This makes it clear that arc_vm_client_adapter.h should only have
factory functions and testing functions.

BUG=None
TEST=try

Change-Id: I47d70028d22a4c376eac3079a0523e8a4c38a59e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2594791Reviewed-by: default avatarWillie Koomson <wvk@google.com>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837784}
parent 41fa43ca
...@@ -148,6 +148,44 @@ ArcBinaryTranslationType IdentifyBinaryTranslationType( ...@@ -148,6 +148,44 @@ ArcBinaryTranslationType IdentifyBinaryTranslationType(
return ArcBinaryTranslationType::HOUDINI; return ArcBinaryTranslationType::HOUDINI;
} }
std::vector<std::string> GenerateUpgradeProps(
const UpgradeParams& upgrade_params,
const std::string& serial_number,
const std::string& prefix) {
std::vector<std::string> result = {
base::StringPrintf("%s.disable_boot_completed=%d", prefix.c_str(),
upgrade_params.skip_boot_completed_broadcast),
base::StringPrintf("%s.enable_adb_sideloading=%d", prefix.c_str(),
upgrade_params.is_adb_sideloading_enabled),
base::StringPrintf("%s.copy_packages_cache=%d", prefix.c_str(),
static_cast<int>(upgrade_params.packages_cache_mode)),
base::StringPrintf("%s.skip_gms_core_cache=%d", prefix.c_str(),
upgrade_params.skip_gms_core_cache),
base::StringPrintf("%s.arc_demo_mode=%d", prefix.c_str(),
upgrade_params.is_demo_session),
base::StringPrintf(
"%s.supervision.transition=%d", prefix.c_str(),
static_cast<int>(upgrade_params.supervision_transition)),
base::StringPrintf("%s.serialno=%s", prefix.c_str(),
serial_number.c_str()),
};
// Conditionally sets more properties based on |upgrade_params|.
if (!upgrade_params.locale.empty()) {
result.push_back(base::StringPrintf("%s.locale=%s", prefix.c_str(),
upgrade_params.locale.c_str()));
if (!upgrade_params.preferred_languages.empty()) {
result.push_back(base::StringPrintf(
"%s.preferred_languages=%s", prefix.c_str(),
base::JoinString(upgrade_params.preferred_languages, ",").c_str()));
}
}
// TODO(niwa): Handle |is_account_managed| and
// |is_managed_adb_sideloading_allowed| in |upgrade_params| when we
// implement apk sideloading for ARCVM.
return result;
}
std::vector<std::string> GenerateKernelCmdline( std::vector<std::string> GenerateKernelCmdline(
const StartParams& start_params, const StartParams& start_params,
const UpgradeParams& upgrade_params, const UpgradeParams& upgrade_params,
...@@ -871,42 +909,11 @@ void EnableAdbOverUsbForTesting() { ...@@ -871,42 +909,11 @@ void EnableAdbOverUsbForTesting() {
g_enable_adb_over_usb_for_testing = true; g_enable_adb_over_usb_for_testing = true;
} }
std::vector<std::string> GenerateUpgradeProps( std::vector<std::string> GenerateUpgradePropsForTesting(
const UpgradeParams& upgrade_params, const UpgradeParams& upgrade_params,
const std::string& serial_number, const std::string& serial_number,
const std::string& prefix) { const std::string& prefix) {
std::vector<std::string> result = { return GenerateUpgradeProps(upgrade_params, serial_number, prefix);
base::StringPrintf("%s.disable_boot_completed=%d", prefix.c_str(),
upgrade_params.skip_boot_completed_broadcast),
base::StringPrintf("%s.enable_adb_sideloading=%d", prefix.c_str(),
upgrade_params.is_adb_sideloading_enabled),
base::StringPrintf("%s.copy_packages_cache=%d", prefix.c_str(),
static_cast<int>(upgrade_params.packages_cache_mode)),
base::StringPrintf("%s.skip_gms_core_cache=%d", prefix.c_str(),
upgrade_params.skip_gms_core_cache),
base::StringPrintf("%s.arc_demo_mode=%d", prefix.c_str(),
upgrade_params.is_demo_session),
base::StringPrintf(
"%s.supervision.transition=%d", prefix.c_str(),
static_cast<int>(upgrade_params.supervision_transition)),
base::StringPrintf("%s.serialno=%s", prefix.c_str(),
serial_number.c_str()),
};
// Conditionally sets more properties based on |upgrade_params|.
if (!upgrade_params.locale.empty()) {
result.push_back(base::StringPrintf("%s.locale=%s", prefix.c_str(),
upgrade_params.locale.c_str()));
if (!upgrade_params.preferred_languages.empty()) {
result.push_back(base::StringPrintf(
"%s.preferred_languages=%s", prefix.c_str(),
base::JoinString(upgrade_params.preferred_languages, ",").c_str()));
}
}
// TODO(niwa): Handle |is_account_managed| and
// |is_managed_adb_sideloading_allowed| in |upgrade_params| when we
// implement apk sideloading for ARCVM.
return result;
} }
} // namespace arc } // namespace arc
...@@ -46,7 +46,7 @@ void EnableAdbOverUsbForTesting(); ...@@ -46,7 +46,7 @@ void EnableAdbOverUsbForTesting();
// Generates a list of props from |upgrade_params|, each of which takes the form // Generates a list of props from |upgrade_params|, each of which takes the form
// "prefix.prop_name=value" // "prefix.prop_name=value"
std::vector<std::string> GenerateUpgradeProps( std::vector<std::string> GenerateUpgradePropsForTesting(
const UpgradeParams& upgrade_params, const UpgradeParams& upgrade_params,
const std::string& serial_number, const std::string& serial_number,
const std::string& prefix); const std::string& prefix);
......
...@@ -1392,10 +1392,10 @@ TEST_F(ArcVmClientAdapterTest, TestConnectToBootNotificationServer) { ...@@ -1392,10 +1392,10 @@ TEST_F(ArcVmClientAdapterTest, TestConnectToBootNotificationServer) {
EXPECT_EQ(boot_notification_server()->connection_count(), 2); EXPECT_EQ(boot_notification_server()->connection_count(), 2);
EXPECT_FALSE(boot_notification_server()->received_data().empty()); EXPECT_FALSE(boot_notification_server()->received_data().empty());
// Compare received data to expected output // Compare received data to expected output
std::string expected_props = std::string expected_props = base::JoinString(
base::JoinString(GenerateUpgradeProps(GetPopulatedUpgradeParams(), GenerateUpgradePropsForTesting(GetPopulatedUpgradeParams(), kSerialNumber,
kSerialNumber, "ro.boot"), "ro.boot"),
"\n"); "\n");
EXPECT_EQ(boot_notification_server()->received_data(), expected_props); EXPECT_EQ(boot_notification_server()->received_data(), expected_props);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment