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