• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #include "update_engine/update_manager/api_restricted_downloads_policy_impl.h"
18 
19 using chromeos_update_engine::ErrorCode;
20 using std::string;
21 using std::vector;
22 
23 namespace chromeos_update_manager {
24 
25 // Allow the API to restrict the downloading of updates.
UpdateCanBeApplied(EvaluationContext * ec,State * state,std::string * error,ErrorCode * result,chromeos_update_engine::InstallPlan * install_plan) const26 EvalStatus ApiRestrictedDownloadsPolicyImpl::UpdateCanBeApplied(
27     EvaluationContext* ec,
28     State* state,
29     std::string* error,
30     ErrorCode* result,
31     chromeos_update_engine::InstallPlan* install_plan) const {
32   // Next, check to see if updates can be applied (in general).
33   const UpdateRestrictions* update_restrictions_p =
34       ec->GetValue(state->updater_provider()->var_update_restrictions());
35   if (update_restrictions_p) {
36     if (*update_restrictions_p & UpdateRestrictions::kRestrictDownloading) {
37       *result = ErrorCode::kOmahaUpdateDeferredPerPolicy;
38       return EvalStatus::kSucceeded;
39     }
40   }
41 
42   // The API isn't restricting downloads, so implicitly allow them to happen
43   // but don't explicitly return success from this policy implementation.
44   return EvalStatus::kContinue;
45 }
46 
47 }  // namespace chromeos_update_manager
48