mirror of
https://github.com/openharmony/miscservices_pasteboard.git
synced 2026-07-01 03:23:18 -04:00
Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>
Changes to be committed:
This commit is contained in:
@@ -48,6 +48,7 @@ INITIALIZATION_FAULT:
|
||||
TIME_CONSUMING_STATISTIC:
|
||||
__BASE: {type: STATISTIC, level: MINOR, desc: The event is api visit statistic }
|
||||
PASTEBOARD_STATE: {type: STRING, desc: Pasteboard state }
|
||||
DATA_LEVLE: {type: STRING, desc: Data level }
|
||||
CONSUMING_DATA: {type: STRING, desc: Consuming data }
|
||||
|
||||
PASTEBOARD_BEHAVIOUR:
|
||||
|
||||
@@ -76,38 +76,27 @@ int CalculateTimeConsuming::CalculateData(size_t calPasteboardData) const
|
||||
int CalculateTimeConsuming::CalculateTime(uint64_t time)
|
||||
{
|
||||
constexpr int FIVE_HUNDRED_MS = 500;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_ZERO = 0;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_ONE = 1;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_TWO = 2;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_THREE = 3;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_FOUR = 4;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_FIVE = 5;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_SIX = 6;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_SEVEN = 7;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_EIGHT = 8;
|
||||
constexpr int PER_FIVE_HUNDRED_MS_NINE = 9;
|
||||
|
||||
uint64_t timeCosuming = time % FIVE_HUNDRED_MS;
|
||||
switch (timeCosuming) {
|
||||
case PER_FIVE_HUNDRED_MS_ZERO:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_ZERO:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_ONE);
|
||||
case PER_FIVE_HUNDRED_MS_ONE:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_ONE:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_TWO);
|
||||
case PER_FIVE_HUNDRED_MS_TWO:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_TWO:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_THREE);
|
||||
case PER_FIVE_HUNDRED_MS_THREE:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_THREE:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_FOUR);
|
||||
case PER_FIVE_HUNDRED_MS_FOUR:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_FOUR:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_FIVE);
|
||||
case PER_FIVE_HUNDRED_MS_FIVE:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_FIVE:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_SIX);
|
||||
case PER_FIVE_HUNDRED_MS_SIX:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_SIX:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_SEVEN);
|
||||
case PER_FIVE_HUNDRED_MS_SEVEN:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_SEVEN:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_EIGHT);
|
||||
case PER_FIVE_HUNDRED_MS_EIGHT:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_EIGHT:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_NINE);
|
||||
case PER_FIVE_HUNDRED_MS_NINE:
|
||||
case TimeLevelTen::PER_FIVE_HUNDRED_MS_NINE:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_TEN);
|
||||
default:
|
||||
return static_cast<int>(Fault::TCS_TIME_CONSUMING_LEVEL_ELEVEN);
|
||||
|
||||
@@ -22,6 +22,19 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum TimeLevelTen : std::int32_t {
|
||||
PER_FIVE_HUNDRED_MS_ZERO = 0,
|
||||
PER_FIVE_HUNDRED_MS_ONE,
|
||||
PER_FIVE_HUNDRED_MS_TWO,
|
||||
PER_FIVE_HUNDRED_MS_THREE,
|
||||
PER_FIVE_HUNDRED_MS_FOUR,
|
||||
PER_FIVE_HUNDRED_MS_FIVE,
|
||||
PER_FIVE_HUNDRED_MS_SIX,
|
||||
PER_FIVE_HUNDRED_MS_SEVEN,
|
||||
PER_FIVE_HUNDRED_MS_EIGHT,
|
||||
PER_FIVE_HUNDRED_MS_NINE,
|
||||
};
|
||||
|
||||
class CalculateTimeConsuming : public Singleton<CalculateTimeConsuming> {
|
||||
public:
|
||||
CalculateTimeConsuming(const size_t calPasteboardData, const int calPasteboardState);
|
||||
|
||||
@@ -22,37 +22,33 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum class Fault {
|
||||
enum Fault : std::int32_t{
|
||||
// Time Consuming Stat
|
||||
TCS_COPY_STATE = 47,
|
||||
TCS_PASTE_STATE = 48,
|
||||
TCS_DEVICES_PASTE_WIFI_STATE = 49,
|
||||
TCS_DEVICES_PASTE_BTONLY_STATE = 50,
|
||||
TCS_PASTEBOARD_STATE = 51,
|
||||
|
||||
TCS_ZERO_TO_HUNDRED_KB = 52,
|
||||
TCS_HUNDRED_TO_FIVE_HUNDREDS_KB = 53,
|
||||
TCS_FIVE_HUNDREDS_TO_THOUSAND_KB = 54,
|
||||
TCS_ONE_TO_FIVE_MB = 56,
|
||||
TCS_FIVE_TO_TEN_MB = 55,
|
||||
TCS_TEN_TO_FIFTY_MB = 57,
|
||||
TCS_OVER_FIFTY_MB = 58,
|
||||
|
||||
TCS_TIME_CONSUMING_LEVEL_ONE = 59,
|
||||
TCS_TIME_CONSUMING_LEVEL_TWO = 60,
|
||||
TCS_TIME_CONSUMING_LEVEL_THREE = 61,
|
||||
TCS_TIME_CONSUMING_LEVEL_FOUR = 62,
|
||||
TCS_TIME_CONSUMING_LEVEL_FIVE = 63,
|
||||
TCS_TIME_CONSUMING_LEVEL_SIX = 64,
|
||||
TCS_TIME_CONSUMING_LEVEL_SEVEN = 65,
|
||||
TCS_TIME_CONSUMING_LEVEL_EIGHT = 66,
|
||||
TCS_TIME_CONSUMING_LEVEL_NINE = 67,
|
||||
TCS_TIME_CONSUMING_LEVEL_TEN = 68,
|
||||
TCS_TIME_CONSUMING_LEVEL_ELEVEN = 69,
|
||||
|
||||
// Pasteboard Behaviour
|
||||
PB_COPY_STATE = 70,
|
||||
PB_PASTE_STATE = 71,
|
||||
TCS_COPY_STATE = 0,
|
||||
TCS_PASTE_STATE,
|
||||
TCS_DEVICES_PASTE_WIFI_STATE,
|
||||
TCS_DEVICES_PASTE_BTONLY_STATE,
|
||||
TCS_PASTEBOARD_STATE,
|
||||
TCS_ZERO_TO_HUNDRED_KB,
|
||||
TCS_HUNDRED_TO_FIVE_HUNDREDS_KB,
|
||||
TCS_FIVE_HUNDREDS_TO_THOUSAND_KB,
|
||||
TCS_ONE_TO_FIVE_MB,
|
||||
TCS_FIVE_TO_TEN_MB,
|
||||
TCS_TEN_TO_FIFTY_MB,
|
||||
TCS_OVER_FIFTY_MB,
|
||||
TCS_TIME_CONSUMING_LEVEL_ONE,
|
||||
TCS_TIME_CONSUMING_LEVEL_TWO,
|
||||
TCS_TIME_CONSUMING_LEVEL_THREE,
|
||||
TCS_TIME_CONSUMING_LEVEL_FOUR,
|
||||
TCS_TIME_CONSUMING_LEVEL_FIVE,
|
||||
TCS_TIME_CONSUMING_LEVEL_SIX,
|
||||
TCS_TIME_CONSUMING_LEVEL_SEVEN,
|
||||
TCS_TIME_CONSUMING_LEVEL_EIGHT,
|
||||
TCS_TIME_CONSUMING_LEVEL_NINE,
|
||||
TCS_TIME_CONSUMING_LEVEL_TEN,
|
||||
TCS_TIME_CONSUMING_LEVEL_ELEVEN,
|
||||
PB_COPY_STATE,
|
||||
PB_PASTE_STATE,
|
||||
};
|
||||
|
||||
struct InitializationFaultMsg {
|
||||
|
||||
@@ -16,49 +16,18 @@
|
||||
#define LOG_TAG "HiViewAdapter"
|
||||
|
||||
#include "hiview_adapter.h"
|
||||
#include <thread>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "def.h"
|
||||
#include "pasteboard_hilog_wreapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
using namespace HiviewDFX;
|
||||
namespace MiscServices {
|
||||
namespace {
|
||||
// fault key
|
||||
constexpr const char *USER_ID = "USER_ID";
|
||||
constexpr const char *ERROR_TYPE = "ERROR_TYPE";
|
||||
// statistic key
|
||||
constexpr const char *PASTEBOARD_STATE = "PASTEBOARD_STATE";
|
||||
|
||||
constexpr const char *ZERO_TO_HUNDRED_KB = "ZERO_TO_HUNDRED_KB";
|
||||
constexpr const char *HUNDRED_TO_FIVE_HUNDREDS_KB = "HUNDRED_TO_FIVE_HUNDREDS_KB";
|
||||
constexpr const char *FIVE_HUNDREDS_TO_THOUSAND_KB = "FIVE_HUNDREDS_TO_THOUSAND_KB";
|
||||
constexpr const char *ONE_TO_FIVE_MB = "ONE_TO_FIVE_MB";
|
||||
constexpr const char *FIVE_TO_TEN_MB = "FIVE_TO_TEN_MB";
|
||||
constexpr const char *TEN_TO_FIFTY_MB = "TEN_TO_FIFTY_MB";
|
||||
constexpr const char *OVER_FIFTY_MB = "OVER_FIFTY_MB";
|
||||
constexpr const char *CONSUMING_DATA = "CONSUMING_DATA";
|
||||
constexpr const char *DATA_LEVEL = "DATA_LEVEL";
|
||||
// behaviour key
|
||||
constexpr const char *TOP_ONE_APP = "TOP_ONE_APP";
|
||||
constexpr const char *TOP_TOW_APP = "TOP_TOW_APP";
|
||||
constexpr const char *TOP_THREE_APP = "TOP_THREE_APP";
|
||||
constexpr const char *TOP_FOUR_APP = "TOP_FOUR_APP";
|
||||
constexpr const char *TOP_FIVE_APP = "TOP_FIVE_APP";
|
||||
constexpr const char *TOP_SIX_APP = "TOP_SIX_APP";
|
||||
constexpr const char *TOP_SEVEN_APP = "TOP_SEVEN_APP";
|
||||
constexpr const char *TOP_EIGHT_APP = "TOP_EIGHT_APP";
|
||||
constexpr const char *TOP_NINE_APP = "TOP_NINE_APP";
|
||||
constexpr const char *TOP_TEN_APP = "TOP_TEN_APP";
|
||||
|
||||
constexpr const char *WRONG_LEVEL = "WRONG_LEVEL";
|
||||
|
||||
constexpr const char *COPY_STATE = "COPY_STATE";
|
||||
constexpr const char *PASTE_STATE = "PASTE_STATE";
|
||||
|
||||
constexpr const int INIT_COPY_TIME_SONSUMING = 7;
|
||||
constexpr const int INIT_PASTE_TIME_SONSUMING = 8;
|
||||
|
||||
const std::map<int, std::string> EVENT_COVERT_TABLE = {
|
||||
{ DfxCodeConstant::INITIALIZATION_FAULT, "INITIALIZATION_FAULT" },
|
||||
{ DfxCodeConstant::TIME_CONSUMING_STATISTIC, "TIME_CONSUMING_STATISTIC" },
|
||||
@@ -130,6 +99,8 @@ std::map<int, int> HiViewAdapter::InitTimeMap()
|
||||
|
||||
void HiViewAdapter::ReportInitializationFault(int dfxCode, const InitializationFaultMsg &msg)
|
||||
{
|
||||
constexpr const char *USER_ID = "USER_ID";
|
||||
constexpr const char *ERROR_TYPE = "ERROR_TYPE";
|
||||
int ret = HiSysEvent::Write(DOMAIN_STR, CoverEventID(dfxCode), HiSysEvent::EventType::FAULT, USER_ID, msg.userId,
|
||||
ERROR_TYPE, msg.errorCode);
|
||||
if (ret != 0) {
|
||||
@@ -273,6 +244,7 @@ void HiViewAdapter::ReportPasteboardBehaviour(const PasteboardBehaviourMsg &msg)
|
||||
|
||||
const char *HiViewAdapter::GetDataLevel(int dataLevel)
|
||||
{
|
||||
constexpr const char *WRONG_LEVEL = "WRONG_LEVEL";
|
||||
switch (dataLevel) {
|
||||
case static_cast<int>(DataConsumingLevel::DATA_LEVEL_ONE): {
|
||||
return ZERO_TO_HUNDRED_KB;
|
||||
@@ -311,27 +283,24 @@ void HiViewAdapter::InvokeTimeConsuming()
|
||||
}
|
||||
|
||||
void HiViewAdapter::ReportStatisticEvent(
|
||||
std::vector<std::map<int, int>> &timeConsumingStat, std::string pasteboardState)
|
||||
const std::vector<std::map<int, int>> &timeConsumingStat, const std::string &pasteboardState)
|
||||
{
|
||||
if (timeConsumingStat.empty()) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "hisysevent timeConsumingStat is empty.");
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
for (auto iter = timeConsumingStat.begin(); iter != timeConsumingStat.end(); ++iter) {
|
||||
for (std::int32_t i = 0; i < static_cast<int>(timeConsumingStat.size()); ++i) {
|
||||
std::string buffMsg = ": [";
|
||||
for (int j = static_cast<int>(TimeConsumingLevel::TIME_LEVEL_ONE);
|
||||
j <= static_cast<int>(TimeConsumingLevel::TIME_LEVEL_ELEVEN); ++j) {
|
||||
buffMsg = buffMsg + std::to_string((*iter)[j]) + ",";
|
||||
for (std::int32_t j = TimeConsumingLevel::TIME_LEVEL_ONE; j <= TimeConsumingLevel::TIME_LEVEL_ELEVEN; ++j) {
|
||||
buffMsg = buffMsg + std::to_string(timeConsumingStat[i].at(j)) + ",";
|
||||
}
|
||||
buffMsg += "]";
|
||||
int ret = HiSysEvent::Write(DOMAIN_STR, CoverEventID(DfxCodeConstant::TIME_CONSUMING_STATISTIC),
|
||||
HiSysEvent::EventType::STATISTIC, PASTEBOARD_STATE, pasteboardState, DATA_LEVEL, GetDataLevel(i),
|
||||
CONSUMING_DATA, buffMsg);
|
||||
if (ret != 0) {
|
||||
if (ret != HiviewDFX::SUCCESS) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "hisysevent write failed! ret %{public}d.", ret);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +345,7 @@ void HiViewAdapter::ReportBehaviour(std::map<std::string, int> &behaviour, const
|
||||
TOP_EIGHT_APP, appPackName[7],
|
||||
TOP_NINE_APP, appPackName[8],
|
||||
TOP_TEN_APP, appPackName[9]);
|
||||
if (ret != 0) {
|
||||
if (ret != HiviewDFX::SUCCESS) {
|
||||
PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "hisysevent write failed! ret %{public}d.", ret);
|
||||
}
|
||||
behaviour.clear();
|
||||
|
||||
@@ -28,27 +28,27 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum class DataConsumingLevel {
|
||||
enum DataConsumingLevel : std::int32_t {
|
||||
DATA_LEVEL_ONE = 0,
|
||||
DATA_LEVEL_TWO = 1,
|
||||
DATA_LEVEL_THREE = 2,
|
||||
DATA_LEVEL_FOUR = 3,
|
||||
DATA_LEVEL_FIVE = 4,
|
||||
DATA_LEVEL_SIX = 5,
|
||||
DATA_LEVEL_SEVEN = 6,
|
||||
DATA_LEVEL_TWO,
|
||||
DATA_LEVEL_THREE,
|
||||
DATA_LEVEL_FOUR,
|
||||
DATA_LEVEL_FIVE,
|
||||
DATA_LEVEL_SIX,
|
||||
DATA_LEVEL_SEVEN,
|
||||
};
|
||||
enum class TimeConsumingLevel {
|
||||
TIME_LEVEL_ONE = 9,
|
||||
TIME_LEVEL_TWO = 10,
|
||||
TIME_LEVEL_THREE = 11,
|
||||
TIME_LEVEL_FOUR = 12,
|
||||
TIME_LEVEL_FIVE = 13,
|
||||
TIME_LEVEL_SIX = 14,
|
||||
TIME_LEVEL_SEVEN = 15,
|
||||
TIME_LEVEL_EIGHT = 16,
|
||||
TIME_LEVEL_NINE = 17,
|
||||
TIME_LEVEL_TEN = 18,
|
||||
TIME_LEVEL_ELEVEN = 19,
|
||||
enum TimeConsumingLevel : std::int32_t {
|
||||
TIME_LEVEL_ONE = 0,
|
||||
TIME_LEVEL_TWO,
|
||||
TIME_LEVEL_THREE,
|
||||
TIME_LEVEL_FOUR,
|
||||
TIME_LEVEL_FIVE,
|
||||
TIME_LEVEL_SIX,
|
||||
TIME_LEVEL_SEVEN,
|
||||
TIME_LEVEL_EIGHT,
|
||||
TIME_LEVEL_NINE,
|
||||
TIME_LEVEL_TEN,
|
||||
TIME_LEVEL_ELEVEN,
|
||||
};
|
||||
|
||||
class HiViewAdapter {
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
static const char *GetDataLevel(int dataLevel);
|
||||
static void InvokeTimeConsuming();
|
||||
static void ReportBehaviour(std::map<std::string, int> &behaviour, const char *statePasteboard);
|
||||
static void ReportStatisticEvent(std::vector<std::map<int, int>> &timeConsumingStat, std::string pasteboardState);
|
||||
static void ReportStatisticEvent(const std::vector<std::map<int, int>> &timeConsumingStat, const std::string &pasteboardState);
|
||||
|
||||
static std::mutex timeConsumingMutex_;
|
||||
static std::vector<std::map<int, int>> copyTimeConsumingStat_;
|
||||
@@ -94,6 +94,36 @@ private:
|
||||
static inline constexpr int EXEC_MIN_TIME = 60;
|
||||
static inline constexpr int ONE_MINUTE_IN_SECONDS = 60;
|
||||
static inline constexpr int ONE_HOUR_IN_SECONDS = 1 * 60 * 60; // 1 hour
|
||||
|
||||
// statistic key
|
||||
static inline const char *PASTEBOARD_STATE = "PASTEBOARD_STATE";
|
||||
|
||||
static inline const char *ZERO_TO_HUNDRED_KB = "ZERO_TO_HUNDRED_KB";
|
||||
static inline const char *HUNDRED_TO_FIVE_HUNDREDS_KB = "HUNDRED_TO_FIVE_HUNDREDS_KB";
|
||||
static inline const char *FIVE_HUNDREDS_TO_THOUSAND_KB = "FIVE_HUNDREDS_TO_THOUSAND_KB";
|
||||
static inline const char *ONE_TO_FIVE_MB = "ONE_TO_FIVE_MB";
|
||||
static inline const char *FIVE_TO_TEN_MB = "FIVE_TO_TEN_MB";
|
||||
static inline const char *TEN_TO_FIFTY_MB = "TEN_TO_FIFTY_MB";
|
||||
static inline const char *OVER_FIFTY_MB = "OVER_FIFTY_MB";
|
||||
static inline const char *CONSUMING_DATA = "CONSUMING_DATA";
|
||||
static inline const char *DATA_LEVEL = "DATA_LEVEL";
|
||||
// behaviour key
|
||||
static inline const char *TOP_ONE_APP = "TOP_ONE_APP";
|
||||
static inline const char *TOP_TOW_APP = "TOP_TOW_APP";
|
||||
static inline const char *TOP_THREE_APP = "TOP_THREE_APP";
|
||||
static inline const char *TOP_FOUR_APP = "TOP_FOUR_APP";
|
||||
static inline const char *TOP_FIVE_APP = "TOP_FIVE_APP";
|
||||
static inline const char *TOP_SIX_APP = "TOP_SIX_APP";
|
||||
static inline const char *TOP_SEVEN_APP = "TOP_SEVEN_APP";
|
||||
static inline const char *TOP_EIGHT_APP = "TOP_EIGHT_APP";
|
||||
static inline const char *TOP_NINE_APP = "TOP_NINE_APP";
|
||||
static inline const char *TOP_TEN_APP = "TOP_TEN_APP";
|
||||
|
||||
static inline const char *COPY_STATE = "COPY_STATE";
|
||||
static inline const char *PASTE_STATE = "PASTE_STATE";
|
||||
|
||||
static inline const int INIT_COPY_TIME_SONSUMING = 7;
|
||||
static inline const int INIT_PASTE_TIME_SONSUMING = 8;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user