Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 1 | // |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 2 | // Copyright (C) 2016 The Android Open Source Project |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 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_BINDER_SERVICE_H_ |
| 18 | #define UPDATE_ENGINE_BINDER_SERVICE_H_ |
| 19 | |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 20 | #include <utils/Errors.h> |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 21 | |
Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame^] | 22 | #include <vector> |
| 23 | |
| 24 | #include <utils/RefBase.h> |
| 25 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 26 | #include "update_engine/common_service.h" |
| 27 | #include "update_engine/parcelable_update_engine_status.h" |
| 28 | |
| 29 | #include "android/brillo/BnUpdateEngine.h" |
| 30 | #include "android/brillo/IUpdateEngineStatusCallback.h" |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 31 | |
| 32 | namespace chromeos_update_engine { |
| 33 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 34 | class BinderUpdateEngineService : public android::brillo::BnUpdateEngine { |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 35 | public: |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 36 | BinderUpdateEngineService(SystemState* system_state) |
| 37 | : common_(new UpdateEngineService(system_state)) {} |
| 38 | virtual ~BinderUpdateEngineService() = default; |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 39 | |
Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame^] | 40 | void SendStatusUpdate(int64_t in_last_checked_time, double in_progress, |
| 41 | const std::string& in_current_operation, |
| 42 | const std::string& in_new_version, int64_t in_new_size); |
| 43 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 44 | // android::brillo::BnUpdateEngine overrides. |
| 45 | android::binder::Status AttemptUpdate(const android::String16& app_version, |
| 46 | const android::String16& omaha_url, |
| 47 | int flags) override; |
| 48 | android::binder::Status AttemptRollback(bool powerwash) override; |
| 49 | android::binder::Status CanRollback(bool* out_can_rollback) override; |
| 50 | android::binder::Status ResetStatus() override; |
| 51 | android::binder::Status GetStatus( |
| 52 | android::brillo::ParcelableUpdateEngineStatus* status); |
| 53 | android::binder::Status RebootIfNeeded() override; |
| 54 | android::binder::Status SetChannel(const android::String16& target_channel, |
| 55 | bool powerwash) override; |
| 56 | android::binder::Status GetChannel(bool get_current_channel, |
| 57 | android::String16* out_channel) override; |
| 58 | android::binder::Status SetP2PUpdatePermission(bool enabled) override; |
| 59 | android::binder::Status GetP2PUpdatePermission( |
| 60 | bool* out_p2p_permission) override; |
| 61 | android::binder::Status SetUpdateOverCellularPermission( |
| 62 | bool enabled) override; |
| 63 | android::binder::Status GetUpdateOverCellularPermission( |
| 64 | bool* out_cellular_permission) override; |
| 65 | android::binder::Status GetDurationSinceUpdate( |
| 66 | int64_t* out_duration) override; |
| 67 | android::binder::Status GetPrevVersion( |
| 68 | android::String16* out_prev_version) override; |
| 69 | android::binder::Status GetRollbackPartition( |
| 70 | android::String16* out_rollback_partition) override; |
| 71 | android::binder::Status RegisterStatusCallback( |
| 72 | const android::sp<android::brillo::IUpdateEngineStatusCallback>& callback) |
| 73 | override; |
Tao Bao | e78e3fb | 2016-01-04 17:57:53 -0800 | [diff] [blame] | 74 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 75 | private: |
Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame^] | 76 | // Generic function for dispatching to the common service. |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 77 | template<typename... Parameters, typename... Arguments> |
| 78 | android::binder::Status CallCommonHandler( |
| 79 | bool (UpdateEngineService::*Handler)(brillo::ErrorPtr*, Parameters...), |
| 80 | Arguments... arguments); |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 81 | |
Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame^] | 82 | // To be used as a death notification handler only. |
| 83 | void UnregisterStatusCallback( |
| 84 | android::brillo::IUpdateEngineStatusCallback* callback); |
| 85 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 86 | std::unique_ptr<UpdateEngineService> common_; |
Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame^] | 87 | |
| 88 | std::vector<android::sp<android::brillo::IUpdateEngineStatusCallback>> |
| 89 | callbacks_; |
Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 90 | }; // class BinderService |
| 91 | |
| 92 | } // namespace chromeos_update_engine |
| 93 | |
| 94 | #endif // UPDATE_ENGINE_BINDER_SERVICE_H_ |