Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 <stdint.h> |
| 18 | #include <sys/types.h> |
| 19 | #include <batteryservice/BatteryService.h> |
| 20 | #include <binder/Parcel.h> |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/String8.h> |
| 23 | #include <utils/String16.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | /* |
| 28 | * Parcel read/write code must be kept in sync with |
| 29 | * frameworks/base/core/java/android/os/BatteryProperties.java |
| 30 | */ |
| 31 | |
| 32 | status_t BatteryProperties::readFromParcel(Parcel* p) { |
| 33 | chargerAcOnline = p->readInt32() == 1 ? true : false; |
| 34 | chargerUsbOnline = p->readInt32() == 1 ? true : false; |
| 35 | chargerWirelessOnline = p->readInt32() == 1 ? true : false; |
| 36 | batteryStatus = p->readInt32(); |
| 37 | batteryHealth = p->readInt32(); |
| 38 | batteryPresent = p->readInt32() == 1 ? true : false; |
| 39 | batteryLevel = p->readInt32(); |
| 40 | batteryVoltage = p->readInt32(); |
Todd Poynor | b98240c | 2013-07-30 19:12:10 -0700 | [diff] [blame] | 41 | batteryCurrentNow = p->readInt32(); |
| 42 | batteryChargeCounter = p->readInt32(); |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 43 | batteryTemperature = p->readInt32(); |
| 44 | batteryTechnology = String8((p->readString16()).string()); |
| 45 | return OK; |
| 46 | } |
| 47 | |
| 48 | status_t BatteryProperties::writeToParcel(Parcel* p) const { |
| 49 | p->writeInt32(chargerAcOnline ? 1 : 0); |
| 50 | p->writeInt32(chargerUsbOnline ? 1 : 0); |
| 51 | p->writeInt32(chargerWirelessOnline ? 1 : 0); |
| 52 | p->writeInt32(batteryStatus); |
| 53 | p->writeInt32(batteryHealth); |
| 54 | p->writeInt32(batteryPresent ? 1 : 0); |
| 55 | p->writeInt32(batteryLevel); |
| 56 | p->writeInt32(batteryVoltage); |
Todd Poynor | b98240c | 2013-07-30 19:12:10 -0700 | [diff] [blame] | 57 | p->writeInt32(batteryCurrentNow); |
| 58 | p->writeInt32(batteryChargeCounter); |
Todd Poynor | 87bf0d9 | 2013-05-16 14:51:15 -0700 | [diff] [blame] | 59 | p->writeInt32(batteryTemperature); |
| 60 | p->writeString16(String16(batteryTechnology)); |
| 61 | return OK; |
| 62 | } |
| 63 | |
| 64 | }; // namespace android |