蜂窝 apn关键能力适配

Signed-off-by: zhupanpan <zhupanpan4@huawei.com>
This commit is contained in:
zhupanpan 2024-03-27 22:48:06 +08:00
parent 482145e320
commit 2a42752ecf
5 changed files with 117 additions and 0 deletions

View File

@ -78,6 +78,7 @@ ohos_shared_library("tel_core_service") {
"$TELEPHONY_SIM_ROOT/src/operator_config_loader.cpp",
"$TELEPHONY_SIM_ROOT/src/operator_file_parser.cpp",
"$TELEPHONY_SIM_ROOT/src/operator_matching_rule.cpp",
"$TELEPHONY_SIM_ROOT/src/pdp_profile_rdb_helper.cpp",
"$TELEPHONY_SIM_ROOT/src/plmn_file.cpp",
"$TELEPHONY_SIM_ROOT/src/radio_protocol_controller.cpp",
"$TELEPHONY_SIM_ROOT/src/ruim_file.cpp",

View File

@ -43,6 +43,7 @@ private:
void CopyOperatorConfig(const OperatorConfig &from, OperatorConfig &to);
void SendSimMatchedOperatorInfo(int32_t slotId);
bool AnnounceOperatorConfigChanged(int32_t slotId);
void notifyInitApnConfigs(int32_t slotId);
inline static const std::string KEY_SLOTID = "slotId";
inline static const std::string OPERATOR_CONFIG_CHANGED = "operatorConfigChanged";
OperatorConfig opc_;

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_PDP_PROFILE_RDB_HELPER_H
#define OHOS_PDP_PROFILE_RDB_HELPER_H
#include <singleton.h>
#include "datashare_helper.h"
#include "datashare_predicates.h"
#include "datashare_result_set.h"
#include "datashare_values_bucket.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "uri.h"
namespace OHOS {
namespace Telephony {
class PdpProfileRdbHelper : public DelayedSingleton<PdpProfileRdbHelper> {
DECLARE_DELAYED_SINGLETON(PdpProfileRdbHelper);
public:
void notifyInitApnConfig(int32_t slotId);
private:
std::shared_ptr<DataShare::DataShareHelper> CreatePdpProfileDataHelper();
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_PDP_PROFILE_RDB_HELPER_H

View File

@ -22,6 +22,7 @@
#include "common_event_manager.h"
#include "common_event_support.h"
#include "core_manager_inner.h"
#include "pdp_profile_rdb_helper.h"
#include "radio_event.h"
#include "telephony_ext_wrapper.h"
@ -249,8 +250,24 @@ void OperatorConfigCache::SendSimMatchedOperatorInfo(int32_t slotId)
TELEPHONY_LOGI("OperatorConfigCache::SendSimMatchedOperatorInfo response = %{public}d", response);
}
void OperatorConfigCache::notifyInitApnConfigs(int32_t slotId)
{
SimState simState = SimState::SIM_STATE_UNKNOWN;
CoreManagerInner::GetInstance().GetSimState(slotId, simState);
if (simState != SimState::SIM_STATE_READY) {
return;
}
auto helper = PdpProfileRdbHelper::GetInstance();
if (helper == nullptr) {
TELEPHONY_LOGE("get PdpProfileRdbHelper Failed.");
}
TELEPHONY_LOGI("OperatorConfigCache:notifyInitApnConfigs end");
helper->notifyInitApnConfigs(slotId);
}
bool OperatorConfigCache::AnnounceOperatorConfigChanged(int32_t slotId)
{
notifyInitApnConfig(slotId);
SendSimMatchedOperatorInfo(slotId);
AAFwk::Want want;
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED);

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "pdp_profile_rdb_helper.h"
#include "telephony_log_wrapper.h"
static constexpr const char *PDP_PROFILE_RDB_URI = "datashare:///com.ohos.pdpprofileability/net";
static constexpr const char *PDP_PROFILE_RDB_INIT_URI =
"datashare:///com.ohos.pdpprofileability/net/pdp_profile/init?slotId=";
namespace OHOS {
namespace Telephony {
PdpProfileRdbHelper::PdpProfileRdbHelper() {}
PdpProfileRdbHelper::~PdpProfileRdbHelper() = default;
std::shared_ptr<DataShare::DataShareHelper> PdpProfileRdbHelper::CreatePdpProfileDataHelper()
{
auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saManager == nullptr) {
TELEPHONY_LOGE("Get system ability mgr failed.");
return nullptr;
}
auto remoteObj = saManager->GetSystemAbility(TELEPHONY_CORE_SERVICE_SYS_ABILITY_ID);
if (remoteObj == nullptr) {
TELEPHONY_LOGE("GetSystemAbility Service Failed.");
return nullptr;
}
return DataShare::DataShareHelper::Creator(remoteObj, PDP_PROFILE_RDB_URI);
}
void PdpProfileRdbHelper::notifyInitApnConfigs(int32_t slotId)
{
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreatePdpProfileDataHelper();
if (dataShareHelper == nullptr) {
TELEPHONY_LOGE("dataShareHelper is nullptr");
return;
}
std::vector<DataShare::DataShareValuesBucket> values;
Uri pdpProfileUri(static_cast<std::string>(PDP_PROFILE_RDB_INIT_URI) + std::to_string(slotId));
dataShareHelper->BatchInsert(pdpProfileUri, values);
dataShareHelper->Release();
dataShareHelper = nullptr;
}
} // namespace Telephony
} // namespace OHOS