去激活状态下modem上电问题

Signed-off-by: zouxuebin <1593648@qq.com>
This commit is contained in:
zouxuebin 2024-08-13 14:58:36 +08:00
parent e5bbdc2935
commit d53b6b2af5
3 changed files with 35 additions and 3 deletions

View File

@ -104,6 +104,7 @@ public:
private:
void RadioOffOrUnavailableState(int32_t radioState) const;
void SetRadioOffWhenAirplaneIsOn();
void SetRadioOffWhenSimDeactive();
void GetRadioStateResponse(const AppExecFwk::InnerEvent::Pointer &event);
void SetRadioStateResponse(const AppExecFwk::InnerEvent::Pointer &event);
void SimStateChange(const AppExecFwk::InnerEvent::Pointer &);

View File

@ -500,7 +500,6 @@ void NetworkSearchHandler::SimRecordsLoaded(const AppExecFwk::InnerEvent::Pointe
void NetworkSearchHandler::RadioStateChange(const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
TELEPHONY_LOGE("NetworkSearchHandler::RadioStateChange event is nullptr!");
return;
}
std::shared_ptr<Int32Parcel> object = event->GetSharedObject<Int32Parcel>();
@ -525,6 +524,7 @@ void NetworkSearchHandler::RadioStateChange(const AppExecFwk::InnerEvent::Pointe
firstInit_ = false;
InitGetNetworkSelectionMode();
SetRadioOffWhenAirplaneIsOn();
SetRadioOffWhenSimDeactive();
RadioOnState();
break;
}
@ -562,6 +562,29 @@ void NetworkSearchHandler::SetRadioOffWhenAirplaneIsOn()
}
}
void NetworkSearchHandler::SetRadioOffWhenSimDeactive()
{
auto networkSearchManager = networkSearchManager_.lock();
if (networkSearchManager == nullptr) {
TELEPHONY_LOGE("NetworkSearchHandler::SetRadioOffWhenSimDeactive failed to get NetworkSearchManager");
return;
}
auto simManager = networkSearchManager->GetSimManager();
if (simManager == nullptr) {
return;
}
bool hasSim = false;
simManager->HasSimCard(slotId_, hasSim);
TELEPHONY_LOGD("SetRadioOffWhenSimDeactive slotId: %{public}d, IsSetActiveSimInProgress: %{public}d, IsSimActive:"
" %{public}d, IsPowerOnPrimaryRadioWhenNoSim: %{public}d",
slotId_, simManager->IsSetActiveSimInProgress(slotId_),
simManager->IsSimActive(slotId_), IsPowerOnPrimaryRadioWhenNoSim());
if (hasSim && !IsPowerOnPrimaryRadioWhenNoSim()
&& !simManager->IsSetActiveSimInProgress(slotId_) && !simManager->IsSimActive(slotId_)) {
networkSearchManager->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_OFF), 0);
}
}
void NetworkSearchHandler::RadioRestrictedState(const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
@ -759,8 +782,15 @@ void NetworkSearchHandler::RadioOnWhenHasSim(std::shared_ptr<NetworkSearchManage
}
bool hasSim = false;
simManager->HasSimCard(slotId_, hasSim);
if (!isAirplaneMode && (hasSim || IsPowerOnPrimaryRadioWhenNoSim()) && radioState == CORE_SERVICE_POWER_OFF &&
!IsSatelliteOn()) {
TELEPHONY_LOGD("soltid: %{public}d, IsSimActive: %{public}d, hasSim: %{public}d, isAirplaneMode: "
"%{public}d, IsSetActiveSimInProgress: %{public}d, IsPowerOnPrimaryRadioWhenNoSim: %{public}d",
slotId_, simManager->IsSimActive(slotId_), hasSim, isAirplaneMode,
simManager->IsSetActiveSimInProgress(slotId_), IsPowerOnPrimaryRadioWhenNoSim());
bool hasSimAndActive =
(hasSim && (!simManager->IsSetActiveSimInProgress(slotId_) && simManager->IsSimActive(slotId_)));
bool primarySimNoSim = (!hasSim && IsPowerOnPrimaryRadioWhenNoSim());
if (!isAirplaneMode && (hasSimAndActive || primarySimNoSim)
&& radioState == CORE_SERVICE_POWER_OFF && !IsSatelliteOn()) {
networkSearchManager->SetRadioState(slotId_, static_cast<bool>(ModemPowerState::CORE_SERVICE_POWER_ON), 0);
}
}

View File

@ -2465,6 +2465,7 @@ HWTEST_F(BranchTest, Telephony_NetworkSearchHandler_003, Function | MediumTest |
networkSearchHandler->NetworkSearchResult(event);
event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_NEIGHBORING_CELL_INFO);
networkSearchHandler->RadioGetNeighboringCellInfo(event);
networkSearchHandler->SetRadioOffWhenSimDeactive();
EXPECT_EQ(networkSearchHandler->HandleRrcStateChanged(status), TELEPHONY_ERR_SUCCESS);
EXPECT_EQ(networkSearchHandler->RevertLastTechnology(), TELEPHONY_ERR_SUCCESS);
networkSearchHandler->IsPowerOnPrimaryRadioWhenNoSim();