diff --git a/frameworks/native/src/core_service_proxy.cpp b/frameworks/native/src/core_service_proxy.cpp index c8f13678..925be32e 100644 --- a/frameworks/native/src/core_service_proxy.cpp +++ b/frameworks/native/src/core_service_proxy.cpp @@ -2518,7 +2518,7 @@ int32_t CoreServiceProxy::GetOpName(int32_t slotId, std::u16string &opname) int32_t CoreServiceProxy::GetMaxSimCount() { - return SIM_SLOT_COUNT; + return SIM_SLOT_COUNT_REAL; } int32_t CoreServiceProxy::SendEnvelopeCmd(int32_t slotId, const std::string &cmd) diff --git a/interfaces/innerkits/include/telephony_types.h b/interfaces/innerkits/include/telephony_types.h index 78796603..970f3bf3 100644 --- a/interfaces/innerkits/include/telephony_types.h +++ b/interfaces/innerkits/include/telephony_types.h @@ -26,6 +26,7 @@ namespace OHOS { namespace Telephony { #define SIM_SLOT_COUNT GetMaxSlotCount() +#define SIM_SLOT_COUNT_REAL GetRealMaxSlotCount() #define PREFERRED_NETWORK_TYPE GetPreferredNetworkType() #define VSIM_MODEM_COUNT GetVSimModemCount() #define IS_SUPPORT_VSIM (VSIM_MODEM_COUNT > 0) @@ -41,6 +42,7 @@ inline const size_t MAX_PARAMETER_LENGTH = 100; inline const int32_t DUAL_SLOT_COUNT = 2; inline const int32_t MAX_SLOT_COUNT = 3; inline const int32_t VSIM_DEFAULT_VALUE = -1; +inline int32_t maxRealSlotCount_ = 0; inline int32_t maxSlotCount_ = 0; inline int32_t vSimModemCount_ = VSIM_DEFAULT_VALUE; inline constexpr const char *SATELLITE_DEFAULT_VALUE = "0"; @@ -84,6 +86,17 @@ inline T GetMaxSlotCount() return maxSlotCount_; } +template +inline T GetRealMaxSlotCount() +{ + if (maxRealSlotCount_ == 0) { + char realSimSlotCount[SYSPARA_SIZE] = { 0 }; + GetParameter(TEL_SIM_SLOT_COUNT, DEFAULT_SLOT_COUNT, realSimSlotCount, SYSPARA_SIZE); + maxRealSlotCount_ = std::atoi(realSimSlotCount); + } + return maxRealSlotCount_; +} + template inline T GetVSimModemCount() {