service_delegate_android_interface.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright (C) 2016 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_SERVICE_DELEGATE_ANDROID_INTERFACE_H_
  17. #define UPDATE_ENGINE_SERVICE_DELEGATE_ANDROID_INTERFACE_H_
  18. #include <inttypes.h>
  19. #include <string>
  20. #include <vector>
  21. #include <brillo/errors/error.h>
  22. namespace chromeos_update_engine {
  23. // This class defines the interface exposed by the Android version of the
  24. // daemon service. This interface only includes the method calls that such
  25. // daemon exposes. For asynchronous events initiated by a class implementing
  26. // this interface see the ServiceObserverInterface class.
  27. class ServiceDelegateAndroidInterface {
  28. public:
  29. virtual ~ServiceDelegateAndroidInterface() = default;
  30. // Start an update attempt to download an apply the provided |payload_url| if
  31. // no other update is running. The extra |key_value_pair_headers| will be
  32. // included when fetching the payload. Returns whether the update was started
  33. // successfully, which means that no other update was running and the passed
  34. // parameters were correct, but not necessarily that the update finished
  35. // correctly.
  36. virtual bool ApplyPayload(
  37. const std::string& payload_url,
  38. int64_t payload_offset,
  39. int64_t payload_size,
  40. const std::vector<std::string>& key_value_pair_headers,
  41. brillo::ErrorPtr* error) = 0;
  42. // Suspend an ongoing update. Returns true if there was an update ongoing and
  43. // it was suspended. In case of failure, it returns false and sets |error|
  44. // accordingly.
  45. virtual bool SuspendUpdate(brillo::ErrorPtr* error) = 0;
  46. // Resumes an update suspended with SuspendUpdate(). The update can't be
  47. // suspended after it finished and this method will fail in that case.
  48. // Returns whether the resume operation was successful, which only implies
  49. // that there was a suspended update. In case of error, returns false and sets
  50. // |error| accordingly.
  51. virtual bool ResumeUpdate(brillo::ErrorPtr* error) = 0;
  52. // Cancel the ongoing update. The update could be running or suspended, but it
  53. // can't be canceled after it was done. In case of error, returns false and
  54. // sets |error| accordingly.
  55. virtual bool CancelUpdate(brillo::ErrorPtr* error) = 0;
  56. // Reset the already applied update back to an idle state. This method can
  57. // only be called when no update attempt is going on, and it will reset the
  58. // status back to idle, deleting the currently applied update if any. In case
  59. // of error, returns false and sets |error| accordingly.
  60. virtual bool ResetStatus(brillo::ErrorPtr* error) = 0;
  61. // Verifies whether a payload (delegated by the payload metadata) can be
  62. // applied to the current device. Returns whether the payload is applicable.
  63. // In case of error, returns false and sets |error| accordingly.
  64. virtual bool VerifyPayloadApplicable(const std::string& metadata_filename,
  65. brillo::ErrorPtr* error) = 0;
  66. protected:
  67. ServiceDelegateAndroidInterface() = default;
  68. };
  69. } // namespace chromeos_update_engine
  70. #endif // UPDATE_ENGINE_SERVICE_DELEGATE_ANDROID_INTERFACE_H_