!2457 fix tel ril crash

Merge pull request !2457 from rsin/master
This commit is contained in:
openharmony_ci 2024-11-21 08:17:15 +00:00 committed by Gitee
commit 5927c2cf9e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 13 additions and 3 deletions

View File

@ -57,6 +57,7 @@ public:
static std::shared_ptr<TelRilRequest> CreateTelRilRequest(const AppExecFwk::InnerEvent::Pointer &result);
void ResetRilInterface(sptr<HDI::Ril::V1_3::IRil> rilInterface);
sptr<HDI::Ril::V1_3::IRil> GetRilInterface();
static std::shared_ptr<TelRilRequest> FindTelRilRequest(const RadioResponseInfo &responseInfo);
int32_t ErrorResponse(std::shared_ptr<TelRilRequest> telRilRequest, const RadioResponseInfo &responseInfo);
@ -114,7 +115,8 @@ template<typename FuncType, typename... ParamTypes>
inline int32_t TelRilBase::Request(const char *funcName, const AppExecFwk::InnerEvent::Pointer &response,
FuncType &&_func, ParamTypes &&... _args)
{
if (rilInterface_ == nullptr) {
sptr<HDI::Ril::V1_3::IRil> rilInterface = GetRilInterface();
if (rilInterface == nullptr) {
TELEPHONY_LOGE("%{public}s() rilInterface_ is null", funcName);
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
@ -123,7 +125,7 @@ inline int32_t TelRilBase::Request(const char *funcName, const AppExecFwk::Inner
TELEPHONY_LOGE("%{public}s() telRilRequest is null", funcName);
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return (rilInterface_->*(_func))(slotId_, telRilRequest->serialId_, std::forward<ParamTypes>(_args)...);
return (rilInterface->*(_func))(slotId_, telRilRequest->serialId_, std::forward<ParamTypes>(_args)...);
}
inline int32_t TelRilBase::Response(const char *funcName, const HDI::Ril::V1_1::RilRadioResponseInfo &iResponseInfo)

View File

@ -22,6 +22,7 @@ namespace Telephony {
std::atomic_int TelRilBase::nextSerialId_(1);
std::unordered_map<int32_t, std::shared_ptr<TelRilRequest>> TelRilBase::requestMap_;
std::mutex TelRilBase::requestLock_;
std::mutex dealLock_;
std::shared_ptr<TelRilHandler> TelRilBase::handler_;
TelRilBase::TelRilBase(int32_t slotId, sptr<HDI::Ril::V1_3::IRil> rilInterface,
@ -33,9 +34,16 @@ TelRilBase::TelRilBase(int32_t slotId, sptr<HDI::Ril::V1_3::IRil> rilInterface,
void TelRilBase::ResetRilInterface(sptr<HDI::Ril::V1_3::IRil> rilInterface)
{
std::lock_guard<std::mutex> lock(dealLock_);
rilInterface_ = rilInterface;
}
sptr<HDI::Ril::V1_3::IRil> TelRilBase::GetRilInterface()
{
std::lock_guard<std::mutex> lock(dealLock_);
return rilInterface_;
}
std::shared_ptr<TelRilRequest> TelRilBase::CreateTelRilRequest(const AppExecFwk::InnerEvent::Pointer &result)
{
std::shared_ptr<TelRilRequest> telRilRequest = std::make_shared<TelRilRequest>(GetNextSerialId(), result);
@ -83,7 +91,7 @@ std::shared_ptr<TelRilRequest> TelRilBase::FindTelRilRequest(const RadioResponse
int32_t TelRilBase::GetSerialId(const AppExecFwk::InnerEvent::Pointer &response)
{
if (rilInterface_ == nullptr) {
if (GetRilInterface() == nullptr) {
TELEPHONY_LOGE("ERROR : rilInterface_ == nullptr !!!");
return -TELEPHONY_ERR_ARGUMENT_INVALID;
}