Merge branch 'master' of gitee.com:openharmony/telephony_core_service into master

Signed-off-by: PaDaBoo <xuejianwu@huawei.com>
This commit is contained in:
PaDaBoo 2022-06-17 06:58:43 +00:00 committed by Gitee
commit 55d3c653c6
68 changed files with 1174 additions and 343 deletions

View File

@ -14,7 +14,7 @@
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service"
TELEPHONY_NETWORK_SEARCH_ROOT =
@ -35,6 +35,8 @@ ohos_shared_library("tel_core_service") {
"$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_death_recipient.cpp",
"$TELEPHONY_IMS_CORE_SERVICE_SRC_PATH/ims_core_service_proxy.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/cell_info.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/device_state_handler.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/device_state_observer.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/ims_sms_callback_proxy.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/ims_ut_callback_proxy.cpp",
"$TELEPHONY_NETWORK_SEARCH_ROOT/src/ims_video_callback_proxy.cpp",
@ -146,16 +148,17 @@ ohos_shared_library("tel_core_service") {
"bundle_framework:appexecfwk_core",
"common_event_service:cesfwk_innerkits",
"common_event_service:cesfwk_services",
"device_driver_framework:libhdf_utils",
"device_driver_framework:libhdi",
"eventhandler:libeventhandler",
"hdf_core:libhdf_utils",
"hdf_core:libhdi",
"i18n:zone_util",
"ipc:ipc_core",
"netmanager_base:net_conn_manager_if",
"power_manager_native:powermgr_client",
"relational_store:native_dataability",
"relational_store:native_rdb",
"resource_management:global_resmgr",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",

View File

@ -34,11 +34,12 @@
"ability_runtime",
"appexecfwk_standard",
"common_event_service",
"device_driver_framework",
"hdf_core",
"dmsfwk_standard",
"i18n",
"ipc",
"relational_store",
"netmanager_base",
"power_manager_native",
"resource_management",
"ril_adapter",
@ -93,6 +94,7 @@
"header": {
"header_base" : "//base/telephony/core_service/utils",
"header_files": [
"common/include/telephony_hisysevent.h",
"common/include/str_convert.h",
"common/include/telephony_permission.h",
"log/include/telephony_log_c.h",

View File

@ -59,7 +59,7 @@ ohos_shared_library("radio") {
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",

View File

@ -18,7 +18,6 @@
#include <securec.h>
#include <uv.h>
#include <ctime>
#include "singleton.h"
#include "napi_util.h"
@ -29,15 +28,15 @@ namespace OHOS {
namespace Telephony {
class NapiImsCallbackManager {
public:
void RegImsStateCallback(ImsStateCallback stateCallback);
void RegImsStateCallback(const ImsStateCallback &stateCallback);
void UnRegImsStateCallback(napi_env env, int32_t slotId, ImsServiceType imsSrvType);
void UnRegAllImsStateCallbackOfType(napi_env env, int32_t slotId, ImsServiceType imsSrvType);
void UnRegAllImsStateCallbackOfType(int32_t slotId, ImsServiceType imsSrvType);
int32_t UpdateImsState(ImsServiceType imsSrvType, const ImsRegInfo &info);
private:
void UnRegCallback(ImsServiceType imsSrvType, int32_t slotId, std::list<ImsStateCallback>::iterator iter);
int32_t UpdateImsStateInfo(ImsStateCallback stateCallback, const ImsRegInfo &info);
void UnRegCallback(ImsServiceType imsSrvType, int32_t slotId, ImsStateCallback stateCallback);
int32_t UpdateImsStateInfo(const ImsStateCallback &stateCallback, const ImsRegInfo &info);
static void ReportImsStateWork(uv_work_t *work, int32_t status);
static int32_t ReportImsState(ImsRegInfo &info, ImsStateCallback stateCallback);
static int32_t ReportImsState(const ImsRegInfo &info, const ImsStateCallback &stateCallback);
ImsStateCallback stateCallback_;
std::list<ImsStateCallback> listStateCallback_;
};

View File

@ -22,7 +22,7 @@ namespace OHOS {
namespace Telephony {
class NapiImsSmsCallback : public ImsSmsCallbackStub {
public:
explicit NapiImsSmsCallback(ImsRegInfo info);
explicit NapiImsSmsCallback(const ImsRegInfo &info);
void OnImsSmsStateChange(const ImsRegInfo &info) override;
private:
ImsRegInfo info_;

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef NAPI_IMS_UT_CALL_BACK_H
#define NAPI_IMS_UT_CALL_BACK_H
#ifndef NAPI_IMS_UT_CALLBACK_H
#define NAPI_IMS_UT_CALLBACK_H
#include "ims_ut_callback_stub.h"
@ -22,11 +22,11 @@ namespace OHOS {
namespace Telephony {
class NapiImsUtCallback : public ImsUtCallbackStub {
public:
explicit NapiImsUtCallback(ImsRegInfo info);
explicit NapiImsUtCallback(const ImsRegInfo &info);
void OnImsUtStateChange(const ImsRegInfo &info) override;
private:
ImsRegInfo info_;
};
} // namespace Telephony
} // namespace OHOS
#endif // NAPI_IMS_UT_CALL_BACK_H
#endif // NAPI_IMS_UT_CALLBACK_H

View File

@ -22,7 +22,7 @@ namespace OHOS {
namespace Telephony {
class NapiImsVideoCallback : public ImsVideoCallbackStub {
public:
explicit NapiImsVideoCallback(ImsRegInfo info);
explicit NapiImsVideoCallback(const ImsRegInfo &info);
void OnImsVideoStateChange(const ImsRegInfo &info) override;
private:
ImsRegInfo info_;

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef NAPI_IMS_UT_CALLBACK_H
#define NAPI_IMS_UT_CALLBACK_H
#ifndef NAPI_IMS_VOICE_CALLBACK_H
#define NAPI_IMS_VOICE_CALLBACK_H
#include "ims_voice_callback_stub.h"
@ -22,11 +22,11 @@ namespace OHOS {
namespace Telephony {
class NapiImsVoiceCallback : public ImsVoiceCallbackStub {
public:
explicit NapiImsVoiceCallback(ImsRegInfo info);
explicit NapiImsVoiceCallback(const ImsRegInfo &info);
void OnImsVoiceStateChange(const ImsRegInfo &info) override;
private:
ImsRegInfo info_;
};
} // namespace Telephony
} // namespace OHOS
#endif // NAPI_IMS_UT_CALLBACK_H
#endif // NAPI_IMS_VOICE_CALLBACK_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -281,30 +281,17 @@ struct ImsRegInfoContext : BaseContext {
};
struct ImsStateCallback {
ImsStateCallback()
:env(nullptr),
thisVar(nullptr),
callbackRef(nullptr),
deferred(nullptr),
callbackBeginTime_(0),
slotId(0),
imsSrvType(TYPE_VOICE),
voiceCallback(nullptr),
videoCallback(nullptr),
utCallback(nullptr),
smsCallback(nullptr)
{}
napi_env env;
napi_value thisVar;
napi_ref callbackRef;
napi_deferred deferred;
time_t callbackBeginTime_;
int32_t slotId;
ImsServiceType imsSrvType;
sptr<ImsVoiceCallback> voiceCallback;
sptr<ImsVideoCallback> videoCallback;
sptr<ImsUtCallback> utCallback;
sptr<ImsSmsCallback> smsCallback;
napi_env env = nullptr;
napi_value thisVar = nullptr;
napi_ref callbackRef = nullptr;
napi_deferred deferred = nullptr;
time_t callbackBeginTime_ = 0;
int32_t slotId = DEFAULT_SIM_SLOT_ID;
ImsServiceType imsSrvType = TYPE_VOICE;
sptr<ImsVoiceCallback> voiceCallback = nullptr;
sptr<ImsVideoCallback> videoCallback = nullptr;
sptr<ImsUtCallback> utCallback = nullptr;
sptr<ImsSmsCallback> smsCallback = nullptr;
};
struct ImsStateWorker {

View File

@ -17,7 +17,7 @@
namespace OHOS {
namespace Telephony {
void NapiImsCallbackManager::RegImsStateCallback(ImsStateCallback stateCallback)
void NapiImsCallbackManager::RegImsStateCallback(const ImsStateCallback &stateCallback)
{
if (stateCallback.voiceCallback != nullptr
|| stateCallback.videoCallback != nullptr
@ -28,28 +28,32 @@ void NapiImsCallbackManager::RegImsStateCallback(ImsStateCallback stateCallback)
}
void NapiImsCallbackManager::UnRegCallback(
ImsServiceType imsSrvType, int32_t slotId, std::list<ImsStateCallback>::iterator iter)
ImsServiceType imsSrvType, int32_t slotId, ImsStateCallback stateCallback)
{
switch (imsSrvType) {
case ImsServiceType::TYPE_VOICE:
DelayedRefSingleton<CoreServiceClient>::GetInstance()
.UnRegImsVoiceCallback(slotId, iter->voiceCallback);
(void)memset_s(&iter->voiceCallback, sizeof(ImsStateCallback), 0, sizeof(ImsStateCallback));
.UnRegImsVoiceCallback(slotId, stateCallback.voiceCallback);
delete stateCallback.voiceCallback;
stateCallback.voiceCallback = nullptr;
break;
case ImsServiceType::TYPE_VIDEO:
DelayedRefSingleton<CoreServiceClient>::GetInstance()
.UnRegImsVideoCallback(slotId, iter->videoCallback);
(void)memset_s(&iter->videoCallback, sizeof(ImsStateCallback), 0, sizeof(ImsStateCallback));
.UnRegImsVideoCallback(slotId, stateCallback.videoCallback);
delete stateCallback.videoCallback;
stateCallback.videoCallback = nullptr;
break;
case ImsServiceType::TYPE_UT:
DelayedRefSingleton<CoreServiceClient>::GetInstance()
.UnRegImsUtCallback(slotId, iter->utCallback);
(void)memset_s(&iter->utCallback, sizeof(ImsStateCallback), 0, sizeof(ImsStateCallback));
.UnRegImsUtCallback(slotId, stateCallback.utCallback);
delete stateCallback.utCallback;
stateCallback.utCallback = nullptr;
break;
case ImsServiceType::TYPE_SMS:
DelayedRefSingleton<CoreServiceClient>::GetInstance()
.UnRegImsSmsCallback(slotId, iter->smsCallback);
(void)memset_s(&iter->smsCallback, sizeof(ImsStateCallback), 0, sizeof(ImsStateCallback));
.UnRegImsSmsCallback(slotId, stateCallback.smsCallback);
delete stateCallback.smsCallback;
stateCallback.smsCallback = nullptr;
break;
default:
TELEPHONY_LOGE("%{public}d type is error!", imsSrvType);
@ -65,21 +69,21 @@ void NapiImsCallbackManager::UnRegImsStateCallback(napi_env env, int32_t slotId,
&& (iter->slotId == slotId)
&& (iter->imsSrvType == imsSrvType)
&& (iter->callbackRef)) {
UnRegCallback(imsSrvType, slotId, iter);
UnRegCallback(imsSrvType, slotId, *iter);
listStateCallback_.erase(iter);
}
}
}
void NapiImsCallbackManager::UnRegAllImsStateCallbackOfType(
napi_env env, int32_t slotId, ImsServiceType imsSrvType)
int32_t slotId, ImsServiceType imsSrvType)
{
auto iter = listStateCallback_.begin();
for (; iter != listStateCallback_.end(); ++iter) {
if ((iter->slotId == slotId)
&& (iter->imsSrvType == imsSrvType)
&& (iter->callbackRef)) {
UnRegCallback(imsSrvType, slotId, iter);
UnRegCallback(imsSrvType, slotId, *iter);
listStateCallback_.erase(iter);
}
}
@ -87,21 +91,20 @@ void NapiImsCallbackManager::UnRegAllImsStateCallbackOfType(
int32_t NapiImsCallbackManager::UpdateImsState(ImsServiceType imsSrvType, const ImsRegInfo &info)
{
int32_t ret;
auto iter = listStateCallback_.begin();
for (; iter != listStateCallback_.end(); ++iter) {
if (iter->imsSrvType == imsSrvType) {
UpdateImsStateInfo(*iter, info);
int32_t ret = ERROR;
for (auto iter : listStateCallback_) {
if (iter.imsSrvType == imsSrvType) {
UpdateImsStateInfo(iter, info);
ret = SUCCESS;
} else {
TELEPHONY_LOGE("%{public}d type is null!", imsSrvType);
ret = ERROR;
}
}
if (ret == ERROR) {
TELEPHONY_LOGE("%{public}d type is null!", imsSrvType);
}
return ret;
}
int32_t NapiImsCallbackManager::UpdateImsStateInfo(ImsStateCallback stateCallback, const ImsRegInfo &info)
int32_t NapiImsCallbackManager::UpdateImsStateInfo(const ImsStateCallback &stateCallback, const ImsRegInfo &info)
{
if (stateCallback.thisVar == nullptr) {
TELEPHONY_LOGE("stateCallback is null!");
@ -111,21 +114,13 @@ int32_t NapiImsCallbackManager::UpdateImsStateInfo(ImsStateCallback stateCallbac
#if NAPI_VERSION >= 2
napi_get_uv_event_loop(stateCallback.env, &loop);
#endif
ImsStateWorker *dataWorker = std::make_unique<ImsStateWorker>().release();
if (dataWorker == nullptr) {
TELEPHONY_LOGE("dataWorker is nullptr!");
return ERROR;
}
dataWorker->info = info;
dataWorker->callback = stateCallback;
uv_work_t *work = std::make_unique<uv_work_t>().release();
if (work == nullptr) {
TELEPHONY_LOGE("work is nullptr!");
return ERROR;
}
work->data = (void *)dataWorker;
ImsStateWorker dataWorker;
dataWorker.info = info;
dataWorker.callback = stateCallback;
uv_work_t work;
work.data = (void*)(&dataWorker);
uv_queue_work(
loop, work, [](uv_work_t *work) {}, ReportImsStateWork);
loop, &work, [](uv_work_t *work) {}, ReportImsStateWork);
return SUCCESS;
}
@ -134,6 +129,8 @@ void NapiImsCallbackManager::ReportImsStateWork(uv_work_t *work, int32_t status)
ImsStateWorker *dataWorkerData = (ImsStateWorker *)work->data;
if (dataWorkerData == nullptr) {
TELEPHONY_LOGE("dataWorkerData is nullptr!");
delete work;
work = nullptr;
return;
}
int32_t ret = ReportImsState(dataWorkerData->info, dataWorkerData->callback);
@ -143,7 +140,8 @@ void NapiImsCallbackManager::ReportImsStateWork(uv_work_t *work, int32_t status)
delete work;
work = nullptr;
}
int32_t NapiImsCallbackManager::ReportImsState(ImsRegInfo &info, ImsStateCallback stateCallback)
int32_t NapiImsCallbackManager::ReportImsState(const ImsRegInfo &info, const ImsStateCallback &stateCallback)
{
napi_value callbackFunc = nullptr;
napi_env env = stateCallback.env;
@ -154,11 +152,11 @@ int32_t NapiImsCallbackManager::ReportImsState(ImsRegInfo &info, ImsStateCallbac
NapiUtil::SetPropertyInt32(
env, callbackValues[0], "imsRegTech", static_cast<int32_t>(info.imsRegTech));
napi_get_reference_value(env, stateCallback.callbackRef, &callbackFunc);
napi_value callbackResult = nullptr;
if (callbackFunc == nullptr) {
TELEPHONY_LOGE("callbackFunc is null!");
return ERROR;
}
napi_value callbackResult = nullptr;
napi_call_function(env, stateCallback.thisVar, callbackFunc, 1, callbackValues, &callbackResult);
return SUCCESS;
}

View File

@ -18,8 +18,9 @@
namespace OHOS {
namespace Telephony {
NapiImsSmsCallback::NapiImsSmsCallback(ImsRegInfo info) : info_(info)
NapiImsSmsCallback::NapiImsSmsCallback(const ImsRegInfo &info) : info_(info)
{}
void NapiImsSmsCallback::OnImsSmsStateChange(const ImsRegInfo &info)
{
info_ = info;

View File

@ -18,8 +18,9 @@
namespace OHOS {
namespace Telephony {
NapiImsUtCallback::NapiImsUtCallback(ImsRegInfo info) : info_(info)
NapiImsUtCallback::NapiImsUtCallback(const ImsRegInfo &info) : info_(info)
{}
void NapiImsUtCallback::OnImsUtStateChange(const ImsRegInfo &info)
{
info_ = info;

View File

@ -18,8 +18,9 @@
namespace OHOS {
namespace Telephony {
NapiImsVideoCallback::NapiImsVideoCallback(ImsRegInfo info) : info_(info)
NapiImsVideoCallback::NapiImsVideoCallback(const ImsRegInfo &info) : info_(info)
{}
void NapiImsVideoCallback::OnImsVideoStateChange(const ImsRegInfo &info)
{
info_ = info;

View File

@ -18,11 +18,12 @@
namespace OHOS {
namespace Telephony {
NapiImsVoiceCallback::NapiImsVoiceCallback(ImsRegInfo info) : info_(info)
NapiImsVoiceCallback::NapiImsVoiceCallback(const ImsRegInfo &info) : info_(info)
{}
void NapiImsVoiceCallback::OnImsVoiceStateChange(const ImsRegInfo &info)
{
TELEPHONY_LOGE("NapiImsVoiceCallback Enter!");
TELEPHONY_LOGI("NapiImsVoiceCallback Enter!");
info_ = info;
int32_t ret = DelayedSingleton<NapiImsCallbackManager>::GetInstance()->
UpdateImsState(ImsServiceType::TYPE_VOICE, info);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -1947,37 +1947,36 @@ static napi_value GetImsRegInfo(napi_env env, napi_callback_info info)
env, asyncContext.release(), "GetImsRegInfo", NativeGetImsRegInfo, GetImsRegInfoCallback);
}
void RegImsCallback(napi_env env, napi_value thisVar, int32_t slotId, int32_t imsSrvType, napi_value argv[])
static void RegImsCallback(napi_env env, napi_value thisVar, int32_t slotId, int32_t imsSrvType, napi_value argv[])
{
int32_t ret = ERROR;
ImsStateCallback imsStateCallback;
ImsRegInfo imsRegInfo = ERROR_IMS_REG_INFO;
(void)memset_s(&imsStateCallback, sizeof(ImsStateCallback), 0, sizeof(ImsStateCallback));
imsStateCallback.env = env;
imsStateCallback.thisVar = thisVar;
imsStateCallback.slotId = slotId;
imsStateCallback.imsSrvType = static_cast<ImsServiceType>(imsSrvType);
switch (static_cast<ImsServiceType>(imsSrvType)) {
case ImsServiceType::TYPE_VOICE:
imsStateCallback.voiceCallback = std::make_unique<NapiImsVoiceCallback>(imsRegInfo).release();
imsStateCallback.voiceCallback = new NapiImsVoiceCallback(imsRegInfo);
ret = DelayedRefSingleton<CoreServiceClient>::GetInstance()
.RegImsVoiceCallback(slotId, imsStateCallback.voiceCallback);
break;
case ImsServiceType::TYPE_VIDEO:
imsStateCallback.videoCallback = std::make_unique<NapiImsVideoCallback>(imsRegInfo).release();
imsStateCallback.videoCallback = new NapiImsVideoCallback(imsRegInfo);
ret = DelayedRefSingleton<CoreServiceClient>::GetInstance()
.RegImsVideoCallback(slotId, imsStateCallback.videoCallback);
break;
case ImsServiceType::TYPE_UT:
imsStateCallback.utCallback = std::make_unique<NapiImsUtCallback>(imsRegInfo).release();
imsStateCallback.utCallback = new NapiImsUtCallback(imsRegInfo);
ret = DelayedRefSingleton<CoreServiceClient>::GetInstance()
.RegImsUtCallback(slotId, imsStateCallback.utCallback);
break;
case ImsServiceType::TYPE_SMS:
imsStateCallback.smsCallback = std::make_unique<NapiImsSmsCallback>(imsRegInfo).release();
imsStateCallback.smsCallback = new NapiImsSmsCallback(imsRegInfo);
ret = DelayedRefSingleton<CoreServiceClient>::GetInstance()
.RegImsSmsCallback(slotId, imsStateCallback.smsCallback);
break;
break;
default:
ret = ERROR;
TELEPHONY_LOGE("ImsServiceType Error!");
@ -1992,18 +1991,32 @@ void RegImsCallback(napi_env env, napi_value thisVar, int32_t slotId, int32_t im
}
}
napi_value ObserverOn(napi_env env, napi_callback_info info)
static napi_value ObserverOn(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value result = nullptr;
napi_value argv[4];
napi_value thisVar;
char callbackType[INFO_MAXIMUM_LIMIT + 1];
int32_t slotId;
int32_t imsSrvType;
napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL);
napi_get_value_string_utf8(env, argv[ARRAY_INDEX_FIRST], callbackType, INFO_MAXIMUM_LIMIT, NULL);
napi_get_value_int32(env, argv[ARRAY_INDEX_SECOND], &slotId);
napi_get_value_int32(env, argv[ARRAY_INDEX_THIRD], &imsSrvType);
if (napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get thisVar value");
return result;
}
if (napi_get_value_string_utf8(env, argv[ARRAY_INDEX_FIRST],
callbackType, INFO_MAXIMUM_LIMIT, NULL) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get callbackType value");
return result;
}
if (napi_get_value_int32(env, argv[ARRAY_INDEX_SECOND], &slotId) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get slotId value");
return result;
}
if (napi_get_value_int32(env, argv[ARRAY_INDEX_THIRD], &imsSrvType) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get imsSrvType value");
return result;
}
bool matchFlag = NapiUtil::MatchValueType(env, argv[ARRAY_INDEX_FIRST], napi_string);
NAPI_ASSERT(env, matchFlag, "Type error, should be string type");
std::string tmpStr = callbackType;
@ -2011,22 +2024,35 @@ napi_value ObserverOn(napi_env env, napi_callback_info info)
if (tmpStr.compare("imsRegStateChange") == 0) {
RegImsCallback(env, thisVar, slotId, imsSrvType, argv);
}
napi_value result = nullptr;
return result;
}
napi_value ObserverOff(napi_env env, napi_callback_info info)
static napi_value ObserverOff(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value result = nullptr;
napi_value argv[4];
napi_value thisVar;
char callbackType[INFO_MAXIMUM_LIMIT + 1];
int32_t slotId;
int32_t imsSrvType;
napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL);
napi_get_value_string_utf8(env, argv[ARRAY_INDEX_FIRST], callbackType, INFO_MAXIMUM_LIMIT, NULL);
napi_get_value_int32(env, argv[ARRAY_INDEX_SECOND], &slotId);
napi_get_value_int32(env, argv[ARRAY_INDEX_THIRD], &imsSrvType);
if (napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get thisVar value");
return result;
}
if (napi_get_value_string_utf8(env, argv[ARRAY_INDEX_FIRST],
callbackType, INFO_MAXIMUM_LIMIT, NULL) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get callbackType value");
return result;
}
if (napi_get_value_int32(env, argv[ARRAY_INDEX_SECOND], &slotId) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get slotId value");
return result;
}
if (napi_get_value_int32(env, argv[ARRAY_INDEX_THIRD], &imsSrvType) != napi_ok) {
TELEPHONY_LOGE("ObserverOn Can not get imsSrvType value");
return result;
}
std::string tmpStr = callbackType;
bool matchFlag = NapiUtil::MatchValueType(env, argv[ARRAY_INDEX_FIRST], napi_string);
NAPI_ASSERT(env, matchFlag, "Type error, should be string type");
@ -2037,10 +2063,9 @@ napi_value ObserverOff(napi_env env, napi_callback_info info)
UnRegImsStateCallback(env, slotId, static_cast<ImsServiceType>(imsSrvType));
} else if (argc == THREE_PARAMETERS) {
DelayedSingleton<NapiImsCallbackManager>::GetInstance()->
UnRegAllImsStateCallbackOfType(env, slotId, static_cast<ImsServiceType>(imsSrvType));
UnRegAllImsStateCallbackOfType(slotId, static_cast<ImsServiceType>(imsSrvType));
}
}
napi_value result = nullptr;
return result;
}

View File

@ -42,7 +42,7 @@ ohos_shared_library("sim") {
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -1929,11 +1929,12 @@ ImsRegInfo CoreServiceProxy::GetImsRegStatus(int32_t slotId, ImsServiceType imsS
TELEPHONY_LOGE("GetImsRegStatus WriteInt32 imsSrvType is false");
return ERROR_IMS_REG_INFO;
}
if (Remote() == nullptr) {
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TELEPHONY_LOGE("GetImsRegStatus Remote is null");
return ERROR_IMS_REG_INFO;
}
int32_t st = Remote()->SendRequest(uint32_t(InterfaceID::GET_IMS_REG_STATUS), data, reply, option);
int32_t st = remote->SendRequest(uint32_t(InterfaceID::GET_IMS_REG_STATUS), data, reply, option);
if (st != ERR_NONE) {
TELEPHONY_LOGE("GetImsRegStatus failed, error code is %{public}d \n", st);
return ERROR_IMS_REG_INFO;
@ -2108,14 +2109,14 @@ int32_t CoreServiceProxy::RegImsCallback(MessageParcel &idata)
int32_t slotId = idata.ReadInt32();
sptr<IRemoteObject> callback = idata.ReadRemoteObject();
TELEPHONY_LOGI("imsSrvType is %{public}d, slotId is %{public}d", imsSrvType, slotId);
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("RegisterCallBack WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
if (callback == nullptr) {
TELEPHONY_LOGE("CoreServiceProxy::RegImsCallback is nullptr");
return ERROR;
}
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("RegisterCallBack WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
if (!data.WriteInt32(imsSrvType)) {
TELEPHONY_LOGE("WriteInt32 ERROR");
return ERROR;
@ -2128,7 +2129,11 @@ int32_t CoreServiceProxy::RegImsCallback(MessageParcel &idata)
TELEPHONY_LOGE("WriteRemoteObject ERROR");
return ERROR;
}
int32_t error = Remote()->SendRequest(static_cast<uint32_t>(InterfaceID::REG_IMS_CALLBACK), data, reply, option);
sptr<OHOS::IRemoteObject> remote = Remote();
if (remote == nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t error = remote->SendRequest(static_cast<uint32_t>(InterfaceID::REG_IMS_CALLBACK), data, reply, option);
if (error != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("Function RegisterCallBack! errCode:%{public}d", error);
return error;
@ -2144,17 +2149,21 @@ int32_t CoreServiceProxy::UnRegImsCallback(MessageParcel &idata)
int32_t imsSrvType = idata.ReadInt32();
int32_t slotId = idata.ReadInt32();
sptr<IRemoteObject> callback = idata.ReadRemoteObject();
if (callback == nullptr) {
TELEPHONY_LOGE("CoreServiceProxy::RegImsCallback is nullptr");
}
if (!WriteInterfaceToken(data)) {
TELEPHONY_LOGE("RegisterCallBack WriteInterfaceToken is false");
return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
}
if (callback == nullptr) {
TELEPHONY_LOGE("CoreServiceProxy::RegImsCallback is nullptr");
}
data.WriteInt32(imsSrvType);
data.WriteInt32(slotId);
data.WriteRemoteObject(callback);
int32_t error = Remote()->SendRequest(static_cast<uint32_t>(InterfaceID::UN_REG_IMS_CALLBACK), data, reply, option);
sptr<OHOS::IRemoteObject> remote = Remote();
if (remote == nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t error = remote->SendRequest(static_cast<uint32_t>(InterfaceID::UN_REG_IMS_CALLBACK), data, reply, option);
if (error != TELEPHONY_SUCCESS) {
TELEPHONY_LOGE("Function UnRegImsCallback! errCode:%{public}d", error);
return error;

26
hisysevent.yaml Normal file
View File

@ -0,0 +1,26 @@
# Copyright (c) 2022 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.
domain: CORE_SERVICE
SIGNAL_LEVEL:
__BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: signal level}
SLOT_ID: {type: INT32, desc: slot id}
LEVEL: {type: INT32, desc: signal strength level}
NETWORK_REGISTER:
__BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: network register}
SLOT_ID: {type: INT32, desc: slot id}
REGISTRATION_DOMAIN: {type: INT32, desc: network domain type}
RADIO_TECH: {type: INT32, desc: radio technology}
REGISTRATION_STATE: {type: INT32, desc: network registration state}

View File

@ -77,7 +77,7 @@ ohos_shared_library("tel_core_service_api") {
external_deps = [
"eventhandler:libeventhandler",
"ipc:ipc_core",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",
"utils_base:utils",

View File

@ -285,6 +285,11 @@ public:
int32_t slotId, ApduSimIORequestInfo reqInfo, const AppExecFwk::InnerEvent::Pointer &response) = 0;
virtual int32_t SimAuthentication(
int32_t slotId, SimAuthenticationRequestInfo reqInfo, const AppExecFwk::InnerEvent::Pointer &response) = 0;
virtual int32_t SetNotificationFilter(
int32_t slotId, int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response) = 0;
virtual int32_t SetDeviceState(int32_t slotId, int32_t deviceStateType, bool deviceStateOn,
const AppExecFwk::InnerEvent::Pointer &response) = 0;
};
} // namespace Telephony
} // namespace OHOS

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2022 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

View File

@ -22,7 +22,6 @@ namespace OHOS {
namespace Telephony {
class ImsSmsCallback : public ImsManagerCallback {
public:
~ImsSmsCallback() = default;
virtual int32_t OnImsStateCallback(const ImsRegInfo &info) = 0;
};
} // namespace Telephony

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2022 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

View File

@ -22,7 +22,6 @@ namespace OHOS {
namespace Telephony {
class ImsUtCallback : public ImsManagerCallback {
public:
~ImsUtCallback() = default;
virtual int32_t OnImsStateCallback(const ImsRegInfo &info) = 0;
};
} // namespace Telephony

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2022 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

View File

@ -22,7 +22,6 @@ namespace OHOS {
namespace Telephony {
class ImsVideoCallback : public ImsManagerCallback {
public:
~ImsVideoCallback() = default;
virtual int32_t OnImsStateCallback(const ImsRegInfo &info) = 0;
};
} // namespace Telephony

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2022 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

View File

@ -22,7 +22,6 @@ namespace OHOS {
namespace Telephony {
class ImsVoiceCallback : public ImsManagerCallback {
public:
~ImsVoiceCallback() = default;
virtual int32_t OnImsStateCallback(const ImsRegInfo &info) = 0;
};
} // namespace Telephony

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2022 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

View File

@ -131,6 +131,8 @@ enum RadioEvent {
RADIO_SET_LOCATION_UPDATE,
RADIO_CURRENT_CELL_UPDATE,
RADIO_SET_DATA_CONNECT_ACTIVE,
RADIO_SET_DEVICE_STATE,
RADIO_SET_NOTIFICATION_FILTER,
// module internal events
RADIO_PS_CONNECTION_ATTACHED = 401,

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -861,7 +861,7 @@ bool CoreService::HasOperatorPrivileges(const int32_t slotId)
int32_t CoreService::RegImsCallback(MessageParcel &data)
{
if (networkSearchManager_ == nullptr) {
return false;
return ERROR;
}
return networkSearchManager_->RegImsCallback(data);
}
@ -869,7 +869,7 @@ int32_t CoreService::RegImsCallback(MessageParcel &data)
int32_t CoreService::UnRegImsCallback(MessageParcel &data)
{
if (networkSearchManager_ == nullptr) {
return false;
return ERROR;
}
return networkSearchManager_->UnRegImsCallback(data);
}

View File

@ -41,7 +41,11 @@ int32_t ImsCoreServiceCallbackProxy::UpdateImsServiceStatusChanged(
TELEPHONY_LOGE("write imsServiceStatus fail!");
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
int32_t error = Remote()->SendRequest(IMS_SERVICE_STATUS_REPORT, in, out, option);
sptr<IRemoteObject> remote = Remote();
if (remote== nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t error = remote->SendRequest(IMS_SERVICE_STATUS_REPORT, in, out, option);
if (error == ERR_NONE) {
TELEPHONY_LOGE("send imsServiceStatus fail!");
return out.ReadInt32();
@ -67,7 +71,11 @@ int32_t ImsCoreServiceCallbackProxy::GetImsRegistrationStatusResponse(
TELEPHONY_LOGE("write imsRegStatus fail!");
return TELEPHONY_ERR_WRITE_DATA_FAIL;
}
int32_t error = Remote()->SendRequest(IMS_GET_REGISTRATION_STATUS, in, out, option);
sptr<IRemoteObject> remote = Remote();
if (remote== nullptr) {
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
int32_t error = remote->SendRequest(IMS_GET_REGISTRATION_STATUS, in, out, option);
if (error == ERR_NONE) {
return out.ReadInt32();
}

View File

@ -76,6 +76,7 @@ int32_t ImsCoreServiceCallbackStub::OnImsServiceStatusReportInner(MessageParcel
int32_t ImsCoreServiceCallbackStub::UpdateImsServiceStatusChanged(
int32_t slotId, const ImsServiceStatus &imsServiceStatus)
{
TELEPHONY_LOGI("ImsCoreServiceCallbackStub::UpdateImsServiceStatusChanged entry");
std::shared_ptr<ImsCoreServiceClient> imsCoreServiceClient = DelayedSingleton<ImsCoreServiceClient>::GetInstance();
std::unique_ptr<ImsServiceStatus> info = std::make_unique<ImsServiceStatus>();
if (info.get() == nullptr) {
@ -86,7 +87,6 @@ int32_t ImsCoreServiceCallbackStub::UpdateImsServiceStatusChanged(
*info = imsServiceStatus;
imsCoreServiceClient->GetHandler(slotId)->SendEvent(
ImsCoreServiceInterface::IMS_SERVICE_STATUS_UPDATE, std::move(info));
TELEPHONY_LOGI("ImsCoreServiceCallbackStub::UpdateImsServiceStatusChanged entry");
return TELEPHONY_SUCCESS;
}
@ -106,11 +106,11 @@ int32_t ImsCoreServiceCallbackStub::OnGetImsRegistrationStatusResponseInner(Mess
int32_t ImsCoreServiceCallbackStub::GetImsRegistrationStatusResponse(
int32_t slotId, const ImsRegistrationStatus &imsRegStatus)
{
TELEPHONY_LOGI("ImsCoreServiceCallbackStub::GetImsRegistrationStatusResponse entry");
std::shared_ptr<ImsCoreServiceClient> imsCoreServiceClient = DelayedSingleton<ImsCoreServiceClient>::GetInstance();
int32_t isRegisterd = imsRegStatus.isRegisterd ? 1 : 0;
imsCoreServiceClient->GetHandler(slotId)->SendEvent(
ImsCoreServiceInterface::IMS_REGISTER_STATE_UPDATE, isRegisterd);
TELEPHONY_LOGI("ImsCoreServiceCallbackStub::GetImsRegistrationStatusResponse entry");
return TELEPHONY_SUCCESS;
}
} // namespace Telephony

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2022 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 NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H
#define NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H
#include <memory>
#include "i_tel_ril_manager.h"
namespace OHOS {
namespace Telephony {
class NetworkSearchManager;
class DeviceStateHandler {
public:
DeviceStateHandler(const std::weak_ptr<NetworkSearchManager> &networkSearchManager,
const std::weak_ptr<ITelRilManager> &telRilManager, int32_t slotId);
virtual ~DeviceStateHandler() = default;
void ProcessWifiState(bool isWifiConnected);
void ProcessScreenDisplay(bool isScreenOn);
void ProcessPowerSaveMode(bool isPowerSaveModeOn);
void ProcessChargingState(bool isCharging);
void ProcessNetSharingState(bool isNetSharingOn);
void ProcessRadioState();
private:
uint32_t GetCellRequestMinInterval() const;
bool IsHighPowerConsumption() const;
bool IsSignalStrengthNotificationExpected() const;
void SetCellRequestMinInterval(uint32_t minInterval) const;
void ProcessDeviceState();
void SetNotificationFilter(int32_t newFilter, bool force);
void SetDeviceState(int32_t deviceStateType, bool deviceStateOn);
void SyncSettings();
private:
std::weak_ptr<NetworkSearchManager> networkSearchManager_;
std::weak_ptr<ITelRilManager> telRilManager_;
int32_t slotId_ = 0;
int32_t notificationFilter_ = 0;
uint32_t cellRequestMinInterval_ = 2;
bool isWifiConnected_ = false;
bool isLowData_ = false;
bool isPowerSaveModeOn_ = false;
bool isCharging_ = false;
bool isScreenOn_ = false;
bool isNetSharingOn_ = false;
};
} // namespace Telephony
} // namespace OHOS
#endif // NETWORK_SEARCH_INCLUDE_DEVICE_STATE_HANDLER_H

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2022 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 NETWORK_SEARCH_DEVICE_STATE_OBSERVER_H
#define NETWORK_SEARCH_DEVICE_STATE_OBSERVER_H
#include "common_event_subscriber.h"
#include "common_event_support.h"
#include "common_event_manager.h"
#include "device_state_handler.h"
#include "net_all_capabilities.h"
#include "net_supplier_info.h"
namespace OHOS {
namespace Telephony {
using CommonEventData = OHOS::EventFwk::CommonEventData;
using CommonEventManager = OHOS::EventFwk::CommonEventManager;
using CommonEventSubscribeInfo = OHOS::EventFwk::CommonEventSubscribeInfo;
using CommonEventSubscriber = OHOS::EventFwk::CommonEventSubscriber;
using CommonEventSupport = OHOS::EventFwk::CommonEventSupport;
using MatchingSkills = OHOS::EventFwk::MatchingSkills;
using NetBearType = OHOS::NetManagerStandard::NetBearType;
using NetConnState = OHOS::NetManagerStandard::NetConnState;
enum DeviceStateEventIntValue {
COMMON_EVENT_CONNECTIVITY_CHANGE,
COMMON_EVENT_SCREEN_ON,
COMMON_EVENT_SCREEN_OFF,
COMMON_EVENT_POWER_SAVE_MODE_CHANGED,
COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED,
COMMON_EVENT_CHARGING,
COMMON_EVENT_DISCHARGING,
COMMON_EVENT_WIFI_HOTSPOT_STATE,
COMMON_EVENT_WIFI_AP_STA_JOIN,
COMMON_EVENT_WIFI_AP_STA_LEAVE,
COMMON_EVENT_UNKNOWN,
};
class DeviceStateEventSubscriber : public CommonEventSubscriber {
public:
explicit DeviceStateEventSubscriber(const CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {}
~DeviceStateEventSubscriber() = default;
void OnReceiveEvent(const CommonEventData &data) override;
void SetEventHandler(const std::shared_ptr<DeviceStateHandler> &deviceStateHandler);
void InitEventMap();
private:
DeviceStateEventIntValue GetDeviceStateEventIntValue(std::string &event) const;
private:
std::shared_ptr<DeviceStateHandler> deviceStateHandler_;
std::map<std::string, DeviceStateEventIntValue> deviceStateEventMapIntValues_;
};
class DeviceStateObserver {
public:
DeviceStateObserver() = default;
~DeviceStateObserver() = default;
void StartEventSubscriber(const std::shared_ptr<DeviceStateHandler> &deviceStateHandler);
void StopEventSubscriber();
private:
std::shared_ptr<DeviceStateEventSubscriber> subscriber_;
};
} // namespace Telephony
} // namespace OHOS
#endif // NETWORK_SEARCH_DEVICE_STATE_OBSERVER_H

View File

@ -87,6 +87,7 @@ public:
void UpdateCellLocation(int32_t techType, int32_t cellId, int32_t lac);
sptr<CellLocation> GetCellLocation();
void TimezoneRefresh();
void SetCellRequestMinInterval(uint32_t minInterval);
private:
void RadioOnState();
@ -123,6 +124,7 @@ private:
void AutoTimeChange(const AppExecFwk::InnerEvent::Pointer &);
void AutoTimeZoneChange(const AppExecFwk::InnerEvent::Pointer &);
void AirplaneModeChange(const AppExecFwk::InnerEvent::Pointer &);
private:
std::weak_ptr<NetworkSearchManager> networkSearchManager_;
std::unique_ptr<NetworkRegister> networkRegister_ = nullptr;
@ -142,6 +144,8 @@ private:
int64_t lastTimeCsRegistrationReq_ = 0;
bool firstInit_ = true;
int32_t slotId_ = 0;
uint32_t cellRequestMinInterval_ = 2; // This is the minimum interval in seconds for cell requests
uint32_t lastCellRequestTime_ = 0;
};
} // namespace Telephony
} // namespace OHOS

View File

@ -37,6 +37,8 @@
#include "radio_event.h"
#include "setting_utils.h"
#include "iremote_stub.h"
#include "device_state_handler.h"
#include "device_state_observer.h"
namespace OHOS {
namespace Telephony {
@ -53,6 +55,8 @@ struct NetworkSearchManagerInner {
std::shared_ptr<NetworkSearchHandler> networkSearchHandler_ = nullptr;
std::shared_ptr<AppExecFwk::EventRunner> eventLoop_ = nullptr;
std::unique_ptr<ObserverHandler> observerHandler_ = nullptr;
std::shared_ptr<DeviceStateHandler> deviceStateHandler_ = nullptr;
std::shared_ptr<DeviceStateObserver> deviceStateObserver_ = nullptr;
sptr<AutoTimeObserver> settingAutoTimeObserver_;
sptr<AutoTimezoneObserver> settingAutoTimezoneObserver_;
sptr<AirplaneModeObserver> airplaneModeObserver_;
@ -70,6 +74,8 @@ struct NetworkSearchManagerInner {
bool RegisterSetting();
bool UnRegisterSetting();
bool RegisterDeviceStateObserver();
bool UnRegisterDeviceStateObserver();
bool Init()
{
radioCapability_.ratFamily = DEFAULT_RAF;
@ -86,6 +92,11 @@ struct NetworkSearchManagerInner {
return false;
}
}
if (deviceStateHandler_ != nullptr) {
if (!RegisterDeviceStateObserver()) {
return false;
}
}
if (eventLoop_ != nullptr) {
eventLoop_->Run();
}

View File

@ -0,0 +1,177 @@
/*
* Copyright (C) 2022 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 "device_state_handler.h"
#include "network_search_manager.h"
#include "telephony_log_wrapper.h"
namespace OHOS {
namespace Telephony {
const uint32_t CELL_REQUEST_SHORT_INTERVAL = 2; // This is the minimum interval in seconds for cell requests
const uint32_t CELL_REQUEST_LONG_INTERVAL = 10; // This is the maximum interval in seconds for cell requests
DeviceStateHandler::DeviceStateHandler(
const std::weak_ptr<NetworkSearchManager> &networkSearchManager,
const std::weak_ptr<ITelRilManager> &telRilManager, int32_t slotId)
: networkSearchManager_(networkSearchManager), telRilManager_(telRilManager), slotId_(slotId)
{}
void DeviceStateHandler::ProcessWifiState(bool isWifiConnected)
{
isWifiConnected_ = isWifiConnected;
ProcessDeviceState();
}
void DeviceStateHandler::ProcessScreenDisplay(bool isScreenOn)
{
isScreenOn_ = isScreenOn;
ProcessDeviceState();
}
void DeviceStateHandler::ProcessPowerSaveMode(bool isPowerSaveModeOn)
{
isPowerSaveModeOn_ = isPowerSaveModeOn;
SetDeviceState(POWER_SAVE_MODE, isPowerSaveModeOn_);
ProcessDeviceState();
}
void DeviceStateHandler::ProcessChargingState(bool isCharging)
{
isCharging_ = isCharging;
SetDeviceState(CHARGING_STATE, isCharging_);
ProcessDeviceState();
}
void DeviceStateHandler::ProcessNetSharingState(bool isNetSharingOn)
{
isNetSharingOn_ = isNetSharingOn;
ProcessDeviceState();
}
void DeviceStateHandler::ProcessRadioState()
{
SyncSettings();
}
void DeviceStateHandler::ProcessDeviceState()
{
uint32_t newCellRequestMinInterval = GetCellRequestMinInterval();
if (cellRequestMinInterval_ != newCellRequestMinInterval) {
cellRequestMinInterval_ = newCellRequestMinInterval;
SetCellRequestMinInterval(cellRequestMinInterval_);
}
if (isLowData_ != !IsHighPowerConsumption()) {
isLowData_ = !isLowData_;
SetDeviceState(LOW_DATA_STATE, isLowData_);
}
int32_t newFilter = NOTIFICATION_FILTER_NONE;
if (IsSignalStrengthNotificationExpected()) {
newFilter |= NOTIFICATION_FILTER_SIGNAL_STRENGTH;
}
if (IsHighPowerConsumption()) {
newFilter |= NOTIFICATION_FILTER_NETWORK_STATE;
newFilter |= NOTIFICATION_FILTER_DATA_CALL;
newFilter |= NOTIFICATION_FILTER_PHYSICAL_CHANNEL_CONFIG;
}
SetNotificationFilter(newFilter, false);
}
bool DeviceStateHandler::IsSignalStrengthNotificationExpected() const
{
return isCharging_ || isScreenOn_;
}
bool DeviceStateHandler::IsHighPowerConsumption() const
{
return isCharging_ || isScreenOn_ || isNetSharingOn_;
}
uint32_t DeviceStateHandler::GetCellRequestMinInterval() const
{
if (isScreenOn_ && (!isWifiConnected_ || isCharging_)) {
return CELL_REQUEST_SHORT_INTERVAL;
} else {
return CELL_REQUEST_LONG_INTERVAL;
}
}
void DeviceStateHandler::SetCellRequestMinInterval(uint32_t minInterval) const
{
std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
if (nsm == nullptr) {
return;
}
auto inner = nsm->FindManagerInner(slotId_);
if (inner == nullptr) {
return;
}
if (inner->networkSearchHandler_ != nullptr) {
TELEPHONY_LOGI("DeviceStateHandler::SetCellRequestMinInterval %{public}d", minInterval);
inner->networkSearchHandler_->SetCellRequestMinInterval(minInterval);
}
}
void DeviceStateHandler::SetNotificationFilter(int32_t newFilter, bool force)
{
if (!force && newFilter == notificationFilter_) {
TELEPHONY_LOGE("DeviceStateHandler::SetNotificationFilter is not necessary");
return;
}
auto event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_NOTIFICATION_FILTER);
if (event == nullptr) {
TELEPHONY_LOGE("DeviceStateHandler::SetNotificationFilter event is null");
return;
}
std::shared_ptr<ITelRilManager> telRilManager = telRilManager_.lock();
if (telRilManager != nullptr) {
TELEPHONY_LOGI("DeviceStateHandler::SetNotificationFilter old filter:%{public}d, new filter:%{public}d",
notificationFilter_, newFilter);
telRilManager->SetNotificationFilter(slotId_, newFilter, event);
notificationFilter_ = newFilter;
}
}
void DeviceStateHandler::SetDeviceState(int32_t deviceStateType, bool deviceStateOn)
{
auto event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_DEVICE_STATE);
if (event == nullptr) {
TELEPHONY_LOGE("DeviceStateHandler::SetDeviceState event is null");
return;
}
std::shared_ptr<ITelRilManager> telRilManager = telRilManager_.lock();
if (telRilManager != nullptr) {
TELEPHONY_LOGI("DeviceStateHandler::SetDeviceState type:%{public}d state:%{public}d",
deviceStateType, deviceStateOn);
telRilManager->SetDeviceState(slotId_, deviceStateType, deviceStateOn, event);
}
}
void DeviceStateHandler::SyncSettings()
{
TELEPHONY_LOGI("DeviceStateHandler::SyncSettings isCharging_=%{public}d, isLowData_=%{public}d,"
" isPowerSaveModeOn_=%{public}d, notificationFilter_=%{public}d",
isCharging_, isLowData_, isPowerSaveModeOn_, notificationFilter_);
SetDeviceState(CHARGING_STATE, isCharging_);
SetDeviceState(LOW_DATA_STATE, isLowData_);
SetDeviceState(POWER_SAVE_MODE, isPowerSaveModeOn_);
SetNotificationFilter(notificationFilter_, true);
}
} // namespace Telephony
} // namespace OHOS

View File

@ -0,0 +1,130 @@
/*
* Copyright (C) 2022 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 "device_state_observer.h"
#include "telephony_log_wrapper.h"
namespace OHOS {
namespace Telephony {
const std::string NET_TYPE = "NetType";
void DeviceStateObserver::StartEventSubscriber(const std::shared_ptr<DeviceStateHandler> &deviceStateHandler)
{
MatchingSkills matchingSkills;
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_CONNECTIVITY_CHANGE);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_SCREEN_ON);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_SCREEN_OFF);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_POWER_SAVE_MODE_CHANGED);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_CHARGING);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_DISCHARGING);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_WIFI_HOTSPOT_STATE);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_WIFI_AP_STA_JOIN);
matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_WIFI_AP_STA_LEAVE);
CommonEventSubscribeInfo subscriberInfo(matchingSkills);
subscriber_ = std::make_shared<DeviceStateEventSubscriber>(subscriberInfo);
subscriber_->SetEventHandler(deviceStateHandler);
subscriber_->InitEventMap();
bool subscribeResult = CommonEventManager::SubscribeCommonEvent(subscriber_);
TELEPHONY_LOGI("DeviceStateObserver::StartEventSubscriber subscribeResult = %{public}d", subscribeResult);
}
void DeviceStateObserver::StopEventSubscriber()
{
if (subscriber_ == nullptr) {
TELEPHONY_LOGE("DeviceStateObserver::StopEventSubscriber subscriber_ is nullptr");
return;
}
bool subscribeResult = CommonEventManager::UnSubscribeCommonEvent(subscriber_);
subscriber_ = nullptr;
TELEPHONY_LOGI("DeviceStateObserver::StopEventSubscriber subscribeResult = %{public}d", subscribeResult);
}
void DeviceStateEventSubscriber::OnReceiveEvent(const CommonEventData &data)
{
if (deviceStateHandler_ == nullptr) {
TELEPHONY_LOGE("DeviceStateEventSubscriber::OnReceiveEvent: networkSearchHandler_ is nullptr");
return;
}
std::string action = data.GetWant().GetAction();
TELEPHONY_LOGI("DeviceStateEventSubscriber::OnReceiveEvent: action = %{public}s", action.c_str());
switch (GetDeviceStateEventIntValue(action)) {
case COMMON_EVENT_CONNECTIVITY_CHANGE:
if (data.GetWant().GetIntParam(NET_TYPE, NetBearType::BEARER_DEFAULT) == NetBearType::BEARER_WIFI) {
bool isWifiConnected = data.GetCode() == NetConnState::NET_CONN_STATE_CONNECTED;
deviceStateHandler_->ProcessWifiState(isWifiConnected);
TELEPHONY_LOGI("DeviceStateEventSubscriber:: wifi %{public}s",
isWifiConnected ? "connected" : "no connected");
}
break;
case COMMON_EVENT_SCREEN_ON:
deviceStateHandler_->ProcessScreenDisplay(true);
break;
case COMMON_EVENT_SCREEN_OFF:
deviceStateHandler_->ProcessScreenDisplay(false);
break;
case COMMON_EVENT_POWER_SAVE_MODE_CHANGED:
deviceStateHandler_->ProcessPowerSaveMode(true);
break;
case COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED:
deviceStateHandler_->ProcessPowerSaveMode(false);
break;
case COMMON_EVENT_CHARGING:
deviceStateHandler_->ProcessChargingState(true);
break;
case COMMON_EVENT_DISCHARGING:
deviceStateHandler_->ProcessChargingState(false);
break;
case COMMON_EVENT_WIFI_HOTSPOT_STATE:
case COMMON_EVENT_WIFI_AP_STA_JOIN:
case COMMON_EVENT_WIFI_AP_STA_LEAVE:
break;
default:
break;
}
}
void DeviceStateEventSubscriber::SetEventHandler(const std::shared_ptr<DeviceStateHandler> &deviceStateHandler)
{
deviceStateHandler_ = deviceStateHandler;
}
DeviceStateEventIntValue DeviceStateEventSubscriber::GetDeviceStateEventIntValue(std::string &event) const
{
auto iter = deviceStateEventMapIntValues_.find(event);
if (iter == deviceStateEventMapIntValues_.end()) {
return COMMON_EVENT_UNKNOWN;
}
return iter->second;
}
void DeviceStateEventSubscriber::InitEventMap()
{
deviceStateEventMapIntValues_ = {
{CommonEventSupport::COMMON_EVENT_CONNECTIVITY_CHANGE, COMMON_EVENT_CONNECTIVITY_CHANGE},
{CommonEventSupport::COMMON_EVENT_SCREEN_ON, COMMON_EVENT_SCREEN_ON},
{CommonEventSupport::COMMON_EVENT_SCREEN_OFF, COMMON_EVENT_SCREEN_OFF},
{CommonEventSupport::COMMON_EVENT_POWER_SAVE_MODE_CHANGED, COMMON_EVENT_POWER_SAVE_MODE_CHANGED},
{CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED, COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED},
{CommonEventSupport::COMMON_EVENT_CHARGING, COMMON_EVENT_CHARGING},
{CommonEventSupport::COMMON_EVENT_DISCHARGING, COMMON_EVENT_DISCHARGING},
{CommonEventSupport::COMMON_EVENT_WIFI_HOTSPOT_STATE, COMMON_EVENT_WIFI_HOTSPOT_STATE},
{CommonEventSupport::COMMON_EVENT_WIFI_AP_STA_JOIN, COMMON_EVENT_WIFI_AP_STA_JOIN},
{CommonEventSupport::COMMON_EVENT_WIFI_AP_STA_LEAVE, COMMON_EVENT_WIFI_AP_STA_LEAVE},
};
}
} // namespace Telephony
} // namespace OHOS

View File

@ -24,6 +24,7 @@
#include "telephony_log_wrapper.h"
#include "i_network_search_callback.h"
#include "resource_utils.h"
#include "telephony_hisysevent.h"
namespace OHOS {
namespace Telephony {
@ -127,6 +128,8 @@ void NetworkRegister::ProcessCsRegister(const AppExecFwk::InnerEvent::Pointer &e
if (networkSearchManager->CheckIsNeedNotify(slotId_) || networkSearchState_->IsEmergency()) {
networkSearchState_->NotifyStateChange();
}
WriteNetworkStateHiSysEvent(slotId_, static_cast<int32_t>(DomainType::DOMAIN_TYPE_CS),
static_cast<int32_t>(tech), static_cast<int32_t>(regStatus));
}
void NetworkRegister::ProcessPsRegister(const AppExecFwk::InnerEvent::Pointer &event)
@ -177,6 +180,8 @@ void NetworkRegister::ProcessPsRegister(const AppExecFwk::InnerEvent::Pointer &e
if (networkSearchManager->CheckIsNeedNotify(slotId_) || networkSearchState_->IsEmergency()) {
networkSearchState_->NotifyStateChange();
}
WriteNetworkStateHiSysEvent(slotId_, static_cast<int32_t>(DomainType::DOMAIN_TYPE_PS),
static_cast<int32_t>(tech), static_cast<int32_t>(regStatus));
}
void NetworkRegister::ProcessChannelConfigInfo(const AppExecFwk::InnerEvent::Pointer &event)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -161,7 +161,7 @@ void NetworkSearchHandler::RegisterEvents()
}
// Register IMS
{
std::shared_ptr< ImsCoreServiceClient> imsCoreServiceClient =
std::shared_ptr<ImsCoreServiceClient> imsCoreServiceClient =
DelayedSingleton<ImsCoreServiceClient>::GetInstance();
if (imsCoreServiceClient != nullptr) {
imsCoreServiceClient->RegisterImsCoreServiceCallbackHandler(slotId_, shared_from_this());
@ -274,6 +274,10 @@ void NetworkSearchHandler::RadioStateChange(const AppExecFwk::InnerEvent::Pointe
}
if (radioState == CORE_SERVICE_POWER_ON || radioState == CORE_SERVICE_POWER_OFF) {
networkSearchManager->SetRadioStateValue(slotId_, (ModemPowerState)radioState);
auto inner = networkSearchManager->FindManagerInner(slotId_);
if (inner != nullptr && inner->deviceStateHandler_ != nullptr) {
inner->deviceStateHandler_->ProcessRadioState();
}
} else {
networkSearchManager->SetRadioStateValue(slotId_, CORE_SERVICE_POWER_NOT_AVAILABLE);
}
@ -690,10 +694,16 @@ void NetworkSearchHandler::TimezoneRefresh()
void NetworkSearchHandler::SendUpdateCellLocationRequest()
{
uint32_t curTime = (uint32_t)time(0);
if ((curTime - lastCellRequestTime_) < cellRequestMinInterval_) {
TELEPHONY_LOGE("NetworkSearchHandler::SendUpdateCellLocationRequest interval is too short");
return;
}
TELEPHONY_LOGI("NetworkSearchHandler::SendUpdateCellLocationRequest slotId:%{public}d", slotId_);
std::shared_ptr<ITelRilManager> telRilManager = telRilManager_.lock();
auto event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CURRENT_CELL_INFO);
if (event != nullptr && telRilManager != nullptr) {
lastCellRequestTime_ = curTime;
event->SetOwner(shared_from_this());
telRilManager->GetCurrentCellInfo(slotId_, event);
}
@ -738,7 +748,7 @@ void NetworkSearchHandler::DcPhysicalLinkActiveUpdate(const AppExecFwk::InnerEve
if (event == nullptr) {
return;
}
bool isActive = (event->GetParam() == 1) ? true : false;
bool isActive = (event->GetParam() == 1);
if (networkRegister_ != nullptr) {
networkRegister_->DcPhysicalLinkActiveUpdate(isActive);
}
@ -769,7 +779,7 @@ void NetworkSearchHandler::UpdateImsRegisterState(const AppExecFwk::InnerEvent::
TELEPHONY_LOGE("UpdateImsRegisterState event is null slotId:%{public}d", slotId_);
return;
}
bool isRegister = (event->GetParam() == 1) ? true : false;
bool isRegister = (event->GetParam() == 1);
std::shared_ptr<ImsServiceStatus> imsServiceStatus = event->GetSharedObject<ImsServiceStatus>();
std::shared_ptr<NetworkSearchState> networkSearchState =
networkSearchManager->GetNetworkSearchState(slotId_);
@ -811,5 +821,10 @@ void NetworkSearchHandler::AirplaneModeChange(const AppExecFwk::InnerEvent::Poin
radioInfo_->AirplaneModeChange();
}
}
void NetworkSearchHandler::SetCellRequestMinInterval(uint32_t minInterval)
{
cellRequestMinInterval_ = minInterval;
}
} // namespace Telephony
} // namespace OHOS

View File

@ -40,6 +40,7 @@ NetworkSearchManager::~NetworkSearchManager()
std::shared_ptr<NetworkSearchManagerInner> inner = FindManagerInner(slotId);
if (inner != nullptr) {
inner->UnRegisterSetting();
inner->UnRegisterDeviceStateObserver();
}
}
}
@ -78,6 +79,11 @@ bool NetworkSearchManager::InitPointer(std::shared_ptr<NetworkSearchManagerInner
TELEPHONY_LOGE("failed to create new NetworkSearchResult slotId:%{public}d", slotId);
return false;
}
inner->deviceStateHandler_ = std::make_shared<DeviceStateHandler>(shared_from_this(), telRilManager_, slotId);
if (inner->deviceStateHandler_ == nullptr) {
TELEPHONY_LOGE("failed to create new DeviceStateHandler slotId:%{public}d", slotId);
return false;
}
return true;
}
@ -120,6 +126,23 @@ bool NetworkSearchManagerInner::UnRegisterSetting()
return true;
}
bool NetworkSearchManagerInner::RegisterDeviceStateObserver()
{
deviceStateObserver_ = std::make_shared<DeviceStateObserver>();
deviceStateObserver_->StartEventSubscriber(deviceStateHandler_);
return true;
}
bool NetworkSearchManagerInner::UnRegisterDeviceStateObserver()
{
if (deviceStateObserver_ == nullptr) {
TELEPHONY_LOGE("NetworkSearchManager::UnRegisterDeviceStateObserver deviceStateObserver_ is null.");
return false;
}
deviceStateObserver_->StopEventSubscriber();
return true;
}
bool NetworkSearchManager::OnInit()
{
TELEPHONY_LOGI("NetworkSearchManager::Init");

View File

@ -17,6 +17,7 @@
#include "network_search_notify.h"
#include "telephony_log_wrapper.h"
#include "telephony_hisysevent.h"
namespace OHOS {
namespace Telephony {
@ -138,6 +139,11 @@ void SignalInfo::ProcessSignalIntensity(int32_t slotId, const AppExecFwk::InnerE
std::vector<sptr<SignalInformation>> signals;
GetSignalInfoList(signals);
DelayedSingleton<NetworkSearchNotify>::GetInstance()->NotifySignalInfoUpdated(slotId, signals);
int level = 0;
if (signals.size() != 0) {
level = signals[0]->GetSignalLevel();
}
WriteSignalLevelHiSysEvent(slotId, level);
}
PrintfLog(*signalIntensity);
}

View File

@ -13,7 +13,7 @@
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
ohos_executable("tel_network_search_test") {
install_enable = true
@ -44,7 +44,7 @@ ohos_executable("tel_network_search_test") {
"core_service:tel_core_service_api",
"eventhandler:libeventhandler",
"ipc:ipc_core",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 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
@ -377,7 +377,7 @@ void TestRegisterImsStateCallback()
"TYPE_UT = 2,TYPE_SMS = 3):" << std::endl;
std::cin >> imsSrvType;
ImsRegInfo imsRegInfo = ERROR_IMS_REG_INFO;
sptr<ImsVoiceCallbackStub> voiceCallback = std::make_unique<ImsVoiceCallbackTestStub>(imsRegInfo).release();
sptr<ImsVoiceCallbackStub> voiceCallback = new ImsVoiceCallbackTestStub(imsRegInfo);
sptr<ImsVideoCallbackStub> videoCallback(new ImsVideoCallbackStub());
sptr<ImsUtCallbackStub> utCallback(new ImsUtCallbackStub());
sptr<ImsSmsCallbackStub> smsCallback(new ImsSmsCallbackStub());

View File

@ -56,6 +56,7 @@ public:
private:
bool IsValidSlotId(int32_t);
bool IsValidSlotIdForDefault(int32_t);
std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr;
std::shared_ptr<SimStateManager> simStateManager_ = nullptr;
std::shared_ptr<SimFileManager> simFileManager_ = nullptr;

View File

@ -18,18 +18,18 @@
#include <vector>
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "abs_shared_result_set.h"
#include "data_ability_helper.h"
#include "data_ability_predicates.h"
#include "abs_shared_result_set.h"
#include "values_bucket.h"
#include "iservice_registry.h"
#include "result_set.h"
#include "uri.h"
#include "sim_utils.h"
#include "sim_constant.h"
#include "sim_rdb_info.h"
#include "sim_utils.h"
#include "system_ability_definition.h"
#include "telephony_log_wrapper.h"
#include "uri.h"
#include "values_bucket.h"
namespace OHOS {
namespace Telephony {
@ -44,9 +44,6 @@ public:
int32_t SetDefaultVoiceCard(int32_t slotId);
int32_t SetDefaultMessageCard(int32_t slotId);
int32_t SetDefaultCellularData(int32_t slotId);
bool RemoveDefaultVoiceCard();
bool RemoveDefaultMessageCard();
bool RemoveDefaultCellularCard();
int32_t InsertData(int64_t &id, const NativeRdb::ValuesBucket &values);
int32_t QueryDataBySlotId(int32_t slotId, SimRdbInfo &simBean);
@ -61,8 +58,8 @@ public:
private:
std::shared_ptr<AppExecFwk::DataAbilityHelper> CreateDataAHelper();
int Insert(const NativeRdb::ValuesBucket &values);
std::shared_ptr<NativeRdb::AbsSharedResultSet> Query(std::vector<std::string> &columns,
const NativeRdb::DataAbilityPredicates &predicates);
std::shared_ptr<NativeRdb::AbsSharedResultSet> Query(
std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates);
int Update(const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates);
int Delete(const NativeRdb::DataAbilityPredicates &predicates);
void SaveDataToBean(std::shared_ptr<NativeRdb::AbsSharedResultSet> result, SimRdbInfo &simBean);
@ -71,6 +68,13 @@ private:
const static int32_t SUCCESS = 1;
std::shared_ptr<AppExecFwk::DataAbilityHelper> helper_ = nullptr;
};
enum class DefaultCardType {
MAIN,
VOICE,
SMS,
DATA,
};
} // namespace Telephony
} // namespace OHOS
#endif // TELEPHONY_SIM_RDB_HELPER_H
#endif // TELEPHONY_SIM_RDB_HELPER_H

View File

@ -37,7 +37,6 @@ constexpr int32_t P3 = 0x00;
constexpr int32_t INT32_INTVALUE = 0;
constexpr int32_t INT32_ZERO = 0;
constexpr int32_t INT32_FST_NEGATIVE = -1;
constexpr int32_t INT32_FST_POSITIVE = 1;
constexpr size_t FST_POS = 0;
static std::string_view Strip(const std::string_view &src)
@ -318,7 +317,16 @@ void IccOperatorPrivilegeController::ProcessOpenLogicalChannelDone(const AppExec
return;
}
TELEPHONY_LOGI("Will to SimTransmitApduLogicalChannel");
state_->currentChannelId = INT32_FST_POSITIVE;
auto resultPtr = event->GetUniqueObject<OpenLogicalChannelResponse>();
if (resultPtr == nullptr) {
TELEPHONY_LOGE("the data of result is nullptr! then will Close Logical Channel");
return;
}
state_->currentChannelId = resultPtr->channelId;
if (state_->currentChannelId <= INT32_ZERO) {
TELEPHONY_LOGE("the logical channel transmit Unexpected shutdown");
return;
}
auto transmitEvent = GenCallBackEvent(shared_from_this(), MSG_TRANSMIT_LOGICAL_CHANNEL_DONE);
ApduSimIORequestInfo reqInfo;
reqInfo.channelId = state_->currentChannelId;

View File

@ -14,6 +14,7 @@
*/
#include "multi_sim_controller.h"
#include "string_ex.h"
namespace OHOS {
@ -121,9 +122,9 @@ bool MultiSimController::InitActive(int slotId)
if (IsSimActive(slotId) && !simStateManager_->HasSimCard()) {
if (result && SetActiveSim(slotId, DEACTIVE, true)) {
result = true;
} else {
} else {
result = false;
} // force set to database DEACTIVE and avoid duplicate
} // force set to database DEACTIVE and avoid duplicate
}
return result;
}
@ -251,8 +252,8 @@ void MultiSimController::SortCache()
sortCache.emplace_back(emptyUnit);
}
for (size_t j = 0; j < count; j++) {
TELEPHONY_LOGI("MultiSimController::index = %{public}d j = %{public}lu",
localCacheInfo_[j].slotIndex, (unsigned long)j);
TELEPHONY_LOGI(
"MultiSimController::index = %{public}d j = %{public}lu", localCacheInfo_[j].slotIndex, (unsigned long)j);
sortCache[localCacheInfo_[j].slotIndex] = localCacheInfo_[j];
}
localCacheInfo_ = sortCache;
@ -436,19 +437,7 @@ bool MultiSimController::SetDefaultVoiceSlotId(int32_t slotId)
TELEPHONY_LOGE("MultiSimController::SetDefaultVoiceSlotId failed by nullptr");
return false;
}
if (slotId == DEFAULT_SIM_SLOT_ID_REMOVE) {
int32_t result = simDbHelper_->RemoveDefaultVoiceCard();
if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultVoiceSlotId get Data Base failed");
return false;
}
int32_t i = DEFAULT_SIM_SLOT_ID;
for (; i < maxCount_; i++) {
localCacheInfo_[i].isVoiceCard = NOT_MAIN;
}
return AnnounceDefaultVoiceSlotIdChanged(slotId);
}
if ((uint32_t)slotId >= localCacheInfo_.size() || (int32_t)slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
if (slotId >= (int32_t)localCacheInfo_.size() || slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultVoiceSlotId failed by out of range");
return false;
}
@ -501,19 +490,7 @@ bool MultiSimController::SetDefaultSmsSlotId(int32_t slotId)
TELEPHONY_LOGE("MultiSimController::SetDefaultSmsSlotId failed by nullptr");
return false;
}
if (slotId == DEFAULT_SIM_SLOT_ID_REMOVE) {
int32_t result = simDbHelper_->RemoveDefaultMessageCard();
if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultSmsSlotId get Data Base failed");
return false;
}
int32_t i = DEFAULT_SIM_SLOT_ID;
for (; i < maxCount_; i++) {
localCacheInfo_[i].isMessageCard = NOT_MAIN;
}
return AnnounceDefaultSmsSlotIdChanged(slotId);
}
if ((uint32_t)slotId >= localCacheInfo_.size() || (int32_t)slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
if (slotId >= (int32_t)localCacheInfo_.size() || slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultSmsSlotId failed by out of range");
return false;
}
@ -553,19 +530,7 @@ bool MultiSimController::SetDefaultCellularDataSlotId(int32_t slotId)
TELEPHONY_LOGE("MultiSimController::SetDefaultCellularDataSlotId failed by nullptr");
return false;
}
if (slotId == DEFAULT_SIM_SLOT_ID_REMOVE) {
int32_t result = simDbHelper_->RemoveDefaultCellularCard();
if (result == INVALID_VALUE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultCellularDataSlotId get Data Base failed");
return false;
}
int32_t i = DEFAULT_SIM_SLOT_ID;
for (; i < maxCount_; i++) {
localCacheInfo_[i].isCellularDataCard = NOT_MAIN;
}
return AnnounceDefaultCellularDataSlotIdChanged(slotId);
}
if ((uint32_t)slotId >= localCacheInfo_.size() || (int32_t)slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
if (slotId >= (int32_t)localCacheInfo_.size() || slotId < DEFAULT_SIM_SLOT_ID_REMOVE) {
TELEPHONY_LOGE("MultiSimController::SetDefaultCellularDataSlotId failed by out of range");
return false;
}
@ -793,8 +758,7 @@ bool MultiSimController::SetIccId(int32_t slotId, std::u16string iccId)
bool MultiSimController::SetRadioProtocol(int32_t slotId, int32_t protocol)
{
TELEPHONY_LOGI(
"MultiSimController::SetRadioProtocol slotId = %{public}d protocol = %{public}d", slotId, protocol);
TELEPHONY_LOGI("MultiSimController::SetRadioProtocol slotId = %{public}d protocol = %{public}d", slotId, protocol);
if (radioCapController_ == nullptr) {
TELEPHONY_LOGE("MultiSimController::SetRadioProtocol failed by nullptr");
return false;

View File

@ -136,6 +136,10 @@ bool SimAccountManager::SetDefaultVoiceSlotId(int32_t slotId)
TELEPHONY_LOGE("SimAccountManager::SetDefaultVoiceSlotId failed by nullptr");
return false;
}
if (!IsValidSlotIdForDefault(slotId)) {
TELEPHONY_LOGE("SimAccountManager::SetDefaultVoiceSlotId invalid slotId = %{public}d", slotId);
return false;
}
return multiSimController_->SetDefaultVoiceSlotId(slotId);
}
@ -145,7 +149,7 @@ bool SimAccountManager::SetDefaultSmsSlotId(int32_t slotId)
TELEPHONY_LOGE("SimAccountManager::SetDefaultSmsSlotId failed by nullptr");
return false;
}
if (!IsValidSlotId(slotId)) {
if (!IsValidSlotIdForDefault(slotId)) {
TELEPHONY_LOGE("SimAccountManager::SetDefaultSmsSlotId invalid slotId = %{public}d", slotId);
return false;
}
@ -177,7 +181,7 @@ bool SimAccountManager::SetDefaultCellularDataSlotId(int32_t slotId)
TELEPHONY_LOGE("SimAccountManager::SetDefaultCellularDataSlotId failed by nullptr");
return false;
}
if (!IsValidSlotId(slotId)) {
if (!IsValidSlotIdForDefault(slotId)) {
TELEPHONY_LOGE("SimAccountManager::SetDefaultCellularDataSlotId invalid slotId = %{public}d", slotId);
return false;
}
@ -306,6 +310,16 @@ bool SimAccountManager::IsValidSlotId(int32_t slotId)
}
}
bool SimAccountManager::IsValidSlotIdForDefault(int32_t slotId)
{
int32_t count = SIM_SLOT_COUNT;
if ((slotId >= DEFAULT_SIM_SLOT_ID_REMOVE) && (slotId < count)) {
return true;
} else {
return false;
}
}
bool SimAccountManager::HasOperatorPrivileges(const int32_t slotId)
{
TELEPHONY_LOGI("SimAccountManager::HasOperatorPrivileges begin");
@ -331,4 +345,4 @@ bool SimAccountManager::HasOperatorPrivileges(const int32_t slotId)
return controller->HasOperatorPrivileges();
}
} // namespace Telephony
} // namespace OHOS
} // namespace OHOS

View File

@ -14,6 +14,7 @@
*/
#include "sim_rdb_helper.h"
#include "telephony_types.h"
namespace OHOS {
@ -52,8 +53,8 @@ int SimRdbHelper::Insert(const NativeRdb::ValuesBucket &values)
return helper_->Insert(simUri, values);
}
std::shared_ptr<NativeRdb::AbsSharedResultSet> SimRdbHelper::Query(std::vector<std::string> &columns,
const NativeRdb::DataAbilityPredicates &predicates)
std::shared_ptr<NativeRdb::AbsSharedResultSet> SimRdbHelper::Query(
std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates)
{
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::Query failed by nullptr");
@ -152,20 +153,13 @@ int32_t SimRdbHelper::SetDefaultMainCard(int32_t slotId)
TELEPHONY_LOGI("SimRdbHelper::SetDefaultMainCard = %{public}d", slotId);
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
value.PutInt(SimRdbInfo::SLOT_INDEX, slotId);
value.PutInt(SimRdbInfo::CARD_TYPE, static_cast<int>(DefaultCardType::MAIN));
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultMainCard failed by nullptr");
return INVALID_VALUE;
}
std::string slot = std::to_string(slotId);
value.PutInt(SimRdbInfo::IS_MAIN_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
helper_->Update(defaultUri, value, predicates);
value.Clear();
value.PutInt(SimRdbInfo::IS_MAIN_CARD, static_cast<int>(CardSeclectedStatus::ON));
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot);
return helper_->Update(defaultUri, value, predicates);
}
@ -174,35 +168,12 @@ int32_t SimRdbHelper::SetDefaultVoiceCard(int32_t slotId)
TELEPHONY_LOGI("SimRdbHelper::SetDefaultVoiceCard = %{public}d", slotId);
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
value.PutInt(SimRdbInfo::SLOT_INDEX, slotId);
value.PutInt(SimRdbInfo::CARD_TYPE, static_cast<int>(DefaultCardType::VOICE));
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultVoiceCard failed by nullptr");
return INVALID_VALUE;
}
std::string slot = std::to_string(slotId);
value.PutInt(SimRdbInfo::IS_VOICE_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
helper_->Update(defaultUri, value, predicates);
value.Clear();
value.PutInt(SimRdbInfo::IS_VOICE_CARD, static_cast<int>(CardSeclectedStatus::ON));
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot);
return helper_->Update(defaultUri, value, predicates);
}
bool SimRdbHelper::RemoveDefaultVoiceCard()
{
TELEPHONY_LOGI("SimRdbHelper::RemoveDefaultVoiceCard");
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::RemoveDefaultVoiceCard failed by nullptr");
return false;
}
std::string slot = std::to_string(DEFAULT_SIM_SLOT_ID_REMOVE);
value.PutInt(SimRdbInfo::IS_VOICE_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
return helper_->Update(defaultUri, value, predicates);
}
@ -212,78 +183,31 @@ int32_t SimRdbHelper::SetDefaultMessageCard(int32_t slotId)
TELEPHONY_LOGI("SimRdbHelper::SetDefaultMessageCard = %{public}d", slotId);
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
value.PutInt(SimRdbInfo::SLOT_INDEX, slotId);
value.PutInt(SimRdbInfo::CARD_TYPE, static_cast<int>(DefaultCardType::SMS));
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultMessageCard failed by nullptr");
return INVALID_VALUE;
}
std::string slot = std::to_string(slotId);
value.PutInt(SimRdbInfo::IS_MESSAGE_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
helper_->Update(defaultUri, value, predicates);
value.Clear();
value.PutInt(SimRdbInfo::IS_MESSAGE_CARD, static_cast<int>(CardSeclectedStatus::ON));
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot);
return helper_->Update(defaultUri, value, predicates);
}
bool SimRdbHelper::RemoveDefaultMessageCard()
{
TELEPHONY_LOGI("SimRdbHelper::RemoveDefaultVoiceCard");
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::RemoveDefaultVoiceCard failed by nullptr");
return false;
}
std::string slot = std::to_string(DEFAULT_SIM_SLOT_ID_REMOVE);
value.PutInt(SimRdbInfo::IS_MESSAGE_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
return helper_->Update(defaultUri, value, predicates);
}
int32_t SimRdbHelper::SetDefaultCellularData(int32_t slotId)
{
TELEPHONY_LOGI("SimRdbHelper::SetDefaultMessageCard = %{public}d", slotId);
TELEPHONY_LOGI("SimRdbHelper::SetDefaultCellularData = %{public}d", slotId);
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
value.PutInt(SimRdbInfo::SLOT_INDEX, slotId);
value.PutInt(SimRdbInfo::CARD_TYPE, static_cast<int>(DefaultCardType::DATA));
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::SetDefaultMessageCard failed by nullptr");
TELEPHONY_LOGE("SimRdbHelper::SetDefaultCellularData failed by nullptr");
return INVALID_VALUE;
}
std::string slot = std::to_string(slotId);
value.PutInt(SimRdbInfo::IS_CELLULAR_DATA_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
helper_->Update(defaultUri, value, predicates);
value.Clear();
value.PutInt(SimRdbInfo::IS_CELLULAR_DATA_CARD, static_cast<int>(CardSeclectedStatus::ON));
predicates.EqualTo(SimRdbInfo::SLOT_INDEX, slot);
return helper_->Update(defaultUri, value, predicates);
}
bool SimRdbHelper::RemoveDefaultCellularCard()
{
TELEPHONY_LOGI("SimRdbHelper::RemoveDefaultVoiceCard");
NativeRdb::DataAbilityPredicates predicates;
NativeRdb::ValuesBucket value;
if (helper_ == nullptr) {
TELEPHONY_LOGE("SimRdbHelper::RemoveDefaultVoiceCard failed by nullptr");
return false;
}
std::string slot = std::to_string(DEFAULT_SIM_SLOT_ID_REMOVE);
value.PutInt(SimRdbInfo::IS_CELLULAR_DATA_CARD, static_cast<int>(CardSeclectedStatus::OFF));
predicates.NotEqualTo(SimRdbInfo::SLOT_INDEX, slot);
Uri defaultUri(SimRdbInfo::SIM_RDB_DEFAULT_SET_URI);
return helper_->Update(defaultUri, value, predicates);
}
int32_t SimRdbHelper::InsertData(int64_t &id, const NativeRdb::ValuesBucket &values)
{
TELEPHONY_LOGI("SimRdbHelper::InsertData");
@ -446,4 +370,3 @@ int32_t SimRdbHelper::ClearData()
}
} // namespace Telephony
} // namespace OHOS

View File

@ -13,7 +13,7 @@
import("//base/telephony/core_service/core_service_aafwk.gni")
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service"
TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim"
@ -72,7 +72,7 @@ ohos_executable("tel_sim_test") {
"ipc:ipc_core",
"relational_store:native_dataability",
"relational_store:native_rdb",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",

View File

@ -23,12 +23,5 @@ typedef enum {
CORE_SERVICE_CDMA_LTE_PHONE = 3
} CoreServiceTelephonyType;
typedef enum {
HDF_SUCCESS = 0, /* The operation is successful. */
HDF_FAILURE = -1, /* Failed to invoke the OS underlying function. */
HDF_ERR_NOT_SUPPORT = -2, /* Not supported. */
HDF_ERR_INVALID_PARAM = -3 /* Invalid parameter. */
} HDF_STATUS;
typedef enum { CORE_SERVICE_SUCCESS = 0, CORE_SERVICE_ERROR = 1 } CoreServiceLteOptStatus;
#endif

View File

@ -163,6 +163,25 @@ public:
int32_t SetLocateUpdates(
int32_t slotId, HRilRegNotifyMode mode, const AppExecFwk::InnerEvent::Pointer &response) override;
/**
* @param slotId is the card slot index number
* @param newFilter is the notification filter with bits in HRilNotificationFilter
* @param response is the feedback info after setting notification filter
* @return int32_t Indicates if notification filter is set successfully
*/
int32_t SetNotificationFilter(
int32_t slotId, int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response) override;
/**
* @param slotId is the card slot index number
* @param deviceStateType is the device state type in HRilDeviceStateType
* @param deviceStateOn Indicates the specific device state is on
* @param response is the feedback info after setting device state
* @return int32_t Indicates if device state is set successfully
*/
int32_t SetDeviceState(int32_t slotId, int32_t deviceStateType, bool deviceStateOn,
const AppExecFwk::InnerEvent::Pointer &response) override;
int32_t GetBasebandVersion(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response) override;
/**

View File

@ -44,6 +44,9 @@ public:
int32_t GetCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer &response);
int32_t GetPhysicalChannelConfig(const AppExecFwk::InnerEvent::Pointer &response);
int32_t SetLocateUpdates(HRilRegNotifyMode mode, const AppExecFwk::InnerEvent::Pointer &response);
int32_t SetNotificationFilter(int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response);
int32_t SetDeviceState(
int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response);
// ril unsol
int32_t SignalStrengthUpdated(MessageParcel &data);
@ -81,6 +84,8 @@ public:
int32_t GetPreferredNetworkResponse(MessageParcel &data);
int32_t GetPhysicalChannelConfigResponse(MessageParcel &data);
int32_t SetLocateUpdatesResponse(MessageParcel &data);
int32_t SetNotificationFilterResponse(MessageParcel &data);
int32_t SetDeviceStateResponse(MessageParcel &data);
/**
* @brief Current operator ons or eons response

View File

@ -100,7 +100,7 @@ int32_t TelRilData::DeactivatePdpContext(int32_t cid, int32_t reason, const AppE
uniInfo.gsmIndex = cid;
uniInfo.arg1 = reason;
int32_t ret = SendBufferEvent(HREQ_DATA_DEACTIVATE_PDP_CONTEXT, uniInfo);
if (ret != HDF_SUCCESS) {
if (ret != 0) {
TELEPHONY_LOGE("Send HREQ_DATA_DEACTIVATE_PDP_CONTEXT return: %{public}d", ret);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
@ -131,7 +131,7 @@ int32_t TelRilData::ActivatePdpContext(int32_t radioTechnology, DataProfile data
dataCallInfo.roamingAllowed = allowRoaming;
dataCallInfo.isRoaming = isRoaming;
int32_t ret = SendBufferEvent(HREQ_DATA_ACTIVATE_PDP_CONTEXT, dataCallInfo);
if (ret != HDF_SUCCESS) {
if (ret != 0) {
TELEPHONY_LOGE("Send HREQ_DATA_ACTIVATE_PDP_CONTEXT return: %{public}d", ret);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
@ -188,7 +188,7 @@ int32_t TelRilData::GetPdpContextList(const AppExecFwk::InnerEvent::Pointer &res
UniInfo uniInfo;
uniInfo.serial = telRilRequest->serialId_;
int32_t ret = SendBufferEvent(HREQ_DATA_GET_PDP_CONTEXT_LIST, uniInfo);
if (ret != HDF_SUCCESS) {
if (ret != 0) {
TELEPHONY_LOGE("HREQ_DATA_GET_PDP_CONTEXT_LIST return: %{public}d", ret);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
@ -262,7 +262,7 @@ int32_t TelRilData::SetInitApnInfo(const DataProfile &dataProfile, const AppExec
dataProfileInfo.serial = telRilRequest->serialId_;
int32_t ret = SendBufferEvent(HREQ_DATA_SET_INIT_APN_INFO, dataProfileInfo);
if (ret != HDF_SUCCESS) {
if (ret != 0) {
TELEPHONY_LOGE("Send HREQ_DATA_ACTIVATE_PDP_CONTEXT return: %{public}d", ret);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}
@ -372,7 +372,7 @@ int32_t TelRilData::SetLinkBandwidthReportingRule(
TELEPHONY_LOGI("maximumUplinkKbpsSize:%{public}d, maximumDownlinkKbpsSize:%{public}d",
dLinkBandwidth.maximumUplinkKbpsSize, dLinkBandwidth.maximumDownlinkKbpsSize);
int32_t ret = SendBufferEvent(HREQ_DATA_SET_LINK_BANDWIDTH_REPORTING_RULE, dLinkBandwidth);
if (ret != HDF_SUCCESS) {
if (ret != 0) {
TELEPHONY_LOGE("HREQ_DATA_SET_LINK_BANDWIDTH_REPORTING_RULE return: %{public}d", ret);
return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
}

View File

@ -692,6 +692,19 @@ int32_t TelRilManager::SetLocateUpdates(
return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetLocateUpdates, mode);
}
int32_t TelRilManager::SetNotificationFilter(
int32_t slotId, int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response)
{
return TaskSchedule(
response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetNotificationFilter, newFilter);
}
int32_t TelRilManager::SetDeviceState(
int32_t slotId, int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response)
{
return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetDeviceState,
deviceStateType, deviceStateOn);
}
/*********************** TelRilNetwork end ****************************/
/*********************** TelRilSms start ******************************/
int32_t TelRilManager::SendGsmSms(

View File

@ -54,6 +54,8 @@ void TelRilNetwork::AddHandlerToMap()
memberFuncMap_[HREQ_NETWORK_GET_RADIO_CAPABILITY] = &TelRilNetwork::GetRadioCapabilityResponse;
memberFuncMap_[HREQ_NETWORK_GET_PHYSICAL_CHANNEL_CONFIG] = &TelRilNetwork::GetPhysicalChannelConfigResponse;
memberFuncMap_[HREQ_NETWORK_SET_LOCATE_UPDATES] = &TelRilNetwork::SetLocateUpdatesResponse;
memberFuncMap_[HREQ_NETWORK_SET_NOTIFICATION_FILTER] = &TelRilNetwork::SetNotificationFilterResponse;
memberFuncMap_[HREQ_NETWORK_SET_DEVICE_STATE] = &TelRilNetwork::SetDeviceStateResponse;
}
TelRilNetwork::TelRilNetwork(int32_t slotId, sptr<IRemoteObject> cellularRadio,
@ -657,6 +659,55 @@ int32_t TelRilNetwork::SetLocateUpdates(HRilRegNotifyMode mode, const AppExecFwk
}
}
int32_t TelRilNetwork::SetNotificationFilter(int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response)
{
std::shared_ptr<TelRilRequest> telRilRequest = CreateTelRilRequest(HREQ_NETWORK_SET_NOTIFICATION_FILTER, response);
if (telRilRequest == nullptr) {
TELEPHONY_LOGE("TelRilNetwork SetNotificationFilter::telRilRequest is nullptr");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
if (cellularRadio_ != nullptr) {
MessageParcel data;
MessageParcel reply;
data.WriteInt32(slotId_);
data.WriteInt32(telRilRequest->serialId_);
data.WriteInt32(static_cast<int32_t>(newFilter));
OHOS::MessageOption option = {OHOS::MessageOption::TF_ASYNC};
cellularRadio_->SendRequest(HREQ_NETWORK_SET_NOTIFICATION_FILTER, data, reply, option);
TELEPHONY_LOGI("TelRilNetwork::SetNotificationFilter: %{public}d", newFilter);
return TELEPHONY_ERR_SUCCESS;
} else {
TELEPHONY_LOGE("%{public}s cellularRadio_ == nullptr", __func__);
return ErrorResponse(telRilRequest->serialId_, HRilErrType::HRIL_ERR_INVALID_RESPONSE);
}
}
int32_t TelRilNetwork::SetDeviceState(
int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response)
{
std::shared_ptr<TelRilRequest> telRilRequest = CreateTelRilRequest(HREQ_NETWORK_SET_DEVICE_STATE, response);
if (telRilRequest == nullptr) {
TELEPHONY_LOGE("TelRilNetwork SetDeviceState::telRilRequest is nullptr");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
if (cellularRadio_ != nullptr) {
MessageParcel data;
MessageParcel reply;
data.WriteInt32(slotId_);
data.WriteInt32(telRilRequest->serialId_);
data.WriteInt32(static_cast<int32_t>(deviceStateType));
data.WriteInt32(static_cast<int32_t>(deviceStateOn));
OHOS::MessageOption option = {OHOS::MessageOption::TF_ASYNC};
cellularRadio_->SendRequest(HREQ_NETWORK_SET_DEVICE_STATE, data, reply, option);
TELEPHONY_LOGI("TelRilNetwork::SetDeviceState deviceStateType:%{public}d, deviceState:%{public}d",
deviceStateType, deviceStateOn);
return TELEPHONY_ERR_SUCCESS;
} else {
TELEPHONY_LOGE("%{public}s cellularRadio_ == nullptr", __func__);
return ErrorResponse(telRilRequest->serialId_, HRilErrType::HRIL_ERR_INVALID_RESPONSE);
}
}
int32_t TelRilNetwork::GetSignalStrengthResponse(MessageParcel &data)
{
const size_t readSpSize = sizeof(struct HRilRadioResponseInfo);
@ -1142,5 +1193,71 @@ int32_t TelRilNetwork::SetLocateUpdatesResponse(MessageParcel &data)
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
}
int32_t TelRilNetwork::SetNotificationFilterResponse(MessageParcel &data)
{
const size_t readSpSize = sizeof(struct HRilRadioResponseInfo);
const uint8_t *spBuffer = data.ReadUnpadBuffer(readSpSize);
if (spBuffer == nullptr) {
TELEPHONY_LOGE("TelRilNetwork::SetNotificationFilterResponse read spBuffer failed");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
const struct HRilRadioResponseInfo *radioResponseInfo =
reinterpret_cast<const struct HRilRadioResponseInfo *>(spBuffer);
if (radioResponseInfo == nullptr) {
TELEPHONY_LOGE("ERROR : SetNotificationFilterResponse --> radioResponseInfo == nullptr !!!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
std::shared_ptr<TelRilRequest> telRilRequest = FindTelRilRequest(*radioResponseInfo);
if (telRilRequest != nullptr && telRilRequest->pointer_ != nullptr) {
if (radioResponseInfo->error == HRilErrType::NONE) {
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &handler = telRilRequest->pointer_->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("SetNotificationFilterResponse handler is nullptr: this is the expected result");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
handler->SendEvent(telRilRequest->pointer_);
return TELEPHONY_ERR_SUCCESS;
} else {
return ErrorResponse(telRilRequest, *radioResponseInfo);
}
} else {
TELEPHONY_LOGE("telRilRequest or pointer_ == nullptr !");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
}
int32_t TelRilNetwork::SetDeviceStateResponse(MessageParcel &data)
{
const size_t readSpSize = sizeof(struct HRilRadioResponseInfo);
const uint8_t *spBuffer = data.ReadUnpadBuffer(readSpSize);
if (spBuffer == nullptr) {
TELEPHONY_LOGE("TelRilNetwork::SetDeviceStateResponse read spBuffer failed");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
const struct HRilRadioResponseInfo *radioResponseInfo =
reinterpret_cast<const struct HRilRadioResponseInfo *>(spBuffer);
if (radioResponseInfo == nullptr) {
TELEPHONY_LOGE("ERROR : SetDeviceStateResponse --> radioResponseInfo == nullptr !!!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
std::shared_ptr<TelRilRequest> telRilRequest = FindTelRilRequest(*radioResponseInfo);
if (telRilRequest != nullptr && telRilRequest->pointer_ != nullptr) {
if (radioResponseInfo->error == HRilErrType::NONE) {
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &handler = telRilRequest->pointer_->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("SetDeviceStateResponse handler is nullptr: this is the expected result");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
handler->SendEvent(telRilRequest->pointer_);
return TELEPHONY_ERR_SUCCESS;
} else {
return ErrorResponse(telRilRequest, *radioResponseInfo);
}
} else {
TELEPHONY_LOGE("telRilRequest or pointer_ == nullptr !");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
}
} // namespace Telephony
} // namespace OHOS

View File

@ -686,27 +686,31 @@ int32_t TelRilSim::SimOpenLogicalChannelResponse(MessageParcel &data)
TELEPHONY_LOGE("spBuffer == nullptr");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
std::unique_ptr<OpenLogicalChannelResponse> openLogicalChannelResult =
std::make_unique<OpenLogicalChannelResponse>();
openLogicalChannelResult->ReadFromParcel(data);
const struct HRilRadioResponseInfo *radioResponseInfo =
reinterpret_cast<const struct HRilRadioResponseInfo *>(spBuffer);
if (radioResponseInfo == nullptr) {
TELEPHONY_LOGE("ERROR :radioResponseInfo == nullptr");
TELEPHONY_LOGE("ERROR :radioResponseInfo == nullptr !!!");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
std::shared_ptr<TelRilRequest> telRilRequest = FindTelRilRequest(*radioResponseInfo);
if (telRilRequest != nullptr && telRilRequest->pointer_ != nullptr) {
if (radioResponseInfo->error == HRilErrType::NONE) {
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &handler = telRilRequest->pointer_->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("ERROR :handler == nullptr");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
uint32_t eventId = telRilRequest->pointer_->GetInnerEventId();
std::shared_ptr<HRilErrType> errorCode = std::make_shared<HRilErrType>();
*errorCode = radioResponseInfo->error;
handler->SendEvent(eventId, errorCode);
} else {
return ErrorResponse(telRilRequest, *radioResponseInfo);
}
if (telRilRequest == nullptr || telRilRequest->pointer_ == nullptr) {
TELEPHONY_LOGE("ERROR :telRilRequest == nullptr || radioResponseInfo error");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &handler = telRilRequest->pointer_->GetOwner();
if (handler == nullptr) {
TELEPHONY_LOGE("ERROR :handler == nullptr");
return TELEPHONY_ERR_LOCAL_PTR_NULL;
}
if (radioResponseInfo->error == HRilErrType::NONE) {
uint32_t eventId = telRilRequest->pointer_->GetInnerEventId();
handler->SendEvent(eventId, openLogicalChannelResult);
} else {
return ErrorResponse(telRilRequest, *radioResponseInfo);
}
return TELEPHONY_ERR_SUCCESS;
}
@ -957,6 +961,7 @@ int32_t TelRilSim::GetSimLockStatus(std::string fac, const AppExecFwk::InnerEven
simLockInfo.serial = telRilRequest->serialId_;
simLockInfo.fac = fac;
simLockInfo.mode = MODE;
simLockInfo.classx = 0;
simLockInfo.Marshalling(data);
MessageParcel reply;
OHOS::MessageOption option = {OHOS::MessageOption::TF_ASYNC};
@ -981,6 +986,7 @@ int32_t TelRilSim::SetSimLock(
simLockInfo.fac = fac;
simLockInfo.mode = mode;
simLockInfo.passwd = passwd;
simLockInfo.classx = 0;
simLockInfo.Marshalling(data);
MessageParcel reply;
OHOS::MessageOption option = {OHOS::MessageOption::TF_ASYNC};

View File

@ -13,7 +13,7 @@
import("//base/telephony/core_service/telephony.gni")
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
TELEPHONY_CORE_SERVICE_ROOT = "//base/telephony/core_service"
TELEPHONY_SIM_ROOT = "//base/telephony/core_service/services/sim"
@ -48,7 +48,7 @@ ohos_executable("tel_ril_test") {
"eventhandler:libeventhandler",
"ipc:ipc_core",
"power_manager_native:powermgr_client",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",
]

View File

@ -114,6 +114,8 @@ enum class DiffInterfaceId {
TEST_GET_VOICE_RADIO_INFO,
TEST_GET_PHYSICAL_CHANNEL_CONFIG,
TEST_SET_LOCATE_UPDATES,
TEST_SET_NOTIFICATION_FILTER,
TEST_SET_DEVICE_STATE,
TEST_SET_USSD,
TEST_GET_USSD,
TEST_SET_MUTE,
@ -315,6 +317,8 @@ public:
void OnRequestGetVoiceRadioTechnology(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestGetPhysicalChannelConfig(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestSetLocateUpdatesTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestSetNotificationFilterTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestSetDeviceStateTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestGetImsCallListTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void OnRequestSetCallPreferenceModeTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
@ -507,6 +511,8 @@ void TelRilTest::OnInitNetwork()
memberFuncMap_[DiffInterfaceId::TEST_GET_VOICE_RADIO_INFO] = &TelRilTest::OnRequestGetVoiceRadioTechnology;
memberFuncMap_[DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG] = &TelRilTest::OnRequestGetPhysicalChannelConfig;
memberFuncMap_[DiffInterfaceId::TEST_SET_LOCATE_UPDATES] = &TelRilTest::OnRequestSetLocateUpdatesTest;
memberFuncMap_[DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER] = &TelRilTest::OnRequestSetNotificationFilterTest;
memberFuncMap_[DiffInterfaceId::TEST_SET_DEVICE_STATE] = &TelRilTest::OnRequestSetDeviceStateTest;
}
void TelRilTest::OnInitForRegister(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
@ -1696,6 +1702,39 @@ void TelRilTest::OnRequestSetLocateUpdatesTest(
}
}
void TelRilTest::OnRequestSetNotificationFilterTest(
int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{
auto event = AppExecFwk::InnerEvent::Get(TYPESBITMAP);
if (event != nullptr && telRilManager_ != nullptr) {
event->SetOwner(handler);
int32_t filter = 0;
std::cout << "Please input filter: " << endl;
std::cin >> filter;
TELEPHONY_LOGI("TelRilTest::OnRequestSetNotificationFilterTest -->");
telRilManager_->SetNotificationFilter(slotId, filter, event);
TELEPHONY_LOGI("TelRilTest::OnRequestSetNotificationFilterTest --> finished");
}
}
void TelRilTest::OnRequestSetDeviceStateTest(
int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{
auto event = AppExecFwk::InnerEvent::Get(TYPESBITMAP);
if (event != nullptr && telRilManager_ != nullptr) {
event->SetOwner(handler);
int32_t deviceStateType = 0;
std::cout << "Please input deviceStateType: " << endl;
std::cin >> deviceStateType;
bool deviceStateOn = true;
std::cout << "Please input deviceStateOn: " << endl;
std::cin >> deviceStateOn;
TELEPHONY_LOGI("TelRilTest::OnRequestSetDeviceStateTest -->");
telRilManager_->SetDeviceState(slotId, deviceStateType, deviceStateOn, event);
TELEPHONY_LOGI("TelRilTest::OnRequestSetDeviceStateTest --> finished");
}
}
void TelRilTest::OnRequestCallJoinTest(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{
int32_t callType = 0; /* call type
@ -1996,18 +2035,15 @@ void TelRilTest::DemoHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer
"TelRilTest::DemoHandler::ProcessEvent --> eventId:%{public}d, slotId:%{public}d", eventId, this->slotId_);
switch (eventId) {
case uint32_t(CustomMessageID::MSG_OPEN_LOGICAL_CHANNEL_DONE): {
TELEPHONY_LOGI("open logical channel done");
break;
}
case uint32_t(CustomMessageID::MSG_TRANSMIT_LOGICAL_CHANNEL_DONE): {
auto result = event->GetUniqueObject<IccIoResultInfo>();
auto result = event->GetUniqueObject<OpenLogicalChannelResponse>();
if (result == nullptr) {
TELEPHONY_LOGE("TransmitSimIO response nullptr");
TELEPHONY_LOGE("Open logical response nullptr");
break;
}
TELEPHONY_LOGI("TransmitSimIO response:'%{public}s'", result->response.c_str());
TELEPHONY_LOGI("Open logical response channel:'%{public}d'", result->channelId);
break;
}
case uint32_t(CustomMessageID::MSG_TRANSMIT_LOGICAL_CHANNEL_DONE):
case uint32_t(CustomMessageID::MSG_TRANSMIT_BASIC_CHANNEL_DONE): {
auto result = event->GetUniqueObject<IccIoResultInfo>();
if (result == nullptr) {
@ -2374,6 +2410,8 @@ void NetworkTest()
cout << (int32_t)DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG << "--> OnRequestGetPhysicalChannelConfig"
<< endl;
cout << (int32_t)DiffInterfaceId::TEST_SET_LOCATE_UPDATES << "--> OnRequestSetLocateUpdatesTest" << endl;
cout << (int32_t)DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER << "--> OnRequestSetNotificationFilterTest" << endl;
cout << (int32_t)DiffInterfaceId::TEST_SET_DEVICE_STATE << "--> OnRequestSetDeviceStateTest" << endl;
}
} // namespace
} // namespace Telephony

View File

@ -49,7 +49,7 @@ ohos_unittest("tel_core_service_gtest") {
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ipc:ipc_core",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]

View File

@ -34,7 +34,7 @@ ohos_unittest("tel_ril_gtest") {
"//base/telephony/core_service/services/tel_ril/include",
"//base/telephony/core_service/services/sim/include",
"//utils/native/base/include",
"//drivers/adapter/uhdf2/include/hdi",
"//drivers/hdf_core/adapter/uhdf2/include/hdi",
]
deps = [
@ -51,7 +51,7 @@ ohos_unittest("tel_ril_gtest") {
"eventhandler:libeventhandler",
"ipc:ipc_core",
"power_manager_native:powermgr_client",
"ril_adapter:hril_innerkits",
"ril_device_driver_interface:hril_innerkits",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
"startup_l2:syspara",

View File

@ -201,6 +201,8 @@ void TelRilTest::InitNetwork()
memberFuncMap_[DiffInterfaceId::TEST_GET_VOICE_RADIO_INFO] = &TelRilTest::GetVoiceRadioTechnologyTest;
memberFuncMap_[DiffInterfaceId::TEST_GET_PHYSICAL_CHANNEL_CONFIG] = &TelRilTest::GetPhysicalChannelConfigTest;
memberFuncMap_[DiffInterfaceId::TEST_SET_LOCATE_UPDATES] = &TelRilTest::SetLocateUpdatesTest;
memberFuncMap_[DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER] = &TelRilTest::SetNotificationFilterTest;
memberFuncMap_[DiffInterfaceId::TEST_SET_DEVICE_STATE] = &TelRilTest::SetDeviceStateTest;
}
void TelRilTest::InitModem()
@ -1547,6 +1549,47 @@ void TelRilTest::SetLocateUpdatesTest(const std::shared_ptr<AppExecFwk::EventHan
}
}
/**
* @brief Set notification fiter
*
* @param handler
*/
void TelRilTest::SetNotificationFilterTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{
int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER);
auto event = AppExecFwk::InnerEvent::Get(eventId);
if (event != nullptr && telRilManager_ != nullptr) {
event->SetOwner(handler);
int32_t filter = 1;
TELEPHONY_LOGI("TelRilTest::SetNotificationFilterTest -->");
telRilManager_->SetNotificationFilter(slotId_, filter, event);
TELEPHONY_LOGI("TelRilTest::SetNotificationFilterTest --> finished");
bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
ASSERT_TRUE(syncResult);
}
}
/**
* @brief Set device state
*
* @param handler
*/
void TelRilTest::SetDeviceStateTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{
int32_t eventId = static_cast<int32_t>(DiffInterfaceId::TEST_SET_DEVICE_STATE);
auto event = AppExecFwk::InnerEvent::Get(eventId);
if (event != nullptr && telRilManager_ != nullptr) {
event->SetOwner(handler);
int32_t deviceStateType = 0;
bool deviceStateOn = true;
TELEPHONY_LOGI("TelRilTest::SetDeviceStateTest -->");
telRilManager_->SetDeviceState(slotId_, deviceStateType, deviceStateOn, event);
TELEPHONY_LOGI("TelRilTest::SetDeviceStateTest --> finished");
bool syncResult = WaitGetResult(eventId, handler, WAIT_TIME_SECOND);
ASSERT_TRUE(syncResult);
}
}
/**
* @brief Call merge
*
@ -2984,6 +3027,28 @@ HWTEST_F(TelRilTest, Telephony_TelRil_SetLocateUpdatesTest_0101, Function | Medi
return;
}
/**
* @tc.number Telephony_TelRil_SetNotificationFilterTest_0101 to do ...
* @tc.name Set notification filter
* @tc.desc Function test
*/
HWTEST_F(TelRilTest, Telephony_TelRil_SetNotificationFilterTest_0101, Function | MediumTest | Level3)
{
ProcessTest(static_cast<int32_t>(DiffInterfaceId::TEST_SET_NOTIFICATION_FILTER), GetHandler());
return;
}
/**
* @tc.number Telephony_TelRil_SetDeviceStateTest_0101 to do ...
* @tc.name Set device state
* @tc.desc Function test
*/
HWTEST_F(TelRilTest, Telephony_TelRil_SetDeviceStateTest_0101, Function | MediumTest | Level3)
{
ProcessTest(static_cast<int32_t>(DiffInterfaceId::TEST_SET_DEVICE_STATE), GetHandler());
return;
}
/**
* @tc.number Telephony_TelRil_SetUssdTest_0101 to do ...
* @tc.name Set USSD information

View File

@ -112,6 +112,8 @@ enum class DiffInterfaceId {
TEST_GET_VOICE_RADIO_INFO,
TEST_GET_PHYSICAL_CHANNEL_CONFIG,
TEST_SET_LOCATE_UPDATES,
TEST_SET_NOTIFICATION_FILTER,
TEST_SET_DEVICE_STATE,
TEST_SET_USSD,
TEST_GET_USSD,
TEST_SET_CMUT,
@ -246,6 +248,8 @@ private:
void GetVoiceRadioTechnologyTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void GetPhysicalChannelConfigTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void SetLocateUpdatesTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void SetNotificationFilterTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void SetDeviceStateTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void SetUssdTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void GetUssdTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
void SetMuteTest(const std::shared_ptr<AppExecFwk::EventHandler> &handler);

View File

@ -30,8 +30,11 @@ config("tel_utils_config") {
}
ohos_shared_library("libtel_common") {
include_dirs = [ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include" ]
sources = [
"common/src/str_convert.cpp",
"common/src/telephony_hisysevent.cpp",
"common/src/telephony_permission.cpp",
"preferences/src/tel_profile_util.cpp",
]
@ -69,6 +72,7 @@ ohos_shared_library("libtel_common") {
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"hisysevent_native:libhisysevent",
"ipc:ipc_single",
"permission_standard:libpermissionsdk_standard",
"safwk:system_ability_fwk",

View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 2022 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 TELEPHONY_HISYSEVENT_H
#define TELEPHONY_HISYSEVENT_H
#include <string>
namespace OHOS {
namespace Telephony {
// CoreService HiSysEvent
void WriteSignalLevelHiSysEvent(const int32_t slotId, const int32_t level);
void WriteNetworkStateHiSysEvent(const int32_t slotId, const int32_t domain, const int32_t tech, const int32_t state);
} // namespace Telephony
} // namespace OHOS
#endif // TELEPHONY_HISYSEVENT_H

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2022 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 "telephony_hisysevent.h"
#include "hisysevent.h"
namespace OHOS {
namespace Telephony {
// CoreService HiSysEvent
const std::string CORE_SERVICE_DOMAIN = "CORE_SERVICE";
const std::string SLOT_ID = "SLOT_ID";
const std::string SIGNAL_STRENGTH_EVENT = "SIGNAL_LEVEL";
const std::string SIGANL_LEVEL = "LEVEL";
const std::string NETWORK_REGISTER_EVENT = "NETWORK_REGISTER";
const std::string NETWORK_DOMAIN = "REGISTRATION_DOMAIN";
const std::string NETWORK_TECH = "RADIO_TECH";
const std::string NETWORK_STATE = "REGISTRATION_STATE";
template<typename... Types>
static void WriteStatisticEvent(const std::string &domain, const std::string &eventType, Types... args)
{
HiviewDFX::HiSysEvent::Write(domain, eventType, HiviewDFX::HiSysEvent::EventType::STATISTIC, args...);
}
void WriteSignalLevelHiSysEvent(const int32_t slotId, const int32_t level)
{
WriteStatisticEvent(CORE_SERVICE_DOMAIN, SIGNAL_STRENGTH_EVENT, SLOT_ID, slotId, SIGANL_LEVEL, level);
}
void WriteNetworkStateHiSysEvent(const int32_t slotId, const int32_t domain, const int32_t tech, const int32_t state)
{
WriteStatisticEvent(CORE_SERVICE_DOMAIN, NETWORK_REGISTER_EVENT,
SLOT_ID, slotId, NETWORK_DOMAIN, domain, NETWORK_TECH, tech, NETWORK_STATE, state);
}
} // namespace Telephony
} // namespace OHOS