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; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 25 | public int maxChargingCurrent; |
Badhri Jagan Sridharan | f92fcfe | 2015-10-27 13:59:34 -0700 | [diff] [blame] | 26 | public int maxChargingVoltage; |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 27 | public int batteryStatus; |
| 28 | public int batteryHealth; |
| 29 | public boolean batteryPresent; |
| 30 | public int batteryLevel; |
| 31 | public int batteryVoltage; |
| 32 | public int batteryTemperature; |
| 33 | public String batteryTechnology; |
| 34 | |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame] | 35 | public BatteryProperties() { |
| 36 | } |
| 37 | |
| 38 | public void set(BatteryProperties other) { |
| 39 | chargerAcOnline = other.chargerAcOnline; |
| 40 | chargerUsbOnline = other.chargerUsbOnline; |
| 41 | chargerWirelessOnline = other.chargerWirelessOnline; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 42 | maxChargingCurrent = other.maxChargingCurrent; |
Badhri Jagan Sridharan | f92fcfe | 2015-10-27 13:59:34 -0700 | [diff] [blame] | 43 | maxChargingVoltage = other.maxChargingVoltage; |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame] | 44 | batteryStatus = other.batteryStatus; |
| 45 | batteryHealth = other.batteryHealth; |
| 46 | batteryPresent = other.batteryPresent; |
| 47 | batteryLevel = other.batteryLevel; |
| 48 | batteryVoltage = other.batteryVoltage; |
| 49 | batteryTemperature = other.batteryTemperature; |
| 50 | batteryTechnology = other.batteryTechnology; |
| 51 | } |
| 52 | |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Parcel read/write code must be kept in sync with |
| 55 | * frameworks/native/services/batteryservice/BatteryProperties.cpp |
| 56 | */ |
| 57 | |
| 58 | private BatteryProperties(Parcel p) { |
| 59 | chargerAcOnline = p.readInt() == 1 ? true : false; |
| 60 | chargerUsbOnline = p.readInt() == 1 ? true : false; |
| 61 | chargerWirelessOnline = p.readInt() == 1 ? true : false; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 62 | maxChargingCurrent = p.readInt(); |
Badhri Jagan Sridharan | f92fcfe | 2015-10-27 13:59:34 -0700 | [diff] [blame] | 63 | maxChargingVoltage = p.readInt(); |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 64 | batteryStatus = p.readInt(); |
| 65 | batteryHealth = p.readInt(); |
| 66 | batteryPresent = p.readInt() == 1 ? true : false; |
| 67 | batteryLevel = p.readInt(); |
| 68 | batteryVoltage = p.readInt(); |
| 69 | batteryTemperature = p.readInt(); |
| 70 | batteryTechnology = p.readString(); |
| 71 | } |
| 72 | |
| 73 | public void writeToParcel(Parcel p, int flags) { |
| 74 | p.writeInt(chargerAcOnline ? 1 : 0); |
| 75 | p.writeInt(chargerUsbOnline ? 1 : 0); |
| 76 | p.writeInt(chargerWirelessOnline ? 1 : 0); |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 77 | p.writeInt(maxChargingCurrent); |
Badhri Jagan Sridharan | f92fcfe | 2015-10-27 13:59:34 -0700 | [diff] [blame] | 78 | p.writeInt(maxChargingVoltage); |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 79 | p.writeInt(batteryStatus); |
| 80 | p.writeInt(batteryHealth); |
| 81 | p.writeInt(batteryPresent ? 1 : 0); |
| 82 | p.writeInt(batteryLevel); |
| 83 | p.writeInt(batteryVoltage); |
Todd Poynor | a9de346 | 2013-05-22 18:53:29 -0700 | [diff] [blame] | 84 | p.writeInt(batteryTemperature); |
| 85 | p.writeString(batteryTechnology); |
| 86 | } |
| 87 | |
| 88 | public static final Parcelable.Creator<BatteryProperties> CREATOR |
| 89 | = new Parcelable.Creator<BatteryProperties>() { |
| 90 | public BatteryProperties createFromParcel(Parcel p) { |
| 91 | return new BatteryProperties(p); |
| 92 | } |
| 93 | |
| 94 | public BatteryProperties[] newArray(int size) { |
| 95 | return new BatteryProperties[size]; |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | public int describeContents() { |
| 100 | return 0; |
| 101 | } |
| 102 | } |