blob: 5df5214d733bd329c67aeb79a9ff9d076f5210d0 [file] [log] [blame]
Todd Poynora9de3462013-05-22 18:53:29 -07001/* 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;
Todd Poynordf89ca32013-07-30 20:33:27 -070033 public int batteryCurrentNow;
34 public int batteryChargeCounter;
Todd Poynora9de3462013-05-22 18:53:29 -070035 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();
Todd Poynordf89ca32013-07-30 20:33:27 -070052 batteryCurrentNow = p.readInt();
53 batteryChargeCounter = p.readInt();
Todd Poynora9de3462013-05-22 18:53:29 -070054 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);
Todd Poynordf89ca32013-07-30 20:33:27 -070067 p.writeInt(batteryCurrentNow);
68 p.writeInt(batteryChargeCounter);
Todd Poynora9de3462013-05-22 18:53:29 -070069 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}