• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved.
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 #ifndef SANITIZER_TELEMETRY_H
16 #define SANITIZER_TELEMETRY_H
17 
18 #include <string>
19 #include "singleton.h"
20 #include "event.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 struct GwpTelemetryEvent {
25     std::string telemetryId;
26     uint64_t fault { 0 };
27     std::string bundleName;
28     std::string gwpEnable;
29     std::string gwpSampleRate;
30     std::string gwpMaxSlots;
31     std::string minSampleSize;
32     std::string stackParam;
33 };
34 
35 class SanitizerTelemetry {
36 public:
37     void OnUnorderedEvent(const Event& msg);
38 private:
39     void HandleTelemetryStart(const Event& msg);
40     void SetTelemetryParam(const GwpTelemetryEvent& gwpTelemetryEvent);
41     void ClearTelemetryParam(const std::string& bundleName);
42     void ClearThirdPartyTelemetryParam(const std::string& bundleName);
43     void SetIfTelemetryExist(const std::string& key, const std::string& value);
44     void ClearIfParameterSet(const std::string& key);
45     bool IsOverTelemetryAppNum(const std::string& bundleName);
46     uint64_t GetThirdPartyDurationDay(const std::string& bundleName);
47     uint64_t GetThirdPartyBeginTime(const std::string& bundleName);
48     uint64_t GetTelemetryAppNum();
49     bool SafeStoll(const std::string& str, long long& value);
50 };
51 }  // namespace HiviewDFX
52 }  // namespace OHOS
53 #endif // SANITIZER_TELEMETRY_H