• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 package com.android.loganalysis.item;
17 
18 import java.util.Arrays;
19 import java.util.Date;
20 import java.util.HashSet;
21 import java.util.Set;
22 
23 /**
24  * An {@link IItem} used to store Bugreport info.
25  */
26 public class BugreportItem extends GenericItem {
27 
28     /** Constant for JSON output */
29     public static final String TIME = "TIME";
30     /** Constant for JSON output */
31     public static final String COMMAND_LINE = "COMMAND_LINE";
32     /** Constant for JSON output */
33     public static final String MEM_INFO = "MEM_INFO";
34     /** Constant for JSON output */
35     public static final String PROCRANK = "PROCRANK";
36     /** Constant for JSON output */
37     public static final String TOP = "TOP";
38     /** Constant for JSON output */
39     public static final String KERNEL_LOG = "KERNEL_LOG";
40     /** Constant for JSON output */
41     public static final String LAST_KMSG = "LAST_KMSG";
42     /** Constant for JSON output */
43     public static final String SYSTEM_LOG = "SYSTEM_LOG";
44     /** Constant for JSON output */
45     public static final String SYSTEM_PROPS = "SYSTEM_PROPS";
46     /** Constant for JSON output */
47     public static final String DUMPSYS = "DUMPSYS";
48     /** Constant for JSON output */
49     public static final String ACTIVITY_SERVICE = "ACTIVITY_SERVICE";
50 
51     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
52             TIME, COMMAND_LINE, MEM_INFO, PROCRANK, TOP, KERNEL_LOG, LAST_KMSG, SYSTEM_LOG,
53             SYSTEM_PROPS, DUMPSYS, ACTIVITY_SERVICE));
54 
55     public static class CommandLineItem extends GenericMapItem<String> {
56         private static final long serialVersionUID = 0L;
57     }
58 
59     /**
60      * The constructor for {@link BugreportItem}.
61      */
BugreportItem()62     public BugreportItem() {
63         super(ATTRIBUTES);
64     }
65 
66     /**
67      * Get the time of the bugreport.
68      */
getTime()69     public Date getTime() {
70         return (Date) getAttribute(TIME);
71     }
72 
73     /**
74      * Set the time of the bugreport.
75      */
setTime(Date time)76     public void setTime(Date time) {
77         setAttribute(TIME, time);
78     }
79 
80     /**
81      * Get the {@link CommandLineItem} of the bugreport.
82      */
getCommandLine()83     public CommandLineItem getCommandLine() {
84         return (CommandLineItem) getAttribute(COMMAND_LINE);
85     }
86 
87     /**
88      * Set the {@link CommandLineItem} of the bugreport.
89      */
setCommandLine(CommandLineItem commandLine)90     public void setCommandLine(CommandLineItem commandLine) {
91         setAttribute(COMMAND_LINE, commandLine);
92     }
93 
94     /**
95      * Get the {@link MemInfoItem} of the bugreport.
96      */
getMemInfo()97     public MemInfoItem getMemInfo() {
98         return (MemInfoItem) getAttribute(MEM_INFO);
99     }
100 
101     /**
102      * Set the {@link MemInfoItem} of the bugreport.
103      */
setMemInfo(MemInfoItem memInfo)104     public void setMemInfo(MemInfoItem memInfo) {
105         setAttribute(MEM_INFO, memInfo);
106     }
107 
108     /**
109      * Get the {@link ProcrankItem} of the bugreport.
110      */
getProcrank()111     public ProcrankItem getProcrank() {
112         return (ProcrankItem) getAttribute(PROCRANK);
113     }
114 
115     /**
116      * Set the {@link ProcrankItem} of the bugreport.
117      */
setProcrank(ProcrankItem procrank)118     public void setProcrank(ProcrankItem procrank) {
119         setAttribute(PROCRANK, procrank);
120     }
121 
122     /**
123      * Get the {@link TopItem} of the bugreport.
124      */
getTop()125     public TopItem getTop() {
126         return (TopItem) getAttribute(TOP);
127     }
128 
129     /**
130      * Set the {@link TopItem} of the bugreport.
131      */
setTop(TopItem top)132     public void setTop(TopItem top) {
133         setAttribute(TOP, top);
134     }
135 
136     /**
137      * Get the kernel log {@link KernelLogItem} of the bugreport.
138      */
getKernelLog()139     public KernelLogItem getKernelLog() {
140         return (KernelLogItem) getAttribute(KERNEL_LOG);
141     }
142 
143     /**
144      * Set the kernel log {@link KernelLogItem} of the bugreport.
145      */
setKernelLog(KernelLogItem systemLog)146     public void setKernelLog(KernelLogItem systemLog) {
147         setAttribute(KERNEL_LOG, systemLog);
148     }
149 
150     /**
151      * Get the last kmsg {@link KernelLogItem} of the bugreport.
152      */
getLastKmsg()153     public KernelLogItem getLastKmsg() {
154         return (KernelLogItem) getAttribute(LAST_KMSG);
155     }
156 
157     /**
158      * Set the last kmsg {@link KernelLogItem} of the bugreport.
159      */
setLastKmsg(KernelLogItem systemLog)160     public void setLastKmsg(KernelLogItem systemLog) {
161         setAttribute(LAST_KMSG, systemLog);
162     }
163 
164     /**
165      * Get the {@link LogcatItem} of the bugreport.
166      */
getSystemLog()167     public LogcatItem getSystemLog() {
168         return (LogcatItem) getAttribute(SYSTEM_LOG);
169     }
170 
171     /**
172      * Set the {@link LogcatItem} of the bugreport.
173      */
setSystemLog(LogcatItem systemLog)174     public void setSystemLog(LogcatItem systemLog) {
175         setAttribute(SYSTEM_LOG, systemLog);
176     }
177 
178     /**
179      * Get the {@link SystemPropsItem} of the bugreport.
180      */
getSystemProps()181     public SystemPropsItem getSystemProps() {
182         return (SystemPropsItem) getAttribute(SYSTEM_PROPS);
183     }
184 
185     /**
186      * Set the {@link SystemPropsItem} of the bugreport.
187      */
setSystemProps(SystemPropsItem systemProps)188     public void setSystemProps(SystemPropsItem systemProps) {
189         setAttribute(SYSTEM_PROPS, systemProps);
190     }
191 
192     /**
193      * Get the {@link DumpsysItem} of the bugreport.
194      */
getDumpsys()195     public DumpsysItem getDumpsys() {
196         return (DumpsysItem) getAttribute(DUMPSYS);
197     }
198 
199     /**
200      * Set the {@link DumpsysItem} of the bugreport.
201      */
setDumpsys(DumpsysItem dumpsys)202     public void setDumpsys(DumpsysItem dumpsys) {
203         setAttribute(DUMPSYS, dumpsys);
204     }
205     /**
206      * Get the {@link ActivityServiceItem} of the bugreport.
207      */
getActivityService()208     public ActivityServiceItem getActivityService() {
209         return (ActivityServiceItem) getAttribute(ACTIVITY_SERVICE);
210     }
211 
212     /**
213      * Set the {@link ActivityServiceItem} of the bugreport.
214      */
setActivityService(ActivityServiceItem activityService)215     public void setActivityService(ActivityServiceItem activityService) {
216         setAttribute(ACTIVITY_SERVICE, activityService);
217     }
218 }
219