DSDS2.0副卡未驻网发彩信主卡能恢复上网

Signed-off-by: 黄强 <huangqiang73@huawei.com>
This commit is contained in:
黄强 2024-11-22 11:24:31 +08:00
parent e9c890d74a
commit dd39add1f6
5 changed files with 103 additions and 30 deletions

View File

@ -143,6 +143,7 @@ private:
void OnRilAdapterHostDied(const AppExecFwk::InnerEvent::Pointer &event);
void HandleFactoryReset(const AppExecFwk::InnerEvent::Pointer &event);
void OnCleanAllDataConnectionsDone(const AppExecFwk::InnerEvent::Pointer &event);
void ResumeDataPermittedTimerOut(const AppExecFwk::InnerEvent::Pointer &event);
void CreateApnItem();
void UpdatePhysicalConnectionState(bool noActiveConnection);
bool IsVSimSlotId(int32_t slotId);
@ -166,6 +167,8 @@ private:
const int32_t simId, int32_t &profileIdValue);
void UpdateApnInfo(const int32_t profileId);
bool WriteEventCellularRequest(NetRequest request, int32_t state);
void DataConnCompleteUpdateState(const sptr<ApnHolder> &apnHolder,
const std::shared_ptr<SetupDataCallResultInfo> &resultInfo);
private:
sptr<ApnManager> apnManager_;
@ -264,6 +267,8 @@ private:
[this](const AppExecFwk::InnerEvent::Pointer &event) { RetryToSetupDatacall(event); } },
{ CellularDataEventCode::MSG_ESTABLISH_ALL_APNS_IF_CONNECTABLE,
[this](const AppExecFwk::InnerEvent::Pointer &event) { HandleEstablishAllApnsIfConnectable(event); } },
{ CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT,
[this](const AppExecFwk::InnerEvent::Pointer &event) { ResumeDataPermittedTimerOut(event); } },
};
};
} // namespace Telephony

View File

@ -246,6 +246,7 @@ static const int32_t DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT = 1000 * 10
static const int32_t ESTABLISH_DATA_CONNECTION_DELAY = 1 * 1000;
static const int32_t CONNECTION_DISCONNECTION_TIMEOUT = 180 * 1000;
static const int32_t CONNECTION_TASK_TIME = 170 * 1000;
static const int32_t RESUME_DATA_PERMITTED_TIMEOUT = 30 * 1000;
static const int32_t RECOVERY_TRIGGER_PACKET = 10;
static const int32_t ERROR_APN_ID = -1;
static const int32_t VALID_IP_SIZE = 2;

View File

@ -70,6 +70,7 @@ public:
static const uint32_t MSG_RETRY_TO_SETUP_DATACALL = BASE + 43;
static const uint32_t MSG_SM_UPDATE_NETWORK_INFO = BASE + 44;
static const uint32_t MSG_ESTABLISH_ALL_APNS_IF_CONNECTABLE = BASE + 45;
static const uint32_t MSG_RESUME_DATA_PERMITTED_TIMEOUT = BASE + 46;
};
} // namespace Telephony
} // namespace OHOS

View File

@ -579,6 +579,14 @@ bool CellularDataHandler::CheckAttachAndSimState(sptr<ApnHolder> &apnHolder)
bool isSimStateReadyOrLoaded = IsSimStateReadyOrLoaded();
TELEPHONY_LOGD("Slot%{public}d: attached: %{public}d simState: %{public}d isRilApnAttached: %{public}d",
slotId_, attached, isSimStateReadyOrLoaded, isRilApnAttached_);
if (apnHolder->IsMmsType() && isSimStateReadyOrLoaded && !attached) {
if (!HasInnerEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT)) {
SendEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT,
apnHolder->IsMmsType(), RESUME_DATA_PERMITTED_TIMEOUT);
}
SetDataPermittedForMms(true);
return false;
}
bool isEmergencyApn = apnHolder->IsEmergencyType();
if (!isEmergencyApn && !attached) {
CellularDataHiSysEvent::WriteDataActivateFaultEvent(slotId_, SWITCH_ON,
@ -821,34 +829,43 @@ void CellularDataHandler::EstablishDataConnectionComplete(const InnerEvent::Poin
TELEPHONY_LOGI("default apn has connected, to setup internal_default apn");
SendEvent(CellularDataEventCode::MSG_RETRY_TO_SETUP_DATACALL, DATA_CONTEXT_ROLE_INTERNAL_DEFAULT_ID, 0);
}
std::shared_ptr<CellularDataStateMachine> stateMachine = apnHolder->GetCellularDataStateMachine();
if (stateMachine != nullptr) {
std::string proxyIpAddress = "";
sptr<ApnItem> attachApn = apnManager_->GetRilAttachApn();
if (attachApn != nullptr) {
proxyIpAddress = attachApn->attr_.proxyIpAddress_;
}
stateMachine->UpdateHttpProxy(proxyIpAddress);
stateMachine->UpdateNetworkInfo(*resultInfo);
} else {
apnHolder->SetApnState(PROFILE_STATE_IDLE);
TELEPHONY_LOGE(
"Slot%{public}d:update network info stateMachine(%{public}d) is null", slotId_, resultInfo->flag);
DataConnCompleteUpdateState(apnHolder, resultInfo);
}
}
void CellularDataHandler::DataConnCompleteUpdateState(const sptr<ApnHolder> &apnHolder,
const std::shared_ptr<SetupDataCallResultInfo> &resultInfo)
{
std::shared_ptr<CellularDataStateMachine> stateMachine = apnHolder->GetCellularDataStateMachine();
if (stateMachine != nullptr) {
std::string proxyIpAddress = "";
sptr<ApnItem> attachApn = apnManager_->GetRilAttachApn();
if (attachApn != nullptr) {
proxyIpAddress = attachApn->attr_.proxyIpAddress_;
}
if (connectionManager_ != nullptr) {
connectionManager_->StartStallDetectionTimer();
connectionManager_->BeginNetStatistics();
}
if (!physicalConnectionActiveState_) {
physicalConnectionActiveState_ = true;
CoreManagerInner::GetInstance().DcPhysicalLinkActiveUpdate(slotId_, physicalConnectionActiveState_);
}
if (incallDataStateMachine_ != nullptr) {
InnerEvent::Pointer incallEvent = InnerEvent::Get(CellularDataEventCode::MSG_SM_INCALL_DATA_DATA_CONNECTED);
incallDataStateMachine_->SendEvent(incallEvent);
}
UpdateCellularDataConnectState(apnHolder->GetApnType());
UpdateApnInfo(apnHolder->GetCurrentApn()->attr_.profileId_);
stateMachine->UpdateHttpProxy(proxyIpAddress);
stateMachine->UpdateNetworkInfo(*resultInfo);
} else {
apnHolder->SetApnState(PROFILE_STATE_IDLE);
TELEPHONY_LOGE(
"Slot%{public}d:update network info stateMachine(%{public}d) is null", slotId_, resultInfo->flag);
}
if (connectionManager_ != nullptr) {
connectionManager_->StartStallDetectionTimer();
connectionManager_->BeginNetStatistics();
}
if (!physicalConnectionActiveState_) {
physicalConnectionActiveState_ = true;
CoreManagerInner::GetInstance().DcPhysicalLinkActiveUpdate(slotId_, physicalConnectionActiveState_);
}
if (incallDataStateMachine_ != nullptr) {
InnerEvent::Pointer incallEvent = InnerEvent::Get(CellularDataEventCode::MSG_SM_INCALL_DATA_DATA_CONNECTED);
incallDataStateMachine_->SendEvent(incallEvent);
}
UpdateCellularDataConnectState(apnHolder->GetApnType());
UpdateApnInfo(apnHolder->GetCurrentApn()->attr_.profileId_);
if (apnHolder->IsMmsType()) {
RemoveEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT);
}
}
@ -979,6 +996,10 @@ void CellularDataHandler::DisconnectDataComplete(const InnerEvent::Pointer &even
if (reason == DisConnectionReason::REASON_CHANGE_CONNECTION) {
HandleSortConnection();
}
if (apnHolder->IsMmsType()) {
SetDataPermittedForMms(false);
RemoveEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT);
}
}
void CellularDataHandler::RetryOrClearConnection(const sptr<ApnHolder> &apnHolder, DisConnectionReason reason,
@ -1005,6 +1026,20 @@ void CellularDataHandler::RetryOrClearConnection(const sptr<ApnHolder> &apnHolde
}
}
void CellularDataHandler::ResumeDataPermittedTimerOut(const AppExecFwk::InnerEvent::Pointer &event)
{
TELEPHONY_LOGI("SlotId=%{public}d, ResumeDataPermittedTimerOut", slotId_);
if (apnManager_ == nullptr) {
SetDataPermittedForMms(false);
return;
}
auto apnHolder = apnManager_->FindApnHolderById(DataContextRolesId::DATA_CONTEXT_ROLE_MMS_ID);
if (apnHolder == nullptr || apnHolder->GetApnState() == PROFILE_STATE_IDLE) {
TELEPHONY_LOGI("SlotId=%{public}d, mms resume data due time out", slotId_);
SetDataPermittedForMms(false);
}
}
void CellularDataHandler::RetryToSetupDatacall(const AppExecFwk::InnerEvent::Pointer &event)
{
int32_t apnId = event->GetParam();
@ -1057,9 +1092,6 @@ void CellularDataHandler::MsgEstablishDataConnection(const InnerEvent::Pointer &
}
TELEPHONY_LOGD("Slot%{public}d: APN holder type:%{public}s call:%{public}d", slotId_,
apnHolder->GetApnType().c_str(), apnHolder->IsDataCallEnabled());
if (apnHolder->IsMmsType()) {
SetDataPermittedForMms(apnHolder->IsDataCallEnabled());
}
if (apnHolder->IsDataCallEnabled()) {
AttemptEstablishDataConnection(apnHolder);
} else {

View File

@ -571,5 +571,39 @@ HWTEST_F(CellularDataHandlerBranchTest, CheckCellularDataSlotId, Function | Medi
EXPECT_FALSE(ret);
}
HWTEST_F(CellularDataHandlerBranchTest, ResumeDataPermittedTimerOut_001, Function | MediumTest | Level3)
{
InitCellularDataHandler();
InitMockManager();
auto event = AppExecFwk::InnerEvent::Get(0);
auto apnHolder =
cellularDataHandler_->apnManager_->FindApnHolderById(DataContextRolesId::DATA_CONTEXT_ROLE_MMS_ID);
apnHolder->SetApnState(PROFILE_STATE_IDLE);
cellularDataHandler_->ResumeDataPermittedTimerOut(event);
EXPECT_TRUE(cellularDataHandler_->dataSwitchSettings_->IsInternalDataOn());
cellularDataHandler_->apnManager_ = nullptr;
cellularDataHandler_->ResumeDataPermittedTimerOut(event);
EXPECT_TRUE(cellularDataHandler_->dataSwitchSettings_->IsInternalDataOn());
}
HWTEST_F(CellularDataHandlerBranchTest, CheckAttachAndSimState_001, Function | MediumTest | Level3)
{
InitCellularDataHandler();
InitMockManager();
auto apnHolder =
cellularDataHandler_->apnManager_->FindApnHolderById(DataContextRolesId::DATA_CONTEXT_ROLE_MMS_ID);
SimState simState = SimState::SIM_STATE_READY;
EXPECT_CALL(*mockSimManager, GetSimState(_, _)).WillRepeatedly(DoAll(SetArgReferee<1>(simState), Return(0)));
EXPECT_CALL(*mockNetworkSearchManager, GetPsRegState(_)).WillOnce(Return(0));
EXPECT_FALSE(cellularDataHandler_->CheckAttachAndSimState(apnHolder));
cellularDataHandler_->RemoveAllEvents();
EXPECT_CALL(*mockNetworkSearchManager, GetPsRegState(_)).WillOnce(Return(1));
cellularDataHandler_->CheckAttachAndSimState(apnHolder);
EXPECT_FALSE(cellularDataHandler_->HasInnerEvent(CellularDataEventCode::MSG_RESUME_DATA_PERMITTED_TIMEOUT));
}
} // namespace Telephony
} // namespace OHOS