Provide a separate embargo end date for enterprise management pings
Introduce a new VPD key, enterprise_management_embargo_end_date, to control the date until which one shall not try and ping Google enteprise management servers. If this VPD key exists, use it. If not, use the RLZ embargo end date instead as before. This VPD key gives OEMs control about when a device can start to ping Google servers that is fully independent of the marketing embargo for RLZ promotions. Bug: chromium:1093139 Test: unit_tests Change-Id: Iab264912b9c65af23b90563ec8109b673eafc26d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2239286 Reviewed-by: Roman Sorokin [CET] <rsorokin@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Commit-Queue: Yves Arrouye <drcrash@chromium.org> Cr-Commit-Position: refs/heads/master@{#779706}
This commit is contained in:
chrome/browser/chromeos/login
chromeos/system
factory_ping_embargo_check.ccfactory_ping_embargo_check.hfactory_ping_embargo_check_unittest.ccstatistics_provider.ccstatistics_provider.h
rlz
@ -498,7 +498,7 @@ AutoEnrollmentController::GetInitialEnrollmentRequirement() {
|
||||
system::StatisticsProvider* provider =
|
||||
system::StatisticsProvider::GetInstance();
|
||||
system::FactoryPingEmbargoState embargo_state =
|
||||
system::GetFactoryPingEmbargoState(provider);
|
||||
system::GetEnterpriseManagementPingEmbargoState(provider);
|
||||
if (provider->GetEnterpriseMachineID().empty()) {
|
||||
LOG(WARNING)
|
||||
<< "Skip Initial Enrollment Check due to missing serial number.";
|
||||
|
@ -288,31 +288,31 @@ void QuitLoopOnAutoEnrollmentProgress(
|
||||
loop->Quit();
|
||||
}
|
||||
|
||||
// Returns a string which can be put into the |kRlzEmbargoEndDateKey| VPD
|
||||
// variable. If |days_offset| is 0, the return value represents the current day.
|
||||
// If |days_offset| is positive, the return value represents |days_offset| days
|
||||
// in the future. If |days_offset| is negative, the return value represents
|
||||
// |days_offset| days in the past.
|
||||
// Returns a string which can be put into the VPD variable
|
||||
// |kEnterpriseManagementEmbargoEndDateKey|. If |days_offset| is 0, the return
|
||||
// value represents the current day. If |days_offset| is positive, the return
|
||||
// value represents |days_offset| days in the future. If |days_offset| is
|
||||
// negative, the return value represents |days_offset| days in the past.
|
||||
std::string GenerateEmbargoEndDate(int days_offset) {
|
||||
base::Time::Exploded exploded;
|
||||
base::Time target_time =
|
||||
base::Time::Now() + base::TimeDelta::FromDays(days_offset);
|
||||
target_time.UTCExplode(&exploded);
|
||||
|
||||
std::string rlz_embargo_end_date_string = base::StringPrintf(
|
||||
std::string embargo_end_date_string = base::StringPrintf(
|
||||
"%04d-%02d-%02d", exploded.year, exploded.month, exploded.day_of_month);
|
||||
|
||||
// Sanity check that base::Time::FromUTCString can read back the format used
|
||||
// here.
|
||||
base::Time reparsed_time;
|
||||
EXPECT_TRUE(base::Time::FromUTCString(rlz_embargo_end_date_string.c_str(),
|
||||
EXPECT_TRUE(base::Time::FromUTCString(embargo_end_date_string.c_str(),
|
||||
&reparsed_time));
|
||||
EXPECT_EQ(target_time.ToDeltaSinceWindowsEpoch().InMicroseconds() /
|
||||
base::Time::kMicrosecondsPerDay,
|
||||
reparsed_time.ToDeltaSinceWindowsEpoch().InMicroseconds() /
|
||||
base::Time::kMicrosecondsPerDay);
|
||||
|
||||
return rlz_embargo_end_date_string;
|
||||
return embargo_end_date_string;
|
||||
}
|
||||
|
||||
template <typename View>
|
||||
@ -1463,7 +1463,6 @@ IN_PROC_BROWSER_TEST_P(WizardControllerDeviceStateExplicitRequirementTest,
|
||||
EXPECT_EQ(0, FakeSessionManagerClient::Get()
|
||||
->clear_forced_re_enrollment_vpd_call_count());
|
||||
} else {
|
||||
|
||||
// Make AutoEnrollmentClient notify the controller that a server error
|
||||
// occurred.
|
||||
fake_auto_enrollment_client->SetState(
|
||||
@ -1518,7 +1517,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
ControlFlowInitialEnrollment) {
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-15 /* days_offset */));
|
||||
CheckCurrentScreen(WelcomeView::kScreenId);
|
||||
EXPECT_CALL(*mock_welcome_screen_, HideImpl()).Times(1);
|
||||
@ -1592,7 +1591,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-15 /* days_offset */));
|
||||
CheckCurrentScreen(WelcomeView::kScreenId);
|
||||
EXPECT_CALL(*mock_welcome_screen_, HideImpl()).Times(1);
|
||||
@ -1683,7 +1682,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_NE(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT,
|
||||
auto_enrollment_controller()->state());
|
||||
@ -1727,7 +1726,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
ControlFlowWaitSystemClockSyncThenEmbargoPeriod) {
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_NE(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT,
|
||||
auto_enrollment_controller()->state());
|
||||
@ -1783,7 +1782,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
base::TestMockTimeTaskRunner::ScopedContext scoped_context(task_runner);
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_NE(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT,
|
||||
auto_enrollment_controller()->state());
|
||||
@ -1839,7 +1838,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
|
||||
fake_statistics_provider_.ClearMachineStatistic(system::kActivateDateKey);
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_NE(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT,
|
||||
auto_enrollment_controller()->state());
|
||||
@ -1877,7 +1876,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
// Simulate that the clock moved forward, passing the embargo period, by
|
||||
// moving the embargo period back in time.
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-1 /* days_offset */));
|
||||
base::DictionaryValue device_state;
|
||||
device_state.SetString(policy::kDeviceStateMode,
|
||||
@ -1921,7 +1920,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
|
||||
fake_statistics_provider_.SetMachineStatistic(system::kCheckEnrollmentKey,
|
||||
"0");
|
||||
fake_statistics_provider_.SetMachineStatistic(
|
||||
system::kRlzEmbargoEndDateKey,
|
||||
system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_NE(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT,
|
||||
auto_enrollment_controller()->state());
|
||||
|
@ -27,42 +27,64 @@ enum class EndDateValidityHistogramValue {
|
||||
|
||||
// This is in a helper function to help the compiler avoid generating duplicated
|
||||
// code.
|
||||
void RecordEndDateValidity(EndDateValidityHistogramValue value) {
|
||||
UMA_HISTOGRAM_ENUMERATION("FactoryPingEmbargo.EndDateValidity", value);
|
||||
void RecordEndDateValidity(const char* uma_prefix,
|
||||
EndDateValidityHistogramValue value) {
|
||||
if (uma_prefix)
|
||||
UMA_HISTOGRAM_ENUMERATION(std::string(uma_prefix) + ".EndDateValidity",
|
||||
value);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
FactoryPingEmbargoState GetFactoryPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider) {
|
||||
std::string rlz_embargo_end_date;
|
||||
if (!statistics_provider->GetMachineStatistic(kRlzEmbargoEndDateKey,
|
||||
&rlz_embargo_end_date)) {
|
||||
// |rlz_embargo_end_date| only exists on new devices that have not yet
|
||||
// launched.
|
||||
FactoryPingEmbargoState GetPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider,
|
||||
const std::string& key_name,
|
||||
const char* uma_prefix) {
|
||||
std::string ping_embargo_end_date;
|
||||
if (!statistics_provider->GetMachineStatistic(key_name,
|
||||
&ping_embargo_end_date)) {
|
||||
return FactoryPingEmbargoState::kMissingOrMalformed;
|
||||
}
|
||||
base::Time parsed_time;
|
||||
if (!base::Time::FromUTCString(rlz_embargo_end_date.c_str(), &parsed_time)) {
|
||||
LOG(ERROR) << "|rlz_embargo_end_date| exists but cannot be parsed.";
|
||||
RecordEndDateValidity(EndDateValidityHistogramValue::kMalformed);
|
||||
if (!base::Time::FromUTCString(ping_embargo_end_date.c_str(), &parsed_time)) {
|
||||
LOG(ERROR) << key_name << " exists but cannot be parsed.";
|
||||
RecordEndDateValidity(uma_prefix,
|
||||
EndDateValidityHistogramValue::kMalformed);
|
||||
return FactoryPingEmbargoState::kMissingOrMalformed;
|
||||
}
|
||||
|
||||
if (parsed_time - base::Time::Now() >=
|
||||
kRlzEmbargoEndDateGarbageDateThreshold) {
|
||||
// If |rlz_embargo_end_date| is more than this many days in the future,
|
||||
// ignore it. Because it indicates that the device is not connected to an
|
||||
// ntp server in the factory, and its internal clock could be off when the
|
||||
// date is written.
|
||||
RecordEndDateValidity(EndDateValidityHistogramValue::kInvalid);
|
||||
if (parsed_time - base::Time::Now() >= kEmbargoEndDateGarbageDateThreshold) {
|
||||
// If the date is more than this many days in the future, ignore it.
|
||||
// Because it indicates that the device is not connected to an NTP server
|
||||
// in the factory, and its internal clock could be off when the date is
|
||||
// written.
|
||||
RecordEndDateValidity(uma_prefix, EndDateValidityHistogramValue::kInvalid);
|
||||
return FactoryPingEmbargoState::kInvalid;
|
||||
}
|
||||
|
||||
RecordEndDateValidity(EndDateValidityHistogramValue::kValid);
|
||||
RecordEndDateValidity(uma_prefix, EndDateValidityHistogramValue::kValid);
|
||||
return base::Time::Now() > parsed_time ? FactoryPingEmbargoState::kPassed
|
||||
: FactoryPingEmbargoState::kNotPassed;
|
||||
}
|
||||
|
||||
FactoryPingEmbargoState GetEnterpriseManagementPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider) {
|
||||
std::string ping_embargo_end_date;
|
||||
if (statistics_provider->GetMachineStatistic(
|
||||
kEnterpriseManagementEmbargoEndDateKey, &ping_embargo_end_date))
|
||||
return GetPingEmbargoState(statistics_provider,
|
||||
kEnterpriseManagementEmbargoEndDateKey,
|
||||
"FactoryPingEmbargo");
|
||||
// Default to the RLZ ping embargo if no value for an enterprise management
|
||||
// embargo.
|
||||
return GetRlzPingEmbargoState(statistics_provider);
|
||||
}
|
||||
|
||||
FactoryPingEmbargoState GetRlzPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider) {
|
||||
return GetPingEmbargoState(statistics_provider, kRlzEmbargoEndDateKey,
|
||||
/*uma_prefix=*/nullptr);
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
} // namespace chromeos
|
||||
|
@ -13,9 +13,9 @@ namespace system {
|
||||
|
||||
class StatisticsProvider;
|
||||
|
||||
// The RLZ embargo end date is considered invalid if it's more than this many
|
||||
// An embargo end date is considered invalid if it's more than this many
|
||||
// days in the future.
|
||||
constexpr base::TimeDelta kRlzEmbargoEndDateGarbageDateThreshold =
|
||||
constexpr base::TimeDelta kEmbargoEndDateGarbageDateThreshold =
|
||||
base::TimeDelta::FromDays(14);
|
||||
|
||||
enum class FactoryPingEmbargoState {
|
||||
@ -34,7 +34,11 @@ enum class FactoryPingEmbargoState {
|
||||
};
|
||||
|
||||
COMPONENT_EXPORT(CHROMEOS_SYSTEM)
|
||||
FactoryPingEmbargoState GetFactoryPingEmbargoState(
|
||||
FactoryPingEmbargoState GetEnterpriseManagementPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider);
|
||||
|
||||
COMPONENT_EXPORT(CHROMEOS_SYSTEM)
|
||||
FactoryPingEmbargoState GetRlzPingEmbargoState(
|
||||
StatisticsProvider* statistics_provider);
|
||||
|
||||
} // namespace system
|
||||
|
@ -14,10 +14,10 @@ namespace system {
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns a string which can be put into the |kRlzEmbargoEndDateKey| VPD
|
||||
// variable. If |days_offset| is 0, the return value represents the current day.
|
||||
// If |days_offset| is positive, the return value represents |days_offset| days
|
||||
// in the future. If |days_offset| is negative, the return value represents
|
||||
// Returns a string which can be put into the one of the embargo end date VPD
|
||||
// variables. If |days_offset| is 0, the return value represents the current
|
||||
// day. If |days_offset| is positive, the return value represents |days_offset|
|
||||
// days in the future. If |days_offset| is negative, the return value represents
|
||||
// |days_offset| days in the past.
|
||||
// For example, if the test runs on 2018-01-22 and |days_offset| is 3, the
|
||||
// return value will be "2018-01-25". Similarly, if |days_offset| is -1, the
|
||||
@ -28,20 +28,20 @@ std::string GenerateEmbargoEndDate(int days_offset) {
|
||||
base::Time::Now() + base::TimeDelta::FromDays(days_offset);
|
||||
target_time.UTCExplode(&exploded);
|
||||
|
||||
const std::string rlz_embargo_end_date_string = base::StringPrintf(
|
||||
const std::string embargo_end_date_string = base::StringPrintf(
|
||||
"%04d-%02d-%02d", exploded.year, exploded.month, exploded.day_of_month);
|
||||
|
||||
// Sanity check that base::Time::FromUTCString can read back the format used
|
||||
// here.
|
||||
base::Time reparsed_time;
|
||||
EXPECT_TRUE(base::Time::FromUTCString(rlz_embargo_end_date_string.c_str(),
|
||||
EXPECT_TRUE(base::Time::FromUTCString(embargo_end_date_string.c_str(),
|
||||
&reparsed_time));
|
||||
EXPECT_EQ(target_time.ToDeltaSinceWindowsEpoch().InMicroseconds() /
|
||||
base::Time::kMicrosecondsPerDay,
|
||||
reparsed_time.ToDeltaSinceWindowsEpoch().InMicroseconds() /
|
||||
base::Time::kMicrosecondsPerDay);
|
||||
|
||||
return rlz_embargo_end_date_string;
|
||||
return embargo_end_date_string;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -51,46 +51,100 @@ class FactoryPingEmbargoCheckTest : public ::testing::Test {
|
||||
FakeStatisticsProvider statistics_provider_;
|
||||
};
|
||||
|
||||
// No embargo end date in VPD.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, NoValue) {
|
||||
// No initial state embargo end date in VPD.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EnterpriseManagementNoValue) {
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kMissingOrMalformed,
|
||||
GetFactoryPingEmbargoState(&statistics_provider_));
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// There is a malformed embargo end date in VPD.
|
||||
// There is a malformed initial state embargo end date in VPD.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EnterpriseManagementMalformedValue) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kEnterpriseManagementEmbargoEndDateKey, "blabla");
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kMissingOrMalformed,
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// There is an initial state embargo end date in VPD which is too far in the
|
||||
// future to be plausible.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EnterpriseManagementInvalidValue) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(15 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kInvalid,
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// The current time is before a (valid and plausible) initial state embargo end
|
||||
// date.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EnterpriseManagementEmbargoNotPassed) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kNotPassed,
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// The current time is after a (valid and plausible) initial state embargo end
|
||||
// date.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EnterpriseManagementEmbargoPassed) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kEnterpriseManagementEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-1 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kPassed,
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// Fallback to the RLZ embargo.
|
||||
TEST_F(FactoryPingEmbargoCheckTest,
|
||||
EnterpriseManagementFallbackToRlzEmbargoPassed) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kRlzEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-1 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kPassed,
|
||||
GetEnterpriseManagementPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// No RLZ embargo end date in VPD.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, NoValue) {
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kMissingOrMalformed,
|
||||
GetRlzPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// There is a malformed RLZ embargo end date in VPD.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, MalformedValue) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kRlzEmbargoEndDateKey, "blabla");
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kMissingOrMalformed,
|
||||
GetFactoryPingEmbargoState(&statistics_provider_));
|
||||
GetRlzPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// There is an embargo end date in VPD which is too far in the future to be
|
||||
// plausible.
|
||||
// There is an RLZ embargo end date in VPD which is too far in the
|
||||
// future to be plausible.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, InvalidValue) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kRlzEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(15 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kInvalid,
|
||||
GetFactoryPingEmbargoState(&statistics_provider_));
|
||||
GetRlzPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// The current time is before a (valid and plausible) embargo end date.
|
||||
// The current time is before a (valid and plausible) RLZ embargo end date.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EmbargoNotPassed) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kRlzEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(1 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kNotPassed,
|
||||
GetFactoryPingEmbargoState(&statistics_provider_));
|
||||
GetRlzPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
// The current time is after a (valid and plausible) embargo end date.
|
||||
// The current time is after a (valid and plausible) RLZ embargo end date.
|
||||
TEST_F(FactoryPingEmbargoCheckTest, EmbargoPassed) {
|
||||
statistics_provider_.SetMachineStatistic(
|
||||
chromeos::system::kRlzEmbargoEndDateKey,
|
||||
GenerateEmbargoEndDate(-1 /* days_offset */));
|
||||
EXPECT_EQ(FactoryPingEmbargoState::kPassed,
|
||||
GetFactoryPingEmbargoState(&statistics_provider_));
|
||||
GetRlzPingEmbargoState(&statistics_provider_));
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
@ -46,7 +46,7 @@ namespace {
|
||||
|
||||
// Path to the tool used to get system info, and delimiters for the output
|
||||
// format of the tool.
|
||||
const char* kCrosSystemTool[] = { "/usr/bin/crossystem" };
|
||||
const char* kCrosSystemTool[] = {"/usr/bin/crossystem"};
|
||||
const char kCrosSystemEq[] = "=";
|
||||
const char kCrosSystemDelim[] = "\n";
|
||||
const char kCrosSystemCommentDelim[] = "#";
|
||||
@ -184,6 +184,8 @@ const char kShouldSendRlzPingKey[] = "should_send_rlz_ping";
|
||||
const char kShouldSendRlzPingValueFalse[] = "0";
|
||||
const char kShouldSendRlzPingValueTrue[] = "1";
|
||||
const char kRlzEmbargoEndDateKey[] = "rlz_embargo_end_date";
|
||||
const char kEnterpriseManagementEmbargoEndDateKey[] =
|
||||
"enterprise_management_embargo_end_date";
|
||||
const char kCustomizationIdKey[] = "customization_id";
|
||||
const char kDevSwitchBootKey[] = "devsw_boot";
|
||||
const char kDevSwitchBootValueDev[] = "1";
|
||||
@ -341,8 +343,8 @@ bool StatisticsProviderImpl::WaitForStatisticsLoaded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Statistics not loaded after waiting "
|
||||
<< dtime.InMilliseconds() << "ms.";
|
||||
LOG(ERROR) << "Statistics not loaded after waiting " << dtime.InMilliseconds()
|
||||
<< "ms.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -418,8 +420,7 @@ bool StatisticsProviderImpl::GetMachineStatistic(const std::string& name,
|
||||
if (iter == machine_info_.end()) {
|
||||
if (GetRegionalInformation(name, result))
|
||||
return true;
|
||||
if (result != nullptr &&
|
||||
base::SysInfo::IsRunningOnChromeOS() &&
|
||||
if (result != nullptr && base::SysInfo::IsRunningOnChromeOS() &&
|
||||
(oem_manifest_loaded_ || !HasOemPrefix(name))) {
|
||||
VLOG(1) << "Requested statistic not found: " << name;
|
||||
}
|
||||
@ -440,8 +441,7 @@ bool StatisticsProviderImpl::GetMachineFlag(const std::string& name,
|
||||
|
||||
MachineFlags::const_iterator iter = machine_flags_.find(name);
|
||||
if (iter == machine_flags_.end()) {
|
||||
if (result != nullptr &&
|
||||
base::SysInfo::IsRunningOnChromeOS() &&
|
||||
if (result != nullptr && base::SysInfo::IsRunningOnChromeOS() &&
|
||||
(oem_manifest_loaded_ || !HasOemPrefix(name))) {
|
||||
VLOG(1) << "Requested machine flag not found: " << name;
|
||||
}
|
||||
@ -568,15 +568,11 @@ void StatisticsProviderImpl::LoadMachineStatistics(bool load_oem_manifest) {
|
||||
}
|
||||
}
|
||||
|
||||
parser.GetNameValuePairsFromFile(machine_info_path,
|
||||
kMachineHardwareInfoEq,
|
||||
parser.GetNameValuePairsFromFile(machine_info_path, kMachineHardwareInfoEq,
|
||||
kMachineHardwareInfoDelim);
|
||||
parser.GetNameValuePairsFromFile(base::FilePath(kEchoCouponFile),
|
||||
kEchoCouponEq,
|
||||
kEchoCouponDelim);
|
||||
parser.GetNameValuePairsFromFile(vpd_path,
|
||||
kVpdEq,
|
||||
kVpdDelim);
|
||||
kEchoCouponEq, kEchoCouponDelim);
|
||||
parser.GetNameValuePairsFromFile(vpd_path, kVpdEq, kVpdDelim);
|
||||
|
||||
// Ensure that the hardware class key is present with the expected
|
||||
// key name, and if it couldn't be retrieved, that the value is "unknown".
|
||||
@ -661,14 +657,11 @@ void StatisticsProviderImpl::LoadOemManifestFromFile(
|
||||
LOG(WARNING) << "Unable to load OEM Manifest file: " << file.value();
|
||||
return;
|
||||
}
|
||||
machine_info_[kOemDeviceRequisitionKey] =
|
||||
oem_manifest.device_requisition;
|
||||
machine_flags_[kOemIsEnterpriseManagedKey] =
|
||||
oem_manifest.enterprise_managed;
|
||||
machine_info_[kOemDeviceRequisitionKey] = oem_manifest.device_requisition;
|
||||
machine_flags_[kOemIsEnterpriseManagedKey] = oem_manifest.enterprise_managed;
|
||||
machine_flags_[kOemCanExitEnterpriseEnrollmentKey] =
|
||||
oem_manifest.can_exit_enrollment;
|
||||
machine_flags_[kOemKeyboardDrivenOobeKey] =
|
||||
oem_manifest.keyboard_driven_oobe;
|
||||
machine_flags_[kOemKeyboardDrivenOobeKey] = oem_manifest.keyboard_driven_oobe;
|
||||
|
||||
oem_manifest_loaded_ = true;
|
||||
VLOG(1) << "Loaded OEM Manifest statistics from " << file.value();
|
||||
|
@ -34,6 +34,11 @@ extern const char kShouldSendRlzPingValueTrue[];
|
||||
// allowed to be sent. It is in the format of "yyyy-mm-dd".
|
||||
COMPONENT_EXPORT(CHROMEOS_SYSTEM) extern const char kRlzEmbargoEndDateKey[];
|
||||
|
||||
// The key present in VPD that indicates the date after which enterprise
|
||||
// management pings are allowed to be sent. It is in the format of "yyyy-mm-dd".
|
||||
COMPONENT_EXPORT(CHROMEOS_SYSTEM)
|
||||
extern const char kEnterpriseManagementEmbargoEndDateKey[];
|
||||
|
||||
// Customization ID key.
|
||||
COMPONENT_EXPORT(CHROMEOS_SYSTEM) extern const char kCustomizationIdKey[];
|
||||
|
||||
|
@ -186,8 +186,9 @@ bool RlzValueStoreChromeOS::WritePingTime(Product product, int64_t time) {
|
||||
bool RlzValueStoreChromeOS::ReadPingTime(Product product, int64_t* time) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
// TODO(wzang): make sure time is correct (check that npupdate has updated
|
||||
// successfully).
|
||||
// TODO(wzang): Make sure time is correct (check that npupdate has updated
|
||||
// successfully). See AutoEnrollmentController::SystemClockSyncWaiter for
|
||||
// potential refactor in the ping embargo class.
|
||||
if (!HasRlzEmbargoEndDatePassed()) {
|
||||
*time = GetSystemTimeAsInt64();
|
||||
return true;
|
||||
@ -376,7 +377,7 @@ void RlzValueStoreChromeOS::CollectGarbage() {
|
||||
bool RlzValueStoreChromeOS::HasRlzEmbargoEndDatePassed() {
|
||||
chromeos::system::StatisticsProvider* statistics_provider =
|
||||
chromeos::system::StatisticsProvider::GetInstance();
|
||||
return chromeos::system::GetFactoryPingEmbargoState(statistics_provider) !=
|
||||
return chromeos::system::GetRlzPingEmbargoState(statistics_provider) !=
|
||||
chromeos::system::FactoryPingEmbargoState::kNotPassed;
|
||||
}
|
||||
|
||||
|
@ -349,11 +349,11 @@ TEST_F(FinancialPingTest, RlzEmbargoEndDate) {
|
||||
rlz_lib::FinancialPing::IsPingTime(rlz_lib::TOOLBAR_NOTIFIER, false));
|
||||
|
||||
// Simulate writing a future embargo date (less than
|
||||
// |kRlzEmbargoEndDateGarbageDateThresholdDays|) to VPD, verify that
|
||||
// |kEmbargoEndDateGarbageDateThresholdDays|) to VPD, verify that
|
||||
// |IsPingTime| is false.
|
||||
base::Time future_rlz_embargo_date =
|
||||
base::Time::NowFromSystemTime() +
|
||||
chromeos::system::kRlzEmbargoEndDateGarbageDateThreshold -
|
||||
chromeos::system::kEmbargoEndDateGarbageDateThreshold -
|
||||
base::TimeDelta::FromDays(1);
|
||||
future_rlz_embargo_date.LocalExplode(&exploded);
|
||||
std::string future_rlz_embargo_date_value =
|
||||
@ -365,11 +365,11 @@ TEST_F(FinancialPingTest, RlzEmbargoEndDate) {
|
||||
rlz_lib::FinancialPing::IsPingTime(rlz_lib::TOOLBAR_NOTIFIER, false));
|
||||
|
||||
// Simulate writing a future embargo date (more than
|
||||
// |kRlzEmbargoEndDateGarbageDateThresholdDays|) to VPD, verify that
|
||||
// |kEmbargoEndDateGarbageDateThresholdDays|) to VPD, verify that
|
||||
// |IsPingTime| is true.
|
||||
future_rlz_embargo_date =
|
||||
base::Time::NowFromSystemTime() +
|
||||
chromeos::system::kRlzEmbargoEndDateGarbageDateThreshold +
|
||||
chromeos::system::kEmbargoEndDateGarbageDateThreshold +
|
||||
base::TimeDelta::FromDays(1);
|
||||
future_rlz_embargo_date.LocalExplode(&exploded);
|
||||
future_rlz_embargo_date_value = ConvertExplodedToRlzEmbargoDate(exploded);
|
||||
|
Reference in New Issue
Block a user