mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-27 10:11:08 +00:00
commit
d2039b48d3
@ -2212,6 +2212,15 @@ int32_t CoreManagerInner::GetSimState(int32_t slotId, SimState &simState)
|
||||
return simManager_->GetSimState(slotId, simState);
|
||||
}
|
||||
|
||||
int32_t CoreManagerInner::GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus)
|
||||
{
|
||||
if (simManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("simManager_ is null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->GetSimIccStatus(slotId, iccStatus);
|
||||
}
|
||||
|
||||
int32_t CoreManagerInner::GetCardType(int32_t slotId, CardType &cardType)
|
||||
{
|
||||
if (simManager_ == nullptr) {
|
||||
|
@ -247,6 +247,7 @@ public:
|
||||
int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response);
|
||||
int32_t HasSimCard(int32_t slotId, bool &hasSimCard);
|
||||
int32_t GetSimState(int32_t slotId, SimState &simState);
|
||||
int32_t GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus);
|
||||
int32_t GetCardType(int32_t slotId, CardType &cardType);
|
||||
int32_t SetModemInit(int32_t slotId, bool state);
|
||||
int32_t UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response);
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
// SimState
|
||||
virtual int32_t HasSimCard(int32_t slotId, bool &hasSimCard) = 0;
|
||||
virtual int32_t GetSimState(int32_t slotId, SimState &simState) = 0;
|
||||
virtual int32_t GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus) = 0;
|
||||
virtual int32_t GetCardType(int32_t slotId, CardType &cardType) = 0;
|
||||
virtual int32_t SetModemInit(int32_t slotId, bool state) = 0;
|
||||
virtual int32_t UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response) = 0;
|
||||
|
@ -225,6 +225,25 @@ enum class LockState {
|
||||
LOCK_ERROR,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief icc sim status
|
||||
*/
|
||||
enum class IccSimStatus {
|
||||
ICC_CONTENT_UNKNOWN = -1,
|
||||
ICC_CARD_ABSENT = 0,
|
||||
ICC_CONTENT_READY,
|
||||
ICC_CONTENT_PIN,
|
||||
ICC_CONTENT_PUK,
|
||||
ICC_CONTENT_PIN2,
|
||||
ICC_CONTENT_PUK2,
|
||||
ICC_CONTENT_PH_NET_PIN,
|
||||
ICC_CONTENT_PH_NET_PUK,
|
||||
ICC_CONTENT_PH_NET_SUB_PIN,
|
||||
ICC_CONTENT_PH_NET_SUB_PUK,
|
||||
ICC_CONTENT_PH_SP_PIN,
|
||||
ICC_CONTENT_PH_SP_PUK,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Lock information
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
// SimState
|
||||
int32_t HasSimCard(int32_t slotId, bool &hasSimCard) override;
|
||||
int32_t GetSimState(int32_t slotId, SimState &simState) override;
|
||||
int32_t GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus) override;
|
||||
int32_t GetCardType(int32_t slotId, CardType &cardType) override;
|
||||
int32_t SetModemInit(int32_t slotId, bool state) override;
|
||||
int32_t UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response) override;
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
void Init(int32_t slotId);
|
||||
void UnInit();
|
||||
SimState GetSimState();
|
||||
IccSimStatus GetSimIccStatus();
|
||||
CardType GetCardType();
|
||||
std::string GetIccid();
|
||||
bool HasSimCard();
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void Init(int32_t slotId);
|
||||
bool HasSimCard();
|
||||
SimState GetSimState();
|
||||
IccSimStatus GetSimIccStatus();
|
||||
CardType GetCardType();
|
||||
std::string GetIccid();
|
||||
int32_t SetModemInit(bool state);
|
||||
|
@ -163,6 +163,16 @@ int32_t SimManager::GetSimState(int32_t slotId, SimState &simState)
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus)
|
||||
{
|
||||
if (!HasSimCardInner(slotId)) {
|
||||
iccStatus = IccSimStatus::ICC_CARD_ABSENT;
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
iccStatus = simStateManager_[slotId]->GetSimIccStatus();
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SimManager::GetCardType(int32_t slotId, CardType &cardType)
|
||||
{
|
||||
if (!HasSimCardInner(slotId)) {
|
||||
|
@ -151,6 +151,11 @@ SimState SimStateHandle::GetSimState()
|
||||
return externalState_;
|
||||
}
|
||||
|
||||
IccSimStatus SimStateHandle::GetSimIccStatus()
|
||||
{
|
||||
return static_cast<IccSimStatus>(oldSimStatus_);
|
||||
}
|
||||
|
||||
CardType SimStateHandle::GetCardType()
|
||||
{
|
||||
TELEPHONY_LOGD("SimStateHandle::GetCardType() externalType_=%{public}d", static_cast<int32_t>(externalType_));
|
||||
|
@ -97,6 +97,17 @@ SimState SimStateManager::GetSimState()
|
||||
return ret;
|
||||
}
|
||||
|
||||
IccSimStatus SimStateManager::GetSimIccStatus()
|
||||
{
|
||||
IccSimStatus ret = IccSimStatus::ICC_CONTENT_UNKNOWN;
|
||||
if (simStateHandle_ != nullptr) {
|
||||
std::lock_guard<std::mutex> lck(mtx_);
|
||||
TELEPHONY_LOGD("SimStateManager::GetSimIccStatus()");
|
||||
ret = simStateHandle_->GetSimIccStatus();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SimStateManager::IfModemInitDone()
|
||||
{
|
||||
if (simStateHandle_ != nullptr) {
|
||||
|
@ -948,6 +948,12 @@ HWTEST_F(BranchTest, Telephony_CoreManagerInner_002, Function | MediumTest | Lev
|
||||
EXPECT_GT(mInner.GetOperatorInfo(0, 0, nullptr), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_GT(mInner.GetCellInfoList(0, 0, nullptr), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_GT(mInner.GetCurrentCellInfo(0, 0, nullptr), TELEPHONY_ERR_SUCCESS);
|
||||
IccSimStatus iccStatus = IccSimStatus::ICC_CARD_ABSENT;
|
||||
auto telRilManager = std::make_shared<TelRilManager>();
|
||||
mInner.simManager_ = std::make_shared<SimManager>(telRilManager);
|
||||
EXPECT_GT(mInner.GetSimIccStatus(0, iccStatus), TELEPHONY_ERR_SUCCESS);
|
||||
mInner.simManager_ = nullptr;
|
||||
EXPECT_GT(mInner.GetSimIccStatus(0, iccStatus), TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1444,6 +1450,9 @@ HWTEST_F(BranchTest, Telephony_SimManager_001, Function | MediumTest | Level1)
|
||||
EXPECT_NE(simManager->GetLockState(INVALID_SLOTID, mLockType, lockState), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->RefreshSimState(0), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->RefreshSimState(INVALID_SLOTID), TELEPHONY_ERR_SUCCESS);
|
||||
IccSimStatus iccStatus = IccSimStatus::ICC_CARD_ABSENT;
|
||||
EXPECT_EQ(simManager->GetSimIccStatus(3, iccStatus), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_EQ(simManager->GetSimIccStatus(0, iccStatus), TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1679,6 +1688,12 @@ HWTEST_F(BranchTest, Telephony_SimStateManager_001, Function | MediumTest | Leve
|
||||
simStateManager->simStateHandle_ = std::make_shared<SimStateHandle>(simStateManagerTwo);
|
||||
EXPECT_GE(simStateManager->GetCardType(), CardType::UNKNOWN_CARD);
|
||||
EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
simStateManager->simStateHandle_->GetSimIccStatus();
|
||||
auto ret = simStateManager->GetSimIccStatus();
|
||||
EXPECT_EQ(static_cast<int>(ret), -1);
|
||||
simStateManager->simStateHandle_ = nullptr;
|
||||
ret = simStateManager->GetSimIccStatus();
|
||||
EXPECT_EQ(static_cast<int>(ret), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user