1 /* 2 * Copyright (C) 2011 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 * For now, this only stores info about the main stack trace from the first process. It is used to 28 * get a stack from {@code /data/anr/traces.txt} which can be used to give some context about the 29 * ANR. If there is a need, this item can be expanded to store all stacks from all processes. 30 * </p> 31 */ 32 public class TracesItem extends GenericItem { 33 34 /** Constant for JSON output */ 35 public static final String PID = "PID"; 36 /** Constant for JSON output */ 37 public static final String APP = "APP"; 38 /** Constant for JSON output */ 39 public static final String STACK = "STACK"; 40 41 private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList( 42 PID, APP, STACK)); 43 44 /** 45 * The constructor for {@link TracesItem}. 46 */ 47 public TracesItem() { 48 super(ATTRIBUTES); 49 } 50 51 /** 52 * Get the PID of the event. 53 */ 54 public Integer getPid() { 55 return (Integer) getAttribute(PID); 56 } 57 58 /** 59 * Set the PID of the event. 60 */ 61 public void setPid(Integer pid) { 62 setAttribute(PID, pid); 63 } 64 65 /** 66 * Get the app or package name of the event. 67 */ 68 public String getApp() { 69 return (String) getAttribute(APP); 70 } 71 72 /** 73 * Set the app or package name of the event. 74 */ 75 public void setApp(String app) { 76 setAttribute(APP, app); 77 } 78 79 /** 80 * Get the stack for the crash. 81 */ 82 public String getStack() { 83 return (String) getAttribute(STACK); 84 } 85 86 /** 87 * Set the stack for the crash. 88 */ 89 public void setStack(String stack) { 90 setAttribute(STACK, stack); 91 } 92 } 93