Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
| 17 | package android.os; |
| 18 | |
| 19 | /** |
| 20 | * CPU usage information per core. |
| 21 | */ |
| 22 | public final class CpuUsageInfo implements Parcelable { |
| 23 | private long mActive; |
| 24 | private long mTotal; |
| 25 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 26 | public static final @android.annotation.NonNull Parcelable.Creator<CpuUsageInfo> CREATOR = new |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 27 | Parcelable.Creator<CpuUsageInfo>() { |
| 28 | public CpuUsageInfo createFromParcel(Parcel in) { |
| 29 | return new CpuUsageInfo(in); |
| 30 | } |
| 31 | |
| 32 | public CpuUsageInfo[] newArray(int size) { |
| 33 | return new CpuUsageInfo[size]; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | /** @hide */ |
| 38 | public CpuUsageInfo(long activeTime, long totalTime) { |
| 39 | mActive = activeTime; |
| 40 | mTotal = totalTime; |
| 41 | } |
| 42 | |
| 43 | private CpuUsageInfo(Parcel in) { |
| 44 | readFromParcel(in); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Gets the active time in milliseconds since the system last booted. |
| 49 | * |
| 50 | * @return Active time in milliseconds. |
| 51 | */ |
| 52 | public long getActive() { |
| 53 | return mActive; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Gets the total time in milliseconds that the CPU has been enabled since the system last |
| 58 | * booted. This includes time the CPU spent idle. |
| 59 | * |
| 60 | * @return Total time in milliseconds. |
| 61 | */ |
| 62 | public long getTotal() { |
| 63 | return mTotal; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public int describeContents() { |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void writeToParcel(Parcel out, int flags) { |
| 73 | out.writeLong(mActive); |
| 74 | out.writeLong(mTotal); |
| 75 | } |
| 76 | |
| 77 | private void readFromParcel(Parcel in) { |
| 78 | mActive = in.readLong(); |
| 79 | mTotal = in.readLong(); |
| 80 | } |
| 81 | } |