From a580da2d259450ad4be39468aa8ff22c88eb8479 Mon Sep 17 00:00:00 2001 From: songshenke Date: Mon, 21 Apr 2025 14:19:59 +0000 Subject: [PATCH] add logmsg for systemsoundmanager 2 Signed-off-by: songshenke Change-Id: I5298dafc68c5e94f45cd6efaf83389312eebe0a8 --- .../ringtone_player/ringtone_player_impl.cpp | 6 +++++ .../system_sound_manager_impl.cpp | 22 +++++++++++++++++++ .../system_sound_manager_utils.cpp | 7 ++++++ .../system_tone_player_impl.cpp | 2 ++ 4 files changed, 37 insertions(+) diff --git a/frameworks/native/system_sound_manager/ringtone_player/ringtone_player_impl.cpp b/frameworks/native/system_sound_manager/ringtone_player/ringtone_player_impl.cpp index 4fd42bd4a..e0d1e3c69 100644 --- a/frameworks/native/system_sound_manager/ringtone_player/ringtone_player_impl.cpp +++ b/frameworks/native/system_sound_manager/ringtone_player/ringtone_player_impl.cpp @@ -350,12 +350,14 @@ int32_t RingtonePlayerImpl::Configure(const float &volume, const bool &loop) if (configuredUri_ == NO_RING_SOUND && ringtoneState_ == STATE_RUNNING) { MEDIA_LOGI("Set volume to 0.0 for NO_RING_SOUND. Stop vibrator!"); SystemSoundVibrator::StopVibrator(); + // 无铃声场景,流音量设为0,打点记录 return MSERR_OK; } CHECK_AND_RETURN_RET_LOG(player_ != nullptr && ringtoneState_ != STATE_INVALID, MSERR_INVALID_VAL, "no player_"); volume_ = volume; loop_ = loop; + // RingtonePlayer设置铃声及循环,打点记录volume和loop(volume设为0时会停止震动) (void)player_->SetVolume(volume_); (void)player_->SetLoop(loop_); @@ -387,6 +389,7 @@ int32_t RingtonePlayerImpl::Start() ringtoneUri = specifyRingtoneUri_; } if (ringtoneUri == NO_RING_SOUND) { + // 无铃声起播,需打点记录 AudioHapticPlayerOptions options = {true, true}; ToneHapticsSettings settings = GetHapticSettings(ringtoneUri, options.muteHaptics); InitPlayer(ringtoneUri, settings, options); @@ -409,6 +412,7 @@ int32_t RingtonePlayerImpl::Start() InitPlayer(ringtoneUri, settings, options); } ReleaseDatabaseTool(); + // 铃声起播,需打点记录,需打点信息参考systemtonePlayer int32_t ret = player_->Start(); CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, MSERR_START_FAILED, "Start failed %{public}d", ret); ringtoneState_ = STATE_RUNNING; @@ -425,6 +429,7 @@ int32_t RingtonePlayerImpl::Stop() CHECK_AND_RETURN_RET_LOG(player_ != nullptr && ringtoneState_ != STATE_INVALID, MSERR_INVALID_VAL, "no player_"); (void)player_->Stop(); + // 铃声stop,需打点记录 if (configuredUri_ == NO_RING_SOUND && ringtoneState_ == STATE_RUNNING) { SystemSoundVibrator::StopVibrator(); } @@ -538,6 +543,7 @@ void RingtonePlayerCallback::OnEndOfStream(void) void RingtonePlayerCallback::OnError(int32_t errorCode) { MEDIA_LOGI("OnError from audio haptic player. errorCode %{public}d", errorCode); + // 播放器回调error,打点记录错误码 } } // namesapce Media } // namespace OHOS diff --git a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp index f39670742..9db3a8293 100644 --- a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp +++ b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp @@ -517,6 +517,8 @@ int32_t SystemSoundManagerImpl::SetNoRingToneUri(std::shared_ptr &contex CHECK_AND_RETURN_RET_LOG(IsRingtoneTypeValid(ringtoneType), MSERR_INVALID_VAL, "Invalid ringtone type"); MEDIA_LOGI("SetRingtoneUri: ringtoneType %{public}d, uri %{public}s", ringtoneType, uri.c_str()); + // 打点:设置来电铃声 + // 内容:调用者pid或uid, 设置的uri, RingtoneType std::shared_ptr dataShareHelper = SystemSoundManagerUtils::CreateDataShareHelper(STORAGE_MANAGER_MANAGER_ID); CHECK_AND_RETURN_RET_LOG(dataShareHelper != nullptr, ERROR, "Create dataShare failed, datashare or library error."); @@ -587,6 +591,8 @@ int32_t SystemSoundManagerImpl::SetRingtoneUri(const shared_ptr &contex resultSetByUri == nullptr ? : resultSetByUri->Close(); dataShareHelper->Release(); MEDIA_LOGE("Failed to find the uri in ringtone library!"); + // 打点:设置来电铃声 异常 + // 内容:调用者pid或uid, 设置的uri, RingtoneType。 Uri在铃音库内未找到,不允许设置 return ERROR; } resultSetByUri == nullptr ? : resultSetByUri->Close(); @@ -601,6 +607,8 @@ int32_t SystemSoundManagerImpl::SetRingtoneUri(const shared_ptr &contex if (ringtoneAsset != nullptr) { int32_t changedRows = UpdateRingtoneUri(dataShareHelper, ringtoneAsset->GetId(), ringtoneType, ringtoneAsset->GetRingtoneType()); + // 打点:设置来电铃声 + // 内容:调用者pid或uid, 设置的uri, RingtoneType。 changedRows(可以通过改变了几行,判断是否设置成功) resultSet == nullptr ? : resultSet->Close(); dataShareHelper->Release(); SetExtRingtoneUri(uri, ringtoneAsset->GetTitle(), ringtoneType, TONE_TYPE_RINGTONE, changedRows); @@ -879,6 +887,8 @@ int32_t SystemSoundManagerImpl::SetNoSystemToneUri(std::shared_ptr &cont CHECK_AND_RETURN_RET_LOG(IsSystemToneTypeValid(systemToneType), MSERR_INVALID_VAL, "Invalid system tone type"); MEDIA_LOGI("SetSystemToneUri: systemToneType %{public}d, uri %{public}s", systemToneType, uri.c_str()); + // 打点:设置短信或通知铃声 SetSystemToneUri + // 内容:调用者pid或uid, 设置的uri, SystemToneType std::shared_ptr dataShareHelper = SystemSoundManagerUtils::CreateDataShareHelper(STORAGE_MANAGER_MANAGER_ID); CHECK_AND_RETURN_RET_LOG(dataShareHelper != nullptr, ERROR, "Create dataShare failed."); @@ -957,6 +969,8 @@ int32_t SystemSoundManagerImpl::SetSystemToneUri(const shared_ptr &cont if (ringtoneAssetByUri == nullptr) { resultSetByUri == nullptr ? : resultSetByUri->Close(); dataShareHelper->Release(); + // 打点:设置短信或通知铃声 SetSystemToneUri 异常 + // 内容:调用者pid或uid, 设置的uri, SystemToneType。 Uri在铃音库内未找到,不允许设置 MEDIA_LOGE("Failed to find the uri in ringtone library!"); return ERROR; } @@ -977,6 +991,8 @@ int32_t SystemSoundManagerImpl::SetSystemToneUri(const shared_ptr &cont changedRows = UpdateShotToneUri(dataShareHelper, ringtoneAsset->GetId(), systemToneType, ringtoneAsset->GetShottoneType()); } + // 打点:设置短信或通知铃声 SetSystemToneUri + // 内容:调用者pid或uid, 设置的uri, SystemToneType。 changedRows(可以通过改变了几行,判断是否设置成功) resultSet == nullptr ? : resultSet->Close(); SetExtRingtoneUri(uri, ringtoneAsset->GetTitle(), systemToneType, TONE_TYPE_NOTIFICATION, changedRows); return changedRows > 0 ? SUCCESS : ERROR; @@ -1229,6 +1245,7 @@ std::shared_ptr SystemSoundManagerImpl::GetDefaultRingtoneAttrs( MEDIA_LOGI("RingtoneAttrs_ : Title = %{public}s", ringtoneAsset->GetTitle().c_str()); } else { MEDIA_LOGE("GetDefaultRingtoneAttrs: no single card default ringtone in the ringtone library!"); + // 打点记录:来电铃声默认值查询结果为空,打印RingtoneType } resultSet == nullptr ? : resultSet->Close(); dataShareHelper->Release(); @@ -1277,6 +1294,7 @@ std::vector> SystemSoundManagerImpl::GetRingtoneAttrL } if (ringtoneAttrsArray_.empty()) { MEDIA_LOGE("GetRingtoneAttrList: no ringtone in the ringtone library!"); + // 打点记录:来电铃声列表查询结果为空, 打印RingtoneType } resultSet == nullptr ? : resultSet->Close(); dataShareHelper->Release(); @@ -1329,6 +1347,7 @@ std::shared_ptr SystemSoundManagerImpl::GetDefaultSystemToneAttrs( ringtoneAsset->GetPath(), sourceTypeMap_[ringtoneAsset->GetSourceType()], category); } else { MEDIA_LOGE("GetDefaultSystemToneAttrs: no single default systemtone in the ringtone library!"); + // 打点记录:默认systemtone铃声查询结果为空,打印SystemToneType } resultSet == nullptr ? : resultSet->Close(); dataShareHelper->Release(); @@ -1378,12 +1397,15 @@ std::vector> SystemSoundManagerImpl::GetSystemToneAtt } if (systemtoneAttrsArray_.empty()) { MEDIA_LOGE("GetSystemToneAttrList: no systemtone in the ringtone library!"); + // 打点记录:systemtone铃声列表查询结果为空, 打印SystemToneType } resultSet == nullptr ? : resultSet->Close(); dataShareHelper->Release(); return systemtoneAttrsArray_; } +// 打点:Alarm的Set、Get函数参考铃声的做类似打点 + int32_t SystemSoundManagerImpl::SetAlarmToneUri(const std::shared_ptr &context, const std::string &uri) { diff --git a/frameworks/native/system_sound_manager/system_sound_manager_utils.cpp b/frameworks/native/system_sound_manager/system_sound_manager_utils.cpp index f4d375ae9..5af4d6832 100644 --- a/frameworks/native/system_sound_manager/system_sound_manager_utils.cpp +++ b/frameworks/native/system_sound_manager/system_sound_manager_utils.cpp @@ -63,6 +63,7 @@ int32_t SystemSoundManagerUtils::GetCurrentUserId() } if (result != ERR_OK || ids.empty()) { MEDIA_LOGW("current userId is empty"); + // 打点:userId查询失败! } return currentuserId; } @@ -87,6 +88,7 @@ shared_ptr SystemSoundManagerUtils::CreateDataShareH DataShare::DataShareHelper::Create(remoteObj, uri, ""); MEDIA_LOGI("CreateDataShareHelperUri with : %{public}s. errcode : %{public}d", uri.c_str(), dataShare.first); return dataShare.second; + // 打点:返回前先判断返回值是不是nullptr,如果返回空指针,打点记录 } shared_ptr SystemSoundManagerUtils::CreateDataShareHelper(int32_t systemAbilityId) @@ -103,6 +105,7 @@ shared_ptr SystemSoundManagerUtils::CreateDataShareH return nullptr; } return DataShare::DataShareHelper::Creator(remoteObj, RINGTONE_URI); + // 打点:返回前先判断返回值是不是nullptr,如果返回空指针,打点记录 } bool SystemSoundManagerUtils::VerifyCustomPath(const std::string &audioUri) @@ -154,6 +157,8 @@ bool SystemSoundManagerUtils::CheckCurrentUser() int result = SetParameter(RINGTONE_PARAMETER_SCANNER_USERID_KEY, ids.c_str()); MEDIA_LOGI("CheckCurrentUser End. SetParameter result: %{public}d ,CurrentUserIds: %{private}s .", result, ids.c_str()); + // return false + // 打点记录:currentUserId对应的铃音库,尚未完成初始化扫描 return false; } @@ -167,6 +172,8 @@ bool SystemSoundManagerUtils::GetScannerFirstParameter(const char* key, int32_t if (strcmp(paramValue, RINGTONE_PARAMETER_SCANNER_FIRST_TRUE) == 0) { return true; } + // return false + // 打点记录:铃音库尚未完成初始化扫描 if (strcmp(paramValue, RINGTONE_PARAMETER_SCANNER_FIRST_FALSE) == 0) { return false; } diff --git a/frameworks/native/system_sound_manager/system_tone_player/system_tone_player_impl.cpp b/frameworks/native/system_sound_manager/system_tone_player/system_tone_player_impl.cpp index f6c68bcf5..4d0ae51fd 100644 --- a/frameworks/native/system_sound_manager/system_tone_player/system_tone_player_impl.cpp +++ b/frameworks/native/system_sound_manager/system_tone_player/system_tone_player_impl.cpp @@ -441,6 +441,7 @@ int32_t SystemTonePlayerImpl::Start(const SystemToneOptions &systemToneOptions) "Failed to start audio haptic player: %{public}d", result); SendMessageZoneEvent(AudioStandard::ERR_INVALID_PARAM, systemToneOptions.muteAudio, systemToneOptions.muteHaptics); + // Start打点时把streamId_信息也添加上 return streamId_; } @@ -457,6 +458,7 @@ int32_t SystemTonePlayerImpl::Stop(const int32_t &streamId) } int32_t result = playerMap_[streamId]->Stop(); + // 打点记录一下streamId调用了stop DeletePlayer(streamId); CHECK_AND_RETURN_RET_LOG(result == MSERR_OK, MSERR_INVALID_OPERATION, "Failed to stop audio haptic player: %{public}d", result); -- Gitee