Commit 9c0e4f94 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Populate ARC Kiosk app id into device status reports.

Chrome OS should report to the server ID of the launched kiosk app for
ARC Kiosk sessions, so it will be able to find out which app is active.
In order to do it, it will populate AppStatus.app_id with package name
of the Android app for both:
- SessionStatusReportRequest.installed_apps
- DeviceStatusReportRequest.running_kiosk_apps

Note: previously it was populated with empty AppStatus.

BUG=b/62446184
TEST=Add browser tests, run trybots.

Change-Id: Ied7759cee40c75082814b0ddac40aaff81f1a538
Reviewed-on: https://chromium-review.googlesource.com/840743Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525981}
parent 57c198cc
......@@ -179,6 +179,25 @@ void ArcKioskAppManager::RemoveObserver(ArcKioskAppManagerObserver* observer) {
observers_.RemoveObserver(observer);
}
void ArcKioskAppManager::AddAutoLaunchAppForTest(
const std::string& app_id,
const policy::ArcKioskAppBasicInfo& app_info,
const AccountId& account_id) {
for (auto it = apps_.begin(); it != apps_.end(); ++it) {
if ((*it)->app_id() == app_id) {
apps_.erase(it);
break;
}
}
apps_.emplace_back(std::make_unique<ArcKioskAppData>(
app_id, app_info.package_name(), app_info.class_name(), app_info.action(),
account_id, app_info.display_name()));
auto_launch_account_id_ = account_id;
auto_launched_with_zero_delay_ = true;
}
void ArcKioskAppManager::UpdateApps() {
// Do not populate ARC kiosk apps if ARC kiosk apps can't be run on the
// device.
......
......@@ -69,6 +69,12 @@ class ArcKioskAppManager {
return auto_launched_with_zero_delay_;
}
// Adds an app with the given meta data directly, skips meta data fetching
// and sets the app as the auto launched one. Only for test.
void AddAutoLaunchAppForTest(const std::string& app_id,
const policy::ArcKioskAppBasicInfo& app_info,
const AccountId& account_id);
private:
// Updates apps_ based on CrosSettings.
void UpdateApps();
......
......@@ -1096,21 +1096,28 @@ bool DeviceStatusCollector::GetRunningKioskApp(
return false;
em::AppStatus* running_kiosk_app = status->mutable_running_kiosk_app();
running_kiosk_app->set_app_id(account->kiosk_app_id);
if (account->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP) {
running_kiosk_app->set_app_id(account->kiosk_app_id);
const std::string app_version = GetAppVersion(account->kiosk_app_id);
if (app_version.empty()) {
DLOG(ERROR) << "Unable to get version for extension: "
<< account->kiosk_app_id;
} else {
running_kiosk_app->set_extension_version(app_version);
}
const std::string app_version = GetAppVersion(account->kiosk_app_id);
if (app_version.empty()) {
DLOG(ERROR) << "Unable to get version for extension: "
<< account->kiosk_app_id;
} else {
running_kiosk_app->set_extension_version(app_version);
}
chromeos::KioskAppManager::App app_info;
if (chromeos::KioskAppManager::Get()->GetApp(account->kiosk_app_id,
&app_info)) {
running_kiosk_app->set_required_platform_version(
app_info.required_platform_version);
chromeos::KioskAppManager::App app_info;
if (chromeos::KioskAppManager::Get()->GetApp(account->kiosk_app_id,
&app_info)) {
running_kiosk_app->set_required_platform_version(
app_info.required_platform_version);
}
} else if (account->type == policy::DeviceLocalAccount::TYPE_ARC_KIOSK_APP) {
// Use package name as app ID for ARC Kiosks.
running_kiosk_app->set_app_id(account->arc_kiosk_app_info.package_name());
} else {
NOTREACHED();
}
return true;
}
......@@ -1240,15 +1247,22 @@ bool DeviceStatusCollector::GetKioskSessionStatus(
// Get the account ID associated with this user.
status->set_device_local_account_id(account->account_id);
em::AppStatus* app_status = status->add_installed_apps();
app_status->set_app_id(account->kiosk_app_id);
// Look up the app and get the version.
const std::string app_version = GetAppVersion(account->kiosk_app_id);
if (app_version.empty()) {
DLOG(ERROR) << "Unable to get version for extension: "
<< account->kiosk_app_id;
if (account->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP) {
app_status->set_app_id(account->kiosk_app_id);
// Look up the app and get the version.
const std::string app_version = GetAppVersion(account->kiosk_app_id);
if (app_version.empty()) {
DLOG(ERROR) << "Unable to get version for extension: "
<< account->kiosk_app_id;
} else {
app_status->set_extension_version(app_version);
}
} else if (account->type == policy::DeviceLocalAccount::TYPE_ARC_KIOSK_APP) {
// Use package name as app ID for ARC Kiosks.
app_status->set_app_id(account->arc_kiosk_app_info.package_name());
} else {
app_status->set_extension_version(app_version);
NOTREACHED();
}
return true;
......
......@@ -756,8 +756,8 @@ message DeviceStatusReportRequest {
// OS version.
optional OsUpdateStatus os_update_status = 17;
// Set only when there is an auto launched with zero delay kiosk app
// and it is currently running. Otherwise, this field is empty.
// Set only when there is an auto launched with zero delay Chrome or ARC kiosk
// app and it is currently running. Otherwise, this field is empty.
optional AppStatus running_kiosk_app = 18;
// Sound output volume level in range [0,100].
......@@ -790,10 +790,12 @@ message OsUpdateStatus {
// Provides status information for an installed app/extension.
message AppStatus {
// ID of the installed app/extension
// ID of the installed app/extension for a Chrome app.
// Package name for ARC kiosk app.
optional string app_id = 1;
// Currently installed version of the app.
// Currently installed version of the app for a Chrome app.
// Empty for ARC kiosk app.
optional string extension_version = 2;
// Self-reported status summary (via chrome.reporting APIs)
......@@ -803,6 +805,7 @@ message AppStatus {
optional bool error = 4;
// App required Chrome version, specified in app’s manifest file.
// Empty for ARC kiosk app.
optional string required_platform_version = 5;
}
......@@ -820,7 +823,8 @@ message SessionStatusReportRequest {
// If this is a kiosk session, this is the device local account ID.
optional string device_local_account_id = 4;
// Information about installed apps for this user on this device.
// Information about installed apps for this user on this device,
// including information about ARC kiosk app for ARC kiosk session.
repeated AppStatus installed_apps = 5;
// Information about ARC status.
......
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