169570cc8Sopenharmony_ci/*
269570cc8Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
369570cc8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
469570cc8Sopenharmony_ci * you may not use this file except in compliance with the License.
569570cc8Sopenharmony_ci * You may obtain a copy of the License at
669570cc8Sopenharmony_ci *
769570cc8Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
869570cc8Sopenharmony_ci *
969570cc8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1069570cc8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1169570cc8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269570cc8Sopenharmony_ci * See the License for the specific language governing permissions and
1369570cc8Sopenharmony_ci * limitations under the License.
1469570cc8Sopenharmony_ci */
1569570cc8Sopenharmony_ci
1669570cc8Sopenharmony_ci#include "appspawn_hisysevent.h"
1769570cc8Sopenharmony_ci#include "appspawn_utils.h"
1869570cc8Sopenharmony_ci#include <chrono>
1969570cc8Sopenharmony_ci#include "hisysevent.h"
2069570cc8Sopenharmony_ci
2169570cc8Sopenharmony_cistatic constexpr char PERFORMANCE_DOMAIN[] = "PERFORMANCE";
2269570cc8Sopenharmony_ciconst std::string CPU_SCENE_ENTRY = "CPU_SCENE_ENTRY";
2369570cc8Sopenharmony_ciconst std::string PACKAGE_NAME = "PACKAGE_NAME";
2469570cc8Sopenharmony_ciconst std::string SCENE_ID = "SCENE_ID";
2569570cc8Sopenharmony_ciconst std::string HAPPEN_TIME = "HAPPEN_TIME";
2669570cc8Sopenharmony_ciconst std::string APPSPAWN = "APPSPAWN";
2769570cc8Sopenharmony_civoid AppSpawnHiSysEventWrite()
2869570cc8Sopenharmony_ci{
2969570cc8Sopenharmony_ci    auto now = std::chrono::system_clock::now();
3069570cc8Sopenharmony_ci    int64_t timeStamp = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
3169570cc8Sopenharmony_ci    int32_t sceneld = 0;
3269570cc8Sopenharmony_ci    int ret = HiSysEventWrite(PERFORMANCE_DOMAIN, CPU_SCENE_ENTRY,
3369570cc8Sopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
3469570cc8Sopenharmony_ci        PACKAGE_NAME, APPSPAWN,
3569570cc8Sopenharmony_ci        SCENE_ID, std::to_string(sceneld).c_str(),
3669570cc8Sopenharmony_ci        HAPPEN_TIME, timeStamp);
3769570cc8Sopenharmony_ci    if (ret != 0) {
3869570cc8Sopenharmony_ci        APPSPAWN_LOGI("HiSysEventWrite error,ret = %{public}d", ret);
3969570cc8Sopenharmony_ci    }
4069570cc8Sopenharmony_ci}
41