android_things_policy.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #ifndef UPDATE_ENGINE_UPDATE_MANAGER_ANDROID_THINGS_POLICY_H_
  17. #define UPDATE_ENGINE_UPDATE_MANAGER_ANDROID_THINGS_POLICY_H_
  18. #include <string>
  19. #include "update_engine/update_manager/next_update_check_policy_impl.h"
  20. #include "update_engine/update_manager/policy_utils.h"
  21. namespace chromeos_update_manager {
  22. // AndroidThingsPolicy implements the policy-related logic used in
  23. // AndroidThings.
  24. class AndroidThingsPolicy : public Policy {
  25. public:
  26. AndroidThingsPolicy() = default;
  27. ~AndroidThingsPolicy() override = default;
  28. // Policy overrides.
  29. EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
  30. State* state,
  31. std::string* error,
  32. UpdateCheckParams* result) const override;
  33. // Uses the |UpdateRestrictions| to determine if the download and apply can
  34. // occur at this time.
  35. EvalStatus UpdateCanBeApplied(
  36. EvaluationContext* ec,
  37. State* state,
  38. std::string* error,
  39. chromeos_update_engine::ErrorCode* result,
  40. chromeos_update_engine::InstallPlan* install_plan) const override;
  41. // Always returns |EvalStatus::kSucceeded|
  42. EvalStatus UpdateCanStart(EvaluationContext* ec,
  43. State* state,
  44. std::string* error,
  45. UpdateDownloadParams* result,
  46. UpdateState update_state) const override;
  47. // Always returns |EvalStatus::kSucceeded|
  48. EvalStatus UpdateDownloadAllowed(EvaluationContext* ec,
  49. State* state,
  50. std::string* error,
  51. bool* result) const override;
  52. // P2P is always disabled. Returns |result|==|false| and
  53. // |EvalStatus::kSucceeded|
  54. EvalStatus P2PEnabled(EvaluationContext* ec,
  55. State* state,
  56. std::string* error,
  57. bool* result) const override;
  58. // This will return immediately with |EvalStatus::kSucceeded| and set
  59. // |result|==|false|
  60. EvalStatus P2PEnabledChanged(EvaluationContext* ec,
  61. State* state,
  62. std::string* error,
  63. bool* result,
  64. bool prev_result) const override;
  65. protected:
  66. // Policy override.
  67. std::string PolicyName() const override { return "AndroidThingsPolicy"; }
  68. private:
  69. friend class UmAndroidThingsPolicyTest;
  70. FRIEND_TEST(UmAndroidThingsPolicyTest, UpdateCheckAllowedWaitsForTheTimeout);
  71. static const NextUpdateCheckPolicyConstants kNextUpdateCheckPolicyConstants;
  72. DISALLOW_COPY_AND_ASSIGN(AndroidThingsPolicy);
  73. };
  74. } // namespace chromeos_update_manager
  75. #endif // UPDATE_ENGINE_UPDATE_MANAGER_ANDROID_THINGS_POLICY_H_