1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
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 */
15
16#ifndef HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
17#define HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
18
19#include <map>
20#include <memory>
21#include <optional>
22#include "hitrace_meter.h"
23#include "resource/memory.h"
24#include "hidebug/hidebug_type.h"
25
26namespace OHOS {
27namespace HiviewDFX {
28enum MemoryState {
29    MEMORY_FAILED = -1,
30    MEMORY_SUCCESS = 0,
31};
32
33class HidebugNativeInterface {
34public:
35    static std::unique_ptr<HidebugNativeInterface> CreateInstance();
36    virtual ~HidebugNativeInterface() = default;
37
38    /**
39     * GetSystemCpuUsage
40     *
41     * @return the cpu usage of the system
42     */
43    virtual std::optional<double> GetSystemCpuUsage() = 0;
44
45    virtual double GetCpuUsage() = 0;
46    virtual std::map<uint32_t, double> GetAppThreadCpuUsage() = 0;
47    virtual HiDebug_ErrorCode StartAppTraceCapture(uint64_t tags, uint32_t flag,
48        uint32_t limitsize, std::string &file) = 0;
49    virtual HiDebug_ErrorCode StopAppTraceCapture() = 0;
50    virtual int GetMemoryLeakResource(const std::string& type, int32_t value, bool enabledDebugLog) = 0;
51    virtual std::optional<MemoryLimit> GetAppMemoryLimit() = 0;
52    virtual std::optional<HiDebug_NativeMemInfo> GetAppNativeMemInfo() = 0;
53    virtual std::optional<SysMemory> GetSystemMemInfo() = 0;
54    virtual bool IsDebuggerConnected() = 0;
55    virtual std::optional<int32_t> GetGraphicsMemory() = 0;
56};
57}
58}
59
60#endif  // HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
61