Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 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 | /** |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 22 | * Battery properties that may be queried using |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 23 | * BatteryManager.getProperty()} |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 24 | */ |
Todd Poynor | 5fde3ff | 2014-06-05 14:49:28 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * @hide |
| 28 | */ |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 29 | public class BatteryProperty implements Parcelable { |
Todd Poynor | 540f4d6 | 2014-05-08 15:12:50 -0700 | [diff] [blame] | 30 | private long mValueLong; |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * @hide |
| 34 | */ |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 35 | public BatteryProperty() { |
Todd Poynor | 540f4d6 | 2014-05-08 15:12:50 -0700 | [diff] [blame] | 36 | mValueLong = Long.MIN_VALUE; |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /** |
Todd Poynor | 5fde3ff | 2014-06-05 14:49:28 -0700 | [diff] [blame] | 40 | * @hide |
Todd Poynor | 540f4d6 | 2014-05-08 15:12:50 -0700 | [diff] [blame] | 41 | */ |
| 42 | public long getLong() { |
| 43 | return mValueLong; |
| 44 | } |
Todd Poynor | 5fde3ff | 2014-06-05 14:49:28 -0700 | [diff] [blame] | 45 | |
Yifan Hong | 1fd86f4c | 2017-10-09 16:50:33 -0700 | [diff] [blame] | 46 | /** |
| 47 | * @hide |
| 48 | */ |
| 49 | public void setLong(long val) { |
| 50 | mValueLong = val; |
| 51 | } |
| 52 | |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Parcel read/write code must be kept in sync with |
| 55 | * frameworks/native/services/batteryservice/BatteryProperty.cpp |
| 56 | */ |
| 57 | |
| 58 | private BatteryProperty(Parcel p) { |
| 59 | readFromParcel(p); |
| 60 | } |
| 61 | |
| 62 | public void readFromParcel(Parcel p) { |
Todd Poynor | 540f4d6 | 2014-05-08 15:12:50 -0700 | [diff] [blame] | 63 | mValueLong = p.readLong(); |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | public void writeToParcel(Parcel p, int flags) { |
Todd Poynor | 540f4d6 | 2014-05-08 15:12:50 -0700 | [diff] [blame] | 67 | p.writeLong(mValueLong); |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 70 | public static final @android.annotation.NonNull Parcelable.Creator<BatteryProperty> CREATOR |
Todd Poynor | d7b3477 | 2013-08-14 20:42:44 -0700 | [diff] [blame] | 71 | = new Parcelable.Creator<BatteryProperty>() { |
| 72 | public BatteryProperty createFromParcel(Parcel p) { |
| 73 | return new BatteryProperty(p); |
| 74 | } |
| 75 | |
| 76 | public BatteryProperty[] newArray(int size) { |
| 77 | return new BatteryProperty[size]; |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | public int describeContents() { |
| 82 | return 0; |
| 83 | } |
| 84 | } |