mirror of
https://gitee.com/openharmony/request_request
synced 2024-11-23 15:00:48 +00:00
电话子系统在无SIM卡状况下先判断是否有SIM在获取对应的能力
Signed-off-by: Jeam_wang <jeam.wangwei@huawei.com>
This commit is contained in:
parent
6964eac5b4
commit
d8f9f24fa0
@ -41,6 +41,7 @@
|
||||
"ability_base",
|
||||
"hiviewdfx_hilog_native",
|
||||
"core_service",
|
||||
"cellular_data",
|
||||
"hilog_native",
|
||||
"distributed_notification_service",
|
||||
"c_utils",
|
||||
|
@ -31,6 +31,8 @@ third_path = "//third_party"
|
||||
|
||||
core_service_path = "//base/telephony/core_service/interfaces"
|
||||
|
||||
cellular_data_path = "//base/telephony/cellular_data/interfaces"
|
||||
|
||||
notification_path = "//base/notification/distributed_notification_service"
|
||||
|
||||
test_path = "//test/testfwk/developer_test/signature"
|
||||
@ -41,7 +43,16 @@ base_path = "//base/hiviewdfx"
|
||||
|
||||
declare_args() {
|
||||
request_telephony_core_service = false
|
||||
if (defined(global_parts_info.telephony_core_service)) {
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.telephony_core_service) &&
|
||||
global_parts_info.telephony_core_service) {
|
||||
request_telephony_core_service = true
|
||||
}
|
||||
|
||||
request_telephony_cellular_data = false
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.telephony_cellular_data) &&
|
||||
global_parts_info.telephony_cellular_data) {
|
||||
request_telephony_cellular_data = true
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ ohos_shared_library("request_service_c") {
|
||||
"${request_path}/common/include",
|
||||
"${request_path}/services/service/rust/src/c_wrapper/include",
|
||||
"${core_service_path}/innerkits/include",
|
||||
"${cellular_data_path}/innerkits/include",
|
||||
"${notification_path}/interfaces/inner_api",
|
||||
]
|
||||
sources = [
|
||||
@ -131,8 +132,11 @@ ohos_shared_library("request_service_c") {
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
defines = []
|
||||
if (request_telephony_core_service) {
|
||||
external_deps += [ "core_service:tel_core_service_api" ]
|
||||
if (request_telephony_core_service && request_telephony_cellular_data) {
|
||||
external_deps += [
|
||||
"cellular_data:tel_cellular_data_api",
|
||||
"core_service:tel_core_service_api",
|
||||
]
|
||||
defines += [ "REQUEST_TELEPHONY_CORE_SERVICE" ]
|
||||
}
|
||||
output_extension = "so"
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#ifdef REQUEST_TELEPHONY_CORE_SERVICE
|
||||
#include "core_service_client.h"
|
||||
#include "cellular_data_client.h"
|
||||
#endif
|
||||
#include "i_net_conn_callback.h"
|
||||
#include "log.h"
|
||||
@ -36,10 +37,7 @@
|
||||
#include "telephony_errors.h"
|
||||
#endif
|
||||
using namespace OHOS::NetManagerStandard;
|
||||
using namespace OHOS::Telephony;
|
||||
namespace OHOS::Request {
|
||||
constexpr int32_t INVALID_SLOT_ID = -1;
|
||||
|
||||
NetworkAdapter &NetworkAdapter::GetInstance()
|
||||
{
|
||||
static NetworkAdapter adapter;
|
||||
@ -141,14 +139,29 @@ int32_t NetworkAdapter::NetConnCallbackObserver::NetBlockStatusChange(sptr<NetHa
|
||||
void NetworkAdapter::NetConnCallbackObserver::UpdateRoaming()
|
||||
{
|
||||
#ifdef REQUEST_TELEPHONY_CORE_SERVICE
|
||||
REQUEST_HILOGI("upload roaming");
|
||||
constexpr int32_t INVALID_SLOT_ID = -1;
|
||||
int32_t maxSlotNum = DelayedRefSingleton<OHOS::Telephony::CoreServiceClient>::GetInstance().GetMaxSimCount();
|
||||
bool isSim = false;
|
||||
for (int32_t i = 0; i < maxSlotNum; ++i) {
|
||||
if (DelayedRefSingleton<OHOS::Telephony::CoreServiceClient>::GetInstance().IsSimActive(i)) {
|
||||
isSim = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSim) {
|
||||
REQUEST_HILOGE("no sim");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t slotId = INVALID_SLOT_ID;
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetPrimarySlotId(slotId);
|
||||
slotId = DelayedRefSingleton<OHOS::Telephony::CellularDataClient>::GetInstance().GetDefaultCellularDataSlotId();
|
||||
if (slotId <= INVALID_SLOT_ID) {
|
||||
REQUEST_HILOGE("GetDefaultCellularDataSlotId InValidData");
|
||||
return;
|
||||
}
|
||||
sptr<NetworkState> networkClient = nullptr;
|
||||
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetNetworkState(slotId, networkClient);
|
||||
sptr<OHOS::Telephony::NetworkState> networkClient = nullptr;
|
||||
DelayedRefSingleton<OHOS::Telephony::CoreServiceClient>::GetInstance().GetNetworkState(slotId, networkClient);
|
||||
if (networkClient == nullptr) {
|
||||
REQUEST_HILOGE("networkState is nullptr");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user