BatteryProperties.java revision 7b04311d88e377c67b4c663091b6b1c63c932c52
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 batteryStatus; 27 public int batteryHealth; 28 public boolean batteryPresent; 29 public int batteryLevel; 30 public int batteryVoltage; 31 public int batteryTemperature; 32 public String batteryTechnology; 33 34 public BatteryProperties() { 35 } 36 37 public void set(BatteryProperties other) { 38 chargerAcOnline = other.chargerAcOnline; 39 chargerUsbOnline = other.chargerUsbOnline; 40 chargerWirelessOnline = other.chargerWirelessOnline; 41 maxChargingCurrent = other.maxChargingCurrent; 42 batteryStatus = other.batteryStatus; 43 batteryHealth = other.batteryHealth; 44 batteryPresent = other.batteryPresent; 45 batteryLevel = other.batteryLevel; 46 batteryVoltage = other.batteryVoltage; 47 batteryTemperature = other.batteryTemperature; 48 batteryTechnology = other.batteryTechnology; 49 } 50 51 /* 52 * Parcel read/write code must be kept in sync with 53 * frameworks/native/services/batteryservice/BatteryProperties.cpp 54 */ 55 56 private BatteryProperties(Parcel p) { 57 chargerAcOnline = p.readInt() == 1 ? true : false; 58 chargerUsbOnline = p.readInt() == 1 ? true : false; 59 chargerWirelessOnline = p.readInt() == 1 ? true : false; 60 maxChargingCurrent = p.readInt(); 61 batteryStatus = p.readInt(); 62 batteryHealth = p.readInt(); 63 batteryPresent = p.readInt() == 1 ? true : false; 64 batteryLevel = p.readInt(); 65 batteryVoltage = p.readInt(); 66 batteryTemperature = p.readInt(); 67 batteryTechnology = p.readString(); 68 } 69 70 public void writeToParcel(Parcel p, int flags) { 71 p.writeInt(chargerAcOnline ? 1 : 0); 72 p.writeInt(chargerUsbOnline ? 1 : 0); 73 p.writeInt(chargerWirelessOnline ? 1 : 0); 74 p.writeInt(maxChargingCurrent); 75 p.writeInt(batteryStatus); 76 p.writeInt(batteryHealth); 77 p.writeInt(batteryPresent ? 1 : 0); 78 p.writeInt(batteryLevel); 79 p.writeInt(batteryVoltage); 80 p.writeInt(batteryTemperature); 81 p.writeString(batteryTechnology); 82 } 83 84 public static final Parcelable.Creator<BatteryProperties> CREATOR 85 = new Parcelable.Creator<BatteryProperties>() { 86 public BatteryProperties createFromParcel(Parcel p) { 87 return new BatteryProperties(p); 88 } 89 90 public BatteryProperties[] newArray(int size) { 91 return new BatteryProperties[size]; 92 } 93 }; 94 95 public int describeContents() { 96 return 0; 97 } 98} 99