Commit f81cd1a8 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Pass is_demo_session flag with container upgrade request

BUG=b:110439301

Change-Id: I3ab1081653fbca1c1f427f2621d181f2fe0c1bc3
Reviewed-on: https://chromium-review.googlesource.com/1128326Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575684}
parent 825c668c
......@@ -976,20 +976,21 @@ void ArcSessionManager::StartArc() {
std::string preferred_lanaguages;
GetLocaleAndPreferredLanguages(profile_, &locale, &preferred_lanaguages);
chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
base::FilePath demo_session_apps_path;
if (demo_session && demo_session->started()) {
ArcSession::UpgradeParams params;
const chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
params.is_demo_session = demo_session && demo_session->started();
if (params.is_demo_session) {
DCHECK(demo_session->offline_resources_loaded());
demo_session_apps_path = demo_session->GetDemoAppsPath();
base::FilePath demo_session_apps_path;
params.demo_session_apps_path = demo_session->GetDemoAppsPath();
}
ArcSession::UpgradeParams params;
params.is_child = profile_->IsChild();
params.locale = locale;
// Empty |preferred_lanaguages| is converted to empty array.
params.preferred_languages = base::SplitString(
preferred_lanaguages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
params.demo_session_apps_path = demo_session_apps_path;
arc_session_runner_->RequestUpgrade(std::move(params));
}
......
......@@ -62,10 +62,14 @@ class ArcSession {
std::string locale;
std::vector<std::string> preferred_languages;
// Whether ARC is being upgraded in a demo session.
bool is_demo_session = false;
// |demo_session_apps_path| is a file path to the image containing set of
// demo apps that should be added to the Android container for demo
// sessions. It might be empty, in which case no demo apps will be added to
// the container.
// demo apps that should be pre-installed into the Android container for
// demo sessions. It might be empty, in which case no demo apps will be
// pre-installed.
// Should be empty if |is_demo_session| is not set.
base::FilePath demo_session_apps_path;
private:
......
......@@ -371,9 +371,12 @@ void ArcSessionImpl::DoUpgrade() {
for (const std::string& language : upgrade_params_.preferred_languages)
request.add_preferred_languages(language);
if (!upgrade_params_.demo_session_apps_path.empty())
request.set_is_demo_session(upgrade_params_.is_demo_session);
if (!upgrade_params_.demo_session_apps_path.empty()) {
DCHECK(upgrade_params_.is_demo_session);
request.set_demo_session_apps_path(
upgrade_params_.demo_session_apps_path.value());
}
chromeos::SessionManagerClient* client = GetSessionManagerClient();
client->UpgradeArcContainer(
......
......@@ -623,5 +623,42 @@ TEST_F(ArcSessionImplTest, IsChild) {
EXPECT_TRUE(GetSessionManagerClient()->last_upgrade_arc_request().is_child());
}
TEST_F(ArcSessionImplTest, DemoSession) {
auto arc_session = CreateArcSession();
arc_session->StartMiniInstance();
const std::string demo_apps_path =
"/run/imageloader/demo_mode_resources/android_apps.squash";
ArcSession::UpgradeParams params;
params.is_demo_session = true;
params.demo_session_apps_path = base::FilePath(demo_apps_path);
params.locale = kDefaultLocale;
arc_session->RequestUpgrade(std::move(params));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(
GetSessionManagerClient()->last_upgrade_arc_request().is_demo_session());
EXPECT_EQ(demo_apps_path, GetSessionManagerClient()
->last_upgrade_arc_request()
.demo_session_apps_path());
}
TEST_F(ArcSessionImplTest, DemoSessionWithoutOfflineDemoApps) {
auto arc_session = CreateArcSession();
arc_session->StartMiniInstance();
ArcSession::UpgradeParams params;
params.is_demo_session = true;
params.locale = kDefaultLocale;
arc_session->RequestUpgrade(std::move(params));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(
GetSessionManagerClient()->last_upgrade_arc_request().is_demo_session());
EXPECT_EQ(std::string(), GetSessionManagerClient()
->last_upgrade_arc_request()
.demo_session_apps_path());
}
} // namespace
} // namespace arc
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