mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 08:00:07 +00:00
add dfx
Signed-off-by: qian-nan-xu <xuqiannan@huawei.com>
This commit is contained in:
parent
7f95bc263d
commit
11b3450e84
@ -16,6 +16,7 @@
|
||||
#include "core_service_dump_helper.h"
|
||||
|
||||
#include "core_service.h"
|
||||
#include "enum_convert.h"
|
||||
#include "signal_info.h"
|
||||
#include "signal_information.h"
|
||||
|
||||
@ -71,10 +72,10 @@ void CoreServiceDumpHelper::ShowCoreServiceInfo(std::string &result) const
|
||||
result.append(std::to_string(i));
|
||||
result.append("\n");
|
||||
result.append("IsSimActive = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->IsSimActive(i)));
|
||||
result.append(GetBoolValue(DelayedSingleton<CoreService>::GetInstance()->IsSimActive(i)));
|
||||
result.append("\n");
|
||||
result.append("IsNrSupported = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->IsNrSupported(i)));
|
||||
result.append(GetBoolValue(DelayedSingleton<CoreService>::GetInstance()->IsNrSupported(i)));
|
||||
result.append("\n");
|
||||
result.append("SignalLevel = ");
|
||||
std::vector<sptr<SignalInformation>> signals =
|
||||
@ -82,10 +83,10 @@ void CoreServiceDumpHelper::ShowCoreServiceInfo(std::string &result) const
|
||||
result.append(std::to_string(signals[0]->GetSignalLevel()));
|
||||
result.append("\n");
|
||||
result.append("CardType = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->GetCardType(i)));
|
||||
result.append(GetCardType(DelayedSingleton<CoreService>::GetInstance()->GetCardType(i)));
|
||||
result.append("\n");
|
||||
result.append("SimState = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->GetSimState(i)));
|
||||
result.append(GetSimState(DelayedSingleton<CoreService>::GetInstance()->GetSimState(i)));
|
||||
result.append("\n");
|
||||
result.append("Spn = ");
|
||||
result.append(to_utf8(DelayedSingleton<CoreService>::GetInstance()->GetSimSpn(i)));
|
||||
@ -94,10 +95,12 @@ void CoreServiceDumpHelper::ShowCoreServiceInfo(std::string &result) const
|
||||
result.append(to_utf8(DelayedSingleton<CoreService>::GetInstance()->GetOperatorName(i)));
|
||||
result.append("\n");
|
||||
result.append("PsRadioTech = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->GetPsRadioTech(i)));
|
||||
result.append(
|
||||
GetCellularDataConnectionNetworkType(DelayedSingleton<CoreService>::GetInstance()->GetPsRadioTech(i)));
|
||||
result.append("\n");
|
||||
result.append("CsRadioTech = ");
|
||||
result.append(std::to_string(DelayedSingleton<CoreService>::GetInstance()->GetCsRadioTech(i)));
|
||||
result.append(
|
||||
GetCellularDataConnectionNetworkType(DelayedSingleton<CoreService>::GetInstance()->GetCsRadioTech(i)));
|
||||
result.append("\n");
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ ohos_shared_library("libtel_common") {
|
||||
include_dirs = [ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" ]
|
||||
|
||||
sources = [
|
||||
"common/src/enum_convert.cpp",
|
||||
"common/src/str_convert.cpp",
|
||||
"common/src/telephony_common_utils.cpp",
|
||||
"common/src/telephony_permission.cpp",
|
||||
|
115
utils/common/include/enum_convert.h
Normal file
115
utils/common/include/enum_convert.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 ENUM_CONVERT_H
|
||||
#define ENUM_CONVERT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
enum class TelephonyCardType {
|
||||
UNKNOWN_CARD = -1,
|
||||
SINGLE_MODE_SIM_CARD = 10,
|
||||
SINGLE_MODE_USIM_CARD = 20,
|
||||
SINGLE_MODE_RUIM_CARD = 30,
|
||||
DUAL_MODE_CG_CARD = 40,
|
||||
CT_NATIONAL_ROAMING_CARD = 41,
|
||||
CU_DUAL_MODE_CARD = 42,
|
||||
DUAL_MODE_TELECOM_LTE_CARD = 43,
|
||||
DUAL_MODE_UG_CARD = 50,
|
||||
SINGLE_MODE_ISIM_CARD = 60,
|
||||
};
|
||||
|
||||
enum class TelephonySimState {
|
||||
SIM_STATE_UNKNOWN,
|
||||
SIM_STATE_NOT_PRESENT,
|
||||
SIM_STATE_LOCKED,
|
||||
SIM_STATE_NOT_READY,
|
||||
SIM_STATE_READY,
|
||||
SIM_STATE_LOADED
|
||||
};
|
||||
|
||||
enum class TelephonyDataConnectionStatus {
|
||||
DATA_STATE_DISCONNECTED = 11,
|
||||
DATA_STATE_CONNECTING = 12,
|
||||
DATA_STATE_CONNECTED = 13,
|
||||
DATA_STATE_SUSPENDED = 14
|
||||
};
|
||||
|
||||
enum class TelephonyCallState {
|
||||
CALL_STATUS_ACTIVE = 0,
|
||||
CALL_STATUS_HOLDING,
|
||||
CALL_STATUS_DIALING,
|
||||
CALL_STATUS_ALERTING,
|
||||
CALL_STATUS_INCOMING,
|
||||
CALL_STATUS_WAITING,
|
||||
CALL_STATUS_DISCONNECTED,
|
||||
CALL_STATUS_DISCONNECTING,
|
||||
CALL_STATUS_IDLE,
|
||||
};
|
||||
|
||||
enum class TelephonyRadioTech {
|
||||
RADIO_TECHNOLOGY_UNKNOWN = 0,
|
||||
RADIO_TECHNOLOGY_GSM = 1,
|
||||
RADIO_TECHNOLOGY_1XRTT = 2,
|
||||
RADIO_TECHNOLOGY_WCDMA = 3,
|
||||
RADIO_TECHNOLOGY_HSPA = 4,
|
||||
RADIO_TECHNOLOGY_HSPAP = 5,
|
||||
RADIO_TECHNOLOGY_TD_SCDMA = 6,
|
||||
RADIO_TECHNOLOGY_EVDO = 7,
|
||||
RADIO_TECHNOLOGY_EHRPD = 8,
|
||||
RADIO_TECHNOLOGY_LTE = 9,
|
||||
RADIO_TECHNOLOGY_LTE_CA = 10,
|
||||
RADIO_TECHNOLOGY_IWLAN = 11,
|
||||
RADIO_TECHNOLOGY_NR = 12
|
||||
};
|
||||
|
||||
enum class TelephonyCellDataFlowType {
|
||||
DATA_FLOW_TYPE_NONE = 0,
|
||||
DATA_FLOW_TYPE_DOWN = 1,
|
||||
DATA_FLOW_TYPE_UP = 2,
|
||||
DATA_FLOW_TYPE_UP_DOWN = 3,
|
||||
DATA_FLOW_TYPE_DORMANT = 4
|
||||
};
|
||||
|
||||
enum class TelephonyLockReason {
|
||||
SIM_NONE,
|
||||
SIM_PIN,
|
||||
SIM_PUK,
|
||||
SIM_PN_PIN,
|
||||
SIM_PN_PUK,
|
||||
SIM_PU_PIN,
|
||||
SIM_PU_PUK,
|
||||
SIM_PP_PIN,
|
||||
SIM_PP_PUK,
|
||||
SIM_PC_PIN,
|
||||
SIM_PC_PUK,
|
||||
SIM_SIM_PIN,
|
||||
SIM_SIM_PUK,
|
||||
};
|
||||
|
||||
std::string GetBoolValue(int32_t value);
|
||||
std::string GetSimState(int32_t state);
|
||||
std::string GetCallState(int32_t state);
|
||||
std::string GetCardType(int32_t type);
|
||||
std::string GetCellularDataConnectionState(int32_t state);
|
||||
std::string GetCellularDataFlow(int32_t flowData);
|
||||
std::string GetCellularDataConnectionNetworkType(int32_t type);
|
||||
std::string GetLockReason(int32_t reason);
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ENUM_CONVERT_H
|
280
utils/common/src/enum_convert.cpp
Normal file
280
utils/common/src/enum_convert.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 "enum_convert.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Telephony {
|
||||
std::string GetBoolValue(int32_t value)
|
||||
{
|
||||
std::string result = "";
|
||||
if (value == 0) {
|
||||
result = "FALSE";
|
||||
}
|
||||
result = "TRUE";
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetSimState(int32_t state)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonySimState>(state)) {
|
||||
case TelephonySimState::SIM_STATE_UNKNOWN:
|
||||
result = "SIM_STATE_UNKNOWN";
|
||||
break;
|
||||
case TelephonySimState::SIM_STATE_NOT_PRESENT:
|
||||
result = "SIM_STATE_NOT_PRESENT";
|
||||
break;
|
||||
case TelephonySimState::SIM_STATE_LOCKED:
|
||||
result = "SIM_STATE_LOCKED";
|
||||
break;
|
||||
case TelephonySimState::SIM_STATE_NOT_READY:
|
||||
result = "SIM_STATE_NOT_READY";
|
||||
break;
|
||||
case TelephonySimState::SIM_STATE_READY:
|
||||
result = "SIM_STATE_READY";
|
||||
break;
|
||||
case TelephonySimState::SIM_STATE_LOADED:
|
||||
result = "SIM_STATE_LOADED";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCallState(int32_t state)
|
||||
{
|
||||
std::string result = "CALL_STATUS_IDLE";
|
||||
switch (static_cast<TelephonyCallState>(state)) {
|
||||
case TelephonyCallState::CALL_STATUS_ACTIVE:
|
||||
result = "CALL_STATUS_ACTIVE";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_HOLDING:
|
||||
result = "CALL_STATUS_HOLDING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_DIALING:
|
||||
result = "CALL_STATUS_DIALING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_ALERTING:
|
||||
result = "CALL_STATUS_ALERTING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_INCOMING:
|
||||
result = "CALL_STATUS_INCOMING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_WAITING:
|
||||
result = "CALL_STATUS_WAITING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_DISCONNECTED:
|
||||
result = "CALL_STATUS_DISCONNECTED";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_DISCONNECTING:
|
||||
result = "CALL_STATUS_DISCONNECTING";
|
||||
break;
|
||||
case TelephonyCallState::CALL_STATUS_IDLE:
|
||||
result = "CALL_STATUS_IDLE";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCardType(int32_t type)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonyCardType>(type)) {
|
||||
case TelephonyCardType::UNKNOWN_CARD:
|
||||
result = "UNKNOWN_CARD";
|
||||
break;
|
||||
case TelephonyCardType::SINGLE_MODE_SIM_CARD:
|
||||
result = "SINGLE_MODE_SIM_CARD";
|
||||
break;
|
||||
case TelephonyCardType::SINGLE_MODE_USIM_CARD:
|
||||
result = "SINGLE_MODE_USIM_CARD";
|
||||
break;
|
||||
case TelephonyCardType::SINGLE_MODE_RUIM_CARD:
|
||||
result = "SINGLE_MODE_RUIM_CARD";
|
||||
break;
|
||||
case TelephonyCardType::DUAL_MODE_CG_CARD:
|
||||
result = "DUAL_MODE_CG_CARD";
|
||||
break;
|
||||
case TelephonyCardType::CT_NATIONAL_ROAMING_CARD:
|
||||
result = "CT_NATIONAL_ROAMING_CARD";
|
||||
break;
|
||||
case TelephonyCardType::CU_DUAL_MODE_CARD:
|
||||
result = "CU_DUAL_MODE_CARD";
|
||||
break;
|
||||
case TelephonyCardType::DUAL_MODE_TELECOM_LTE_CARD:
|
||||
result = "DUAL_MODE_TELECOM_LTE_CARD";
|
||||
break;
|
||||
case TelephonyCardType::DUAL_MODE_UG_CARD:
|
||||
result = "DUAL_MODE_UG_CARD";
|
||||
break;
|
||||
case TelephonyCardType::SINGLE_MODE_ISIM_CARD:
|
||||
result = "SINGLE_MODE_ISIM_CARD";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCellularDataConnectionState(int32_t state)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonyDataConnectionStatus>(state)) {
|
||||
case TelephonyDataConnectionStatus::DATA_STATE_DISCONNECTED:
|
||||
result = "DATA_STATE_DISCONNECTED";
|
||||
break;
|
||||
case TelephonyDataConnectionStatus::DATA_STATE_CONNECTING:
|
||||
result = "DATA_STATE_CONNECTING";
|
||||
break;
|
||||
case TelephonyDataConnectionStatus::DATA_STATE_CONNECTED:
|
||||
result = "DATA_STATE_CONNECTED";
|
||||
break;
|
||||
case TelephonyDataConnectionStatus::DATA_STATE_SUSPENDED:
|
||||
result = "DATA_STATE_SUSPENDED";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCellularDataFlow(int32_t flowData)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonyCellDataFlowType>(flowData)) {
|
||||
case TelephonyCellDataFlowType::DATA_FLOW_TYPE_NONE:
|
||||
result = "DATA_FLOW_TYPE_NONE";
|
||||
break;
|
||||
case TelephonyCellDataFlowType::DATA_FLOW_TYPE_DOWN:
|
||||
result = "DATA_FLOW_TYPE_DOWN";
|
||||
break;
|
||||
case TelephonyCellDataFlowType::DATA_FLOW_TYPE_UP:
|
||||
result = "DATA_FLOW_TYPE_UP";
|
||||
break;
|
||||
case TelephonyCellDataFlowType::DATA_FLOW_TYPE_UP_DOWN:
|
||||
result = "DATA_FLOW_TYPE_UP_DOWN";
|
||||
break;
|
||||
case TelephonyCellDataFlowType::DATA_FLOW_TYPE_DORMANT:
|
||||
result = "DATA_FLOW_TYPE_DORMANT";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetCellularDataConnectionNetworkType(int32_t type)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonyRadioTech>(type)) {
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_UNKNOWN:
|
||||
result = "RADIO_TECHNOLOGY_UNKNOWN";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_GSM:
|
||||
result = "RADIO_TECHNOLOGY_GSM";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_1XRTT:
|
||||
result = "RADIO_TECHNOLOGY_1XRTT";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_WCDMA:
|
||||
result = "RADIO_TECHNOLOGY_WCDMA";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_HSPA:
|
||||
result = "RADIO_TECHNOLOGY_HSPA";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_HSPAP:
|
||||
result = "RADIO_TECHNOLOGY_HSPAP";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_TD_SCDMA:
|
||||
result = "RADIO_TECHNOLOGY_TD_SCDMA";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_EVDO:
|
||||
result = "RADIO_TECHNOLOGY_EVDO";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_EHRPD:
|
||||
result = "RADIO_TECHNOLOGY_EHRPD";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_LTE:
|
||||
result = "RADIO_TECHNOLOGY_LTE";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_LTE_CA:
|
||||
result = "RADIO_TECHNOLOGY_LTE_CA";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_IWLAN:
|
||||
result = "RADIO_TECHNOLOGY_IWLAN";
|
||||
break;
|
||||
case TelephonyRadioTech::RADIO_TECHNOLOGY_NR:
|
||||
result = "RADIO_TECHNOLOGY_NR";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetLockReason(int32_t reason)
|
||||
{
|
||||
std::string result = "";
|
||||
switch (static_cast<TelephonyLockReason>(reason)) {
|
||||
case TelephonyLockReason::SIM_NONE:
|
||||
result = "SIM_NONE";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PIN:
|
||||
result = "SIM_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PUK:
|
||||
result = "SIM_PUK";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PN_PIN:
|
||||
result = "SIM_PN_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PN_PUK:
|
||||
result = "SIM_PN_PUK";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PU_PIN:
|
||||
result = "SIM_PU_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PU_PUK:
|
||||
result = "SIM_PU_PUK";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PP_PIN:
|
||||
result = "SIM_PP_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PP_PUK:
|
||||
result = "SIM_PP_PUK";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PC_PIN:
|
||||
result = "SIM_PC_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_PC_PUK:
|
||||
result = "SIM_PC_PUK";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_SIM_PIN:
|
||||
result = "SIM_SIM_PIN";
|
||||
break;
|
||||
case TelephonyLockReason::SIM_SIM_PUK:
|
||||
result = "SIM_SIM_PUK";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user