mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 16:09:48 +00:00
!1222 支持OPL5G卡文件运营商名称匹配策略
Merge pull request !1222 from dingxiaochen/master
This commit is contained in:
commit
e3c90876f5
@ -131,6 +131,7 @@ protected:
|
||||
std::string fplmns_ = "";
|
||||
std::vector<std::shared_ptr<PlmnNetworkName>> pnnFiles_;
|
||||
std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles_;
|
||||
std::vector<std::shared_ptr<OperatorPlmnInfo>> opl5gFiles_;
|
||||
int lengthOfMnc_ = DEFAULT_MNC;
|
||||
int indexOfMailbox_ = 1;
|
||||
int fileToGet_ = 0;
|
||||
@ -140,6 +141,8 @@ protected:
|
||||
bool waitResult_ = false;
|
||||
static std::mutex mtx_;
|
||||
std::condition_variable processWait_;
|
||||
const int HEXADECIMAL = 16;
|
||||
const size_t OPL_5G_LENGTH = 10;
|
||||
const uint8_t BYTE_NUM = 0xFF;
|
||||
const uint8_t BYTE_NUM2 = 0x01;
|
||||
const uint8_t BYTE_NUM3 = 0x0F;
|
||||
|
@ -89,6 +89,7 @@ enum SimMessage {
|
||||
MSG_SIM_OBTAIN_CDMA_SUBSCRIPTION_DONE,
|
||||
MSG_SIM_SMS_ON_RUIM,
|
||||
MSG_SIM_OBTAIN_OPL_DONE,
|
||||
MSG_SIM_OBTAIN_OPL5G_DONE,
|
||||
MSG_SIM_OBTAIN_IMPI_DONE,
|
||||
MSG_SIM_OBTAIN_CSIM_SPN_DONE,
|
||||
MSG_SIM_OBTAIN_IST_DONE,
|
||||
@ -107,6 +108,7 @@ enum ElementaryFile {
|
||||
ELEMENTARY_FILE_SPN_SHORT_CPHS = 0x6F18,
|
||||
// 3GPP TS 51.011 V4.1.0 section 10 contents of the Elementary Files
|
||||
ELEMENTARY_FILE_ICCID = 0x2FE2,
|
||||
ELEMENTARY_FILE_OPL5G = 0x4F08,
|
||||
ELEMENTARY_FILE_IMG = 0x4F20,
|
||||
ELEMENTARY_FILE_HPLMN = 0x6F31,
|
||||
ELEMENTARY_FILE_SST = 0x6F38,
|
||||
|
@ -113,6 +113,7 @@ private:
|
||||
bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
@ -145,6 +146,7 @@ private:
|
||||
std::string ParseSpn(const std::string &rawData, int curState);
|
||||
void ParsePnn(const std::vector<std::string> &records);
|
||||
void ParseOpl(const std::vector<std::string> &records);
|
||||
void ParseOpl5g(const std::vector<std::string> &records);
|
||||
};
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -30,6 +30,7 @@ namespace Telephony {
|
||||
static const int DECIMAL_MAX = 10;
|
||||
static const int HALF_LEN = 2;
|
||||
static const int HALF_BYTE_LEN = 4;
|
||||
static const int LAC_RANGE_LEN = 6;
|
||||
static const int UCS_FLAG = 0x81;
|
||||
static const int UCS_WIDE_FLAG = 0x82;
|
||||
// Full Name IEI from TS 24.008
|
||||
|
@ -14,12 +14,14 @@
|
||||
*/
|
||||
|
||||
#include "icc_file.h"
|
||||
|
||||
#include "core_manager_inner.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "inner_event.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "radio_event.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "telephony_state_registry_client.h"
|
||||
#include "radio_event.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
@ -204,21 +206,29 @@ std::string IccFile::ObtainSPN()
|
||||
|
||||
std::string IccFile::ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired)
|
||||
{
|
||||
std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles = oplFiles_;
|
||||
sptr<NetworkState> networkState = nullptr;
|
||||
CoreManagerInner::GetInstance().GetNetworkStatus(slotId_, networkState);
|
||||
if (networkState != nullptr && !(opl5gFiles_.empty())) {
|
||||
NrState nrState = networkState->GetNrState();
|
||||
if (nrState == NrState::NR_NSA_STATE_SA_ATTACHED) {
|
||||
oplFiles = opl5gFiles_;
|
||||
}
|
||||
}
|
||||
bool roaming = (plmn.compare(operatorNumeric_) == 0 ? false : true);
|
||||
TELEPHONY_LOGI("ObtainEons roaming:%{public}d", roaming);
|
||||
if (plmn.empty() || pnnFiles_.empty() || (oplFiles_.empty() && roaming)) {
|
||||
if (plmn.empty() || pnnFiles_.empty() || (oplFiles.empty() && roaming)) {
|
||||
TELEPHONY_LOGE("ObtainEons is empty");
|
||||
return "";
|
||||
}
|
||||
int pnnIndex = 1;
|
||||
for (std::shared_ptr<OperatorPlmnInfo> opl : oplFiles_) {
|
||||
for (std::shared_ptr<OperatorPlmnInfo> opl : oplFiles) {
|
||||
if (opl == nullptr) {
|
||||
continue;
|
||||
}
|
||||
pnnIndex = -1;
|
||||
TELEPHONY_LOGI(
|
||||
"ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, "
|
||||
"opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d",
|
||||
TELEPHONY_LOGD("ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, "
|
||||
"opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d",
|
||||
plmn.c_str(), opl->plmnNumeric.c_str(), lac, opl->lacStart, opl->lacEnd, opl->pnnRecordId);
|
||||
if (plmn.compare(opl->plmnNumeric) == 0 &&
|
||||
((opl->lacStart == 0 && opl->lacEnd == 0xfffe) || (opl->lacStart <= lac && opl->lacEnd >= lac))) {
|
||||
|
@ -231,6 +231,10 @@ void SimFile::LoadSimFiles()
|
||||
fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL, eventOpl);
|
||||
fileToGet_++;
|
||||
|
||||
AppExecFwk::InnerEvent::Pointer eventOpl5g = BuildCallerInfo(MSG_SIM_OBTAIN_OPL5G_DONE);
|
||||
fileController_->ObtainAllLinearFixedFile(ELEMENTARY_FILE_OPL5G, eventOpl5g);
|
||||
fileToGet_++;
|
||||
|
||||
AppExecFwk::InnerEvent::Pointer phoneNumberEvent =
|
||||
CreateDiallingNumberPointer(MSG_SIM_OBTAIN_MSISDN_DONE, 0, 0, nullptr);
|
||||
diallingNumberHandler_->GetDiallingNumbers(
|
||||
@ -461,16 +465,50 @@ void SimFile::ParseOpl(const std::vector<std::string> &records)
|
||||
}
|
||||
std::shared_ptr<OperatorPlmnInfo> file = std::make_shared<OperatorPlmnInfo>();
|
||||
file->plmnNumeric = plmn;
|
||||
int base = 16; // convert to hexadecimal
|
||||
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, base);
|
||||
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, base);
|
||||
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, base);
|
||||
if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) {
|
||||
TELEPHONY_LOGI("InputValue is not a hexadecimal number");
|
||||
continue;
|
||||
}
|
||||
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL);
|
||||
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + HALF_BYTE_LEN, HALF_BYTE_LEN), 0, HEXADECIMAL);
|
||||
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + BYTE_LENGTH, HALF_LEN), 0, HEXADECIMAL);
|
||||
TELEPHONY_LOGI("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d",
|
||||
file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId);
|
||||
oplFiles_.push_back(file);
|
||||
}
|
||||
}
|
||||
|
||||
void SimFile::ParseOpl5g(const std::vector<std::string> &records)
|
||||
{
|
||||
opl5gFiles_.clear();
|
||||
if (records.empty()) {
|
||||
TELEPHONY_LOGI("ParseOpl5g records is empty");
|
||||
return;
|
||||
}
|
||||
for (const auto &dataOpl : records) {
|
||||
TELEPHONY_LOGD("ParseOpl5g: %{public}s", dataOpl.c_str());
|
||||
if (dataOpl.size() != (OPL_5G_LENGTH + OPL_5G_LENGTH)) {
|
||||
continue;
|
||||
}
|
||||
std::string plmn = SIMUtils::BcdPlmnConvertToString(dataOpl, 0);
|
||||
if (plmn.empty()) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<OperatorPlmnInfo> file = std::make_shared<OperatorPlmnInfo>();
|
||||
file->plmnNumeric = plmn;
|
||||
if (!regex_match(dataOpl, std::regex("[0-9a-fA-F]+"))) {
|
||||
TELEPHONY_LOGI("InputValue is not a hexadecimal number");
|
||||
continue;
|
||||
}
|
||||
file->lacStart = stoi(dataOpl.substr(MCCMNC_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL);
|
||||
file->lacEnd = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN, LAC_RANGE_LEN), 0, HEXADECIMAL);
|
||||
file->pnnRecordId = stoi(dataOpl.substr(MCCMNC_LEN + LAC_RANGE_LEN + LAC_RANGE_LEN, HALF_LEN), 0, HEXADECIMAL);
|
||||
TELEPHONY_LOGD("plmnNumeric: %{public}s, lacStart: %{public}d, lacEnd: %{public}d, pnnRecordId: %{public}d",
|
||||
file->plmnNumeric.c_str(), file->lacStart, file->lacEnd, file->pnnRecordId);
|
||||
opl5gFiles_.push_back(file);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<UsimFunctionHandle> SimFile::ObtainUsimFunctionHandle()
|
||||
{
|
||||
return UsimFunctionHandle_;
|
||||
@ -1274,9 +1312,6 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
if (object->exception == nullptr) {
|
||||
ParseOpl(object->fileResults);
|
||||
}
|
||||
for (std::string str : object->fileResults) {
|
||||
TELEPHONY_LOGI("ProcessGetOplDone: %{public}s", str.c_str());
|
||||
}
|
||||
} else {
|
||||
TELEPHONY_LOGE("ProcessGetOplDone: get null pointer!!!");
|
||||
}
|
||||
@ -1284,6 +1319,32 @@ bool SimFile::ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
|
||||
bool SimFile::ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
TELEPHONY_LOGD("ProcessGetOpl5gDone: start");
|
||||
bool isFileProcessResponse = true;
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("event is nullptr!");
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
std::unique_ptr<ControllerToFileMsg> fd = event->GetUniqueObject<ControllerToFileMsg>();
|
||||
if (fd != nullptr) {
|
||||
if (fd->exception != nullptr) {
|
||||
TELEPHONY_LOGE("ProcessGetOpl5gDone: get error result");
|
||||
}
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
std::shared_ptr<MultiRecordResult> object = event->GetSharedObject<MultiRecordResult>();
|
||||
if (object == nullptr) {
|
||||
TELEPHONY_LOGE("ProcessGetOpl5gDone: get null pointer!!!");
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
if (object->exception == nullptr) {
|
||||
ParseOpl5g(object->fileResults);
|
||||
}
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
|
||||
bool SimFile::ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
bool isFileProcessResponse = false;
|
||||
@ -1497,6 +1558,7 @@ void SimFile::InitMemberFunc()
|
||||
memberFuncMap_[MSG_SIM_UPDATE_DONE] = &SimFile::ProcessUpdateDone;
|
||||
memberFuncMap_[MSG_SIM_OBTAIN_PNN_DONE] = &SimFile::ProcessGetPnnDone;
|
||||
memberFuncMap_[MSG_SIM_OBTAIN_OPL_DONE] = &SimFile::ProcessGetOplDone;
|
||||
memberFuncMap_[MSG_SIM_OBTAIN_OPL5G_DONE] = &SimFile::ProcessGetOpl5gDone;
|
||||
memberFuncMap_[MSG_SIM_OBTAIN_ALL_SMS_DONE] = &SimFile::ProcessGetAllSmsDone;
|
||||
memberFuncMap_[MSG_SIM_MARK_SMS_READ_DONE] = &SimFile::ProcessMarkSms;
|
||||
memberFuncMap_[MSG_SIM_SMS_ON_SIM] = &SimFile::ProcessSmsOnSim;
|
||||
|
@ -51,6 +51,7 @@ std::string UsimFileController::ObtainUsimElementFilePath(int efId)
|
||||
case ELEMENTARY_FILE_MBDN:
|
||||
case ELEMENTARY_FILE_PNN:
|
||||
case ELEMENTARY_FILE_OPL:
|
||||
case ELEMENTARY_FILE_OPL5G:
|
||||
case ELEMENTARY_FILE_SPDI:
|
||||
case ELEMENTARY_FILE_SST:
|
||||
case ELEMENTARY_FILE_CFIS:
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "addcoreservicetoken_fuzzer.h"
|
||||
#include "core_service.h"
|
||||
#include "napi_util.h"
|
||||
#include "sim_file.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "unistd.h"
|
||||
|
||||
@ -33,6 +34,7 @@ constexpr int32_t SLOT_NUM = 2;
|
||||
constexpr int32_t TYPE_NUM = 2;
|
||||
constexpr int32_t TWO_INT_NUM = 2;
|
||||
constexpr int32_t SLEEP_TIME_SECONDS = 10;
|
||||
bool g_flag = false;
|
||||
|
||||
bool IsServiceInited()
|
||||
{
|
||||
@ -152,6 +154,27 @@ void SimAuthentication(const uint8_t *data, size_t size)
|
||||
DelayedSingleton<CoreService>::GetInstance()->OnSimAuthentication(dataMessageParcel, reply);
|
||||
}
|
||||
|
||||
void ParseOpl5g(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (!IsServiceInited()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_flag) {
|
||||
return;
|
||||
}
|
||||
g_flag = true;
|
||||
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile");
|
||||
std::shared_ptr<SimFile> simFile = std::make_shared<SimFile>(eventLoopRecord, simStateManager);
|
||||
std::string fileData(reinterpret_cast<const char *>(data), size);
|
||||
std::vector<std::string> records;
|
||||
records.push_back(fileData);
|
||||
simFile->ParseOpl5g(records);
|
||||
}
|
||||
|
||||
void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
@ -164,6 +187,7 @@ void DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
|
||||
GetVoiceMailNumber(data, size);
|
||||
QueryIccDiallingNumbers(data, size);
|
||||
SimAuthentication(data, size);
|
||||
ParseOpl5g(data, size);
|
||||
return;
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -413,6 +413,7 @@ HWTEST_F(BranchTest, Telephony_SimFile_002, Function | MediumTest | Level1)
|
||||
EXPECT_TRUE(simFile->ProcessGetEhplmnDone(event));
|
||||
EXPECT_TRUE(simFile->ProcessGetPnnDone(event));
|
||||
EXPECT_TRUE(simFile->ProcessGetOplDone(event));
|
||||
EXPECT_TRUE(simFile->ProcessGetOpl5gDone(event));
|
||||
EXPECT_FALSE(simFile->ProcessUpdateDone(event));
|
||||
EXPECT_TRUE(simFile->ProcessSetCphsMailbox(event));
|
||||
EXPECT_TRUE(simFile->ProcessGetFplmnDone(event));
|
||||
@ -504,6 +505,12 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1)
|
||||
simFile->ParseOpl(emptyRecords);
|
||||
simFile->ParsePnn(records);
|
||||
simFile->ParseOpl(records);
|
||||
std::vector<std::string> invalidRecords = { "64F0100000GGGG02", "64F0000000GGGG01" };
|
||||
simFile->ParseOpl(invalidRecords);
|
||||
std::vector<std::string> invalidPlmnRecords = { "F640100000FFFE02", "F640000000FFFE01" };
|
||||
simFile->ParseOpl(invalidPlmnRecords);
|
||||
std::vector<std::string> records5g = { "64F0100000FFFE02", "64F0000000FFFE01" };
|
||||
simFile->ParseOpl(records5g);
|
||||
SimFile::SpnStatus newStatus;
|
||||
EXPECT_TRUE(simFile->IsContinueGetSpn(false, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus));
|
||||
EXPECT_TRUE(simFile->IsContinueGetSpn(true, SimFile::SpnStatus::OBTAIN_SPN_NONE, newStatus));
|
||||
@ -522,6 +529,35 @@ HWTEST_F(BranchTest, Telephony_SimFile_004, Function | MediumTest | Level1)
|
||||
EXPECT_EQ(simFile->ParseSpn("", 0), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimFile_005
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(BranchTest, Telephony_SimFile_005, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
telRilManager->OnInit();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventLoopRecord = AppExecFwk::EventRunner::Create("SimFile");
|
||||
std::shared_ptr<SimFile> simFile = std::make_shared<SimFile>(eventLoopRecord, simStateManager);
|
||||
std::vector<std::string> emptyRecords = {};
|
||||
simFile->ParseOpl5g(emptyRecords);
|
||||
EXPECT_TRUE(simFile->opl5gFiles_.empty());
|
||||
std::vector<std::string> records = { "46000", "46002", "46004", "46007", "46008" };
|
||||
simFile->ParseOpl5g(records);
|
||||
EXPECT_TRUE(simFile->opl5gFiles_.empty());
|
||||
std::vector<std::string> invalidRecords = { "64F010000000GGGGGG02", "64F000000000GGGGGG01" };
|
||||
simFile->ParseOpl5g(invalidRecords);
|
||||
EXPECT_TRUE(simFile->opl5gFiles_.empty());
|
||||
std::vector<std::string> invalidPlmnRecords = { "F64010000000FFFFFE02", "F64000000000FFFFFE01" };
|
||||
simFile->ParseOpl5g(invalidPlmnRecords);
|
||||
EXPECT_TRUE(simFile->opl5gFiles_.empty());
|
||||
std::vector<std::string> records5g = { "64F010000000FFFFFE02", "64F000000000FFFFFE01" };
|
||||
simFile->ParseOpl5g(records5g);
|
||||
EXPECT_FALSE(simFile->opl5gFiles_.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_ISimFile_001
|
||||
* @tc.name test error branch
|
||||
@ -1899,6 +1935,7 @@ HWTEST_F(BranchTest, Telephony_UsimFileController_001, Function | MediumTest | L
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_MBDN), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_PNN), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_OPL5G), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SPDI), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_SST), "");
|
||||
EXPECT_NE(uSimFileController->ObtainElementFilePath(ELEMENTARY_FILE_CFIS), "");
|
||||
|
Loading…
Reference in New Issue
Block a user