| 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" | 
 | 18 |  | 
 | 19 | #include <binder/Parcel.h> | 
 | 20 |  | 
 | 21 | namespace android { | 
 | 22 | namespace brillo { | 
 | 23 |  | 
 | 24 | status_t ParcelableUpdateEngineStatus::writeToParcel(Parcel* parcel) const { | 
 | 25 |   status_t status; | 
 | 26 |  | 
 | 27 |   status = parcel->writeInt64(last_checked_time_); | 
 | 28 |   if (status != OK) { | 
 | 29 |     return status; | 
 | 30 |   } | 
 | 31 |  | 
 | 32 |   status = parcel->writeDouble(progress_); | 
 | 33 |   if (status != OK) { | 
 | 34 |     return status; | 
 | 35 |   } | 
 | 36 |  | 
 | 37 |   status = parcel->writeString16(current_operation_); | 
 | 38 |   if (status != OK) { | 
 | 39 |     return status; | 
 | 40 |   } | 
 | 41 |  | 
 | 42 |   status = parcel->writeString16(new_version_); | 
 | 43 |   if (status != OK) { | 
 | 44 |     return status; | 
 | 45 |   } | 
 | 46 |  | 
 | 47 |   return parcel->writeInt64(new_size_); | 
 | 48 | } | 
 | 49 |  | 
 | 50 | status_t ParcelableUpdateEngineStatus::readFromParcel(const Parcel* parcel) { | 
 | 51 |   status_t status; | 
 | 52 |  | 
 | 53 |   status = parcel->readInt64(&last_checked_time_); | 
 | 54 |   if (status != OK) { | 
 | 55 |     return status; | 
 | 56 |   } | 
 | 57 |  | 
 | 58 |   status = parcel->readDouble(&progress_); | 
 | 59 |   if (status != OK) { | 
 | 60 |     return status; | 
 | 61 |   } | 
 | 62 |  | 
 | 63 |   status = parcel->readString16(¤t_operation_); | 
 | 64 |   if (status != OK) { | 
 | 65 |     return status; | 
 | 66 |   } | 
 | 67 |  | 
 | 68 |   status = parcel->readString16(&new_version_); | 
 | 69 |   if (status != OK) { | 
 | 70 |     return status; | 
 | 71 |   } | 
 | 72 |  | 
 | 73 |   return parcel->readInt64(&new_size_); | 
 | 74 | } | 
 | 75 |  | 
 | 76 | }  // namespace brillo | 
 | 77 | }  // namespace android |