blob: aa977e3c8d338a5ba3e4948b880a5de9f0176ab0 [file] [log] [blame]
Tianjie Xu1536db82019-05-14 10:54:43 -07001/*
2 * Copyright (C) 2019 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#pragma once
18
19#include <stdint.h>
20
21#include <string>
22#include <string_view>
23
24struct ZipArchive;
25typedef ZipArchive* ZipArchiveHandle;
26
27class UpdaterRuntimeInterface;
28
29class UpdaterInterface {
30 public:
31 virtual ~UpdaterInterface() = default;
32
33 // Writes the message to command pipe, adds a new line in the end.
34 virtual void WriteToCommandPipe(const std::string_view message, bool flush = false) const = 0;
35
36 // Sends over the message to recovery to print it on the screen.
37 virtual void UiPrint(const std::string_view message) const = 0;
38
39 // Given the name of the block device, returns |name| for updates on the device; or the file path
40 // to the fake block device for simulations.
41 virtual std::string FindBlockDeviceName(const std::string_view name) const = 0;
42
43 virtual UpdaterRuntimeInterface* GetRuntime() const = 0;
44 virtual ZipArchiveHandle GetPackageHandle() const = 0;
45 virtual std::string GetResult() const = 0;
46 virtual uint8_t* GetMappedPackageAddress() const = 0;
Robin Lee1cf8eb72019-07-05 22:56:20 +020047 virtual size_t GetMappedPackageLength() const = 0;
Tianjie Xu1536db82019-05-14 10:54:43 -070048};