mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 16:09:48 +00:00
sim authentication.
Signed-off-by: dingxiaochen <dingxiaochen@huawei.com>
This commit is contained in:
parent
9f0dbddc75
commit
1c233a38e8
@ -851,14 +851,14 @@ int32_t CoreServiceClient::HasOperatorPrivileges(const int32_t slotId, bool &has
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response)
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
|
||||
{
|
||||
auto proxy = GetProxy();
|
||||
if (proxy == nullptr) {
|
||||
TELEPHONY_LOGE("proxy is null!");
|
||||
return false;
|
||||
}
|
||||
return proxy->SimAuthentication(slotId, aid, authData, response);
|
||||
return proxy->SimAuthentication(slotId, authType, authData, response);
|
||||
}
|
||||
|
||||
int32_t CoreServiceClient::GetPrimarySlotId(int32_t &slotId)
|
||||
|
@ -2547,7 +2547,7 @@ int32_t CoreServiceProxy::HasOperatorPrivileges(const int32_t slotId, bool &hasO
|
||||
}
|
||||
|
||||
int32_t CoreServiceProxy::SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response)
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -2557,7 +2557,7 @@ int32_t CoreServiceProxy::SimAuthentication(
|
||||
return ERROR;
|
||||
}
|
||||
data.WriteInt32(slotId);
|
||||
data.WriteString(aid);
|
||||
data.WriteInt32(static_cast<int32_t>(authType));
|
||||
data.WriteString(authData);
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response);
|
||||
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges);
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response);
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response);
|
||||
int32_t GetPrimarySlotId(int32_t &slotId);
|
||||
int32_t SetPrimarySlotId(int32_t slotId);
|
||||
int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo);
|
||||
|
@ -120,8 +120,8 @@ public:
|
||||
int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override;
|
||||
int32_t SendUpdateCellLocationRequest(int32_t slotId) override;
|
||||
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
|
||||
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData,
|
||||
SimAuthenticationResponse &response) override;
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
|
||||
int32_t RegisterImsRegInfoCallback(
|
||||
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override;
|
||||
int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override;
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0;
|
||||
virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
|
||||
virtual int32_t SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0;
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
|
||||
virtual int32_t RegisterImsRegInfoCallback(
|
||||
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) = 0;
|
||||
virtual int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) = 0;
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0;
|
||||
virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
|
||||
virtual int32_t SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response) = 0;
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
|
||||
virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0;
|
||||
virtual void GetRadioProtocol(int32_t slotId) = 0;
|
||||
// STK
|
||||
|
@ -126,6 +126,11 @@ enum class LockType {
|
||||
FDN_LOCK = 2,
|
||||
};
|
||||
|
||||
enum AuthType {
|
||||
SIM_AUTH_EAP_SIM_TYPE = 128,
|
||||
SIM_AUTH_EAP_AKA_TYPE = 129,
|
||||
};
|
||||
|
||||
enum class LockState {
|
||||
/**Indicates that the lock state card is in the <b>off</b> state. */
|
||||
LOCK_OFF = 0,
|
||||
|
@ -208,8 +208,8 @@ public:
|
||||
|
||||
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
|
||||
|
||||
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData,
|
||||
SimAuthenticationResponse &response) override;
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
|
||||
|
||||
int32_t RegisterImsRegInfoCallback(
|
||||
int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override;
|
||||
|
@ -1135,7 +1135,7 @@ int32_t CoreService::HasOperatorPrivileges(const int32_t slotId, bool &hasOperat
|
||||
}
|
||||
|
||||
int32_t CoreService::SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response)
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
|
||||
{
|
||||
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
|
||||
TELEPHONY_LOGE("Failed because no permission:GET_TELEPHONY_STATE");
|
||||
@ -1146,7 +1146,7 @@ int32_t CoreService::SimAuthentication(
|
||||
TELEPHONY_LOGE("simManager_ is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simManager_->SimAuthentication(slotId, aid, authData, response);
|
||||
return simManager_->SimAuthentication(slotId, authType, authData, response);
|
||||
}
|
||||
|
||||
int32_t CoreService::RegisterImsRegInfoCallback(
|
||||
|
@ -1459,10 +1459,10 @@ int32_t CoreServiceStub::OnHasOperatorPrivileges(MessageParcel &data, MessagePar
|
||||
int32_t CoreServiceStub::OnSimAuthentication(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t slotId = data.ReadInt32();
|
||||
std::string aid = data.ReadString();
|
||||
AuthType authType = static_cast<AuthType>(data.ReadInt32());
|
||||
std::string authData = data.ReadString();
|
||||
SimAuthenticationResponse response = { 0 };
|
||||
int32_t result = SimAuthentication(slotId, aid, authData, response);
|
||||
int32_t result = SimAuthentication(slotId, authType, authData, response);
|
||||
reply.WriteInt32(result);
|
||||
reply.WriteInt32(response.sw1);
|
||||
reply.WriteInt32(response.sw2);
|
||||
|
@ -77,8 +77,8 @@ public:
|
||||
int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override;
|
||||
int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override;
|
||||
int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) override;
|
||||
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData,
|
||||
SimAuthenticationResponse &response) override;
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
|
||||
int32_t GetRadioProtocolTech(int32_t slotId) override;
|
||||
void GetRadioProtocol(int32_t slotId) override;
|
||||
// STK
|
||||
@ -135,6 +135,7 @@ public:
|
||||
|
||||
private:
|
||||
bool IsValidSlotId(int32_t slotId);
|
||||
bool IsValidAuthType(AuthType authType);
|
||||
bool IsValidSlotIdForDefault(int32_t slotId);
|
||||
void InitMultiSimObject();
|
||||
void InitSingleSimObject();
|
||||
|
@ -89,6 +89,10 @@ constexpr const char *FDN_PIN_LOCK = "P2";
|
||||
// FDN lock type
|
||||
constexpr const char *FDN_PIN2_LOCK = "FD";
|
||||
|
||||
constexpr const char *USIM_AID = "USIM_AID";
|
||||
constexpr const char *CDMA_FAKE_AID = "CDMA_FAKE_AID";
|
||||
constexpr const char *GSM_FAKE_AID = "GSM_FAKE_AID";
|
||||
|
||||
struct UnlockData {
|
||||
int32_t result = 0;
|
||||
int32_t remain = 0;
|
||||
@ -122,7 +126,7 @@ public:
|
||||
bool IsIccReady();
|
||||
void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what);
|
||||
void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what);
|
||||
int32_t SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData);
|
||||
int32_t SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData);
|
||||
SimAuthenticationResponse GetSimAuthenticationResponse();
|
||||
|
||||
private:
|
||||
@ -143,6 +147,7 @@ private:
|
||||
void NotifySimLock(int slotId);
|
||||
void GetUnlockSimLockResult(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId);
|
||||
void GetSimAuthenticationResult(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &event);
|
||||
std::string GetAidByCardType(CardType type);
|
||||
|
||||
private:
|
||||
int32_t oldSimType_ = ICC_UNKNOWN_TYPE;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
void RegisterCoreNotify(const HANDLE &handler, int what);
|
||||
void UnRegisterCoreNotify(const HANDLE &observerCallBack, int what);
|
||||
int32_t SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response);
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response);
|
||||
|
||||
public:
|
||||
static bool responseReady_;
|
||||
|
@ -496,14 +496,21 @@ int32_t SimManager::HasOperatorPrivileges(const int32_t slotId, bool &hasOperato
|
||||
}
|
||||
|
||||
int32_t SimManager::SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response)
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
|
||||
{
|
||||
TELEPHONY_LOGI("SimManager::SimAuthentication slotId:%{public}d", slotId);
|
||||
if ((!IsValidSlotId(slotId)) || (simStateManager_[slotId] == nullptr)) {
|
||||
if (!HasSimCardInner(slotId)) {
|
||||
TELEPHONY_LOGE("SimAuthentication has no sim card!");
|
||||
return TELEPHONY_ERR_NO_SIM_CARD;
|
||||
}
|
||||
if (!IsValidAuthType(authType)) {
|
||||
TELEPHONY_LOGE("SimAuthentication authType is invalid!");
|
||||
return TELEPHONY_ERR_ARGUMENT_INVALID;
|
||||
}
|
||||
if (simStateManager_[slotId] == nullptr) {
|
||||
TELEPHONY_LOGE("simStateManager_ can not be null!");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
return simStateManager_[slotId]->SimAuthentication(slotId, aid, authData, response);
|
||||
return simStateManager_[slotId]->SimAuthentication(slotId, authType, authData, response);
|
||||
}
|
||||
|
||||
int32_t SimManager::GetRadioProtocolTech(int32_t slotId)
|
||||
@ -979,6 +986,11 @@ bool SimManager::IsValidSlotId(int32_t slotId)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimManager::IsValidAuthType(AuthType authType)
|
||||
{
|
||||
return (authType == AuthType::SIM_AUTH_EAP_SIM_TYPE || authType == AuthType::SIM_AUTH_EAP_AKA_TYPE);
|
||||
}
|
||||
|
||||
bool SimManager::IsValidSlotIdForDefault(int32_t slotId)
|
||||
{
|
||||
if ((slotId < DEFAULT_SIM_SLOT_ID_REMOVE) || (slotId >= slotCount_)) {
|
||||
|
@ -294,7 +294,7 @@ void SimStateHandle::ObtainRealtimeIccStatus(int32_t slotId)
|
||||
telRilManager_->GetSimStatus(slotId, event); // get sim card state
|
||||
}
|
||||
|
||||
int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid, const std::string &authData)
|
||||
int32_t SimStateHandle::SimAuthentication(int32_t slotId, AuthType authType, const std::string &authData)
|
||||
{
|
||||
if (telRilManager_ == nullptr) {
|
||||
TELEPHONY_LOGE("SimStateHandle::SimAuthentication() telRilManager_ is nullptr!!");
|
||||
@ -307,11 +307,30 @@ int32_t SimStateHandle::SimAuthentication(int32_t slotId, const std::string &aid
|
||||
}
|
||||
event->SetOwner(shared_from_this());
|
||||
SimAuthenticationRequestInfo requireInfo;
|
||||
requireInfo.aid = aid;
|
||||
requireInfo.serial = static_cast<int32_t>(authType);
|
||||
requireInfo.aid = GetAidByCardType(externalType_);
|
||||
requireInfo.authData = authData;
|
||||
return telRilManager_->SimAuthentication(slotId, requireInfo, event);
|
||||
}
|
||||
|
||||
std::string SimStateHandle::GetAidByCardType(CardType type)
|
||||
{
|
||||
switch (type) {
|
||||
case CardType::SINGLE_MODE_RUIM_CARD:
|
||||
return CDMA_FAKE_AID;
|
||||
case CardType::SINGLE_MODE_SIM_CARD:
|
||||
case CardType::DUAL_MODE_CG_CARD:
|
||||
case CardType::CT_NATIONAL_ROAMING_CARD:
|
||||
case CardType::CU_DUAL_MODE_CARD:
|
||||
case CardType::DUAL_MODE_TELECOM_LTE_CARD:
|
||||
case CardType::DUAL_MODE_UG_CARD:
|
||||
return GSM_FAKE_AID;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return USIM_AID;
|
||||
}
|
||||
|
||||
void SimStateHandle::GetSimCardData(const AppExecFwk::InnerEvent::Pointer &event, int32_t slotId)
|
||||
{
|
||||
TELEPHONY_LOGI("SimStateHandle::GetSimCardData slotId = %{public}d", slotId);
|
||||
|
@ -458,7 +458,7 @@ int32_t SimStateManager::UnlockSimLock(int32_t slotId, const PersoLockInfo &lock
|
||||
}
|
||||
|
||||
int32_t SimStateManager::SimAuthentication(
|
||||
int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response)
|
||||
int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response)
|
||||
{
|
||||
if (simStateHandle_ == nullptr) {
|
||||
TELEPHONY_LOGE("SimAuthentication(), simStateHandle_ is nullptr!!!");
|
||||
@ -467,7 +467,7 @@ int32_t SimStateManager::SimAuthentication(
|
||||
std::unique_lock<std::mutex> lck(ctx_);
|
||||
responseReady_ = false;
|
||||
int32_t ret = SIM_AUTH_FAIL;
|
||||
ret = simStateHandle_->SimAuthentication(slotId, aid, authData);
|
||||
ret = simStateHandle_->SimAuthentication(slotId, authType, authData);
|
||||
while (!responseReady_) {
|
||||
TELEPHONY_LOGI("SimAuthentication::wait(), response = false");
|
||||
if (cv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_SECOND)) == std::cv_status::timeout) {
|
||||
|
@ -283,7 +283,11 @@ int32_t TelRilSim::SimTransmitApduBasicChannelResponse(
|
||||
int32_t TelRilSim::SimAuthenticationResponse(
|
||||
const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::IccIoResultInfo &result)
|
||||
{
|
||||
return ResponseIccIo(responseInfo, result);
|
||||
std::shared_ptr<IccIoResultInfo> simAuthResp = std::make_shared<IccIoResultInfo>();
|
||||
simAuthResp->sw1 = result.sw1;
|
||||
simAuthResp->sw2 = result.sw2;
|
||||
simAuthResp->response = result.response;
|
||||
return Response<IccIoResultInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, simAuthResp);
|
||||
}
|
||||
|
||||
int32_t TelRilSim::UnlockSimLockResponse(
|
||||
@ -459,6 +463,7 @@ int32_t TelRilSim::SimAuthentication(
|
||||
const SimAuthenticationRequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
|
||||
{
|
||||
OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo simAuthInfo;
|
||||
simAuthInfo.serial = reqInfo.serial;
|
||||
simAuthInfo.aid = reqInfo.aid;
|
||||
simAuthInfo.authData = reqInfo.authData;
|
||||
return Request(TELEPHONY_LOG_FUNC_NAME, response, HREQ_SIM_AUTHENTICATION, &HDI::Ril::V1_1::IRil::SimAuthentication,
|
||||
|
@ -714,8 +714,27 @@ void TelRilTest::OnRequestSimAuthenticationTest(int32_t slotId,
|
||||
std::cerr << "telRilManager is nullptr" << std::endl;
|
||||
return;
|
||||
}
|
||||
int32_t authType;
|
||||
std::string aid;
|
||||
std::string authData;
|
||||
|
||||
std::cout << "please enter the authType:" << std::endl;
|
||||
std::cout << "SIM_AUTH_EAP_SIM_TYPE is 128" << std::endl;
|
||||
std::cout << "SIM_AUTH_EAP_AKA_TYPE is 129" << std::endl;
|
||||
std::cin >> authType;
|
||||
std::cout << "please enter the aid:" << std::endl;
|
||||
std::cout << "USIM_AID" << std::endl;
|
||||
std::cout << "CDMA_FAKE_AID" << std::endl;
|
||||
std::cout << "GSM_FAKE_AID" << std::endl;
|
||||
std::cin >> aid;
|
||||
std::cout << "please enter the authData base64 encoded:" << std::endl;
|
||||
std::cin >> authData;
|
||||
SimAuthenticationRequestInfo reqInfo;
|
||||
telRilManager_->SimAuthentication(slotId, reqInfo, event);
|
||||
reqInfo.serial = authType;
|
||||
reqInfo.aid = aid;
|
||||
reqInfo.authData = authData;
|
||||
int ret = telRilManager_->SimAuthentication(slotId, reqInfo, event);
|
||||
TELEPHONY_LOGI("OnRequestSimAuthenticationTest ret = %{public}d", ret);
|
||||
std::cout << "TelRilTest::OnRequestSimAuthenticationTest end" << std::endl;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@ constexpr int32_t SLOT_NUM = 2;
|
||||
constexpr int32_t TYPE_NUM = 2;
|
||||
constexpr int32_t TWO_INT_NUM = 2;
|
||||
constexpr int32_t SLEEP_TIME_SECONDS = 10;
|
||||
constexpr int32_t SIM_AUTH_EAP_SIM_TYPE = 128;
|
||||
constexpr int32_t SIM_AUTH_EAP_AKA_TYPE = 129;
|
||||
|
||||
bool IsServiceInited()
|
||||
{
|
||||
@ -141,11 +143,15 @@ void SimAuthentication(const uint8_t *data, size_t size)
|
||||
}
|
||||
|
||||
int32_t slotId = static_cast<int32_t>(size % SLOT_NUM);
|
||||
std::string aid(reinterpret_cast<const char *>(data), size);
|
||||
std::string authData(reinterpret_cast<const char *>(data), size);
|
||||
MessageParcel dataMessageParcel;
|
||||
dataMessageParcel.WriteInt32(slotId);
|
||||
dataMessageParcel.WriteString(aid);
|
||||
int32_t authType = static_cast<int32_t>(size % TYPE_NUM);
|
||||
if (authType) {
|
||||
dataMessageParcel.WriteInt32(SIM_AUTH_EAP_AKA_TYPE);
|
||||
} else {
|
||||
dataMessageParcel.WriteInt32(SIM_AUTH_EAP_SIM_TYPE);
|
||||
}
|
||||
dataMessageParcel.WriteString(authData);
|
||||
dataMessageParcel.RewindRead(0);
|
||||
MessageParcel reply;
|
||||
|
@ -3336,9 +3336,9 @@ HWTEST_F(SimTest, Telephony_Sim_UnlockSimLock_0300, Function | MediumTest | Leve
|
||||
void SimAuthenticationTestFunc(CoreServiceTestHelper &helper)
|
||||
{
|
||||
SimAuthenticationResponse response = { 0 };
|
||||
std::string aid = "aa";
|
||||
AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE;
|
||||
std::string authData = "1234";
|
||||
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, aid, authData, response);
|
||||
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
|
||||
helper.SetBoolResult(result == 0);
|
||||
helper.NotifyAll();
|
||||
}
|
||||
@ -3369,9 +3369,10 @@ void SimAuthenticationTestFunc1(CoreServiceTestHelper &helper)
|
||||
{
|
||||
AccessToken token;
|
||||
SimAuthenticationResponse response = { 0 };
|
||||
std::string aid = "aa";
|
||||
AuthType authType = AuthType::SIM_AUTH_EAP_SIM_TYPE;
|
||||
std::string authData = "1234";
|
||||
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, aid, authData, response);
|
||||
int32_t result =
|
||||
CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId1_, authType, authData, response);
|
||||
helper.SetBoolResult(result == 0);
|
||||
helper.NotifyAll();
|
||||
}
|
||||
@ -3418,6 +3419,70 @@ HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0300, Function | MediumTest |
|
||||
}
|
||||
}
|
||||
|
||||
void SimAuthenticationTestFunc2(CoreServiceTestHelper &helper)
|
||||
{
|
||||
SimAuthenticationResponse response = { 0 };
|
||||
AuthType authType = AuthType::SIM_AUTH_EAP_AKA_TYPE;
|
||||
std::string authData = "1234";
|
||||
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
|
||||
helper.SetBoolResult(result == 0);
|
||||
helper.NotifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_Sim_SimAuthentication_0400
|
||||
* @tc.name Sim authentication
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0400, Function | MediumTest | Level3)
|
||||
{
|
||||
AccessToken token;
|
||||
if (!SimTest::HasSimCard(slotId_)) {
|
||||
TELEPHONY_LOGI("TelephonyTestService has no sim card");
|
||||
} else {
|
||||
CoreServiceTestHelper helper;
|
||||
if (!helper.Run(SimAuthenticationTestFunc2, std::ref(helper))) {
|
||||
TELEPHONY_LOGI("Interface out of time");
|
||||
EXPECT_TRUE(true);
|
||||
} else {
|
||||
bool result = helper.GetBoolResult();
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimAuthenticationTestFunc3(CoreServiceTestHelper &helper)
|
||||
{
|
||||
SimAuthenticationResponse response = { 0 };
|
||||
AuthType authType = static_cast<AuthType>(0);
|
||||
std::string authData = "1234";
|
||||
int32_t result = CoreServiceClient::GetInstance().SimAuthentication(SimTest::slotId_, authType, authData, response);
|
||||
helper.SetBoolResult(result == 0);
|
||||
helper.NotifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_Sim_SimAuthentication_0500
|
||||
* @tc.name Sim authentication
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(SimTest, Telephony_Sim_SimAuthentication_0500, Function | MediumTest | Level3)
|
||||
{
|
||||
AccessToken token;
|
||||
if (!SimTest::HasSimCard(slotId_)) {
|
||||
TELEPHONY_LOGI("TelephonyTestService has no sim card");
|
||||
} else {
|
||||
CoreServiceTestHelper helper;
|
||||
if (!helper.Run(SimAuthenticationTestFunc3, std::ref(helper))) {
|
||||
TELEPHONY_LOGI("Interface out of time");
|
||||
EXPECT_TRUE(true);
|
||||
} else {
|
||||
bool result = helper.GetBoolResult();
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_Sim_GetPrimarySlotId_0100
|
||||
* @tc.name Get primary slotId
|
||||
@ -4093,7 +4158,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0200, Function | MediumTest | Level3
|
||||
EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->SendUpdateCellLocationRequest(0);
|
||||
SimAuthenticationResponse mSimAuthenticationResponse;
|
||||
EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse),
|
||||
TELEPHONY_ERR_SUCCESS);
|
||||
const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr;
|
||||
EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback),
|
||||
TELEPHONY_ERR_SUCCESS);
|
||||
@ -4238,7 +4304,8 @@ HWTEST_F(SimTest, Telephony_Sim_CoreService_0500, Function | MediumTest | Level3
|
||||
EXPECT_NE(mCoreService->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
mCoreService->SendUpdateCellLocationRequest(0);
|
||||
SimAuthenticationResponse mSimAuthenticationResponse;
|
||||
EXPECT_NE(mCoreService->SimAuthentication(0, "", "", mSimAuthenticationResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(mCoreService->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mSimAuthenticationResponse),
|
||||
TELEPHONY_ERR_SUCCESS);
|
||||
const sptr<ImsRegInfoCallback> mImsRegInfoCallback = nullptr;
|
||||
EXPECT_NE(mCoreService->RegisterImsRegInfoCallback(0, ImsServiceType::TYPE_VOICE, mImsRegInfoCallback),
|
||||
TELEPHONY_ERR_SUCCESS);
|
||||
|
@ -1247,9 +1247,6 @@ HWTEST_F(BranchTest, Telephony_SimManager_003, Function | MediumTest | Level1)
|
||||
bool boolResult = false;
|
||||
EXPECT_GT(simManager->HasOperatorPrivileges(0, boolResult), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_GT(simManager->HasOperatorPrivileges(INVALID_SLOTID, boolResult), TELEPHONY_ERR_SUCCESS);
|
||||
SimAuthenticationResponse mResponse;
|
||||
EXPECT_NE(simManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
int32_t testRadioProtocolTech = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_UNKNOWN);
|
||||
EXPECT_EQ(simManager->GetRadioProtocolTech(0), testRadioProtocolTech);
|
||||
EXPECT_EQ(simManager->GetRadioProtocolTech(INVALID_SLOTID), testRadioProtocolTech);
|
||||
@ -1304,6 +1301,13 @@ HWTEST_F(BranchTest, Telephony_SimManager_004, Function | MediumTest | Level1)
|
||||
std::string testString = "";
|
||||
EXPECT_NE(simManager->ObtainSpnCondition(0, true, testString), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->ObtainSpnCondition(INVALID_SLOTID, true, testString), TELEPHONY_ERR_SUCCESS);
|
||||
SimAuthenticationResponse mResponse;
|
||||
EXPECT_NE(simManager->SimAuthentication(0, static_cast<AuthType>(0), "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(
|
||||
simManager->SimAuthentication(INVALID_SLOTID, static_cast<AuthType>(0), "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simManager->SimAuthentication(INVALID_SLOTID, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse),
|
||||
TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1343,12 +1347,33 @@ HWTEST_F(BranchTest, Telephony_SimStateManager_001, Function | MediumTest | Leve
|
||||
PersoLockInfo mPersoLockInfo;
|
||||
EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
SimAuthenticationResponse mResponse;
|
||||
EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(
|
||||
simStateManager->SimAuthentication(0, AuthType::SIM_AUTH_EAP_SIM_TYPE, "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
auto simStateManagerTwo = std::make_shared<SimStateManager>(telRilManager);
|
||||
simStateManager->simStateHandle_ = std::make_shared<SimStateHandle>(runner, simStateManagerTwo);
|
||||
EXPECT_GE(simStateManager->GetCardType(), CardType::UNKNOWN_CARD);
|
||||
EXPECT_GT(simStateManager->UnlockSimLock(0, mPersoLockInfo, mLockStatusResponse), TELEPHONY_ERR_SUCCESS);
|
||||
EXPECT_NE(simStateManager->SimAuthentication(0, "", "", mResponse), TELEPHONY_ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_SimStateHandle_001
|
||||
* @tc.name test error branch
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(BranchTest, Telephony_SimStateHandle_001, Function | MediumTest | Level1)
|
||||
{
|
||||
std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
|
||||
std::shared_ptr<Telephony::SimStateManager> simStateManager = std::make_shared<SimStateManager>(telRilManager);
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("test");
|
||||
auto simStateHandle = std::make_shared<SimStateHandle>(runner, simStateManager);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_RUIM_CARD), CDMA_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::SINGLE_MODE_SIM_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_CG_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CT_NATIONAL_ROAMING_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::CU_DUAL_MODE_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_TELECOM_LTE_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::DUAL_MODE_UG_CARD), GSM_FAKE_AID);
|
||||
EXPECT_EQ(simStateHandle->GetAidByCardType(CardType::UNKNOWN_CARD), USIM_AID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user