• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.loganalysis.item;
18 
19 import java.util.Arrays;
20 import java.util.HashSet;
21 import java.util.Set;
22 
23 
24 /**
25  * An {@link IItem} used to store traces info.
26  * <p>
27  * This stores info about page allocation failures, i.e. order.
28  * </p>
29  */
30 public class LowMemoryKillerItem extends MiscKernelLogItem {
31     /** Constant for JSON output */
32     public static final String PID = "PID";
33     /** Constant for JSON output */
34     public static final String PROCESS_NAME = "PROCESS_NAME";
35     /** Constant for JSON output */
36     public static final String ADJUSTMENT = "ADJUSTMENT";
37 
38     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
39             PID, PROCESS_NAME, ADJUSTMENT));
40 
41     /**
42      * The constructor for {@link LowMemoryKillerItem}.
43      */
LowMemoryKillerItem()44     public LowMemoryKillerItem() {
45         super(ATTRIBUTES);
46     }
47 
48     /**
49      * Get the pid of the killed process.
50      */
getPid()51     public int getPid() {
52         return (int) getAttribute(PID);
53     }
54 
55     /**
56      * Set the pid of the killed process.
57      */
setPid(int pid)58     public void setPid(int pid) {
59         setAttribute(PID, pid);
60     }
61 
62     /**
63      * Get the name of the killed process.
64      */
getProcessName()65     public String getProcessName() {
66         return (String) getAttribute(PROCESS_NAME);
67     }
68 
69     /**
70      * Set the name of the killed process.
71      */
setProcessName(String name)72     public void setProcessName(String name) {
73         setAttribute(PROCESS_NAME, name);
74     }
75 
76     /**
77      * Get the adjustment score of the LMK action.
78      */
getAdjustment()79     public int getAdjustment() {
80         return (int) getAttribute(ADJUSTMENT);
81     }
82 
83     /**
84      * Set the adjustment score of the LMK action.
85      */
setAdjustment(int adjustment)86     public void setAdjustment(int adjustment) {
87         setAttribute(ADJUSTMENT, adjustment);
88     }
89 }
90