/* * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERFACES_INNER_API_UNIFIED_COLLECTION_CLIENT_TRACE_COLLECTOR_H #define INTERFACES_INNER_API_UNIFIED_COLLECTION_CLIENT_TRACE_COLLECTOR_H #include #include #include #include #include "collect_result.h" #include "trace_caller.h" namespace OHOS { namespace HiviewDFX { namespace UCollectClient { constexpr int32_t ACTION_ID_START_TRACE = 1; constexpr int32_t ACTION_ID_DUMP_TRACE = 2; struct AppCaller { int32_t actionId; // 1: start trace; 2: dump trace std::string bundleName; // app bundle name std::string bundleVersion; // app bundle version std::string threadName; // app thread name int32_t foreground; // app foreground int32_t uid; // app user id int32_t pid; // app process id int64_t happenTime; // jank happend time, millisecond unit int64_t beginTime; // message handle begin time, millisecond unit int64_t endTime; // message handle end time, millisecond unit bool isBusinessJank = false; // is business jank or not, control output file name }; class TraceCollector { public: TraceCollector() = default; virtual ~TraceCollector() = default; public: virtual CollectResult OpenSnapshot(const std::vector& tagGroups) = 0; virtual CollectResult> DumpSnapshot( UCollect::TraceCaller caller = UCollect::TraceCaller::OTHER) = 0; virtual CollectResult OpenRecording(const std::string& tags) = 0; virtual CollectResult RecordingOn() = 0; virtual CollectResult> RecordingOff() = 0; virtual CollectResult Close() = 0; virtual CollectResult Recover() = 0; // use for hap main looper virtual CollectResult CaptureDurationTrace(AppCaller &appCaller) = 0; static std::shared_ptr Create(); }; // TraceCollector } // UCollectClient } // HiviewDFX } // OHOS #endif // INTERFACES_INNER_API_UNIFIED_COLLECTION_CLIENT_TRACE_COLLECTOR_H