Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.app; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** |
| 23 | * The memory stats for a process. |
| 24 | * {@hide} |
| 25 | */ |
Rafal Slawik | 5c1263e | 2018-09-12 17:20:31 +0100 | [diff] [blame] | 26 | public final class ProcessMemoryState implements Parcelable { |
| 27 | public final int uid; |
| 28 | public final String processName; |
| 29 | public final int oomScore; |
| 30 | public final long pgfault; |
| 31 | public final long pgmajfault; |
| 32 | public final long rssInBytes; |
| 33 | public final long cacheInBytes; |
| 34 | public final long swapInBytes; |
Rafal Slawik | bf67d07 | 2018-10-23 11:07:54 +0100 | [diff] [blame] | 35 | public final long startTimeNanos; |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 36 | |
| 37 | public ProcessMemoryState(int uid, String processName, int oomScore, long pgfault, |
| 38 | long pgmajfault, long rssInBytes, long cacheInBytes, |
Rafal Slawik | d03ae42 | 2018-11-20 11:27:45 +0000 | [diff] [blame] | 39 | long swapInBytes, long startTimeNanos) { |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 40 | this.uid = uid; |
| 41 | this.processName = processName; |
| 42 | this.oomScore = oomScore; |
| 43 | this.pgfault = pgfault; |
| 44 | this.pgmajfault = pgmajfault; |
| 45 | this.rssInBytes = rssInBytes; |
| 46 | this.cacheInBytes = cacheInBytes; |
| 47 | this.swapInBytes = swapInBytes; |
Rafal Slawik | bf67d07 | 2018-10-23 11:07:54 +0100 | [diff] [blame] | 48 | this.startTimeNanos = startTimeNanos; |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | private ProcessMemoryState(Parcel in) { |
| 52 | uid = in.readInt(); |
| 53 | processName = in.readString(); |
| 54 | oomScore = in.readInt(); |
| 55 | pgfault = in.readLong(); |
| 56 | pgmajfault = in.readLong(); |
| 57 | rssInBytes = in.readLong(); |
| 58 | cacheInBytes = in.readLong(); |
| 59 | swapInBytes = in.readLong(); |
Rafal Slawik | bf67d07 | 2018-10-23 11:07:54 +0100 | [diff] [blame] | 60 | startTimeNanos = in.readLong(); |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 63 | public static final @android.annotation.NonNull Creator<ProcessMemoryState> CREATOR = new Creator<ProcessMemoryState>() { |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 64 | @Override |
| 65 | public ProcessMemoryState createFromParcel(Parcel in) { |
| 66 | return new ProcessMemoryState(in); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public ProcessMemoryState[] newArray(int size) { |
| 71 | return new ProcessMemoryState[size]; |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | @Override |
| 76 | public int describeContents() { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void writeToParcel(Parcel parcel, int i) { |
| 82 | parcel.writeInt(uid); |
| 83 | parcel.writeString(processName); |
| 84 | parcel.writeInt(oomScore); |
| 85 | parcel.writeLong(pgfault); |
| 86 | parcel.writeLong(pgmajfault); |
| 87 | parcel.writeLong(rssInBytes); |
| 88 | parcel.writeLong(cacheInBytes); |
| 89 | parcel.writeLong(swapInBytes); |
Rafal Slawik | bf67d07 | 2018-10-23 11:07:54 +0100 | [diff] [blame] | 90 | parcel.writeLong(startTimeNanos); |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 91 | } |
| 92 | } |