blob: ddbd147fac96a007b1566c00d96989243545f3fa [file] [log] [blame]
Christopher Wiley9e1eda92015-11-16 15:23:37 -08001//
Casey Dahlina93cd532016-01-14 16:55:11 -08002// Copyright (C) 2016 The Android Open Source Project
Christopher Wiley9e1eda92015-11-16 15:23:37 -08003//
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_BINDER_SERVICE_H_
18#define UPDATE_ENGINE_BINDER_SERVICE_H_
19
Christopher Wiley9e1eda92015-11-16 15:23:37 -080020#include <utils/Errors.h>
Christopher Wiley9e1eda92015-11-16 15:23:37 -080021
Casey Dahlina93cd532016-01-14 16:55:11 -080022#include "update_engine/common_service.h"
23#include "update_engine/parcelable_update_engine_status.h"
24
25#include "android/brillo/BnUpdateEngine.h"
26#include "android/brillo/IUpdateEngineStatusCallback.h"
Christopher Wiley9e1eda92015-11-16 15:23:37 -080027
28namespace chromeos_update_engine {
29
Casey Dahlina93cd532016-01-14 16:55:11 -080030class BinderUpdateEngineService : public android::brillo::BnUpdateEngine {
Christopher Wiley9e1eda92015-11-16 15:23:37 -080031 public:
Casey Dahlina93cd532016-01-14 16:55:11 -080032 BinderUpdateEngineService(SystemState* system_state)
33 : common_(new UpdateEngineService(system_state)) {}
34 virtual ~BinderUpdateEngineService() = default;
Christopher Wiley9e1eda92015-11-16 15:23:37 -080035
Casey Dahlina93cd532016-01-14 16:55:11 -080036 // android::brillo::BnUpdateEngine overrides.
37 android::binder::Status AttemptUpdate(const android::String16& app_version,
38 const android::String16& omaha_url,
39 int flags) override;
40 android::binder::Status AttemptRollback(bool powerwash) override;
41 android::binder::Status CanRollback(bool* out_can_rollback) override;
42 android::binder::Status ResetStatus() override;
43 android::binder::Status GetStatus(
44 android::brillo::ParcelableUpdateEngineStatus* status);
45 android::binder::Status RebootIfNeeded() override;
46 android::binder::Status SetChannel(const android::String16& target_channel,
47 bool powerwash) override;
48 android::binder::Status GetChannel(bool get_current_channel,
49 android::String16* out_channel) override;
50 android::binder::Status SetP2PUpdatePermission(bool enabled) override;
51 android::binder::Status GetP2PUpdatePermission(
52 bool* out_p2p_permission) override;
53 android::binder::Status SetUpdateOverCellularPermission(
54 bool enabled) override;
55 android::binder::Status GetUpdateOverCellularPermission(
56 bool* out_cellular_permission) override;
57 android::binder::Status GetDurationSinceUpdate(
58 int64_t* out_duration) override;
59 android::binder::Status GetPrevVersion(
60 android::String16* out_prev_version) override;
61 android::binder::Status GetRollbackPartition(
62 android::String16* out_rollback_partition) override;
63 android::binder::Status RegisterStatusCallback(
64 const android::sp<android::brillo::IUpdateEngineStatusCallback>& callback)
65 override;
Tao Baoe78e3fb2016-01-04 17:57:53 -080066
Casey Dahlina93cd532016-01-14 16:55:11 -080067 private:
68 template<typename... Parameters, typename... Arguments>
69 android::binder::Status CallCommonHandler(
70 bool (UpdateEngineService::*Handler)(brillo::ErrorPtr*, Parameters...),
71 Arguments... arguments);
Christopher Wiley9e1eda92015-11-16 15:23:37 -080072
Casey Dahlina93cd532016-01-14 16:55:11 -080073 std::unique_ptr<UpdateEngineService> common_;
Christopher Wiley9e1eda92015-11-16 15:23:37 -080074}; // class BinderService
75
76} // namespace chromeos_update_engine
77
78#endif // UPDATE_ENGINE_BINDER_SERVICE_H_