blob: 22d1cf0cfb9a71437415e4a273c17e872540d8b6 [file] [log] [blame]
Christopher Wiley16daa082015-10-01 17:18:40 -07001//
Casey Dahlina93cd532016-01-14 16:55:11 -08002// Copyright (C) 2016 The Android Open Source Project
Christopher Wiley16daa082015-10-01 17:18:40 -07003//
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
Casey Dahlina93cd532016-01-14 16:55:11 -080017#ifndef UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_
18#define UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_
Christopher Wiley16daa082015-10-01 17:18:40 -070019
20#include <cstdint>
21#include <memory>
22#include <string>
23
24#include <base/macros.h>
Casey Dahlina93cd532016-01-14 16:55:11 -080025#include <utils/StrongPointer.h>
26
27#include "android/brillo/IUpdateEngine.h"
Christopher Wiley16daa082015-10-01 17:18:40 -070028
Christopher Wiley16daa082015-10-01 17:18:40 -070029#include "update_engine/client_library/include/update_engine/client.h"
Christopher Wiley16daa082015-10-01 17:18:40 -070030
31namespace update_engine {
32namespace internal {
33
Casey Dahlina93cd532016-01-14 16:55:11 -080034class BinderUpdateEngineClient : public UpdateEngineClient {
Christopher Wiley16daa082015-10-01 17:18:40 -070035 public:
Casey Dahlina93cd532016-01-14 16:55:11 -080036 BinderUpdateEngineClient() = default;
Casey Dahlin19441412016-01-07 14:56:40 -080037 bool Init();
38
Casey Dahlina93cd532016-01-14 16:55:11 -080039 virtual ~BinderUpdateEngineClient() = default;
Christopher Wiley16daa082015-10-01 17:18:40 -070040
41 bool AttemptUpdate(const std::string& app_version,
42 const std::string& omaha_url,
43 bool at_user_request) override;
44
45 bool GetStatus(int64_t* out_last_checked_time,
46 double* out_progress,
47 UpdateStatus* out_update_status,
48 std::string* out_new_version,
Casey Dahlin19441412016-01-07 14:56:40 -080049 int64_t* out_new_size) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070050
Casey Dahlinef361132015-12-17 13:02:37 -080051 bool SetUpdateOverCellularPermission(bool allowed) override;
Casey Dahlin19441412016-01-07 14:56:40 -080052 bool GetUpdateOverCellularPermission(bool* allowed) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080053
54 bool SetP2PUpdatePermission(bool enabled) override;
Casey Dahlin19441412016-01-07 14:56:40 -080055 bool GetP2PUpdatePermission(bool* enabled) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080056
57 bool Rollback(bool powerwash) override;
58
Casey Dahlin19441412016-01-07 14:56:40 -080059 bool GetRollbackPartition(std::string* rollback_partition) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080060
61 void RebootIfNeeded() override;
62
Casey Dahlin19441412016-01-07 14:56:40 -080063 bool GetPrevVersion(std::string* prev_version) const override;
Casey Dahlinef361132015-12-17 13:02:37 -080064
Casey Dahline844c1a2015-12-16 14:30:58 -080065 bool ResetStatus() override;
66
Casey Dahlin87ab88e2015-12-16 17:58:05 -080067 bool SetTargetChannel(const std::string& target_channel,
68 bool allow_powerwash) override;
Christopher Wiley16daa082015-10-01 17:18:40 -070069
Casey Dahlin19441412016-01-07 14:56:40 -080070 bool GetTargetChannel(std::string* out_channel) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070071
Casey Dahlin19441412016-01-07 14:56:40 -080072 bool GetChannel(std::string* out_channel) const override;
Christopher Wiley16daa082015-10-01 17:18:40 -070073
Casey Dahlin97c87052016-01-06 14:33:55 -080074 void RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override;
75
Christopher Wiley16daa082015-10-01 17:18:40 -070076 private:
Casey Dahlina93cd532016-01-14 16:55:11 -080077 android::sp<android::brillo::IUpdateEngine> service_;
Christopher Wiley16daa082015-10-01 17:18:40 -070078
Casey Dahlina93cd532016-01-14 16:55:11 -080079 DISALLOW_COPY_AND_ASSIGN(BinderUpdateEngineClient);
80}; // class BinderUpdateEngineClient
Christopher Wiley16daa082015-10-01 17:18:40 -070081
82} // namespace internal
83} // namespace update_engine
84
Casey Dahlina93cd532016-01-14 16:55:11 -080085#endif // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_