diff --git a/frameworks/native/light/src/light_client.cpp b/frameworks/native/light/src/light_client.cpp index ca9c65882119b441e3a2c9a69dc2dd5b3327238c..33d89a429b58635900449bde36609a792a35d3cf 100644 --- a/frameworks/native/light/src/light_client.cpp +++ b/frameworks/native/light/src/light_client.cpp @@ -66,7 +66,8 @@ int32_t LightClient::InitLightClient() CHKPR(remoteObject, MISC_NATIVE_GET_SERVICE_ERR); remoteObject->AddDeathRecipient(serviceDeathObserver_); lightInfoList_.clear(); - miscdeviceProxy_->GetLightList(lightInfoList_); + int32_t ret = miscdeviceProxy_->GetLightList(lightInfoList_); + WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode::COMMAND_GET_LIGHT_LIST, ret); return ERR_OK; } #ifdef HIVIEWDFX_HISYSEVENT_ENABLE @@ -107,6 +108,10 @@ void LightClient::WriteHiSysIPCEvent(IMiscdeviceServiceIpcCode code, int32_t ret HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOff", "ERROR_CODE", ret); break; + case IMiscdeviceServiceIpcCode::COMMAND_GET_LIGHT_LIST: + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "GetLightList", "ERROR_CODE", ret); + break; default: MISC_HILOGW("Code does not exist, code:%{public}d", static_cast(code)); break; diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp index 6d22d8046f0914ef2f260d2d2ab2a6f615c2051c..08f71c5fe26088ba572bef4b8abaaa03f2895e4b 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_connection.cpp @@ -307,6 +307,10 @@ int32_t HdiConnection::GetAllWaveInfo(std::vector &waveInfos int32_t vibratorId = 1; int32_t ret = vibratorInterface_->GetAllWaveInfo(vibratorId, waveInfos); if (ret != ERR_OK) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, + "PKG_NAME", "GetAllWaveInfo", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE MISC_HILOGE("GetAllWaveInfo failed"); } return ret; diff --git a/services/miscdevice_service/hdi_connection/adapter/src/hdi_light_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/hdi_light_connection.cpp index 12ba4b782fc979972e892f55f3c0dd2322c01d9b..b861e392817762c966cc602732a1962266efb7ce 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/hdi_light_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/hdi_light_connection.cpp @@ -17,6 +17,9 @@ #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE +#include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "sensors_errors.h" #undef LOG_TAG @@ -53,6 +56,10 @@ int32_t HdiLightConnection::GetLightList(std::vector &lightList) CHKPR(lightInterface_, ERROR); int32_t ret = lightInterface_->GetLightInfo(lightInfos); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "GetLightList", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE MISC_HILOGE("Get light info failed"); return ret; } @@ -84,6 +91,10 @@ int32_t HdiLightConnection::TurnOn(int32_t lightId, const LightColor &color, con CHKPR(lightInterface_, ERROR); int32_t ret = lightInterface_->TurnOnLight(lightId, effect); if (ret < 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOn", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE MISC_HILOGE("TurnOn failed"); return ret; } @@ -96,6 +107,10 @@ int32_t HdiLightConnection::TurnOff(int32_t lightId) CHKPR(lightInterface_, ERROR); int32_t ret = lightInterface_->TurnOffLight(lightId); if (ret < 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::MISCDEVICE, "VIBRATOR_HDF_SERVICE_EXCEPTION", + HiviewDFX::HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOff", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE MISC_HILOGE("TurnOff failed"); return ret; } diff --git a/services/miscdevice_service/include/vibration_priority_manager.h b/services/miscdevice_service/include/vibration_priority_manager.h index 106c251661a513afb0df2c019ca1b5291ee4aaae..549d2f77a1a9ca02a6adae167dc8531eed7ec5a8 100644 --- a/services/miscdevice_service/include/vibration_priority_manager.h +++ b/services/miscdevice_service/include/vibration_priority_manager.h @@ -123,6 +123,9 @@ private: void UpdateStatus(); bool IsSystemServiceCalling(); bool IsSystemCalling(); + void PrintSwitchStatus(); + std::thread printSwitchStatusThread_; + bool stop_ = false; sptr remoteObj_ { nullptr }; sptr observer_ { nullptr }; std::shared_ptr appMgrClientPtr_ {nullptr}; diff --git a/services/miscdevice_service/src/vibration_priority_manager.cpp b/services/miscdevice_service/src/vibration_priority_manager.cpp index f17201de8a01593dab9f2ba509ddb4cc71e1ae3a..b43854d0709fc245f0fbd536f7905a62e85c519f 100644 --- a/services/miscdevice_service/src/vibration_priority_manager.cpp +++ b/services/miscdevice_service/src/vibration_priority_manager.cpp @@ -71,9 +71,14 @@ const std::string SETTING_VIBRATE_INTENSITY_KEY = "vibration_intensity_index"; constexpr int32_t DECEM_BASE = 10; constexpr int32_t DATA_SHARE_READY = 0; constexpr int32_t DATA_SHARE_NOT_READY = 1055; +constexpr int32_t HOURS_IN_DAY = 24; +constexpr int32_t MINUTES_IN_HOUR = 60; +constexpr int32_t SECONDS_IN_MINUTE = 60; } // namespace -VibrationPriorityManager::VibrationPriorityManager() {} +VibrationPriorityManager::VibrationPriorityManager() + : printSwitchStatusThread_([this]() { this->PrintSwitchStatus(); }) +{} VibrationPriorityManager::~VibrationPriorityManager() { @@ -86,6 +91,10 @@ VibrationPriorityManager::~VibrationPriorityManager() MISC_HILOGE("UnregisterUserObserver failed"); } #endif // OHOS_BUILD_ENABLE_DO_NOT_DISTURB + if (printSwitchStatusThread_.joinable()) { + stop_ = true; + printSwitchStatusThread_.join(); + } } bool VibrationPriorityManager::Init() @@ -621,6 +630,34 @@ bool VibrationPriorityManager::IsSystemCalling() return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(IPCSkeleton::GetCallingFullTokenID()); } +void VibrationPriorityManager::PrintSwitchStatus() +{ + std::time_t now = std::time(nullptr); + std::tm *nowTm = std::localtime(&now); + if (nowTm == nullptr) { + MISC_HILOGE("Get the current time failed!"); + return; + } + int32_t hoursToMidnight = HOURS_IN_DAY - 1 - nowTm->tm_hour; + int32_t minutesToMidnight = MINUTES_IN_HOUR - 1 - nowTm->tm_min; + int32_t secondsToMidnight = SECONDS_IN_MINUTE - nowTm->tm_sec; + auto durationToMidnight = std::chrono::hours(hoursToMidnight) + std::chrono::minutes(minutesToMidnight) + + std::chrono::seconds(secondsToMidnight); + std::this_thread::sleep_for(durationToMidnight); + while (!stop_) { + int32_t feedbackTemp = miscFeedback_; + int32_t ringModeTemp = miscAudioRingerMode_; +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "SWITCHES_TOGGLE", HiSysEvent::EventType::BEHAVIOR, + "SWITCH_TYPE", "feedbackCurrentStatus", "STATUS", feedbackTemp); + HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "SWITCHES_TOGGLE", HiSysEvent::EventType::BEHAVIOR, + "SWITCH_TYPE", "ringerModeCurrentStatus", "STATUS", ringModeTemp); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE + MISC_HILOGI("feedbackCurrentStatus:%{public}d, ringerModeCurrentStatus:%{public}d", feedbackTemp, ringModeTemp); + std::this_thread::sleep_for(std::chrono::hours(HOURS_IN_DAY)); + } +} + #ifdef OHOS_BUILD_ENABLE_VIBRATOR_INPUT_METHOD bool VibrationPriorityManager::ShouldIgnoreInputMethod(const VibrateInfo &vibrateInfo) {