BatteryProperties.java revision 6361e22feae7cdb0968f1056c7834e2825eeae31
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 16package android.os; 17 18/** 19 * {@hide} 20 */ 21public class BatteryProperties implements Parcelable { 22 public boolean chargerAcOnline; 23 public boolean chargerUsbOnline; 24 public boolean chargerWirelessOnline; 25 public int maxChargingCurrent; 26 public int maxChargingVoltage; 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 int batteryChargeCounter; 34 public String batteryTechnology; 35 36 public BatteryProperties() { 37 } 38 39 public void set(BatteryProperties other) { 40 chargerAcOnline = other.chargerAcOnline; 41 chargerUsbOnline = other.chargerUsbOnline; 42 chargerWirelessOnline = other.chargerWirelessOnline; 43 maxChargingCurrent = other.maxChargingCurrent; 44 maxChargingVoltage = other.maxChargingVoltage; 45 batteryStatus = other.batteryStatus; 46 batteryHealth = other.batteryHealth; 47 batteryPresent = other.batteryPresent; 48 batteryLevel = other.batteryLevel; 49 batteryVoltage = other.batteryVoltage; 50 batteryTemperature = other.batteryTemperature; 51 batteryChargeCounter = other.batteryChargeCounter; 52 batteryTechnology = other.batteryTechnology; 53 } 54 55 /* 56 * Parcel read/write code must be kept in sync with 57 * frameworks/native/services/batteryservice/BatteryProperties.cpp 58 */ 59 60 private BatteryProperties(Parcel p) { 61 chargerAcOnline = p.readInt() == 1 ? true : false; 62 chargerUsbOnline = p.readInt() == 1 ? true : false; 63 chargerWirelessOnline = p.readInt() == 1 ? true : false; 64 maxChargingCurrent = p.readInt(); 65 maxChargingVoltage = p.readInt(); 66 batteryStatus = p.readInt(); 67 batteryHealth = p.readInt(); 68 batteryPresent = p.readInt() == 1 ? true : false; 69 batteryLevel = p.readInt(); 70 batteryVoltage = p.readInt(); 71 batteryTemperature = p.readInt(); 72 batteryChargeCounter = p.readInt(); 73 batteryTechnology = p.readString(); 74 } 75 76 public void writeToParcel(Parcel p, int flags) { 77 p.writeInt(chargerAcOnline ? 1 : 0); 78 p.writeInt(chargerUsbOnline ? 1 : 0); 79 p.writeInt(chargerWirelessOnline ? 1 : 0); 80 p.writeInt(maxChargingCurrent); 81 p.writeInt(maxChargingVoltage); 82 p.writeInt(batteryStatus); 83 p.writeInt(batteryHealth); 84 p.writeInt(batteryPresent ? 1 : 0); 85 p.writeInt(batteryLevel); 86 p.writeInt(batteryVoltage); 87 p.writeInt(batteryTemperature); 88 p.writeInt(batteryChargeCounter); 89 p.writeString(batteryTechnology); 90 } 91 92 public static final Parcelable.Creator<BatteryProperties> CREATOR 93 = new Parcelable.Creator<BatteryProperties>() { 94 public BatteryProperties createFromParcel(Parcel p) { 95 return new BatteryProperties(p); 96 } 97 98 public BatteryProperties[] newArray(int size) { 99 return new BatteryProperties[size]; 100 } 101 }; 102 103 public int describeContents() { 104 return 0; 105 } 106} 107