• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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  * An {@link IItem} used to store action info logged in dmesg
25  * For example: [   14.942872] init: processing action (early-init)
26  */
27 public class DmesgActionInfoItem extends GenericItem {
28 
29     /** Constant for JSON output */
30     public static final String ACTION_NAME = "ACTION_NAME";
31     /** Constant for JSON output */
32     public static final String ACTION_START_TIME = "ACTION_START_TIME";
33 
34     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
35             ACTION_NAME, ACTION_START_TIME));
36 
37     /**
38      * The constructor for {@link DmesgActionInfoItem}.
39      */
DmesgActionInfoItem()40     public DmesgActionInfoItem() {
41         super(ATTRIBUTES);
42     }
43 
44     /**
45      * The constructor for {@link DmesgActionInfoItem}.
46      */
DmesgActionInfoItem(String name, Long startTime)47     public DmesgActionInfoItem(String name, Long startTime) {
48         super(ATTRIBUTES);
49         setAttribute(ACTION_NAME, name);
50         setAttribute(ACTION_START_TIME, startTime);
51     }
52 
53     /**
54      * Get the name of the action
55      */
getActionName()56     public String getActionName() {
57         return (String) getAttribute(ACTION_NAME);
58     }
59 
60     /**
61      * Set the name of the action
62      */
setActionName(String stageName)63     public void setActionName(String stageName) {
64         setAttribute(ACTION_NAME, stageName);
65     }
66 
67     /**
68      * Get the start time in msecs
69      */
getStartTime()70     public Long getStartTime() {
71         return (Long) getAttribute(ACTION_START_TIME);
72     }
73 
74     /**
75      * Set the start time in msecs
76      */
setStartTime(Long startTime)77     public void setStartTime(Long startTime) {
78         setAttribute(ACTION_START_TIME, startTime);
79     }
80 
81     @Override
toString()82     public String toString() {
83         return "ActionInfoItem [getActionName()=" + getActionName() + ", getStartTime()="
84                 + getStartTime() + "]";
85     }
86 
87 }
88