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