Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2016 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 | |
| 17 | #include "update_engine/parcelable_update_engine_status.h" |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 18 | #include "update_engine/update_status_utils.h" |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 19 | |
| 20 | #include <binder/Parcel.h> |
| 21 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 22 | using update_engine::UpdateEngineStatus; |
| 23 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace brillo { |
| 26 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 27 | ParcelableUpdateEngineStatus::ParcelableUpdateEngineStatus( |
| 28 | const UpdateEngineStatus& status) |
| 29 | : last_checked_time_(status.last_checked_time_ms), |
| 30 | current_operation_( |
| 31 | chromeos_update_engine::UpdateStatusToString(status.status)), |
| 32 | progress_(status.progress), |
| 33 | current_version_(String16{status.current_version.c_str()}), |
| 34 | current_system_version_(String16{status.current_system_version.c_str()}), |
| 35 | new_size_(status.new_size_bytes), |
| 36 | new_version_(String16{status.new_version.c_str()}), |
| 37 | new_system_version_(String16{status.new_system_version.c_str()}) {} |
| 38 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 39 | status_t ParcelableUpdateEngineStatus::writeToParcel(Parcel* parcel) const { |
| 40 | status_t status; |
| 41 | |
| 42 | status = parcel->writeInt64(last_checked_time_); |
| 43 | if (status != OK) { |
| 44 | return status; |
| 45 | } |
| 46 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 47 | status = parcel->writeString16(current_operation_); |
| 48 | if (status != OK) { |
| 49 | return status; |
| 50 | } |
| 51 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 52 | status = parcel->writeDouble(progress_); |
| 53 | if (status != OK) { |
| 54 | return status; |
| 55 | } |
| 56 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 57 | status = parcel->writeString16(current_version_); |
| 58 | if (status != OK) { |
| 59 | return status; |
| 60 | } |
| 61 | |
| 62 | status = parcel->writeString16(current_system_version_); |
| 63 | if (status != OK) { |
| 64 | return status; |
| 65 | } |
| 66 | |
| 67 | status = parcel->writeInt64(new_size_); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 68 | if (status != OK) { |
| 69 | return status; |
| 70 | } |
| 71 | |
| 72 | status = parcel->writeString16(new_version_); |
| 73 | if (status != OK) { |
| 74 | return status; |
| 75 | } |
| 76 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 77 | return parcel->writeString16(new_system_version_); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | status_t ParcelableUpdateEngineStatus::readFromParcel(const Parcel* parcel) { |
| 81 | status_t status; |
| 82 | |
| 83 | status = parcel->readInt64(&last_checked_time_); |
| 84 | if (status != OK) { |
| 85 | return status; |
| 86 | } |
| 87 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 88 | status = parcel->readString16(¤t_operation_); |
| 89 | if (status != OK) { |
| 90 | return status; |
| 91 | } |
| 92 | |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 93 | status = parcel->readDouble(&progress_); |
| 94 | if (status != OK) { |
| 95 | return status; |
| 96 | } |
| 97 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 98 | status = parcel->readString16(¤t_version_); |
| 99 | if (status != OK) { |
| 100 | return status; |
| 101 | } |
| 102 | |
| 103 | status = parcel->readString16(¤t_system_version_); |
| 104 | if (status != OK) { |
| 105 | return status; |
| 106 | } |
| 107 | |
| 108 | status = parcel->readInt64(&new_size_); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 109 | if (status != OK) { |
| 110 | return status; |
| 111 | } |
| 112 | |
| 113 | status = parcel->readString16(&new_version_); |
| 114 | if (status != OK) { |
| 115 | return status; |
| 116 | } |
| 117 | |
Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame^] | 118 | return parcel->readString16(&new_system_version_); |
Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | } // namespace brillo |
| 122 | } // namespace android |