0

Updater: Set installsources for different modes of operation.

These install sources will be carried through to the event pings as
well.

Bug: b/339047023, b/338448485
Change-Id: I4358efb341c1651c7d8d7d3b976fa6df005df250
Low-Coverage-Reason: COVERAGE_UNDERREPORTED - coverage bots don't run updater_tests_system
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5538474
Reviewed-by: Sorin Jianu <sorin@chromium.org>
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1304610}
This commit is contained in:
Joshua Pawlicki
2024-05-22 19:37:11 +00:00
committed by Chromium LUCI CQ
parent c61c01518d
commit f14af82da2
11 changed files with 54 additions and 19 deletions

@ -795,6 +795,7 @@ if (is_win || is_mac || is_linux) {
":base",
":branding_header",
":constants_test",
":public_sources",
":tagging",
":unit_test_util_sources",
":version_header",

@ -134,4 +134,9 @@ const char kSetupMutex[] = SETUP_MUTEX;
const char kUserDefaultsSuiteName[] = MAC_BUNDLE_IDENTIFIER_STRING ".defaults";
#endif // BUILDFLAG(IS_MAC)
const char kInstallSourceTaggedMetainstaller[] = "taggedmi";
const char kInstallSourceOffline[] = "offline";
const char kInstallSourcePolicy[] = "policy";
const char kInstallSourceOnDemand[] = "ondemand";
} // namespace updater

@ -527,6 +527,12 @@ inline constexpr int GOOPDATEINSTALL_E_INSTALLER_FAILED = 0x80040902;
inline constexpr int GOOPDATEINSTALL_E_INSTALLER_TIMED_OUT = 0x80040904;
inline constexpr int GOOPDATEINSTALL_E_INSTALL_ALREADY_RUNNING = 0x80040907;
// Install Sources.
extern const char kInstallSourceTaggedMetainstaller[];
extern const char kInstallSourceOffline[];
extern const char kInstallSourcePolicy[];
extern const char kInstallSourceOnDemand[];
} // namespace updater
#endif // CHROME_UPDATER_CONSTANTS_H_

@ -75,6 +75,7 @@ Installer::Installer(
const std::string& app_id,
const std::string& client_install_data,
const std::string& install_data_index,
const std::string& install_source,
const std::string& target_channel,
const std::string& target_version_prefix,
bool rollback_allowed,
@ -86,6 +87,7 @@ Installer::Installer(
app_id_(app_id),
client_install_data_(client_install_data),
install_data_index_(install_data_index),
install_source_(install_source),
rollback_allowed_(rollback_allowed),
target_channel_(target_channel),
target_version_prefix_(target_version_prefix),
@ -150,6 +152,7 @@ void Installer::MakeCrxComponentFromAppInfo(
UpdateService::PolicySameVersionUpdate::kAllowed;
component.target_version_prefix = target_version_prefix_;
component.updates_enabled = !update_disabled_;
component.install_source = install_source_;
std::move(callback).Run(component);
}

@ -92,6 +92,7 @@ class Installer final : public update_client::CrxInstaller {
Installer(const std::string& app_id,
const std::string& client_install_data,
const std::string& install_data_index,
const std::string& install_source,
const std::string& target_channel,
const std::string& target_version_prefix,
bool rollback_allowed,
@ -151,6 +152,7 @@ class Installer final : public update_client::CrxInstaller {
const std::string app_id_;
const std::string client_install_data_;
const std::string install_data_index_;
const std::string install_source_;
const bool rollback_allowed_;
const std::string target_channel_;
const std::string target_version_prefix_;

@ -41,8 +41,8 @@ TEST(InstallerTest, Simple) {
base::RunLoop loop;
base::MakeRefCounted<Installer>(
"id", "client_install_data", "install_data_index", "target_channel",
"target_version_prefix", /*rollback_allowed=*/true,
"id", "client_install_data", "install_data_index", "install_source",
"target_channel", "target_version_prefix", /*rollback_allowed=*/true,
/*update_disabled=*/false,
UpdateService::PolicySameVersionUpdate::kNotAllowed, metadata,
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF)
@ -98,8 +98,8 @@ TEST(InstallerTest, LoadFromPath) {
update_client::CrxComponent crx;
base::RunLoop loop;
base::MakeRefCounted<Installer>(
"id", "client_install_data", "install_data_index", "target_channel",
"target_version_prefix", /*rollback_allowed=*/true,
"id", "client_install_data", "install_data_index", "install_source",
"target_channel", "target_version_prefix", /*rollback_allowed=*/true,
/*update_disabled=*/false,
UpdateService::PolicySameVersionUpdate::kNotAllowed, metadata,
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF)
@ -114,6 +114,7 @@ TEST(InstallerTest, LoadFromPath) {
EXPECT_EQ(crx.version, base::Version("5.5.5.5"));
EXPECT_EQ(crx.ap, "ap2");
EXPECT_EQ(crx.brand, "BTWO");
EXPECT_EQ(crx.install_source, "install_source");
}
#endif // BUILDFLAG(IS_MAC)
@ -140,8 +141,8 @@ TEST(InstallerTest, LoadFromPath_PathDoesNotExist) {
base::RunLoop loop;
base::MakeRefCounted<Installer>(
"id", "client_install_data", "install_data_index", "target_channel",
"target_version_prefix", /*rollback_allowed=*/true,
"id", "client_install_data", "install_data_index", "install_source",
"target_channel", "target_version_prefix", /*rollback_allowed=*/true,
/*update_disabled=*/false,
UpdateService::PolicySameVersionUpdate::kNotAllowed, metadata,
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF)
@ -185,8 +186,8 @@ TEST(InstallerTest, LoadFromPath_KeysMissing) {
update_client::CrxComponent crx;
base::RunLoop loop;
base::MakeRefCounted<Installer>(
"id", "client_install_data", "install_data_index", "target_channel",
"target_version_prefix", /*rollback_allowed=*/true,
"id", "client_install_data", "install_data_index", "install_source",
"target_channel", "target_version_prefix", /*rollback_allowed=*/true,
/*update_disabled=*/false,
UpdateService::PolicySameVersionUpdate::kNotAllowed, metadata,
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF)

@ -168,7 +168,9 @@ Matcher GetAppPriorityMatcher(const std::string& app_id,
if (const auto* appid = dict->FindString("appid"); *appid == app_id) {
if (const auto* install_source =
dict->FindString("installsource")) {
return (*install_source == "ondemand") ==
return (*install_source == "ondemand" ||
*install_source == "taggedmi" ||
*install_source == "policy") ==
(priority == UpdateService::Priority::kForeground);
}
}

@ -108,6 +108,7 @@ void GetComponents(
scoped_refptr<PersistedData> persisted_data,
const AppClientInstallData& app_client_install_data,
const AppInstallDataIndex& app_install_data_index,
const std::string& install_source,
UpdateService::Priority priority,
bool update_blocked,
UpdateService::PolicySameVersionUpdate policy_same_version_update,
@ -150,6 +151,7 @@ void GetComponents(
auto it = app_install_data_index.find(id);
return it != app_install_data_index.end() ? it->second : "";
}(),
install_source,
policy_service->GetTargetChannel(id).policy_or(std::string()),
policy_service->GetTargetVersionPrefix(id).policy_or(std::string()),
policy_service->IsRollbackToTargetVersionAllowed(id).policy_or(false),
@ -927,7 +929,7 @@ void UpdateServiceImplImpl::Install(const RegistrationRequest& registration,
{std::make_pair(registration.app_id, client_install_data)}),
AppInstallDataIndex(
{std::make_pair(registration.app_id, install_data_index)}),
priority,
kInstallSourceTaggedMetainstaller, priority,
/*update_blocked=*/false, PolicySameVersionUpdate::kAllowed),
MakeUpdateClientCrxStateChangeCallback(config_,
config_->GetUpdaterPersistedData(),
@ -1101,6 +1103,7 @@ void UpdateServiceImplImpl::RunInstaller(const std::string& app_id,
install_data.app_id = app_id;
install_data.brand = brand;
install_data.requires_network_encryption = false;
install_data.install_source = kInstallSourceOffline;
install_data.version = installer_version;
update_client->SendPing(
install_data,
@ -1197,6 +1200,9 @@ void UpdateServiceImplImpl::OnShouldBlockCheckForUpdateForMeteredNetwork(
config_->GetCrxVerifierFormat(),
config_->GetUpdaterPersistedData(),
AppClientInstallData(), AppInstallDataIndex(),
priority == UpdateService::Priority::kForeground
? kInstallSourceOnDemand
: "",
priority, update_blocked, policy_same_version_update),
MakeUpdateClientCrxStateChangeCallback(
config_, config_->GetUpdaterPersistedData(),
@ -1223,6 +1229,9 @@ void UpdateServiceImplImpl::OnShouldBlockUpdateForMeteredNetwork(
config_->GetCrxVerifierFormat(),
config_->GetUpdaterPersistedData(),
app_client_install_data, app_install_data_index,
priority == UpdateService::Priority::kForeground
? kInstallSourceOnDemand
: "",
priority, update_blocked, policy_same_version_update),
MakeUpdateClientCrxStateChangeCallback(
config_, config_->GetUpdaterPersistedData(),
@ -1257,12 +1266,13 @@ void UpdateServiceImplImpl::OnShouldBlockForceInstallForMeteredNetwork(
base::BindOnce(
base::IgnoreResult(&update_client::UpdateClient::Install),
update_client_, id,
base::BindOnce(
&internal::GetComponents, config_->GetPolicyService(),
config_->GetCrxVerifierFormat(),
config_->GetUpdaterPersistedData(), app_client_install_data,
app_install_data_index, Priority::kBackground, update_blocked,
policy_same_version_update),
base::BindOnce(&internal::GetComponents,
config_->GetPolicyService(),
config_->GetCrxVerifierFormat(),
config_->GetUpdaterPersistedData(),
app_client_install_data, app_install_data_index,
kInstallSourcePolicy, Priority::kBackground,
update_blocked, policy_same_version_update),
MakeUpdateClientCrxStateChangeCallback(
config_, config_->GetUpdaterPersistedData(),
/*new_install=*/false, state_update),

@ -149,6 +149,7 @@ void GetComponents(
scoped_refptr<PersistedData> persisted_data,
const AppClientInstallData& app_client_install_data,
const AppInstallDataIndex& app_install_data_index,
const std::string& install_source,
UpdateService::Priority priority,
bool update_blocked,
UpdateService::PolicySameVersionUpdate policy_same_version_update,

@ -85,7 +85,7 @@ TEST(UpdateServiceImplTest, TestGetComponentsInOrder) {
base::RunLoop loop;
internal::GetComponents(
base::MakeRefCounted<PolicyService>(CreateExternalConstants()),
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF, metadata, {}, {},
crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF, metadata, {}, {}, {},
UpdateService::Priority::kForeground, false,
UpdateService::PolicySameVersionUpdate::kNotAllowed,
{"id1", "id2", "id3", "id4"},

@ -386,8 +386,12 @@ following members:
The string should be drawn from a small set of constant values, to minimize
entropy and the ability for the client to be fingerprinted. Default: "".
* `installsource`: A string describing the immediate cause of this request.
Known values include: "" (a normal background update) and "ondemand" (a
foreground, user-initiated update). Default: "".
Default: "". Known values include:
* "" (a normal background update),
* "ondemand" (a foreground, user-initiated update),
* "taggedmi" (a tagged metainstaller was run),
* "offline" (an offline installer was run),
* "policy" (an install was triggered by group policy),
The string should be drawn from a small set of constant values, to minimize
entropy and the ability for the client to be fingerprinted.
* `ismachine`: "0" if the application is installed for the user specifically