1 /*
2  * Copyright (C) 2010 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.tradefed.result;
17 
18 /** Represents the data type of log data. */
19 public enum LogDataType {
20     TEXT("txt", "text/plain", false, true),
21     UIX("uix", "text/xml", false, true),
22     XML("xml", "text/xml", false, true),
23     HTML("html", "text/html", true, true),
24     PNG("png", "image/png", true, false),
25     MP4("mp4", "video/mp4", true, false),
26     EAR("ear", "application/octet-stream", true, false),
27     ZIP("zip", "application/zip", true, false),
28     SEVEN_Z("7z", "application/x-7z-compressed", true, false),
29     BITS("bits", "application/octet-stream", true, false),
30     JPEG("jpeg", "image/jpeg", true, false),
31     TAR_GZ("tar.gz", "application/gzip", true, false),
32     GZIP("gz", "application/gzip", true, false),
33     HPROF("hprof", "application/octet-stream", true, false),
34     COVERAGE("ec", "text/plain", true /* do not compress */, false), // Emma coverage file
35     NATIVE_COVERAGE("zip", "application/zip", true, false), // gcov coverage archive
36     CLANG_COVERAGE(
37             "profdata",
38             "text/plain",
39             true /* do not compress */,
40             false), // LLVM indexed profile data
41     GCOV_KERNEL_COVERAGE(
42             "tar.gz",
43             "application/gzip",
44             true /* do not compress */,
45             false), // GCOV debugfs coverage archive
46     PB("pb", "application/octet-stream", true, false), // Binary proto file
47     TEXTPB("textproto", "text/plain", false, true), // Text proto file
48     JSON("json", "application/json", false, true),
49     PERFETTO(
50             "perfetto-trace",
51             "application/octet-stream",
52             false, // Not compressed by default, so we can gzip them
53             false), // binary proto perfetto trace file
54     TRACE(
55             "trace",
56             "application/octet-stream",
57             false, // Not compressed by default, so we can gzip them
58             false), // binary method trace file
59     /* Specific text file types */
60     ANRS("txt", "text/plain", true, true),
61     BUGREPORT("txt", "text/plain", false, true),
62     BUGREPORTZ("zip", "application/zip", true, false),
63     HOST_LOG("txt", "text/plain", true, true),
64     LOGCAT("txt", "text/plain", true, true),
65     KERNEL_LOG("txt", "text/plain", true, true),
66     MONKEY_LOG("txt", "text/plain", false, true),
67     MUGSHOT_LOG("txt", "text/plain", false, true),
68     CB_METRICS_FILE(
69             "txt",
70             "text/plain",
71             true /* TODO(b/228497046): Allow compression when supported */,
72             true),
73     PROCRANK("txt", "text/plain", false, true),
74     MEM_INFO("txt", "text/plain", false, true),
75     TOP("txt", "text/plain", false, true),
76     DUMPSYS("txt", "text/plain", false, true),
77     DUMPTRACE("txt", "text/plain", true, true),
78     COMPACT_MEMINFO("txt", "text/plain", false, true), // dumpsys meminfo -c
79     SERVICES("txt", "text/plain", false, true), // dumpsys activity services
80     GFX_INFO("txt", "text/plain", false, true), // dumpsys gfxinfo
81     CPU_INFO("txt", "text/plain", false, true), // dumpsys cpuinfo
82     JACOCO_CSV("csv", "text/csv", false, true), // JaCoCo coverage report in CSV format
83     JACOCO_XML("xml", "text/xml", false, true), // JaCoCo coverage report in XML format
84     JACOCO_EXEC("exec", "application/octet-stream", false, false), // JaCoCo coverage execution file
85     ATRACE("atr", "text/plain", true, false), // atrace -z format
86     KERNEL_TRACE("dat", "text/plain", false, false), // raw kernel ftrace buffer
87     DIR("", "text/plain", false, false),
88     CFG("cfg", "application/octet-stream", false, true),
89     TF_EVENTS("txt", "text/plain", true, true),
90     HARNESS_STD_LOG("txt", "text/plain", true, true),
91     HARNESS_CONFIG("xml", "text/xml", true, true),
92     ADB_HOST_LOG("txt", "text/plain", true, true),
93     PASSED_TESTS("txt", "text/plain", true, true),
94     RECOVERY_MODE_LOG("txt", "text/plain", false, true),
95     GOLDEN_RESULT_PROTO(
96             "textproto",
97             "text/plain",
98             true, // b/230070438: don't compress this file
99             true), // ScreenshotTest proto result
100     CUTTLEFISH_LOG("txt", "text/plain", true, true), // Log from cuttlefish instance
101     TOMBSTONEZ("zip", "application/zip", true, false),
102     BT_SNOOP_LOG("log", "application/octet-stream", false, false), // Bluetooth HCI snoop logs
103     /* Unknown file type */
104     UNKNOWN("dat", "text/plain", false, false);
105 
106     private final String mFileExt; // Usual extension of the file type
107     private final String mContentType;
108     // If the type is already compressed or should never be compressed
109     private final boolean mIsCompressedOrNeverCompress;
110     private final boolean mIsText;
111 
LogDataType( String fileExt, String contentType, boolean isCompressedOrNeverCompress, boolean text)112     LogDataType(
113             String fileExt, String contentType, boolean isCompressedOrNeverCompress, boolean text) {
114         mFileExt = fileExt;
115         mIsCompressedOrNeverCompress = isCompressedOrNeverCompress;
116         mIsText = text;
117         mContentType = contentType;
118     }
119 
getFileExt()120     public String getFileExt() {
121         return mFileExt;
122     }
123 
getContentType()124     public String getContentType() {
125         return mContentType;
126     }
127 
128     /**
129      * @return <code>true</code> if data type is a compressed format or should not be compressed.
130      */
isCompressed()131     public boolean isCompressed() {
132         return mIsCompressedOrNeverCompress;
133     }
134 
135     /**
136      * @return <code>true</code> if data type is a textual format.
137      */
isText()138     public boolean isText() {
139         return mIsText;
140     }
141 }
142