| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2015 The Android Open Source Project | 
|  | 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 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 17 | #include "update_engine/aosp/binder_service_android.h" | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 18 |  | 
| Yifan Hong | 40bb0d0 | 2020-02-24 17:33:14 -0800 | [diff] [blame] | 19 | #include <memory> | 
|  | 20 |  | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 21 | #include <base/bind.h> | 
|  | 22 | #include <base/logging.h> | 
|  | 23 | #include <binderwrapper/binder_wrapper.h> | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 24 | #include <utils/String8.h> | 
|  | 25 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 26 | #include "update_engine/aosp/binder_service_android_common.h" | 
| Yifan Hong | 2562cf2 | 2020-07-21 19:28:44 -0700 | [diff] [blame] | 27 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 28 | using android::binder::Status; | 
|  | 29 | using android::os::IUpdateEngineCallback; | 
| Kyeongkab.Nam | 4213299 | 2019-10-03 18:04:02 +0900 | [diff] [blame] | 30 | using android::os::ParcelFileDescriptor; | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 31 | using std::string; | 
|  | 32 | using std::vector; | 
| Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 33 | using update_engine::UpdateEngineStatus; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 34 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 35 | namespace chromeos_update_engine { | 
|  | 36 |  | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 37 | BinderUpdateEngineAndroidService::BinderUpdateEngineAndroidService( | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 38 | ServiceDelegateAndroidInterface* service_delegate) | 
| Amin Hassani | 7cc8bb0 | 2019-01-14 16:29:47 -0800 | [diff] [blame] | 39 | : service_delegate_(service_delegate) {} | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 40 |  | 
|  | 41 | void BinderUpdateEngineAndroidService::SendStatusUpdate( | 
| Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 42 | const UpdateEngineStatus& update_engine_status) { | 
|  | 43 | last_status_ = static_cast<int>(update_engine_status.status); | 
|  | 44 | last_progress_ = update_engine_status.progress; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 45 | for (auto& callback : callbacks_) { | 
| Alex Deymo | 0e061ae | 2016-02-09 17:49:03 -0800 | [diff] [blame] | 46 | callback->onStatusUpdate(last_status_, last_progress_); | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 47 | } | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | void BinderUpdateEngineAndroidService::SendPayloadApplicationComplete( | 
|  | 51 | ErrorCode error_code) { | 
|  | 52 | for (auto& callback : callbacks_) { | 
|  | 53 | callback->onPayloadApplicationComplete(static_cast<int>(error_code)); | 
|  | 54 | } | 
| Alex Deymo | fa78f14 | 2016-01-26 21:36:16 -0800 | [diff] [blame] | 55 | } | 
|  | 56 |  | 
| Alex Deymo | e97b39c | 2016-01-20 13:22:17 -0800 | [diff] [blame] | 57 | Status BinderUpdateEngineAndroidService::bind( | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 58 | const android::sp<IUpdateEngineCallback>& callback, bool* return_value) { | 
| Tianjie Xu | 60f3a23 | 2019-12-11 13:53:39 -0800 | [diff] [blame] | 59 | // Send an status update on connection (except when no update sent so far). | 
|  | 60 | // Even though the status update is oneway, it still returns an erroneous | 
|  | 61 | // status in case of a selinux denial. We should at least check this status | 
|  | 62 | // and fails the binding. | 
|  | 63 | if (last_status_ != -1) { | 
|  | 64 | auto status = callback->onStatusUpdate(last_status_, last_progress_); | 
|  | 65 | if (!status.isOk()) { | 
|  | 66 | LOG(ERROR) << "Failed to call onStatusUpdate() from callback: " | 
|  | 67 | << status.toString8(); | 
|  | 68 | *return_value = false; | 
|  | 69 | return Status::ok(); | 
|  | 70 | } | 
|  | 71 | } | 
|  | 72 |  | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 73 | callbacks_.emplace_back(callback); | 
|  | 74 |  | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 75 | const android::sp<IBinder>& callback_binder = | 
|  | 76 | IUpdateEngineCallback::asBinder(callback); | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 77 | auto binder_wrapper = android::BinderWrapper::Get(); | 
|  | 78 | binder_wrapper->RegisterForDeathNotifications( | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 79 | callback_binder, | 
| Kelvin Zhang | 2f6c25a | 2023-07-05 12:49:34 -0700 | [diff] [blame] | 80 | [this, callback = callback_binder.get()]() { UnbindCallback(callback); }); | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 81 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 82 | *return_value = true; | 
|  | 83 | return Status::ok(); | 
|  | 84 | } | 
|  | 85 |  | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 86 | Status BinderUpdateEngineAndroidService::unbind( | 
|  | 87 | const android::sp<IUpdateEngineCallback>& callback, bool* return_value) { | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 88 | const android::sp<IBinder>& callback_binder = | 
|  | 89 | IUpdateEngineCallback::asBinder(callback); | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 90 | auto binder_wrapper = android::BinderWrapper::Get(); | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 91 | binder_wrapper->UnregisterForDeathNotifications(callback_binder); | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 92 |  | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 93 | *return_value = UnbindCallback(callback_binder.get()); | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 94 | return Status::ok(); | 
|  | 95 | } | 
|  | 96 |  | 
| Alex Deymo | e97b39c | 2016-01-20 13:22:17 -0800 | [diff] [blame] | 97 | Status BinderUpdateEngineAndroidService::applyPayload( | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 98 | const android::String16& url, | 
| Alex Deymo | 95b8f24 | 2016-01-28 16:06:57 -0800 | [diff] [blame] | 99 | int64_t payload_offset, | 
|  | 100 | int64_t payload_size, | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 101 | const vector<android::String16>& header_kv_pairs) { | 
| Tomasz Wasilczyk | 0e78ec2 | 2023-08-11 16:11:15 +0000 | [diff] [blame] | 102 | const string payload_url{android::String8{url}.c_str()}; | 
| Yifan Hong | eec2927 | 2019-12-13 15:02:37 -0800 | [diff] [blame] | 103 | vector<string> str_headers = ToVecString(header_kv_pairs); | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 104 |  | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 105 | Error error; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 106 | if (!service_delegate_->ApplyPayload( | 
|  | 107 | payload_url, payload_offset, payload_size, str_headers, &error)) { | 
|  | 108 | return ErrorPtrToStatus(error); | 
|  | 109 | } | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 110 | return Status::ok(); | 
|  | 111 | } | 
|  | 112 |  | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 113 | Status BinderUpdateEngineAndroidService::applyPayloadFd( | 
| Kyeongkab.Nam | 4213299 | 2019-10-03 18:04:02 +0900 | [diff] [blame] | 114 | const ParcelFileDescriptor& pfd, | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 115 | int64_t payload_offset, | 
|  | 116 | int64_t payload_size, | 
|  | 117 | const vector<android::String16>& header_kv_pairs) { | 
| Yifan Hong | eec2927 | 2019-12-13 15:02:37 -0800 | [diff] [blame] | 118 | vector<string> str_headers = ToVecString(header_kv_pairs); | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 119 |  | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 120 | Error error; | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 121 | if (!service_delegate_->ApplyPayload( | 
| Kyeongkab.Nam | 4213299 | 2019-10-03 18:04:02 +0900 | [diff] [blame] | 122 | pfd.get(), payload_offset, payload_size, str_headers, &error)) { | 
| Kyeongkab.Nam | 500ca13 | 2019-06-26 13:48:07 +0900 | [diff] [blame] | 123 | return ErrorPtrToStatus(error); | 
|  | 124 | } | 
|  | 125 | return Status::ok(); | 
|  | 126 | } | 
|  | 127 |  | 
| Alex Deymo | e97b39c | 2016-01-20 13:22:17 -0800 | [diff] [blame] | 128 | Status BinderUpdateEngineAndroidService::suspend() { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 129 | Error error; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 130 | if (!service_delegate_->SuspendUpdate(&error)) | 
|  | 131 | return ErrorPtrToStatus(error); | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 132 | return Status::ok(); | 
|  | 133 | } | 
|  | 134 |  | 
| Alex Deymo | e97b39c | 2016-01-20 13:22:17 -0800 | [diff] [blame] | 135 | Status BinderUpdateEngineAndroidService::resume() { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 136 | Error error; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 137 | if (!service_delegate_->ResumeUpdate(&error)) | 
|  | 138 | return ErrorPtrToStatus(error); | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 139 | return Status::ok(); | 
|  | 140 | } | 
|  | 141 |  | 
| Alex Deymo | e97b39c | 2016-01-20 13:22:17 -0800 | [diff] [blame] | 142 | Status BinderUpdateEngineAndroidService::cancel() { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 143 | Error error; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 144 | if (!service_delegate_->CancelUpdate(&error)) | 
|  | 145 | return ErrorPtrToStatus(error); | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 146 | return Status::ok(); | 
|  | 147 | } | 
|  | 148 |  | 
| Alex Deymo | 3b678db | 2016-02-09 11:50:06 -0800 | [diff] [blame] | 149 | Status BinderUpdateEngineAndroidService::resetStatus() { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 150 | Error error; | 
| Alex Deymo | 3b678db | 2016-02-09 11:50:06 -0800 | [diff] [blame] | 151 | if (!service_delegate_->ResetStatus(&error)) | 
|  | 152 | return ErrorPtrToStatus(error); | 
|  | 153 | return Status::ok(); | 
|  | 154 | } | 
|  | 155 |  | 
| Tianjie | da607a3 | 2021-05-05 17:38:06 -0700 | [diff] [blame] | 156 | Status BinderUpdateEngineAndroidService::setShouldSwitchSlotOnReboot( | 
|  | 157 | const android::String16& metadata_filename) { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 158 | Error error; | 
| Tianjie | 7f8f2ab | 2021-07-23 17:08:50 -0700 | [diff] [blame] | 159 | if (!service_delegate_->setShouldSwitchSlotOnReboot( | 
| Tomasz Wasilczyk | 0e78ec2 | 2023-08-11 16:11:15 +0000 | [diff] [blame] | 160 | android::String8(metadata_filename).c_str(), &error)) { | 
| Tianjie | 7f8f2ab | 2021-07-23 17:08:50 -0700 | [diff] [blame] | 161 | return ErrorPtrToStatus(error); | 
|  | 162 | } | 
| Tianjie | da607a3 | 2021-05-05 17:38:06 -0700 | [diff] [blame] | 163 | return Status::ok(); | 
|  | 164 | } | 
|  | 165 |  | 
|  | 166 | Status BinderUpdateEngineAndroidService::resetShouldSwitchSlotOnReboot() { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 167 | Error error; | 
| Tianjie | 7f8f2ab | 2021-07-23 17:08:50 -0700 | [diff] [blame] | 168 | if (!service_delegate_->resetShouldSwitchSlotOnReboot(&error)) { | 
|  | 169 | return ErrorPtrToStatus(error); | 
|  | 170 | } | 
| Tianjie | da607a3 | 2021-05-05 17:38:06 -0700 | [diff] [blame] | 171 | return Status::ok(); | 
|  | 172 | } | 
|  | 173 |  | 
| Tao Bao | 20c9672 | 2018-01-09 22:38:57 -0800 | [diff] [blame] | 174 | Status BinderUpdateEngineAndroidService::verifyPayloadApplicable( | 
|  | 175 | const android::String16& metadata_filename, bool* return_value) { | 
|  | 176 | const std::string payload_metadata{ | 
| Tomasz Wasilczyk | 0e78ec2 | 2023-08-11 16:11:15 +0000 | [diff] [blame] | 177 | android::String8{metadata_filename}.c_str()}; | 
| Tao Bao | 20c9672 | 2018-01-09 22:38:57 -0800 | [diff] [blame] | 178 | LOG(INFO) << "Received a request of verifying payload metadata in " | 
|  | 179 | << payload_metadata << "."; | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 180 | Error error; | 
| Sen Jiang | 28d8ed9 | 2018-02-01 13:46:39 -0800 | [diff] [blame] | 181 | *return_value = | 
|  | 182 | service_delegate_->VerifyPayloadApplicable(payload_metadata, &error); | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 183 | if (error.error_code != ErrorCode::kSuccess) | 
| Sen Jiang | 28d8ed9 | 2018-02-01 13:46:39 -0800 | [diff] [blame] | 184 | return ErrorPtrToStatus(error); | 
| Tao Bao | 20c9672 | 2018-01-09 22:38:57 -0800 | [diff] [blame] | 185 | return Status::ok(); | 
|  | 186 | } | 
|  | 187 |  | 
| Sen Jiang | b7f7380 | 2017-07-18 15:29:26 -0700 | [diff] [blame] | 188 | bool BinderUpdateEngineAndroidService::UnbindCallback(const IBinder* callback) { | 
|  | 189 | auto it = std::find_if( | 
|  | 190 | callbacks_.begin(), | 
|  | 191 | callbacks_.end(), | 
|  | 192 | [&callback](const android::sp<IUpdateEngineCallback>& elem) { | 
|  | 193 | return IUpdateEngineCallback::asBinder(elem).get() == callback; | 
|  | 194 | }); | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 195 | if (it == callbacks_.end()) { | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 196 | LOG(ERROR) << "Unable to unbind unknown callback."; | 
|  | 197 | return false; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 198 | } | 
|  | 199 | callbacks_.erase(it); | 
| Sen Jiang | 5caab19 | 2017-07-07 17:22:29 -0700 | [diff] [blame] | 200 | return true; | 
| Alex Deymo | f8bfcff | 2016-02-02 21:22:11 -0800 | [diff] [blame] | 201 | } | 
|  | 202 |  | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 203 | Status BinderUpdateEngineAndroidService::allocateSpaceForPayload( | 
|  | 204 | const android::String16& metadata_filename, | 
|  | 205 | const vector<android::String16>& header_kv_pairs, | 
|  | 206 | int64_t* return_value) { | 
|  | 207 | const std::string payload_metadata{ | 
| Tomasz Wasilczyk | 0e78ec2 | 2023-08-11 16:11:15 +0000 | [diff] [blame] | 208 | android::String8{metadata_filename}.c_str()}; | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 209 | vector<string> str_headers = ToVecString(header_kv_pairs); | 
|  | 210 | LOG(INFO) << "Received a request of allocating space for " << payload_metadata | 
|  | 211 | << "."; | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 212 | Error error; | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 213 | *return_value = | 
|  | 214 | static_cast<int64_t>(service_delegate_->AllocateSpaceForPayload( | 
|  | 215 | payload_metadata, str_headers, &error)); | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 216 | if (error.error_code != ErrorCode::kSuccess) | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 217 | return ErrorPtrToStatus(error); | 
| Yifan Hong | 2236ea0 | 2019-12-13 16:11:22 -0800 | [diff] [blame] | 218 | return Status::ok(); | 
|  | 219 | } | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 220 |  | 
| Yifan Hong | 40bb0d0 | 2020-02-24 17:33:14 -0800 | [diff] [blame] | 221 | class CleanupSuccessfulUpdateCallback | 
|  | 222 | : public CleanupSuccessfulUpdateCallbackInterface { | 
|  | 223 | public: | 
|  | 224 | CleanupSuccessfulUpdateCallback( | 
|  | 225 | const android::sp<IUpdateEngineCallback>& callback) | 
|  | 226 | : callback_(callback) {} | 
|  | 227 | void OnCleanupComplete(int32_t error_code) { | 
|  | 228 | ignore_result(callback_->onPayloadApplicationComplete(error_code)); | 
|  | 229 | } | 
|  | 230 | void OnCleanupProgressUpdate(double progress) { | 
|  | 231 | ignore_result(callback_->onStatusUpdate( | 
|  | 232 | static_cast<int32_t>( | 
|  | 233 | update_engine::UpdateStatus::CLEANUP_PREVIOUS_UPDATE), | 
|  | 234 | progress)); | 
|  | 235 | } | 
| Kelvin Zhang | 2f6c25a | 2023-07-05 12:49:34 -0700 | [diff] [blame] | 236 | void RegisterForDeathNotifications(const std::function<void()>& unbind) { | 
| Yifan Hong | 40bb0d0 | 2020-02-24 17:33:14 -0800 | [diff] [blame] | 237 | const android::sp<android::IBinder>& callback_binder = | 
|  | 238 | IUpdateEngineCallback::asBinder(callback_); | 
|  | 239 | auto binder_wrapper = android::BinderWrapper::Get(); | 
|  | 240 | binder_wrapper->RegisterForDeathNotifications(callback_binder, unbind); | 
|  | 241 | } | 
|  | 242 |  | 
|  | 243 | private: | 
|  | 244 | android::sp<IUpdateEngineCallback> callback_; | 
|  | 245 | }; | 
|  | 246 |  | 
| Yifan Hong | 2236ea0 | 2019-12-13 16:11:22 -0800 | [diff] [blame] | 247 | Status BinderUpdateEngineAndroidService::cleanupSuccessfulUpdate( | 
| Yifan Hong | 40bb0d0 | 2020-02-24 17:33:14 -0800 | [diff] [blame] | 248 | const android::sp<IUpdateEngineCallback>& callback) { | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 249 | Error error; | 
| Yifan Hong | 40bb0d0 | 2020-02-24 17:33:14 -0800 | [diff] [blame] | 250 | service_delegate_->CleanupSuccessfulUpdate( | 
|  | 251 | std::make_unique<CleanupSuccessfulUpdateCallback>(callback), &error); | 
| Daniel Zheng | 92f7d17 | 2023-06-22 14:31:37 -0700 | [diff] [blame] | 252 | if (error.error_code != ErrorCode::kSuccess) | 
| Yifan Hong | 2236ea0 | 2019-12-13 16:11:22 -0800 | [diff] [blame] | 253 | return ErrorPtrToStatus(error); | 
| Yifan Hong | 6f7e29f | 2019-12-13 14:41:06 -0800 | [diff] [blame] | 254 | return Status::ok(); | 
|  | 255 | } | 
|  | 256 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 257 | }  // namespace chromeos_update_engine |