diff --git a/frameworks/js/napi/src/napi_call_ability_callback.cpp b/frameworks/js/napi/src/napi_call_ability_callback.cpp index 42c77474a31607b1bfe59821ec6773ef1f5c01dc..f39f1a3ec4decc1df93a54396a5b642814edd5c1 100644 --- a/frameworks/js/napi/src/napi_call_ability_callback.cpp +++ b/frameworks/js/napi/src/napi_call_ability_callback.cpp @@ -580,6 +580,10 @@ int32_t NapiCallAbilityCallback::ReportCallState(CallAttributeInfo &info, EventC } napi_value thisVar = nullptr; napi_get_reference_value(env, stateCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + napi_close_handle_scope(env, scope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, scope); @@ -728,6 +732,11 @@ int32_t NapiCallAbilityCallback::ReportCallEvent(CallEventInfo &info, EventCallb } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, scopeCallEvent); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callEventCallbackFunc, DATA_LENGTH_ONE, callEventCallbackValues, &callbackResult); napi_close_handle_scope(env, scopeCallEvent); @@ -821,6 +830,11 @@ int32_t NapiCallAbilityCallback::ReportDisconnectedCause( } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, disconnectedScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, disconnectedScope); @@ -925,6 +939,11 @@ int32_t NapiCallAbilityCallback::ReportMmiCode(MmiCodeInfo &info, EventCallback } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, mmiCodeScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); napi_close_handle_scope(env, mmiCodeScope); @@ -1038,6 +1057,11 @@ int32_t NapiCallAbilityCallback::ReportAudioDeviceInfo(AudioDeviceInfo &info, Ev } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, AudioDeviceInfoScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, AudioDeviceInfoScope); @@ -1811,6 +1835,11 @@ int32_t NapiCallAbilityCallback::ReportCallOtt( } napi_value thisVar = nullptr; napi_get_reference_value(env, settingInfo.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, callOttscope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, callOttscope); @@ -1896,6 +1925,11 @@ int32_t NapiCallAbilityCallback::ReportPostDialDelay(std::string postDialStr, Ev } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, scope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, scope); @@ -1990,6 +2024,11 @@ int32_t NapiCallAbilityCallback::ReportCallMediaModeInfo( } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, CallMediaModeInfoScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, CallMediaModeInfoScope); @@ -2081,6 +2120,11 @@ int32_t NapiCallAbilityCallback::ReportCallSessionEvent( } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, CallSessionEventScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, CallSessionEventScope); @@ -2175,6 +2219,11 @@ int32_t NapiCallAbilityCallback::ReportPeerDimensions( } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, PeerDimensionsDetailScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, PeerDimensionsDetailScope); @@ -2261,6 +2310,11 @@ int32_t NapiCallAbilityCallback::ReportCallDataUsage(int64_t dataUsage, EventCal } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, CallDataUsageScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, CallDataUsageScope); @@ -2355,6 +2409,11 @@ int32_t NapiCallAbilityCallback::ReportCameraCapabilitiesInfo( } napi_value thisVar = nullptr; napi_get_reference_value(env, eventCallback.thisVar, &thisVar); + if (thisVar == nullptr) { + TELEPHONY_LOGE("thisVar is null!"); + napi_close_handle_scope(env, cameraCapabilitiesScope); + return TELEPHONY_ERROR; + } napi_value callbackResult = nullptr; napi_call_function(env, thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); napi_close_handle_scope(env, cameraCapabilitiesScope); diff --git a/frameworks/native/src/call_manager_proxy.cpp b/frameworks/native/src/call_manager_proxy.cpp index 3a6f313374c55aefab6abc182cb56f2aa151f50e..697d63556c5353d426672eb247d51f1a345307af 100644 --- a/frameworks/native/src/call_manager_proxy.cpp +++ b/frameworks/native/src/call_manager_proxy.cpp @@ -1619,7 +1619,7 @@ int32_t CallManagerProxy::CancelCallUpgrade(int32_t callId) } int32_t errCode = callManagerServicePtr_->CancelCallUpgrade(callId); if (errCode != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("ReportAudioDeviceInfo failed, errcode:%{public}d", errCode); + TELEPHONY_LOGE("CancelCallUpgrade failed, errcode:%{public}d", errCode); return errCode; } return TELEPHONY_SUCCESS; @@ -1638,7 +1638,7 @@ int32_t CallManagerProxy::RequestCameraCapabilities(int32_t callId) } int32_t errCode = callManagerServicePtr_->RequestCameraCapabilities(callId); if (errCode != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("ReportAudioDeviceInfo failed, errcode:%{public}d", errCode); + TELEPHONY_LOGE("RequestCameraCapabilities failed, errcode:%{public}d", errCode); return errCode; } return TELEPHONY_SUCCESS; diff --git a/services/audio/src/tone.cpp b/services/audio/src/tone.cpp index 3b66bb283fe25a06595ce3609433e9a542fe74a5..2136d7f10c5dcdcfd5b0ea7e108010d4c19ace61 100644 --- a/services/audio/src/tone.cpp +++ b/services/audio/src/tone.cpp @@ -64,7 +64,11 @@ int32_t Tone::Play() pthread_setname_np(pthread_self(), TONE_PLAY_THREAD); tonePlayerPtr->StartTone(); }); - play.detach(); + if (!play.joinable()) { + TELEPHONY_LOGE("failed to create thread for tone player"); + } else { + play.detach(); + } } else { AudioPlay audioPlay = &AudioPlayer::Play; if (audioPlayer_ == nullptr) { @@ -73,8 +77,12 @@ int32_t Tone::Play() } std::thread play(audioPlay, audioPlayer_, GetToneDescriptorPath(currentToneDescriptor_), AudioStandard::AudioStreamType::STREAM_MUSIC, PlayerType::TYPE_TONE); - pthread_setname_np(play.native_handle(), TONE_PLAY_THREAD); - play.detach(); + if (!play.joinable()) { + TELEPHONY_LOGE("failed to create thread for tone player"); + } else { + pthread_setname_np(play.native_handle(), TONE_PLAY_THREAD); + play.detach(); + } } return TELEPHONY_SUCCESS; } diff --git a/services/bluetooth/src/bluetooth_call_manager.cpp b/services/bluetooth/src/bluetooth_call_manager.cpp index 6b252fc10c278325ce20ac420cc3d2635e0d530b..4281296cb346c31d14e1fc15934f2e8ea8e41c61 100644 --- a/services/bluetooth/src/bluetooth_call_manager.cpp +++ b/services/bluetooth/src/bluetooth_call_manager.cpp @@ -33,7 +33,7 @@ int32_t BluetoothCallManager::SendBtCallState( { if (btConnection_ == nullptr) { TELEPHONY_LOGE("bluetooth connection nullptr"); - return false; + return TELEPHONY_ERROR; } return btConnection_->SendBtCallState(numActive, numHeld, callState, number); } @@ -42,7 +42,7 @@ int32_t BluetoothCallManager::SendCallDetailsChange(int32_t callId, int32_t call { if (btConnection_ == nullptr) { TELEPHONY_LOGE("bluetooth connection nullptr"); - return false; + return TELEPHONY_ERROR; } return btConnection_->SendCallDetailsChange(callId, callState); }