blob: 4aaa85fb57223f3ccc174cb53768f72536849336 [file] [log] [blame]
Joe Onorato713fec82016-03-04 10:34:02 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os.health;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * A TimerStat object stores a count and a time.
24 *
25 * @more
26 * When possible, the other APIs in this package avoid requiring a TimerStat
27 * object to be constructed, even internally, but the getTimers method on
28 * {@link android.os.health.HealthStats} does require TimerStat objects.
29 */
Jeff Sharkey70168dd2016-03-30 21:47:16 -060030public final class TimerStat implements Parcelable {
Joe Onorato713fec82016-03-04 10:34:02 -080031 private int mCount;
32 private long mTime;
33
34 /**
35 * The CREATOR instance for use by aidl Binder interfaces.
36 */
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070037 public static final @android.annotation.NonNull Parcelable.Creator<TimerStat> CREATOR
Joe Onorato713fec82016-03-04 10:34:02 -080038 = new Parcelable.Creator<TimerStat>() {
39 public TimerStat createFromParcel(Parcel in) {
40 return new TimerStat(in);
41 }
42
43 public TimerStat[] newArray(int size) {
44 return new TimerStat[size];
45 }
46 };
47
48 /**
49 * Construct an empty TimerStat object with the count and time set to 0.
50 */
51 public TimerStat() {
52 }
53
54 /**
55 * Construct a TimerStat object with the supplied count and time fields.
56 *
57 * @param count The count
58 * @param time The time
59 */
60 public TimerStat(int count, long time) {
61 mCount = count;
62 mTime = time;
63 }
64
65 /**
66 * Construct a TimerStat object reading the values from a {@link android.os.Parcel Parcel}
67 * object.
68 */
69 public TimerStat(Parcel in) {
70 mCount = in.readInt();
71 mTime = in.readLong();
72 }
73
74 /**
75 * @inheritDoc
76 */
77 public int describeContents() {
78 return 0;
79 }
80
81 /**
82 * Write this TimerStat object to a parcel.
83 */
84 public void writeToParcel(Parcel out, int flags) {
85 out.writeInt(mCount);
86 out.writeLong(mTime);
87 }
88
89 /**
90 * Set the count for this timer.
91 */
92 public void setCount(int count) {
93 mCount = count;
94 }
95
96 /**
97 * Get the count for this timer.
98 */
99 public int getCount() {
100 return mCount;
101 }
102
103 /**
Joe Onorato181cada2016-05-09 10:31:41 -0700104 * Set the time for this timer in milliseconds.
Joe Onorato713fec82016-03-04 10:34:02 -0800105 */
106 public void setTime(long time) {
107 mTime = time;
108 }
109
110 /**
Joe Onorato181cada2016-05-09 10:31:41 -0700111 * Get the time for this timer in milliseconds.
Joe Onorato713fec82016-03-04 10:34:02 -0800112 */
113 public long getTime() {
114 return mTime;
115 }
116}