blob: cfd5395fd6af06f4b227111edd338fe2a01c13f3 [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:
Casey Dahlin19441412016-01-07 14:56:40 -080034 explicit UpdateEngineClientImpl() = default;
35 bool Init();
36
Christopher Wiley16daa082015-10-01 17:18:40 -070037 virtual ~UpdateEngineClientImpl() = default;
38
39 bool AttemptUpdate(const std::string& app_version,
40 const std::string& omaha_url,
41 bool at_user_request) override;
42
43 bool GetStatus(int64_t* out_last_checked_time,
44 double* out_progress,
45 UpdateStatus* out_update_status,
46 std::string* out_new_version,
Casey Dahlin19441412016-01-07 14:56:40 -080047 int64_t* out_new_size) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070048
Casey Dahlinef361132015-12-17 13:02:37 -080049 bool SetUpdateOverCellularPermission(bool allowed) override;
Casey Dahlin19441412016-01-07 14:56:40 -080050 bool GetUpdateOverCellularPermission(bool* allowed) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080051
52 bool SetP2PUpdatePermission(bool enabled) override;
Casey Dahlin19441412016-01-07 14:56:40 -080053 bool GetP2PUpdatePermission(bool* enabled) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080054
55 bool Rollback(bool powerwash) override;
56
Casey Dahlin19441412016-01-07 14:56:40 -080057 bool GetRollbackPartition(std::string* rollback_partition) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080058
59 void RebootIfNeeded() override;
60
Casey Dahlin19441412016-01-07 14:56:40 -080061 bool GetPrevVersion(std::string* prev_version) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080062
Casey Dahline844c1a2015-12-16 14:30:58 -080063 bool ResetStatus() override;
64
Casey Dahlin87ab88e2015-12-16 17:58:05 -080065 bool SetTargetChannel(const std::string& target_channel,
66 bool allow_powerwash) override;
Christopher Wiley16daa082015-10-01 17:18:40 -070067
Casey Dahlin19441412016-01-07 14:56:40 -080068 bool GetTargetChannel(std::string* out_channel) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070069
Casey Dahlin19441412016-01-07 14:56:40 -080070 bool GetChannel(std::string* out_channel) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070071
Casey Dahlin97c87052016-01-06 14:33:55 -080072 void RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
73
Christopher Wiley16daa082015-10-01 17:18:40 -070074 private:
75 std::unique_ptr<org::chromium::UpdateEngineInterfaceProxy> proxy_;
76
Casey Dahlin97c87052016-01-06 14:33:55 -080077 void StatusUpdateHandlerRegistered(StatusUpdateHandler* handler,
78 const std::string& interface,
79 const std::string& signal_name,
Casey Dahlin19441412016-01-07 14:56:40 -080080 bool success) const;
Casey Dahlin97c87052016-01-06 14:33:55 -080081
82 void RunStatusUpdateHandler(StatusUpdateHandler* handler,
83 int64_t last_checked_time,
84 double progress,
85 const std::string& current_operation,
86 const std::string& new_version,
87 int64_t new_size);
88
Christopher Wiley16daa082015-10-01 17:18:40 -070089 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl);
90}; // class UpdateEngineClientImpl
91
92} // namespace internal
93} // namespace update_engine
94
95#endif // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_IMPL_H_