mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-27 02:00:45 +00:00
make mainslot same with mainmodem
Signed-off-by: 1439925662@qq.com <1439925662@qq.com>
This commit is contained in:
parent
3f824ffa99
commit
ad1709174d
@ -32,6 +32,7 @@ public:
|
||||
|
||||
void Init();
|
||||
int32_t GetRadioProtocolTech(int32_t slotId);
|
||||
int32_t GetRadioProtocolModemId(int32_t slotId);
|
||||
void GetRadioProtocol(int32_t slotId);
|
||||
bool SetRadioProtocol(int32_t slotId);
|
||||
void UnRegisterEvents();
|
||||
|
@ -34,6 +34,7 @@ namespace OHOS {
|
||||
namespace Telephony {
|
||||
static const int32_t EVENT_CODE = 1;
|
||||
static const int32_t IMS_SWITCH_VALUE_UNKNOWN = -1;
|
||||
static const int32_t MAIN_MODEM_ID = 0;
|
||||
const int32_t SYSTEM_PARAMETER_LENGTH = 128;
|
||||
static const std::string PARAM_SIMID = "simId";
|
||||
static const std::string PARAM_SET_PRIMARY_STATUS = "setDone";
|
||||
@ -556,6 +557,13 @@ void MultiSimController::CheckIfNeedSwitchMainSlotId()
|
||||
CoreManagerInner::GetInstance().SetPrimarySlotId(defaultSlotId);
|
||||
});
|
||||
initDataTask.detach();
|
||||
} else if (radioProtocolController_->GetRadioProtocolModemId(defaultSlotId) != MAIN_MODEM_ID) {
|
||||
TELEPHONY_LOGI("main slot is different with modemid, need to set slot%{public}d primary", defaultSlotId);
|
||||
std::thread initDataTask([&, defaultSlotId = defaultSlotId]() {
|
||||
pthread_setname_np(pthread_self(), "SetPrimarySlotId");
|
||||
CoreManagerInner::GetInstance().SetPrimarySlotId(defaultSlotId);
|
||||
});
|
||||
initDataTask.detach();
|
||||
} else {
|
||||
TELEPHONY_LOGI("no need set main slot, defaultslot same main slot");
|
||||
SavePrimarySlotIdInfo(defaultSlotId);
|
||||
@ -854,7 +862,7 @@ int32_t MultiSimController::SetPrimarySlotId(int32_t slotId)
|
||||
TELEPHONY_LOGE("no sim card");
|
||||
return TELEPHONY_ERR_NO_SIM_CARD;
|
||||
}
|
||||
if (lastPrimarySlotId_ == slotId) {
|
||||
if (radioProtocolController_->GetRadioProtocolModemId(slotId) == MAIN_MODEM_ID) {
|
||||
TELEPHONY_LOGI("The current slot is the main slot, no need to set primary slot");
|
||||
SavePrimarySlotIdInfo(slotId);
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
|
@ -59,6 +59,12 @@ int32_t RadioProtocolController::GetRadioProtocolTech(int32_t slotId)
|
||||
return static_cast<int32_t>(radioProtocol_[slotId].technology);
|
||||
}
|
||||
|
||||
int32_t RadioProtocolController::GetRadioProtocolModemId(int32_t slotId)
|
||||
{
|
||||
std::unique_lock<std::mutex> radioProtocolLock(radioProtocolMutex_);
|
||||
return static_cast<int32_t>(radioProtocol_[slotId].modemId);
|
||||
}
|
||||
|
||||
void RadioProtocolController::GetRadioProtocol(int32_t slotId)
|
||||
{
|
||||
auto telRilManager = telRilManager_.lock();
|
||||
|
@ -2676,6 +2676,28 @@ HWTEST_F(BranchTest, Telephony_RadioProtocolController_001, Function | MediumTes
|
||||
EXPECT_FALSE(radioProtocolController->SetActiveSimToRil(INVALID_SLOTID, 1, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_RadioProtocolController_002
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(BranchTest, Telephony_RadioProtocolController_002, Function | MediumTest | Level1)
|
||||
{
|
||||
auto telRilManager = std::make_shared<TelRilManager>();
|
||||
AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(INVALID_SLOTID, 1);
|
||||
auto radioProtocolController =
|
||||
std::make_shared<RadioProtocolController>(std::weak_ptr<TelRilManager>(telRilManager));
|
||||
RadioProtocol radioProtocol1;
|
||||
radioProtocol1.slotId = SLOT_ID_0;
|
||||
radioProtocol1.sessionId = 0;
|
||||
radioProtocol1.phase = RadioProtocolPhase::RADIO_PROTOCOL_PHASE_INITIAL;
|
||||
radioProtocol1.technology = 0;
|
||||
radioProtocol1.modemId = 0;
|
||||
radioProtocol1.status = RadioProtocolStatus::RADIO_PROTOCOL_STATUS_NONE;
|
||||
radioProtocolController->radioProtocol_.push_back(radioProtocol1);
|
||||
EXPECT_EQ(radioProtocolController->GetRadioProtocolModemId(SLOT_ID_0), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_StkController_001
|
||||
* @tc.name test error branch
|
||||
|
Loading…
Reference in New Issue
Block a user