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#include "appspawn_hisysevent.h" 17#include "appspawn_utils.h" 18#include <chrono> 19#include "hisysevent.h" 20 21static constexpr char PERFORMANCE_DOMAIN[] = "PERFORMANCE"; 22const std::string CPU_SCENE_ENTRY = "CPU_SCENE_ENTRY"; 23const std::string PACKAGE_NAME = "PACKAGE_NAME"; 24const std::string SCENE_ID = "SCENE_ID"; 25const std::string HAPPEN_TIME = "HAPPEN_TIME"; 26const std::string APPSPAWN = "APPSPAWN"; 27void AppSpawnHiSysEventWrite() 28{ 29 auto now = std::chrono::system_clock::now(); 30 int64_t timeStamp = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count(); 31 int32_t sceneld = 0; 32 int ret = HiSysEventWrite(PERFORMANCE_DOMAIN, CPU_SCENE_ENTRY, 33 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 34 PACKAGE_NAME, APPSPAWN, 35 SCENE_ID, std::to_string(sceneld).c_str(), 36 HAPPEN_TIME, timeStamp); 37 if (ret != 0) { 38 APPSPAWN_LOGI("HiSysEventWrite error,ret = %{public}d", ret); 39 } 40} 41