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