BatteryProperty.java revision 5a43cc6ddd2aa3d9af38891bae6fea866c7227f9
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 BatteryProperty implements Parcelable {
25    /*
26     * Battery property identifiers.  These must match the values in
27     * frameworks/native/include/batteryservice/BatteryService.h
28     */
29    public static final int BATTERY_PROP_CHARGE_COUNTER = 1;
30    public static final int BATTERY_PROP_CURRENT_NOW = 2;
31    public static final int BATTERY_PROP_CURRENT_AVG = 3;
32    public static final int BATTERY_PROP_CAPACITY = 4;
33
34    public int valueInt;
35
36    public BatteryProperty() {
37        valueInt = Integer.MIN_VALUE;
38    }
39
40    /*
41     * Parcel read/write code must be kept in sync with
42     * frameworks/native/services/batteryservice/BatteryProperty.cpp
43     */
44
45    private BatteryProperty(Parcel p) {
46        readFromParcel(p);
47    }
48
49    public void readFromParcel(Parcel p) {
50        valueInt = p.readInt();
51    }
52
53    public void writeToParcel(Parcel p, int flags) {
54        p.writeInt(valueInt);
55    }
56
57    public static final Parcelable.Creator<BatteryProperty> CREATOR
58        = new Parcelable.Creator<BatteryProperty>() {
59        public BatteryProperty createFromParcel(Parcel p) {
60            return new BatteryProperty(p);
61        }
62
63        public BatteryProperty[] newArray(int size) {
64            return new BatteryProperty[size];
65        }
66    };
67
68    public int describeContents() {
69        return 0;
70    }
71}
72