Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 1 | /* Copyright 2013, The Android Open Source Project |
| 2 | * |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package android.os; |
| 17 | |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 18 | /** |
| 19 | * {@hide} |
| 20 | */ |
| 21 | public class BatteryProperties implements Parcelable { |
| 22 | public boolean chargerAcOnline; |
| 23 | public boolean chargerUsbOnline; |
| 24 | public boolean chargerWirelessOnline; |
| 25 | public int batteryStatus; |
| 26 | public int batteryHealth; |
| 27 | public boolean batteryPresent; |
| 28 | public int batteryLevel; |
| 29 | public int batteryVoltage; |
| 30 | public int batteryTemperature; |
| 31 | public String batteryTechnology; |
| 32 | |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame^] | 33 | public BatteryProperties() { |
| 34 | } |
| 35 | |
| 36 | public void set(BatteryProperties other) { |
| 37 | chargerAcOnline = other.chargerAcOnline; |
| 38 | chargerUsbOnline = other.chargerUsbOnline; |
| 39 | chargerWirelessOnline = other.chargerWirelessOnline; |
| 40 | batteryStatus = other.batteryStatus; |
| 41 | batteryHealth = other.batteryHealth; |
| 42 | batteryPresent = other.batteryPresent; |
| 43 | batteryLevel = other.batteryLevel; |
| 44 | batteryVoltage = other.batteryVoltage; |
| 45 | batteryTemperature = other.batteryTemperature; |
| 46 | batteryTechnology = other.batteryTechnology; |
| 47 | } |
| 48 | |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 49 | /* |
| 50 | * Parcel read/write code must be kept in sync with |
| 51 | * frameworks/native/services/batteryservice/BatteryProperties.cpp |
| 52 | */ |
| 53 | |
| 54 | private BatteryProperties(Parcel p) { |
| 55 | chargerAcOnline = p.readInt() == 1 ? true : false; |
| 56 | chargerUsbOnline = p.readInt() == 1 ? true : false; |
| 57 | chargerWirelessOnline = p.readInt() == 1 ? true : false; |
| 58 | batteryStatus = p.readInt(); |
| 59 | batteryHealth = p.readInt(); |
| 60 | batteryPresent = p.readInt() == 1 ? true : false; |
| 61 | batteryLevel = p.readInt(); |
| 62 | batteryVoltage = p.readInt(); |
| 63 | batteryTemperature = p.readInt(); |
| 64 | batteryTechnology = p.readString(); |
| 65 | } |
| 66 | |
| 67 | public void writeToParcel(Parcel p, int flags) { |
| 68 | p.writeInt(chargerAcOnline ? 1 : 0); |
| 69 | p.writeInt(chargerUsbOnline ? 1 : 0); |
| 70 | p.writeInt(chargerWirelessOnline ? 1 : 0); |
| 71 | p.writeInt(batteryStatus); |
| 72 | p.writeInt(batteryHealth); |
| 73 | p.writeInt(batteryPresent ? 1 : 0); |
| 74 | p.writeInt(batteryLevel); |
| 75 | p.writeInt(batteryVoltage); |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 76 | p.writeInt(batteryTemperature); |
| 77 | p.writeString(batteryTechnology); |
| 78 | } |
| 79 | |
| 80 | public static final Parcelable.Creator<BatteryProperties> CREATOR |
| 81 | = new Parcelable.Creator<BatteryProperties>() { |
| 82 | public BatteryProperties createFromParcel(Parcel p) { |
| 83 | return new BatteryProperties(p); |
| 84 | } |
| 85 | |
| 86 | public BatteryProperties[] newArray(int size) { |
| 87 | return new BatteryProperties[size]; |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | public int describeContents() { |
| 92 | return 0; |
| 93 | } |
| 94 | } |