diff --git a/services/src/cellular_data_handler.cpp b/services/src/cellular_data_handler.cpp index 70212ddd0b241ff01d0fd0ca1be638e807c8b988..c53e686ff7725f40467e07a8431ed11e6d55f052 100644 --- a/services/src/cellular_data_handler.cpp +++ b/services/src/cellular_data_handler.cpp @@ -49,6 +49,7 @@ CellularDataHandler::CellularDataHandler(const EventFwk::CommonEventSubscribeInf void CellularDataHandler::Init() { + lastApnItem_ = new ApnItem(); apnManager_ = std::make_unique().release(); dataSwitchSettings_ = std::make_unique(slotId_); connectionManager_ = std::make_unique(slotId_).release(); @@ -69,7 +70,6 @@ void CellularDataHandler::Init() dataSwitchSettings_->LoadSwitchValue(); GetConfigurationFor5G(); SetRilLinkBandwidths(); - lastApnItem_ = new ApnItem(); } CellularDataHandler::~CellularDataHandler() @@ -291,6 +291,9 @@ void CellularDataHandler::ClearConnectionsOnUpdateApns(DisConnectionReason reaso auto apnItem = apnManager_->GetRilAttachApn(); if (!ApnHolder::IsCompatibleApnItem(lastApnItem_, apnItem, isRoaming)) { ClearAllConnections(reason); + if (lastApnItem_ == nullptr) { + lastApnItem_ = new ApnItem(); + } *lastApnItem_ = *apnItem; } }