1// Copyright (C) 2021 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import { 16 oneOf, 17 num, 18 bool, 19 arrayOf, 20 str, 21 requiredStr, 22 record, 23 runValidator, 24 ValidatedType, 25} from './validators'; 26 27const recordModes = ['STOP_WHEN_FULL', 'RING_BUFFER', 'LONG_TRACE'] as const; 28export const recordConfigValidator = record({ 29 mode: oneOf(recordModes, 'STOP_WHEN_FULL'), 30 durationMs: num(10000.0), 31 maxFileSizeMb: num(100), 32 fileWritePeriodMs: num(2500), 33 bufferSizeMb: num(64.0), 34 35 cpuSched: bool(), 36 cpuFreq: bool(), 37 cpuFreqPollMs: num(1000), 38 cpuSyscall: bool(), 39 40 gpuFreq: bool(), 41 gpuMemTotal: bool(), 42 43 ftrace: bool(), 44 atrace: bool(), 45 ftraceEvents: arrayOf(str()), 46 ftraceExtraEvents: str(), 47 atraceCats: arrayOf(str()), 48 allAtraceApps: bool(true), 49 atraceApps: str(), 50 ftraceBufferSizeKb: num(0), 51 ftraceDrainPeriodMs: num(0), 52 androidLogs: bool(), 53 androidLogBuffers: arrayOf(str()), 54 androidFrameTimeline: bool(), 55 androidGameInterventionList: bool(), 56 androidNetworkTracing: bool(), 57 androidNetworkTracingPollMs: num(250), 58 59 cpuCoarse: bool(), 60 cpuCoarsePollMs: num(1000), 61 62 batteryDrain: bool(), 63 batteryDrainPollMs: num(1000), 64 65 boardSensors: bool(), 66 67 memHiFreq: bool(), 68 meminfo: bool(), 69 meminfoPeriodMs: num(1000), 70 meminfoCounters: arrayOf(str()), 71 72 vmstat: bool(), 73 vmstatPeriodMs: num(1000), 74 vmstatCounters: arrayOf(str()), 75 76 heapProfiling: bool(), 77 hpSamplingIntervalBytes: num(4096), 78 hpProcesses: str(), 79 hpContinuousDumpsPhase: num(), 80 hpContinuousDumpsInterval: num(), 81 hpSharedMemoryBuffer: num(8 * 1048576), 82 hpBlockClient: bool(true), 83 hpAllHeaps: bool(), 84 85 javaHeapDump: bool(), 86 jpProcesses: str(), 87 jpContinuousDumpsPhase: num(), 88 jpContinuousDumpsInterval: num(), 89 90 memLmk: bool(), 91 procStats: bool(), 92 procStatsPeriodMs: num(1000), 93 94 chromeCategoriesSelected: arrayOf(str()), 95 chromeHighOverheadCategoriesSelected: arrayOf(str()), 96 chromePrivacyFiltering: bool(), 97 98 chromeLogs: bool(), 99 taskScheduling: bool(), 100 ipcFlows: bool(), 101 jsExecution: bool(), 102 webContentRendering: bool(), 103 uiRendering: bool(), 104 inputEvents: bool(), 105 navigationAndLoading: bool(), 106 107 symbolizeKsyms: bool(), 108}); 109export const namedRecordConfigValidator = record( 110 {title: requiredStr, key: requiredStr, config: recordConfigValidator}); 111export type NamedRecordConfig = 112 ValidatedType<typeof namedRecordConfigValidator>; 113export type RecordConfig = ValidatedType<typeof recordConfigValidator>; 114 115export function createEmptyRecordConfig(): RecordConfig { 116 return runValidator(recordConfigValidator, {}).result; 117} 118