106f6ba60Sopenharmony_ci/*
206f6ba60Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License.
506f6ba60Sopenharmony_ci * You may obtain a copy of the License at
606f6ba60Sopenharmony_ci *
706f6ba60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
806f6ba60Sopenharmony_ci *
906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and
1306f6ba60Sopenharmony_ci * limitations under the License.
1406f6ba60Sopenharmony_ci */
1506f6ba60Sopenharmony_ci
1606f6ba60Sopenharmony_ci#ifndef HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
1706f6ba60Sopenharmony_ci#define HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
1806f6ba60Sopenharmony_ci
1906f6ba60Sopenharmony_ci#include <map>
2006f6ba60Sopenharmony_ci#include <memory>
2106f6ba60Sopenharmony_ci#include <optional>
2206f6ba60Sopenharmony_ci#include "hitrace_meter.h"
2306f6ba60Sopenharmony_ci#include "resource/memory.h"
2406f6ba60Sopenharmony_ci#include "hidebug/hidebug_type.h"
2506f6ba60Sopenharmony_ci
2606f6ba60Sopenharmony_cinamespace OHOS {
2706f6ba60Sopenharmony_cinamespace HiviewDFX {
2806f6ba60Sopenharmony_cienum MemoryState {
2906f6ba60Sopenharmony_ci    MEMORY_FAILED = -1,
3006f6ba60Sopenharmony_ci    MEMORY_SUCCESS = 0,
3106f6ba60Sopenharmony_ci};
3206f6ba60Sopenharmony_ci
3306f6ba60Sopenharmony_ciclass HidebugNativeInterface {
3406f6ba60Sopenharmony_cipublic:
3506f6ba60Sopenharmony_ci    static std::unique_ptr<HidebugNativeInterface> CreateInstance();
3606f6ba60Sopenharmony_ci    virtual ~HidebugNativeInterface() = default;
3706f6ba60Sopenharmony_ci
3806f6ba60Sopenharmony_ci    /**
3906f6ba60Sopenharmony_ci     * GetSystemCpuUsage
4006f6ba60Sopenharmony_ci     *
4106f6ba60Sopenharmony_ci     * @return the cpu usage of the system
4206f6ba60Sopenharmony_ci     */
4306f6ba60Sopenharmony_ci    virtual std::optional<double> GetSystemCpuUsage() = 0;
4406f6ba60Sopenharmony_ci
4506f6ba60Sopenharmony_ci    virtual double GetCpuUsage() = 0;
4606f6ba60Sopenharmony_ci    virtual std::map<uint32_t, double> GetAppThreadCpuUsage() = 0;
4706f6ba60Sopenharmony_ci    virtual HiDebug_ErrorCode StartAppTraceCapture(uint64_t tags, uint32_t flag,
4806f6ba60Sopenharmony_ci        uint32_t limitsize, std::string &file) = 0;
4906f6ba60Sopenharmony_ci    virtual HiDebug_ErrorCode StopAppTraceCapture() = 0;
5006f6ba60Sopenharmony_ci    virtual int GetMemoryLeakResource(const std::string& type, int32_t value, bool enabledDebugLog) = 0;
5106f6ba60Sopenharmony_ci    virtual std::optional<MemoryLimit> GetAppMemoryLimit() = 0;
5206f6ba60Sopenharmony_ci    virtual std::optional<HiDebug_NativeMemInfo> GetAppNativeMemInfo() = 0;
5306f6ba60Sopenharmony_ci    virtual std::optional<SysMemory> GetSystemMemInfo() = 0;
5406f6ba60Sopenharmony_ci    virtual bool IsDebuggerConnected() = 0;
5506f6ba60Sopenharmony_ci    virtual std::optional<int32_t> GetGraphicsMemory() = 0;
5606f6ba60Sopenharmony_ci};
5706f6ba60Sopenharmony_ci}
5806f6ba60Sopenharmony_ci}
5906f6ba60Sopenharmony_ci
6006f6ba60Sopenharmony_ci#endif  // HIVIEWDFX_HIDEBUG_NATIVE_INTERFACE_H
61