api_restricted_downloads_policy_impl.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Copyright (C) 2017 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include "update_engine/update_manager/api_restricted_downloads_policy_impl.h"
  17. using chromeos_update_engine::ErrorCode;
  18. using std::string;
  19. using std::vector;
  20. namespace chromeos_update_manager {
  21. // Allow the API to restrict the downloading of updates.
  22. EvalStatus ApiRestrictedDownloadsPolicyImpl::UpdateCanBeApplied(
  23. EvaluationContext* ec,
  24. State* state,
  25. std::string* error,
  26. ErrorCode* result,
  27. chromeos_update_engine::InstallPlan* install_plan) const {
  28. // Next, check to see if updates can be applied (in general).
  29. const UpdateRestrictions* update_restrictions_p =
  30. ec->GetValue(state->updater_provider()->var_update_restrictions());
  31. if (update_restrictions_p) {
  32. if (*update_restrictions_p & UpdateRestrictions::kRestrictDownloading) {
  33. *result = ErrorCode::kOmahaUpdateDeferredPerPolicy;
  34. return EvalStatus::kSucceeded;
  35. }
  36. }
  37. // The API isn't restricting downloads, so implicitly allow them to happen
  38. // but don't explicitly return success from this policy implementation.
  39. return EvalStatus::kContinue;
  40. }
  41. } // namespace chromeos_update_manager