BatteryProperties.java revision 50ae3858942c3afb4006317a8b517bceb1b0114e
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 18import android.os.Parcel; 19import android.os.Parcelable; 20 21/** 22 * {@hide} 23 */ 24public class BatteryProperties implements Parcelable { 25 public boolean chargerAcOnline; 26 public boolean chargerUsbOnline; 27 public boolean chargerWirelessOnline; 28 public int batteryStatus; 29 public int batteryHealth; 30 public boolean batteryPresent; 31 public int batteryLevel; 32 public int batteryVoltage; 33 public int batteryTemperature; 34 public String batteryTechnology; 35 36 /* 37 * Parcel read/write code must be kept in sync with 38 * frameworks/native/services/batteryservice/BatteryProperties.cpp 39 */ 40 41 private BatteryProperties(Parcel p) { 42 chargerAcOnline = p.readInt() == 1 ? true : false; 43 chargerUsbOnline = p.readInt() == 1 ? true : false; 44 chargerWirelessOnline = p.readInt() == 1 ? true : false; 45 batteryStatus = p.readInt(); 46 batteryHealth = p.readInt(); 47 batteryPresent = p.readInt() == 1 ? true : false; 48 batteryLevel = p.readInt(); 49 batteryVoltage = p.readInt(); 50 batteryTemperature = p.readInt(); 51 batteryTechnology = p.readString(); 52 } 53 54 public void writeToParcel(Parcel p, int flags) { 55 p.writeInt(chargerAcOnline ? 1 : 0); 56 p.writeInt(chargerUsbOnline ? 1 : 0); 57 p.writeInt(chargerWirelessOnline ? 1 : 0); 58 p.writeInt(batteryStatus); 59 p.writeInt(batteryHealth); 60 p.writeInt(batteryPresent ? 1 : 0); 61 p.writeInt(batteryLevel); 62 p.writeInt(batteryVoltage); 63 p.writeInt(batteryTemperature); 64 p.writeString(batteryTechnology); 65 } 66 67 public static final Parcelable.Creator<BatteryProperties> CREATOR 68 = new Parcelable.Creator<BatteryProperties>() { 69 public BatteryProperties createFromParcel(Parcel p) { 70 return new BatteryProperties(p); 71 } 72 73 public BatteryProperties[] newArray(int size) { 74 return new BatteryProperties[size]; 75 } 76 }; 77 78 public int describeContents() { 79 return 0; 80 } 81} 82