116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// 216daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// Copyright (C) 2015 The Android Open Source Project 316daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// 416daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// Licensed under the Apache License, Version 2.0 (the "License"); 516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// you may not use this file except in compliance with the License. 616daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// You may obtain a copy of the License at 716daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// 816daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// http://www.apache.org/licenses/LICENSE-2.0 916daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// 1016daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// Unless required by applicable law or agreed to in writing, software 1116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// distributed under the License is distributed on an "AS IS" BASIS, 1216daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1316daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// See the License for the specific language governing permissions and 1416daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// limitations under the License. 1516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley// 1616daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 17a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#ifndef UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_DBUS_H_ 18a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#define UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_DBUS_H_ 1916daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 2016daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley#include <cstdint> 2116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley#include <memory> 2216daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley#include <string> 23a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin#include <vector> 2416daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 2516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley#include <base/macros.h> 2616daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 2716daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley#include "update_engine/client_library/include/update_engine/client.h" 2839910dcd1d68987ccee7c3031dc269233a8490bbAlex Deymo#include "update_engine/dbus-proxies.h" 2916daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 3016daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wileynamespace update_engine { 3116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wileynamespace internal { 3216daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 33a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlinclass DBusUpdateEngineClient : public UpdateEngineClient { 3416daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley public: 35a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin DBusUpdateEngineClient() = default; 36194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool Init(); 37194414134a954d921c8063610304c4fd21f19df2Casey Dahlin 38a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin virtual ~DBusUpdateEngineClient() = default; 3916daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 4016daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley bool AttemptUpdate(const std::string& app_version, 4116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley const std::string& omaha_url, 4216daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley bool at_user_request) override; 4316daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 4416daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley bool GetStatus(int64_t* out_last_checked_time, 4516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley double* out_progress, 4616daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley UpdateStatus* out_update_status, 4716daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley std::string* out_new_version, 48194414134a954d921c8063610304c4fd21f19df2Casey Dahlin int64_t* out_new_size) const override; 4916daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 505b5fa8b412312a41cfd4d7ab475b54d4f730ed2aAlex Deymo bool SetCohortHint(const std::string& cohort_hint) override; 515b5fa8b412312a41cfd4d7ab475b54d4f730ed2aAlex Deymo bool GetCohortHint(std::string* cohort_hint) const override; 525b5fa8b412312a41cfd4d7ab475b54d4f730ed2aAlex Deymo 53ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin bool SetUpdateOverCellularPermission(bool allowed) override; 54194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetUpdateOverCellularPermission(bool* allowed) const override; 55ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 56ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin bool SetP2PUpdatePermission(bool enabled) override; 57194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetP2PUpdatePermission(bool* enabled) const override; 58ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 59ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin bool Rollback(bool powerwash) override; 60ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 61194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetRollbackPartition(std::string* rollback_partition) const override; 62ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 63ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin void RebootIfNeeded() override; 64ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 65194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetPrevVersion(std::string* prev_version) const override; 66ef361136cea1e423dc462d2b347923ae60b2cf08Casey Dahlin 67e844c1a5604765bbddafa7e05f1143a27f136747Casey Dahlin bool ResetStatus() override; 68e844c1a5604765bbddafa7e05f1143a27f136747Casey Dahlin 6987ab88e35fac5d3ded1c70c8911d307ec47a7db9Casey Dahlin bool SetTargetChannel(const std::string& target_channel, 7087ab88e35fac5d3ded1c70c8911d307ec47a7db9Casey Dahlin bool allow_powerwash) override; 7116daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 72194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetTargetChannel(std::string* out_channel) const override; 7316daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 74194414134a954d921c8063610304c4fd21f19df2Casey Dahlin bool GetChannel(std::string* out_channel) const override; 7516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 7640892497a9b1ea124058baf09f5f2873a15cb696Casey Dahlin bool RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override; 77a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) override; 7897c870518ce1149b32966d98ebfe93f3eb5d1fefCasey Dahlin 792997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao bool GetLastAttemptError(int32_t* last_attempt_error) const override; 802997173235e88c5e4cb13d2844f74afc7b25d6e2Shuqian Zhao 81b3fa53bf760bd0a6fd1ef9df28cb425586d733f6Alex Deymo bool GetEolStatus(int32_t* eol_status) const override; 82b3fa53bf760bd0a6fd1ef9df28cb425586d733f6Alex Deymo 8316daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley private: 84492eaf5067c88db3477538d935ffb0a0ec0c1936Alex Deymo void DBusStatusHandlersRegistered(const std::string& interface, 85a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin const std::string& signal_name, 86a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin bool success) const; 87a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin 88a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin // Send an initial event to new StatusUpdateHandlers. If the handler argument 89a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin // is not nullptr, only that handler receives the event. Otherwise all 90a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin // registered handlers receive the event. 91a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin void StatusUpdateHandlersRegistered(StatusUpdateHandler* handler) const; 92a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin 93a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin void RunStatusUpdateHandlers(int64_t last_checked_time, 94a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin double progress, 95a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin const std::string& current_operation, 96a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin const std::string& new_version, 97a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin int64_t new_size); 98a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin 99492eaf5067c88db3477538d935ffb0a0ec0c1936Alex Deymo std::unique_ptr<org::chromium::UpdateEngineInterfaceProxy> proxy_; 100a715f7b8a211b5c4b74206539e9aa7ddacf4b243Casey Dahlin std::vector<update_engine::StatusUpdateHandler*> handlers_; 101492eaf5067c88db3477538d935ffb0a0ec0c1936Alex Deymo bool dbus_handler_registered_{false}; 10297c870518ce1149b32966d98ebfe93f3eb5d1fefCasey Dahlin 103a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin DISALLOW_COPY_AND_ASSIGN(DBusUpdateEngineClient); 104a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin}; // class DBusUpdateEngineClient 10516daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 10616daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley} // namespace internal 10716daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley} // namespace update_engine 10816daa08470beb5021b85618f1b3ee214d89e59a1Christopher Wiley 109a93cd53c4f8ab8cb926ed9223373567ebbf45cb6Casey Dahlin#endif // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_DBUS_H_ 110