update_engine: Modify Update Time Restrictions to block downloads

This makes Update Time Restrictions policy block downloads rather than
checks. This will allow for better capturing of metrics. Furthermore,
this change makes Update Time Restrictions only apply for kiosks, per
the discussion with security and PM.
The following changes are made:
* Use UpdateCanBeApplied rather than UpdateCheckAllowed in
UpdateTimeRestrictionsPolicyImpl.
* ChromeOSPolicy::UpdateCanBeApplied now checks for forced updates.
Modify the corresponding classes to implement UpdateCanBeApplied.
* Add the auto_launched_kiosk_app_id variable from libbrillo to the
policy provider, this variable lets us know if the device is in
kiosk-mode.
* If the device is not in kiosk mode, this policy won't be used.
* Change chromeos_policy to check for policies in UpdateCanBeApplied.
* Add unit tests accounting for the new changes.

BUG=chromium:852860
TEST=cros_workon_make update_engine --test

Change-Id: Iba52fa0fd1f89cc55e5009776036f8949e01e3a0
Reviewed-on: https://chromium-review.googlesource.com/1144435
Commit-Ready: Adolfo Higueros <adokar@google.com>
Tested-by: Adolfo Higueros <adokar@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index f8ef84f..abb06c7 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -214,7 +214,6 @@
   OobePolicyImpl oobe_policy;
   NextUpdateCheckTimePolicyImpl next_update_check_time_policy(
       kNextUpdateCheckPolicyConstants);
-  UpdateTimeRestrictionsPolicyImpl update_time_restrictions_policy;
 
   vector<Policy const*> policies_to_consult = {
       // Do not perform any updates if there are not enough slots to do A/B
@@ -234,9 +233,6 @@
       // If OOBE is enabled, wait until it is completed.
       &oobe_policy,
 
-      // Ensure that updates are checked only in allowed times.
-      &update_time_restrictions_policy,
-
       // Ensure that periodic update checks are timed properly.
       &next_update_check_time_policy,
   };
@@ -265,8 +261,33 @@
                                               std::string* error,
                                               ErrorCode* result,
                                               InstallPlan* install_plan) const {
-  *result = ErrorCode::kSuccess;
-  return EvalStatus::kSucceeded;
+  UpdateTimeRestrictionsPolicyImpl update_time_restrictions_policy;
+  InteractiveUpdatePolicyImpl interactive_update_policy;
+
+  vector<Policy const*> policies_to_consult = {
+      // Check to see if an interactive update has been requested.
+      &interactive_update_policy,
+
+      // Do not apply or download an update if we are inside one of the
+      // restricted times.
+      &update_time_restrictions_policy,
+  };
+
+  EvalStatus status = ConsultPolicies(policies_to_consult,
+                                      &Policy::UpdateCanBeApplied,
+                                      ec,
+                                      state,
+                                      error,
+                                      result,
+                                      install_plan);
+  if (EvalStatus::kContinue != status) {
+    return status;
+  } else {
+    // The update can proceed.
+    LOG(INFO) << "Allowing update to be applied.";
+    *result = ErrorCode::kSuccess;
+    return EvalStatus::kSucceeded;
+  }
 }
 
 EvalStatus ChromeOSPolicy::UpdateCanStart(
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index 184c241..b5b1bd9 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -28,6 +28,7 @@
 using chromeos_update_engine::ConnectionTethering;
 using chromeos_update_engine::ConnectionType;
 using chromeos_update_engine::ErrorCode;
+using chromeos_update_engine::InstallPlan;
 using std::set;
 using std::string;
 
@@ -151,20 +152,25 @@
   // time.
   void TestDisallowedTimeIntervals(const WeeklyTimeIntervalVector& intervals,
                                    const EvalStatus& expected_status,
-                                   bool is_forced_update) {
+                                   bool kiosk) {
     SetUpDefaultTimeProvider();
-    SetUpdateCheckAllowed(true);
-
-    if (is_forced_update)
-      fake_state_.updater_provider()->var_forced_update_requested()->reset(
-          new UpdateRequestStatus(UpdateRequestStatus::kInteractive));
+    if (kiosk)
+      fake_state_.device_policy_provider()
+          ->var_auto_launched_kiosk_app_id()
+          ->reset(new string("myapp"));
     fake_state_.device_policy_provider()
         ->var_disallowed_time_intervals()
         ->reset(new WeeklyTimeIntervalVector(intervals));
 
     // Check that |expected_status| matches the value of UpdateCheckAllowed
-    UpdateCheckParams result;
-    ExpectPolicyStatus(expected_status, &Policy::UpdateCheckAllowed, &result);
+    ErrorCode result;
+    InstallPlan install_plan;
+    ExpectPolicyStatus(
+        expected_status, &Policy::UpdateCanBeApplied, &result, &install_plan);
+    if (expected_status == EvalStatus::kAskMeAgainLater)
+      EXPECT_EQ(result, ErrorCode::kOmahaUpdateDeferredPerPolicy);
+    else
+      EXPECT_EQ(result, ErrorCode::kSuccess);
   }
 };
 
@@ -328,43 +334,6 @@
 }
 
 TEST_F(UmChromeOSPolicyTest,
-       UpdateCheckAllowedWaitsForEndOfDisallowedInterval) {
-  // Check that the policy blocks during the disallowed checking intervals.
-  Time curr_time = fake_clock_.GetWallclockTime();
-  TestDisallowedTimeIntervals(
-      {WeeklyTimeInterval(
-          WeeklyTime::FromTime(curr_time),
-          WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
-      EvalStatus::kAskMeAgainLater,
-      false);
-}
-
-TEST_F(UmChromeOSPolicyTest,
-       UpdateCheckAllowedNoBlockOutsideDisallowedInterval) {
-  // Check that updates are allowed outside interval.
-  Time curr_time = fake_clock_.GetWallclockTime();
-  TestDisallowedTimeIntervals(
-      {WeeklyTimeInterval(
-          WeeklyTime::FromTime(curr_time - TimeDelta::FromMinutes(2)),
-          WeeklyTime::FromTime(curr_time - TimeDelta::FromMinutes(1)))},
-      EvalStatus::kSucceeded,
-      false);
-}
-
-TEST_F(UmChromeOSPolicyTest,
-       UpdateCheckAllowedDisallowedIntervalNoBlockWhenForced) {
-  // Check that updates are not blocked by this policy when an update is forced.
-  Time curr_time = fake_clock_.GetWallclockTime();
-  // Really big interval so that current time definitely falls in it.
-  TestDisallowedTimeIntervals(
-      {WeeklyTimeInterval(
-          WeeklyTime::FromTime(curr_time - TimeDelta::FromMinutes(1234)),
-          WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1234)))},
-      EvalStatus::kSucceeded,
-      true);
-}
-
-TEST_F(UmChromeOSPolicyTest,
        UpdateCheckAllowedUpdatesDisabledWhenNotEnoughSlotsAbUpdates) {
   // UpdateCheckAllowed should return false (kSucceeded) if the image booted
   // without enough slots to do A/B updates.
@@ -1636,4 +1605,48 @@
                      &result, false);
 }
 
+TEST_F(UmChromeOSPolicyTest,
+       UpdateCanBeAppliedForcedUpdatesDisablesTimeRestrictions) {
+  Time curr_time = fake_clock_.GetWallclockTime();
+  fake_state_.updater_provider()->var_forced_update_requested()->reset(
+      new UpdateRequestStatus(UpdateRequestStatus::kInteractive));
+  // Should return kAskMeAgainLater when updated are not forced.
+  TestDisallowedTimeIntervals(
+      {WeeklyTimeInterval(
+          WeeklyTime::FromTime(curr_time),
+          WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
+      EvalStatus::kSucceeded,
+      /* kiosk = */ true);
+}
+
+TEST_F(UmChromeOSPolicyTest, UpdateCanBeAppliedFailsInDisallowedTime) {
+  Time curr_time = fake_clock_.GetWallclockTime();
+  TestDisallowedTimeIntervals(
+      {WeeklyTimeInterval(
+          WeeklyTime::FromTime(curr_time),
+          WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
+      EvalStatus::kAskMeAgainLater,
+      /* kiosk = */ true);
+}
+
+TEST_F(UmChromeOSPolicyTest, UpdateCanBeAppliedOutsideDisallowedTime) {
+  Time curr_time = fake_clock_.GetWallclockTime();
+  TestDisallowedTimeIntervals(
+      {WeeklyTimeInterval(
+          WeeklyTime::FromTime(curr_time - TimeDelta::FromHours(3)),
+          WeeklyTime::FromTime(curr_time))},
+      EvalStatus::kSucceeded,
+      /* kiosk = */ true);
+}
+
+TEST_F(UmChromeOSPolicyTest, UpdateCanBeAppliedPassesOnNonKiosk) {
+  Time curr_time = fake_clock_.GetWallclockTime();
+  TestDisallowedTimeIntervals(
+      {WeeklyTimeInterval(
+          WeeklyTime::FromTime(curr_time),
+          WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
+      EvalStatus::kSucceeded,
+      /* kiosk = */ false);
+}
+
 }  // namespace chromeos_update_manager
diff --git a/update_manager/device_policy_provider.h b/update_manager/device_policy_provider.h
index c7e9d3a..80dcfa2 100644
--- a/update_manager/device_policy_provider.h
+++ b/update_manager/device_policy_provider.h
@@ -76,6 +76,10 @@
 
   virtual Variable<bool>* var_allow_kiosk_app_control_chrome_version() = 0;
 
+  // Variable that contains the app that is to be run when launched in kiosk
+  // mode. If the device is not in kiosk-mode this should be empty.
+  virtual Variable<std::string>* var_auto_launched_kiosk_app_id() = 0;
+
   // Variable that contains the time intervals during the week for which update
   // checks are disallowed.
   virtual Variable<WeeklyTimeIntervalVector>*
diff --git a/update_manager/fake_device_policy_provider.h b/update_manager/fake_device_policy_provider.h
index 70aca12..d70e0c3 100644
--- a/update_manager/fake_device_policy_provider.h
+++ b/update_manager/fake_device_policy_provider.h
@@ -84,6 +84,10 @@
     return &var_allow_kiosk_app_control_chrome_version_;
   }
 
+  FakeVariable<std::string>* var_auto_launched_kiosk_app_id() override {
+    return &var_auto_launched_kiosk_app_id_;
+  }
+
   FakeVariable<WeeklyTimeIntervalVector>* var_disallowed_time_intervals()
       override {
     return &var_disallowed_time_intervals_;
@@ -115,6 +119,8 @@
   FakeVariable<bool> var_au_p2p_enabled_{"au_p2p_enabled", kVariableModePoll};
   FakeVariable<bool> var_allow_kiosk_app_control_chrome_version_{
       "allow_kiosk_app_control_chrome_version", kVariableModePoll};
+  FakeVariable<std::string> var_auto_launched_kiosk_app_id_{
+      "auto_launched_kiosk_app_id", kVariableModePoll};
   FakeVariable<WeeklyTimeIntervalVector> var_disallowed_time_intervals_{
       "disallowed_time_intervals", kVariableModePoll};
 
diff --git a/update_manager/interactive_update_policy_impl.cc b/update_manager/interactive_update_policy_impl.cc
index 03af435..872dc5d 100644
--- a/update_manager/interactive_update_policy_impl.cc
+++ b/update_manager/interactive_update_policy_impl.cc
@@ -16,6 +16,9 @@
 
 #include "update_engine/update_manager/interactive_update_policy_impl.h"
 
+using chromeos_update_engine::ErrorCode;
+using chromeos_update_engine::InstallPlan;
+
 namespace chromeos_update_manager {
 
 // Check to see if an interactive update was requested.
@@ -24,21 +27,51 @@
     State* state,
     std::string* error,
     UpdateCheckParams* result) const {
-  UpdaterProvider* const updater_provider = state->updater_provider();
+  bool interactive;
+  if (CheckInteractiveUpdateRequested(
+          ec, state->updater_provider(), &interactive)) {
+    result->interactive = interactive;
+    LOG(INFO) << "Forced update signaled ("
+              << (interactive ? "interactive" : "periodic")
+              << "), allowing update check.";
+    return EvalStatus::kSucceeded;
+  }
+  return EvalStatus::kContinue;
+}
 
+EvalStatus InteractiveUpdatePolicyImpl::UpdateCanBeApplied(
+    EvaluationContext* ec,
+    State* state,
+    std::string* error,
+    ErrorCode* result,
+    InstallPlan* install_plan) const {
+  bool interactive;
+  if (CheckInteractiveUpdateRequested(
+          ec, state->updater_provider(), &interactive)) {
+    LOG(INFO) << "Forced update signaled ("
+              << (interactive ? "interactive" : "periodic")
+              << "), allowing update to be applied.";
+    *result = ErrorCode::kSuccess;
+    return EvalStatus::kSucceeded;
+  }
+  return EvalStatus::kContinue;
+}
+
+bool InteractiveUpdatePolicyImpl::CheckInteractiveUpdateRequested(
+    EvaluationContext* ec,
+    UpdaterProvider* const updater_provider,
+    bool* interactive_out) const {
   // First, check to see if an interactive update was requested.
   const UpdateRequestStatus* forced_update_requested_p =
       ec->GetValue(updater_provider->var_forced_update_requested());
   if (forced_update_requested_p != nullptr &&
       *forced_update_requested_p != UpdateRequestStatus::kNone) {
-    result->interactive =
-        (*forced_update_requested_p == UpdateRequestStatus::kInteractive);
-    LOG(INFO) << "Forced update signaled ("
-              << (result->interactive ? "interactive" : "periodic")
-              << "), allowing update check.";
-    return EvalStatus::kSucceeded;
+    if (interactive_out)
+      *interactive_out =
+          (*forced_update_requested_p == UpdateRequestStatus::kInteractive);
+    return true;
   }
-  return EvalStatus::kContinue;
+  return false;
 }
 
 }  // namespace chromeos_update_manager
diff --git a/update_manager/interactive_update_policy_impl.h b/update_manager/interactive_update_policy_impl.h
index 18cf565..3690cfb 100644
--- a/update_manager/interactive_update_policy_impl.h
+++ b/update_manager/interactive_update_policy_impl.h
@@ -19,6 +19,8 @@
 
 #include <string>
 
+#include "update_engine/common/error_code.h"
+#include "update_engine/payload_consumer/install_plan.h"
 #include "update_engine/update_manager/policy_utils.h"
 
 namespace chromeos_update_manager {
@@ -35,12 +37,27 @@
                                 std::string* error,
                                 UpdateCheckParams* result) const override;
 
+  EvalStatus UpdateCanBeApplied(
+      EvaluationContext* ec,
+      State* state,
+      std::string* error,
+      chromeos_update_engine::ErrorCode* result,
+      chromeos_update_engine::InstallPlan* install_plan) const override;
+
  protected:
   std::string PolicyName() const override {
     return "InteractiveUpdatePolicyImpl";
   }
 
  private:
+  // Checks whether a forced update was requested. If there is a forced update,
+  // return true and set |interactive_out| to true if the forced update is
+  // interactive, and false otherwise. If there are no forced updates, return
+  // true and don't modify |interactive_out|.
+  bool CheckInteractiveUpdateRequested(EvaluationContext* ec,
+                                       UpdaterProvider* const updater_provider,
+                                       bool* interactive_out) const;
+
   DISALLOW_COPY_AND_ASSIGN(InteractiveUpdatePolicyImpl);
 };
 
diff --git a/update_manager/real_device_policy_provider.cc b/update_manager/real_device_policy_provider.cc
index b1135d9..e0872bb 100644
--- a/update_manager/real_device_policy_provider.cc
+++ b/update_manager/real_device_policy_provider.cc
@@ -232,6 +232,8 @@
   UpdateVariable(&var_au_p2p_enabled_, &DevicePolicy::GetAuP2PEnabled);
   UpdateVariable(&var_allow_kiosk_app_control_chrome_version_,
                  &DevicePolicy::GetAllowKioskAppControlChromeVersion);
+  UpdateVariable(&var_auto_launched_kiosk_app_id_,
+                 &DevicePolicy::GetAutoLaunchedKioskAppId);
   UpdateVariable(&var_disallowed_time_intervals_,
                  &RealDevicePolicyProvider::ConvertDisallowedTimeIntervals);
 }
diff --git a/update_manager/real_device_policy_provider.h b/update_manager/real_device_policy_provider.h
index 88fbfa2..d999d81 100644
--- a/update_manager/real_device_policy_provider.h
+++ b/update_manager/real_device_policy_provider.h
@@ -105,6 +105,10 @@
     return &var_allow_kiosk_app_control_chrome_version_;
   }
 
+  Variable<std::string>* var_auto_launched_kiosk_app_id() override {
+    return &var_auto_launched_kiosk_app_id_;
+  }
+
   Variable<WeeklyTimeIntervalVector>* var_disallowed_time_intervals() override {
     return &var_disallowed_time_intervals_;
   }
@@ -203,6 +207,8 @@
       "allow_kiosk_app_control_chrome_version"};
   AsyncCopyVariable<WeeklyTimeIntervalVector> var_disallowed_time_intervals_{
       "update_time_restrictions"};
+  AsyncCopyVariable<std::string> var_auto_launched_kiosk_app_id_{
+      "auto_launched_kiosk_app_id"};
 
   DISALLOW_COPY_AND_ASSIGN(RealDevicePolicyProvider);
 };
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index 49a5ec2..32e273d 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -193,6 +193,8 @@
   UmTestUtils::ExpectVariableNotSet(provider_->var_au_p2p_enabled());
   UmTestUtils::ExpectVariableNotSet(
       provider_->var_allow_kiosk_app_control_chrome_version());
+  UmTestUtils::ExpectVariableNotSet(
+      provider_->var_auto_launched_kiosk_app_id());
   UmTestUtils::ExpectVariableNotSet(provider_->var_disallowed_time_intervals());
 }
 
@@ -211,6 +213,8 @@
       .WillOnce(Return(false));
   EXPECT_CALL(mock_device_policy_, GetAllowKioskAppControlChromeVersion(_))
       .WillOnce(DoAll(SetArgPointee<0>(true), Return(true)));
+  EXPECT_CALL(mock_device_policy_, GetAutoLaunchedKioskAppId(_))
+      .WillOnce(DoAll(SetArgPointee<0>(string("myapp")), Return(true)));
 
   provider_->RefreshDevicePolicy();
 
@@ -224,6 +228,8 @@
       provider_->var_allowed_connection_types_for_update());
   UmTestUtils::ExpectVariableHasValue(
       true, provider_->var_allow_kiosk_app_control_chrome_version());
+  UmTestUtils::ExpectVariableHasValue(
+      string("myapp"), provider_->var_auto_launched_kiosk_app_id());
 }
 
 TEST_F(UmRealDevicePolicyProviderTest, RollbackToTargetVersionConverted) {
diff --git a/update_manager/update_time_restrictions_policy_impl.cc b/update_manager/update_time_restrictions_policy_impl.cc
index baeb937..8179f89 100644
--- a/update_manager/update_time_restrictions_policy_impl.cc
+++ b/update_manager/update_time_restrictions_policy_impl.cc
@@ -26,15 +26,23 @@
 using base::Time;
 using base::TimeDelta;
 
+using chromeos_update_engine::ErrorCode;
+using chromeos_update_engine::InstallPlan;
+
 namespace chromeos_update_manager {
 
-EvalStatus UpdateTimeRestrictionsPolicyImpl::UpdateCheckAllowed(
+EvalStatus UpdateTimeRestrictionsPolicyImpl::UpdateCanBeApplied(
     EvaluationContext* ec,
     State* state,
     std::string* error,
-    UpdateCheckParams* result) const {
-  TimeProvider* const time_provider = state->time_provider();
+    ErrorCode* result,
+    InstallPlan* install_plan) const {
   DevicePolicyProvider* const dp_provider = state->device_policy_provider();
+  TimeProvider* const time_provider = state->time_provider();
+
+  // If kiosk mode is not enabled, don't restrict updates.
+  if (!ec->GetValue(dp_provider->var_auto_launched_kiosk_app_id()))
+    return EvalStatus::kContinue;
 
   const Time* curr_date = ec->GetValue(time_provider->var_curr_date());
   const int* curr_hour = ec->GetValue(time_provider->var_curr_hour());
@@ -55,6 +63,7 @@
   }
   for (const auto& interval : *intervals) {
     if (interval.InRange(now)) {
+      *result = ErrorCode::kOmahaUpdateDeferredPerPolicy;
       return EvalStatus::kAskMeAgainLater;
     }
   }
diff --git a/update_manager/update_time_restrictions_policy_impl.h b/update_manager/update_time_restrictions_policy_impl.h
index 1046531..6a810ba 100644
--- a/update_manager/update_time_restrictions_policy_impl.h
+++ b/update_manager/update_time_restrictions_policy_impl.h
@@ -20,6 +20,8 @@
 
 #include <base/time/time.h>
 
+#include "update_engine/common/error_code.h"
+#include "update_engine/payload_consumer/install_plan.h"
 #include "update_engine/update_manager/policy_utils.h"
 
 namespace chromeos_update_manager {
@@ -38,10 +40,12 @@
   // kAskMeAgainLater. If the current time is not inside any intervals returns
   // kContinue. In case of errors, i.e. cannot access intervals or time, return
   // kContinue.
-  EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
-                                State* state,
-                                std::string* error,
-                                UpdateCheckParams* result) const override;
+  EvalStatus UpdateCanBeApplied(
+      EvaluationContext* ec,
+      State* state,
+      std::string* error,
+      chromeos_update_engine::ErrorCode* result,
+      chromeos_update_engine::InstallPlan* install_plan) const override;
 
  protected:
   std::string PolicyName() const override {
diff --git a/update_manager/update_time_restrictions_policy_impl_unittest.cc b/update_manager/update_time_restrictions_policy_impl_unittest.cc
index 5c15821..bfb43dc 100644
--- a/update_manager/update_time_restrictions_policy_impl_unittest.cc
+++ b/update_manager/update_time_restrictions_policy_impl_unittest.cc
@@ -25,6 +25,8 @@
 
 using base::Time;
 using base::TimeDelta;
+using chromeos_update_engine::ErrorCode;
+using chromeos_update_engine::InstallPlan;
 using std::string;
 
 namespace chromeos_update_manager {
@@ -49,40 +51,67 @@
 
   void TestPolicy(const Time::Exploded& exploded,
                   const WeeklyTimeIntervalVector& test_intervals,
-                  const EvalStatus& expected_value) {
+                  const EvalStatus& expected_value,
+                  bool kiosk) {
+    if (kiosk)
+      fake_state_.device_policy_provider()
+          ->var_auto_launched_kiosk_app_id()
+          ->reset(new string("myapp"));
     fake_clock_.SetWallclockTime(Time::FromLocalExploded(exploded));
     SetUpDefaultTimeProvider();
     fake_state_.device_policy_provider()
         ->var_disallowed_time_intervals()
         ->reset(new WeeklyTimeIntervalVector(test_intervals));
-    UpdateCheckParams result;
-    ExpectPolicyStatus(expected_value, &Policy::UpdateCheckAllowed, &result);
+    ErrorCode result;
+    InstallPlan install_plan;
+    ExpectPolicyStatus(
+        expected_value, &Policy::UpdateCanBeApplied, &result, &install_plan);
+    if (expected_value == EvalStatus::kAskMeAgainLater)
+      EXPECT_EQ(result, ErrorCode::kOmahaUpdateDeferredPerPolicy);
   }
 };
 
 // If there are no intervals, then the check should always return kContinue.
 TEST_F(UmUpdateTimeRestrictionsPolicyImplTest, NoIntervalsSetTest) {
   Time::Exploded random_time{2018, 7, 1, 9, 12, 30, 0, 0};
-  TestPolicy(random_time, WeeklyTimeIntervalVector(), EvalStatus::kContinue);
+  TestPolicy(random_time,
+             WeeklyTimeIntervalVector(),
+             EvalStatus::kContinue,
+             /* kiosk = */ true);
 }
 
 // Check that all intervals are checked.
 TEST_F(UmUpdateTimeRestrictionsPolicyImplTest, TimeInRange) {
   // Monday, July 9th 2018 12:30 PM.
   Time::Exploded first_interval_time{2018, 7, 1, 9, 12, 30, 0, 0};
-  TestPolicy(first_interval_time, kTestIntervals, EvalStatus::kAskMeAgainLater);
+  TestPolicy(first_interval_time,
+             kTestIntervals,
+             EvalStatus::kAskMeAgainLater,
+             /* kiosk = */ true);
 
   // Check second interval.
   // Thursday, July 12th 2018 4:30 AM.
   Time::Exploded second_interval_time{2018, 7, 4, 12, 4, 30, 0, 0};
-  TestPolicy(
-      second_interval_time, kTestIntervals, EvalStatus::kAskMeAgainLater);
+  TestPolicy(second_interval_time,
+             kTestIntervals,
+             EvalStatus::kAskMeAgainLater,
+             /* kiosk = */ true);
 }
 
 TEST_F(UmUpdateTimeRestrictionsPolicyImplTest, TimeOutOfRange) {
   // Monday, July 9th 2018 6:30 PM.
   Time::Exploded out_of_range_time{2018, 7, 1, 9, 18, 30, 0, 0};
-  TestPolicy(out_of_range_time, kTestIntervals, EvalStatus::kContinue);
+  TestPolicy(out_of_range_time,
+             kTestIntervals,
+             EvalStatus::kContinue,
+             /* kiosk = */ true);
 }
 
+TEST_F(UmUpdateTimeRestrictionsPolicyImplTest, NoKioskDisablesPolicy) {
+  Time::Exploded in_range_time{2018, 7, 1, 9, 12, 30, 0, 0};
+  TestPolicy(in_range_time,
+             kTestIntervals,
+             EvalStatus::kContinue,
+             /* kiosk = */ false);
+}
 }  // namespace chromeos_update_manager