blob: 6bd75b62cb3c47fe52a78fb44e1a34d1c9d8e3b3 [file] [log] [blame]
Alex Deymof8bfcff2016-02-02 21:22:11 -08001//
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
27namespace 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.
33class 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
Kyeongkab.Nam500ca132019-06-26 13:48:07 +090050 virtual bool ApplyPayload(
51 int fd,
52 int64_t payload_offset,
53 int64_t payload_size,
54 const std::vector<std::string>& key_value_pair_headers,
55 brillo::ErrorPtr* error) = 0;
56
Alex Deymof8bfcff2016-02-02 21:22:11 -080057 // Suspend an ongoing update. Returns true if there was an update ongoing and
58 // it was suspended. In case of failure, it returns false and sets |error|
59 // accordingly.
60 virtual bool SuspendUpdate(brillo::ErrorPtr* error) = 0;
61
62 // Resumes an update suspended with SuspendUpdate(). The update can't be
63 // suspended after it finished and this method will fail in that case.
64 // Returns whether the resume operation was successful, which only implies
65 // that there was a suspended update. In case of error, returns false and sets
66 // |error| accordingly.
67 virtual bool ResumeUpdate(brillo::ErrorPtr* error) = 0;
68
69 // Cancel the ongoing update. The update could be running or suspended, but it
70 // can't be canceled after it was done. In case of error, returns false and
71 // sets |error| accordingly.
72 virtual bool CancelUpdate(brillo::ErrorPtr* error) = 0;
73
Alex Deymo3b678db2016-02-09 11:50:06 -080074 // Reset the already applied update back to an idle state. This method can
75 // only be called when no update attempt is going on, and it will reset the
76 // status back to idle, deleting the currently applied update if any. In case
77 // of error, returns false and sets |error| accordingly.
78 virtual bool ResetStatus(brillo::ErrorPtr* error) = 0;
79
Sen Jiang8371c1c2018-02-01 13:46:39 -080080 // Verifies whether a payload (delegated by the payload metadata) can be
81 // applied to the current device. Returns whether the payload is applicable.
82 // In case of error, returns false and sets |error| accordingly.
83 virtual bool VerifyPayloadApplicable(const std::string& metadata_filename,
84 brillo::ErrorPtr* error) = 0;
85
Alex Deymof8bfcff2016-02-02 21:22:11 -080086 protected:
87 ServiceDelegateAndroidInterface() = default;
88};
89
90} // namespace chromeos_update_engine
91
92#endif // UPDATE_ENGINE_SERVICE_DELEGATE_ANDROID_INTERFACE_H_