blob: 03c8f3c6925517eaee777a46dd46e2eaf2033861 [file] [log] [blame]
Christopher Wiley16daa082015-10-01 17:18:40 -07001//
2// Copyright (C) 2015 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_CLIENT_LIBRARY_CLIENT_IMPL_H_
18#define UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_IMPL_H_
19
20#include <cstdint>
21#include <memory>
22#include <string>
23
24#include <base/macros.h>
25
Christopher Wiley16daa082015-10-01 17:18:40 -070026#include "update_engine/client_library/include/update_engine/client.h"
Alex Deymo39910dc2015-11-09 17:04:30 -080027#include "update_engine/dbus-proxies.h"
Christopher Wiley16daa082015-10-01 17:18:40 -070028
29namespace update_engine {
30namespace internal {
31
32class UpdateEngineClientImpl : public UpdateEngineClient {
33 public:
34 UpdateEngineClientImpl();
35 virtual ~UpdateEngineClientImpl() = default;
36
37 bool AttemptUpdate(const std::string& app_version,
38 const std::string& omaha_url,
39 bool at_user_request) override;
40
41 bool GetStatus(int64_t* out_last_checked_time,
42 double* out_progress,
43 UpdateStatus* out_update_status,
44 std::string* out_new_version,
45 int64_t* out_new_size) override;
46
Casey Dahlinef361132015-12-17 13:02:37 -080047 bool SetUpdateOverCellularPermission(bool allowed) override;
48 bool GetUpdateOverCellularPermission(bool* allowed) override;
49
50 bool SetP2PUpdatePermission(bool enabled) override;
51 bool GetP2PUpdatePermission(bool* enabled) override;
52
53 bool Rollback(bool powerwash) override;
54
55 bool GetRollbackPartition(std::string* rollback_partition) override;
56
57 void RebootIfNeeded() override;
58
Casey Dahlind8158462016-01-05 15:20:19 -080059 bool GetPrevVersion(std::string* prev_version) override;
Casey Dahlinef361132015-12-17 13:02:37 -080060
Casey Dahline844c1a2015-12-16 14:30:58 -080061 bool ResetStatus() override;
62
Casey Dahlin87ab88e2015-12-16 17:58:05 -080063 bool SetTargetChannel(const std::string& target_channel,
64 bool allow_powerwash) override;
Christopher Wiley16daa082015-10-01 17:18:40 -070065
66 bool GetTargetChannel(std::string* out_channel) override;
67
68 bool GetChannel(std::string* out_channel) override;
69
Casey Dahlin97c87052016-01-06 14:33:55 -080070 void RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
71
Christopher Wiley16daa082015-10-01 17:18:40 -070072 private:
73 std::unique_ptr<org::chromium::UpdateEngineInterfaceProxy> proxy_;
74
Casey Dahlin97c87052016-01-06 14:33:55 -080075 void StatusUpdateHandlerRegistered(StatusUpdateHandler* handler,
76 const std::string& interface,
77 const std::string& signal_name,
78 bool success);
79
80 void RunStatusUpdateHandler(StatusUpdateHandler* handler,
81 int64_t last_checked_time,
82 double progress,
83 const std::string& current_operation,
84 const std::string& new_version,
85 int64_t new_size);
86
Christopher Wiley16daa082015-10-01 17:18:40 -070087 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl);
88}; // class UpdateEngineClientImpl
89
90} // namespace internal
91} // namespace update_engine
92
93#endif // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_IMPL_H_