| 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 |  | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_BINDER_SERVICE_BRILLO_H_ | 
|  | 18 | #define UPDATE_ENGINE_BINDER_SERVICE_BRILLO_H_ | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 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 |  | 
| Alex Deymo | 5b5fa8b | 2016-10-06 15:40:49 -0700 | [diff] [blame] | 22 | #include <memory> | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 23 | #include <string> | 
| Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame] | 24 | #include <vector> | 
|  | 25 |  | 
|  | 26 | #include <utils/RefBase.h> | 
|  | 27 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 28 | #include "update_engine/common_service.h" | 
|  | 29 | #include "update_engine/parcelable_update_engine_status.h" | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 30 | #include "update_engine/service_observer_interface.h" | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 31 |  | 
|  | 32 | #include "android/brillo/BnUpdateEngine.h" | 
|  | 33 | #include "android/brillo/IUpdateEngineStatusCallback.h" | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 34 |  | 
|  | 35 | namespace chromeos_update_engine { | 
|  | 36 |  | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 37 | class BinderUpdateEngineBrilloService : public android::brillo::BnUpdateEngine, | 
|  | 38 | public ServiceObserverInterface { | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 39 | public: | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 40 | explicit BinderUpdateEngineBrilloService(SystemState* system_state) | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 41 | : common_(new UpdateEngineService(system_state)) {} | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 42 | virtual ~BinderUpdateEngineBrilloService() = default; | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 43 |  | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 44 | const char* ServiceName() const { | 
|  | 45 | return "android.brillo.UpdateEngineService"; | 
|  | 46 | } | 
|  | 47 |  | 
|  | 48 | // ServiceObserverInterface overrides. | 
| Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 49 | void SendStatusUpdate( | 
|  | 50 | const update_engine::UpdateEngineStatus& update_engine_status) override; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 51 | void SendPayloadApplicationComplete(ErrorCode error_code) override {} | 
| Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame] | 52 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 53 | // android::brillo::BnUpdateEngine overrides. | 
|  | 54 | android::binder::Status AttemptUpdate(const android::String16& app_version, | 
|  | 55 | const android::String16& omaha_url, | 
|  | 56 | int flags) override; | 
|  | 57 | android::binder::Status AttemptRollback(bool powerwash) override; | 
|  | 58 | android::binder::Status CanRollback(bool* out_can_rollback) override; | 
|  | 59 | android::binder::Status ResetStatus() override; | 
|  | 60 | android::binder::Status GetStatus( | 
|  | 61 | android::brillo::ParcelableUpdateEngineStatus* status); | 
|  | 62 | android::binder::Status RebootIfNeeded() override; | 
|  | 63 | android::binder::Status SetChannel(const android::String16& target_channel, | 
|  | 64 | bool powerwash) override; | 
|  | 65 | android::binder::Status GetChannel(bool get_current_channel, | 
|  | 66 | android::String16* out_channel) override; | 
| Alex Deymo | 5b5fa8b | 2016-10-06 15:40:49 -0700 | [diff] [blame] | 67 | android::binder::Status SetCohortHint( | 
|  | 68 | const android::String16& cohort_hint) override; | 
|  | 69 | android::binder::Status GetCohortHint( | 
|  | 70 | android::String16* out_cohort_hint) override; | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 71 | android::binder::Status SetP2PUpdatePermission(bool enabled) override; | 
|  | 72 | android::binder::Status GetP2PUpdatePermission( | 
|  | 73 | bool* out_p2p_permission) override; | 
|  | 74 | android::binder::Status SetUpdateOverCellularPermission( | 
|  | 75 | bool enabled) override; | 
|  | 76 | android::binder::Status GetUpdateOverCellularPermission( | 
|  | 77 | bool* out_cellular_permission) override; | 
|  | 78 | android::binder::Status GetDurationSinceUpdate( | 
|  | 79 | int64_t* out_duration) override; | 
|  | 80 | android::binder::Status GetPrevVersion( | 
|  | 81 | android::String16* out_prev_version) override; | 
|  | 82 | android::binder::Status GetRollbackPartition( | 
|  | 83 | android::String16* out_rollback_partition) override; | 
|  | 84 | android::binder::Status RegisterStatusCallback( | 
|  | 85 | const android::sp<android::brillo::IUpdateEngineStatusCallback>& callback) | 
|  | 86 | override; | 
| Shuqian Zhao | 2997173 | 2016-02-05 11:29:32 -0800 | [diff] [blame] | 87 | android::binder::Status GetLastAttemptError( | 
|  | 88 | int* out_last_attempt_error) override; | 
| Alex Deymo | b3fa53b | 2016-04-18 19:57:58 -0700 | [diff] [blame] | 89 | android::binder::Status GetEolStatus(int* out_eol_status) override; | 
| Tao Bao | e78e3fb | 2016-01-04 17:57:53 -0800 | [diff] [blame] | 90 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 91 | private: | 
| Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame] | 92 | // Generic function for dispatching to the common service. | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 93 | template <typename... Parameters, typename... Arguments> | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 94 | android::binder::Status CallCommonHandler( | 
|  | 95 | bool (UpdateEngineService::*Handler)(brillo::ErrorPtr*, Parameters...), | 
|  | 96 | Arguments... arguments); | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 97 |  | 
| Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame] | 98 | // To be used as a death notification handler only. | 
|  | 99 | void UnregisterStatusCallback( | 
|  | 100 | android::brillo::IUpdateEngineStatusCallback* callback); | 
|  | 101 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 102 | std::unique_ptr<UpdateEngineService> common_; | 
| Casey Dahlin | 4089249 | 2016-01-25 16:55:28 -0800 | [diff] [blame] | 103 |  | 
|  | 104 | std::vector<android::sp<android::brillo::IUpdateEngineStatusCallback>> | 
|  | 105 | callbacks_; | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 106 | }; | 
| Christopher Wiley | 9e1eda9 | 2015-11-16 15:23:37 -0800 | [diff] [blame] | 107 |  | 
|  | 108 | }  // namespace chromeos_update_engine | 
|  | 109 |  | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 110 | #endif  // UPDATE_ENGINE_BINDER_SERVICE_BRILLO_H_ |