!1780 add telephony vsim support -- core_service.

Merge pull request !1780 from clevercong/mysubmit
This commit is contained in:
openharmony_ci 2024-02-28 06:58:48 +00:00 committed by Gitee
commit 0d258c2ee5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 63 additions and 13 deletions

View File

@ -70,16 +70,12 @@ inline T GetMaxSlotCount()
template<typename T>
inline T GetVSimModemCount()
{
#ifdef OHOS_BUILD_ENABLE_TELEPHONY_VSIM
if (vSimModemCount_ == VSIM_DEFAULT_VALUE) {
char vSimModemCount[SYSPARA_SIZE] = { 0 };
GetParameter(VSIM_MODEM_COUNT_STR, DEFAULT_VSIM_MODEM_COUNT, vSimModemCount, SYSPARA_SIZE);
vSimModemCount_ = std::atoi(vSimModemCount);
}
return vSimModemCount_;
#else
return VSIM_DEFAULT_VALUE;
#endif
}
template<typename T>

1
services/sim/include/multi_sim_monitor.h Executable file → Normal file
View File

@ -48,6 +48,7 @@ public:
void NotifySimAccountChanged();
void RegisterSimNotify();
void UnRegisterSimNotify();
bool IsVSimSlotId(int32_t slotId);
public:
enum {

13
services/sim/src/multi_sim_monitor.cpp Executable file → Normal file
View File

@ -22,6 +22,7 @@
#include "os_account_manager_wrapper.h"
#include "radio_event.h"
#include "string_ex.h"
#include "telephony_ext_wrapper.h"
namespace OHOS {
namespace Telephony {
@ -135,7 +136,7 @@ void MultiSimMonitor::RegisterCoreNotify(
TELEPHONY_LOGE("controller_ is nullptr");
return;
}
if (controller_->IsSimActive(slotId)) {
if (controller_->IsSimActive(slotId) || IsVSimSlotId(slotId)) {
TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_SIM_ACCOUNT_LOADED, slotId, 0);
}
}
@ -145,6 +146,16 @@ bool MultiSimMonitor::IsValidSlotId(int32_t slotId)
return (slotId >= DEFAULT_SIM_SLOT_ID) && (slotId < SIM_SLOT_COUNT);
}
bool MultiSimMonitor::IsVSimSlotId(int32_t slotId)
{
if (TELEPHONY_EXT_WRAPPER.getVSimSlotId_) {
int vSimSlotId = DEFAULT_SIM_SLOT_ID_REMOVE;
TELEPHONY_EXT_WRAPPER.getVSimSlotId_(vSimSlotId);
return vSimSlotId == slotId;
}
return false;
}
int32_t MultiSimMonitor::RegisterSimAccountCallback(
const std::string &bundleName, const sptr<SimAccountCallback> &callback)
{

View File

@ -1066,8 +1066,9 @@ void SimManager::RegisterCoreNotify(int32_t slotId, const std::shared_ptr<AppExe
}
simStateManager_[slotId]->RegisterCoreNotify(handler, what);
} else if (what == RadioEvent::RADIO_SIM_ACCOUNT_LOADED) {
if ((!IsValidSlotId(slotId)) || (multiSimMonitor_ == nullptr)) {
TELEPHONY_LOGE("slotId is invalid or multiSimMonitor_ is nullptr");
// IsVSimSlotId is used for the callback function can be registered in the VSIM card.
if ((!IsValidSlotId(slotId) && !multiSimMonitor_->IsVSimSlotId(slotId)) || (multiSimMonitor_ == nullptr)) {
TELEPHONY_LOGE("slotId is invalid or multiSimMonitor_ is nullptr !");
return;
}
multiSimMonitor_->RegisterCoreNotify(slotId, handler, what);

8
services/sim/src/sim_state_handle.cpp Executable file → Normal file
View File

@ -463,7 +463,7 @@ std::string SimStateHandle::GetAidByCardType(CardType type)
void SimStateHandle::GetSimCardData(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event)
{
TELEPHONY_LOGI("SimStateHandle::GetSimCardData slotId = %{public}d", slotId);
TELEPHONY_LOGD("SimStateHandle::GetSimCardData slotId = %{public}d", slotId);
int32_t error = 0;
IccState iccState;
std::shared_ptr<CardStatusInfo> param = event->GetSharedObject<CardStatusInfo>();
@ -476,11 +476,11 @@ void SimStateHandle::GetSimCardData(int32_t slotId, const AppExecFwk::InnerEvent
iccState.simType_ = param->simType;
iccState.simStatus_ = param->simState;
modemInitDone_ = true;
TELEPHONY_LOGI("SimStateHandle::GetSimCardData(), simType_ = %{public}d, simStatus_ = %{public}d",
iccState.simType_, iccState.simStatus_);
TELEPHONY_LOGI("SimStateHandle::GetSimCardData(), slot%{public}d, type = %{public}d, status = %{public}d",
slotId, iccState.simType_, iccState.simStatus_);
} else {
error = static_cast<int32_t>(response->error);
TELEPHONY_LOGI("SimStateHandle::GetSimCardData(), error = %{public}d", error);
TELEPHONY_LOGI("SimStateHandle::GetSimCardData(), slot%{public}d, error = %{public}d", slotId, error);
return;
}
ProcessIccCardState(iccState, slotId);

View File

@ -69,7 +69,7 @@ public:
typedef void (*IS_VSIM_IN_STATUS)(int32_t slotId, int32_t type, bool &status);
typedef void (*GET_VSIM_SLOT_ID)(int32_t &slotId);
typedef void (*ON_ALL_FILES_FETCHED_EXT)(int32_t slotId);
typedef void (*PUT_VSIM_EXTRA_INFO)(OHOS::AAFwk::Want &want, int32_t slotId, std::string value);
typedef void (*PUT_VSIM_EXTRA_INFO)(OHOS::AAFwk::Want &want, int32_t slotId, int32_t value);
typedef void (*CHANGE_SPN_AND_RULE_EXT)(std::string &spn, int32_t &rule, bool &showSpn);
typedef void (*GET_VSIM_CARD_STATE)(int32_t &cardType);
typedef bool (*GET_SIM_ID_EXT)(int32_t slotId, int32_t &simId);

View File

@ -129,7 +129,7 @@ void TelephonyExtWrapper::InitTelephonyExtWrapperForCust()
void TelephonyExtWrapper::InitTelephonyExtWrapperForVSim()
{
TELEPHONY_LOGI("[VSIM] telephony ext wrapper init begin");
telephonyVSimWrapperHandle_ = dlopen(TELEPHONY_EXT_WRAPPER_PATH.c_str(), RTLD_NOW);
telephonyVSimWrapperHandle_ = dlopen(TELEPHONY_VSIM_WRAPPER_PATH.c_str(), RTLD_NOW);
if (telephonyVSimWrapperHandle_ == nullptr) {
TELEPHONY_LOGE("libtel_vsim_symbol.z.so was not loaded, error: %{public}s", dlerror());
return;

View File

@ -22,6 +22,7 @@
#include "operator_config_cache.h"
#include "sim_test_util.h"
#include "tel_ril_callback.h"
#include "telephony_ext_wrapper.h"
namespace OHOS {
namespace Telephony {
@ -143,6 +144,46 @@ HWTEST_F(SimTest, Telephony_VSim_GetMaxSimSlot_0100, Function | MediumTest | Lev
#endif
}
/**
* @tc.number Telephony_VSim_Wrapper_0100
* @tc.name InitExtraModule
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_VSim_Wrapper_0100, Function | MediumTest | Level1)
{
TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForVSim();
if (TELEPHONY_EXT_WRAPPER.telephonyVSimWrapperHandle_ != nullptr) {
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.isVSimInStatus_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getVSimSlotId_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.onAllFilesFetchedExt_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.putVSimExtraInfo_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.changeSpnAndRuleExt_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getVSimCardState_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getSimIdExt_ != nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getSlotIdExt_ != nullptr);
}
}
/**
* @tc.number Telephony_VSim_Wrapper_0200
* @tc.name InitExtraModule
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_VSim_Wrapper_0200, Function | MediumTest | Level1)
{
TELEPHONY_EXT_WRAPPER.InitTelephonyExtWrapperForVSim();
if (TELEPHONY_EXT_WRAPPER.telephonyVSimWrapperHandle_ == nullptr) {
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.isVSimInStatus_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getVSimSlotId_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.onAllFilesFetchedExt_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.putVSimExtraInfo_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.changeSpnAndRuleExt_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getVSimCardState_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getSimIdExt_ == nullptr);
EXPECT_TRUE(TELEPHONY_EXT_WRAPPER.getSlotIdExt_ == nullptr);
}
}
#else // TEL_TEST_UNSUPPORT
/**
* @tc.number Telephony_Sim_MockTest_0100