!236 fix: napi_radio.cpp中GetCellInformationCallback函数存在空指针引用,可能会导致系统崩溃

Merge pull request !236 from Hongjin Li/fix1
This commit is contained in:
openharmony_ci 2022-02-28 13:11:57 +00:00 committed by Gitee
commit 3c283734fa
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1606,18 +1606,24 @@ void GetCellInformationCallback(napi_env env, napi_status status, void *data)
napi_value info = nullptr;
napi_create_object(env, &info);
NapiUtil::SetPropertyBoolean(env, info, "isCamped", true);
NapiUtil::SetPropertyInt32(env, info, "timeStamp", infoItem->GetTimeStamp());
CellInformation::CellType cellType = infoItem->GetNetworkType();
uint64_t timeStamp = 0;
int32_t signalLevel = 0;
CellInformation::CellType cellType = CellInformation::CellType::CELL_TYPE_NONE;
if (infoItem != nullptr) {
timeStamp = infoItem->GetTimeStamp();
signalLevel = infoItem->GetSignalLevel();
cellType = infoItem->GetNetworkType();
}
NapiUtil::SetPropertyInt32(env, info, "timeStamp", timeStamp);
NapiUtil::SetPropertyInt32(env, info, "networkType", WrapCellInformationType(infoItem));
napi_value signalInformation = nullptr;
napi_create_object(env, &signalInformation);
int32_t signalType = WrapCellInformationType(infoItem);
NapiUtil::SetPropertyInt32(env, signalInformation, "signalType", signalType);
int32_t signalLevel = 0;
if (infoItem != nullptr) {
signalLevel = infoItem->GetSignalLevel();
}
NapiUtil::SetPropertyInt32(env, signalInformation, "signalLevel", signalLevel);
std::string name = "signalInformation";
napi_set_named_property(env, info, name.c_str(), signalInformation);
napi_set_named_property(env, info, "data", JudgmentData(env, infoItem, cellType));