blob: c3e0f246574f2af0395267a506afe98be471d1c6 [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
Todd Poynora9de3462013-05-22 18:53:29 -070018/**
19 * {@hide}
20 */
21public class BatteryProperties implements Parcelable {
22 public boolean chargerAcOnline;
23 public boolean chargerUsbOnline;
24 public boolean chargerWirelessOnline;
Adrian Roos7b043112015-07-10 13:00:33 -070025 public int maxChargingCurrent;
Badhri Jagan Sridharanf92fcfe2015-10-27 13:59:34 -070026 public int maxChargingVoltage;
Todd Poynora9de3462013-05-22 18:53:29 -070027 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 String batteryTechnology;
34
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -080035 public BatteryProperties() {
36 }
37
38 public void set(BatteryProperties other) {
39 chargerAcOnline = other.chargerAcOnline;
40 chargerUsbOnline = other.chargerUsbOnline;
41 chargerWirelessOnline = other.chargerWirelessOnline;
Adrian Roos7b043112015-07-10 13:00:33 -070042 maxChargingCurrent = other.maxChargingCurrent;
Badhri Jagan Sridharanf92fcfe2015-10-27 13:59:34 -070043 maxChargingVoltage = other.maxChargingVoltage;
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -080044 batteryStatus = other.batteryStatus;
45 batteryHealth = other.batteryHealth;
46 batteryPresent = other.batteryPresent;
47 batteryLevel = other.batteryLevel;
48 batteryVoltage = other.batteryVoltage;
49 batteryTemperature = other.batteryTemperature;
50 batteryTechnology = other.batteryTechnology;
51 }
52
Todd Poynora9de3462013-05-22 18:53:29 -070053 /*
54 * Parcel read/write code must be kept in sync with
55 * frameworks/native/services/batteryservice/BatteryProperties.cpp
56 */
57
58 private BatteryProperties(Parcel p) {
59 chargerAcOnline = p.readInt() == 1 ? true : false;
60 chargerUsbOnline = p.readInt() == 1 ? true : false;
61 chargerWirelessOnline = p.readInt() == 1 ? true : false;
Adrian Roos7b043112015-07-10 13:00:33 -070062 maxChargingCurrent = p.readInt();
Badhri Jagan Sridharanf92fcfe2015-10-27 13:59:34 -070063 maxChargingVoltage = p.readInt();
Todd Poynora9de3462013-05-22 18:53:29 -070064 batteryStatus = p.readInt();
65 batteryHealth = p.readInt();
66 batteryPresent = p.readInt() == 1 ? true : false;
67 batteryLevel = p.readInt();
68 batteryVoltage = p.readInt();
69 batteryTemperature = p.readInt();
70 batteryTechnology = p.readString();
71 }
72
73 public void writeToParcel(Parcel p, int flags) {
74 p.writeInt(chargerAcOnline ? 1 : 0);
75 p.writeInt(chargerUsbOnline ? 1 : 0);
76 p.writeInt(chargerWirelessOnline ? 1 : 0);
Adrian Roos7b043112015-07-10 13:00:33 -070077 p.writeInt(maxChargingCurrent);
Badhri Jagan Sridharanf92fcfe2015-10-27 13:59:34 -070078 p.writeInt(maxChargingVoltage);
Todd Poynora9de3462013-05-22 18:53:29 -070079 p.writeInt(batteryStatus);
80 p.writeInt(batteryHealth);
81 p.writeInt(batteryPresent ? 1 : 0);
82 p.writeInt(batteryLevel);
83 p.writeInt(batteryVoltage);
Todd Poynora9de3462013-05-22 18:53:29 -070084 p.writeInt(batteryTemperature);
85 p.writeString(batteryTechnology);
86 }
87
88 public static final Parcelable.Creator<BatteryProperties> CREATOR
89 = new Parcelable.Creator<BatteryProperties>() {
90 public BatteryProperties createFromParcel(Parcel p) {
91 return new BatteryProperties(p);
92 }
93
94 public BatteryProperties[] newArray(int size) {
95 return new BatteryProperties[size];
96 }
97 };
98
99 public int describeContents() {
100 return 0;
101 }
102}