1/*
2 * Copyright 2020, 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
17import {TRACE_TYPES, DUMP_TYPES} from '@/decode.js';
18
19const mixin = {
20  showInTraceView(file) {
21    return file.type == TRACE_TYPES.WINDOW_MANAGER ||
22      file.type == TRACE_TYPES.ACCESSIBILITY ||
23      file.type == TRACE_TYPES.SURFACE_FLINGER ||
24      file.type == TRACE_TYPES.WAYLAND ||
25      file.type == TRACE_TYPES.SYSTEM_UI ||
26      file.type == TRACE_TYPES.LAUNCHER ||
27      file.type == TRACE_TYPES.IME_CLIENTS ||
28      file.type == TRACE_TYPES.IME_SERVICE ||
29      file.type == TRACE_TYPES.IME_MANAGERSERVICE ||
30      file.type == DUMP_TYPES.WINDOW_MANAGER ||
31      file.type == DUMP_TYPES.SURFACE_FLINGER ||
32      file.type == DUMP_TYPES.WAYLAND;
33  },
34  showInAccessibilityTraceView(file) {
35    return file.type == TRACE_TYPES.ACCESSIBILITY;
36  },
37  showInWindowManagerTraceView(file) {
38    return file.type == TRACE_TYPES.WINDOW_MANAGER ||
39        file.type == DUMP_TYPES.WINDOW_MANAGER;
40  },
41  showInSurfaceFlingerTraceView(file) {
42    return file.type == TRACE_TYPES.SURFACE_FLINGER ||
43        file.type == DUMP_TYPES.SURFACE_FLINGER;
44  },
45  isVideo(file) {
46    return file.type == TRACE_TYPES.SCREEN_RECORDING;
47  },
48  isTransactions(file) {
49    return file.type == TRACE_TYPES.TRANSACTION;
50  },
51  isLog(file) {
52    return file.type == TRACE_TYPES.PROTO_LOG;
53  },
54  hasDataView(file) {
55    return this.isLog(file) || this.showInTraceView(file) ||
56      this.isTransactions(file);
57  },
58};
59
60export {mixin};
61
62export default {
63  name: 'FileType',
64  methods: mixin,
65};
66