IssueNo:CoreService codecheck整改

Description:CoreService codecheck整改
Sig:SIG_Telephony
Feature or Bugfix: Bugfix
Binary Source: No

Signed-off-by: liuxiyao223 <liuxiyao223@huawei.com>
This commit is contained in:
liuxiyao223 2024-03-22 15:41:07 +08:00
parent d7d5a49d71
commit ab56cf4c42
11 changed files with 162 additions and 18 deletions

View File

@ -308,6 +308,9 @@ int32_t TelephonyStateRegistryProxy::RegisterStateChange(
if (!in.WriteBool(isUpdate)) {
return TELEPHONY_ERR_FAIL;
}
if (callback == nullptr) {
return TELEPHONY_ERR_FAIL;
}
if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
return TELEPHONY_ERR_FAIL;
}

View File

@ -136,6 +136,10 @@ void SignalInfo::ProcessSignalIntensity(int32_t slotId, const AppExecFwk::InnerE
DelayedSingleton<NetworkSearchNotify>::GetInstance()->NotifySignalInfoUpdated(slotId, signals);
int level = 0;
if (signals.size() != 0) {
if (signals[0] == nullptr) {
TELEPHONY_LOGE("signals is nullptr!");
return;
}
level = signals[0]->GetSignalLevel();
}
CoreServiceHiSysEvent::WriteSignalLevelBehaviorEvent(slotId, level);

View File

@ -76,6 +76,9 @@ int32_t SatelliteCoreCallbackStub::OnSetRadioStateResponse(MessageParcel &data,
int32_t error = data.ReadInt32();
int32_t type = data.ReadInt32();
auto info = std::make_shared<HRilRadioResponseInfo>();
if (info == nullptr) {
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
info->flag = flag;
info->serial = serial;
info->error = static_cast<HRilErrType>(error);
@ -93,6 +96,9 @@ int32_t SatelliteCoreCallbackStub::OnSetRadioStateResponse(MessageParcel &data,
int64_t flag = data.ReadInt64();
int32_t state = data.ReadInt32();
auto info = std::make_unique<HRilRadioStateInfo>();
if (info == nullptr) {
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
info->flag = flag;
info->state = state;
AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventCode, info);

View File

@ -268,6 +268,10 @@ void IccDiallingNumbersHandler::ProcessDiallingNumberLoadDone(const AppExecFwk::
return;
}
std::unique_ptr<ControllerToFileMsg> fd = event->GetUniqueObject<ControllerToFileMsg>();
if (fd == nullptr) {
TELEPHONY_LOGE("IccDiallingNumbersHandler::ProcessDiallingNumberLoadDone fd is nullptr");
return;
}
int loadId = fd->arg1;
id = loadId;
std::shared_ptr<DiallingNumberLoadRequest> loadRequest = FindLoadRequest(loadId);
@ -336,6 +340,10 @@ bool IccDiallingNumbersHandler::SendBackResult(int loadId)
return false;
}
std::unique_ptr<DiallingNumbersHandlerResult> data = make_unique<DiallingNumbersHandlerResult>(fd.get());
if (data == nullptr) {
TELEPHONY_LOGE("data is nullptr!");
return false;
}
data->result = loadRequest->GetResult();
data->exception = loadRequest->GetException();
if (owner == nullptr) {
@ -351,6 +359,10 @@ bool IccDiallingNumbersHandler::SendBackResult(int loadId)
AppExecFwk::InnerEvent::Pointer IccDiallingNumbersHandler::BuildCallerInfo(int eventId, int loadId)
{
std::unique_ptr<FileToControllerMsg> object = std::make_unique<FileToControllerMsg>();
if (object == nullptr) {
TELEPHONY_LOGE("object is nullptr!");
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
object->arg1 = loadId;
int eventParam = 0;
AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(eventId, object, eventParam);
@ -366,6 +378,10 @@ AppExecFwk::InnerEvent::Pointer IccDiallingNumbersHandler::BuildCallerInfo(
int eventId, std::shared_ptr<void> pobj, int loadId)
{
std::unique_ptr<FileToControllerMsg> object = std::make_unique<FileToControllerMsg>();
if (object == nullptr) {
TELEPHONY_LOGE("object is nullptr!");
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
object->arg1 = loadId;
object->iccLoader = pobj;
int eventParam = 0;

View File

@ -167,7 +167,7 @@ void IccFileController::ProcessBinarySize(const AppExecFwk::InnerEvent::Pointer
int fileId = rcvMsg->arg1;
TELEPHONY_LOGI("ProcessBinarySize fileId:%{public}d size:%{public}d", fileId, size);
const AppExecFwk::InnerEvent::Pointer &evt = hd->fileLoaded;
if (evt->GetOwner() == nullptr) {
if (evt == nullptr) {
TELEPHONY_LOGE("ProcessBinarySize isNull is null pointer");
return;
}
@ -192,7 +192,7 @@ void IccFileController::ProcessReadRecord(const AppExecFwk::InnerEvent::Pointer
std::string str = IccFileController::NULLSTR;
std::string path = IccFileController::NULLSTR;
std::unique_ptr<IccFromRilMsg> rcvMsg = event->GetUniqueObject<IccFromRilMsg>();
if (rcvMsg == nullptr) {
if (rcvMsg == nullptr || rcvMsg->controlHolder == nullptr) {
TELEPHONY_LOGE("rcvMsg is nullptr");
return;
}
@ -484,6 +484,10 @@ void IccFileController::SendResponse(std::shared_ptr<IccControllerHolder> holder
void IccFileController::SendEfLinearResult(const AppExecFwk::InnerEvent::Pointer &response, const int val[], int len)
{
if (response == nullptr) {
TELEPHONY_LOGE("response is nullptr!");
return;
}
std::shared_ptr<AppExecFwk::EventHandler> handler = response->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("handler is nullptr!");
@ -507,6 +511,10 @@ void IccFileController::SendEfLinearResult(const AppExecFwk::InnerEvent::Pointer
void IccFileController::SendMultiRecordResult(
const AppExecFwk::InnerEvent::Pointer &response, std::vector<std::string> &strValue)
{
if (response == nullptr) {
TELEPHONY_LOGE("response is nullptr!");
return;
}
std::shared_ptr<AppExecFwk::EventHandler> handler = response->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("handler is nullptr!");
@ -569,7 +577,15 @@ AppExecFwk::InnerEvent::Pointer IccFileController::BuildCallerInfo(
int eventId, int arg1, int arg2, const AppExecFwk::InnerEvent::Pointer &msg)
{
std::shared_ptr<IccControllerHolder> ctrlHolder = std::make_shared<IccControllerHolder>(arg1);
if (ctrlHolder == nullptr) {
TELEPHONY_LOGE("ctrlHolder is nullptr!");
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
ctrlHolder->fileLoaded = std::move(const_cast<AppExecFwk::InnerEvent::Pointer &>(msg));
if (ctrlHolder->fileLoaded == nullptr) {
TELEPHONY_LOGE("ctrlHolder->fileLoaded is nullptr!");
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
bool isNull = ctrlHolder->fileLoaded->GetOwner() == nullptr;
TELEPHONY_LOGD("IccFileController::BuildCallerInfo stage init owner: %{public}d", isNull);
std::unique_ptr<IccToRilMsg> msgTo = std::make_unique<IccToRilMsg>(ctrlHolder);
@ -674,10 +690,13 @@ std::string IccFileController::CheckRightPath(const std::string &path, int fileI
bool IccFileController::ProcessErrorResponse(const AppExecFwk::InnerEvent::Pointer &event)
{
std::shared_ptr<IccFromRilMsg> rcvMsg = event->GetSharedObject<IccFromRilMsg>();
if (rcvMsg == nullptr) {
if (rcvMsg == nullptr || rcvMsg->controlHolder == nullptr) {
return false;
}
AppExecFwk::InnerEvent::Pointer &response = rcvMsg->controlHolder->fileLoaded;
if (response == nullptr) {
return false;
}
auto owner = response->GetOwner();
if (owner == nullptr) {
TELEPHONY_LOGE("owner is nullptr");
@ -691,6 +710,9 @@ bool IccFileController::ProcessErrorResponse(const AppExecFwk::InnerEvent::Point
TELEPHONY_LOGD("ProcessErrorResponse start response %{public}d", needShare);
if (needShare) {
objectShare = std::make_shared<ControllerToFileMsg>(cmdData.get(), nullptr);
if (objectShare == nullptr) {
return false;
}
objectShare->exception = rcvMsg->fileData.exception;
} else {
objectUnique = std::make_unique<ControllerToFileMsg>(cmdData.get(), nullptr);

View File

@ -57,6 +57,10 @@ void UsimDiallingNumbersService::InitFuncMap()
void UsimDiallingNumbersService::ProcessPbrLoadDone(const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
TELEPHONY_LOGE("event is nullptr!");
return;
}
std::shared_ptr<MultiRecordResult> object = event->GetSharedObject<MultiRecordResult>();
if (object != nullptr) {
TELEPHONY_LOGI("UsimDiallingNumbersService::ProcessPbrLoadDone: %{public}d", object->resultLength);
@ -81,6 +85,9 @@ void UsimDiallingNumbersService::ProcessPbrLoadDone(const AppExecFwk::InnerEvent
void UsimDiallingNumbersService::ProcessDiallingNumberLoadDone(const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
return;
}
std::unique_ptr<DiallingNumbersHandlerResult> object = event->GetUniqueObject<DiallingNumbersHandlerResult>();
if (object != nullptr) {
@ -188,19 +195,18 @@ void UsimDiallingNumbersService::GeneratePbrFile(std::vector<std::string> &recor
continue;
}
auto pbrFile = BuildNumberFileByRecord(dataPac);
pbrFiles_.push_back(pbrFile);
auto fileIt = pbrFile->fileIds_.find(TAG_SIM_USIM_ADN);
if (fileIt == pbrFile->fileIds_.end()) {
continue;
if (pbrFile != nullptr) {
pbrFiles_.push_back(pbrFile);
auto fileIt = pbrFile->fileIds_.find(TAG_SIM_USIM_ADN);
if (fileIt == pbrFile->fileIds_.end()) {
continue;
}
std::shared_ptr<TagData> file = fileIt->second;
if (file == nullptr || file->shortFileId == INVALID_SFI) {
continue;
}
efIdOfSfi_.insert(std::pair<int, int>(file->shortFileId, file->fileId));
}
std::shared_ptr<TagData> file = fileIt->second;
if (file == nullptr) {
continue;
}
if (file->shortFileId == INVALID_SFI) {
continue;
}
efIdOfSfi_.insert(std::pair<int, int>(file->shortFileId, file->fileId));
}
}
@ -221,6 +227,10 @@ AppExecFwk::InnerEvent::Pointer UsimDiallingNumbersService::CreateHandlerPointer
int eventid, int efId, int index, std::shared_ptr<void> pobj)
{
std::unique_ptr<DiallingNumbersHandleHolder> holder = std::make_unique<DiallingNumbersHandleHolder>();
if (holder == nullptr) {
TELEPHONY_LOGE("holder is nullptr!");
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
holder->fileID = efId;
holder->index = index;
holder->diallingNumber = pobj;
@ -245,6 +255,10 @@ std::shared_ptr<UsimDiallingNumberFile> UsimDiallingNumbersService::BuildNumberF
const std::string &record)
{
std::shared_ptr<TagService> recTlv = std::make_shared<TagService>(record);
if (recTlv == nullptr) {
TELEPHONY_LOGI("BuildNumberFileByRecord: recTlv is nullptr!");
return nullptr;
}
std::shared_ptr<UsimDiallingNumberFile> file = std::make_shared<UsimDiallingNumberFile>();
int tag = 0;
TELEPHONY_LOGI("BuildNumberFileByRecord: start get tag");
@ -267,6 +281,10 @@ std::shared_ptr<UsimDiallingNumberFile> UsimDiallingNumbersService::BuildNumberF
void UsimDiallingNumbersService::StorePbrDetailInfo(
std::shared_ptr<UsimDiallingNumberFile> file, std::shared_ptr<TagService> tlv, int parentTag)
{
if (tlv == nullptr) {
TELEPHONY_LOGI("StorePbrDetailInfo: tlv is nullptr!");
return;
}
for (int count = 0; tlv->Next(); ++count) {
const int tag = tlv->GetTagCode();
TELEPHONY_LOGI("make file tag type: %{public}d", tag);
@ -312,6 +330,10 @@ void UsimDiallingNumbersService::SendBackResult(
uint32_t id = callerPointer_->GetInnerEventId();
std::unique_ptr<UsimFetcher> fd = callerPointer_->GetUniqueObject<UsimFetcher>();
std::unique_ptr<UsimResult> data = std::make_unique<UsimResult>(fd.get());
if (data == nullptr) {
TELEPHONY_LOGE("data is nullptr");
return;
}
data->result = static_cast<std::shared_ptr<void>>(diallingnumbers);
TelEventHandler::SendTelEvent(owner, id, data);
TELEPHONY_LOGI("UsimDiallingNumbersService::SendBackResult send end");

View File

@ -255,7 +255,7 @@ public:
TELEPHONY_LOGE("handler is nullptr");
return false;
}
if (handler->GetEventRunner() == nullptr) {
if (handler->GetEventRunner() == nullptr && handler.get() != nullptr) {
return static_cast<TelEventHandler *>(handler.get())->SendEvent(std::forward<ParamTypes>(_args)...);
}
return handler->SendEvent(std::forward<ParamTypes>(_args)...);

View File

@ -71,6 +71,9 @@ uint32_t TelEventQueue::ToTelPriority(AppExecFwk::EventQueue::Priority priority)
void TelEventQueue::InsertEventsInner(AppExecFwk::InnerEvent::Pointer &event, AppExecFwk::EventQueue::Priority priority)
{
if (event == nullptr) {
return;
}
std::unique_lock<std::mutex> lock(eventCtx_);
auto &events = eventLists_[ToTelPriority(priority)].events;
auto f = [](const AppExecFwk::InnerEvent::Pointer &first, const AppExecFwk::InnerEvent::Pointer &second) {
@ -162,8 +165,12 @@ void TelEventQueue::SubmitToFFRT(int32_t queueId, AppExecFwk::InnerEvent::TimePo
void TelEventQueue::RemoveEvent(uint32_t innerEventId)
{
std::lock_guard<std::mutex> lock(eventCtx_);
auto filter = [innerEventId](
const AppExecFwk::InnerEvent::Pointer &p) { return p->GetInnerEventId() == innerEventId; };
auto filter = [innerEventId](const AppExecFwk::InnerEvent::Pointer &p) {
if (p == nullptr) {
return false;
}
return p->GetInnerEventId() == innerEventId;
};
for (uint32_t i = 0; i < EVENT_QUEUE_NUM; ++i) {
eventLists_[i].events.remove_if(filter);
}

View File

@ -542,6 +542,10 @@ void VCardConstructor::AddPostalLine(
void VCardConstructor::ConstructPostalLine(std::shared_ptr<VCardPostalData> postalData, std::stringstream &postalLine,
bool &needCharset, bool &needAddQuotedPrintable)
{
if (postalData == nullptr) {
TELEPHONY_LOGI("postalData is nullptr!");
return;
}
std::string poBox = postalData->GetPOBox();
std::string street = postalData->GetStreet();
std::string city = postalData->GetCity();

View File

@ -166,6 +166,10 @@ bool VCardDecoderV21::ParseItem(int32_t &errorCode)
}
std::lock_guard<std::mutex> lock(rawDataMutex_);
auto rawData = std::make_shared<VCardRawData>();
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return false;
}
BuildRawData(line, rawData, errorCode);
if (errorCode != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("Build raw data failed");
@ -189,6 +193,10 @@ bool VCardDecoderV21::ParseItem(int32_t &errorCode)
void VCardDecoderV21::DealRawDataValue(
const std::string &name, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
std::string nameUp = VCardUtils::ToUpper(rawData->GetName());
std::string rawValue = rawData->GetRawValue();
std::string sourceCharset = DEFAULT_INTERMEDIATE_CHARSET;
@ -254,6 +262,10 @@ std::string VCardDecoderV21::GetVersion()
void VCardDecoderV21::DealBase64OrB(
const std::string &rawValue, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
std::string base64 = GetBase64(rawValue, errorCode);
rawData->SetByte(VCardUtils::DecodeBase64(base64));
NotifyRawDataCreated(rawData);
@ -262,6 +274,10 @@ void VCardDecoderV21::DealBase64OrB(
void VCardDecoderV21::DealEncodingQPOrNoEncodingFN(const std::string &rawValue, std::shared_ptr<VCardRawData> rawData,
const std::string &fromCharSet, const std::string &toCharSet, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
std::string quotedPrintableValue = GetQuotedPrintableValue(rawValue, errorCode);
if (errorCode != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("GetQuotedPrintableValue failed");
@ -340,6 +356,10 @@ void VCardDecoderV21::BuildRawData(const std::string &line, std::shared_ptr<VCar
void VCardDecoderV21::DealGroupOrTypeNameStatus(const std::string &line, std::shared_ptr<VCardRawData> rawData,
int32_t &errorCode, int32_t &status, int32_t &namePos, int32_t &index)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (line[index] == ':') {
rawData->SetName(line.substr(namePos, index - namePos));
rawData->SetRawValue(index < static_cast<int32_t>(line.length()) - 1 ? line.substr(index + 1) : "");
@ -368,6 +388,10 @@ void VCardDecoderV21::DealGroupOrTypeNameStatus(const std::string &line, std::sh
void VCardDecoderV21::DealParamsStatus(const std::string &line, std::shared_ptr<VCardRawData> rawData,
int32_t &errorCode, int32_t &status, int32_t &namePos, int32_t &index)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (line[index] == '"') {
status = STATUS_PARAMS_IN_DQUOTE;
return;
@ -432,6 +456,10 @@ void VCardDecoderV21::DealNoNameParam(
void VCardDecoderV21::DealTypeParam(const std::string &type, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (!(ContainValue(VCardUtils::ToUpper(type), GetSupportParamType()) || VCardUtils::StartWith(type, "X-"))) {
unknowParamType_.insert(type);
}
@ -441,6 +469,10 @@ void VCardDecoderV21::DealTypeParam(const std::string &type, std::shared_ptr<VCa
void VCardDecoderV21::DealValueParam(
const std::string &value, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (!(ContainValue(VCardUtils::ToUpper(value), GetSupportParamValue()) || VCardUtils::StartWith(value, "X-"))) {
unknowParamValue_.insert(value);
}
@ -450,6 +482,10 @@ void VCardDecoderV21::DealValueParam(
void VCardDecoderV21::DealEncodingParam(
const std::string &encoding, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (ContainValue(encoding, GetSupportParamEncoding()) || VCardUtils::StartWith(encoding, "X-")) {
rawData->AppendParameter(VCARD_PARAM_ENCODING, encoding);
currentEncoding_ = encoding;
@ -462,6 +498,10 @@ void VCardDecoderV21::DealEncodingParam(
void VCardDecoderV21::DealCharsetParam(
const std::string &charset, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
currentCharset_ = charset;
rawData->AppendParameter(VCARD_PARAM_CHARSET, charset);
}
@ -469,6 +509,10 @@ void VCardDecoderV21::DealCharsetParam(
void VCardDecoderV21::DealLanguageParam(
const std::string &language, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
auto strs = VCardUtils::Split(language, "-");
if (static_cast<int32_t>(strs.size()) != SIZE_TWO) {
TELEPHONY_LOGE("Language error");
@ -486,6 +530,10 @@ void VCardDecoderV21::DealLanguageParam(
void VCardDecoderV21::DealAnyParam(
const std::string &param, const std::string &paramValue, std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
rawData->AppendParameter(param, paramValue);
}
@ -534,6 +582,10 @@ bool VCardDecoderV21::ContainValue(const std::string &value, const std::vector<s
void VCardDecoderV21::DealAdrOrgN(const std::string &rawValue, std::shared_ptr<VCardRawData> rawData,
const std::string &fromCharSet, const std::string &toCharSet, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (currentEncoding_ == VCARD_PARAM_ENCODING_QP) {
std::string quotedPrintableValue = GetQuotedPrintableValue(rawValue, errorCode);
if (errorCode != TELEPHONY_SUCCESS) {
@ -664,6 +716,10 @@ std::vector<std::string> VCardDecoderV21::BuildListFromValue(const std::string &
void VCardDecoderV21::DealAgent(std::shared_ptr<VCardRawData> rawData, int32_t &errorCode)
{
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr!");
return;
}
if (VCardUtils::ToUpper(rawData->GetRawValue()).find("BEGIN : VCARD") != std::string::npos) {
TELEPHONY_LOGE("Agent data error");
errorCode = TELEPHONY_ERR_VCARD_FILE_INVALID;

View File

@ -67,6 +67,10 @@ void VCardEncoder::SetPhoneNumberEncodedCallback(std::shared_ptr<PhoneNumberEnco
void VCardEncoder::ContructContact(std::shared_ptr<VCardContact> contact,
std::shared_ptr<DataShare::DataShareResultSet> rawResultSet, int32_t &errorCode)
{
if (rawResultSet == nullptr) {
TELEPHONY_LOGE("rawResultSet is nullptr!");
return;
}
int32_t rawResultSetNum = rawResultSet->GoToFirstRow();
while (rawResultSetNum == 0 && errorCode == TELEPHONY_SUCCESS) {
int32_t index = 0;