cfi and voicemail

Signed-off-by: jyh926 <jiayanhong@huawei.com>
This commit is contained in:
jyh926 2023-03-23 17:46:29 +08:00
parent 20d68d42a5
commit f236cdbc60
35 changed files with 915 additions and 24 deletions

View File

@ -725,6 +725,43 @@ napi_value GetVoiceMailNumber(napi_env env, napi_callback_info info)
env, info, "GetVoiceMailNumber");
}
void NativeGetVoiceMailCount(napi_env env, void *data)
{
if (data == nullptr) {
return;
}
AsyncContext<int32_t> *asyncContext = static_cast<AsyncContext<int32_t> *>(data);
if (!IsValidSlotId(asyncContext->slotId)) {
TELEPHONY_LOGE("NativeGetVoiceMailCount slotId is invalid");
asyncContext->context.errorCode = ERROR_SLOT_ID_INVALID;
return;
}
int32_t voiceMailCount = ERROR_DEFAULT;
int32_t errorCode =
DelayedRefSingleton<CoreServiceClient>::GetInstance().GetVoiceMailCount(asyncContext->slotId, voiceMailCount);
if (errorCode == ERROR_NONE) {
asyncContext->callbackVal = voiceMailCount;
asyncContext->context.resolved = true;
} else {
asyncContext->context.resolved = false;
}
asyncContext->context.errorCode = errorCode;
}
void GetVoiceMailCountCallback(napi_env env, napi_status status, void *data)
{
NAPI_CALL_RETURN_VOID(env, (data == nullptr ? napi_invalid_arg : napi_ok));
std::unique_ptr<AsyncContext<int32_t>> context(static_cast<AsyncContext<int32_t> *>(data));
NapiAsyncPermissionCompleteCallback(
env, status, *context, false, "GetVoiceMailCount", Permission::GET_TELEPHONY_STATE);
}
napi_value GetVoiceMailCount(napi_env env, napi_callback_info info)
{
return NapiCreateAsyncWork<int32_t, NativeGetVoiceMailCount, GetVoiceMailCountCallback>(
env, info, "GetVoiceMailCount");
}
void NativeGetSimTelephoneNumber(napi_env env, void *data)
{
if (data == nullptr) {
@ -2533,6 +2570,7 @@ napi_status InitSimInterfaceAboutVoice(napi_env env, napi_value exports)
DECLARE_NAPI_FUNCTION("getDefaultVoiceSlotId", GetDefaultVoiceSlotId),
DECLARE_NAPI_FUNCTION("getVoiceMailIdentifier", GetVoiceMailIdentifier),
DECLARE_NAPI_FUNCTION("getVoiceMailNumber", GetVoiceMailNumber),
DECLARE_NAPI_FUNCTION("getVoiceMailCount", GetVoiceMailCount),
DECLARE_NAPI_FUNCTION("setVoiceMailInfo", SetVoiceMailInfo),
};
return napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);

View File

@ -1946,6 +1946,33 @@ int32_t CoreManagerInner::GetVoiceMailNumber(int32_t slotId, std::u16string &voi
return simManager_->GetVoiceMailNumber(slotId, voiceMailNumber);
}
int32_t CoreManagerInner::GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount)
{
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->GetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreManagerInner::SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount)
{
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->SetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreManagerInner::SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number)
{
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->SetVoiceCallForwarding(slotId, enable, number);
}
int32_t CoreManagerInner::HasSimCard(int32_t slotId, bool &hasSimCard)
{
if (simManager_ == nullptr) {

View File

@ -655,6 +655,36 @@ int32_t CoreServiceClient::GetVoiceMailNumber(int32_t slotId, std::u16string &vo
return proxy->GetVoiceMailNumber(slotId, voiceMailNumber);
}
int32_t CoreServiceClient::GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->GetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreServiceClient::SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->SetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreServiceClient::SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->SetVoiceCallForwarding(slotId, enable, number);
}
int32_t CoreServiceClient::QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result)
{

View File

@ -1868,6 +1868,91 @@ int32_t CoreServiceProxy::GetVoiceMailNumber(int32_t slotId, std::u16string &voi
return result;
}
int32_t CoreServiceProxy::GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount)
{
if (!IsValidSlotId(slotId)) {
return TELEPHONY_ERR_SLOTID_INVALID;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("GetVoiceMailCount WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
data.WriteInt32(slotId);
auto remote = Remote();
if (remote == nullptr) {
TELEPHONY_LOGE("GetVoiceMailCount Remote is null");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t st = remote->SendRequest(uint32_t(InterfaceID::GET_VOICE_MAIL_COUNT), data, reply, option);
if (st != ERR_NONE) {
TELEPHONY_LOGE("GetVoiceMailCount failed, error code is %{public}d", st);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t result = reply.ReadInt32();
if (result == TELEPHONY_ERR_SUCCESS) {
voiceMailCount = reply.ReadInt32();
}
return result;
}
int32_t CoreServiceProxy::SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount)
{
if (!IsValidSlotId(slotId)) {
return TELEPHONY_ERR_SLOTID_INVALID;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("SetVoiceMailCount WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
data.WriteInt32(slotId);
data.WriteInt32(voiceMailCount);
auto remote = Remote();
if (remote == nullptr) {
TELEPHONY_LOGE("SetVoiceMailCount Remote is null");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t st = remote->SendRequest(uint32_t(InterfaceID::SET_VOICE_MAIL_COUNT), data, reply, option);
if (st != ERR_NONE) {
TELEPHONY_LOGE("SetVoiceMailCount failed, error code is %{public}d", st);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return reply.ReadInt32();
}
int32_t CoreServiceProxy::SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number)
{
if (!IsValidSlotId(slotId)) {
return TELEPHONY_ERR_SLOTID_INVALID;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("SetVoiceCallForwarding WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
data.WriteInt32(slotId);
data.WriteBool(enable);
data.WriteString(number);
auto remote = Remote();
if (remote == nullptr) {
TELEPHONY_LOGE("SetVoiceCallForwarding Remote is null");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t st = remote->SendRequest(uint32_t(InterfaceID::SET_VOICE_CALL_FORWARDING), data, reply, option);
if (st != ERR_NONE) {
TELEPHONY_LOGE("SetVoiceCallForwarding failed, error code is %{public}d", st);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return reply.ReadInt32();
}
int32_t CoreServiceProxy::QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result)
{

View File

@ -165,6 +165,26 @@ int32_t TelephonyStateRegistryClient::UpdateSimState(
}
return proxy->UpdateSimState(slotId, type, state, reason);
}
}
int32_t TelephonyStateRegistryClient::UpdateCfuIndicator(int32_t slotId, bool cfuResult)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->UpdateCfuIndicator(slotId, cfuResult);
}
int32_t TelephonyStateRegistryClient::UpdateVoiceMailMsgIndicator(int32_t slotId, bool voiceMailMsgResult)
{
auto proxy = GetProxy();
if (proxy == nullptr) {
TELEPHONY_LOGE("proxy is null!");
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
return proxy->UpdateVoiceMailMsgIndicator(slotId, voiceMailMsgResult);
}
} // namespace Telephony
}

View File

@ -349,5 +349,59 @@ int32_t TelephonyStateRegistryProxy::UnregisterStateChange(
}
return TELEPHONY_SUCCESS;
}
int32_t TelephonyStateRegistryProxy::UpdateCfuIndicator(int32_t slotId, bool cfuResult)
{
MessageOption option;
MessageParcel in;
MessageParcel out;
if (!in.WriteInterfaceToken(TelephonyStateRegistryProxy::GetDescriptor())) {
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
if (!in.WriteInt32(slotId)) {
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
if (!in.WriteBool(cfuResult)) {
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int result = remote->SendRequest(
static_cast<uint32_t>(StateNotifyCode::CFU_INDICATOR), in, out, option);
if (result == ERR_NONE) {
result = out.ReadInt32();
return result;
}
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t TelephonyStateRegistryProxy::UpdateVoiceMailMsgIndicator(int32_t slotId, bool voiceMailMsgResult)
{
MessageOption option;
MessageParcel in;
MessageParcel out;
if (!in.WriteInterfaceToken(TelephonyStateRegistryProxy::GetDescriptor())) {
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
if (!in.WriteInt32(slotId)) {
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
if (!in.WriteBool(voiceMailMsgResult)) {
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int result = remote->SendRequest(
static_cast<uint32_t>(StateNotifyCode::VOICE_MAIL_MSG_INDICATOR), in, out, option);
if (result == ERR_NONE) {
result = out.ReadInt32();
return result;
}
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
} // namespace Telephony
} // namespace OHOS

View File

@ -263,6 +263,9 @@ public:
std::u16string GetSimTeleNumberIdentifier(const int32_t slotId);
int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier);
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber);
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount);
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount);
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number);
std::u16string GetSimIst(int32_t slotId);
int32_t QueryIccDiallingNumbers(int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result);
int32_t AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);

View File

@ -94,6 +94,9 @@ public:
int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber);
int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier);
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber);
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount);
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount);
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number);
int32_t QueryIccDiallingNumbers(int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result);
int32_t AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
int32_t DelIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);

View File

@ -95,6 +95,9 @@ public:
std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) override;
int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) override;
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) override;
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) override;
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) override;
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) override;
int32_t QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) override;
int32_t AddIccDiallingNumbers(

View File

@ -100,6 +100,9 @@ public:
virtual std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) = 0;
virtual int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) = 0;
virtual int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) = 0;
virtual int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) = 0;
virtual int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) = 0;
virtual int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) = 0;
virtual int32_t QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) = 0;
virtual int32_t AddIccDiallingNumbers(
@ -210,6 +213,9 @@ public:
GET_SIM_EONS,
GET_SIM_SLOTID,
GET_SIM_SIMID,
GET_VOICE_MAIL_COUNT,
SET_VOICE_MAIL_COUNT,
SET_VOICE_CALL_FORWARDING,
};
protected:

View File

@ -96,6 +96,9 @@ public:
virtual std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) = 0;
virtual int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) = 0;
virtual int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) = 0;
virtual int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) = 0;
virtual int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) = 0;
virtual int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) = 0;
virtual std::u16string GetSimIst(int32_t slotId) = 0;
virtual int ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum) = 0;
virtual int32_t SetVoiceMailInfo(

View File

@ -32,7 +32,9 @@ public:
CALL_STATE_FOR_ID,
SIM_STATE,
ADD_OBSERVER,
REMOVE_OBSERVER
REMOVE_OBSERVER,
CFU_INDICATOR,
VOICE_MAIL_MSG_INDICATOR
};
/**
@ -45,6 +47,7 @@ public:
*/
virtual int32_t UpdateCellularDataConnectState(
int32_t slotId, int32_t dataState, int32_t networkState) = 0;
/**
* UpdateCellularDataFlow
*
@ -66,6 +69,7 @@ public:
*/
virtual int32_t UpdateSimState(
int32_t slotId, CardType type, SimState state, LockReason reason) = 0;
/**
* UpdateCallState
*
@ -119,6 +123,24 @@ public:
virtual int32_t UpdateNetworkState(
int32_t slotId, const sptr<NetworkState> &networkState) = 0;
/**
* Update call forward unconditionally indicator
*
* @param slotId sim slot id
* @param cfuResult set the result of call forwarding
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
*/
virtual int32_t UpdateCfuIndicator(int32_t slotId, bool cfuResult) = 0;
/**
* Update voice mail message indicator
*
* @param slotId sim slot id
* @param voiceMailMsgResult voice mail message indicator
* @return int32_t TELEPHONY_SUCCESS on success, others on failure.
*/
virtual int32_t UpdateVoiceMailMsgIndicator(int32_t slotId, bool voiceMailMsgResult) = 0;
/**
* RegisterStateChange
*

View File

@ -35,7 +35,9 @@ public:
ON_CELL_INFO_UPDATED,
ON_SIM_STATE_UPDATED,
ON_CELLULAR_DATA_CONNECT_STATE_UPDATED,
ON_CELLULAR_DATA_FLOW_UPDATED
ON_CELLULAR_DATA_FLOW_UPDATED,
ON_CFU_INDICATOR_UPDATED,
ON_VOICE_MAIL_MSG_INDICATOR_UPDATED,
};
virtual void OnCellularDataConnectStateUpdated(
@ -52,6 +54,8 @@ public:
int32_t slotId, CardType type, SimState state, LockReason reason) = 0;
virtual void OnCellularDataFlowUpdated(
int32_t slotId, int32_t dataFlowType) = 0;
virtual void OnCfuIndicatorUpdated(int32_t slotId, bool cfuResult) = 0;
virtual void OnVoiceMailMsgIndicatorUpdated(int32_t slotId, bool voiceMailMsgResult) = 0;
public:
static const uint32_t OBSERVER_MASK_NETWORK_STATE = 0x00000001;
@ -61,6 +65,8 @@ public:
static const uint32_t OBSERVER_MASK_SIM_STATE = 0x00000020;
static const uint32_t OBSERVER_MASK_DATA_CONNECTION_STATE = 0x00000040;
static const uint32_t OBSERVER_MASK_DATA_FLOW = 0x00000080;
static const uint32_t OBSERVER_MASK_CFU_INDICATOR = 0x00000100;
static const uint32_t OBSERVER_MASK_VOICE_MAIL_MSG_INDICATOR = 0x00000200;
};
} // namespace Telephony
} // namespace OHOS

View File

@ -37,6 +37,8 @@ public:
int32_t UpdateNetworkState(int32_t slotId, const sptr<NetworkState> &networkState);
int32_t UpdateSimState(int32_t slotId, CardType type, SimState state, LockReason reason);
int32_t UpdateCellularDataFlow(int32_t slotId, int32_t flowType);
int32_t UpdateCfuIndicator(int32_t slotId, bool cfuResult);
int32_t UpdateVoiceMailMsgIndicator(int32_t slotId, bool voiceMailMsgResult);
sptr<ITelephonyStateNotify> GetProxy();
private:

View File

@ -46,6 +46,8 @@ public:
int32_t slotId, const sptr<NetworkState> &networkState) override;
int32_t UpdateSimState(
int32_t slotId, CardType type, SimState state, LockReason reason) override;
int32_t UpdateCfuIndicator(int32_t slotId, bool cfuResult) override;
int32_t UpdateVoiceMailMsgIndicator(int32_t slotId, bool voiceMailMsgResult) override;
int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver,
int32_t slotId, uint32_t mask, bool isUpdate) override;

View File

@ -222,6 +222,27 @@ declare namespace sim {
function getVoiceMailNumber(slotId: number, callback: AsyncCallback<string>): void;
function getVoiceMailNumber(slotId: number): Promise<string>;
/**
* Obtains the number of messages in the voice mailbox of the SIM card in the specified slot.
*
* @param slotId Indicates the card slot index number,
* ranging from {@code 0} to the maximum card slot index number supported by the device.
* @param callback Returns the number of messages in the voice mailbox.
* @permission ohos.permission.GET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300004 - Do not have sim card.
* @throws {BusinessError} 8300999 - Unknown error code.
* @throws {BusinessError} 8301002 - SIM card operation error.
* @systemapi Hide this for inner system use.
* @since 10
*/
function getVoiceMailCount(slotId: number, callback: AsyncCallback<number>): void;
function getVoiceMailCount(slotId: number): Promise<number>;
/**
* Sets the voice mail information.
*

View File

@ -163,6 +163,12 @@ public:
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) override;
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) override;
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) override;
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) override;
int32_t QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) override;

View File

@ -99,6 +99,9 @@ private:
int32_t OnGetSimTeleNumberIdentifier(MessageParcel &data, MessageParcel &reply);
int32_t OnGetVoiceMailInfor(MessageParcel &data, MessageParcel &reply);
int32_t OnGetVoiceMailNumber(MessageParcel &data, MessageParcel &reply);
int32_t OnGetVoiceMailCount(MessageParcel &data, MessageParcel &reply);
int32_t OnSetVoiceMailCount(MessageParcel &data, MessageParcel &reply);
int32_t OnSetVoiceCallForwarding(MessageParcel &data, MessageParcel &reply);
int32_t OnDiallingNumbersGet(MessageParcel &data, MessageParcel &reply);
int32_t OnAddIccDiallingNumbers(MessageParcel &data, MessageParcel &reply);
int32_t OnUpdateIccDiallingNumbers(MessageParcel &data, MessageParcel &reply);

View File

@ -872,6 +872,48 @@ int32_t CoreService::GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMai
return simManager_->GetVoiceMailNumber(slotId, voiceMailNumber);
}
int32_t CoreService::GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount)
{
if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
TELEPHONY_LOGE("permission denied!");
return TELEPHONY_ERR_PERMISSION_ERR;
}
TELEPHONY_LOGI("CoreService::GetVoiceMailCount(), slotId = %{public}d", slotId);
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->GetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreService::SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount)
{
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
TELEPHONY_LOGE("permission denied!");
return TELEPHONY_ERR_PERMISSION_ERR;
}
TELEPHONY_LOGI("CoreService::SetVoiceMailCount(), slotId = %{public}d", slotId);
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->SetVoiceMailCount(slotId, voiceMailCount);
}
int32_t CoreService::SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number)
{
if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
TELEPHONY_LOGE("permission denied!");
return TELEPHONY_ERR_PERMISSION_ERR;
}
TELEPHONY_LOGI("CoreService::SetVoiceCallForwarding(), slotId = %{public}d", slotId);
if (simManager_ == nullptr) {
TELEPHONY_LOGE("simManager_ is null");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
return simManager_->SetVoiceCallForwarding(slotId, enable, number);
}
int32_t CoreService::QueryIccDiallingNumbers(
int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &reslut)
{

View File

@ -104,6 +104,9 @@ void CoreServiceStub::AddHandlerSimToMapExt()
&CoreServiceStub::OnGetSimTeleNumberIdentifier;
memberFuncMap_[uint32_t(InterfaceID::GET_VOICE_MAIL_TAG)] = &CoreServiceStub::OnGetVoiceMailInfor;
memberFuncMap_[uint32_t(InterfaceID::GET_VOICE_MAIL_NUMBER)] = &CoreServiceStub::OnGetVoiceMailNumber;
memberFuncMap_[uint32_t(InterfaceID::GET_VOICE_MAIL_COUNT)] = &CoreServiceStub::OnGetVoiceMailCount;
memberFuncMap_[uint32_t(InterfaceID::SET_VOICE_MAIL_COUNT)] = &CoreServiceStub::OnSetVoiceMailCount;
memberFuncMap_[uint32_t(InterfaceID::SET_VOICE_CALL_FORWARDING)] = &CoreServiceStub::OnSetVoiceCallForwarding;
memberFuncMap_[uint32_t(InterfaceID::ICC_DIALLING_NUMBERS_GET)] = &CoreServiceStub::OnDiallingNumbersGet;
memberFuncMap_[uint32_t(InterfaceID::ICC_DIALLING_NUMBERS_INSERT)] = &CoreServiceStub::OnAddIccDiallingNumbers;
memberFuncMap_[uint32_t(InterfaceID::ICC_DIALLING_NUMBERS_UPDATE)] = &CoreServiceStub::OnUpdateIccDiallingNumbers;
@ -1124,6 +1127,47 @@ int32_t CoreServiceStub::OnGetVoiceMailNumber(MessageParcel &data, MessageParcel
return result;
}
int32_t CoreServiceStub::OnGetVoiceMailCount(MessageParcel &data, MessageParcel &reply)
{
int32_t slotId = data.ReadInt32();
int32_t voiceMailCount;
int32_t result = GetVoiceMailCount(slotId, voiceMailCount);
bool ret = reply.WriteInt32(result);
if (result == TELEPHONY_ERR_SUCCESS) {
ret = (ret && reply.WriteInt32(voiceMailCount));
}
if (!ret) {
TELEPHONY_LOGE("OnRemoteRequest::OnGetVoiceMailCount write reply failed.");
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
}
return result;
}
int32_t CoreServiceStub::OnSetVoiceMailCount(MessageParcel &data, MessageParcel &reply)
{
int32_t slotId = data.ReadInt32();
int32_t voiceMailCount = data.ReadInt32();
int32_t result = SetVoiceMailCount(slotId, voiceMailCount);
if (!reply.WriteInt32(result)) {
TELEPHONY_LOGE("OnRemoteRequest::OnSetVoiceMailCount write reply failed.");
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
}
return result;
}
int32_t CoreServiceStub::OnSetVoiceCallForwarding(MessageParcel &data, MessageParcel &reply)
{
int32_t slotId = data.ReadInt32();
bool enable = data.ReadBool();
std::string number = data.ReadString();
int32_t result = SetVoiceCallForwarding(slotId, enable, number);
if (!reply.WriteInt32(result)) {
TELEPHONY_LOGE("OnRemoteRequest::OnSetVoiceCallForwarding write reply failed.");
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
}
return result;
}
int32_t CoreServiceStub::OnDiallingNumbersGet(MessageParcel &data, MessageParcel &reply)
{
int32_t slotId = data.ReadInt32();

View File

@ -62,6 +62,7 @@ public:
std::string ObtainHomeNameOfPnn();
std::string ObtainMsisdnAlphaStatus();
std::string ObtainVoiceMailNumber();
int32_t ObtainVoiceMailCount();
std::string ObtainSPN();
std::string ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired);
std::string ObtainVoiceMailInfo();
@ -79,6 +80,8 @@ public:
virtual void ProcessParseFile(const AppExecFwk::InnerEvent::Pointer &event) = 0;
};
virtual bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber) = 0;
virtual bool SetVoiceMailCount(int32_t voiceMailCount) = 0;
virtual bool SetVoiceCallForwarding(bool enable, const std::string &number) = 0;
bool HasSimCard();
void UnInit();
void ClearData();
@ -107,6 +110,13 @@ protected:
std::string lastMsisdn_ = "";
std::string lastMsisdnTag_ = "";
std::string voiceMailNum_ = "";
int32_t efMWISSize_ = 0;
int32_t efCphsMwiSize_ = 0;
int32_t efCfisSize_ = 0;
int32_t efCffSize_ = 0;
int32_t callForwardingStatus = CALL_FORWARDING_STATUS_UNKNOWN;
bool voiceMailWaiting_ = false;
int32_t voiceMailCount_ = DEFAULT_VOICE_MAIL_COUNT;
std::string voiceMailTag_ = "";
std::string lastVoiceMailNum_ = "";
std::string lastVoiceMailTag_ = "";
@ -130,7 +140,13 @@ protected:
bool waitResult_ = false;
static std::mutex mtx_;
std::condition_variable processWait_;
const uint8_t BYTE_NUM = 0xff;
const uint8_t BYTE_NUM = 0xFF;
const uint8_t BYTE_NUM2 = 0x01;
const uint8_t BYTE_NUM3 = 0x0F;
const uint8_t BYTE_NUM4 = 0x0A;
const uint8_t BYTE_NUM5 = 0x05;
const uint8_t BYTE_NUM6 = 0xFE;
const uint8_t BYTE_NUM7 = 0xF0;
const int DATA_STEP = 2;
static std::unique_ptr<ObserverHandler> filesFetchedObser_;
std::unique_ptr<ObserverHandler> lockedFilesFetchedObser_ = nullptr;

View File

@ -33,6 +33,8 @@ public:
std::string ObtainIsimIst();
std::string *ObtainIsimPcscf();
bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber);
bool SetVoiceMailCount(int32_t voiceMailCount);
bool SetVoiceCallForwarding(bool enable, const std::string &number);
int ObtainSpnCondition(bool roaming, const std::string &operatorNum);
std::string ObtainIsoCountryCode();

View File

@ -40,6 +40,8 @@ public:
bool ObtainCsimSpnDisplayCondition();
int ObtainSpnCondition(bool roaming, const std::string &operatorNum);
bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber);
bool SetVoiceMailCount(int32_t voiceMailCount);
bool SetVoiceCallForwarding(bool enable, const std::string &number);
protected:
void ProcessIccRefresh(int msgId);

View File

@ -273,6 +273,17 @@ enum RadioProtocolEvent {
MSG_SIM_SET_ACTIVE = 2001,
MSG_SIM_FORGET_ALLDATA = 2002,
};
enum VoiceMailConstant {
DEFAULT_VOICE_MAIL_COUNT = -2,
UNKNOWN_VOICE_MAIL_COUNT = -1,
};
enum CallForwardingStatus {
CALL_FORWARDING_STATUS_DISABLED = 0,
CALL_FORWARDING_STATUS_ENABLED = 1,
CALL_FORWARDING_STATUS_UNKNOWN = -1,
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_SIM_CONSTANT_H

View File

@ -36,6 +36,8 @@ public:
~SimFile() = default;
bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event);
bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber);
bool SetVoiceMailCount(int32_t voiceMailCount);
bool SetVoiceCallForwarding(bool enable, const std::string &number);
protected:
enum SpnStatus {
@ -59,6 +61,10 @@ protected:
unsigned char *efCphsMwi_ = nullptr;
unsigned char *efCff_ = nullptr;
unsigned char *efCfis_ = nullptr;
std::string efMWISStr_;
std::string efCphsMwisStr_;
std::string efCffStr_;
std::string efCfisStr_;
std::string efLi_ = IccFileController::NULLSTR;
std::string efPl_ = IccFileController::NULLSTR;
SpnStatus spnStatus_ = OBTAIN_SPN_NONE;
@ -128,8 +134,13 @@ private:
const int MAIL_DELAY_TIME = 50 * 1000;
static const uint8_t CPHS_VOICE_MAIL_MASK = 0x30;
static const uint8_t CPHS_VOICE_MAIL_EXSIT = 0x30;
static const int CFIS_BCD_NUMBER_LENGTH_OFFSET = 2;
static const int CFIS_TON_NPI_OFFSET = 3;
static const int CFIS_ADN_CAPABILITY_ID_OFFSET = 14;
static const int CFIS_ADN_EXTENSION_ID_OFFSET = 15;
int ObtainExtensionElementaryFile(int ef);
bool CphsVoiceMailAvailable();
bool EfCfisAvailable(int32_t size);
void GetCphsMailBox();
std::string ParseSpn(const std::string &rawData, int curState);
void ParsePnn(const std::vector<std::string> &records);

View File

@ -55,6 +55,9 @@ public:
std::u16string GetSimIst();
std::u16string GetVoiceMailIdentifier();
std::u16string GetVoiceMailNumber();
int32_t GetVoiceMailCount();
bool SetVoiceMailCount(int32_t voiceMailCount);
bool SetVoiceCallForwarding(bool enable, const std::string &number);
std::u16string GetOpName();
std::u16string GetOpKey();
std::u16string GetOpKeyExt();

View File

@ -102,6 +102,9 @@ public:
std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) override;
int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) override;
int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) override;
int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) override;
int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) override;
int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) override;
std::u16string GetSimIst(int32_t slotId) override;
int ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum) override;
int32_t SetVoiceMailInfo(int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) override;

View File

@ -192,6 +192,11 @@ std::string IccFile::ObtainVoiceMailNumber()
return voiceMailNum_;
}
int32_t IccFile::ObtainVoiceMailCount()
{
return voiceMailCount_;
}
std::string IccFile::ObtainSPN()
{
return spn_;

View File

@ -245,6 +245,18 @@ bool IsimFile::UpdateVoiceMail(const std::string &mailName, const std::string &m
return false;
}
bool IsimFile::SetVoiceMailCount(int32_t voiceMailCount)
{
// cdma not support
return false;
}
bool IsimFile::SetVoiceCallForwarding(bool enable, const std::string &number)
{
// cdma not support
return false;
}
int IsimFile::ObtainSpnCondition(bool roaming, const std::string &operatorNum)
{
return 0;

View File

@ -371,6 +371,18 @@ bool RuimFile::UpdateVoiceMail(const std::string &mailName, const std::string &m
return false;
}
bool RuimFile::SetVoiceMailCount(int32_t voiceMailCount)
{
// cdma not support
return false;
}
bool RuimFile::SetVoiceCallForwarding(bool enable, const std::string &number)
{
// cdma not support
return false;
}
RuimFile::~RuimFile() {}
} // namespace Telephony
} // namespace OHOS

View File

@ -20,7 +20,9 @@
#include "common_event_manager.h"
#include "common_event_support.h"
#include "radio_event.h"
#include "sim_number_decode.h"
#include "telephony_common_utils.h"
#include "telephony_state_registry_client.h"
using namespace std;
using namespace OHOS::AppExecFwk;
@ -242,6 +244,16 @@ void SimFile::LoadSimFiles()
AppExecFwk::InnerEvent::Pointer eventAD = BuildCallerInfo(MSG_SIM_OBTAIN_AD_DONE);
fileController_->ObtainBinaryFile(ELEMENTARY_FILE_AD, eventAD);
fileToGet_++;
AppExecFwk::InnerEvent::Pointer eventMWIS = BuildCallerInfo(MSG_SIM_OBTAIN_MWIS_DONE);
fileController_->ObtainLinearFixedFile(ELEMENTARY_FILE_MWIS, 1, eventMWIS);
fileToGet_++;
AppExecFwk::InnerEvent::Pointer eventCPHS = BuildCallerInfo(MSG_SIM_OBTAIN_VOICE_MAIL_INDICATOR_CPHS_DONE);
fileController_->ObtainBinaryFile(ELEMENTARY_FILE_VOICE_MAIL_INDICATOR_CPHS, eventCPHS);
fileToGet_++;
ObtainCallForwardFiles();
}
void SimFile::ObtainSpnPhase(bool start, const AppExecFwk::InnerEvent::Pointer &event)
@ -656,15 +668,24 @@ bool SimFile::ProcessGetCfisDone(const AppExecFwk::InnerEvent::Pointer &event)
TELEPHONY_LOGE("fd is nullptr!");
return isFileProcessResponse;
}
std::string iccData = fd->resultData;
char *rawData = const_cast<char *>(iccData.c_str());
unsigned char *fileData = reinterpret_cast<unsigned char *>(rawData);
efCfisStr_ = fd->resultData;
std::shared_ptr<unsigned char> rawData = SIMUtils::HexStringConvertToBytes(efCfisStr_, efCfisSize_);
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr");
return isFileProcessResponse;
}
if (fd->exception != nullptr) {
efCfis_ = nullptr;
} else {
unsigned char *fileData = rawData.get();
TELEPHONY_LOGI("ELEMENTARY_FILE_CFIS: %{public}s", fileData);
efCfis_ = fileData;
if (EfCfisAvailable(efCfisSize_)) {
// Refer TS 51.011 Section 10.3.46 for the content description
callForwardingStatus = (efCfis_[1] & BYTE_NUM2);
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateCfuIndicator(
slotId_, callForwardingStatus == CALL_FORWARDING_STATUS_ENABLED);
}
}
return isFileProcessResponse;
}
@ -789,20 +810,34 @@ bool SimFile::ProcessGetMwisDone(const AppExecFwk::InnerEvent::Pointer &event)
TELEPHONY_LOGE("fd is nullptr!");
return isFileProcessResponse;
}
std::string iccData = fd->resultData;
char *rawData = const_cast<char *>(iccData.c_str());
unsigned char *fileData = reinterpret_cast<unsigned char *>(rawData);
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_MWIS : %{public}s", rawData);
if (fd->exception != nullptr) {
TELEPHONY_LOGE("MSG_SIM_OBTAIN_MWIS_DONE exception = ");
efMWISStr_ = fd->resultData;
std::shared_ptr<unsigned char> rawData = SIMUtils::HexStringConvertToBytes(efMWISStr_, efMWISSize_);
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr");
return isFileProcessResponse;
}
if (fd->exception != nullptr) {
TELEPHONY_LOGE("MSG_SIM_OBTAIN_MWIS_DONE exception is nullptr");
return isFileProcessResponse;
}
unsigned char *fileData = rawData.get();
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_MWIS : %{public}s", fileData);
unsigned char value = fileData[0];
if ((value & BYTE_NUM) == BYTE_NUM) {
TELEPHONY_LOGI("SimFiles: Uninitialized record MWIS");
return isFileProcessResponse;
}
efMWIS_ = fileData;
if (efMWIS_ != nullptr && efMWISSize_ > 1) {
// Refer TS 51.011 Section 10.3.45 for the content description
voiceMailWaiting_ = ((efMWIS_[0] & BYTE_NUM2) != 0);
voiceMailCount_ = efMWIS_[1] & BYTE_NUM;
if (voiceMailWaiting_ && (voiceMailCount_ == 0 || voiceMailCount_ == BYTE_NUM)) {
voiceMailCount_ = UNKNOWN_VOICE_MAIL_COUNT;
}
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateVoiceMailMsgIndicator(
slotId_, voiceMailCount_ > 0);
}
return isFileProcessResponse;
}
@ -818,15 +853,30 @@ bool SimFile::ProcessVoiceMailCphs(const AppExecFwk::InnerEvent::Pointer &event)
TELEPHONY_LOGE("fd is nullptr!");
return isFileProcessResponse;
}
std::string iccData = fd->resultData;
char *rawData = const_cast<char *>(iccData.c_str());
unsigned char *fileData = reinterpret_cast<unsigned char *>(rawData);
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_CPHS_MWI: %{public}s", rawData);
if (fd->exception != nullptr) {
TELEPHONY_LOGE("MSG_SIM_OBTAIN_VOICE_MAIL_INDICATOR_CPHS_DONE exception = ");
efCphsMwisStr_ = fd->resultData;
std::shared_ptr<unsigned char> rawData = SIMUtils::HexStringConvertToBytes(efCphsMwisStr_, efCphsMwiSize_);
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr");
return isFileProcessResponse;
}
if (fd->exception != nullptr) {
TELEPHONY_LOGE("MSG_SIM_OBTAIN_VOICE_MAIL_INDICATOR_CPHS_DONE exception is nullptr");
return isFileProcessResponse;
}
unsigned char *fileData = rawData.get();
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_VOICE_MAIL_INDICATOR_CPHS: %{public}s", fileData);
efCphsMwi_ = fileData;
if (efCphsMwi_ != nullptr && efCphsMwiSize_ > 0 && voiceMailCount_ == DEFAULT_VOICE_MAIL_COUNT) {
// Refer TS 51.011 Section 10.3.45 for the content description
int indicator = static_cast<int>(efCphsMwi_[0] & BYTE_NUM3);
if (indicator == BYTE_NUM4) {
voiceMailCount_ = UNKNOWN_VOICE_MAIL_COUNT;
} else if (indicator == BYTE_NUM5) {
voiceMailCount_ = 0;
}
}
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateVoiceMailMsgIndicator(
slotId_, voiceMailCount_ > 0);
return isFileProcessResponse;
}
@ -886,14 +936,25 @@ bool SimFile::ProcessGetCffDone(const AppExecFwk::InnerEvent::Pointer &event)
TELEPHONY_LOGE("fd is nullptr!");
return isFileProcessResponse;
}
std::string iccData = fd->resultData;
char *rawData = const_cast<char *>(iccData.c_str());
unsigned char *fileData = reinterpret_cast<unsigned char *>(rawData);
efCffStr_ = fd->resultData;
std::shared_ptr<unsigned char> rawData = SIMUtils::HexStringConvertToBytes(efCffStr_, efCffSize_);
if (rawData == nullptr) {
TELEPHONY_LOGE("rawData is nullptr");
return isFileProcessResponse;
}
if (fd->exception != nullptr) {
efCff_ = nullptr;
} else {
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_CFF_CPHS: %{public}s", rawData);
unsigned char *fileData = rawData.get();
TELEPHONY_LOGI("SimFile ELEMENTARY_FILE_CFF_CPHS: %{public}s", fileData);
efCff_ = fileData;
if (efCff_ != nullptr && efCffSize_ > 0 && callForwardingStatus == CALL_FORWARDING_STATUS_UNKNOWN) {
// Refer TS 51.011 Section 10.3.46 for the content description
callForwardingStatus = ((efCff_[0] & BYTE_NUM3) == BYTE_NUM4) ? CALL_FORWARDING_STATUS_ENABLED
: CALL_FORWARDING_STATUS_DISABLED;
}
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateCfuIndicator(
slotId_, callForwardingStatus == CALL_FORWARDING_STATUS_ENABLED);
}
return isFileProcessResponse;
}
@ -1523,6 +1584,88 @@ bool SimFile::UpdateVoiceMail(const std::string &mailName, const std::string &ma
return waitResult_;
}
bool SimFile::SetVoiceMailCount(int32_t voiceMailCount)
{
bool setDone = false;
AppExecFwk::InnerEvent::Pointer eventUpdate = BuildCallerInfo(MSG_SIM_UPDATE_DONE);
std::shared_ptr<unsigned char> efMWISData = SIMUtils::HexStringConvertToBytes(efMWISStr_, efMWISSize_);
efMWIS_ = efMWISData != nullptr ? efMWISData.get() : nullptr;
if (efMWIS_ != nullptr && efMWISSize_ > 1) {
// TS 51.011 10.3.45
efMWIS_[0] = static_cast<unsigned char>((efMWIS_[0] & BYTE_NUM6) | (voiceMailCount == 0 ? 0 : BYTE_NUM2));
efMWIS_[1] = voiceMailCount < 0 ? 0 : static_cast<unsigned char>(voiceMailCount);
fileController_->UpdateLinearFixedFile(ELEMENTARY_FILE_MWIS, 1, efMWISStr_, efMWISSize_, "", eventUpdate);
setDone = true;
}
std::shared_ptr<unsigned char> efCphsMwiData = SIMUtils::HexStringConvertToBytes(efCphsMwisStr_, efCphsMwiSize_);
efCphsMwi_ = efCphsMwiData != nullptr ? efCphsMwiData.get() : nullptr;
if (efCphsMwi_ != nullptr && efCphsMwiSize_ > 1) {
efCphsMwi_[0] =
static_cast<unsigned char>((efCphsMwi_[0] & BYTE_NUM7) | (voiceMailCount == 0 ? BYTE_NUM5 : BYTE_NUM4));
fileController_->UpdateBinaryFile(
ELEMENTARY_FILE_VOICE_MAIL_INDICATOR_CPHS, efCphsMwisStr_, efCphsMwiSize_, eventUpdate);
setDone = true;
}
if (setDone) {
voiceMailCount_ = voiceMailCount;
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateVoiceMailMsgIndicator(
slotId_, voiceMailCount_ > 0);
return true;
}
TELEPHONY_LOGE("SetVoiceMailCount efMWIS_ and efCphsMwi_ is nullptr");
return false;
}
bool SimFile::SetVoiceCallForwarding(bool enable, const std::string &number)
{
bool setDone = false;
AppExecFwk::InnerEvent::Pointer eventUpdate = BuildCallerInfo(MSG_SIM_UPDATE_DONE);
std::shared_ptr<unsigned char> efCfisData = SIMUtils::HexStringConvertToBytes(efCfisStr_, efCfisSize_);
efCfis_ = efCfisData != nullptr ? efCfisData.get() : nullptr;
if (EfCfisAvailable(efCfisSize_)) {
if (enable) {
efCfis_[1] |= BYTE_NUM2;
} else {
efCfis_[1] &= BYTE_NUM6;
}
// Spec reference for EF_CFIS contents, TS 51.011 section 10.3.46.
if (enable && !number.empty()) {
std::vector<uint8_t> bcdCodes;
SimNumberDecode::NumberConvertToBCD(number, bcdCodes, false, SimNumberDecode::BCD_TYPE_ADN);
int dataLength = bcdCodes.size();
unsigned char numberData[dataLength];
for (int i = 0; i < dataLength; ++i) {
numberData[i] = bcdCodes.at(i);
}
SIMUtils::ArrayCopy(numberData, 0, efCfis_, CFIS_TON_NPI_OFFSET, dataLength);
efCfis_[CFIS_BCD_NUMBER_LENGTH_OFFSET] = static_cast<unsigned char>(dataLength);
efCfis_[CFIS_ADN_CAPABILITY_ID_OFFSET] = static_cast<unsigned char>(BYTE_NUM);
efCfis_[CFIS_ADN_EXTENSION_ID_OFFSET] = static_cast<unsigned char>(BYTE_NUM);
}
fileController_->UpdateLinearFixedFile(ELEMENTARY_FILE_CFIS, 1, efCfisStr_, efCfisSize_, "", eventUpdate);
setDone = true;
}
std::shared_ptr<unsigned char> efCffData = SIMUtils::HexStringConvertToBytes(efCffStr_, efCffSize_);
efCff_ = efCffData != nullptr ? efCffData.get() : nullptr;
if (efCff_ != nullptr && efCffSize_ > 0) {
if (enable) {
efCff_[0] = static_cast<unsigned char>((efCff_[0] & BYTE_NUM7) | BYTE_NUM4);
} else {
efCff_[0] = static_cast<unsigned char>((efCff_[0] & BYTE_NUM7) | BYTE_NUM5);
}
fileController_->UpdateBinaryFile(ELEMENTARY_FILE_CFF_CPHS, efCffStr_, efCffSize_, eventUpdate);
setDone = true;
}
if (setDone) {
callForwardingStatus = enable ? CALL_FORWARDING_STATUS_ENABLED : CALL_FORWARDING_STATUS_DISABLED;
DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateCfuIndicator(
slotId_, callForwardingStatus == CALL_FORWARDING_STATUS_ENABLED);
return true;
}
TELEPHONY_LOGE("SetVoiceCallForwarding efCfis_ and efCff_ is nullptr");
return false;
}
bool SimFile::CphsVoiceMailAvailable()
{
bool available = false;
@ -1533,5 +1676,17 @@ bool SimFile::CphsVoiceMailAvailable()
}
return available;
}
bool SimFile::EfCfisAvailable(int32_t size)
{
if (efCfis_ != nullptr && size > 1) {
for (int32_t i = 0; i < size; ++i) {
if (efCfis_[i] != BYTE_NUM) {
return true;
}
}
}
return false;
}
} // namespace Telephony
} // namespace OHOS

View File

@ -316,6 +316,36 @@ std::u16string SimFileManager::GetVoiceMailNumber()
return Str8ToStr16(result);
}
int32_t SimFileManager::GetVoiceMailCount()
{
if (simFile_ == nullptr) {
TELEPHONY_LOGE("SimFileManager::GetVoiceMailCount simFile nullptr");
return UNKNOWN_VOICE_MAIL_COUNT;
}
return simFile_->ObtainVoiceMailCount();
}
bool SimFileManager::SetVoiceMailCount(int32_t voiceMailCount)
{
if (simFile_ == nullptr) {
TELEPHONY_LOGE("SimFileManager::SetVoiceMailCount simFile nullptr");
return false;
}
return simFile_->SetVoiceMailCount(voiceMailCount);
}
bool SimFileManager::SetVoiceCallForwarding(bool enable, const std::string &number)
{
if (simFile_ == nullptr) {
TELEPHONY_LOGE("SimFileManager::SetVoiceCallForwarding simFile nullptr");
return false;
}
return simFile_->SetVoiceCallForwarding(enable, number);
}
std::u16string SimFileManager::GetOpName()
{
return Str8ToStr16(opName_);

View File

@ -777,6 +777,52 @@ int32_t SimManager::GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMail
return TELEPHONY_ERR_SUCCESS;
}
int32_t SimManager::GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount)
{
if (!HasSimCardInner(slotId)) {
TELEPHONY_LOGE("GetVoiceMailCount has no sim card!");
return TELEPHONY_ERR_NO_SIM_CARD;
}
if ((!IsValidSlotId(slotId)) || (simFileManager_[slotId] == nullptr)) {
TELEPHONY_LOGE("simFileManager is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
voiceMailCount = simFileManager_[slotId]->GetVoiceMailCount();
return TELEPHONY_ERR_SUCCESS;
}
int32_t SimManager::SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount)
{
if (!HasSimCardInner(slotId)) {
TELEPHONY_LOGE("SetVoiceMailCount has no sim card!");
return TELEPHONY_ERR_NO_SIM_CARD;
}
if ((!IsValidSlotId(slotId)) || (simFileManager_[slotId] == nullptr)) {
TELEPHONY_LOGE("simFileManager is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
if (simFileManager_[slotId]->SetVoiceMailCount(voiceMailCount)) {
return TELEPHONY_ERR_SUCCESS;
}
return CORE_ERR_SIM_CARD_UPDATE_FAILED;
}
int32_t SimManager::SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number)
{
if (!HasSimCardInner(slotId)) {
TELEPHONY_LOGE("SetVoiceCallForwarding has no sim card!");
return TELEPHONY_ERR_NO_SIM_CARD;
}
if ((!IsValidSlotId(slotId)) || (simFileManager_[slotId] == nullptr)) {
TELEPHONY_LOGE("simFileManager is null!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
if (simFileManager_[slotId]->SetVoiceCallForwarding(enable, number)) {
return TELEPHONY_ERR_SUCCESS;
}
return CORE_ERR_SIM_CARD_UPDATE_FAILED;
}
int32_t SimManager::ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum)
{
if ((!IsValidSlotId(slotId)) || (simFileManager_[slotId] == nullptr)) {

View File

@ -235,6 +235,9 @@ enum class InputCmd {
INPUT_GETSIMID = 71,
INPUT_GETSLOTID = 72,
INPUT_QUIT = 100,
INPUT_GET_VOICEMAIL_COUNT = 130,
INPUT_SET_VOICEMAIL_COUNT = 131,
INPUT_SET_VOICECALL_FORWARDING = 132,
};
enum class PinWordSize {
@ -598,6 +601,44 @@ static bool TestGetVoiceMailNumber()
return true;
}
static bool TestGetVoiceMailCount()
{
AccessToken token;
static int32_t testSlot = SLOT_ID;
std::cout << "please input Slot Id" << std::endl;
std::cin >> testSlot;
int32_t result;
g_telephonyService->GetVoiceMailCount(testSlot, result);
std::cout << "TelephonyTestService Remote GetVoiceMailCount result [" << result << "] " << std::endl;
return true;
}
static bool TestSetVoiceMailCount()
{
static int32_t testSlot = SLOT_ID;
int32_t voiceMailCount;
std::cout << "please input Slot Id" << std::endl;
std::cin >> testSlot;
std::cout << "please input voiceMailCount" << std::endl;
std::cin >> voiceMailCount;
int32_t result = g_telephonyService->SetVoiceMailCount(testSlot, voiceMailCount);
std::cout << "TelephonyTestService Remote SetVoiceMailCount result [" << result << "] " << std::endl;
return true;
}
static bool TestSetVoiceCallForwarding()
{
static int32_t testSlot = SLOT_ID;
std::cout << "please input Slot Id" << std::endl;
std::cin >> testSlot;
std::string number;
std::cout << "please input number" << endl;
std::cin >> number;
int32_t result = g_telephonyService->SetVoiceCallForwarding(testSlot, true, number);
std::cout << "TelephonyTestService Remote SetVoiceCallForwarding result [" << result << "] " << std::endl;
return true;
}
static bool TestQueryIccDiallingNumbers()
{
AccessToken token;
@ -1364,6 +1405,7 @@ static void Prompt()
"61:GetSimTelephoneNumber\n62:GetSimTeleNumberIdentifier\n63:GetCardType\n"
"64:UnlockSimLock\n65:SetPrimarySlotId\n66:GetPrimarySlotId\n67:GetOpName\n"
"68:GetOpKeyExt\n70:HasOperatorPrivileges\n71:TestGetSimId\n72:TestGetSlotId\n"
"130:GetVoiceMailCount\n131:SetVoiceMailCount\n132:SetVoiceCallForwarding\n"
"100:exit\n"
<< std::endl;
}
@ -1428,6 +1470,9 @@ static void InitFuncMapExt()
g_funcMap[InputCmd::INPUT_GETSIMID] = TestGetSimId;
g_funcMap[InputCmd::INPUT_GETSLOTID] = TestGetSlotId;
g_funcMap[InputCmd::INPUT_QUIT] = TestQuit;
g_funcMap[InputCmd::INPUT_GET_VOICEMAIL_COUNT] = TestGetVoiceMailCount;
g_funcMap[InputCmd::INPUT_SET_VOICEMAIL_COUNT] = TestSetVoiceMailCount;
g_funcMap[InputCmd::INPUT_SET_VOICECALL_FORWARDING] = TestSetVoiceCallForwarding;
}
static bool ProcessInput()

View File

@ -942,6 +942,124 @@ HWTEST_F(SimTest, Telephony_Sim_GetVoiceMailNumber_0300, Function | MediumTest |
}
}
/**
* @tc.number Telephony_Sim_GetVoiceMailCount_0100
* @tc.name Get sim voice mail count
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_GetVoiceMailCount_0100, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
int32_t voiceMailCount;
int32_t result = CoreServiceClient::GetInstance().GetVoiceMailCount(SimTest::slotId_, voiceMailCount);
EXPECT_EQ(result, TELEPHONY_ERR_SUCCESS);
}
}
/**
* @tc.number Telephony_Sim_GetVoiceMailCount_0200
* @tc.name Get sim voice mail count
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_GetVoiceMailCount_0200, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId1_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
int32_t voiceMailCount;
int32_t result = CoreServiceClient::GetInstance().GetVoiceMailCount(SimTest::slotId1_, voiceMailCount);
EXPECT_EQ(result, TELEPHONY_ERR_SUCCESS);
}
}
/**
* @tc.number Telephony_Sim_GetVoiceMailCount_0300
* @tc.name Get sim voice mail count
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_GetVoiceMailCount_0300, Function | MediumTest | Level1)
{
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
int32_t voiceMailCount;
int32_t result = CoreServiceClient::GetInstance().GetVoiceMailCount(SimTest::slotId_, voiceMailCount);
EXPECT_NE(result, TELEPHONY_ERR_SUCCESS);
}
}
/**
* @tc.number Telephony_Sim_SetVoiceMailCount_0100
* @tc.name Set sim voice mail count
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SetVoiceMailCount_0100, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
int32_t voiceMailCount = 0;
int32_t result = CoreServiceClient::GetInstance().SetVoiceMailCount(SimTest::slotId_, voiceMailCount);
EXPECT_GT(result, -1);
}
}
/**
* @tc.number Telephony_Sim_SetVoiceMailCount_0200
* @tc.name Get sim voice mail count
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SetVoiceMailCount_0200, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId1_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
int32_t voiceMailCount = 0;
int32_t result = CoreServiceClient::GetInstance().SetVoiceMailCount(SimTest::slotId1_, voiceMailCount);
EXPECT_GT(result, -1);
}
}
/**
* @tc.number Telephony_Sim_SetVoiceCallForwarding_0100
* @tc.name Set sim voicecall forwarding
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SetVoiceCallForwarding_0100, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
std::string number = "01234567890123456789";
int32_t result = CoreServiceClient::GetInstance().SetVoiceCallForwarding(SimTest::slotId_, true, number);
EXPECT_GT(result, -1);
}
}
/**
* @tc.number Telephony_Sim_SetVoiceCallForwarding_0200
* @tc.name Set sim voicecall forwarding
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_SetVoiceCallForwarding_0200, Function | MediumTest | Level1)
{
AccessToken token;
if (!SimTest::HasSimCard(slotId1_)) {
TELEPHONY_LOGI("TelephonyTestService has no sim card");
} else {
std::string number = "01234567890123456789";
int32_t result = CoreServiceClient::GetInstance().SetVoiceCallForwarding(SimTest::slotId_, true, number);
EXPECT_GT(result, -1);
}
}
/**
* @tc.number Telephony_Sim_GetDefaultVoiceSlotId_0100
* @tc.name Get default voice sim slotId