• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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.HashSet;
20 import java.util.Set;
21 
22 /**
23  * An {@link IItem} used to store the output of the dumpsys section of the bugreport.
24  */
25 public class DumpsysItem extends GenericItem {
26 
27     /** Constant for JSON output */
28     private static final String BATTERY_STATS = "BATTERY_STATS";
29     /** Constant for JSON output */
30     private static final String PACKAGE_STATS = "PACKAGE_STATS";
31     /** Constant for JSON output */
32     private static final String PROC_STATS = "PROC_STATS";
33     /** Constant for JSON output */
34     private static final String WIFI_STATS = "WIFI_STATS";
35 
36     private static final Set<String> ATTRIBUTES =
37             new HashSet<String>(
38                     Arrays.asList(BATTERY_STATS, PACKAGE_STATS, PROC_STATS, WIFI_STATS));
39 
40     /**
41      * The constructor for {@link DumpsysItem}.
42      */
DumpsysItem()43     public DumpsysItem() {
44         super(ATTRIBUTES);
45     }
46 
47     /**
48      * Set the {@link DumpsysBatteryStatsItem} of the bugreport.
49      */
setBatteryInfo(DumpsysBatteryStatsItem batteryStats)50     public void setBatteryInfo(DumpsysBatteryStatsItem batteryStats) {
51         setAttribute(BATTERY_STATS, batteryStats);
52     }
53 
54     /** Set the {@link DumpsysPackageStatsItem} of the bugreport. */
setPackageStats(DumpsysPackageStatsItem packageStats)55     public void setPackageStats(DumpsysPackageStatsItem packageStats) {
56         setAttribute(PACKAGE_STATS, packageStats);
57     }
58 
59     /** Set the {@link DumpsysProcStatsItem} of the bugreport. */
setProcStats(DumpsysProcStatsItem procStats)60     public void setProcStats(DumpsysProcStatsItem procStats) {
61         setAttribute(PROC_STATS, procStats);
62     }
63 
64     /**
65      * Set the {@link DumpsysWifiStatsItem} of the bugreport.
66      */
setWifiStats(DumpsysWifiStatsItem wifiStats)67     public void setWifiStats(DumpsysWifiStatsItem wifiStats) {
68         setAttribute(WIFI_STATS, wifiStats);
69     }
70 
71     /**
72      * Get the {@link DumpsysBatteryStatsItem} of the bugreport.
73      */
getBatteryStats()74     public DumpsysBatteryStatsItem getBatteryStats() {
75         return (DumpsysBatteryStatsItem) getAttribute(BATTERY_STATS);
76     }
77 
78     /** Get the {@link DumpsysPackageStatsItem} of the bugreport. */
getPackageStats()79     public DumpsysPackageStatsItem getPackageStats() {
80         return (DumpsysPackageStatsItem) getAttribute(PACKAGE_STATS);
81     }
82 
83     /** Get the {@link DumpsysProcStatsItem} of the bugreport. */
getProcStats()84     public DumpsysProcStatsItem getProcStats() {
85         return (DumpsysProcStatsItem) getAttribute(PROC_STATS);
86     }
87 
88     /**
89      * Get the {@link DumpsysWifiStatsItem} of the bugreport.
90      */
getWifiStats()91     public DumpsysWifiStatsItem getWifiStats() {
92         return (DumpsysWifiStatsItem) getAttribute(WIFI_STATS);
93     }
94 }
95