diff --git a/BUILD.gn b/BUILD.gn old mode 100755 new mode 100644 index 1b4406a587be3875d76f401825c325d69f76cff5..52d9b491693d05113f7c29ec15ab1db631fefb19 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,13 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/telephony/call_manager/call_manager_aafwk.gni") import("//base/telephony/core_service/telephony.gni") import("//build/ohos.gni") ohos_shared_library("tel_call_manager") { sources = [ - "//base/telephony/cellular_call/framework/cellular_call_death_recipient.cpp", - "//base/telephony/cellular_call/framework/cellular_call_proxy.cpp", "services/audio/src/audio_control_manager.cpp", "services/audio/src/audio_device_manager.cpp", "services/audio/src/audio_player.cpp", @@ -39,8 +38,10 @@ ohos_shared_library("tel_call_manager") { "services/audio/src/ring.cpp", "services/audio/src/tone.cpp", "services/bluetooth/src/bluetooth_call_manager.cpp", + "services/bluetooth/src/bluetooth_call_policy.cpp", + "services/bluetooth/src/bluetooth_call_service.cpp", + "services/bluetooth/src/bluetooth_call_stub.cpp", "services/bluetooth/src/bluetooth_connection.cpp", - "services/bluetooth/src/bluetooth_state_observer.cpp", "services/call/call_state_observer/src/call_data_base_helper.cpp", "services/call/call_state_observer/src/call_recording_tone.cpp", "services/call/call_state_observer/src/call_records_handler.cpp", @@ -85,6 +86,8 @@ ohos_shared_library("tel_call_manager") { "services/telephony_interaction/src/call_status_callback.cpp", "services/telephony_interaction/src/call_status_callback_stub.cpp", "services/telephony_interaction/src/cellular_call_connection.cpp", + "services/telephony_interaction/src/cellular_call_death_recipient.cpp", + "services/telephony_interaction/src/cellular_call_proxy.cpp", "services/telephony_interaction/src/core_service_connection.cpp", "services/telephony_interaction/src/report_call_info_handler.cpp", "services/video/src/video_control_manager.cpp", @@ -97,9 +100,7 @@ ohos_shared_library("tel_call_manager") { "//third_party/libphonenumber/cpp/src/phonenumbers", "//third_party/protobuf/src", "//third_party/protobuf/src/google/protobuf", - "//base/telephony/cellular_call/interfaces", "//base/telephony/call_manager/interfaces/innerkits", - "//base/telephony/cellular_call/services/common/include", "//base/telephony/sms_mms/interfaces/innerkits/", "services/audio/include", "services/audio/include/audio_state", @@ -113,14 +114,13 @@ ohos_shared_library("tel_call_manager") { "services/video/include", "services/call/call_state_observer/include", "frameworks/native/include", - "//foundation/multimedia/camera_standard/interfaces/innerkits/native/camera/include", + "//foundation/multimedia/camera_standard/interfaces/inner_api/native/camera/include", "//foundation/multimedia/camera_standard/services/camera_service/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/base/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/client/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/server/include", - "//foundation/graphic/standard/frameworks/surface/include", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata/include", - "//utils/system/safwk/native/include", + "//foundation/graphic/graphic/frameworks/surface/include", + "//drivers/peripheral/camera/interfaces/metadata/include", "//drivers/framework/include/utils", "//drivers/adapter/uhdf2/utils/include", "//drivers/adapter/uhdf2/include/hdi", @@ -130,49 +130,47 @@ ohos_shared_library("tel_call_manager") { "//drivers/peripheral/camera/interfaces/include/callback/device", "//drivers/peripheral/camera/interfaces/include/callback/operator", "//drivers/peripheral/camera/interfaces/include/callback/host", - "//foundation/aafwk/standard/interfaces/innerkits/dataobs_manager/include", - "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audioringtone/include", + "${aafwk_inner_api_path}/dataobs_manager/include", + "//foundation/multimedia/audio_standard/interfaces/inner_api/native/audioringtone/include", "//foundation/multimedia/audio_standard/services/include/client", - "//foundation/multimedia/media_standard/interfaces/innerkits/native/media/include", + "//foundation/multimedia/media_standard/interfaces/inner_api/native", + "//foundation/multimedia/medialibrary_standard/interfaces/innerkits/native/include", ] configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] deps = [ - "//base/notification/ans_standard/frameworks/ans/core:ans_core", - "//base/notification/ans_standard/frameworks/ans/native:ans_innerkits", - "//base/notification/ans_standard/services/ans:libans", + "${aafwk_inner_api_path}/dataobs_manager:dataobs_manager", + "${aafwk_kits_path}/ability/native:abilitykit_native", + "//base/notification/distributed_notification_service/frameworks/ans:ans_innerkits", + "//base/notification/distributed_notification_service/frameworks/core:ans_core", "//base/telephony/core_service/utils:libtel_common", "//base/telephony/sms_mms/frameworks/native:tel_sms_mms_api", - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", - "//foundation/aafwk/standard/interfaces/innerkits/dataobs_manager:dataobs_manager", - "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", - "//foundation/graphic/standard:libsurface", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/camera:camera_framework", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata:metadata", + "//drivers/peripheral/camera/interfaces/metadata:metadata", + "//foundation/multimedia/camera_standard/frameworks/native/camera:camera_framework", "//third_party/libphonenumber/cpp:phonenumber_standard", - "//third_party/protobuf/src:protobuf_standard", "//utils/native/base:utils", ] external_deps = [ - "ability_runtime:want", - "appexecfwk_standard:libeventhandler", - "ces_standard:cesfwk_innerkits", + "ability_base:configuration", + "ability_base:want", + "ability_base:zuri", + "common_event_service:cesfwk_innerkits", "core_service:tel_core_service_api", + "dataability:native_dataability", "display_manager_native:displaymgr", + "eventhandler:libeventhandler", "ipc:ipc_core", "multimedia_audio_standard:audio_client", "multimedia_audio_standard:audio_renderer", "multimedia_audio_standard:audio_ringtone_client", - "native_appdatamgr:native_appdatafwk", - "native_appdatamgr:native_dataability", - "native_appdatamgr:native_rdb", "power_manager_native:powermgr_client", + "relational_store:native_appdatafwk", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", - "state_registry:tel_state_registry_notify", + "startup_l2:syspara", ] cflags_cc = [ @@ -196,6 +194,12 @@ ohos_shared_library("tel_call_manager") { } else { external_deps += [ "hilog:libhilog" ] } + + if (defined(global_parts_info) && + defined(global_parts_info.communication_bluetooth_standard)) { + external_deps += [ "bluetooth_standard:btframework" ] + defines += [ "ABILITY_BLUETOOTH_SUPPORT" ] + } part_name = "call_manager" subsystem_name = "telephony" } diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/README_zh.md b/README_zh.md old mode 100755 new mode 100644 index 917071cae951a940939927cffdcf525796b1869e..93a933f16b2e6f9ec4c0359986e902be98247d7d --- a/README_zh.md +++ b/README_zh.md @@ -134,7 +134,7 @@ -完整的JS API说明以及实例代码请参考:[拨打电话](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/js-reference/apis/js-apis-call.md)。 +完整的JS API说明以及实例代码请参考:[拨打电话](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-call.md)。 ## 使用说明 ### 拨打电话接口调用流程及示例代码 diff --git a/bundle.json b/bundle.json old mode 100755 new mode 100644 index 361a0987d68dc9567fa823ba1dbf34d2f51c8982..067552a8943c032a72c59423fcd7ec3e8ce2b080 --- a/bundle.json +++ b/bundle.json @@ -26,14 +26,15 @@ "adapted_system_type": [ "standard" ], - "rom": "", - "ram": "", + "rom": "1.6MB", + "ram": "6MB", "deps": { "components": [ + "ability_base", "ability_runtime", "appexecfwk_standard", "camera_device_driver", - "ces_standard", + "common_event_service", "core_service", "device_driver_framework", "display_device_driver", @@ -41,12 +42,12 @@ "dmsfwk_standard", "ipc", "multimedia_audio_standard", - "native_appdatamgr", + "dataability", + "relational_store", "power_manager_native", "safwk", "samgr_standard", "sms_mms", - "state_registry", "utils_base" ], "third_party": [ @@ -59,7 +60,7 @@ "//base/telephony/call_manager:tel_call_manager", "//base/telephony/call_manager/sa_profile:call_manager_sa_profile", "//base/telephony/call_manager/frameworks/js:call", - "//base/telephony/call_manager/frameworks/native:tel_call_manager_api" + "//base/telephony/call_manager/resource/audio:ring.wav" ], "inner_kits": [ { diff --git a/call_manager_aafwk.gni b/call_manager_aafwk.gni new file mode 100644 index 0000000000000000000000000000000000000000..df4c0cc61d2a4cd7f86b51ee8adbfb458b80900c --- /dev/null +++ b/call_manager_aafwk.gni @@ -0,0 +1,15 @@ +# 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. + +aafwk_inner_api_path = "//foundation/aafwk/standard/interfaces/innerkits" +aafwk_kits_path = "//foundation/aafwk/standard/frameworks/kits" diff --git a/figures/en-us_architecture-of-the-call-manager-module.png b/figures/en-us_architecture-of-the-call-manager-module.png old mode 100755 new mode 100644 diff --git a/figures/zh-cn_architecture-of-the-call-manager-module.png b/figures/zh-cn_architecture-of-the-call-manager-module.png old mode 100755 new mode 100644 diff --git a/frameworks/js/BUILD.gn b/frameworks/js/BUILD.gn old mode 100755 new mode 100644 index 790b0fd74e1e010ea1c7b15b2900227552c61040..610607849115ab9a8c4afd83485dcbae1f395063 --- a/frameworks/js/BUILD.gn +++ b/frameworks/js/BUILD.gn @@ -35,21 +35,18 @@ ohos_shared_library("call") { public_configs = [ ":call_manager_js_config" ] deps = [ - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/ace/napi:ace_napi", + "//foundation/arkui/napi:ace_napi", "//third_party/libuv:uv_static", "//utils/native/base:utils", ] external_deps = [ - "ability_runtime:ability_manager", - "ability_runtime:app_manager", - "ability_runtime:want", - "appexecfwk_standard:libeventhandler", + "ability_base:want", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "call_manager:tel_call_manager_api", "core_service:tel_core_service_api", + "eventhandler:libeventhandler", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", diff --git a/frameworks/js/napi/include/napi_call_ability_callback.h b/frameworks/js/napi/include/napi_call_ability_callback.h old mode 100755 new mode 100644 index 7abb4eac177996b2713340ce2285f92c2c14e452..b558c4bda3bd61b4a26885242f2bba268a0fd5ce --- a/frameworks/js/napi/include/napi_call_ability_callback.h +++ b/frameworks/js/napi/include/napi_call_ability_callback.h @@ -67,6 +67,8 @@ public: void UnRegisterStartRttCallback(); int32_t RegisterStopRttCallback(EventCallback callback); void UnRegisterStopRttCallback(); + void RegisterMmiCodeCallback(EventCallback eventCallback); + void UnRegisterMmiCodeCallback(); int32_t UpdateCallStateInfo(const CallAttributeInfo &info); int32_t UpdateCallEvent(const CallEventInfo &info); int32_t UpdateCallDisconnectedCause(DisconnectedDetails cause); @@ -76,6 +78,7 @@ public: void UnRegisterUpdateCallMediaModeCallback(); int32_t ReportSetVolteStateInfo(AppExecFwk::PacMap &resultInfo); int32_t ReportSetLteEnhanceModeInfo(AppExecFwk::PacMap &resultInfo); + int32_t UpdateMmiCodeResultsInfo(const MmiCodeInfo &info); private: static void ReportCallStateWork(uv_work_t *work, int32_t status); @@ -120,6 +123,8 @@ private: int32_t ReportCallMediaModeInfo(AppExecFwk::PacMap &resultInfo); static void ReportCallMediaModeInfoWork(uv_work_t *work, int32_t status); static void ReportCallMediaModeInfo(AppExecFwk::PacMap &resultInfo, EventCallback supplementInfo); + static void ReportMmiCodeWork(uv_work_t *work, int32_t status); + static int32_t ReportMmiCode(MmiCodeInfo &info, EventCallback eventCallback); private: EventCallback stateCallback_; @@ -141,6 +146,7 @@ private: EventCallback startRttCallback_; EventCallback stopRttCallback_; EventCallback updateCallMediaModeCallback_; + EventCallback mmiCodeCallback_; using CallResultReportIdProcessorFunc = int32_t (NapiCallAbilityCallback::*)(AppExecFwk::PacMap &resultInfo); std::map memberFuncMap_; std::mutex mutex_; diff --git a/frameworks/js/napi/include/napi_call_manager.h b/frameworks/js/napi/include/napi_call_manager.h old mode 100755 new mode 100644 index 3227efc1bbc8d41a50306f518548eaca8d10418c..4c51dc8b74931df84bed9d8a62acf2f5e91b0283 --- a/frameworks/js/napi/include/napi_call_manager.h +++ b/frameworks/js/napi/include/napi_call_manager.h @@ -52,8 +52,27 @@ public: static napi_value DeclareCallRestrictionEnum(napi_env env, napi_value exports); static napi_value DeclareCallWaitingEnum(napi_env env, napi_value exports); static napi_value DeclareCallTransferEnum(napi_env env, napi_value exports); + // Enumeration type extension + static napi_value DeclareAudioDeviceEnum(napi_env env, napi_value exports); + static napi_value DeclareVideoStateTypeEnum(napi_env env, napi_value exports); + static napi_value DeclareImsCallModeEnum(napi_env env, napi_value exports); + static napi_value DeclareDialSceneEnum(napi_env env, napi_value exports); + static napi_value DeclareCallTypeEnum(napi_env env, napi_value exports); + static napi_value DeclareDialTypeEnum(napi_env env, napi_value exports); + static napi_value DeclareTelCallStateEnum(napi_env env, napi_value exports); + static napi_value DeclareConferenceStateEnum(napi_env env, napi_value exports); + static napi_value DeclareCallStateToAppEnum(napi_env env, napi_value exports); + static napi_value DeclareCallEventEnumEx(napi_env env, napi_value exports); + static napi_value DeclareRestrictionTypeEnum(napi_env env, napi_value exports); + static napi_value DeclareRestrictionModeEnum(napi_env env, napi_value exports); + static napi_value DeclareRestrictionStatusEnum(napi_env env, napi_value exports); + static napi_value DeclareCallWaitingEnumEx(napi_env env, napi_value exports); + static napi_value DeclareTransferStatusEnum(napi_env env, napi_value exports); + static napi_value DeclareTransferTypeEnum(napi_env env, napi_value exports); + static napi_value DeclareTransferSettingTypeEnum(napi_env env, napi_value exports); static napi_value RegisterCallManagerFunc(napi_env env, napi_value exports); static napi_value DialCall(napi_env env, napi_callback_info info); + static napi_value MakeCall(napi_env env, napi_callback_info info); static napi_value AnswerCall(napi_env env, napi_callback_info info); static napi_value RejectCall(napi_env env, napi_callback_info info); static napi_value HangUpCall(napi_env env, napi_callback_info info); @@ -106,6 +125,7 @@ public: static napi_value IsLteEnhanceModeEnabled(napi_env env, napi_callback_info info); static napi_value ReportOttCallDetailsInfo(napi_env env, napi_callback_info info); static napi_value ReportOttCallEventInfo(napi_env env, napi_callback_info info); + static napi_value HasVoiceCapability(napi_env env, napi_callback_info info); private: static void RegisterCallBack(); @@ -121,6 +141,7 @@ private: static int32_t GetRestrictionInfo(napi_env env, napi_value objValue, CallRestrictionAsyncContext &asyncContext); static int32_t GetTransferInfo(napi_env env, napi_value objValue, CallTransferAsyncContext &asyncContext); static void NativeDialCall(napi_env env, void *data); + static void NativeMakeCall(napi_env env, void *data); static void NativeAnswerCall(napi_env env, void *data); static void NativeRejectCall(napi_env env, void *data); static void NativeHangUpCall(napi_env env, void *data); diff --git a/frameworks/js/napi/include/napi_call_manager_callback.h b/frameworks/js/napi/include/napi_call_manager_callback.h old mode 100755 new mode 100644 index 72819e063083f4fbf5b416c587035bc4d0868c4e..0c15eb9a37d267dc770e7969dd3220f27e1aa358 --- a/frameworks/js/napi/include/napi_call_manager_callback.h +++ b/frameworks/js/napi/include/napi_call_manager_callback.h @@ -33,6 +33,7 @@ public: int32_t OnCallDisconnectedCause(DisconnectedDetails cause) override; int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) override; int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) override; + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) override; }; } // namespace Telephony } // namespace OHOS diff --git a/frameworks/js/napi/include/napi_call_manager_types.h b/frameworks/js/napi/include/napi_call_manager_types.h old mode 100755 new mode 100644 index b422cdeff33e4d7a44da99e90a7bd3ced38b57a3..fd6899796bcf496373287048d38f92e5c2b89fbc --- a/frameworks/js/napi/include/napi_call_manager_types.h +++ b/frameworks/js/napi/include/napi_call_manager_types.h @@ -107,7 +107,8 @@ struct UtilsAsyncContext : AsyncContext { }; struct EventCallback { - EventCallback() : env(nullptr), thisVar(nullptr), callbackRef(nullptr), deferred(nullptr) {} + EventCallback() : env(nullptr), thisVar(nullptr), callbackRef(nullptr), deferred(nullptr), + callbackBeginTime_(0) {} napi_env env; napi_value thisVar; napi_ref callbackRef; @@ -184,7 +185,12 @@ struct CallOttWorker { AppExecFwk::PacMap info; EventCallback callback; }; + +struct MmiCodeWorker { + MmiCodeInfo info; + EventCallback callback; +}; } // namespace Telephony } // namespace OHOS -#endif // NAPI_CALL_MANAGER_TYPES_H \ No newline at end of file +#endif // NAPI_CALL_MANAGER_TYPES_H diff --git a/frameworks/js/napi/include/napi_call_manager_utils.h b/frameworks/js/napi/include/napi_call_manager_utils.h old mode 100755 new mode 100644 index 27d15fdc68e29a55c331042a010021d70381de01..098fbe672a4821657fae1a6405ec6301409b9809 --- a/frameworks/js/napi/include/napi_call_manager_utils.h +++ b/frameworks/js/napi/include/napi_call_manager_utils.h @@ -41,6 +41,7 @@ public: static void SetPropertyInt32(napi_env env, napi_value object, std::string name, int32_t value); static void SetPropertyStringUtf8(napi_env env, napi_value object, std::string name, std::string value); static void SetPropertyBoolean(napi_env env, napi_value object, std::string name, int32_t value); + static napi_value CreateEnumConstructor(napi_env env, napi_callback_info info); }; } // namespace Telephony } // namespace OHOS diff --git a/frameworks/js/napi/src/napi_call_ability_callback.cpp b/frameworks/js/napi/src/napi_call_ability_callback.cpp old mode 100755 new mode 100644 index 6c648dcfdfd67e49161c75f244a8627e5800d8ed..b7905f4f66032ead9f01963f2f1aa4f08e3a397a --- a/frameworks/js/napi/src/napi_call_ability_callback.cpp +++ b/frameworks/js/napi/src/napi_call_ability_callback.cpp @@ -15,6 +15,7 @@ #include "napi_call_ability_callback.h" +#include #include #include "call_manager_errors.h" @@ -45,6 +46,7 @@ NapiCallAbilityCallback::NapiCallAbilityCallback() (void)memset_s(&stopRttCallback_, sizeof(EventCallback), 0, sizeof(EventCallback)); (void)memset_s(&updateCallMediaModeCallback_, sizeof(EventCallback), 0, sizeof(EventCallback)); (void)memset_s(&callDisconnectCauseCallback_, sizeof(EventCallback), 0, sizeof(EventCallback)); + (void)memset_s(&mmiCodeCallback_, sizeof(EventCallback), 0, sizeof(EventCallback)); memberFuncMap_[CallResultReportId::GET_CALL_WAITING_REPORT_ID] = &NapiCallAbilityCallback::ReportGetWaitingInfo; memberFuncMap_[CallResultReportId::SET_CALL_WAITING_REPORT_ID] = &NapiCallAbilityCallback::ReportSetWaitingInfo; memberFuncMap_[CallResultReportId::GET_CALL_RESTRICTION_REPORT_ID] = @@ -82,6 +84,18 @@ void NapiCallAbilityCallback::UnRegisterCallStateCallback() } } +void NapiCallAbilityCallback::RegisterMmiCodeCallback(EventCallback eventCallback) +{ + mmiCodeCallback_ = eventCallback; +} + +void NapiCallAbilityCallback::UnRegisterMmiCodeCallback() +{ + if (mmiCodeCallback_.callbackRef) { + (void)memset_s(&mmiCodeCallback_, sizeof(EventCallback), 0, sizeof(EventCallback)); + } +} + void NapiCallAbilityCallback::RegisterCallEventCallback(EventCallback eventCallback) { eventCallback_ = eventCallback; @@ -211,7 +225,9 @@ void NapiCallAbilityCallback::UnRegisterSetTransferCallback() int32_t NapiCallAbilityCallback::RegisterGetVolteCallback(EventCallback callback) { if (getVolteCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - getVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - getVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -230,7 +246,9 @@ void NapiCallAbilityCallback::UnRegisterGetVolteCallback() int32_t NapiCallAbilityCallback::RegisterEnableVolteCallback(EventCallback callback) { if (enableVolteCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - enableVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - enableVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -249,7 +267,9 @@ void NapiCallAbilityCallback::UnRegisterEnableVolteCallback() int32_t NapiCallAbilityCallback::RegisterDisableVolteCallback(EventCallback callback) { if (disableVolteCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - disableVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - disableVolteCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -268,7 +288,9 @@ void NapiCallAbilityCallback::UnRegisterDisableVolteCallback() int32_t NapiCallAbilityCallback::RegisterGetLteEnhanceCallback(EventCallback callback) { if (getLteEnhanceCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - getLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - getLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -287,7 +309,9 @@ void NapiCallAbilityCallback::UnRegisterGetLteEnhanceCallback() int32_t NapiCallAbilityCallback::RegisterEnableLteEnhanceModeCallback(EventCallback callback) { if (enableLteEnhanceCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - enableLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - enableLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -306,7 +330,9 @@ void NapiCallAbilityCallback::UnRegisterEnableLteEnhanceModeCallback() int32_t NapiCallAbilityCallback::RegisterDisableLteEnhanceModeCallback(EventCallback callback) { if (disableLteEnhanceCallback_.callbackBeginTime_ != 0) { - if ((time(nullptr) - disableLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { + timespec tmpTime = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tmpTime); + if ((tmpTime.tv_sec - disableLteEnhanceCallback_.callbackBeginTime_) < NAPI_MAX_TIMEOUT_SECOND) { return CALL_ERR_CALLBACK_ALREADY_EXIST; } else { TELEPHONY_LOGE("callback already timeout"); @@ -719,7 +745,7 @@ void NapiCallAbilityCallback::ReportCallStateWork(uv_work_t *work, int32_t statu return; } int32_t ret = ReportCallState(dataWorkerData->info, dataWorkerData->callback); - TELEPHONY_LOGI("%{public}d", ret); + TELEPHONY_LOGI("ReportCallState result = %{public}d", ret); delete dataWorkerData; dataWorkerData = nullptr; delete work; @@ -734,29 +760,28 @@ int32_t NapiCallAbilityCallback::ReportCallState(CallAttributeInfo &info, EventC napi_value callbackFunc = nullptr; napi_env env = stateCallback.env; napi_value callbackValues[ARRAY_INDEX_THIRD] = {0}; - callbackValues[ARRAY_INDEX_FIRST] = NapiCallManagerUtils::CreateUndefined(env); - napi_create_object(env, &callbackValues[ARRAY_INDEX_SECOND]); + napi_create_object(env, &callbackValues[ARRAY_INDEX_FIRST]); NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "accountNumber", info.accountNumber); - NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_SECOND], "accountId", info.accountId); + env, callbackValues[ARRAY_INDEX_FIRST], "accountNumber", info.accountNumber); + NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_FIRST], "accountId", info.accountId); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "videoState", static_cast(info.videoState)); - NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_SECOND], "startTime", info.startTime); - NapiCallManagerUtils::SetPropertyBoolean(env, callbackValues[ARRAY_INDEX_SECOND], "isEcc", info.isEcc); + env, callbackValues[ARRAY_INDEX_FIRST], "videoState", static_cast(info.videoState)); + NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_FIRST], "startTime", info.startTime); + NapiCallManagerUtils::SetPropertyBoolean(env, callbackValues[ARRAY_INDEX_FIRST], "isEcc", info.isEcc); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "callType", static_cast(info.callType)); - NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_SECOND], "callId", info.callId); + env, callbackValues[ARRAY_INDEX_FIRST], "callType", static_cast(info.callType)); + NapiCallManagerUtils::SetPropertyInt32(env, callbackValues[ARRAY_INDEX_FIRST], "callId", info.callId); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "callState", static_cast(info.callState)); + env, callbackValues[ARRAY_INDEX_FIRST], "callState", static_cast(info.callState)); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "conferenceState", static_cast(info.conferenceState)); + env, callbackValues[ARRAY_INDEX_FIRST], "conferenceState", static_cast(info.conferenceState)); napi_get_reference_value(env, stateCallback.callbackRef, &callbackFunc); napi_value callbackResult = nullptr; if (callbackFunc == nullptr) { TELEPHONY_LOGE("callbackFunc is null!"); return CALL_ERR_CALLBACK_NOT_EXIST; } - napi_call_function(env, stateCallback.thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); + napi_call_function(env, stateCallback.thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); return TELEPHONY_SUCCESS; } @@ -808,21 +833,20 @@ int32_t NapiCallAbilityCallback::ReportCallEvent(CallEventInfo &info, EventCallb napi_value callbackFunc = nullptr; napi_env env = eventCallback.env; napi_value callbackValues[ARRAY_INDEX_THIRD] = {0}; - callbackValues[ARRAY_INDEX_FIRST] = NapiCallManagerUtils::CreateUndefined(env); - napi_create_object(env, &callbackValues[ARRAY_INDEX_SECOND]); + napi_create_object(env, &callbackValues[ARRAY_INDEX_FIRST]); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "eventId", static_cast(info.eventId)); + env, callbackValues[ARRAY_INDEX_FIRST], "eventId", static_cast(info.eventId)); NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "accountNumber", info.phoneNum); + env, callbackValues[ARRAY_INDEX_FIRST], "accountNumber", info.phoneNum); NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "bundleName", info.bundleName); + env, callbackValues[ARRAY_INDEX_FIRST], "bundleName", info.bundleName); napi_get_reference_value(env, eventCallback.callbackRef, &callbackFunc); napi_value callbackResult = nullptr; if (callbackFunc == nullptr) { TELEPHONY_LOGE("callbackFunc is null!"); return CALL_ERR_CALLBACK_NOT_EXIST; } - napi_call_function(env, eventCallback.thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); + napi_call_function(env, eventCallback.thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); return TELEPHONY_SUCCESS; } @@ -877,17 +901,16 @@ int32_t NapiCallAbilityCallback::ReportDisconnectedCause(int32_t cause, EventCal napi_value callbackFunc = nullptr; napi_env env = eventCallback.env; napi_value callbackValues[ARRAY_INDEX_THIRD] = {0}; - callbackValues[ARRAY_INDEX_FIRST] = NapiCallManagerUtils::CreateUndefined(env); - napi_create_object(env, &callbackValues[ARRAY_INDEX_SECOND]); + napi_create_object(env, &callbackValues[ARRAY_INDEX_FIRST]); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "disconnectedCause", static_cast(cause)); + env, callbackValues[ARRAY_INDEX_FIRST], "disconnectedCause", static_cast(cause)); napi_get_reference_value(env, eventCallback.callbackRef, &callbackFunc); napi_value callbackResult = nullptr; if (callbackFunc == nullptr) { TELEPHONY_LOGE("callbackFunc is null!"); return CALL_ERR_CALLBACK_NOT_EXIST; } - napi_call_function(env, eventCallback.thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); + napi_call_function(env, eventCallback.thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); return TELEPHONY_SUCCESS; } @@ -926,6 +949,74 @@ int32_t NapiCallAbilityCallback::UpdateAsyncResultsInfo( return result; } +int32_t NapiCallAbilityCallback::UpdateMmiCodeResultsInfo(const MmiCodeInfo &info) +{ + if (mmiCodeCallback_.thisVar == nullptr) { + TELEPHONY_LOGE("mmiCodeCallback is null!"); + return CALL_ERR_CALLBACK_NOT_EXIST; + } + uv_loop_s *loop = nullptr; +#if NAPI_VERSION >= 2 + napi_get_uv_event_loop(mmiCodeCallback_.env, &loop); +#endif + MmiCodeWorker *dataWorker = std::make_unique().release(); + if (dataWorker == nullptr) { + TELEPHONY_LOGE("dataWorker is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + dataWorker->info = info; + dataWorker->callback = mmiCodeCallback_; + uv_work_t *work = std::make_unique().release(); + if (work == nullptr) { + TELEPHONY_LOGE("work is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + work->data = (void *)dataWorker; + uv_queue_work( + loop, work, [](uv_work_t *work) {}, ReportMmiCodeWork); + + return TELEPHONY_SUCCESS; +} + +void NapiCallAbilityCallback::ReportMmiCodeWork(uv_work_t *work, int32_t status) +{ + MmiCodeWorker *dataWorkerData = (MmiCodeWorker *)work->data; + if (dataWorkerData == nullptr) { + TELEPHONY_LOGE("dataWorkerData is nullptr!"); + return; + } + int32_t ret = ReportMmiCode(dataWorkerData->info, dataWorkerData->callback); + TELEPHONY_LOGI("ReportMmiCode result = %{public}d", ret); + delete dataWorkerData; + dataWorkerData = nullptr; + delete work; + work = nullptr; +} + +/** + * To notify an application of MMI code result, register a callback with on() first. + */ +int32_t NapiCallAbilityCallback::ReportMmiCode(MmiCodeInfo &info, EventCallback eventCallback) +{ + napi_value callbackFunc = nullptr; + napi_env env = eventCallback.env; + napi_value callbackValues[ARRAY_INDEX_THIRD] = {0}; + callbackValues[ARRAY_INDEX_FIRST] = NapiCallManagerUtils::CreateUndefined(env); + napi_create_object(env, &callbackValues[ARRAY_INDEX_SECOND]); + NapiCallManagerUtils::SetPropertyInt32( + env, callbackValues[ARRAY_INDEX_SECOND], "result", static_cast(info.result)); + NapiCallManagerUtils::SetPropertyStringUtf8( + env, callbackValues[ARRAY_INDEX_SECOND], "message", info.message); + napi_get_reference_value(env, eventCallback.callbackRef, &callbackFunc); + napi_value callbackResult = nullptr; + if (callbackFunc == nullptr) { + TELEPHONY_LOGE("callbackFunc is null!"); + return CALL_ERR_CALLBACK_NOT_EXIST; + } + napi_call_function(env, eventCallback.thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); + return TELEPHONY_SUCCESS; +} + int32_t NapiCallAbilityCallback::OttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) { if (ottRequestCallback_.thisVar == nullptr) { @@ -1541,24 +1632,23 @@ int32_t NapiCallAbilityCallback::ReportCallOtt( napi_value callbackFunc = nullptr; napi_env env = settingInfo.env; napi_value callbackValues[ARRAY_INDEX_THIRD] = {0}; - callbackValues[ARRAY_INDEX_FIRST] = NapiCallManagerUtils::CreateUndefined(env); - napi_create_object(env, &callbackValues[ARRAY_INDEX_SECOND]); + napi_create_object(env, &callbackValues[ARRAY_INDEX_FIRST]); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "requestId", static_cast(requestId)); + env, callbackValues[ARRAY_INDEX_FIRST], "requestId", static_cast(requestId)); NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "phoneNumber", resultInfo.GetStringValue("phoneNumber").c_str()); + env, callbackValues[ARRAY_INDEX_FIRST], "phoneNumber", resultInfo.GetStringValue("phoneNumber").c_str()); NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "bundleName", resultInfo.GetStringValue("bundleName").c_str()); + env, callbackValues[ARRAY_INDEX_FIRST], "bundleName", resultInfo.GetStringValue("bundleName").c_str()); NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "videoState", resultInfo.GetIntValue("videoState")); + env, callbackValues[ARRAY_INDEX_FIRST], "videoState", resultInfo.GetIntValue("videoState")); switch (requestId) { case OttCallRequestId::OTT_REQUEST_INVITE_TO_CONFERENCE: NapiCallManagerUtils::SetPropertyStringUtf8( - env, callbackValues[ARRAY_INDEX_SECOND], "number", resultInfo.GetStringValue("number").c_str()); + env, callbackValues[ARRAY_INDEX_FIRST], "number", resultInfo.GetStringValue("number").c_str()); break; case OttCallRequestId::OTT_REQUEST_UPDATE_CALL_MEDIA_MODE: NapiCallManagerUtils::SetPropertyInt32( - env, callbackValues[ARRAY_INDEX_SECOND], "callMediaMode", resultInfo.GetIntValue("callMediaMode")); + env, callbackValues[ARRAY_INDEX_FIRST], "callMediaMode", resultInfo.GetIntValue("callMediaMode")); break; default: break; @@ -1570,7 +1660,7 @@ int32_t NapiCallAbilityCallback::ReportCallOtt( TELEPHONY_LOGE("callbackFunc is null!"); return CALL_ERR_CALLBACK_NOT_EXIST; } - napi_call_function(env, settingInfo.thisVar, callbackFunc, DATA_LENGTH_TWO, callbackValues, &callbackResult); + napi_call_function(env, settingInfo.thisVar, callbackFunc, DATA_LENGTH_ONE, callbackValues, &callbackResult); return TELEPHONY_SUCCESS; } } // namespace Telephony diff --git a/frameworks/js/napi/src/napi_call_manager.cpp b/frameworks/js/napi/src/napi_call_manager.cpp old mode 100755 new mode 100644 index 202ce907f807b817326c6fd1a7bad5b8b8dd07a5..ceeda8599eba63d2122f408096746ea88f224852 --- a/frameworks/js/napi/src/napi_call_manager.cpp +++ b/frameworks/js/napi/src/napi_call_manager.cpp @@ -19,7 +19,6 @@ #include #include "system_ability_definition.h" -#include "ability.h" #include "call_manager_errors.h" #include "telephony_log_wrapper.h" @@ -45,6 +44,7 @@ napi_value NapiCallManager::DeclareCallBasisInterface(napi_env env, napi_value e { napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("dial", DialCall), + DECLARE_NAPI_FUNCTION("makeCall", MakeCall), DECLARE_NAPI_FUNCTION("answer", AnswerCall), DECLARE_NAPI_FUNCTION("reject", RejectCall), DECLARE_NAPI_FUNCTION("hangup", HangUpCall), @@ -52,6 +52,7 @@ napi_value NapiCallManager::DeclareCallBasisInterface(napi_env env, napi_value e DECLARE_NAPI_FUNCTION("unHoldCall", UnHoldCall), DECLARE_NAPI_FUNCTION("switchCall", SwitchCall), DECLARE_NAPI_FUNCTION("setCallPreferenceMode", SetCallPreferenceMode), + DECLARE_NAPI_FUNCTION("hasVoiceCapability", HasVoiceCapability), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); return exports; @@ -363,6 +364,346 @@ napi_value NapiCallManager::DeclareCallTransferEnum(napi_env env, napi_value exp return exports; } +/** + * Enumeration type extension. + */ +napi_value NapiCallManager::DeclareAudioDeviceEnum(napi_env env, napi_value exports) +{ + // AudioDevice + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_EARPIECE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_EARPIECE))), + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_SPEAKER", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_SPEAKER))), + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_WIRED_HEADSET", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_WIRED_HEADSET))), + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_BLUETOOTH_SCO", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_BLUETOOTH_SCO))), + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_DISABLE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_DISABLE))), + DECLARE_NAPI_STATIC_PROPERTY("DEVICE_UNKNOWN", + NapiCallManagerUtils::ToInt32Value(env, static_cast(AudioDevice::DEVICE_UNKNOWN))), + }; + napi_value result = nullptr; + napi_define_class(env, "AudioDevice", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "AudioDevice", result); + return exports; +} + +napi_value NapiCallManager::DeclareVideoStateTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("TYPE_VOICE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(VideoStateType::TYPE_VOICE))), + DECLARE_NAPI_STATIC_PROPERTY("TYPE_VIDEO", + NapiCallManagerUtils::ToInt32Value(env, static_cast(VideoStateType::TYPE_VIDEO))), + }; + napi_value result = nullptr; + napi_define_class(env, "VideoStateType", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "VideoStateType", result); + return exports; +} + +napi_value NapiCallManager::DeclareImsCallModeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY( + "CALL_MODE_AUDIO_ONLY", NapiCallManagerUtils::ToInt32Value(env, CALL_MODE_AUDIO_ONLY)), + DECLARE_NAPI_STATIC_PROPERTY( + "CALL_MODE_SEND_RECEIVE", NapiCallManagerUtils::ToInt32Value(env, CALL_MODE_SEND_RECEIVE)), + }; + napi_value result = nullptr; + napi_define_class(env, "ImsCallMode", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "ImsCallMode", result); + return exports; +} + +napi_value NapiCallManager::DeclareDialSceneEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY( + "CALL_NORMAL", NapiCallManagerUtils::ToInt32Value(env, static_cast(DialScene::CALL_NORMAL))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_PRIVILEGED", + NapiCallManagerUtils::ToInt32Value(env, static_cast(DialScene::CALL_PRIVILEGED))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_EMERGENCY", + NapiCallManagerUtils::ToInt32Value(env, static_cast(DialScene::CALL_EMERGENCY))), + }; + napi_value result = nullptr; + napi_define_class(env, "DialScene", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "DialScene", result); + return exports; +} + +napi_value NapiCallManager::DeclareCallTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY( + "TYPE_CS", NapiCallManagerUtils::ToInt32Value(env, static_cast(CallType::TYPE_CS))), + DECLARE_NAPI_STATIC_PROPERTY( + "TYPE_IMS", NapiCallManagerUtils::ToInt32Value(env, static_cast(CallType::TYPE_IMS))), + DECLARE_NAPI_STATIC_PROPERTY( + "TYPE_OTT", NapiCallManagerUtils::ToInt32Value(env, static_cast(CallType::TYPE_OTT))), + DECLARE_NAPI_STATIC_PROPERTY("TYPE_ERR_CALL", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallType::TYPE_ERR_CALL))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallType", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallType", result); + return exports; +} + +napi_value NapiCallManager::DeclareDialTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("DIAL_CARRIER_TYPE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(DialType::DIAL_CARRIER_TYPE))), + DECLARE_NAPI_STATIC_PROPERTY("DIAL_VOICE_MAIL_TYPE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(DialType::DIAL_VOICE_MAIL_TYPE))), + DECLARE_NAPI_STATIC_PROPERTY("DIAL_OTT_TYPE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(DialType::DIAL_OTT_TYPE))), + }; + napi_value result = nullptr; + napi_define_class(env, "DialType", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "DialType", result); + return exports; +} + +napi_value NapiCallManager::DeclareTelCallStateEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_ACTIVE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_ACTIVE))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_HOLDING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_HOLDING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_DIALING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_DIALING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_ALERTING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_ALERTING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_INCOMING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_INCOMING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_WAITING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_WAITING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_DISCONNECTED", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_DISCONNECTED))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_DISCONNECTING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_DISCONNECTING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATUS_IDLE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelCallState::CALL_STATUS_IDLE))), + }; + napi_value result = nullptr; + napi_define_class(env, "TelCallState", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "TelCallState", result); + return exports; +} + +napi_value NapiCallManager::DeclareConferenceStateEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("TEL_CONFERENCE_IDLE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(TelConferenceState::TEL_CONFERENCE_IDLE))), + DECLARE_NAPI_STATIC_PROPERTY("TEL_CONFERENCE_ACTIVE", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(TelConferenceState::TEL_CONFERENCE_ACTIVE))), + DECLARE_NAPI_STATIC_PROPERTY("TEL_CONFERENCE_HOLDING", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(TelConferenceState::TEL_CONFERENCE_HOLDING))), + DECLARE_NAPI_STATIC_PROPERTY("TEL_CONFERENCE_DISCONNECTING", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(TelConferenceState::TEL_CONFERENCE_DISCONNECTING))), + DECLARE_NAPI_STATIC_PROPERTY("TEL_CONFERENCE_DISCONNECTED", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(TelConferenceState::TEL_CONFERENCE_DISCONNECTED))), + }; + napi_value result = nullptr; + napi_define_class(env, "TelConferenceState", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "TelConferenceState", result); + return exports; +} + +napi_value NapiCallManager::DeclareCallStateToAppEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATE_UNKNOWN", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallStateToApp::CALL_STATE_UNKNOWN))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATE_IDLE", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallStateToApp::CALL_STATE_IDLE))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATE_RINGING", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallStateToApp::CALL_STATE_RINGING))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_STATE_OFFHOOK", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallStateToApp::CALL_STATE_OFFHOOK))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallStateToApp", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallStateToApp", result); + return exports; +} + +napi_value NapiCallManager::DeclareCallEventEnumEx(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + // CallAbilityEventId + DECLARE_NAPI_STATIC_PROPERTY("EVENT_DIAL_NO_CARRIER", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallAbilityEventId::EVENT_DIAL_NO_CARRIER))), + DECLARE_NAPI_STATIC_PROPERTY("EVENT_INVALID_FDN_NUMBER", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallAbilityEventId::EVENT_INVALID_FDN_NUMBER))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallAbilityEventId", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallAbilityEventId", result); + return exports; +} + +napi_value NapiCallManager::DeclareRestrictionTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_ALL_OUTGOING", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_ALL_OUTGOING))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_INTERNATIONAL", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_INTERNATIONAL))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_ALL_INCOMING", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_ALL_INCOMING))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_ROAMING_INCOMING", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_ROAMING_INCOMING))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_ALL_CALLS", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_ALL_CALLS))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_OUTGOING_SERVICES", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_OUTGOING_SERVICES))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_TYPE_INCOMING_SERVICES", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionType::RESTRICTION_TYPE_INCOMING_SERVICES))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallRestrictionType", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallRestrictionType", result); + return exports; +} + +napi_value NapiCallManager::DeclareRestrictionModeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_MODE_DEACTIVATION", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionMode::RESTRICTION_MODE_DEACTIVATION))), + DECLARE_NAPI_STATIC_PROPERTY("RESTRICTION_MODE_ACTIVATION", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallRestrictionMode::RESTRICTION_MODE_ACTIVATION))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallRestrictionMode", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallRestrictionMode", result); + return exports; +} + +napi_value NapiCallManager::DeclareRestrictionStatusEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY( + "RESTRICTION_DISABLE", NapiCallManagerUtils::ToInt32Value(env, RESTRICTION_DISABLE)), + DECLARE_NAPI_STATIC_PROPERTY( + "RESTRICTION_ENABLE", NapiCallManagerUtils::ToInt32Value(env, RESTRICTION_ENABLE)), + }; + napi_value result = nullptr; + napi_define_class(env, "RestrictionStatus", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "RestrictionStatus", result); + return exports; +} + +napi_value NapiCallManager::DeclareCallWaitingEnumEx(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY( + "CALL_WAITING_DISABLE", NapiCallManagerUtils::ToInt32Value(env, CALL_WAITING_DISABLE)), + DECLARE_NAPI_STATIC_PROPERTY( + "CALL_WAITING_ENABLE", NapiCallManagerUtils::ToInt32Value(env, CALL_WAITING_ENABLE)), + }; + napi_value result = nullptr; + napi_define_class(env, "CallWaitingStatus", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallWaitingStatus", result); + return exports; +} + +napi_value NapiCallManager::DeclareTransferStatusEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_DISABLE", NapiCallManagerUtils::ToInt32Value(env, TRANSFER_DISABLE)), + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_ENABLE", NapiCallManagerUtils::ToInt32Value(env, TRANSFER_ENABLE)), + }; + napi_value result = nullptr; + napi_define_class(env, "TransferStatus", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "TransferStatus", result); + return exports; +} + +napi_value NapiCallManager::DeclareTransferTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_TYPE_UNCONDITIONAL", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferType::TRANSFER_TYPE_UNCONDITIONAL))), + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_TYPE_BUSY", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallTransferType::TRANSFER_TYPE_BUSY))), + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_TYPE_NO_REPLY", + NapiCallManagerUtils::ToInt32Value(env, static_cast(CallTransferType::TRANSFER_TYPE_NO_REPLY))), + DECLARE_NAPI_STATIC_PROPERTY("TRANSFER_TYPE_NOT_REACHABLE", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferType::TRANSFER_TYPE_NOT_REACHABLE))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallTransferType", NAPI_AUTO_LENGTH, NapiCallManagerUtils::CreateEnumConstructor, + nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallTransferType", result); + return exports; +} + +napi_value NapiCallManager::DeclareTransferSettingTypeEnum(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("CALL_TRANSFER_ENABLE", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferSettingType::CALL_TRANSFER_ENABLE))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_TRANSFER_DISABLE", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferSettingType::CALL_TRANSFER_DISABLE))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_TRANSFER_REGISTRATION", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferSettingType::CALL_TRANSFER_REGISTRATION))), + DECLARE_NAPI_STATIC_PROPERTY("CALL_TRANSFER_ERASURE", + NapiCallManagerUtils::ToInt32Value( + env, static_cast(CallTransferSettingType::CALL_TRANSFER_ERASURE))), + }; + napi_value result = nullptr; + napi_define_class(env, "CallTransferSettingType", NAPI_AUTO_LENGTH, + NapiCallManagerUtils::CreateEnumConstructor, nullptr, sizeof(desc) / sizeof(*desc), desc, &result); + napi_set_named_property(env, exports, "CallTransferSettingType", result); + return exports; +} + /** * The call_manager is initialized. */ @@ -383,6 +724,24 @@ napi_value NapiCallManager::RegisterCallManagerFunc(napi_env env, napi_value exp DeclareCallWaitingEnum(env, exports); DeclareCallTransferEnum(env, exports); DeclareCallImsInterface(env, exports); + // Enumeration class extension initialization + DeclareAudioDeviceEnum(env, exports); + DeclareVideoStateTypeEnum(env, exports); + DeclareImsCallModeEnum(env, exports); + DeclareDialSceneEnum(env, exports); + DeclareCallTypeEnum(env, exports); + DeclareDialTypeEnum(env, exports); + DeclareTelCallStateEnum(env, exports); + DeclareConferenceStateEnum(env, exports); + DeclareCallStateToAppEnum(env, exports); + DeclareCallEventEnumEx(env, exports); + DeclareRestrictionTypeEnum(env, exports); + DeclareRestrictionModeEnum(env, exports); + DeclareRestrictionStatusEnum(env, exports); + DeclareCallWaitingEnumEx(env, exports); + DeclareTransferStatusEnum(env, exports); + DeclareTransferTypeEnum(env, exports); + DeclareTransferSettingTypeEnum(env, exports); Init(); return exports; } @@ -410,6 +769,21 @@ napi_value NapiCallManager::DialCall(napi_env env, napi_callback_info info) return HandleAsyncWork(env, asyncContext, "DialCall", NativeDialCall, NativeDialCallBack); } +napi_value NapiCallManager::MakeCall(napi_env env, napi_callback_info info) +{ + GET_PARAMS(env, info, TWO_VALUE_LIMIT); + NAPI_ASSERT(env, argc <= TWO_VALUE_LIMIT, "parameter error!"); + bool matchFlag = NapiCallManagerUtils::MatchValueType(env, argv[ARRAY_INDEX_FIRST], napi_string); + NAPI_ASSERT(env, matchFlag, "Type error, should be string type"); + auto asyncContext = (std::make_unique()).release(); + napi_get_value_string_utf8(env, argv[ARRAY_INDEX_FIRST], asyncContext->number, PHONE_NUMBER_MAXIMUM_LIMIT, + &(asyncContext->numberLen)); + if (argc == TWO_VALUE_LIMIT) { + napi_create_reference(env, argv[ARRAY_INDEX_SECOND], DATA_LENGTH_ONE, &(asyncContext->callbackRef)); + } + return HandleAsyncWork(env, asyncContext, "MakeCall", NativeMakeCall, NativeVoidCallBack); +} + napi_value NapiCallManager::AnswerCall(napi_env env, napi_callback_info info) { GET_PARAMS(env, info, VALUE_MAXIMUM_LIMIT); @@ -944,6 +1318,13 @@ napi_value NapiCallManager::ObserverOn(napi_env env, napi_callback_info info) causeCallback.thisVar = thisVar; napi_create_reference(env, argv[ARRAY_INDEX_SECOND], DATA_LENGTH_ONE, &causeCallback.callbackRef); DelayedSingleton::GetInstance()->RegisterDisconnectedCauseCallback(causeCallback); + } else if (tmpStr == "mmiCodeResult") { + EventCallback mmiCodeResultListener; + (void)memset_s(&mmiCodeResultListener, sizeof(EventCallback), 0, sizeof(EventCallback)); + mmiCodeResultListener.env = env; + mmiCodeResultListener.thisVar = thisVar; + napi_create_reference(env, argv[ARRAY_INDEX_SECOND], DATA_LENGTH_ONE, &mmiCodeResultListener.callbackRef); + DelayedSingleton::GetInstance()->RegisterMmiCodeCallback(mmiCodeResultListener); } napi_value result = nullptr; return result; @@ -969,6 +1350,8 @@ napi_value NapiCallManager::ObserverOff(napi_env env, napi_callback_info info) DelayedSingleton::GetInstance()->UnRegisterCallOttRequestCallback(); } else if (tmpStr == "callDisconnectedCause") { DelayedSingleton::GetInstance()->UnRegisterDisconnectedCauseCallback(); + } else if (tmpStr == "mmiCodeResult") { + DelayedSingleton::GetInstance()->UnRegisterMmiCodeCallback(); } asyncContext->result = TELEPHONY_SUCCESS; if (argc == TWO_VALUE_LIMIT) { @@ -1308,11 +1691,11 @@ napi_value NapiCallManager::ReportOttCallDetailsInfo(napi_env env, napi_callback bool matchFlag = NapiCallManagerUtils::MatchValueType(env, napiFormId, napi_object); NAPI_ASSERT(env, matchFlag, "Type error, should be napi_object type"); std::string tmpStr = NapiCallManagerUtils::GetStringProperty(env, napiFormId, "phoneNumber"); - if (memcpy_s(tmpOttVec.phoneNum, kMaxNumberLen, tmpStr.c_str(), tmpStr.length()) != 0) { + if (memcpy_s(tmpOttVec.phoneNum, kMaxNumberLen, tmpStr.c_str(), tmpStr.length()) != EOK) { return (napi_value) nullptr; } tmpStr = NapiCallManagerUtils::GetStringProperty(env, napiFormId, "bundleName"); - if (memcpy_s(tmpOttVec.bundleName, kMaxNumberLen, tmpStr.c_str(), tmpStr.length()) != 0) { + if (memcpy_s(tmpOttVec.bundleName, kMaxNumberLen, tmpStr.c_str(), tmpStr.length()) != EOK) { return (napi_value) nullptr; } int32_t tmpValue = NapiCallManagerUtils::GetIntProperty(env, napiFormId, "videoState"); @@ -1344,6 +1727,14 @@ napi_value NapiCallManager::ReportOttCallEventInfo(napi_env env, napi_callback_i env, asyncContext, "ReportOttCallEventInfo", NativeReportOttCallEventInfo, NativeVoidCallBack); } +napi_value NapiCallManager::HasVoiceCapability(napi_env env, napi_callback_info) +{ + TELEPHONY_LOGI("napi_call HasVoiceCapability"); + napi_value result = nullptr; + napi_get_boolean(env, DelayedSingleton::GetInstance()->HasVoiceCapability(), &result); + return result; +} + void NapiCallManager::NativeCallBack(napi_env env, napi_status status, void *data) { if (data == nullptr) { @@ -1379,6 +1770,7 @@ void NapiCallManager::NativeCallBack(napi_env env, napi_status status, void *dat } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativeDialCallBack(napi_env env, napi_status status, void *data) @@ -1416,6 +1808,7 @@ void NapiCallManager::NativeDialCallBack(napi_env env, napi_status status, void } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativeVoidCallBack(napi_env env, napi_status status, void *data) @@ -1457,6 +1850,7 @@ void NapiCallManager::NativeVoidCallBack(napi_env env, napi_status status, void } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativePropertyCallBack(napi_env env, napi_status status, void *data) @@ -1482,6 +1876,7 @@ void NapiCallManager::NativePropertyCallBack(napi_env env, napi_status status, v } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativeBoolCallBack(napi_env env, napi_status status, void *data) @@ -1526,6 +1921,7 @@ void NapiCallManager::NativeBoolCallBack(napi_env env, napi_status status, void } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativeFormatNumberCallBack(napi_env env, napi_status status, void *data) @@ -1565,6 +1961,7 @@ void NapiCallManager::NativeFormatNumberCallBack(napi_env env, napi_status statu } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::NativeListCallBack(napi_env env, napi_status status, void *data) @@ -1579,7 +1976,7 @@ void NapiCallManager::NativeListCallBack(napi_env env, napi_status status, void napi_create_array(env, &promiseValue); std::vector::iterator it = asyncContext->listResult.begin(); int32_t i = 0; - for (; it != asyncContext->listResult.end(); it++) { + for (; it != asyncContext->listResult.end(); ++it) { napi_value info = nullptr; napi_create_string_utf8(env, Str16ToStr8(*it).data(), (*it).length(), &info); napi_set_element(env, promiseValue, i, info); @@ -1592,7 +1989,7 @@ void NapiCallManager::NativeListCallBack(napi_env env, napi_status status, void napi_create_array(env, &callbackValue[ARRAY_INDEX_SECOND]); std::vector::iterator it = asyncContext->listResult.begin(); int32_t i = 0; - for (; it != asyncContext->listResult.end(); it++) { + for (; it != asyncContext->listResult.end(); ++it) { napi_value info = nullptr; napi_create_string_utf8(env, Str16ToStr8(*it).data(), (*it).length(), &info); napi_set_element(env, callbackValue[ARRAY_INDEX_SECOND], i, info); @@ -1606,6 +2003,7 @@ void NapiCallManager::NativeListCallBack(napi_env env, napi_status status, void } napi_delete_async_work(env, asyncContext->work); delete asyncContext; + asyncContext = nullptr; } void NapiCallManager::GetDialInfo(napi_env env, napi_value objValue, DialAsyncContext &asyncContext) @@ -1634,8 +2032,8 @@ int32_t NapiCallManager::GetRestrictionInfo( } asyncContext.info.fac = static_cast(type); asyncContext.info.mode = static_cast(mode); - TELEPHONY_LOGI("GetRestrictionInfo: type = %{public}d, mode = %{public}d, content = %{public}s", - asyncContext.info.fac, asyncContext.info.mode, asyncContext.info.password); + TELEPHONY_LOGI("GetRestrictionInfo: type = %{public}d, mode = %{public}d", + asyncContext.info.fac, asyncContext.info.mode); return TELEPHONY_SUCCESS; } @@ -1654,7 +2052,7 @@ int32_t NapiCallManager::GetTransferInfo(napi_env env, napi_value objValue, Call } asyncContext.info.settingType = static_cast(settingType); asyncContext.info.type = static_cast(type); - TELEPHONY_LOGI("GetRestrictionInfo: type = %{public}d, settingType = %{public}d, transferNum = %{public}s", + TELEPHONY_LOGI("GetTransferInfo: type = %{public}d, settingType = %{public}d, transferNum = %{public}s", asyncContext.info.type, asyncContext.info.settingType, asyncContext.info.transferNum); return TELEPHONY_SUCCESS; } @@ -1676,6 +2074,17 @@ void NapiCallManager::NativeDialCall(napi_env env, void *data) DelayedSingleton::GetInstance()->DialCall(Str8ToStr16(phoneNumber), dialInfo); } +void NapiCallManager::NativeMakeCall(napi_env env, void *data) +{ + if (data == nullptr) { + TELEPHONY_LOGE("data is nullptr"); + return; + } + auto asyncContext = (AsyncContext *)data; + std::string phoneNumber(asyncContext->number, asyncContext->numberLen); + asyncContext->result = DelayedSingleton::GetInstance()->MakeCall(phoneNumber); +} + void NapiCallManager::NativeAnswerCall(napi_env env, void *data) { if (data == nullptr) { @@ -2224,6 +2633,13 @@ void NapiCallManager::NativeSetAudioDevice(napi_env env, void *data) AudioDevice type; auto asyncContext = (AudioAsyncContext *)data; type = static_cast(asyncContext->dudioDevice); + + // For interface compatibility, when AudioDevice::DEVICE_MIC is deleted, this code block should also be deleted + // When the parameter passed is DEVICE_MIC, point to DEVICE_EARPIECE + int32_t DEVICE_MIC = 4; + if (static_cast(type) == DEVICE_MIC) { + type = AudioDevice::DEVICE_EARPIECE; + } asyncContext->result = DelayedSingleton::GetInstance()->SetAudioDevice(type); } @@ -2577,4 +2993,4 @@ extern "C" __attribute__((constructor)) void RegisterModule(void) napi_module_register(&g_nativeCallManagerModule); } } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/frameworks/js/napi/src/napi_call_manager_callback.cpp b/frameworks/js/napi/src/napi_call_manager_callback.cpp old mode 100755 new mode 100644 index 15af8e4973a6e9a9a76412b185b64787b04ad1f4..ee817e4c8c22ad814bdb25675d3428d4a67b0bb1 --- a/frameworks/js/napi/src/napi_call_manager_callback.cpp +++ b/frameworks/js/napi/src/napi_call_manager_callback.cpp @@ -67,6 +67,17 @@ int32_t NapiCallManagerCallback::OnReportAsyncResults(CallResultReportId reportI return ret; } +int32_t NapiCallManagerCallback::OnReportMmiCodeResult(const MmiCodeInfo &info) +{ + int32_t ret = DelayedSingleton::GetInstance()->UpdateMmiCodeResultsInfo(info); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("UpdateMmiCodeInfo failed! errCode:%{public}d", ret); + } else { + TELEPHONY_LOGI("UpdateMmiCodeInfo success!"); + } + return ret; +} + int32_t NapiCallManagerCallback::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) { int32_t ret = DelayedSingleton::GetInstance()->OttCallRequest(requestId, info); diff --git a/frameworks/js/napi/src/napi_call_manager_utils.cpp b/frameworks/js/napi/src/napi_call_manager_utils.cpp old mode 100755 new mode 100644 index a56b87cd5d9050c4be8e887165571ed97b255ecb..2f475c9de14e346eb7570d23fbbe4c73de21217e --- a/frameworks/js/napi/src/napi_call_manager_utils.cpp +++ b/frameworks/js/napi/src/napi_call_manager_utils.cpp @@ -16,7 +16,6 @@ #include "napi_call_manager_utils.h" #include "system_ability_definition.h" -#include "ability.h" #include "telephony_log_wrapper.h" @@ -128,5 +127,15 @@ void NapiCallManagerUtils::SetPropertyBoolean(napi_env env, napi_value object, s napi_get_boolean(env, value, &peopertyValue); napi_set_named_property(env, object, name.c_str(), peopertyValue); } + +napi_value NapiCallManagerUtils::CreateEnumConstructor(napi_env env, napi_callback_info info) +{ + napi_value thisArg = nullptr; + void *data = nullptr; + napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, &data); + napi_value global = nullptr; + napi_get_global(env, &global); + return thisArg; +} } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn old mode 100755 new mode 100644 index ddf72ff5fc698a181b0fa80ac11099fc7bc1f970..d03c4d8b0f4c3302e33e02703bcdd4fad89a08e9 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/telephony/call_manager/call_manager_aafwk.gni") import("//build/ohos.gni") SUBSYSTEM_DIR = "//base/telephony" @@ -19,11 +20,15 @@ config("call_manager_config") { "$SUBSYSTEM_DIR/call_manager/frameworks/native/include", "$SUBSYSTEM_DIR/call_manager/interfaces/innerkits", "$SUBSYSTEM_DIR/call_manager/utils/include", + "${aafwk_inner_api_path}/ability_manager/include", + "${aafwk_inner_api_path}/app_manager/include/appmgr", ] } ohos_shared_library("tel_call_manager_api") { sources = [ + "src/bluetooth_call_client.cpp", + "src/bluetooth_call_proxy.cpp", "src/call_ability_callback.cpp", "src/call_ability_callback_stub.cpp", "src/call_manager_client.cpp", @@ -38,11 +43,14 @@ ohos_shared_library("tel_call_manager_api") { deps = [ "//utils/native/base:utils" ] external_deps = [ - "ability_runtime:want", + "ability_base:base", + "ability_base:want", + "ability_runtime:ability_manager", "core_service:tel_core_service_api", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] defines = [ diff --git a/frameworks/native/include/bluetooth_call_proxy.h b/frameworks/native/include/bluetooth_call_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..02c8a54d8303bd94bca64ee1f0d667441af4d0b8 --- /dev/null +++ b/frameworks/native/include/bluetooth_call_proxy.h @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2021 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 BLUETOOTH_CALL_PROXY_H +#define BLUETOOTH_CALL_PROXY_H + +#include +#include + +#include "iremote_broker.h" +#include "iremote_proxy.h" +#include "pac_map.h" + +#include "call_manager_inner_type.h" +#include "i_bluetooth_call.h" +#include "telephony_log_wrapper.h" + +namespace OHOS { +namespace Telephony { +class BluetoothCallProxy : public IRemoteProxy { +public: + /** + * BluetoothCallProxy + * + * @param impl + */ + explicit BluetoothCallProxy(const sptr &impl); + virtual ~BluetoothCallProxy() = default; + + /** + * AnswerCall + * + * @brief Answer a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t AnswerCall() override; + + /** + * RejectCall + * + * @brief Reject a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t RejectCall() override; + + /** + * HangUpCall + * + * @brief Hang up the phone + * @return Returns 0 on success, others on failure. + */ + int32_t HangUpCall() override; + + /** + * GetCallState + * + * @brief Obtain the call status of the device + * @return Returns 0 on success, others on failure. + */ + int32_t GetCallState() override; + + /** + * HoldCall + * + * @brief Park a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t HoldCall() override; + + /** + * UnHoldCall + * + * @brief Activate a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t UnHoldCall() override; + + /** + * SwitchCall + * + * @brief Switch the phone + * @return Returns 0 on success, others on failure. + */ + int32_t SwitchCall() override; + + /** + * StartDtmf + * + * @brief Enable and send DTMF + * @param str[in], Characters sent + * @return Returns 0 on success, others on failure. + */ + int32_t StartDtmf(char str) override; + + /** + * StopDtmf + * + * @brief Stop the DTMF + * @return Returns 0 on success, others on failure. + */ + int32_t StopDtmf() override; + + /** + * CombineConference + * + * @brief Merge calls to form a conference + * @return Returns 0 on success, others on failure. + */ + int32_t CombineConference() override; + + /** + * SeparateConference + * + * @brief Separates a specified call from a conference call + * @return Returns 0 on success, others on failure. + */ + int32_t SeparateConference() override; + + /** + * GetCurrentCallList + * + * @brief Get current call list + * @param slotId[in], The slot id + * @return Returns call info list. + */ + std::vector GetCurrentCallList(int32_t slotId) override; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace Telephony +} // namespace OHOS + +#endif // BLUETOOTH_CALL_PROXY_H \ No newline at end of file diff --git a/frameworks/native/include/call_ability_callback.h b/frameworks/native/include/call_ability_callback.h old mode 100755 new mode 100644 index d891b64f1da7b6aac6108b3781f9b763d16fea50..b7fab088ec8ad121ecf0a2e8e585b74776b09420 --- a/frameworks/native/include/call_ability_callback.h +++ b/frameworks/native/include/call_ability_callback.h @@ -36,6 +36,7 @@ public: int32_t OnCallDisconnectedCause(DisconnectedDetails cause) override; int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) override; int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) override; + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) override; private: std::unique_ptr callbackPtr_; diff --git a/frameworks/native/include/call_ability_callback_death_recipient.h b/frameworks/native/include/call_ability_callback_death_recipient.h old mode 100755 new mode 100644 diff --git a/frameworks/native/include/call_ability_callback_stub.h b/frameworks/native/include/call_ability_callback_stub.h old mode 100755 new mode 100644 index e37a0e0067f3aae220c496d1f60b1ebe0b71a980..90c01847bd5d49e44d773aef2529813712a94738 --- a/frameworks/native/include/call_ability_callback_stub.h +++ b/frameworks/native/include/call_ability_callback_stub.h @@ -40,6 +40,7 @@ private: int32_t OnUpdateCallDisconnectedCause(MessageParcel &data, MessageParcel &reply); int32_t OnUpdateAysncResults(MessageParcel &data, MessageParcel &reply); int32_t OnUpdateOttCallRequest(MessageParcel &data, MessageParcel &reply); + int32_t OnUpdateMmiCodeResults(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; }; diff --git a/frameworks/native/include/call_manager_death_recipient.h b/frameworks/native/include/call_manager_death_recipient.h old mode 100755 new mode 100644 diff --git a/frameworks/native/include/call_manager_proxy.h b/frameworks/native/include/call_manager_proxy.h old mode 100755 new mode 100644 index d2b18a871a657a632d46c43383443e2f7c820705..975a2300f6a818a29025b725b2324bdfdc325f1d --- a/frameworks/native/include/call_manager_proxy.h +++ b/frameworks/native/include/call_manager_proxy.h @@ -96,6 +96,7 @@ public: int32_t JoinConference(int32_t callId, std::vector &numberList); int32_t ReportOttCallDetailsInfo(std::vector &ottVec); int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo); + sptr GetProxyObjectPtr(CallManagerProxyType proxyType); private: static void task(); diff --git a/frameworks/native/include/call_manager_service_proxy.h b/frameworks/native/include/call_manager_service_proxy.h old mode 100755 new mode 100644 index cd1ed92626a1f19ff07e327ee5218546435288c4..008dcef2907ebdc33ea2bd745b634b15b3285f7e --- a/frameworks/native/include/call_manager_service_proxy.h +++ b/frameworks/native/include/call_manager_service_proxy.h @@ -567,9 +567,17 @@ public: */ int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo) override; + /** + * GetProxyObjectPtr + * + * @brief get callManager proxy object ptr + * @param proxyType[in], proxy type + * @return Returns nullptr on failure, others on success. + */ + sptr GetProxyObjectPtr(CallManagerProxyType proxyType) override; + private: static inline BrokerDelegator delegator_; - static constexpr HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, LOG_DOMAIN, "CallManager"}; }; } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/include/cellular_call_callback_death_recipient.h b/frameworks/native/include/cellular_call_callback_death_recipient.h old mode 100755 new mode 100644 diff --git a/frameworks/native/include/i_bluetooth_call.h b/frameworks/native/include/i_bluetooth_call.h new file mode 100644 index 0000000000000000000000000000000000000000..ae6a62ae6d6346e359f6edb8a2dc05f23b6b516e --- /dev/null +++ b/frameworks/native/include/i_bluetooth_call.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 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 I_BLUETOOTH_CALL_H +#define I_BLUETOOTH_CALL_H + +#include +#include +#include + +#include "iremote_broker.h" +#include "pac_map.h" + +#include "call_manager_inner_type.h" + +namespace OHOS { +namespace Telephony { +extern "C" { +enum BluetoothCallSurfaceCode { + INTERFACE_BT_ANSWER_CALL = 0, + INTERFACE_BT_REJECT_CALL, + INTERFACE_BT_HOLD_CALL, + INTERFACE_BT_UNHOLD_CALL, + INTERFACE_BT_DISCONNECT_CALL, + INTERFACE_BT_GET_CALL_STATE, + INTERFACE_BT_SWAP_CALL, + INTERFACE_BT_COMBINE_CONFERENCE, + INTERFACE_BT_SEPARATE_CONFERENCE, + INTERFACE_BT_START_DTMF, + INTERFACE_BT_STOP_DTMF, + INTERFACE_BT_GET_CURRENT_CALL_LIST, +}; +} // end extern + +class IBluetoothCall : public IRemoteBroker { +public: + virtual ~IBluetoothCall() = default; + virtual int32_t AnswerCall() = 0; + virtual int32_t RejectCall() = 0; + virtual int32_t HangUpCall() = 0; + virtual int32_t GetCallState() = 0; + virtual int32_t HoldCall() = 0; + virtual int32_t UnHoldCall() = 0; + virtual int32_t SwitchCall() = 0; + virtual int32_t CombineConference() = 0; + virtual int32_t SeparateConference() = 0; + virtual int32_t StartDtmf(char str) = 0; + virtual int32_t StopDtmf() = 0; + virtual std::vector GetCurrentCallList(int32_t slotId) = 0; + +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.IBluetoothCall"); +}; +} // namespace Telephony +} // namespace OHOS + +#endif // I_BLUETOOTH_CALL_H \ No newline at end of file diff --git a/frameworks/native/include/i_call_ability_callback.h b/frameworks/native/include/i_call_ability_callback.h old mode 100755 new mode 100644 index b43165f044787f46dc17f8c7405d9911449358c7..f48e910aa3c6c4d4a3fc54eed069f561cc9248dc --- a/frameworks/native/include/i_call_ability_callback.h +++ b/frameworks/native/include/i_call_ability_callback.h @@ -25,6 +25,7 @@ namespace OHOS { namespace Telephony { class ICallAbilityCallback : public IRemoteBroker { public: + ICallAbilityCallback() : bundleName_("") {} virtual ~ICallAbilityCallback() = default; virtual int32_t OnCallDetailsChange(const CallAttributeInfo &info) = 0; @@ -32,14 +33,15 @@ public: virtual int32_t OnCallDisconnectedCause(DisconnectedDetails cause) = 0; virtual int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) = 0; virtual int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) = 0; + virtual int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) = 0; void SetBundleName(std::string &name) { bundleName_ = name; } - void GetBundleName(std::string &name) + std::string GetBundleName() { - name = bundleName_; + return bundleName_; } enum CallManagerCallAbilityCode { @@ -48,10 +50,11 @@ public: UPDATE_CALL_DISCONNECTED_CAUSE, UPDATE_CALL_ASYNC_RESULT_REQUEST, REPORT_OTT_CALL_REQUEST, + UPDATE_MMI_CODE_RESULT_REQUEST, }; public: - std::string bundleName_ = ""; + std::string bundleName_; DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.ICallAbilityCallback"); }; } // namespace Telephony diff --git a/frameworks/native/include/i_call_manager_service.h b/frameworks/native/include/i_call_manager_service.h old mode 100755 new mode 100644 index 35f78a7813dd657e11b73425fdb8220aa3d4b9f5..33af1018119c0e2a542d852324653e4663108560 --- a/frameworks/native/include/i_call_manager_service.h +++ b/frameworks/native/include/i_call_manager_service.h @@ -86,6 +86,11 @@ enum CallManagerSurfaceCode { INTERFACE_JOIN_CONFERENCE, INTERFACE_REPORT_OTT_CALL_DETAIL_INFO, INTERFACE_REPORT_OTT_CALL_EVENT_INFO, + INTERFACE_GET_PROXY_OBJECT_PTR, +}; + +enum CallManagerProxyType { + PROXY_BLUETOOTH_CALL = 0, }; } // end extern @@ -150,6 +155,7 @@ public: virtual int32_t JoinConference(int32_t callId, std::vector &numberList) = 0; virtual int32_t ReportOttCallDetailsInfo(std::vector &ottVec) = 0; virtual int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo) = 0; + virtual sptr GetProxyObjectPtr(CallManagerProxyType proxyType) = 0; public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.ICallManagerService"); diff --git a/frameworks/native/src/bluetooth_call_client.cpp b/frameworks/native/src/bluetooth_call_client.cpp new file mode 100644 index 0000000000000000000000000000000000000000..afb371e7cf9e1cfc848fe89b279ee704e5c008bf --- /dev/null +++ b/frameworks/native/src/bluetooth_call_client.cpp @@ -0,0 +1,290 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_client.h" + +#include + +#include "system_ability_definition.h" + +#include "telephony_errors.h" + +#include "bluetooth_call_proxy.h" +#include "call_manager_proxy.h" + +namespace OHOS { +namespace Telephony { +static std::shared_ptr g_callManagerProxyPtr = nullptr; +static sptr g_bluetoothCallProxyPtr = nullptr; + +BluetoothCallClient::BluetoothCallClient() {} + +BluetoothCallClient::~BluetoothCallClient() {} + +void BluetoothCallClient::Init() +{ + if (g_callManagerProxyPtr == nullptr) { + g_callManagerProxyPtr = DelayedSingleton::GetInstance(); + if (g_callManagerProxyPtr == nullptr) { + TELEPHONY_LOGE("g_callManagerProxyPtr is nullptr"); + return; + } + g_callManagerProxyPtr->Init(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID); + sptr iRemoteObjectPtr = g_callManagerProxyPtr->GetProxyObjectPtr(PROXY_BLUETOOTH_CALL); + if (iRemoteObjectPtr == nullptr) { + TELEPHONY_LOGE("GetProxyObjectPtr failed!"); + return; + } + g_bluetoothCallProxyPtr = iface_cast(iRemoteObjectPtr); + if (g_bluetoothCallProxyPtr == nullptr) { + TELEPHONY_LOGE("iface_cast failed!"); + return; + } + TELEPHONY_LOGI("BluetoothCallClient init success!"); + } +} + +void BluetoothCallClient::UnInit() +{ + if (g_callManagerProxyPtr != nullptr) { + g_callManagerProxyPtr->UnInit(); + } else { + TELEPHONY_LOGE("init first please!"); + } +} + +int32_t BluetoothCallClient::RegisterCallBack(std::unique_ptr callback) +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->RegisterCallBack(std::move(callback)); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::UnRegisterCallBack() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->UnRegisterCallBack(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::DialCall(std::u16string number, AppExecFwk::PacMap &extras) +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->DialCall(number, extras); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::AnswerCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->AnswerCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::RejectCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->RejectCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::HangUpCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->HangUpCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::GetCallState() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->GetCallState(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::HoldCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->HoldCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::UnHoldCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->UnHoldCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::SwitchCall() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->SwitchCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::CombineConference() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->CombineConference(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::SeparateConference() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->SeparateConference(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::StartDtmf(char str) +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->StartDtmf(str); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::StopDtmf() +{ + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->StopDtmf(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +bool BluetoothCallClient::IsRinging() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->IsRinging(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +bool BluetoothCallClient::HasCall() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->HasCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +bool BluetoothCallClient::IsNewCallAllowed() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->IsNewCallAllowed(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +bool BluetoothCallClient::IsInEmergencyCall() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->IsInEmergencyCall(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::SetMuted(bool isMute) +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->SetMuted(isMute); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::MuteRinger() +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->MuteRinger(); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +int32_t BluetoothCallClient::SetAudioDevice(AudioDevice deviceType) +{ + if (g_callManagerProxyPtr != nullptr) { + return g_callManagerProxyPtr->SetAudioDevice(deviceType); + } else { + TELEPHONY_LOGE("init first please!"); + return TELEPHONY_ERR_UNINIT; + } +} + +std::vector BluetoothCallClient::GetCurrentCallList(int32_t slotId) +{ + std::vector callVec; + callVec.clear(); + if (g_bluetoothCallProxyPtr != nullptr) { + return g_bluetoothCallProxyPtr->GetCurrentCallList(slotId); + } else { + TELEPHONY_LOGE("init first please!"); + return callVec; + } +} +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/src/bluetooth_call_proxy.cpp b/frameworks/native/src/bluetooth_call_proxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9981d5baff04d79734ec28bcf033aab49b05fe5 --- /dev/null +++ b/frameworks/native/src/bluetooth_call_proxy.cpp @@ -0,0 +1,296 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_proxy.h" + +#include "message_option.h" +#include "message_parcel.h" + +#include "call_manager_errors.h" + +namespace OHOS { +namespace Telephony { +BluetoothCallProxy::BluetoothCallProxy(const sptr &impl) + : IRemoteProxy(impl) +{} + +int32_t BluetoothCallProxy::AnswerCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_ANSWER_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("function AnswerCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::RejectCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_REJECT_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("function RejectCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::HangUpCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_DISCONNECT_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("function HangUpCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::GetCallState() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_GET_CALL_STATE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("function GetCallState! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::HoldCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_HOLD_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function HoldCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::UnHoldCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_UNHOLD_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function UnHoldCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::SwitchCall() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_SWAP_CALL, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function UnHoldCall call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::StartDtmf(char str) +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + dataParcel.WriteInt8(str); + int32_t error = + Remote()->SendRequest(INTERFACE_BT_START_DTMF, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function StartDtmf! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::StopDtmf() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = + Remote()->SendRequest(INTERFACE_BT_STOP_DTMF, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function StopDtmf! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::CombineConference() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_COMBINE_CONFERENCE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function CombineConference failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +int32_t BluetoothCallProxy::SeparateConference() +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_SEPARATE_CONFERENCE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function SeparateConference call failed! errCode:%{public}d", error); + return error; + } + return replyParcel.ReadInt32(); +} + +std::vector BluetoothCallProxy::GetCurrentCallList(int32_t slotId) +{ + std::vector callVec; + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(BluetoothCallProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return callVec; + } + dataParcel.WriteInt32(slotId); + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return callVec; + } + int32_t error = Remote()->SendRequest(INTERFACE_BT_GET_CURRENT_CALL_LIST, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Function GetCurrentCallList call failed! errCode:%{public}d", error); + return callVec; + } + int32_t vecCnt = replyParcel.ReadInt32(); + if (vecCnt <= 0) { + TELEPHONY_LOGE("vector is empty"); + return callVec; + } + CallAttributeInfo *infoPtr = nullptr; + for (int32_t i = 0; i < vecCnt; i++) { + infoPtr = (CallAttributeInfo *)replyParcel.ReadRawData(sizeof(CallAttributeInfo)); + callVec.push_back(*infoPtr); + } + return callVec; +} +} // namespace Telephony +} // namespace OHOS diff --git a/frameworks/native/src/call_ability_callback.cpp b/frameworks/native/src/call_ability_callback.cpp old mode 100755 new mode 100644 index 10ea1da6352f6cba0112290da769fc1936d296b8..a9783d2026b5fde9b8c33f6206fc98475d143bed --- a/frameworks/native/src/call_ability_callback.cpp +++ b/frameworks/native/src/call_ability_callback.cpp @@ -71,6 +71,15 @@ int32_t CallAbilityCallback::OnReportAsyncResults(CallResultReportId reportId, A return TELEPHONY_SUCCESS; } +int32_t CallAbilityCallback::OnReportMmiCodeResult(const MmiCodeInfo &info) +{ + std::lock_guard lock(mutex_); + if (callbackPtr_ != nullptr) { + return callbackPtr_->OnReportMmiCodeResult(info); + } + return TELEPHONY_SUCCESS; +} + int32_t CallAbilityCallback::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) { std::lock_guard lock(mutex_); diff --git a/frameworks/native/src/call_ability_callback_death_recipient.cpp b/frameworks/native/src/call_ability_callback_death_recipient.cpp old mode 100755 new mode 100644 diff --git a/frameworks/native/src/call_ability_callback_stub.cpp b/frameworks/native/src/call_ability_callback_stub.cpp old mode 100755 new mode 100644 index d5617301d6202f15a9ea9ef92b5e3b71694965d9..ade8f458aad8feaa62f529245740cc47fe76fd7d --- a/frameworks/native/src/call_ability_callback_stub.cpp +++ b/frameworks/native/src/call_ability_callback_stub.cpp @@ -29,6 +29,7 @@ CallAbilityCallbackStub::CallAbilityCallbackStub() memberFuncMap_[UPDATE_CALL_DISCONNECTED_CAUSE] = &CallAbilityCallbackStub::OnUpdateCallDisconnectedCause; memberFuncMap_[UPDATE_CALL_ASYNC_RESULT_REQUEST] = &CallAbilityCallbackStub::OnUpdateAysncResults; memberFuncMap_[REPORT_OTT_CALL_REQUEST] = &CallAbilityCallbackStub::OnUpdateOttCallRequest; + memberFuncMap_[UPDATE_MMI_CODE_RESULT_REQUEST] = &CallAbilityCallbackStub::OnUpdateMmiCodeResults; } CallAbilityCallbackStub::~CallAbilityCallbackStub() @@ -133,6 +134,8 @@ int32_t CallAbilityCallbackStub::OnUpdateAysncResults(MessageParcel &data, Messa resultInfo.PutIntValue("classx", data.ReadInt32()); resultInfo.PutStringValue("number", data.ReadString()); resultInfo.PutIntValue("type", data.ReadInt32()); + resultInfo.PutIntValue("reason", data.ReadInt32()); + resultInfo.PutIntValue("time", data.ReadInt32()); break; case CallResultReportId::GET_CALL_CLIP_ID: resultInfo.PutIntValue("action", data.ReadInt32()); @@ -143,6 +146,7 @@ int32_t CallAbilityCallbackStub::OnUpdateAysncResults(MessageParcel &data, Messa resultInfo.PutIntValue("clirStat", data.ReadInt32()); break; case CallResultReportId::GET_CALL_VOTLE_REPORT_ID: + case CallResultReportId::START_RTT_REPORT_ID: resultInfo.PutIntValue("active", data.ReadInt32()); break; case CallResultReportId::GET_IMS_CONFIG_REPORT_ID: @@ -150,9 +154,6 @@ int32_t CallAbilityCallbackStub::OnUpdateAysncResults(MessageParcel &data, Messa case CallResultReportId::GET_LTE_ENHANCE_MODE_REPORT_ID: resultInfo.PutIntValue("value", data.ReadInt32()); break; - case CallResultReportId::START_RTT_REPORT_ID: - resultInfo.PutIntValue("active", data.ReadInt32()); - break; case CallResultReportId::STOP_RTT_REPORT_ID: resultInfo.PutIntValue("inactive", data.ReadInt32()); break; @@ -170,6 +171,31 @@ int32_t CallAbilityCallbackStub::OnUpdateAysncResults(MessageParcel &data, Messa return TELEPHONY_SUCCESS; } +int32_t CallAbilityCallbackStub::OnUpdateMmiCodeResults(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = TELEPHONY_SUCCESS; + const MmiCodeInfo *parcelPtr = nullptr; + int32_t len = data.ReadInt32(); + if (len <= 0) { + TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } + if (!data.ContainFileDescriptors()) { + TELEPHONY_LOGW("sent raw data is less than 32k"); + } + if ((parcelPtr = reinterpret_cast(data.ReadRawData(len))) == nullptr) { + TELEPHONY_LOGE("reading raw data failed, length = %d", len); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + + result = OnReportMmiCodeResult(*parcelPtr); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("writing parcel failed"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + int32_t CallAbilityCallbackStub::OnUpdateOttCallRequest(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_SUCCESS; diff --git a/frameworks/native/src/call_manager_client.cpp b/frameworks/native/src/call_manager_client.cpp old mode 100755 new mode 100644 index 47b4c281f4231bc62eba1efd85377ea289a7de3b..d2d4ab5d4275a7b621bcfa1a214b5a04fddbd538 --- a/frameworks/native/src/call_manager_client.cpp +++ b/frameworks/native/src/call_manager_client.cpp @@ -17,14 +17,21 @@ #include +#include "ability_manager_client.h" +#include "string_wrapper.h" #include "telephony_errors.h" #include "call_manager_proxy.h" +#include "parameter.h" + namespace OHOS { namespace Telephony { std::shared_ptr g_callManagerProxy = nullptr; +const std::string KEY_VOICECALL_CAP = "const.telephony.voice.capable"; +const int32_t VOICECALL_CAP_VAL_LEN = 6; + CallManagerClient::CallManagerClient() {} CallManagerClient::~CallManagerClient() {} @@ -81,6 +88,23 @@ int32_t CallManagerClient::DialCall(std::u16string number, AppExecFwk::PacMap &e } } +int32_t CallManagerClient::MakeCall(std::string number) +{ + AAFwk::Want want; + AppExecFwk::ElementName element("", "com.ohos.contacts", "com.ohos.contacts.MainAbility"); + want.SetElement(element); + AAFwk::WantParams wantParams; + wantParams.SetParam("phoneNumber", AAFwk::String::Box(number)); + wantParams.SetParam("pageFlag", AAFwk::String::Box("page_flag_edit_before_calling")); + want.SetParams(wantParams); + ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want); + if (err != ERR_OK) { + TELEPHONY_LOGE("Fail to make call, err:%{public}d", err); + return TELEPHONY_ERR_FAIL; + } + return TELEPHONY_SUCCESS; +} + int32_t CallManagerClient::AnswerCall(int32_t callId, int32_t videoState) { if (g_callManagerProxy != nullptr) { @@ -301,7 +325,7 @@ bool CallManagerClient::IsRinging() return g_callManagerProxy->IsRinging(); } else { TELEPHONY_LOGE("init first please!"); - return TELEPHONY_ERR_UNINIT; + return false; } } @@ -311,7 +335,7 @@ bool CallManagerClient::HasCall() return g_callManagerProxy->HasCall(); } else { TELEPHONY_LOGE("init first please!"); - return TELEPHONY_ERR_UNINIT; + return false; } } @@ -321,7 +345,7 @@ bool CallManagerClient::IsNewCallAllowed() return g_callManagerProxy->IsNewCallAllowed(); } else { TELEPHONY_LOGE("init first please!"); - return TELEPHONY_ERR_UNINIT; + return false; } } @@ -331,7 +355,7 @@ bool CallManagerClient::IsInEmergencyCall() return g_callManagerProxy->IsInEmergencyCall(); } else { TELEPHONY_LOGE("init first please!"); - return TELEPHONY_ERR_UNINIT; + return false; } } @@ -341,7 +365,7 @@ bool CallManagerClient::IsEmergencyPhoneNumber(std::u16string &number, int32_t s return g_callManagerProxy->IsEmergencyPhoneNumber(number, slotId, errorCode); } else { TELEPHONY_LOGE("init first please!"); - return TELEPHONY_ERR_UNINIT; + return false; } } @@ -616,5 +640,16 @@ int32_t CallManagerClient::ReportOttCallEventInfo(OttCallEventInfo &eventInfo) return TELEPHONY_ERR_UNINIT; } } + +bool CallManagerClient::HasVoiceCapability() +{ + char retValue[VOICECALL_CAP_VAL_LEN + 1] = {"true"}; + int retLen = GetParameter(KEY_VOICECALL_CAP.c_str(), "true", retValue, VOICECALL_CAP_VAL_LEN); + TELEPHONY_LOGI("HasVoiceCapability retValue %{public}s, retLen %{public}d", retValue, retLen); + if (strcmp(retValue, "false") == 0) { + return false; + } + return true; +} } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/src/call_manager_death_recipient.cpp b/frameworks/native/src/call_manager_death_recipient.cpp old mode 100755 new mode 100644 diff --git a/frameworks/native/src/call_manager_proxy.cpp b/frameworks/native/src/call_manager_proxy.cpp old mode 100755 new mode 100644 index 1499c774279e5905bbce12a5b55e134fe2ea1a94..5c8ca022749f739d4d447e96cfa7585a71e16edc --- a/frameworks/native/src/call_manager_proxy.cpp +++ b/frameworks/native/src/call_manager_proxy.cpp @@ -547,7 +547,7 @@ bool CallManagerProxy::IsRinging() { if (ReConnectService() != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("ipc reconnect failed!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + return false; } std::lock_guard lock(mutex_); return callManagerServicePtr_->IsRinging(); @@ -557,7 +557,7 @@ bool CallManagerProxy::HasCall() { if (ReConnectService() != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("ipc reconnect failed!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + return false; } std::lock_guard lock(mutex_); return callManagerServicePtr_->HasCall(); @@ -567,7 +567,7 @@ bool CallManagerProxy::IsNewCallAllowed() { if (ReConnectService() != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("ipc reconnect failed!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + return false; } std::lock_guard lock(mutex_); return callManagerServicePtr_->IsNewCallAllowed(); @@ -577,7 +577,7 @@ bool CallManagerProxy::IsInEmergencyCall() { if (ReConnectService() != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("ipc reconnect failed!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + return false; } std::lock_guard lock(mutex_); return callManagerServicePtr_->IsInEmergencyCall(); @@ -587,7 +587,7 @@ bool CallManagerProxy::IsEmergencyPhoneNumber(std::u16string &number, int32_t sl { if (ReConnectService() != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("ipc reconnect failed!"); - return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + return false; } std::lock_guard lock(mutex_); return callManagerServicePtr_->IsEmergencyPhoneNumber(number, slotId, errorCode); @@ -999,5 +999,20 @@ int32_t CallManagerProxy::ReportOttCallEventInfo(OttCallEventInfo &eventInfo) } return TELEPHONY_SUCCESS; } + +sptr CallManagerProxy::GetProxyObjectPtr(CallManagerProxyType proxyType) +{ + if (ReConnectService() != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("ipc reconnect failed!"); + return nullptr; + } + std::lock_guard lock(mutex_); + sptr ptr = callManagerServicePtr_->GetProxyObjectPtr(proxyType); + if (ptr == nullptr) { + TELEPHONY_LOGE("GetProxyObjectPtr failed"); + return nullptr; + } + return ptr; +} } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/src/call_manager_service_proxy.cpp b/frameworks/native/src/call_manager_service_proxy.cpp old mode 100755 new mode 100644 index db19b9a96f918847a1faf7482f6f738fa95a3226..34628f3aa2f1a8697719dae22d43e22b0f7371cf --- a/frameworks/native/src/call_manager_service_proxy.cpp +++ b/frameworks/native/src/call_manager_service_proxy.cpp @@ -853,7 +853,7 @@ bool CallManagerServiceProxy::IsEmergencyPhoneNumber(std::u16string &number, int } if (number.empty()) { TELEPHONY_LOGE("number is empty"); - return TELEPHONY_ERR_ARGUMENT_INVALID; + return false; } dataParcel.WriteString16(number); dataParcel.WriteInt32(slotId); @@ -864,7 +864,7 @@ bool CallManagerServiceProxy::IsEmergencyPhoneNumber(std::u16string &number, int int32_t error = Remote()->SendRequest(INTERFACE_IS_EMERGENCY_NUMBER, dataParcel, replyParcel, option); if (error != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("Function IsEmergencyPhoneNumber call failed! errCode:%{public}d", error); - return error; + return false; } bool result = replyParcel.ReadBool(); errorCode = replyParcel.ReadInt32(); @@ -1287,7 +1287,7 @@ int32_t CallManagerServiceProxy::ReportOttCallDetailsInfo(std::vector::iterator it = ottVec.begin(); - for (; it != ottVec.end(); it++) { + for (; it != ottVec.end(); ++it) { dataParcel.WriteRawData((const void *)&(*it), sizeof(OttCallDetailsInfo)); } if (Remote() == nullptr) { @@ -1323,5 +1323,27 @@ int32_t CallManagerServiceProxy::ReportOttCallEventInfo(OttCallEventInfo &eventI } return replyParcel.ReadInt32(); } + +sptr CallManagerServiceProxy::GetProxyObjectPtr(CallManagerProxyType proxyType) +{ + MessageOption option; + MessageParcel dataParcel; + MessageParcel replyParcel; + if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return nullptr; + } + dataParcel.WriteInt32(static_cast(proxyType)); + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return nullptr; + } + int32_t error = Remote()->SendRequest(INTERFACE_GET_PROXY_OBJECT_PTR, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("function GetProxyObjectPtr failed! errCode:%{public}d", error); + return nullptr; + } + return replyParcel.ReadRemoteObject(); +} } // namespace Telephony } // namespace OHOS diff --git a/frameworks/native/src/cellular_call_callback_death_recipient.cpp b/frameworks/native/src/cellular_call_callback_death_recipient.cpp old mode 100755 new mode 100644 diff --git a/interfaces/innerkits/bluetooth_call_client.h b/interfaces/innerkits/bluetooth_call_client.h new file mode 100644 index 0000000000000000000000000000000000000000..07714933a33a7e92034492fe599b0193f7e7224d --- /dev/null +++ b/interfaces/innerkits/bluetooth_call_client.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 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 BLUETOOTH_CALL_CLIENT_H +#define BLUETOOTH_CALL_CLIENT_H + +#include "singleton.h" +#include "pac_map.h" + +#include "call_manager_callback.h" + +namespace OHOS { +namespace Telephony { +class BluetoothCallClient : public std::enable_shared_from_this { + DECLARE_DELAYED_SINGLETON(BluetoothCallClient) +public: + void Init(); + void UnInit(); + int32_t RegisterCallBack(std::unique_ptr callback); + int32_t UnRegisterCallBack(); + int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras); + int32_t AnswerCall(); + int32_t RejectCall(); + int32_t HangUpCall(); + int32_t GetCallState(); + int32_t HoldCall(); + int32_t UnHoldCall(); + int32_t SwitchCall(); + int32_t CombineConference(); + int32_t SeparateConference(); + int32_t StartDtmf(char str); + int32_t StopDtmf(); + bool IsRinging(); + bool HasCall(); + bool IsNewCallAllowed(); + bool IsInEmergencyCall(); + int32_t SetMuted(bool isMute); + int32_t MuteRinger(); + int32_t SetAudioDevice(AudioDevice deviceType); + std::vector GetCurrentCallList(int32_t slotId); +}; +} // namespace Telephony +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/call_manager_callback.h b/interfaces/innerkits/call_manager_callback.h old mode 100755 new mode 100644 index 364c67deab38e0dc2aaad7c32bff01b704f25f36..d26f5c1afc9cb8124ecfa5ccbd31f9e347c1a620 --- a/interfaces/innerkits/call_manager_callback.h +++ b/interfaces/innerkits/call_manager_callback.h @@ -32,6 +32,7 @@ public: virtual int32_t OnCallDisconnectedCause(DisconnectedDetails cause) = 0; virtual int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) = 0; virtual int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) = 0; + virtual int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) = 0; }; } // namespace Telephony } // namespace OHOS diff --git a/interfaces/innerkits/call_manager_client.h b/interfaces/innerkits/call_manager_client.h old mode 100755 new mode 100644 index a6bf51a9a46415db86403230fb9466df52870183..0f5694ce83cb114e2962018f4ed629af88dc096b --- a/interfaces/innerkits/call_manager_client.h +++ b/interfaces/innerkits/call_manager_client.h @@ -31,6 +31,7 @@ public: int32_t RegisterCallBack(std::unique_ptr callback); int32_t UnRegisterCallBack(); int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras); + int32_t MakeCall(std::string number); int32_t AnswerCall(int32_t callId, int32_t videoState); int32_t RejectCall(int32_t callId, bool isSendSms, std::u16string content); int32_t HangUpCall(int32_t callId); @@ -85,6 +86,7 @@ public: int32_t JoinConference(int32_t callId, std::vector &numberList); int32_t ReportOttCallDetailsInfo(std::vector &ottVec); int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo); + bool HasVoiceCapability(); }; } // namespace Telephony } // namespace OHOS diff --git a/interfaces/innerkits/call_manager_errors.h b/interfaces/innerkits/call_manager_errors.h old mode 100755 new mode 100644 diff --git a/interfaces/innerkits/call_manager_inner_type.h b/interfaces/innerkits/call_manager_inner_type.h old mode 100755 new mode 100644 index d7038d45184ba31d44c185c64fa78df34338c8ea..32e351edb00578ce802d1399641c1ebc49e7edd4 --- a/interfaces/innerkits/call_manager_inner_type.h +++ b/interfaces/innerkits/call_manager_inner_type.h @@ -78,8 +78,8 @@ enum class DialScene { }; enum class CallDirection { - CALL_DIRECTION_OUT = 0, - CALL_DIRECTION_IN, + CALL_DIRECTION_IN = 0, + CALL_DIRECTION_OUT, CALL_DIRECTION_UNKNOW, }; @@ -166,6 +166,7 @@ struct CallAttributeInfo { struct CallRecordInfo { int32_t callId; char phoneNumber[kMaxNumberLen + 1]; + char formattedPhoneNumber[kMaxNumberLen + 1]; CallType callType; time_t callBeginTime; time_t callEndTime; @@ -367,12 +368,19 @@ struct ClirResponse { int32_t clirStat; }; +struct MmiCodeInfo { + int32_t result; // 0: ok other: error + char message[kMaxNumberLen + 1]; +}; + struct CallTransferResponse { int32_t result; // 0: ok other: error int32_t status; int32_t classx; int32_t type; char number[kMaxNumberLen + 1]; + int32_t reason; + int32_t time; }; struct CallRestrictionResponse { @@ -417,6 +425,16 @@ struct MuteControlResponse { int32_t value; // 0: Un mute 1: Set mute }; +struct CellularCallInfo { + int32_t callId; // uuid + char phoneNum[kMaxNumberLen]; // call phone number + int32_t slotId; // del + int32_t accountId; + CallType callType; // call type: CS、IMS + int32_t videoState; // 0: audio 1:video + int32_t index; // CallInfo index +}; + /** * 27007-430_2001 7.11 Call forwarding number and conditions +CCFC * 3GPP TS 22.082 [4] @@ -455,6 +473,14 @@ struct CallTransferInfo { CallTransferType type; }; +enum class SsRequestType { + SS_ACTIVATION = 0, + SS_DEACTIVATION, + SS_INTERROGATION, + SS_REGISTRATION, + SS_ERASURE, +}; + struct VideoWindow { int32_t x; int32_t y; diff --git a/interfaces/kits/js/@ohos.telephony.call.d.ts b/interfaces/kits/js/@ohos.telephony.call.d.ts old mode 100755 new mode 100644 index 130f39d12fb8c0bcb2f079ebab4651390a1d686f..cdf279387c2cb8d342551f84978ff08ad655b080 --- a/interfaces/kits/js/@ohos.telephony.call.d.ts +++ b/interfaces/kits/js/@ohos.telephony.call.d.ts @@ -1,634 +1,731 @@ /* -* Copyright (C) 2021 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. -*/ + * 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 + * + * 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. + */ import {AsyncCallback, Callback} from "./basic"; /** * Provides methods related to call management. * - * @since 7 - * @sysCap SystemCapability.Telephony.DCall - * @devices phone, tablet, wearable, car + * @since 6 + * @syscap SystemCapability.Telephony.CallManager */ declare namespace call { - /** - * Makes a call. - * - *

Applications must have the {@code ohos.permission.PLACE_CALL} permission to call this method. - * - * @param phoneNumber Indicates the called number. - * @param options Indicates additional information carried in the call. - * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. - * Note that the value {@code true} indicates only the successful processing of the request; it does not mean - * that the call is or can be connected. - * @permission ohos.permission.PLACE_CALL - * @since 6 - */ - function dial(phoneNumber: string, callback: AsyncCallback): void; - function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; - function dial(phoneNumber: string, options?: DialOptions): Promise; - - /** - * Checks whether a call is ongoing. - * - * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} - * state; returns {@code false} otherwise. - */ - function hasCall(callback: AsyncCallback): void; - function hasCall(): Promise; - - /** - * Obtains the call state. - * - *

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. - * If at least one call is in the active, hold, or dialing state, the system returns - * {@code CallState#CALL_STATE_OFFHOOK}. - * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. - * - * @param callback Returns the call state. - */ - function getCallState(callback: AsyncCallback): void; - function getCallState(): Promise; - - /** - * Stops the ringtone. - * - *

If an incoming call is ringing, the phone stops ringing. Otherwise, this method does not function. - * - * @permission ohos.permission.SET_TELEPHONY_STATE or System App - * @systemapi Hide this for inner system use. - */ - function muteRinger(callback: AsyncCallback): void; - function muteRinger(): Promise; - - /** - * Checks whether a phone number is on the emergency number list. - * - * @param phoneNumber Indicates the phone number to check. - * @param callback Returns {@code true} if the phone number is on the emergency number list; - * returns {@code false} otherwise. - */ - function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; - function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; - function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; - - /** - * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, - * a phone number is in the format of country code (if any) + 3-digit service provider code - * + 4-digit area code + 4-digit subscriber number. After the formatting, - * each part is separated by a space. - * - * @param phoneNumber Indicates the phone number to format. - * @param callback Returns the phone number after being formatted; returns an empty string - * if the input phone number is invalid. - */ - function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; - function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; - function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; - - /** - * Formats a phone number into an E.164 representation. - * - * @param phoneNumber Indicates the phone number to format. - * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. - * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. - */ - function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; - function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function answer(callId: number, callback: AsyncCallback): void; - function answer(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function hangup(callId: number, callback: AsyncCallback): void; - function hangup(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function reject(callId: number, callback: AsyncCallback): void; - function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; - function reject(callId: number, options?: RejectMessageOptions): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function holdCall(callId: number, callback: AsyncCallback): void; - function holdCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function unHoldCall(callId: number, callback: AsyncCallback): void; - function unHoldCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function switchCall(callId: number, callback: AsyncCallback): void; - function switchCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function combineConference(callId: number, callback: AsyncCallback): void; - function combineConference(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function getMainCallId(callId: number, callback: AsyncCallback): void; - function getMainCallId(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function getSubCallIdList(callId: number, callback: AsyncCallback>): void; - function getSubCallIdList(callId: number): Promise>; - - /** - * @systemapi Hide this for inner system use. - */ - function getCallIdListForConference(callId: number, callback: AsyncCallback>): void; - function getCallIdListForConference(callId: number): Promise>; - - /** - * @systemapi Hide this for inner system use. - */ - function getCallWaitingStatus(slotId: number, callback: AsyncCallback): void; - function getCallWaitingStatus(slotId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback): void; - function setCallWaiting(slotId: number, activate: boolean): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function startDTMF(callId: number, character: string, callback: AsyncCallback): void; - function startDTMF(callId: number, character: string): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function stopDTMF(callId: number, callback: AsyncCallback): void; - function stopDTMF(callId: number): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - */ - function isInEmergencyCall(callback: AsyncCallback): void; - function isInEmergencyCall(): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function on(type: 'callDetailsChange', callback: Callback): void; - function off(type: 'callDetailsChange', callback?: Callback): void; - - /** - * @systemapi Hide this for inner system use. - */ - function on(type: 'callEventChange', callback: Callback): void; - function off(type: 'callEventChange', callback?: Callback): void; - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - function on(type: 'callDisconnectedCause', callback: Callback): void; - function off(type: 'callDisconnectedCause', callback?: Callback): void; - - /** - * @systemapi Hide this for inner system use. - */ - function isNewCallAllowed(callback: AsyncCallback): void; - function isNewCallAllowed(): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function separateConference(callId: number, callback: AsyncCallback): void; - function separateConference(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function getCallRestrictionStatus(slotId: number, type: CallRestrictionType, callback: AsyncCallback): void; - function getCallRestrictionStatus(slotId: number, type: CallRestrictionType): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function setCallRestriction(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback): void; - function setCallRestriction(slotId: number, info: CallRestrictionInfo): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function getCallTransferInfo(slotId: number, type: CallTransferType, callback: AsyncCallback): void; - function getCallTransferInfo(slotId: number, type: CallTransferType): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function setCallTransfer(slotId: number, info: CallTransferInfo, callback: AsyncCallback): void; - function setCallTransfer(slotId: number, info: CallTransferInfo): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - */ - function isRinging(callback: AsyncCallback): void; - function isRinging(): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function setMuted(callback: AsyncCallback): void; - function setMuted(): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - function cancelMuted(callback: AsyncCallback): void; - function cancelMuted(): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function setAudioDevice(device: AudioDevice, callback: AsyncCallback): void; - function setAudioDevice(device: AudioDevice): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - function joinConference(mainCallId: number, callNumberList: Array, callback: AsyncCallback): void; - function joinConference(mainCallId: number, callNumberList: Array): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - function UpdateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback): void; - function UpdateImsCallMode(callId: number, mode: ImsCallMode): Promise; - + /** + * Makes a call. + * + *

Applications must have the {@code ohos.permission.PLACE_CALL} permission to call this method. + * + * @param phoneNumber Indicates the called number. + * @param options Indicates additional information carried in the call. + * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. + * Note that the value {@code true} indicates only the successful processing of the request; it does not mean + * that the call is or can be connected. + * @permission ohos.permission.PLACE_CALL + */ + function dial(phoneNumber: string, callback: AsyncCallback): void; + function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; + function dial(phoneNumber: string, options?: DialOptions): Promise; + + /** + * Go to the dial screen and the called number is displayed. + * + * @param phoneNumber Indicates the called number. + * @syscap SystemCapability.Applications.Contacts + * @since 7 + */ + function makeCall(phoneNumber: string, callback: AsyncCallback): void; + function makeCall(phoneNumber: string): Promise; + + /** + * Checks whether a call is ongoing. + * + * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} + * state; returns {@code false} otherwise. + */ + function hasCall(callback: AsyncCallback): void; + function hasCall(): Promise; + + /** + * Obtains the call state. + * + *

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. + * If at least one call is in the active, hold, or dialing state, the system returns + * {@code CallState#CALL_STATE_OFFHOOK}. + * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. + * + * @param callback Returns the call state. + */ + function getCallState(callback: AsyncCallback): void; + function getCallState(): Promise; + + /** + * Stops the ringtone. + * + *

If an incoming call is ringing, the phone stops ringing. Otherwise, this method does not function. + * + * @permission ohos.permission.SET_TELEPHONY_STATE or System App + * @systemapi Hide this for inner system use. + * @since 8 + */ + function muteRinger(callback: AsyncCallback): void; + function muteRinger(): Promise; + + /** + * Checks whether a device supports voice calls. + * + *

The system checks whether the device has the capability to initiate a circuit switching (CS) or IP multimedia + * subsystem domain (IMS) call on a telephone service network. If the device supports only packet switching + * (even if the device supports OTT calls), {@code false} is returned. + * + * @return Returns {@code true} if the device supports voice calls; returns {@code false} otherwise. + * @since 7 + */ + function hasVoiceCapability(): boolean; + + /** + * Checks whether a phone number is on the emergency number list. + * + * @param phoneNumber Indicates the phone number to check. + * @param callback Returns {@code true} if the phone number is on the emergency number list; + * returns {@code false} otherwise. + * @since 7 + */ + function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; + + /** + * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, + * a phone number is in the format of country code (if any) + 3-digit service provider code + * + 4-digit area code + 4-digit subscriber number. After the formatting, + * each part is separated by a space. + * + * @param phoneNumber Indicates the phone number to format. + * @param callback Returns the phone number after being formatted; returns an empty string + * if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; + + /** + * Formats a phone number into an E.164 representation. + * + * @param phoneNumber Indicates the phone number to format. + * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. + * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function answer(callId: number, callback: AsyncCallback): void; + function answer(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function hangup(callId: number, callback: AsyncCallback): void; + function hangup(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function reject(callId: number, callback: AsyncCallback): void; + function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function reject(callId: number, options?: RejectMessageOptions): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function holdCall(callId: number, callback: AsyncCallback): void; + function holdCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unHoldCall(callId: number, callback: AsyncCallback): void; + function unHoldCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function switchCall(callId: number, callback: AsyncCallback): void; + function switchCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function combineConference(callId: number, callback: AsyncCallback): void; + function combineConference(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getMainCallId(callId: number, callback: AsyncCallback): void; + function getMainCallId(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSubCallIdList(callId: number, callback: AsyncCallback>): void; + function getSubCallIdList(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallIdListForConference(callId: number, callback: AsyncCallback>): void; + function getCallIdListForConference(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallWaitingStatus(slotId: number, callback: AsyncCallback): void; + function getCallWaitingStatus(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback): void; + function setCallWaiting(slotId: number, activate: boolean): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function startDTMF(callId: number, character: string, callback: AsyncCallback): void; + function startDTMF(callId: number, character: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function stopDTMF(callId: number, callback: AsyncCallback): void; + function stopDTMF(callId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isInEmergencyCall(callback: AsyncCallback): void; + function isInEmergencyCall(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function on(type: 'callDetailsChange', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function off(type: 'callDetailsChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'callEventChange', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'callEventChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'callDisconnectedCause', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'callDisconnectedCause', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 9 + */ + function on(type: 'mmiCodeResult', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 9 + */ + function off(type: 'mmiCodeResult', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isNewCallAllowed(callback: AsyncCallback): void; + function isNewCallAllowed(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function separateConference(callId: number, callback: AsyncCallback): void; + function separateConference(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getCallRestrictionStatus(slotId: number, type: CallRestrictionType, callback: AsyncCallback): void; + function getCallRestrictionStatus(slotId: number, type: CallRestrictionType): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setCallRestriction(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback): void; + function setCallRestriction(slotId: number, info: CallRestrictionInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getCallTransferInfo(slotId: number, type: CallTransferType, callback: AsyncCallback): void; + function getCallTransferInfo(slotId: number, type: CallTransferType): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setCallTransfer(slotId: number, info: CallTransferInfo, callback: AsyncCallback): void; + function setCallTransfer(slotId: number, info: CallTransferInfo): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isRinging(callback: AsyncCallback): void; + function isRinging(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setMuted(callback: AsyncCallback): void; + function setMuted(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function cancelMuted(callback: AsyncCallback): void; + function cancelMuted(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setAudioDevice(device: AudioDevice, callback: AsyncCallback): void; + function setAudioDevice(device: AudioDevice): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function joinConference(mainCallId: number, callNumberList: Array, callback: AsyncCallback): void; + function joinConference(mainCallId: number, callNumberList: Array): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback): void; + function updateImsCallMode(callId: number, mode: ImsCallMode): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function enableImsSwitch(slotId: number, callback: AsyncCallback): void; + function enableImsSwitch(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function disableImsSwitch(slotId: number, callback: AsyncCallback): void; + function disableImsSwitch(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void; + function isImsSwitchEnabled(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum ImsCallMode { + CALL_MODE_AUDIO_ONLY = 0, + CALL_MODE_SEND_ONLY, + CALL_MODE_RECEIVE_ONLY, + CALL_MODE_SEND_RECEIVE, + CALL_MODE_VIDEO_PAUSED, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum AudioDevice { + DEVICE_EARPIECE, + DEVICE_SPEAKER, + DEVICE_WIRED_HEADSET, + DEVICE_BLUETOOTH_SCO, + DEVICE_MIC, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallRestrictionType { + RESTRICTION_TYPE_ALL_INCOMING = 0, + RESTRICTION_TYPE_ALL_OUTGOING, + RESTRICTION_TYPE_INTERNATIONAL, + RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME, + RESTRICTION_TYPE_ROAMING_INCOMING, + RESTRICTION_TYPE_ALL_CALLS, + RESTRICTION_TYPE_OUTGOING_SERVICES, + RESTRICTION_TYPE_INCOMING_SERVICES, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallTransferInfo { + transferNum: string; + type: CallTransferType; + settingType: CallTransferSettingType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallTransferType { + TRANSFER_TYPE_UNCONDITIONAL = 0, + TRANSFER_TYPE_BUSY, + TRANSFER_TYPE_NO_REPLY, + TRANSFER_TYPE_NOT_REACHABLE, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallTransferSettingType { + CALL_TRANSFER_DISABLE = 0, + CALL_TRANSFER_ENABLE = 1, + CALL_TRANSFER_REGISTRATION = 3, + CALL_TRANSFER_ERASURE = 4, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface CallAttributeOptions { + accountNumber: string; + speakerphoneOn: boolean; + accountId: number; + videoState: VideoStateType; + startTime: number; + isEcc: boolean; + callType: CallType; + callId: number; + callState: DetailedCallState; + conferenceState: ConferenceState; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum ConferenceState { + TEL_CONFERENCE_IDLE = 0, + TEL_CONFERENCE_ACTIVE, + TEL_CONFERENCE_DISCONNECTING, + TEL_CONFERENCE_DISCONNECTED, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallType { + TYPE_CS = 0, // CS + TYPE_IMS = 1, // IMS + TYPE_OTT = 2, // OTT + TYPE_ERR_CALL = 3, // OTHER + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum VideoStateType { + TYPE_VOICE = 0, // Voice + TYPE_VIDEO, // Video + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum DetailedCallState { + CALL_STATUS_ACTIVE = 0, + CALL_STATUS_HOLDING, + CALL_STATUS_DIALING, + CALL_STATUS_ALERTING, + CALL_STATUS_INCOMING, + CALL_STATUS_WAITING, + CALL_STATUS_DISCONNECTED, + CALL_STATUS_DISCONNECTING, + CALL_STATUS_IDLE, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallRestrictionInfo { + type: CallRestrictionType; + password: string; + mode: CallRestrictionMode; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallRestrictionMode { + RESTRICTION_MODE_DEACTIVATION = 0, + RESTRICTION_MODE_ACTIVATION, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallEventOptions { + eventId: CallAbilityEventId, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallAbilityEventId { + EVENT_DIAL_NO_CARRIER = 1, + EVENT_INVALID_FDN_NUMBER, + } + + export enum CallState { + /** + * Indicates an invalid state, which is used when the call state fails to be obtained. + */ + CALL_STATE_UNKNOWN = -1, + + /** + * Indicates that there is no ongoing call. + */ + CALL_STATE_IDLE = 0, + + /** + * Indicates that an incoming call is ringing or waiting. + */ + CALL_STATE_RINGING = 1, + + /** + * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call + * ringing or waiting. + */ + CALL_STATE_OFFHOOK = 2 + } + + export interface DialOptions { + /** + * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. + */ + extras?: boolean; /** * @systemapi Hide this for inner system use. * @since 8 */ - function enableImsSwitch(slotId: number, callback: AsyncCallback): void; - function enableImsSwitch(slotId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - function disableImsSwitch(slotId: number, callback: AsyncCallback): void; - function disableImsSwitch(slotId: number): Promise; - + accountId?: number; /** * @systemapi Hide this for inner system use. * @since 8 */ - function isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void; - function isImsSwitchEnabled(slotId: number): Promise; - + videoState?: VideoStateType; /** * @systemapi Hide this for inner system use. * @since 8 */ - export enum ImsCallMode { - CALL_MODE_AUDIO_ONLY = 0, - CALL_MODE_SEND_ONLY, - CALL_MODE_RECEIVE_ONLY, - CALL_MODE_SEND_RECEIVE, - CALL_MODE_VIDEO_PAUSED, - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum AudioDevice { - DEVICE_MIC, - DEVICE_SPEAKER, - DEVICE_WIRED_HEADSET, - DEVICE_BLUETOOTH_SCO - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallRestrictionType { - RESTRICTION_TYPE_ALL_INCOMING = 0, - RESTRICTION_TYPE_ALL_OUTGOING, - RESTRICTION_TYPE_INTERNATIONAL, - RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME, - RESTRICTION_TYPE_ROAMING_INCOMING, - RESTRICTION_TYPE_ALL_CALLS, - RESTRICTION_TYPE_OUTGOING_SERVICES, - RESTRICTION_TYPE_INCOMING_SERVICES, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface CallTransferInfo { - transferNum: string, - type: CallTransferType, - settingType: CallTransferSettingType - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallTransferType { - TRANSFER_TYPE_UNCONDITIONAL = 0, - TRANSFER_TYPE_BUSY, - TRANSFER_TYPE_NO_REPLY, - TRANSFER_TYPE_NOT_REACHABLE, - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallTransferSettingType { - CALL_TRANSFER_DISABLE = 0, - CALL_TRANSFER_ENABLE = 1, - CALL_TRANSFER_REGISTRATION = 3, - CALL_TRANSFER_ERASURE = 4, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface CallAttributeOptions { - accountNumber: string, - speakerphoneOn: boolean, - accountId: number, - videoState: VideoStateType, - startTime: number, - isEcc: boolean, - callType: CallType, - callId: number, - callState: DetailedCallState, - conferenceState: ConferenceState, - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum ConferenceState { - TEL_CONFERENCE_IDLE = 0, - TEL_CONFERENCE_ACTIVE, - TEL_CONFERENCE_DISCONNECTING, - TEL_CONFERENCE_DISCONNECTED, - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallType { - TYPE_CS = 0, // CS - TYPE_IMS = 1, // IMS - TYPE_OTT = 2, // OTT - TYPE_ERR_CALL = 3, // OTHER - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum VideoStateType { - TYPE_VOICE = 0, // Voice - TYPE_VIDEO, // Video - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum DetailedCallState { - CALL_STATUS_ACTIVE = 0, - CALL_STATUS_HOLDING, - CALL_STATUS_DIALING, - CALL_STATUS_ALERTING, - CALL_STATUS_INCOMING, - CALL_STATUS_WAITING, - CALL_STATUS_DISCONNECTED, - CALL_STATUS_DISCONNECTING, - CALL_STATUS_IDLE, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface CallRestrictionInfo { - type: CallRestrictionType, - password: string - mode: CallRestrictionMode - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallRestrictionMode { - RESTRICTION_MODE_DEACTIVATION = 0, - RESTRICTION_MODE_ACTIVATION, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface CallEventOptions { - /** - * @since 8 - */ - eventId: CallAbilityEventId, - } - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - export enum CallAbilityEventId { - EVENT_DIAL_NO_CARRIER = 1, - EVENT_INVALID_FDN_NUMBER, - } - - export enum CallState { - /** - * Indicates an invalid state, which is used when the call state fails to be obtained. - */ - CALL_STATE_UNKNOWN = -1, - - /** - * Indicates that there is no ongoing call. - */ - CALL_STATE_IDLE = 0, - - /** - * Indicates that an incoming call is ringing or waiting. - */ - CALL_STATE_RINGING = 1, - - /** - * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call - * ringing or waiting. - */ - CALL_STATE_OFFHOOK = 2 - } - - export interface DialOptions { - /** - * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. - */ - extras?: boolean; - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - accountId?: number; - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - videoState?: VideoStateType; - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - dialScene?: DialScene; - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - dialType?: DialType; - } - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - export enum DialScene { - CALL_NORMAL = 0, - CALL_PRIVILEGED = 1, - CALL_EMERGENCY = 2, - } - - /** - * @systemapi Hide this for inner system use. - * @since 8 - */ - export enum DialType { - DIAL_CARRIER_TYPE = 0, - DIAL_VOICE_MAIL_TYPE = 1, - DIAL_OTT_TYPE = 2, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface RejectMessageOptions { - messageContent: string, - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface CallTransferResult { - status: TransferStatus, - number: string, - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum CallWaitingStatus { - CALL_WAITING_DISABLE = 0, - CALL_WAITING_ENABLE = 1 - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum RestrictionStatus { - RESTRICTION_DISABLE = 0, - RESTRICTION_ENABLE = 1 - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum TransferStatus { - TRANSFER_DISABLE = 0, - TRANSFER_ENABLE = 1 - } - - export interface EmergencyNumberOptions { - slotId?: number; - } - - export interface NumberFormatOptions { - countryCode?: string; - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface NumberCompareOptions { - numA: string; - netISOA: string; - numB: string; - netISOB: string; - } - + dialScene?: DialScene; /** * @systemapi Hide this for inner system use. * @since 8 */ - export enum DisconnectedDetails { - UNASSIGNED_NUMBER = 1, - NO_ROUTE_TO_DESTINATION = 3, - CHANNEL_UNACCEPTABLE = 6, - OPERATOR_DETERMINED_BARRING = 8, - NORMAL_CALL_CLEARING = 16, - USER_BUSY = 17, - NO_USER_RESPONDING = 18, - USER_ALERTING_NO_ANSWER = 19, - CALL_REJECTED = 21, - NUMBER_CHANGED = 22, - DESTINATION_OUT_OF_ORDER = 27, - INVALID_NUMBER_FORMAT = 28, - NETWORK_OUT_OF_ORDER = 38, - TEMPORARY_FAILURE = 41, - INVALID_PARAMETER = 1025, - SIM_NOT_EXIT = 1026, - SIM_PIN_NEED = 1027, - CALL_NOT_ALLOW = 1029, - SIM_INVALID = 1045, - UNKNOWN = 1279, - }; + dialType?: DialType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DialScene { + CALL_NORMAL = 0, + CALL_PRIVILEGED = 1, + CALL_EMERGENCY = 2, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DialType { + DIAL_CARRIER_TYPE = 0, + DIAL_VOICE_MAIL_TYPE = 1, + DIAL_OTT_TYPE = 2, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface RejectMessageOptions { + messageContent: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallTransferResult { + status: TransferStatus; + number: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallWaitingStatus { + CALL_WAITING_DISABLE = 0, + CALL_WAITING_ENABLE = 1 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum RestrictionStatus { + RESTRICTION_DISABLE = 0, + RESTRICTION_ENABLE = 1 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum TransferStatus { + TRANSFER_DISABLE = 0, + TRANSFER_ENABLE = 1 + } + + /** + * @since 7 + */ + export interface EmergencyNumberOptions { + slotId?: number; + } + + /** + * @since 7 + */ + export interface NumberFormatOptions { + countryCode?: string; + } + + /** + * @since 9 + */ + export interface MmiCodeResults { + result: Int32Array; + message: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DisconnectedDetails { + UNASSIGNED_NUMBER = 1, + NO_ROUTE_TO_DESTINATION = 3, + CHANNEL_UNACCEPTABLE = 6, + OPERATOR_DETERMINED_BARRING = 8, + NORMAL_CALL_CLEARING = 16, + USER_BUSY = 17, + NO_USER_RESPONDING = 18, + USER_ALERTING_NO_ANSWER = 19, + CALL_REJECTED = 21, + NUMBER_CHANGED = 22, + DESTINATION_OUT_OF_ORDER = 27, + INVALID_NUMBER_FORMAT = 28, + NETWORK_OUT_OF_ORDER = 38, + TEMPORARY_FAILURE = 41, + INVALID_PARAMETER = 1025, + SIM_NOT_EXIT = 1026, + SIM_PIN_NEED = 1027, + CALL_NOT_ALLOW = 1029, + SIM_INVALID = 1045, + UNKNOWN = 1279, + }; } export default call; \ No newline at end of file diff --git a/ohos.build b/ohos.build deleted file mode 100755 index 65e3d22d96790e17207c4cc0327a14869c96894f..0000000000000000000000000000000000000000 --- a/ohos.build +++ /dev/null @@ -1,28 +0,0 @@ -{ - "subsystem": "telephony", - "parts": { - "call_manager": { - "module_list": [ - "//base/telephony/call_manager/:tel_call_manager", - "//base/telephony/call_manager/sa_profile:call_manager_sa_profile", - "//base/telephony/call_manager/frameworks/js:call" - ], - "inner_kits": [ - { - "header": { - "header_base" : "//base/telephony/call_manager/interfaces/innerkits/", - "header_files": [ - "call_manager_client.h", - "call_manager_callback.h" - ] - }, - "name":"//base/telephony/call_manager/frameworks/native:tel_call_manager_api" - } - ], - "test_list": [ - "//base/telephony/call_manager/test/unittest:unittest" - ] - } - } -} - diff --git a/resource/audio/BUILD.gn b/resource/audio/BUILD.gn old mode 100755 new mode 100644 diff --git a/resource/audio/ring.wav b/resource/audio/ring.wav old mode 100755 new mode 100644 diff --git a/sa_profile/4005.xml b/sa_profile/4005.xml old mode 100755 new mode 100644 diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn old mode 100755 new mode 100644 diff --git a/services/audio/include/audio_control_manager.h b/services/audio/include/audio_control_manager.h old mode 100755 new mode 100644 diff --git a/services/audio/include/audio_device_manager.h b/services/audio/include/audio_device_manager.h old mode 100755 new mode 100644 diff --git a/services/audio/include/audio_player.h b/services/audio/include/audio_player.h old mode 100755 new mode 100644 index 2ff2e558fa46510fa4e852401759c87a7ae54032..35eb0f9d6b464b7eaf83fb9a629b9322795af5db --- a/services/audio/include/audio_player.h +++ b/services/audio/include/audio_player.h @@ -63,8 +63,9 @@ private: static bool IsStop(PlayerType playerType); static void ReleaseRenderer(); static std::unique_ptr audioRenderer_; + static std::string GetRealPath(const std::string &profilePath); }; } // namespace Telephony } // namespace OHOS -#endif // TELEPHONY_AUDIO_PLAYER_H \ No newline at end of file +#endif // TELEPHONY_AUDIO_PLAYER_H diff --git a/services/audio/include/audio_proxy.h b/services/audio/include/audio_proxy.h old mode 100755 new mode 100644 index 84d12d47470ae263e19b26166a7b9f19b0c74a37..88e4fe9f6786bbaf40ae8e41fa2c8a14131485c6 --- a/services/audio/include/audio_proxy.h +++ b/services/audio/include/audio_proxy.h @@ -76,7 +76,7 @@ private: const std::string defaultRingPath_ = "/system/data/telephony/rings/ring.wav"; const std::string defaultTonePath_ = "/system/data/telephony/tones/tone.wav"; const std::string defaultDtmfPath_ = "/system/data/telephony/dtmfs/dtmf.wav"; - std::shared_ptr context_; + std::shared_ptr context_; std::unique_ptr audioSoundManager_; std::shared_ptr deviceCallback_; }; diff --git a/services/audio/include/audio_scene_processor.h b/services/audio/include/audio_scene_processor.h old mode 100755 new mode 100644 diff --git a/services/audio/include/audio_state/alerting_state.h b/services/audio/include/audio_state/alerting_state.h old mode 100755 new mode 100644 index 09fe5304692b209db3d1b6f12b79003ba8ca3041..b9fa59b6479a89a655d53c5e04556769710df059 --- a/services/audio/include/audio_state/alerting_state.h +++ b/services/audio/include/audio_state/alerting_state.h @@ -25,9 +25,6 @@ public: AlertingState() = default; ~AlertingState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/audio_base.h b/services/audio/include/audio_state/audio_base.h old mode 100755 new mode 100644 index 1426089274339374364206ae6c1bbfe261d7e11a..0cdc4188b69fcc804b532d36973b1eccacd280ef --- a/services/audio/include/audio_state/audio_base.h +++ b/services/audio/include/audio_state/audio_base.h @@ -63,6 +63,9 @@ public: virtual ~AudioBase() {} // handle audio events in current state virtual bool ProcessEvent(int32_t event) = 0; + +protected: + std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/bluetooth_device_state.h b/services/audio/include/audio_state/bluetooth_device_state.h old mode 100755 new mode 100644 index 27c55d6350ecc71617310992fd82206d02aedc3a..576bd27883be54f0d330b666a0c67c8432fa68f0 --- a/services/audio/include/audio_state/bluetooth_device_state.h +++ b/services/audio/include/audio_state/bluetooth_device_state.h @@ -25,9 +25,6 @@ public: BluetoothDeviceState() = default; ~BluetoothDeviceState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/cs_call_state.h b/services/audio/include/audio_state/cs_call_state.h old mode 100755 new mode 100644 index 0a985c8b65deaee8b6469a35c7070ee56bb8e835..664448bafb040ee40bc5889e466d1dfe58c78499 --- a/services/audio/include/audio_state/cs_call_state.h +++ b/services/audio/include/audio_state/cs_call_state.h @@ -25,9 +25,6 @@ public: CSCallState() = default; ~CSCallState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/earpiece_device_state.h b/services/audio/include/audio_state/earpiece_device_state.h old mode 100755 new mode 100644 index a163e177c61ff4696a1cd92e289b193a6770080e..5915a577aee2a446c21078218401d2f0997c7b3e --- a/services/audio/include/audio_state/earpiece_device_state.h +++ b/services/audio/include/audio_state/earpiece_device_state.h @@ -25,9 +25,6 @@ public: EarpieceDeviceState() = default; ~EarpieceDeviceState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/holding_state.h b/services/audio/include/audio_state/holding_state.h old mode 100755 new mode 100644 index 2da0f8031bcb5040cfa086c4dadecfa0a56dc95e..981880ecdc81e8d11c6214966d637071636e5cf1 --- a/services/audio/include/audio_state/holding_state.h +++ b/services/audio/include/audio_state/holding_state.h @@ -25,9 +25,6 @@ public: HoldingState() = default; ~HoldingState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/ims_call_state.h b/services/audio/include/audio_state/ims_call_state.h old mode 100755 new mode 100644 index cc5e7eda0514b0d5a2a40e6f98360ee4373d4baf..4e8e56ceff2b61f59d707ca683ee873b504295b9 --- a/services/audio/include/audio_state/ims_call_state.h +++ b/services/audio/include/audio_state/ims_call_state.h @@ -25,9 +25,6 @@ public: IMSCallState() = default; ~IMSCallState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/inactive_device_state.h b/services/audio/include/audio_state/inactive_device_state.h old mode 100755 new mode 100644 index dae7bda356a0111735c572b0638dea83f1f2ac64..e12982d32796fadd68ff3e9a499bf6fda8d83efa --- a/services/audio/include/audio_state/inactive_device_state.h +++ b/services/audio/include/audio_state/inactive_device_state.h @@ -25,9 +25,6 @@ public: InactiveDeviceState() = default; ~InactiveDeviceState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/inactive_state.h b/services/audio/include/audio_state/inactive_state.h old mode 100755 new mode 100644 index 4f3cc7b0f30d9bcddeb178bced36527fee21e3e9..fa9b0fe8858037dc8312ad69bcccd77810c0c94c --- a/services/audio/include/audio_state/inactive_state.h +++ b/services/audio/include/audio_state/inactive_state.h @@ -25,9 +25,6 @@ public: InActiveState() = default; ~InActiveState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/incoming_state.h b/services/audio/include/audio_state/incoming_state.h old mode 100755 new mode 100644 index baefdce59bee7601e5d99d5d14896c43448e3144..07b428763358158505e765b8553f966df5e94a57 --- a/services/audio/include/audio_state/incoming_state.h +++ b/services/audio/include/audio_state/incoming_state.h @@ -25,9 +25,6 @@ public: IncomingState() = default; ~IncomingState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/ott_call_state.h b/services/audio/include/audio_state/ott_call_state.h old mode 100755 new mode 100644 diff --git a/services/audio/include/audio_state/speaker_device_state.h b/services/audio/include/audio_state/speaker_device_state.h old mode 100755 new mode 100644 index c27387bde0fdcf8903743bde393761a34a61e118..7b3c557d5863bae515843b707ab242b5883e605e --- a/services/audio/include/audio_state/speaker_device_state.h +++ b/services/audio/include/audio_state/speaker_device_state.h @@ -25,9 +25,6 @@ public: SpeakerDeviceState() = default; ~SpeakerDeviceState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/audio_state/wired_headset_device_state.h b/services/audio/include/audio_state/wired_headset_device_state.h old mode 100755 new mode 100644 index a2883133ff30efd7e985204a8078cb7fddfaa2e8..5bf4e83b8db067d2935bb8cea9d837bca366ac3f --- a/services/audio/include/audio_state/wired_headset_device_state.h +++ b/services/audio/include/audio_state/wired_headset_device_state.h @@ -25,9 +25,6 @@ public: WiredHeadsetDeviceState() = default; ~WiredHeadsetDeviceState() = default; bool ProcessEvent(int32_t event) override; - -private: - std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/call_state_processor.h b/services/audio/include/call_state_processor.h old mode 100755 new mode 100644 diff --git a/services/audio/include/ring.h b/services/audio/include/ring.h old mode 100755 new mode 100644 index 53a4cfbcb084bbe7338bb59ef7db207e7f2985f3..b3db36243fc515efc1de3c78c53f617060810a5c --- a/services/audio/include/ring.h +++ b/services/audio/include/ring.h @@ -55,6 +55,7 @@ private: bool shouldVibrate_; bool ShouldVibrate(); std::string ringtonePath_; + std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/include/tone.h b/services/audio/include/tone.h old mode 100755 new mode 100644 index 56e3c1562f3baa0ba76e12a2808540c7a9176a0d..76151a963ebadb3ba78a50b7f85e1b7e4b56393e --- a/services/audio/include/tone.h +++ b/services/audio/include/tone.h @@ -71,6 +71,7 @@ private: ToneDescriptor currentToneDescriptor_ = ToneDescriptor::TONE_UNKNOWN; std::string GetToneDescriptorPath(ToneDescriptor tone); bool IsDtmf(ToneDescriptor tone); + std::mutex mutex_; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/src/audio_control_manager.cpp b/services/audio/src/audio_control_manager.cpp old mode 100755 new mode 100644 index c2a27d40f1580632c2db033d4f4c470f15ec3598..85944752cb1a40bef845bec00adf7c820179f7a1 --- a/services/audio/src/audio_control_manager.cpp +++ b/services/audio/src/audio_control_manager.cpp @@ -338,8 +338,9 @@ AudioDevice AudioControlManager::GetInitAudioDevice() const */ int32_t AudioControlManager::SetMute(bool isMute) { - if (!IsAudioActivated()) { - TELEPHONY_LOGE("audio is not activated, set mute failed"); + bool hasCall = DelayedSingleton::GetInstance()->HasCall(); + if (!hasCall) { + TELEPHONY_LOGE("no call exists, set mute failed"); return CALL_ERR_AUDIO_SETTING_MUTE_FAILED; } if (DelayedSingleton::GetInstance()->HasEmergency()) { diff --git a/services/audio/src/audio_device_manager.cpp b/services/audio/src/audio_device_manager.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_player.cpp b/services/audio/src/audio_player.cpp old mode 100755 new mode 100644 index 32a1994cfcd70d01e74e97b17a0b533dd992074e..d082e06166e719500583dbb654cd73df1b640322 --- a/services/audio/src/audio_player.cpp +++ b/services/audio/src/audio_player.cpp @@ -51,7 +51,7 @@ bool AudioPlayer::InitRenderer(const wav_hdr &wavHeader, AudioStandard::AudioStr } if (audioRenderer_->GetBufferSize(bufferLen)) { TELEPHONY_LOGE("audio renderer get buffer size failed"); - return TELEPHONY_ERR_UNINIT; + return false; } uint32_t frameCount; if (audioRenderer_->GetFrameCount(frameCount)) { @@ -64,11 +64,12 @@ bool AudioPlayer::InitRenderer(const wav_hdr &wavHeader, AudioStandard::AudioStr int32_t AudioPlayer::Play(const std::string &path, AudioStandard::AudioStreamType streamType, PlayerType playerType) { wav_hdr wavHeader; - if (path.empty()) { - TELEPHONY_LOGE("path is empty"); + std::string realPath = GetRealPath(path); + if (realPath.empty()) { + TELEPHONY_LOGE("path or realPath is NULL"); return TELEPHONY_ERR_ARGUMENT_INVALID; } - FILE *wavFile = fopen(path.c_str(), "rb"); + FILE *wavFile = fopen(realPath.c_str(), "rb"); if (wavFile == nullptr) { TELEPHONY_LOGE("open audio file failed"); return TELEPHONY_ERR_LOCAL_PTR_NULL; @@ -101,7 +102,8 @@ int32_t AudioPlayer::Play(const std::string &path, AudioStandard::AudioStreamTyp if (IsStop(playerType)) { break; } - bytesWritten += audioRenderer_->Write(buffer + bytesWritten, bytesToWrite - bytesWritten); + bytesWritten += static_cast( + audioRenderer_->Write(buffer + bytesWritten, bytesToWrite - bytesWritten)); } } ReleaseRenderer(); @@ -153,5 +155,21 @@ void AudioPlayer::ReleaseRenderer() audioRenderer_->Stop(); audioRenderer_->Release(); } + +std::string AudioPlayer::GetRealPath(const std::string &profilePath) +{ + if (profilePath.empty()) { + TELEPHONY_LOGE("profilePath is empty"); + return ""; + } + + char path[PATH_MAX] = {'\0'}; + if (realpath(profilePath.c_str(), path) == nullptr) { + TELEPHONY_LOGE("get real path fail"); + return ""; + } + std::string realPath(path); + return realPath; +} } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/audio/src/audio_proxy.cpp b/services/audio/src/audio_proxy.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_scene_processor.cpp b/services/audio/src/audio_scene_processor.cpp old mode 100755 new mode 100644 index 8d52fd3efc835fc72c92e7d3f882960e196e61e6..e813a3f54ad04310f050ad0fb8c42901ffdb2b62 --- a/services/audio/src/audio_scene_processor.cpp +++ b/services/audio/src/audio_scene_processor.cpp @@ -132,6 +132,7 @@ bool AudioSceneProcessor::SwitchAlerting() // play ringback tone while alerting state DelayedSingleton::GetInstance()->PlayRingback(); currentAudioScene_ = AudioStandard::AudioScene::AUDIO_SCENE_PHONE_CALL; + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_ACTIVATED); TELEPHONY_LOGI("current call state : alerting state"); return true; } @@ -149,6 +150,7 @@ bool AudioSceneProcessor::SwitchIncoming() // play ringtone while incoming state DelayedSingleton::GetInstance()->PlayRingtone(); currentAudioScene_ = AudioStandard::AudioScene::AUDIO_SCENE_RINGING; + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_RINGING); TELEPHONY_LOGI("current call state : incoming state"); return true; } @@ -165,6 +167,7 @@ bool AudioSceneProcessor::SwitchCS() return false; } currentAudioScene_ = AudioStandard::AudioScene::AUDIO_SCENE_PHONE_CALL; + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_ACTIVATED); TELEPHONY_LOGI("current call state : cs call state"); return true; } @@ -181,6 +184,7 @@ bool AudioSceneProcessor::SwitchIMS() return false; } currentAudioScene_ = AudioStandard::AudioScene::AUDIO_SCENE_PHONE_CHAT; + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_ACTIVATED); TELEPHONY_LOGI("current call state : ims call state"); return true; } @@ -191,13 +195,12 @@ bool AudioSceneProcessor::SwitchHolding() { // stay at current audio scene while holding state if (DelayedSingleton::GetInstance()->SetAudioScene(currentAudioScene_)) { - DelayedSingleton::GetInstance()->SetAudioInterruptState( - AudioInterruptState::INTERRUPT_STATE_ACTIVATED); currentState_ = std::make_unique(); if (currentState_ == nullptr) { TELEPHONY_LOGE("make_unique HoldingState failed"); return false; } + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_ACTIVATED); TELEPHONY_LOGI("current call state : holding state"); return true; } @@ -207,14 +210,13 @@ bool AudioSceneProcessor::SwitchHolding() bool AudioSceneProcessor::SwitchInactive() { if (DelayedSingleton::GetInstance()->SetAudioScene(AudioStandard::AudioScene::AUDIO_SCENE_DEFAULT)) { - DelayedSingleton::GetInstance()->SetAudioInterruptState( - AudioInterruptState::INTERRUPT_STATE_DEACTIVATED); currentState_ = std::make_unique(); if (currentState_ == nullptr) { TELEPHONY_LOGE("make_unique InActiveState failed"); return false; } currentAudioScene_ = AudioStandard::AudioScene::AUDIO_SCENE_DEFAULT; + DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::AUDIO_DEACTIVATED); TELEPHONY_LOGI("current call state : inactive state"); return true; } diff --git a/services/audio/src/audio_state/alerting_state.cpp b/services/audio/src/audio_state/alerting_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/bluetooth_device_state.cpp b/services/audio/src/audio_state/bluetooth_device_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/cs_call_state.cpp b/services/audio/src/audio_state/cs_call_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/earpiece_device_state.cpp b/services/audio/src/audio_state/earpiece_device_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/holding_state.cpp b/services/audio/src/audio_state/holding_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/ims_call_state.cpp b/services/audio/src/audio_state/ims_call_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/inactive_device_state.cpp b/services/audio/src/audio_state/inactive_device_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/inactive_state.cpp b/services/audio/src/audio_state/inactive_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/incoming_state.cpp b/services/audio/src/audio_state/incoming_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/ott_call_state.cpp b/services/audio/src/audio_state/ott_call_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/speaker_device_state.cpp b/services/audio/src/audio_state/speaker_device_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/audio_state/wired_headset_device_state.cpp b/services/audio/src/audio_state/wired_headset_device_state.cpp old mode 100755 new mode 100644 diff --git a/services/audio/src/call_state_processor.cpp b/services/audio/src/call_state_processor.cpp old mode 100755 new mode 100644 index 3de7bdfd435886a00c7ea1711161adaf0c471447..bfe4f1fca279f5a2a6023f4922ce03b1810686bd --- a/services/audio/src/call_state_processor.cpp +++ b/services/audio/src/call_state_processor.cpp @@ -100,16 +100,16 @@ int32_t CallStateProcessor::GetCallNumber(TelCallState state) int32_t number = EMPTY_VALUE; switch (state) { case TelCallState::CALL_STATUS_ALERTING: - number = alertingCalls_.size(); + number = static_cast(alertingCalls_.size()); break; case TelCallState::CALL_STATUS_INCOMING: - number = incomingCalls_.size(); + number = static_cast(incomingCalls_.size()); break; case TelCallState::CALL_STATUS_ACTIVE: - number = activeCalls_.size(); + number = static_cast(activeCalls_.size()); break; case TelCallState::CALL_STATUS_HOLDING: - number = holdingCalls_.size(); + number = static_cast(holdingCalls_.size()); break; default: break; diff --git a/services/audio/src/ring.cpp b/services/audio/src/ring.cpp old mode 100755 new mode 100644 index e29550c3f65612ee93c4072965770e5392b735b3..f8e6a472ca19e54b9810ef9f9a108cc21f1fae4e --- a/services/audio/src/ring.cpp +++ b/services/audio/src/ring.cpp @@ -76,6 +76,7 @@ int32_t Ring::Play() int32_t Ring::Stop() { + std::lock_guard lock(mutex_); if (!shouldRing_ || ringtonePath_.empty()) { TELEPHONY_LOGE("should not ring or ringtone path empty"); return CALL_ERR_INVALID_PATH; diff --git a/services/audio/src/tone.cpp b/services/audio/src/tone.cpp old mode 100755 new mode 100644 index 09f2f0bf045349b068ea0a0542130c817747c506..d87d576c6731b1e726242ba87f40d09686b972e4 --- a/services/audio/src/tone.cpp +++ b/services/audio/src/tone.cpp @@ -50,6 +50,7 @@ int32_t Tone::Play() int32_t Tone::Stop() { + std::lock_guard lock(mutex_); if (currentToneDescriptor_ == TONE_UNKNOWN) { TELEPHONY_LOGE("tone descriptor unknown"); return CALL_ERR_AUDIO_UNKNOWN_TONE; diff --git a/services/bluetooth/include/bluetooth_call_manager.h b/services/bluetooth/include/bluetooth_call_manager.h old mode 100755 new mode 100644 index 331050cef30e1de08daf08922e723aa57e94d119..ef126bf7ad49d6d4d5ff07c9dc2d38b97c79c3e3 --- a/services/bluetooth/include/bluetooth_call_manager.h +++ b/services/bluetooth/include/bluetooth_call_manager.h @@ -16,8 +16,6 @@ #ifndef TELEPHONY_BLUETOOTH_CALL_MANAGER_H #define TELEPHONY_BLUETOOTH_CALL_MANAGER_H -#include "call_state_listener_base.h" - #include "singleton.h" #include "bluetooth_connection.h" @@ -26,36 +24,17 @@ namespace OHOS { namespace Telephony { constexpr int16_t DEFAULT_CALL_NUMBER_TYPE = 86; -class BluetoothCallManager : public CallStateListenerBase, - public std::enable_shared_from_this { +class BluetoothCallManager : public std::enable_shared_from_this { DECLARE_DELAYED_SINGLETON(BluetoothCallManager) public: - int32_t Init(); bool ConnectBtSco(); bool DisconnectBtSco(); - bool AnswerBtCall(); - bool HangupBtCall(); - void NewCallCreated(sptr &callObjectPtr) override; - void CallDestroyed(int32_t cause) override; - void IncomingCallActivated(sptr &callObjectPtr) override; - void IncomingCallHungUp(sptr &callObjectPtr, bool isSendSms, std::string content) override; - void CallStateUpdated(sptr &callObjectPtr, TelCallState priorState, TelCallState nextState) override; - /** - * Send call state info to bluetooth headset. - */ - int32_t SendCallState(TelCallState callState, const std::string &number, int32_t type, const std::string &name); - /** - * Send call list info to bluetooth headset. - */ - int32_t SendCallList(); - int32_t SendDtmf(int32_t callId, char str); + int32_t SendBtCallState(int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number); BtScoState GetBtScoState(); private: std::unique_ptr btConnection_; bool IsBtScoConnected(); - int32_t GetCallNumberType(const std::string &number); - std::string GetContactsName(const std::string &number); }; } // namespace Telephony } // namespace OHOS diff --git a/services/bluetooth/include/bluetooth_state_observer.h b/services/bluetooth/include/bluetooth_call_policy.h old mode 100755 new mode 100644 similarity index 50% rename from services/bluetooth/include/bluetooth_state_observer.h rename to services/bluetooth/include/bluetooth_call_policy.h index 889697549206fe521d8e3f7095a7edfd58324c17..085765f17a31fa7d2151de32491cc42ed3a377bc --- a/services/bluetooth/include/bluetooth_state_observer.h +++ b/services/bluetooth/include/bluetooth_call_policy.h @@ -13,33 +13,32 @@ * limitations under the License. */ -#ifndef TELEPHONY_BLUETOOTH_STATE_OBSERVER_H -#define TELEPHONY_BLUETOOTH_STATE_OBSERVER_H +#ifndef BLUETOOTH_CALL_POLICY_H +#define BLUETOOTH_CALL_POLICY_H +#include #include -#include "common_event.h" -#include "common_event_manager.h" +#include "call_object_manager.h" namespace OHOS { namespace Telephony { -class BtEventSubscriber : public OHOS::EventFwk::CommonEventSubscriber { +class BluetoothCallPolicy : public CallObjectManager { public: - explicit BtEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo); - ~BtEventSubscriber() = default; - virtual void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data); -}; - -class BluetoothStateObserver { -public: - BluetoothStateObserver() = default; - ~BluetoothStateObserver(); - static bool SubscribeBluetoothEvent(); - static bool UnSubscribeBluetoothEvent(); + BluetoothCallPolicy(); + ~BluetoothCallPolicy(); -private: - static std::shared_ptr btEventSubscriber_; + int32_t AnswerCallPolicy(int32_t &callId); + int32_t RejectCallPolicy(int32_t &callId); + int32_t HoldCallPolicy(int32_t &callId); + int32_t UnHoldCallPolicy(int32_t &callId); + int32_t HangUpPolicy(int32_t &callId); + int32_t SwitchCallPolicy(int32_t &callId); + int32_t StartDtmfPolicy(int32_t &callId); + int32_t CombineConferencePolicy(int32_t &callId); + int32_t SeparateConferencePolicy(int32_t &callId); }; } // namespace Telephony } // namespace OHOS -#endif \ No newline at end of file + +#endif // BLUETOOTH_CALL_POLICY_H diff --git a/services/bluetooth/include/bluetooth_call_service.h b/services/bluetooth/include/bluetooth_call_service.h new file mode 100644 index 0000000000000000000000000000000000000000..35d7861bd92b00a753e0ce87f220c7e588222f4b --- /dev/null +++ b/services/bluetooth/include/bluetooth_call_service.h @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2021 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 BLUETOOTH_CALL_SERVICE_H +#define BLUETOOTH_CALL_SERVICE_H + +#include + +#include "bluetooth_call_policy.h" +#include "bluetooth_call_stub.h" +#include "call_control_manager.h" + +namespace OHOS { +namespace Telephony { +class BluetoothCallService : public BluetoothCallStub, public BluetoothCallPolicy { +public: + BluetoothCallService(); + ~BluetoothCallService(); + /** + * AnswerCall + * + * @brief Answer a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t AnswerCall() override; + + /** + * RejectCall + * + * @brief Reject a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t RejectCall() override; + + /** + * HangUpCall + * + * @brief Hang up the phone + * @return Returns 0 on success, others on failure. + */ + int32_t HangUpCall() override; + + /** + * GetCallState + * + * @brief Obtain the call status of the device + * @return Returns 0 on success, others on failure. + */ + int32_t GetCallState() override; + + /** + * HoldCall + * + * @brief Park a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t HoldCall() override; + + /** + * UnHoldCall + * + * @brief Activate a phone call + * @return Returns 0 on success, others on failure. + */ + int32_t UnHoldCall() override; + + /** + * SwitchCall + * + * @brief Switch the phone + * @return Returns 0 on success, others on failure. + */ + int32_t SwitchCall() override; + + /** + * StartDtmf + * + * @brief Enable and send DTMF + * @param str[in], Characters sent + * @return Returns 0 on success, others on failure. + */ + int32_t StartDtmf(char str) override; + + /** + * StopDtmf + * + * @brief Stop the DTMF + * @return Returns 0 on success, others on failure. + */ + int32_t StopDtmf() override; + + /** + * CombineConference + * + * @brief Merge calls to form a conference + * @return Returns 0 on success, others on failure. + */ + int32_t CombineConference() override; + + /** + * SeparateConference + * + * @brief Separates a specified call from a conference call + * @return Returns 0 on success, others on failure. + */ + int32_t SeparateConference() override; + + /** + * GetCurrentCallList + * + * @brief Get current call list + * @param slotId[in], The slot id + * @return Returns call info list. + */ + std::vector GetCurrentCallList(int32_t slotId) override; +private: + std::shared_ptr callControlManagerPtr_; + bool sendDtmfState_; + int32_t sendDtmfCallId_; + std::mutex lock_; +}; +} // namespace Telephony +} // namespace OHOS + +#endif // BLUETOOTH_CALL_SERVICE_H diff --git a/services/bluetooth/include/bluetooth_call_stub.h b/services/bluetooth/include/bluetooth_call_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..df99e5be2e2c9fe45cbd0b44f081ba61ae8c40d8 --- /dev/null +++ b/services/bluetooth/include/bluetooth_call_stub.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021 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 BLUETOOTH_CALL_STUB_H +#define BLUETOOTH_CALL_STUB_H + +#include + +#include "iremote_object.h" +#include "iremote_stub.h" + +#include "i_bluetooth_call.h" + +namespace OHOS { +namespace Telephony { +class BluetoothCallStub : public IRemoteStub { +public: + BluetoothCallStub(); + ~BluetoothCallStub(); + virtual int32_t OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + using BluetoothCallFunc = int32_t (BluetoothCallStub::*)(MessageParcel &data, MessageParcel &reply); + + int32_t OnAnswerCall(MessageParcel &data, MessageParcel &reply); + int32_t OnRejectCall(MessageParcel &data, MessageParcel &reply); + int32_t OnHangUpCall(MessageParcel &data, MessageParcel &reply); + int32_t OnGetBtCallState(MessageParcel &data, MessageParcel &reply); + int32_t OnHoldCall(MessageParcel &data, MessageParcel &reply); + int32_t OnUnHoldCall(MessageParcel &data, MessageParcel &reply); + int32_t OnSwitchCall(MessageParcel &data, MessageParcel &reply); + int32_t OnStartDtmf(MessageParcel &data, MessageParcel &reply); + int32_t OnStopDtmf(MessageParcel &data, MessageParcel &reply); + int32_t OnCombineConference(MessageParcel &data, MessageParcel &reply); + int32_t OnSeparateConference(MessageParcel &data, MessageParcel &reply); + int32_t OnGetCurrentCallList(MessageParcel &data, MessageParcel &reply); + std::map memberFuncMap_; +}; +} // namespace Telephony +} // namespace OHOS + +#endif // BLUETOOTH_CALL_STUB_H \ No newline at end of file diff --git a/services/bluetooth/include/bluetooth_connection.h b/services/bluetooth/include/bluetooth_connection.h old mode 100755 new mode 100644 index 90489f42c6b0d9bbf77770213925e445866e8859..0c214b63d920fde04c4aeec6a26fbf7390b0bb43 --- a/services/bluetooth/include/bluetooth_connection.h +++ b/services/bluetooth/include/bluetooth_connection.h @@ -33,30 +33,38 @@ enum BtScoState { SCO_STATE_PENDING, }; +#ifdef ABILITY_BLUETOOTH_SUPPORT +class BluetoothConnection : public OHOS::Bluetooth::HandsFreeAudioGatewayObserver { +#else class BluetoothConnection { +#endif + public: BluetoothConnection(); ~BluetoothConnection(); + void Init(); bool ConnectBtSco(); bool DisconnectBtSco(); bool IsBtScoConnected(); - static const std::string EVENT_BLUETOOTH_SCO_CONNECTED; - static const std::string EVENT_BLUETOOTH_SCO_DISCONNECTED; static BtScoState GetBtScoState(); static void SetBtScoState(BtScoState state); + int32_t SendBtCallState(int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number); + void RemoveBtDevice(std::string address); #ifdef ABILITY_BLUETOOTH_SUPPORT void OnScoStateChanged(const Bluetooth::BluetoothRemoteDevice &device, int32_t state) override; void OnConnectionStateChanged(const Bluetooth::BluetoothRemoteDevice &device, int32_t state) override; + Bluetooth::BluetoothRemoteDevice GetBtDevice(std::string address); + void AddBtDevice(std::string address, Bluetooth::BluetoothRemoteDevice device); #endif private: bool IsAudioActivated(); static BtScoState btScoState_; std::string connectedScoAddr_; - std::set connectedBtDevices_; #ifdef ABILITY_BLUETOOTH_SUPPORT bool ConnectBtSco(const Bluetooth::BluetoothRemoteDevice &device); bool DisconnectBtSco(const Bluetooth::BluetoothRemoteDevice &device); + std::unordered_map mapConnectedBtDevices_; #endif }; } // namespace Telephony diff --git a/services/bluetooth/src/bluetooth_call_manager.cpp b/services/bluetooth/src/bluetooth_call_manager.cpp old mode 100755 new mode 100644 index 1320a0b2607eb48d52ebbe9a11ad08e8c0f0e74f..1b320cb1674d00d6cd619e5fd6ac3839cfa3b876 --- a/services/bluetooth/src/bluetooth_call_manager.cpp +++ b/services/bluetooth/src/bluetooth_call_manager.cpp @@ -20,40 +20,14 @@ #include "audio_control_manager.h" #include "call_control_manager.h" -#include "bluetooth_state_observer.h" #include "bluetooth_connection.h" -#ifdef ABILITY_BLUETOOTH_SUPPORT -#include "bluetooth_mgr_client.h" -#include "bluetooth_remote_device.h" -#endif - namespace OHOS { namespace Telephony { BluetoothCallManager::BluetoothCallManager() : btConnection_(std::make_unique()) {} BluetoothCallManager::~BluetoothCallManager() {} -int32_t BluetoothCallManager::Init() -{ - if (!BluetoothStateObserver::SubscribeBluetoothEvent()) { - TELEPHONY_LOGE("subscribe bluetooth connection event failed"); - return CALL_ERR_BLUETOOTH_CONNECTION_FAILED; - } - return TELEPHONY_SUCCESS; -} - -void BluetoothCallManager::CallStateUpdated( - sptr &callObjectPtr, TelCallState priorState, TelCallState nextState) -{ - if (callObjectPtr == nullptr) { - TELEPHONY_LOGE("call object nullptr"); - return; - } - std::string number = callObjectPtr->GetAccountNumber(); - SendCallState(nextState, number, GetCallNumberType(number), GetContactsName(number)); -} - bool BluetoothCallManager::ConnectBtSco() { if (btConnection_ == nullptr) { @@ -72,6 +46,16 @@ bool BluetoothCallManager::DisconnectBtSco() return btConnection_->DisconnectBtSco(); } +int32_t BluetoothCallManager::SendBtCallState( + int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number) +{ + if (btConnection_ == nullptr) { + TELEPHONY_LOGE("bluetooth connection nullptr"); + return false; + } + return btConnection_->SendBtCallState(numActive, numHeld, callState, number); +} + BtScoState BluetoothCallManager::GetBtScoState() { if (btConnection_ == nullptr) { @@ -89,108 +73,5 @@ bool BluetoothCallManager::IsBtScoConnected() } return btConnection_->IsBtScoConnected(); } - -bool BluetoothCallManager::AnswerBtCall() -{ - if (!IsBtScoConnected()) { - TELEPHONY_LOGE("bluetooth sco is not connected"); - return false; - } - auto callList = DelayedSingleton::GetInstance()->GetCallList(); - bool result = true; - for (auto call : callList) { - if (call->GetTelCallState() == TelCallState::CALL_STATUS_INCOMING) { - result = DelayedSingleton::GetInstance()->AnswerCall( - call->GetCallID(), static_cast(call->GetVideoStateType())); - TELEPHONY_LOGI("call id : %{public}d, answer result : %{public}d", call->GetCallID(), result); - break; - } - } - return result; -} - -bool BluetoothCallManager::HangupBtCall() -{ - if (!IsBtScoConnected()) { - TELEPHONY_LOGE("bluetooth sco is not connected"); - return false; - } - auto callList = DelayedSingleton::GetInstance()->GetCallList(); - bool result = true; - for (auto call : callList) { - if (call->GetTelCallState() == TelCallState::CALL_STATUS_INCOMING || - call->GetTelCallState() == TelCallState::CALL_STATUS_ACTIVE || - call->GetTelCallState() == TelCallState::CALL_STATUS_HOLDING) { - int32_t ret = DelayedSingleton::GetInstance()->HangUpCall(call->GetCallID()); - TELEPHONY_LOGI("call id : %{public}d, state : %{public}d, hangup result : %{public}d", - call->GetCallID(), call->GetTelCallState(), ret); - if (ret != TELEPHONY_SUCCESS) { - result = false; - } - } - } - return result; -} - -int32_t BluetoothCallManager::SendCallState( - TelCallState callState, const std::string &number, int32_t type, const std::string &name) -{ - if (!IsBtScoConnected()) { - TELEPHONY_LOGE("bluetooth sco is not connected"); - return CALL_ERR_BLUETOOTH_CONNECTION_FAILED; - } -#ifdef ABILITY_BLUETOOTH_SUPPORT - int32_t numActive = - DelayedSingleton::GetInstance()->GetCallNumber(TelCallState::CALL_STATUS_ACTIVE); - int32_t numHeld = - DelayedSingleton::GetInstance()->GetCallNumber(TelCallState::CALL_STATUS_HOLDING); - return BluetoothMgr::BluetoothMgrClient::GetInstance()->PhoneStateChanged( - numActive, numHeld, callState, number, type, name); -#endif - return TELEPHONY_SUCCESS; -} - -int32_t BluetoothCallManager::SendCallList() -{ - if (!IsBtScoConnected()) { - TELEPHONY_LOGE("bluetooth sco is not connected"); - return CALL_ERR_BLUETOOTH_CONNECTION_FAILED; - } -#ifdef ABILITY_BLUETOOTH_SUPPORT - auto callList = DelayedSingleton::GetInstance()->GetCallList(); - bool result = false; - for (auto call : callList) { - result = BluetoothMgr::BluetoothMgrClient::GetInstance()->ClccResponse(call->GetCallID(), - static_cast((call->GetTelCallState())), call->GetAccountNumber(), - static_cast((call->GetVideoStateType()))); - } - return result; -#endif - return TELEPHONY_SUCCESS; -} - -int32_t BluetoothCallManager::GetCallNumberType(const std::string &number) -{ - return DEFAULT_CALL_NUMBER_TYPE; -} - -std::string BluetoothCallManager::GetContactsName(const std::string &number) -{ - return ""; -} - -int32_t BluetoothCallManager::SendDtmf(int32_t callId, char str) -{ - return DelayedSingleton::GetInstance()->StartDtmf(callId, str); -} - -void BluetoothCallManager::NewCallCreated(sptr &callObjectPtr) {} - -void BluetoothCallManager::CallDestroyed(int32_t cause) {} - -void BluetoothCallManager::IncomingCallActivated(sptr &callObjectPtr) {} - -void BluetoothCallManager::IncomingCallHungUp(sptr &callObjectPtr, bool isSendSms, std::string content) -{} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/services/bluetooth/src/bluetooth_call_policy.cpp b/services/bluetooth/src/bluetooth_call_policy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43aab46fe05be859e091e2d85d7a72508ffd2c1d --- /dev/null +++ b/services/bluetooth/src/bluetooth_call_policy.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_policy.h" + +#include "call_manager_errors.h" +#include "telephony_log_wrapper.h" + +namespace OHOS { +namespace Telephony { +BluetoothCallPolicy::BluetoothCallPolicy() {} + +BluetoothCallPolicy::~BluetoothCallPolicy() {} + +int32_t BluetoothCallPolicy::AnswerCallPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_INCOMING, callId)) { + TELEPHONY_LOGI("incoming call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_WAITING, callId)) { + TELEPHONY_LOGI("waiting call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("AnswerCallPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::RejectCallPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_INCOMING, callId)) { + TELEPHONY_LOGI("incoming call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_WAITING, callId)) { + TELEPHONY_LOGI("waiting call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("RejectCallPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::HoldCallPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_ACTIVE, callId)) { + TELEPHONY_LOGI("active call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("HoldCallPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::UnHoldCallPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_HOLDING, callId)) { + TELEPHONY_LOGI("holding call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("HoldCallPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::HangUpPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_INCOMING, callId)) { + TELEPHONY_LOGI("incoming call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_WAITING, callId)) { + TELEPHONY_LOGI("waiting call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_ACTIVE, callId)) { + TELEPHONY_LOGI("active call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_ALERTING, callId)) { + TELEPHONY_LOGI("alerting call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_DIALING, callId)) { + TELEPHONY_LOGI("dialing call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_HOLDING, callId)) { + TELEPHONY_LOGI("holding call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("HangUpPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::SwitchCallPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_ACTIVE) && + IsCallExist(TelCallState::CALL_STATUS_HOLDING, callId)) { + TELEPHONY_LOGI("active call and holding call are exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("SwitchCallPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::StartDtmfPolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_ACTIVE, callId)) { + TELEPHONY_LOGI("active call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_ALERTING, callId)) { + TELEPHONY_LOGI("alerting call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_DIALING, callId)) { + TELEPHONY_LOGI("dialing call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + if (IsCallExist(TelCallState::CALL_STATUS_HOLDING, callId)) { + TELEPHONY_LOGI("holding call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("StartDtmfPolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::CombineConferencePolicy(int32_t &callId) +{ + if (IsCallExist(TelCallState::CALL_STATUS_ACTIVE, callId) && + IsCallExist(TelCallState::CALL_STATUS_HOLDING)) { + TELEPHONY_LOGI("active call and holding call are exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("CombineConferencePolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} + +int32_t BluetoothCallPolicy::SeparateConferencePolicy(int32_t &callId) +{ + if (IsConferenceCallExist(TelConferenceState::TEL_CONFERENCE_ACTIVE, callId) || + IsConferenceCallExist(TelConferenceState::TEL_CONFERENCE_HOLDING, callId)) { + TELEPHONY_LOGI("conference call is exist, callId:%{public}d", callId); + return TELEPHONY_SUCCESS; + } + TELEPHONY_LOGW("SeparateConferencePolicy failed"); + return CALL_ERR_ILLEGAL_CALL_OPERATION; +} +} // namespace Telephony +} // namespace OHOS diff --git a/services/bluetooth/src/bluetooth_call_service.cpp b/services/bluetooth/src/bluetooth_call_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c7cb261735ff2f5a222c5fb6dfdd475d97609db7 --- /dev/null +++ b/services/bluetooth/src/bluetooth_call_service.cpp @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_service.h" + +#include "call_manager_errors.h" +#include "telephony_log_wrapper.h" + +#include "bluetooth_call_manager.h" + +namespace OHOS { +namespace Telephony { +BluetoothCallService::BluetoothCallService() + : callControlManagerPtr_(DelayedSingleton::GetInstance()), + sendDtmfState_(false), sendDtmfCallId_(ERR_ID) +{} + +BluetoothCallService::~BluetoothCallService() +{} + +int32_t BluetoothCallService::AnswerCall() +{ + int32_t callId = ERR_ID; + int32_t ret = AnswerCallPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("AnswerCallPolicy failed!"); + return ret; + } + sptr call = GetOneCallObject(callId); + if (call == nullptr) { + TELEPHONY_LOGE("the call object is nullptr, callId:%{public}d", callId); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + VideoStateType videoState = call->GetVideoStateType(); + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->AnswerCall(callId, static_cast(videoState)); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::RejectCall() +{ + int32_t callId = ERR_ID; + bool rejectWithMessage = false; + std::u16string textMessage = Str8ToStr16(""); + int32_t ret = RejectCallPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("RejectCallPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->RejectCall(callId, rejectWithMessage, textMessage); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::HangUpCall() +{ + int32_t callId = ERR_ID; + int32_t ret = HangUpPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("HangUpPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->HangUpCall(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::GetCallState() +{ + TELEPHONY_LOGI("Entry BluetoothCallService GetCallState"); + int32_t numActive = GetCallNum(TelCallState::CALL_STATUS_ACTIVE); + int32_t numHeld = GetCallNum(TelCallState::CALL_STATUS_HOLDING); + int32_t numDial = GetCallNum(TelCallState::CALL_STATUS_DIALING); + int32_t numAlert = GetCallNum(TelCallState::CALL_STATUS_ALERTING); + int32_t numIncoming = GetCallNum(TelCallState::CALL_STATUS_INCOMING); + int32_t numWait = GetCallNum(TelCallState::CALL_STATUS_WAITING); + int32_t numDisconnected = GetCallNum(TelCallState::CALL_STATUS_DISCONNECTED); + int32_t numDisconnecting = GetCallNum(TelCallState::CALL_STATUS_DISCONNECTING); + int32_t callState = static_cast(TelCallState::CALL_STATUS_IDLE); + std::string number = ""; + if (numHeld > 0) { + callState = static_cast(TelCallState::CALL_STATUS_IDLE); + number = GetCallNumber(TelCallState::CALL_STATUS_HOLDING); + } + if (numActive > 0) { + callState = static_cast(TelCallState::CALL_STATUS_IDLE); + number = GetCallNumber(TelCallState::CALL_STATUS_ACTIVE); + } + if (numDial > 0) { + callState = static_cast(TelCallState::CALL_STATUS_DIALING); + number = GetCallNumber(TelCallState::CALL_STATUS_DIALING); + } + if (numAlert > 0) { + callState = static_cast(TelCallState::CALL_STATUS_ALERTING); + number = GetCallNumber(TelCallState::CALL_STATUS_ALERTING); + } + if (numIncoming > 0) { + callState = static_cast(TelCallState::CALL_STATUS_INCOMING); + number = GetCallNumber(TelCallState::CALL_STATUS_INCOMING); + } + if (numWait > 0) { + callState = static_cast(TelCallState::CALL_STATUS_IDLE); + number = GetCallNumber(TelCallState::CALL_STATUS_WAITING); + } + if (numDisconnected > 0) { + callState = static_cast(TelCallState::CALL_STATUS_IDLE); + number = GetCallNumber(TelCallState::CALL_STATUS_DISCONNECTED); + } + if (numDisconnecting > 0) { + callState = static_cast(TelCallState::CALL_STATUS_IDLE); + number = GetCallNumber(TelCallState::CALL_STATUS_DISCONNECTING); + } + return DelayedSingleton::GetInstance()-> + SendBtCallState(numActive, numHeld, callState, number); +} + +int32_t BluetoothCallService::HoldCall() +{ + int32_t callId = ERR_ID; + int32_t ret = HoldCallPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("HoldCallPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->HoldCall(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::UnHoldCall() +{ + int32_t callId = ERR_ID; + int32_t ret = UnHoldCallPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("UnHoldCallPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->UnHoldCall(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::SwitchCall() +{ + int32_t callId = ERR_ID; + int32_t ret = SwitchCallPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("SwitchCallPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->SwitchCall(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::StartDtmf(char str) +{ + int32_t callId = ERR_ID; + int32_t ret = StartDtmfPolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("StartDtmfPolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + { + std::lock_guard guard(lock_); + sendDtmfState_ = true; + sendDtmfCallId_ = callId; + } + return callControlManagerPtr_->StartDtmf(callId, str); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::StopDtmf() +{ + int32_t callId = ERR_ID; + if (callControlManagerPtr_ != nullptr) { + { + std::lock_guard guard(lock_); + callId = sendDtmfCallId_; + sendDtmfState_ = false; + sendDtmfCallId_ = ERR_ID; + } + return callControlManagerPtr_->StopDtmf(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::CombineConference() +{ + int32_t callId = ERR_ID; + int32_t ret = CombineConferencePolicy(callId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("CombineConferencePolicy failed!"); + return ret; + } + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->CombineConference(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +int32_t BluetoothCallService::SeparateConference() +{ + int32_t callId = ERR_ID; + if (callControlManagerPtr_ != nullptr) { + return callControlManagerPtr_->SeparateConference(callId); + } else { + TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } +} + +std::vector BluetoothCallService::GetCurrentCallList(int32_t slotId) +{ + return GetCallInfoList(slotId); +} +} // namespace Telephony +} // namespace OHOS diff --git a/services/bluetooth/src/bluetooth_call_stub.cpp b/services/bluetooth/src/bluetooth_call_stub.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f537cda740f0333ffaea8dd11b0ce59551ede71 --- /dev/null +++ b/services/bluetooth/src/bluetooth_call_stub.cpp @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_stub.h" + +#include + +#include "call_manager_errors.h" +#include "telephony_log_wrapper.h" + +#include "message_option.h" +#include "message_parcel.h" + +#include "call_control_manager.h" + +namespace OHOS { +namespace Telephony { +BluetoothCallStub::BluetoothCallStub() +{ + memberFuncMap_[INTERFACE_BT_ANSWER_CALL] = &BluetoothCallStub::OnAnswerCall; + memberFuncMap_[INTERFACE_BT_REJECT_CALL] = &BluetoothCallStub::OnRejectCall; + memberFuncMap_[INTERFACE_BT_HOLD_CALL] = &BluetoothCallStub::OnHoldCall; + memberFuncMap_[INTERFACE_BT_UNHOLD_CALL] = &BluetoothCallStub::OnUnHoldCall; + memberFuncMap_[INTERFACE_BT_DISCONNECT_CALL] = &BluetoothCallStub::OnHangUpCall; + memberFuncMap_[INTERFACE_BT_GET_CALL_STATE] = &BluetoothCallStub::OnGetBtCallState; + memberFuncMap_[INTERFACE_BT_SWAP_CALL] = &BluetoothCallStub::OnSwitchCall; + memberFuncMap_[INTERFACE_BT_COMBINE_CONFERENCE] = &BluetoothCallStub::OnCombineConference; + memberFuncMap_[INTERFACE_BT_SEPARATE_CONFERENCE] = &BluetoothCallStub::OnSeparateConference; + memberFuncMap_[INTERFACE_BT_START_DTMF] = &BluetoothCallStub::OnStartDtmf; + memberFuncMap_[INTERFACE_BT_STOP_DTMF] = &BluetoothCallStub::OnStopDtmf; + memberFuncMap_[INTERFACE_BT_GET_CURRENT_CALL_LIST] = &BluetoothCallStub::OnGetCurrentCallList; +} + +BluetoothCallStub::~BluetoothCallStub() +{ + memberFuncMap_.clear(); +} + +int32_t BluetoothCallStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) +{ + std::u16string myDescriptor = BluetoothCallStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (myDescriptor != remoteDescriptor) { + TELEPHONY_LOGE("descriptor checked fail !"); + return TELEPHONY_ERR_DESCRIPTOR_MISMATCH; + } + TELEPHONY_LOGI("OnReceived, cmd = %{public}u", code); + auto itFunc = memberFuncMap_.find(code); + if (itFunc != memberFuncMap_.end()) { + auto memberFunc = itFunc->second; + if (memberFunc != nullptr) { + return (this->*memberFunc)(data, reply); + } + } + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +} + +int32_t BluetoothCallStub::OnAnswerCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = AnswerCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnRejectCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = RejectCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnHangUpCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = HangUpCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnGetBtCallState(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = GetCallState(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + +int32_t BluetoothCallStub::OnHoldCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = HoldCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnUnHoldCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = UnHoldCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnSwitchCall(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = SwitchCall(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return result; +} + +int32_t BluetoothCallStub::OnCombineConference(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = CombineConference(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + +int32_t BluetoothCallStub::OnSeparateConference(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = SeparateConference(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + +int32_t BluetoothCallStub::OnStartDtmf(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = TELEPHONY_ERR_FAIL; + char str = static_cast(data.ReadInt8()); + result = StartDtmf(str); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + +int32_t BluetoothCallStub::OnStopDtmf(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = TELEPHONY_ERR_FAIL; + result = StopDtmf(); + TELEPHONY_LOGI("result:%{public}d", result); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + +int32_t BluetoothCallStub::OnGetCurrentCallList(MessageParcel &data, MessageParcel &reply) +{ + int32_t slotId = data.ReadInt32(); + std::vector callVec = GetCurrentCallList(slotId); + reply.WriteInt32(callVec.size()); + std::vector::iterator it = callVec.begin(); + for (; it != callVec.end(); ++it) { + reply.WriteRawData((const void *)&(*it), sizeof(CallAttributeInfo)); + } + return TELEPHONY_SUCCESS; +} +} // namespace Telephony +} // namespace OHOS diff --git a/services/bluetooth/src/bluetooth_connection.cpp b/services/bluetooth/src/bluetooth_connection.cpp old mode 100755 new mode 100644 index ffd8c19d5d29240fb8be1b4564ea13335ad861ca..4b0004b691e0b6a51528384bf365d5be8be5da19 --- a/services/bluetooth/src/bluetooth_connection.cpp +++ b/services/bluetooth/src/bluetooth_connection.cpp @@ -19,21 +19,27 @@ #include "audio_control_manager.h" #include "bluetooth_call_manager.h" -#ifdef ABILITY_BLUETOOTH_SUPPORT -#include "bt_def.h" -#endif namespace OHOS { namespace Telephony { BtScoState BluetoothConnection::btScoState_ = BtScoState::SCO_STATE_DISCONNECTED; -const std::string BluetoothConnection::EVENT_BLUETOOTH_SCO_CONNECTED = "usual.event.BLUETOOTH_SCO_CONNECTED"; -const std::string BluetoothConnection::EVENT_BLUETOOTH_SCO_DISCONNECTED = "usual.event.BLUETOOTH_SCO_DISCONNECTED"; BluetoothConnection::BluetoothConnection() : connectedScoAddr_("") {} BluetoothConnection::~BluetoothConnection() { - connectedBtDevices_.clear(); +#ifdef ABILITY_BLUETOOTH_SUPPORT + mapConnectedBtDevices_.clear(); + Bluetooth::HandsFreeAudioGateway::GetProfile()->DeregisterObserver(this); +#endif +} + +void BluetoothConnection::Init() +{ +#ifdef ABILITY_BLUETOOTH_SUPPORT + TELEPHONY_LOGI("BluetoothConnection init success!"); + Bluetooth::HandsFreeAudioGateway::GetProfile()->RegisterObserver(this); +#endif } bool BluetoothConnection::ConnectBtSco() @@ -43,7 +49,7 @@ bool BluetoothConnection::ConnectBtSco() return true; } #ifdef ABILITY_BLUETOOTH_SUPPORT - return Bluetooth::HandsFreeAudioGateway.GetProfile()->ConnectSco(); + return Bluetooth::HandsFreeAudioGateway::GetProfile()->ConnectSco(); #endif return true; } @@ -55,7 +61,7 @@ bool BluetoothConnection::DisconnectBtSco() return true; } #ifdef ABILITY_BLUETOOTH_SUPPORT - return Bluetooth::HandsFreeAudioGateway.GetProfile()->DisconnectSco(); + return Bluetooth::HandsFreeAudioGateway::GetProfile()->DisconnectSco(); #endif return true; } @@ -63,7 +69,7 @@ bool BluetoothConnection::DisconnectBtSco() #ifdef ABILITY_BLUETOOTH_SUPPORT bool BluetoothConnection::ConnectBtSco(const Bluetooth::BluetoothRemoteDevice &device) { - bool result = Bluetooth::HandsFreeAudioGateway.GetProfile()->Connect(device); + bool result = Bluetooth::HandsFreeAudioGateway::GetProfile()->Connect(device); if (result) { connectedScoAddr_ = device.GetDeviceAddr(); btScoState_ = BtScoState::SCO_STATE_CONNECTED; @@ -98,6 +104,20 @@ void BluetoothConnection::SetBtScoState(BtScoState state) btScoState_ = state; } +int32_t BluetoothConnection::SendBtCallState( + int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number) +{ +#ifdef ABILITY_BLUETOOTH_SUPPORT + std::string nickName = ""; + constexpr int32_t numberType = 0x81; + Bluetooth::HandsFreeAudioGateway::GetProfile()-> + PhoneStateChanged(numActive, numHeld, callState, number, numberType, nickName); +#endif + TELEPHONY_LOGI("PhoneStateChanged,numActive:%{public}d,numHeld:%{public}d,callState:%{public}d", + numActive, numHeld, callState); + return TELEPHONY_SUCCESS; +} + BtScoState BluetoothConnection::GetBtScoState() { TELEPHONY_LOGI("current bluetooth sco state : %{public}d", btScoState_); @@ -143,7 +163,7 @@ void BluetoothConnection::OnConnectionStateChanged(const Bluetooth::BluetoothRem * if connect sco successfully , should switch current audio device to bluetooth sco */ if (BluetoothConnection::GetBtScoState() == BtScoState::SCO_STATE_DISCONNECTED && - IsAudioActivated() && ConnectBtSco(macAddress)) { + IsAudioActivated() && ConnectBtSco(device)) { connectedScoAddr_ = macAddress; DelayedSingleton::GetInstance()->ProcessEvent( AudioEvent::BLUETOOTH_SCO_CONNECTED); diff --git a/services/bluetooth/src/bluetooth_state_observer.cpp b/services/bluetooth/src/bluetooth_state_observer.cpp deleted file mode 100755 index 9bb6a03762765a617dc5bbedf588ecad60c4ac53..0000000000000000000000000000000000000000 --- a/services/bluetooth/src/bluetooth_state_observer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2021 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 "bluetooth_state_observer.h" - -#include "telephony_log_wrapper.h" - -#include "bluetooth_connection.h" -#include "audio_device_manager.h" - -namespace OHOS { -namespace Telephony { -std::shared_ptr BluetoothStateObserver::btEventSubscriber_ = nullptr; - -BtEventSubscriber::BtEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo) - : CommonEventSubscriber(subscriberInfo) -{} - -void BtEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data) -{ - OHOS::EventFwk::Want want = data.GetWant(); - std::string action = want.GetAction(); - if (action == BluetoothConnection::EVENT_BLUETOOTH_SCO_CONNECTED) { - TELEPHONY_LOGI("bluetooth connection receive action : EVENT_BLUETOOTH_SCO_CONNECTED"); - BluetoothConnection::SetBtScoState(BtScoState::SCO_STATE_CONNECTED); - DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::BLUETOOTH_SCO_CONNECTED); - } else if (action == BluetoothConnection::EVENT_BLUETOOTH_SCO_DISCONNECTED) { - TELEPHONY_LOGI("bluetooth connection receive action : EVENT_BLUETOOTH_SCO_DISCONNECTED"); - BluetoothConnection::SetBtScoState(BtScoState::SCO_STATE_DISCONNECTED); - DelayedSingleton::GetInstance()->ProcessEvent(AudioEvent::BLUETOOTH_SCO_DISCONNECTED); - } -} - -BluetoothStateObserver::~BluetoothStateObserver() -{ - if (btEventSubscriber_ != nullptr) { - UnSubscribeBluetoothEvent(); - } -} - -bool BluetoothStateObserver::SubscribeBluetoothEvent() -{ - EventFwk::MatchingSkills matchingSkills; - matchingSkills.AddEvent(BluetoothConnection::EVENT_BLUETOOTH_SCO_CONNECTED); - matchingSkills.AddEvent(BluetoothConnection::EVENT_BLUETOOTH_SCO_DISCONNECTED); - EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills); - btEventSubscriber_ = std::make_shared(subscriberInfo); - if (btEventSubscriber_ == nullptr) { - TELEPHONY_LOGE("bt connection nullptr"); - return false; - } - return EventFwk::CommonEventManager::SubscribeCommonEvent(btEventSubscriber_); -} - -bool BluetoothStateObserver::UnSubscribeBluetoothEvent() -{ - if (btEventSubscriber_ == nullptr) { - TELEPHONY_LOGE("bt connection nullptr"); - return false; - } - return EventFwk::CommonEventManager::UnSubscribeCommonEvent(btEventSubscriber_); -} -} // namespace Telephony -} // namespace OHOS \ No newline at end of file diff --git a/services/call/call_state_observer/include/call_data_base_helper.h b/services/call/call_state_observer/include/call_data_base_helper.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/call_recording_tone.h b/services/call/call_state_observer/include/call_recording_tone.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/call_records_handler.h b/services/call/call_state_observer/include/call_records_handler.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/call_records_manager.h b/services/call/call_state_observer/include/call_records_manager.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/call_state_broadcast.h b/services/call/call_state_observer/include/call_state_broadcast.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/incoming_call_notification.h b/services/call/call_state_observer/include/incoming_call_notification.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/incoming_call_wake_up.h b/services/call/call_state_observer/include/incoming_call_wake_up.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/missed_call_notification.h b/services/call/call_state_observer/include/missed_call_notification.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/proximity_sensor.h b/services/call/call_state_observer/include/proximity_sensor.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/reject_call_sms.h b/services/call/call_state_observer/include/reject_call_sms.h old mode 100755 new mode 100644 index 25cc35f03037124a2efe5ea3d271486802d9d618..fe4852e0486b6231aa05b86ac5304e7cf3f7a887 --- a/services/call/call_state_observer/include/reject_call_sms.h +++ b/services/call/call_state_observer/include/reject_call_sms.h @@ -18,7 +18,7 @@ #include "call_state_listener_base.h" -#include "short_message_manager.h" +#include "sms_service_manager_client.h" namespace OHOS { namespace Telephony { @@ -33,7 +33,6 @@ public: void CallStateUpdated(sptr &callObjectPtr, TelCallState priorState, TelCallState nextState) override; private: - std::unique_ptr msgManager_; void SendMessage(int32_t slotId, const std::u16string &desAddr, const std::u16string &text); std::u16string ConvertToUtf16(const std::string &str); }; diff --git a/services/call/call_state_observer/include/status_bar.h b/services/call/call_state_observer/include/status_bar.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/include/wired_headset.h b/services/call/call_state_observer/include/wired_headset.h old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/call_data_base_helper.cpp b/services/call/call_state_observer/src/call_data_base_helper.cpp old mode 100755 new mode 100644 index bfe208d925b92ff67e28c1c4b67d87134a3cc888..8ea9037564161fca2bbfef0c78575a6cedd3444d --- a/services/call/call_state_observer/src/call_data_base_helper.cpp +++ b/services/call/call_state_observer/src/call_data_base_helper.cpp @@ -36,6 +36,7 @@ void CallDataRdbObserver::OnChange() std::shared_ptr callDataPtr = DelayedSingleton::GetInstance(); if (callDataPtr == nullptr) { TELEPHONY_LOGE("callDataPtr is nullptr!"); + return; } NativeRdb::DataAbilityPredicates predicates; @@ -74,6 +75,7 @@ void CallDataBaseHelper::RegisterObserver(std::vector *phones) callDataRdbObserverPtr_ = (std::make_unique(phones)).release(); if (callDataRdbObserverPtr_ == nullptr) { TELEPHONY_LOGE("callDataRdbObserverPtr_ is null"); + return; } helper->RegisterObserver(uri, callDataRdbObserverPtr_); } @@ -88,6 +90,7 @@ void CallDataBaseHelper::UnRegisterObserver() Uri uri(CALL_BLOCK); if (callDataRdbObserverPtr_ == nullptr) { TELEPHONY_LOGE("callDataRdbObserverPtr_ is null"); + return; } helper->UnregisterObserver(uri, callDataRdbObserverPtr_); } diff --git a/services/call/call_state_observer/src/call_recording_tone.cpp b/services/call/call_state_observer/src/call_recording_tone.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/call_records_handler.cpp b/services/call/call_state_observer/src/call_records_handler.cpp old mode 100755 new mode 100644 index b8f961b21a57b578f795a0fb2e109807a1f2ca50..963f116c5bd5456f89ad2fa01a5515f604cb00b4 --- a/services/call/call_state_observer/src/call_records_handler.cpp +++ b/services/call/call_state_observer/src/call_records_handler.cpp @@ -56,14 +56,14 @@ void CallRecordsHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &eve bucket.PutInt(CALL_IS_READ, 0); bucket.PutInt(CALL_RING_DURATION, info.ringDuration); bucket.PutInt(CALL_TALK_DURATION, info.callDuration); - bucket.PutString(CALL_FORMAT_NUMBER, std::string("")); + bucket.PutString(CALL_FORMAT_NUMBER, std::string(info.formattedPhoneNumber)); bucket.PutString(CALL_QUICKSEARCH_KEY, std::string("")); bucket.PutInt(CALL_NUMBER_TYPE, 0); bucket.PutString(CALL_NUMBER_TYPE_NAME, std::string("")); bucket.PutInt(CALL_BEGIN_TIME, info.callBeginTime); bucket.PutInt(CALL_END_TIME, info.callEndTime); bucket.PutInt(CALL_ANSWER_STATE, static_cast(info.answerType)); - uint64_t timeStamp = time(0); + time_t timeStamp = time(0); bucket.PutInt(CALL_CREATE_TIME, timeStamp); bucket.PutString(CALL_NUMBER_LOCATION, std::string("")); bucket.PutInt(CALL_PHOTO_ID, 0); diff --git a/services/call/call_state_observer/src/call_records_manager.cpp b/services/call/call_state_observer/src/call_records_manager.cpp old mode 100755 new mode 100644 index 6e288a01c5ebca3daf1d8b7941e68cdcb3f7e685..72493ac7e2a1b46ca83b6f36919fd2c4668d1b01 --- a/services/call/call_state_observer/src/call_records_manager.cpp +++ b/services/call/call_state_observer/src/call_records_manager.cpp @@ -17,6 +17,7 @@ #include "securec.h" #include "call_manager_inner_type.h" +#include "call_number_utils.h" namespace OHOS { namespace Telephony { @@ -69,7 +70,9 @@ void CallRecordsManager::AddOneCallRecord(CallAttributeInfo &info) TELEPHONY_LOGE("callRecordsHandlerServerPtr_ is nullptr"); return; } - if (memcpy_s(data.phoneNumber, kMaxNumberLen, info.accountNumber, strlen(info.accountNumber)) != 0) { + errno_t result = memcpy_s(data.phoneNumber, kMaxNumberLen, info.accountNumber, + strlen(info.accountNumber)); + if (result != EOK) { TELEPHONY_LOGE("memcpy_s failed!"); return; } @@ -89,6 +92,13 @@ void CallRecordsManager::AddOneCallRecord(CallAttributeInfo &info) data.directionType = info.callDirection; data.answerType = info.answerType; data.countryCode = DEFAULT_COUNTRY_CODE; + std::string tmpStr(""); + (void)DelayedSingleton::GetInstance()->FormatPhoneNumber( + std::string(data.phoneNumber), "CN", tmpStr); + if (memcpy_s(data.formattedPhoneNumber, kMaxNumberLen, tmpStr.c_str(), tmpStr.length()) != 0) { + TELEPHONY_LOGE("memcpy_s failed!"); + return; + } callRecordsHandlerServerPtr_->StoreCallRecord(data); } } // namespace Telephony diff --git a/services/call/call_state_observer/src/call_state_broadcast.cpp b/services/call/call_state_observer/src/call_state_broadcast.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/incoming_call_notification.cpp b/services/call/call_state_observer/src/incoming_call_notification.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/incoming_call_wake_up.cpp b/services/call/call_state_observer/src/incoming_call_wake_up.cpp old mode 100755 new mode 100644 index d297a4d67c0efeff93a56480e5f1e4f1483d053d..f8834c176a2a8b8aa2ff24a313bf71f27f84dcbe --- a/services/call/call_state_observer/src/incoming_call_wake_up.cpp +++ b/services/call/call_state_observer/src/incoming_call_wake_up.cpp @@ -35,7 +35,7 @@ void IncomingCallWakeup::NewCallCreated(sptr &callObjectPtr) void IncomingCallWakeup::WakeupDevice() { if (IsScreenOn()) { - TELEPHONY_LOGE("screen already up"); + TELEPHONY_LOGI("screen already up"); return; } PowerMgr::PowerMgrClient::GetInstance().WakeupDevice( diff --git a/services/call/call_state_observer/src/missed_call_notification.cpp b/services/call/call_state_observer/src/missed_call_notification.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/proximity_sensor.cpp b/services/call/call_state_observer/src/proximity_sensor.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/reject_call_sms.cpp b/services/call/call_state_observer/src/reject_call_sms.cpp old mode 100755 new mode 100644 index 48836fa874aacbe5a1e569bc5e72d3011ee0708f..411bff502491de13d286a524750d23c3fc9445cb --- a/services/call/call_state_observer/src/reject_call_sms.cpp +++ b/services/call/call_state_observer/src/reject_call_sms.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace Telephony { -RejectCallSms::RejectCallSms() : msgManager_(std::make_unique()) {} +RejectCallSms::RejectCallSms() {} void RejectCallSms::IncomingCallHungUp(sptr &callObjectPtr, bool isSendSms, std::string content) { @@ -34,11 +34,12 @@ void RejectCallSms::IncomingCallHungUp(sptr &callObjectPtr, bool isSen void RejectCallSms::SendMessage(int32_t slotId, const std::u16string &desAddr, const std::u16string &text) { - if (msgManager_ == nullptr) { + auto msgManager = DelayedSingleton::GetInstance(); + if (msgManager == nullptr) { TELEPHONY_LOGE("short message manager nullptr"); return; } - msgManager_->SendMessage(slotId, desAddr, ConvertToUtf16(""), text, nullptr, nullptr); + msgManager->SendMessage(slotId, desAddr, ConvertToUtf16(""), text, nullptr, nullptr); TELEPHONY_LOGI("reject call message sended"); } diff --git a/services/call/call_state_observer/src/status_bar.cpp b/services/call/call_state_observer/src/status_bar.cpp old mode 100755 new mode 100644 diff --git a/services/call/call_state_observer/src/wired_headset.cpp b/services/call/call_state_observer/src/wired_headset.cpp old mode 100755 new mode 100644 diff --git a/services/call/include/call_base.h b/services/call/include/call_base.h old mode 100755 new mode 100644 index fded5d620e56268e889d002d776fc93e7d62ec8e..0c523d1b78a0b98c4a186ab4f54af94dc995df03 --- a/services/call/include/call_base.h +++ b/services/call/include/call_base.h @@ -62,6 +62,7 @@ public: virtual std::vector GetSubCallIdList() = 0; virtual std::vector GetCallIdListForConference() = 0; virtual int32_t IsSupportConferenceable() = 0; + virtual int32_t SetMute(int32_t mute, int32_t slotId) = 0; int32_t DialCallBase(); int32_t IncomingCallBase(); int32_t AnswerCallBase(); @@ -80,6 +81,13 @@ public: uint64_t GetPolicyFlag(); bool GetCallerInfo(ContactInfo &info); void SetCallerInfo(const ContactInfo &contactInfo); + void SetCallRunningState(CallRunningState callRunningState); + void SetStartTime(int64_t startTime); + void SetCallBeginTime(time_t callBeginTime); + void SetCallEndTime(time_t callEndTime); + void SetRingBeginTime(time_t ringBeginTime); + void SetRingEndTime(time_t ringEndTime); + void SetAnswerType(CallAnswerType answerType); CallEndedType GetCallEndedType(); int32_t SetCallEndedType(CallEndedType callEndedType); bool IsSpeakerphoneEnabled(); diff --git a/services/call/include/call_broadcast_subscriber.h b/services/call/include/call_broadcast_subscriber.h old mode 100755 new mode 100644 diff --git a/services/call/include/call_control_manager.h b/services/call/include/call_control_manager.h old mode 100755 new mode 100644 index 2fa43b260a938db4515a80d370ddb6fc3ac8a590..c1e9a46099136ae804962746fa78f56f082d209c --- a/services/call/include/call_control_manager.h +++ b/services/call/include/call_control_manager.h @@ -23,19 +23,19 @@ #include "pac_map.h" #include "singleton.h" -#include "cellular_call_types.h" #include "call_setting_manager.h" #include "call_policy.h" #include "call_state_listener.h" #include "call_request_handler.h" #include "missed_call_notification.h" +#include "incoming_call_wake_up.h" /** * Singleton * @ClassName:CallControlManager * @Description:CallControlManager is designed for performing dial/answer/reject etc ops - * on kinds of calls(ims,cs,ott). usually as a entrance for downflowed [app->ril] telephony business + * on kinds of calls(ims,cs,ott). usually as an entrance for downflowed [app->ril] telephony business */ namespace OHOS { namespace Telephony { @@ -115,6 +115,7 @@ private: std::unique_ptr callStateListenerPtr_; std::unique_ptr callRequestHandlerServicePtr_; // notify when incoming calls are ignored, not rejected or answered + std::unique_ptr incomingCallWakeup_; std::unique_ptr missedCallNotification_; std::unique_ptr callSettingManagerPtr_; DialParaInfo dialSrcInfo_; diff --git a/services/call/include/call_incoming_filter_manager.h b/services/call/include/call_incoming_filter_manager.h old mode 100755 new mode 100644 index 22faa0e43e0d8ab07ffffc26c187687c836b7ed8..a98a602baa4337e0fdc4247d5d26e3daa2d5b066 --- a/services/call/include/call_incoming_filter_manager.h +++ b/services/call/include/call_incoming_filter_manager.h @@ -22,7 +22,6 @@ #include "call_base.h" #include "call_status_policy.h" -#include "cellular_call_types.h" #include "call_data_base_helper.h" namespace OHOS { diff --git a/services/call/include/call_object_manager.h b/services/call/include/call_object_manager.h old mode 100755 new mode 100644 index 67847dbbd88fcbe1ccb89b4c357ee6bff4ef6340..377ed36882ae12614c68a1b33d2a1f69c71bc4cc --- a/services/call/include/call_object_manager.h +++ b/services/call/include/call_object_manager.h @@ -26,6 +26,7 @@ #include "call_base.h" #include "common_type.h" +#include "call_manager_inner_type.h" namespace OHOS { namespace Telephony { @@ -54,7 +55,11 @@ public: static sptr GetOneCallObject(CallRunningState callState); static bool IsCallExist(CallType type, TelCallState callState); static bool IsCallExist(TelCallState callState); - + static bool IsCallExist(TelCallState callState, int32_t &callId); + static bool IsConferenceCallExist(TelConferenceState state, int32_t &callId); + static int32_t GetCallNum(TelCallState callState); + static std::string GetCallNumber(TelCallState callState); + static std::vector GetCallInfoList(int32_t slotId); private: static std::list> callObjectPtrList_; static std::mutex listMutex_; diff --git a/services/call/include/call_policy.h b/services/call/include/call_policy.h old mode 100755 new mode 100644 diff --git a/services/call/include/call_request_handler.h b/services/call/include/call_request_handler.h old mode 100755 new mode 100644 diff --git a/services/call/include/call_request_process.h b/services/call/include/call_request_process.h old mode 100755 new mode 100644 index 3ae6ae9bede58ea24fc520228d6d69d2462c6548..43b07c1b68bb642f61d5dcf54894dd8c91378c76 --- a/services/call/include/call_request_process.h +++ b/services/call/include/call_request_process.h @@ -16,8 +16,6 @@ #ifndef CALL_REQUEST_PROCESS_H #define CALL_REQUEST_PROCESS_H -#include "cellular_call_types.h" - #include "call_object_manager.h" namespace OHOS { diff --git a/services/call/include/call_state_listener.h b/services/call/include/call_state_listener.h old mode 100755 new mode 100644 diff --git a/services/call/include/call_state_listener_base.h b/services/call/include/call_state_listener_base.h old mode 100755 new mode 100644 diff --git a/services/call/include/call_status_manager.h b/services/call/include/call_status_manager.h old mode 100755 new mode 100644 index 9d14d0993a2d2e8eebe5abe170f4517646bdba10..8dc3aa8d3fb8c536411e499d797f4f5208c239f1 --- a/services/call/include/call_status_manager.h +++ b/services/call/include/call_status_manager.h @@ -58,6 +58,7 @@ private: int32_t DisconnectingHandle(const CallDetailInfo &info); int32_t DisconnectedHandle(const CallDetailInfo &info); sptr CreateNewCall(const CallDetailInfo &info, CallDirection dir); + sptr RefreshCallIfNecessary(const sptr &call, const CallDetailInfo &info); void PackParaInfo( DialParaInfo ¶Info, const CallDetailInfo &info, CallDirection dir, AppExecFwk::PacMap &extras); int32_t UpdateCallState(sptr &call, TelCallState nextState); diff --git a/services/call/include/call_status_policy.h b/services/call/include/call_status_policy.h old mode 100755 new mode 100644 diff --git a/services/call/include/carrier_call.h b/services/call/include/carrier_call.h old mode 100755 new mode 100644 index ac757e060611d0b1f06a98c5e94d43cebd737b54..8ccae7e1572562a639f1cff7677f354582da3c22 --- a/services/call/include/carrier_call.h +++ b/services/call/include/carrier_call.h @@ -16,8 +16,6 @@ #ifndef CARRIER_CALL_H #define CARRIER_CALL_H -#include "cellular_call_types.h" - #include "call_base.h" #include "cellular_call_connection.h" @@ -34,6 +32,7 @@ public: int32_t CarrierHangUpCall(); int32_t CarrierHoldCall(); int32_t CarrierUnHoldCall(); + int32_t CarrierSetMute(int32_t mute, int32_t slotId); void GetCallAttributeCarrierInfo(CallAttributeInfo &info); bool GetEmergencyState() override; int32_t CarrierSwitchCall(); diff --git a/services/call/include/common_type.h b/services/call/include/common_type.h old mode 100755 new mode 100644 index 5a79858cc78224a56844ea894bbb521d4f4ca123..136a3662996bec96bd4110dec5765b0c7f68449c --- a/services/call/include/common_type.h +++ b/services/call/include/common_type.h @@ -23,15 +23,18 @@ #include "call_manager_inner_type.h" #include "telephony_log_wrapper.h" -const int16_t kMaxRingingCallNumberLen = 30; -const int16_t kMaxDialingCallNumberLen = 30; -const int16_t kMaxManeLen = 10; -const int16_t kMaxPathKeyLen = 60; -const int16_t kCallStartId = 1; -const int16_t kMilliSecond = 1000; +const int16_t RINGING_CALL_NUMBER_LEN = 30; +const int16_t DIALING_CALL_NUMBER_LEN = 30; +const int16_t CONTACT_NAME_LEN = 10; +const int16_t FILE_PATH_MAX_LEN = 60; +const int16_t CALL_START_ID = 0; + namespace OHOS { namespace Telephony { struct DialParaInfo { + DialParaInfo() : accountId(0), callId(0), index(0), dialType(DialType::DIAL_CARRIER_TYPE), + videoState(VideoStateType::TYPE_VOICE), callType(CallType::TYPE_ERR_CALL), + callState(TelCallState::CALL_STATUS_IDLE), isDialing(false), isEcc(false) {} int32_t accountId; int32_t callId; int32_t index; @@ -71,10 +74,10 @@ enum PolicyFlag : uint64_t { }; struct ContactInfo { - char name[kMaxManeLen]; + char name[CONTACT_NAME_LEN]; char number[kMaxNumberLen]; bool isContacterExists; - char ringtonePath[kMaxPathKeyLen]; + char ringtonePath[FILE_PATH_MAX_LEN]; bool isSendToVoicemail; bool isEcc; bool isVoiceMail; diff --git a/services/call/include/conference_base.h b/services/call/include/conference_base.h old mode 100755 new mode 100644 diff --git a/services/call/include/cs_call.h b/services/call/include/cs_call.h old mode 100755 new mode 100644 index 3ef7f8911cb42e66439f819e9636bbe3239f99f2..ac0ff747ffd7ed2b71468c0dd506fd137d8bf430 --- a/services/call/include/cs_call.h +++ b/services/call/include/cs_call.h @@ -34,6 +34,7 @@ public: int32_t UnHoldCall() override; int32_t SwitchCall() override; void GetCallAttributeInfo(CallAttributeInfo &info) override; + int32_t SetMute(int32_t mute, int32_t slotId) override; int32_t CombineConference() override; // merge calls int32_t SeparateConference() override; int32_t CanCombineConference() override; diff --git a/services/call/include/cs_conference.h b/services/call/include/cs_conference.h old mode 100755 new mode 100644 diff --git a/services/call/include/ims_call.h b/services/call/include/ims_call.h old mode 100755 new mode 100644 index fe671c2c7a8138b63c65467265a4890ff591ea97..302fd5a6dfa38f3f0dd1d86f1d45c15520e19ce3 --- a/services/call/include/ims_call.h +++ b/services/call/include/ims_call.h @@ -49,7 +49,7 @@ public: int32_t IsSupportConferenceable() override; int32_t StartRtt(std::u16string &msg); int32_t StopRtt(); - int32_t SetMute(int32_t mute, int32_t slotId); + int32_t SetMute(int32_t mute, int32_t slotId) override; int32_t AcceptVideoCall(); int32_t RefuseVideoCall(); int32_t SendUpdateCallMediaModeRequest(ImsCallMode mode) override; diff --git a/services/call/include/ims_conference.h b/services/call/include/ims_conference.h old mode 100755 new mode 100644 diff --git a/services/call/include/net_call_base.h b/services/call/include/net_call_base.h old mode 100755 new mode 100644 diff --git a/services/call/include/ott_call.h b/services/call/include/ott_call.h old mode 100755 new mode 100644 index a4373f172d88a72858d9446128da90f0a4bdf555..20247c74e7d0dbbb184487c4e0b1391f6bb2da0c --- a/services/call/include/ott_call.h +++ b/services/call/include/ott_call.h @@ -56,9 +56,10 @@ public: int32_t ReceiveUpdateCallMediaModeResponse(CallMediaModeResponse &reponse) override; int32_t DispatchUpdateVideoRequest(ImsCallMode mode) override; int32_t DispatchUpdateVideoResponse(ImsCallMode mode) override; + int32_t SetMute(int32_t mute, int32_t slotId) override; private: - void PackOttCallRequestInfo(OttCallRequestInfo &requestInfo); + int32_t PackOttCallRequestInfo(OttCallRequestInfo &requestInfo); private: std::unique_ptr ottCallConnectionPtr_; diff --git a/services/call/include/ott_call_connection.h b/services/call/include/ott_call_connection.h old mode 100755 new mode 100644 diff --git a/services/call/include/ott_conference.h b/services/call/include/ott_conference.h old mode 100755 new mode 100644 diff --git a/services/call/include/video_call_state.h b/services/call/include/video_call_state.h old mode 100755 new mode 100644 diff --git a/services/call/src/call_base.cpp b/services/call/src/call_base.cpp old mode 100755 new mode 100644 index 38a030084715fad67f3636fb918c31f25d46e908..9f863a64cf29b38a262254c27452e9aeec700409 --- a/services/call/src/call_base.cpp +++ b/services/call/src/call_base.cpp @@ -99,7 +99,9 @@ void CallBase::GetCallAttributeBaseInfo(CallAttributeInfo &info) info.ringEndTime = ringEndTime_; info.callDirection = direction_; info.answerType = answerType_; - if (memcpy_s(info.bundleName, kMaxBundleNameLen, bundleName_.c_str(), bundleName_.length()) != 0) { + errno_t result = memcpy_s(info.bundleName, kMaxBundleNameLen, bundleName_.c_str(), + bundleName_.length()); + if (result != EOK) { TELEPHONY_LOGE("memcpy_s failed!"); } } @@ -283,6 +285,48 @@ void CallBase::SetCallerInfo(const ContactInfo &info) contactInfo_ = info; } +void CallBase::SetCallRunningState(CallRunningState callRunningState) +{ + std::lock_guard lock(mutex_); + callRunningState_ = callRunningState; +} + +void CallBase::SetStartTime(int64_t startTime) +{ + std::lock_guard lock(mutex_); + startTime_ = startTime; +} + +void CallBase::SetCallBeginTime(time_t callBeginTime) +{ + std::lock_guard lock(mutex_); + callBeginTime_ = callBeginTime; +} + +void CallBase::SetCallEndTime(time_t callEndTime) +{ + std::lock_guard lock(mutex_); + callEndTime_ = callEndTime; +} + +void CallBase::SetRingBeginTime(time_t ringBeginTime) +{ + std::lock_guard lock(mutex_); + ringBeginTime_ = ringBeginTime; +} + +void CallBase::SetRingEndTime(time_t ringEndTime) +{ + std::lock_guard lock(mutex_); + ringEndTime_ = ringEndTime; +} + +void CallBase::SetAnswerType(CallAnswerType answerType) +{ + std::lock_guard lock(mutex_); + answerType_ = answerType; +} + CallEndedType CallBase::GetCallEndedType() { std::lock_guard lock(mutex_); diff --git a/services/call/src/call_broadcast_subscriber.cpp b/services/call/src/call_broadcast_subscriber.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/call_control_manager.cpp b/services/call/src/call_control_manager.cpp old mode 100755 new mode 100644 index 412d5b3b4935fc06d25c22236ae34713674715e8..7a4000a69151b8774f0ca4216604c192103ef92d --- a/services/call/src/call_control_manager.cpp +++ b/services/call/src/call_control_manager.cpp @@ -37,8 +37,8 @@ namespace OHOS { namespace Telephony { CallControlManager::CallControlManager() - : callStateListenerPtr_(nullptr), callRequestHandlerServicePtr_(nullptr), missedCallNotification_(nullptr), - callSettingManagerPtr_(nullptr) + : callStateListenerPtr_(nullptr), callRequestHandlerServicePtr_(nullptr), incomingCallWakeup_(nullptr), + missedCallNotification_(nullptr), callSettingManagerPtr_(nullptr) { dialSrcInfo_.callId = ERR_ID; dialSrcInfo_.number = ""; @@ -61,6 +61,11 @@ bool CallControlManager::Init() return false; } callRequestHandlerServicePtr_->Start(); + incomingCallWakeup_ = std::make_unique(); + if (incomingCallWakeup_ == nullptr) { + TELEPHONY_LOGE("incomingCallWakeup_ is null"); + return false; + } missedCallNotification_ = std::make_unique(); if (missedCallNotification_ == nullptr) { TELEPHONY_LOGE("missedCallNotification_ is null"); @@ -76,7 +81,6 @@ bool CallControlManager::Init() return false; } DelayedSingleton::GetInstance()->Init(); - DelayedSingleton::GetInstance()->Init(); CallStateObserve(); return true; } @@ -95,7 +99,7 @@ int32_t CallControlManager::DialCall(std::u16string &number, AppExecFwk::PacMap accountNumber, extras.GetIntValue("accountId"), errorCode); ret = DialPolicy(number, extras, isEcc); if (ret != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("dial policy result:%{public}d", ret); + TELEPHONY_LOGE("dial policy result:%{public}d", ret); return ret; } // temporarily save dial information @@ -794,6 +798,15 @@ int32_t CallControlManager::JoinConference(int32_t callId, std::vector call = CallObjectManager::GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_ACTIVE); + if (call != nullptr) { + if (call->GetCallType() == CallType::TYPE_IMS + || call->GetCallType() == CallType::TYPE_CS) { + TELEPHONY_LOGI("SetMute by ims or cs"); + call->SetMute(call->GetSlotId(), isMute); + } + } + return DelayedSingleton::GetInstance()->SetMute(isMute); } @@ -907,6 +920,7 @@ void CallControlManager::CallStateObserve() callStateListenerPtr_->AddOneObserver(hangUpSmsPtr.release()); callStateListenerPtr_->AddOneObserver(callStateBroadcastPtr.release()); callStateListenerPtr_->AddOneObserver(missedCallNotification_.release()); + callStateListenerPtr_->AddOneObserver(incomingCallWakeup_.release()); callStateListenerPtr_->AddOneObserver(DelayedSingleton::GetInstance().get()); } @@ -947,11 +961,11 @@ bool CallControlManager::onButtonDealing(HeadsetButtonService::ButtonEvent type) bool isRingState = false; sptr call = nullptr; - if (call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_RINGING) != nullptr) { + if ((call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_RINGING)) != nullptr) { isRingState = true; - } else if (call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_DIALING) != nullptr || - call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_ACTIVE) != nullptr || - call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_HOLD) != nullptr) { + } else if (((call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_DIALING)) != nullptr) || + ((call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_ACTIVE)) != nullptr) || + ((call = GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_HOLD)) != nullptr)) { isRingState = false; } else { return false; diff --git a/services/call/src/call_incoming_filter_manager.cpp b/services/call/src/call_incoming_filter_manager.cpp old mode 100755 new mode 100644 index c191ffd5523a50d62934f6d291c205109ddbc345..dc774c6042c9f1d6c02df6fd4bfc73e94fa8086d --- a/services/call/src/call_incoming_filter_manager.cpp +++ b/services/call/src/call_incoming_filter_manager.cpp @@ -62,6 +62,7 @@ void CallIncomingFilterManager::UpdateIncomingFilterData() std::shared_ptr callDataPtr = DelayedSingleton::GetInstance(); if (callDataPtr == nullptr) { TELEPHONY_LOGE("callDataPtr is nullptr!"); + return; } NativeRdb::DataAbilityPredicates predicates; predicates.NotEqualTo("phone_number", std::string("")); diff --git a/services/call/src/call_object_manager.cpp b/services/call/src/call_object_manager.cpp old mode 100755 new mode 100644 index 141bb8abc1f706db2242da93d2e676bb61f0eea7..6d0f6b9d83b874c0f8e9169ad71a67687889b758 --- a/services/call/src/call_object_manager.cpp +++ b/services/call/src/call_object_manager.cpp @@ -22,7 +22,7 @@ namespace OHOS { namespace Telephony { std::list> CallObjectManager::callObjectPtrList_; std::mutex CallObjectManager::listMutex_; -int32_t CallObjectManager::callId_ = kCallStartId; +int32_t CallObjectManager::callId_ = CALL_START_ID; CallObjectManager::CallObjectManager() { @@ -45,7 +45,7 @@ int32_t CallObjectManager::AddOneCallObject(sptr &call) } std::lock_guard lock(listMutex_); std::list>::iterator it = callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallID() == call->GetCallID()) { TELEPHONY_LOGE("this call has existed yet!"); return CALL_ERR_PHONE_CALL_ALREADY_EXISTS; @@ -61,7 +61,7 @@ int32_t CallObjectManager::DeleteOneCallObject(int32_t callId) { std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallID() == callId) { callObjectPtrList_.erase(it); TELEPHONY_LOGI("DeleteOneCallObject success! call list size:%{public}zu", callObjectPtrList_.size()); @@ -87,7 +87,7 @@ sptr CallObjectManager::GetOneCallObject(int32_t callId) sptr retPtr = nullptr; std::lock_guard lock(listMutex_); std::list>::iterator it = CallObjectManager::callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallID() == callId) { retPtr = *it; break; @@ -105,7 +105,7 @@ sptr CallObjectManager::GetOneCallObject(std::string &phoneNumber) sptr retPtr = nullptr; std::lock_guard lock(listMutex_); std::list>::iterator it = callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetAccountNumber() == phoneNumber) { TELEPHONY_LOGI("GetOneCallObject success!"); retPtr = *it; @@ -119,7 +119,7 @@ int32_t CallObjectManager::HasNewCall() { std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_CREATE || (*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_CONNECTING || (*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_DIALING) { @@ -136,7 +136,7 @@ bool CallObjectManager::IsNewCallAllowedCreate() bool ret = true; std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_CREATE || (*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_CONNECTING || (*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_DIALING || @@ -154,7 +154,7 @@ int32_t CallObjectManager::GetCarrierCallList(std::list &list) list.clear(); std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallType() == CallType::TYPE_CS || (*it)->GetCallType() == CallType::TYPE_IMS) { list.emplace_back((*it)->GetCallID()); } @@ -167,13 +167,13 @@ bool CallObjectManager::HasRingingMaximum() int32_t ringingCount = 0; std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { // Count the number of calls in the ringing state if ((*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_RINGING) { ringingCount++; } } - if (ringingCount >= kMaxRingingCallNumberLen) { + if (ringingCount >= RINGING_CALL_NUMBER_LEN) { return true; } return false; @@ -184,13 +184,13 @@ bool CallObjectManager::HasDialingMaximum() int32_t dialingCount = 0; std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { // Count the number of calls in the active state if ((*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_ACTIVE) { dialingCount++; } } - if (dialingCount >= kMaxDialingCallNumberLen) { + if (dialingCount >= DIALING_CALL_NUMBER_LEN) { return true; } return false; @@ -200,7 +200,7 @@ bool CallObjectManager::HasEmergencyCall() { std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetEmergencyState()) { return true; } @@ -220,7 +220,7 @@ bool CallObjectManager::IsCallExist(int32_t callId) { std::lock_guard lock(listMutex_); std::list>::iterator it = callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallID() == callId) { TELEPHONY_LOGW("the call is exist."); return true; @@ -232,11 +232,11 @@ bool CallObjectManager::IsCallExist(int32_t callId) bool CallObjectManager::IsCallExist(std::string &phoneNumber) { if (phoneNumber.empty()) { - return CALL_ERR_PHONE_NUMBER_EMPTY; + return false; } std::lock_guard lock(listMutex_); std::list>::iterator it = callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetAccountNumber() == phoneNumber) { return true; } @@ -260,7 +260,7 @@ bool CallObjectManager::HasRingingCall() bool ret = false; std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { // Count the number of calls in the ringing state if ((*it)->GetCallRunningState() == CallRunningState::CALL_RUNNING_STATE_RINGING) { ret = true; @@ -275,7 +275,7 @@ TelCallState CallObjectManager::GetCallState(int32_t callId) TelCallState retState = TelCallState::CALL_STATUS_IDLE; std::lock_guard lock(listMutex_); std::list>::iterator it = CallObjectManager::callObjectPtrList_.begin(); - for (; it != callObjectPtrList_.end(); it++) { + for (; it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallID() == callId) { retState = (*it)->GetTelCallState(); break; @@ -288,7 +288,7 @@ sptr CallObjectManager::GetOneCallObject(CallRunningState callState) { std::lock_guard lock(listMutex_); std::list>::reverse_iterator it; - for (it = callObjectPtrList_.rbegin(); it != callObjectPtrList_.rend(); it++) { + for (it = callObjectPtrList_.rbegin(); it != callObjectPtrList_.rend(); ++it) { if ((*it)->GetCallRunningState() == callState) { return (*it); } @@ -300,7 +300,7 @@ bool CallObjectManager::IsCallExist(CallType callType, TelCallState callState) { std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetCallType() == callType && (*it)->GetTelCallState() == callState) { return true; } @@ -313,13 +313,87 @@ bool CallObjectManager::IsCallExist(TelCallState callState) { std::lock_guard lock(listMutex_); std::list>::iterator it; - for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); it++) { + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { + if ((*it)->GetTelCallState() == callState) { + return true; + } + } + TELEPHONY_LOGI("the call is does not exist."); + return false; +} + +bool CallObjectManager::IsCallExist(TelCallState callState, int32_t &callId) +{ + std::lock_guard lock(listMutex_); + std::list>::iterator it; + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { if ((*it)->GetTelCallState() == callState) { + callId = (*it)->GetCallID(); return true; } } TELEPHONY_LOGI("the call is does not exist."); return false; } + +bool CallObjectManager::IsConferenceCallExist(TelConferenceState state, int32_t &callId) +{ + std::lock_guard lock(listMutex_); + std::list>::iterator it; + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { + if ((*it)->GetTelConferenceState() == state) { + callId = (*it)->GetCallID(); + return true; + } + } + TELEPHONY_LOGI("the call is does not exist."); + return false; +} + +int32_t CallObjectManager::GetCallNum(TelCallState callState) +{ + int32_t num = 0; + std::lock_guard lock(listMutex_); + std::list>::iterator it; + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { + if ((*it)->GetTelCallState() == callState) { + ++num; + continue; + } + } + TELEPHONY_LOGI("callState:%{public}d, num:%{public}d", callState, num); + return num; +} + +std::string CallObjectManager::GetCallNumber(TelCallState callState) +{ + std::string number = ""; + std::lock_guard lock(listMutex_); + std::list>::iterator it; + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { + if ((*it)->GetTelCallState() == callState) { + number = (*it)->GetAccountNumber(); + break; + } + } + return number; +} + +std::vector CallObjectManager::GetCallInfoList(int32_t slotId) +{ + std::vector callVec; + CallAttributeInfo info; + callVec.clear(); + std::lock_guard lock(listMutex_); + std::list>::iterator it; + for (it = callObjectPtrList_.begin(); it != callObjectPtrList_.end(); ++it) { + (void)memset_s(&info, sizeof(CallAttributeInfo), 0, sizeof(CallAttributeInfo)); + (*it)->GetCallAttributeInfo(info); + if (info.accountId == slotId && info.callType != CallType::TYPE_OTT) { + callVec.emplace_back(info); + } + } + return callVec; +} } // namespace Telephony } // namespace OHOS diff --git a/services/call/src/call_policy.cpp b/services/call/src/call_policy.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/call_request_handler.cpp b/services/call/src/call_request_handler.cpp old mode 100755 new mode 100644 index e2c054cd6f1315cc95f641ad1ea5e41aa0152a6a..28bd63d7d77fc352fab768dfa182d8839e8f357e --- a/services/call/src/call_request_handler.cpp +++ b/services/call/src/call_request_handler.cpp @@ -47,9 +47,7 @@ CallRequestHandler::CallRequestHandler(const std::shared_ptrStop(); eventLoop_ = nullptr; } - if (handler_ != nullptr) { - handler_ = nullptr; - } + handler_ = nullptr; } void CallRequestHandlerService::Start() @@ -393,8 +390,9 @@ int32_t CallRequestHandlerService::RejectCall(int32_t callId, bool isSendSms, st para->callId = callId; para->isSendSms = isSendSms; (void)memset_s(para->content, REJECT_CALL_MSG_MAX_LEN + 1, 0, REJECT_CALL_MSG_MAX_LEN + 1); - if (para->isSendSms && - memcpy_s(para->content, REJECT_CALL_MSG_MAX_LEN, content.c_str(), REJECT_CALL_MSG_MAX_LEN) != 0) { + errno_t result = memcpy_s(para->content, REJECT_CALL_MSG_MAX_LEN, content.c_str(), + REJECT_CALL_MSG_MAX_LEN); + if (para->isSendSms && result != EOK) { TELEPHONY_LOGE("memcpy_s rejectCall content failed!"); return TELEPHONY_ERR_MEMCPY_FAIL; } diff --git a/services/call/src/call_request_process.cpp b/services/call/src/call_request_process.cpp old mode 100755 new mode 100644 index fe18e1a783654d52d34bde176f04ee62d7360e27..40742d2e6776d314558d6664f38908787dc0c5fa --- a/services/call/src/call_request_process.cpp +++ b/services/call/src/call_request_process.cpp @@ -329,7 +329,7 @@ bool CallRequestProcess::IsFdnNumber(std::vector fdnNumberList, { char number[kMaxNumberLen + 1] = {0}; int32_t j = 0; - for (int32_t i = 0; i < phoneNumber.length(); i++) { + for (int32_t i = 0; i < static_cast(phoneNumber.length()); i++) { if (i >= kMaxNumberLen) { break; } @@ -337,7 +337,7 @@ bool CallRequestProcess::IsFdnNumber(std::vector fdnNumberList, number[j++] = *(phoneNumber.c_str() + i); } } - for (std::vector::iterator it = fdnNumberList.begin(); it != fdnNumberList.end(); it++) { + for (std::vector::iterator it = fdnNumberList.begin(); it != fdnNumberList.end(); ++it) { if (strstr(number, Str16ToStr8(*it).c_str()) != nullptr) { TELEPHONY_LOGI("you are allowed to dial!"); return true; diff --git a/services/call/src/call_state_listener.cpp b/services/call/src/call_state_listener.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/call_status_manager.cpp b/services/call/src/call_status_manager.cpp old mode 100755 new mode 100644 index e4fbcc5215394c74f82cb1d58e4cf8a1c531491c..0df4f85b5dd1d92419f3023f1903a3b6c881bd4c --- a/services/call/src/call_status_manager.cpp +++ b/services/call/src/call_status_manager.cpp @@ -26,6 +26,7 @@ #include "ott_call.h" #include "audio_control_manager.h" #include "call_control_manager.h" +#include "bluetooth_call_service.h" namespace OHOS { namespace Telephony { @@ -98,6 +99,8 @@ int32_t CallStatusManager::HandleCallReportInfo(const CallDetailInfo &info) TELEPHONY_LOGE("Invalid call state!"); break; } + TELEPHONY_LOGI("Entry CallStatusManager HandleCallReportInfo"); + DelayedSingleton::GetInstance()->GetCallState(); return ret; } @@ -311,6 +314,7 @@ int32_t CallStatusManager::ActiveHandle(const CallDetailInfo &info) TELEPHONY_LOGE("Call is NULL"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + call = RefreshCallIfNecessary(call, info); // call state change active, need to judge if launching a conference int32_t ret = call->LaunchConference(); if (ret == TELEPHONY_SUCCESS) { @@ -343,6 +347,7 @@ int32_t CallStatusManager::HoldingHandle(const CallDetailInfo &info) return TELEPHONY_ERR_LOCAL_PTR_NULL; } // if the call is in a conference, it will exit, otherwise just set it holding + call = RefreshCallIfNecessary(call, info); int32_t ret = call->HoldConference(); if (ret == TELEPHONY_SUCCESS) { TELEPHONY_LOGI("HoldConference success"); @@ -368,6 +373,7 @@ int32_t CallStatusManager::AlertHandle(const CallDetailInfo &info) TELEPHONY_LOGE("Call is NULL"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + call = RefreshCallIfNecessary(call, info); int32_t ret = UpdateCallState(call, TelCallState::CALL_STATUS_ALERTING); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("UpdateCallState failed, errCode:%{public}d", ret); @@ -390,6 +396,7 @@ int32_t CallStatusManager::DisconnectingHandle(const CallDetailInfo &info) TELEPHONY_LOGE("Call is NULL"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + call = RefreshCallIfNecessary(call, info); int32_t ret = UpdateCallState(call, TelCallState::CALL_STATUS_DISCONNECTING); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("UpdateCallState failed, errCode:%{public}d", ret); @@ -406,6 +413,7 @@ int32_t CallStatusManager::DisconnectedHandle(const CallDetailInfo &info) TELEPHONY_LOGE("Call is NULL"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } + call = RefreshCallIfNecessary(call, info); int32_t ret = call->ExitConference(); if (ret == TELEPHONY_SUCCESS) { TELEPHONY_LOGI("SubCallSeparateFromConference success"); @@ -443,6 +451,36 @@ int32_t CallStatusManager::UpdateCallState(sptr &call, TelCallState ne return TELEPHONY_SUCCESS; } +sptr CallStatusManager::RefreshCallIfNecessary(const sptr &call, const CallDetailInfo &info) +{ + TELEPHONY_LOGI("RefreshCallIfNecessary"); + if (call->GetCallType() == info.callType) { + TELEPHONY_LOGI("RefreshCallIfNecessary not need Refresh"); + return call; + } + CallAttributeInfo attrInfo; + (void)memset_s(&attrInfo, sizeof(CallAttributeInfo), 0, sizeof(CallAttributeInfo)); + call->GetCallAttributeBaseInfo(attrInfo); + sptr newCall = CreateNewCall(info, attrInfo.callDirection); + if (newCall == nullptr) { + TELEPHONY_LOGE("RefreshCallIfNecessary createCallFail"); + return call; + } + newCall->SetCallRunningState(call->GetCallRunningState()); + newCall->SetTelConferenceState(call->GetTelConferenceState()); + newCall->SetStartTime(attrInfo.startTime); + newCall->SetPolicyFlag(PolicyFlag(call->GetPolicyFlag())); + newCall->SetSpeakerphoneOn(call->IsSpeakerphoneOn()); + newCall->SetCallEndedType(call->GetCallEndedType()); + newCall->SetCallEndTime(attrInfo.callBeginTime); + newCall->SetCallEndTime(attrInfo.callEndTime); + newCall->SetRingBeginTime(attrInfo.ringBeginTime); + newCall->SetRingEndTime(attrInfo.ringEndTime); + newCall->SetAnswerType(attrInfo.answerType); + DeleteOneCallObject(call->GetCallID()); + return newCall; +} + int32_t CallStatusManager::ToSpeakerPhone(sptr &call) { int32_t ret = TELEPHONY_ERR_FAIL; diff --git a/services/call/src/call_status_policy.cpp b/services/call/src/call_status_policy.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/carrier_call.cpp b/services/call/src/carrier_call.cpp old mode 100755 new mode 100644 index 440055dd5f3b17a40aa0928a83154002345da2d3..ffc5d0cff121184fa3372101ac3e19d8764a90d1 --- a/services/call/src/carrier_call.cpp +++ b/services/call/src/carrier_call.cpp @@ -162,6 +162,20 @@ int32_t CarrierCall::CarrierUnHoldCall() return TELEPHONY_SUCCESS; } +int32_t CarrierCall::CarrierSetMute(int32_t mute, int32_t slotId) +{ + if (cellularCallConnectionPtr_ == nullptr) { + TELEPHONY_LOGE("cellularCallConnectionPtr_ is nullptr!"); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + int32_t ret = cellularCallConnectionPtr_->SetMute(mute, slotId); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("SetMute failed!"); + return CALL_ERR_UNHOLD_FAILED; + } + return TELEPHONY_SUCCESS; +} + void CarrierCall::GetCallAttributeCarrierInfo(CallAttributeInfo &info) { std::lock_guard lock(mutex_); diff --git a/services/call/src/conference_base.cpp b/services/call/src/conference_base.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/cs_call.cpp b/services/call/src/cs_call.cpp old mode 100755 new mode 100644 index 44aa643409477f6b0bba10d483a671098000438b..6563984d1df88e82ce21bd93ea66d240ba157e74 --- a/services/call/src/cs_call.cpp +++ b/services/call/src/cs_call.cpp @@ -74,6 +74,11 @@ void CSCall::GetCallAttributeInfo(CallAttributeInfo &info) GetCallAttributeCarrierInfo(info); } +int32_t CSCall::SetMute(int32_t mute, int32_t slotId) +{ + return CarrierSetMute(mute, slotId); +} + int32_t CSCall::CombineConference() { int32_t ret = DelayedSingleton::GetInstance()->SetMainCall(GetCallID()); diff --git a/services/call/src/cs_conference.cpp b/services/call/src/cs_conference.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/ims_call.cpp b/services/call/src/ims_call.cpp old mode 100755 new mode 100644 index ddeae441b352adfd2cb4d098c1ae379f3e8ac593..16f579a637cca35bfb3e89d8263f7ca4384e146e --- a/services/call/src/ims_call.cpp +++ b/services/call/src/ims_call.cpp @@ -143,7 +143,7 @@ int32_t IMSCall::StopRtt() int32_t IMSCall::SetMute(int32_t mute, int32_t slotId) { - return DelayedSingleton::GetInstance()->SetMute(mute, slotId); + return CarrierSetMute(mute, slotId); } void IMSCall::GetCallAttributeInfo(CallAttributeInfo &info) diff --git a/services/call/src/ims_conference.cpp b/services/call/src/ims_conference.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/net_call_base.cpp b/services/call/src/net_call_base.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/ott_call.cpp b/services/call/src/ott_call.cpp old mode 100755 new mode 100644 index 4705adb289fff32eb46ce3437fa448cd8a3d86b5..a127ae43d8ddeb7926c4cbc1b87b626439f687a5 --- a/services/call/src/ott_call.cpp +++ b/services/call/src/ott_call.cpp @@ -49,7 +49,11 @@ int32_t OTTCall::AnswerCall(int32_t videoState) return CALL_ERR_ANSWER_FAILED; } OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); + ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_ANSWER_FAILED; + } if (ottCallConnectionPtr_ == nullptr) { TELEPHONY_LOGE("ottCallConnectionPtr_ is nullptr!"); return TELEPHONY_ERR_LOCAL_PTR_NULL; @@ -69,7 +73,11 @@ int32_t OTTCall::RejectCall() return ret; } OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); + ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_REJECT_FAILED; + } ret = ottCallConnectionPtr_->Reject(requestInfo); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("reject call failed!"); @@ -81,8 +89,12 @@ int32_t OTTCall::RejectCall() int32_t OTTCall::HangUpCall() { OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); - int32_t ret = ottCallConnectionPtr_->HangUp(requestInfo); + int32_t ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_HANGUP_FAILED; + } + ret = ottCallConnectionPtr_->HangUp(requestInfo); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("hangUp call failed!"); return CALL_ERR_HANGUP_FAILED; @@ -93,8 +105,12 @@ int32_t OTTCall::HangUpCall() int32_t OTTCall::HoldCall() { OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); - int32_t ret = ottCallConnectionPtr_->HoldCall(requestInfo); + int32_t ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_HOLD_FAILED; + } + ret = ottCallConnectionPtr_->HoldCall(requestInfo); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("holdCall call failed!"); return CALL_ERR_HOLD_FAILED; @@ -105,8 +121,12 @@ int32_t OTTCall::HoldCall() int32_t OTTCall::UnHoldCall() { OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); - int32_t ret = ottCallConnectionPtr_->UnHoldCall(requestInfo); + int32_t ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_UNHOLD_FAILED; + } + ret = ottCallConnectionPtr_->UnHoldCall(requestInfo); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("unHoldCall call failed!"); return CALL_ERR_UNHOLD_FAILED; @@ -117,8 +137,12 @@ int32_t OTTCall::UnHoldCall() int32_t OTTCall::SwitchCall() { OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); - int32_t ret = ottCallConnectionPtr_->SwitchCall(requestInfo); + int32_t ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return CALL_ERR_UNHOLD_FAILED; + } + ret = ottCallConnectionPtr_->SwitchCall(requestInfo); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("switchCall call failed!"); return CALL_ERR_UNHOLD_FAILED; @@ -159,7 +183,11 @@ int32_t OTTCall::CombineConference() return ret; } OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); + ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return ret; + } if (ottCallConnectionPtr_ == nullptr) { TELEPHONY_LOGE("ottCallConnectionPtr_ is nullptr!"); return TELEPHONY_ERR_LOCAL_PTR_NULL; @@ -180,7 +208,11 @@ int32_t OTTCall::CanCombineConference() int32_t OTTCall::SeparateConference() { OttCallRequestInfo requestInfo; - PackOttCallRequestInfo(requestInfo); + int32_t ret = PackOttCallRequestInfo(requestInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("PackOttCallRequestInfo failed, error%{public}d", ret); + return ret; + } if (ottCallConnectionPtr_ == nullptr) { TELEPHONY_LOGE("ottCallConnectionPtr_ is nullptr!"); return TELEPHONY_ERR_LOCAL_PTR_NULL; @@ -278,11 +310,23 @@ int32_t OTTCall::DispatchUpdateVideoResponse(ImsCallMode mode) return CALL_ERR_FUNCTION_NOT_SUPPORTED; } -void OTTCall::PackOttCallRequestInfo(OttCallRequestInfo &requestInfo) +int32_t OTTCall::SetMute(int32_t mute, int32_t slotId) { - (void)memcpy_s(requestInfo.phoneNum, kMaxNumberLen, accountNumber_.c_str(), accountNumber_.length()); - (void)memcpy_s(requestInfo.bundleName, kMaxBundleNameLen, bundleName_.c_str(), bundleName_.length()); + return CALL_ERR_FUNCTION_NOT_SUPPORTED; +} + +int32_t OTTCall::PackOttCallRequestInfo(OttCallRequestInfo &requestInfo) +{ + if (memcpy_s(requestInfo.phoneNum, kMaxNumberLen, accountNumber_.c_str(), accountNumber_.length()) != EOK) { + TELEPHONY_LOGW("memset_s failed!"); + return TELEPHONY_ERR_MEMSET_FAIL; + } + if (memcpy_s(requestInfo.bundleName, kMaxBundleNameLen, bundleName_.c_str(), bundleName_.length()) != EOK) { + TELEPHONY_LOGW("memset_s failed!"); + return TELEPHONY_ERR_MEMSET_FAIL; + } requestInfo.videoState = videoState_; + return TELEPHONY_SUCCESS; } } // namespace Telephony } // namespace OHOS diff --git a/services/call/src/ott_call_connection.cpp b/services/call/src/ott_call_connection.cpp old mode 100755 new mode 100644 index 1a2e9189cb792c9e5d732038025df5f08e12aca3..27942738663b414bfa34307a8fa3e77f55814435 --- a/services/call/src/ott_call_connection.cpp +++ b/services/call/src/ott_call_connection.cpp @@ -98,7 +98,7 @@ int32_t OTTCallConnection::InviteToConference( PackCellularCallInfo(requestInfo, info); info.PutIntValue("listCnt", list.size()); std::vector::iterator it = list.begin(); - for (; it != list.end(); it++) { + for (; it != list.end(); ++it) { if (!(*it).empty()) { info.PutStringValue("number", *it); } diff --git a/services/call/src/ott_conference.cpp b/services/call/src/ott_conference.cpp old mode 100755 new mode 100644 diff --git a/services/call/src/video_call_state.cpp b/services/call/src/video_call_state.cpp old mode 100755 new mode 100644 index 423acf0f577e2a3121328fe9eaefef534e6337e2..cf4bbb2f8e65affc9b06f9451e29fcf405537401 --- a/services/call/src/video_call_state.cpp +++ b/services/call/src/video_call_state.cpp @@ -30,7 +30,7 @@ bool VideoCallState::IsCallSupportVideoCall() { if (call_ == nullptr) { TELEPHONY_LOGE("unexpect null pointer."); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } sptr netCall = static_cast(call_.GetRefPtr()); return netCall->IsSupportVideoCall(); @@ -160,7 +160,7 @@ int32_t AudioOnlyState::RecieveUpdateCallMediaModeRequest(ImsCallMode mode) sptr netCall = static_cast(call_.GetRefPtr()); if (netCall == nullptr) { TELEPHONY_LOGE("unexpect null pointer."); - ret = TELEPHONY_ERR_LOCAL_PTR_NULL; + return TELEPHONY_ERR_LOCAL_PTR_NULL; } (void)netCall->AcceptVideoCall(); } else { @@ -611,4 +611,4 @@ int32_t VideoPauseState::ReceiveUpdateCallMediaModeResponse(ImsCallMode mode) return TELEPHONY_SUCCESS; } } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/call_manager_service/include/call_manager_dump_helper.h b/services/call_manager_service/include/call_manager_dump_helper.h old mode 100755 new mode 100644 diff --git a/services/call_manager_service/include/call_manager_service.h b/services/call_manager_service/include/call_manager_service.h old mode 100755 new mode 100644 index 1da56571da08f6740bd648f70e67ed1530ee12f5..d494b10653dfdfc20f748b1b54b774304e5c5bd7 --- a/services/call_manager_service/include/call_manager_service.h +++ b/services/call_manager_service/include/call_manager_service.h @@ -598,6 +598,15 @@ public: */ int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo) override; + /** + * GetProxyObjectPtr + * + * @brief get callManager proxy object ptr + * @param proxyType[in], proxy type + * @return Returns nullptr on failure, others on success. + */ + sptr GetProxyObjectPtr(CallManagerProxyType proxyType) override; + private: int32_t CheckBundleName(std::string bundleName); @@ -610,7 +619,7 @@ private: ServiceRunningState state_ {ServiceRunningState::STATE_STOPPED}; std::shared_ptr callControlManagerPtr_; - std::shared_ptr bluetoothCallManagerPtr_; + std::map> proxyObjectPtrMap_; std::mutex lock_; const int32_t startTime_ = 1900; const int32_t extraMonth_ = 1; diff --git a/services/call_manager_service/include/call_manager_service_stub.h b/services/call_manager_service/include/call_manager_service_stub.h old mode 100755 new mode 100644 index 5517adf9fa7f72dd43125b2b5f67934a66df3e9f..4e1c64fcbbe41f0b70a4f2388cb70cae8c527787 --- a/services/call_manager_service/include/call_manager_service_stub.h +++ b/services/call_manager_service/include/call_manager_service_stub.h @@ -101,7 +101,7 @@ private: int32_t OnStopRtt(MessageParcel &data, MessageParcel &reply); int32_t OnReportOttCallDetailsInfo(MessageParcel &data, MessageParcel &reply); int32_t OnReportOttCallEventInfo(MessageParcel &data, MessageParcel &reply); - + int32_t OnGetProxyObjectPtr(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; }; } // namespace Telephony diff --git a/services/call_manager_service/src/call_manager_dump_helper.cpp b/services/call_manager_service/src/call_manager_dump_helper.cpp old mode 100755 new mode 100644 diff --git a/services/call_manager_service/src/call_manager_service.cpp b/services/call_manager_service/src/call_manager_service.cpp old mode 100755 new mode 100644 index 7939b6307bc2f2b527a927f65fd32abdda18fcaf..8d1404f57b584e266991cdecdb69e4fd8944ad70 --- a/services/call_manager_service/src/call_manager_service.cpp +++ b/services/call_manager_service/src/call_manager_service.cpp @@ -21,6 +21,7 @@ #include "telephony_log_wrapper.h" #include "telephony_permission.h" +#include "bluetooth_call_service.h" #include "call_ability_report_proxy.h" #include "call_manager_dump_helper.h" #include "report_call_info_handler.h" @@ -56,23 +57,16 @@ bool CallManagerService::Init() TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); return false; } - bluetoothCallManagerPtr_ = DelayedSingleton::GetInstance(); - if (bluetoothCallManagerPtr_ == nullptr) { - TELEPHONY_LOGE("bluetoothCallManagerPtr_ is nullptr!"); - return false; - } - DelayedSingleton::GetInstance()->Init(); DelayedSingleton::GetInstance()->Start(); DelayedSingleton::GetInstance()->Init(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID); DelayedSingleton::GetInstance()->Init(); + DelayedSingleton::GetInstance()->Init(); return true; } void CallManagerService::UnInit() { - if (callControlManagerPtr_ != nullptr) { - callControlManagerPtr_ = nullptr; - } + callControlManagerPtr_ = nullptr; } void CallManagerService::OnStart() @@ -98,11 +92,12 @@ void CallManagerService::OnStart() state_ = ServiceRunningState::STATE_RUNNING; struct tm *timeNow = nullptr; + struct tm nowTime = {0}; time_t second = time(0); if (second < 0) { return; } - timeNow = localtime(&second); + timeNow = localtime_r(&second, &nowTime); if (timeNow != nullptr) { spendTime_ = duration_cast(high_resolution_clock::now() - beginTime).count(); TELEPHONY_LOGI( @@ -117,11 +112,12 @@ void CallManagerService::OnStop() { std::lock_guard guard(lock_); struct tm *timeNow = nullptr; + struct tm nowTime = {0}; time_t second = time(0); if (second < 0) { return; } - timeNow = localtime(&second); + timeNow = localtime_r(&second, &nowTime); if (timeNow != nullptr) { TELEPHONY_LOGI( "CallManagerService dump time:%{public}d-%{public}d-%{public}d %{public}d:%{public}d:%{public}d", @@ -297,7 +293,7 @@ bool CallManagerService::HasCall() return callControlManagerPtr_->HasCall(); } else { TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } } @@ -307,7 +303,7 @@ bool CallManagerService::IsNewCallAllowed() return callControlManagerPtr_->IsNewCallAllowed(); } else { TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } } @@ -315,13 +311,13 @@ bool CallManagerService::IsRinging() { if (!TelephonyPermission::CheckPermission(OHOS_PERMISSION_SET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; + return false; } if (callControlManagerPtr_ != nullptr) { return callControlManagerPtr_->IsRinging(); } else { TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } } @@ -329,13 +325,13 @@ bool CallManagerService::IsInEmergencyCall() { if (!TelephonyPermission::CheckPermission(OHOS_PERMISSION_SET_TELEPHONY_STATE)) { TELEPHONY_LOGE("Permission denied!"); - return TELEPHONY_ERR_PERMISSION_ERR; + return false; } if (callControlManagerPtr_ != nullptr) { return callControlManagerPtr_->HasEmergency(); } else { TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } } @@ -574,7 +570,7 @@ bool CallManagerService::IsEmergencyPhoneNumber(std::u16string &number, int32_t return callControlManagerPtr_->IsEmergencyPhoneNumber(number, slotId, errorCode); } else { TELEPHONY_LOGE("callControlManagerPtr_ is nullptr!"); - return TELEPHONY_ERR_LOCAL_PTR_NULL; + return false; } } @@ -764,7 +760,7 @@ int32_t CallManagerService::ReportOttCallDetailsInfo(std::vector::iterator it = ottVec.begin(); - for (; it != ottVec.end(); it++) { + for (; it != ottVec.end(); ++it) { detailInfo.callMode = (*it).videoState; detailInfo.state = (*it).callState; (void)memcpy_s(detailInfo.phoneNum, kMaxNumberLen, (*it).phoneNum, kMaxNumberLen); @@ -791,23 +787,37 @@ int32_t CallManagerService::ReportOttCallEventInfo(OttCallEventInfo &eventInfo) return ret; } +sptr CallManagerService::GetProxyObjectPtr(CallManagerProxyType proxyType) +{ + auto it = proxyObjectPtrMap_.find(static_cast(proxyType)); + if (it != proxyObjectPtrMap_.end()) { + TELEPHONY_LOGI("GetProxyObjectPtr success! proxyType:%{public}d", proxyType); + return it->second; + } else { + switch (proxyType) { + case PROXY_BLUETOOTH_CALL: { + sptr ptr = (std::make_unique()).release(); + if (ptr == nullptr) { + TELEPHONY_LOGE("create BluetoothCallService object failed!"); + return nullptr; + } + proxyObjectPtrMap_[proxyType] = ptr->AsObject().GetRefPtr(); + TELEPHONY_LOGI("create BluetoothCallService object success! proxyType:%{public}d", proxyType); + return ptr->AsObject().GetRefPtr(); + } + default: + TELEPHONY_LOGE("invalid proxyType!"); + break; + } + } + TELEPHONY_LOGE("GetProxyObjectPtr failed! proxyType:%{public}d", proxyType); + return nullptr; +} + int32_t CallManagerService::CheckBundleName(std::string bundleName) { std::string bundleNameList[] = { "com.ohos.callui", - "com.ohos.service.callui", - "com.ohos.callmanagercallmedia", - "com.ohos.callmanager", - "com.ohos.callmanagerregister", - "com.ohos.callmanagerreliabilityperformance", - "com.ohos.callmanagerimscall", - "com.ohos.callmanagercallcarmera", - "com.ohos.callmanagerreliability", - "com.ohos.callmanagerperformance", - "com.example.callmanager", - "com.example.telephone_demo", - "com.ohos.calldemo", - "com.ohos.callservice", }; for (int32_t i = 0; i < end(bundleNameList) - begin(bundleNameList); i++) { if (strcmp(bundleName.c_str(), bundleNameList[i].c_str()) == 0) { diff --git a/services/call_manager_service/src/call_manager_service_stub.cpp b/services/call_manager_service/src/call_manager_service_stub.cpp old mode 100755 new mode 100644 index d7b7345adf982f728e15f126a4b1681fc2d20b66..efec15f159f32fd8f131cd40c02f02135e672d89 --- a/services/call_manager_service/src/call_manager_service_stub.cpp +++ b/services/call_manager_service/src/call_manager_service_stub.cpp @@ -24,7 +24,6 @@ #include "message_parcel.h" #include "call_control_manager.h" -#include "cellular_call_types.h" namespace OHOS { namespace Telephony { @@ -39,6 +38,7 @@ CallManagerServiceStub::CallManagerServiceStub() InitCallMultimediaRequest(); InitImsServiceRequest(); InitOttServiceRequest(); + memberFuncMap_[INTERFACE_GET_PROXY_OBJECT_PTR] = &CallManagerServiceStub::OnGetProxyObjectPtr; } CallManagerServiceStub::~CallManagerServiceStub() @@ -162,9 +162,6 @@ int32_t CallManagerServiceStub::OnRemoteRequest( int32_t CallManagerServiceStub::OnRegisterCallBack(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { TELEPHONY_LOGE("callback ptr is nullptr."); @@ -180,9 +177,6 @@ int32_t CallManagerServiceStub::OnRegisterCallBack(MessageParcel &data, MessageP int32_t CallManagerServiceStub::OnUnRegisterCallBack(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } result = UnRegisterCallBack(); if (!reply.WriteInt32(result)) { TELEPHONY_LOGE("fail to write parcel"); @@ -195,9 +189,6 @@ int32_t CallManagerServiceStub::OnDialCall(MessageParcel &data, MessageParcel &r { int32_t result = TELEPHONY_ERR_FAIL; AppExecFwk::PacMap dialInfo; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string callNumber = data.ReadString16(); dialInfo.PutIntValue("accountId", data.ReadInt32()); dialInfo.PutIntValue("videoState", data.ReadInt32()); @@ -220,9 +211,6 @@ int32_t CallManagerServiceStub::OnDialCall(MessageParcel &data, MessageParcel &r int32_t CallManagerServiceStub::OnAcceptCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t videoState = data.ReadInt32(); int32_t result = AnswerCall(callId, videoState); @@ -236,9 +224,6 @@ int32_t CallManagerServiceStub::OnAcceptCall(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnRejectCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); bool isSendSms = data.ReadBool(); std::u16string content = data.ReadString16(); @@ -253,9 +238,6 @@ int32_t CallManagerServiceStub::OnRejectCall(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnHangUpCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = HangUpCall(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -268,9 +250,6 @@ int32_t CallManagerServiceStub::OnHangUpCall(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnGetCallState(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t result = GetCallState(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteInt32(result)) { @@ -282,9 +261,6 @@ int32_t CallManagerServiceStub::OnGetCallState(MessageParcel &data, MessageParce int32_t CallManagerServiceStub::OnHoldCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = HoldCall(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -297,9 +273,6 @@ int32_t CallManagerServiceStub::OnHoldCall(MessageParcel &data, MessageParcel &r int32_t CallManagerServiceStub::OnUnHoldCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = UnHoldCall(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -312,9 +285,6 @@ int32_t CallManagerServiceStub::OnUnHoldCall(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnSwitchCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = SwitchCall(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -327,9 +297,6 @@ int32_t CallManagerServiceStub::OnSwitchCall(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnHasCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } bool result = HasCall(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteBool(result)) { @@ -341,9 +308,6 @@ int32_t CallManagerServiceStub::OnHasCall(MessageParcel &data, MessageParcel &re int32_t CallManagerServiceStub::OnIsNewCallAllowed(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } bool result = IsNewCallAllowed(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteBool(result)) { @@ -355,9 +319,6 @@ int32_t CallManagerServiceStub::OnIsNewCallAllowed(MessageParcel &data, MessageP int32_t CallManagerServiceStub::OnSetMute(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } bool isMute = data.ReadBool(); int32_t result = SetMuted(isMute); TELEPHONY_LOGI("result:%{public}d", result); @@ -370,9 +331,6 @@ int32_t CallManagerServiceStub::OnSetMute(MessageParcel &data, MessageParcel &re int32_t CallManagerServiceStub::OnMuteRinger(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t result = MuteRinger(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteInt32(result)) { @@ -384,9 +342,6 @@ int32_t CallManagerServiceStub::OnMuteRinger(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnSetAudioDevice(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t deviceType = data.ReadInt32(); int32_t result = SetAudioDevice((AudioDevice)deviceType); TELEPHONY_LOGI("result:%{public}d", result); @@ -399,9 +354,6 @@ int32_t CallManagerServiceStub::OnSetAudioDevice(MessageParcel &data, MessagePar int32_t CallManagerServiceStub::OnIsRinging(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } bool result = IsRinging(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteBool(result)) { @@ -413,9 +365,6 @@ int32_t CallManagerServiceStub::OnIsRinging(MessageParcel &data, MessageParcel & int32_t CallManagerServiceStub::OnIsInEmergencyCall(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } bool result = IsInEmergencyCall(); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteBool(result)) { @@ -428,11 +377,8 @@ int32_t CallManagerServiceStub::OnIsInEmergencyCall(MessageParcel &data, Message int32_t CallManagerServiceStub::OnStartDtmf(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); - char str = data.ReadInt8(); + char str = static_cast(data.ReadInt8()); result = StartDtmf(callId, str); TELEPHONY_LOGI("result:%{public}d", result); if (!reply.WriteInt32(result)) { @@ -445,9 +391,6 @@ int32_t CallManagerServiceStub::OnStartDtmf(MessageParcel &data, MessageParcel & int32_t CallManagerServiceStub::OnStopDtmf(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); result = StopDtmf(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -461,9 +404,6 @@ int32_t CallManagerServiceStub::OnStopDtmf(MessageParcel &data, MessageParcel &r int32_t CallManagerServiceStub::OnGetCallWaiting(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = GetCallWaiting(slotId); TELEPHONY_LOGI("result:%{public}d", result); @@ -477,9 +417,6 @@ int32_t CallManagerServiceStub::OnGetCallWaiting(MessageParcel &data, MessagePar int32_t CallManagerServiceStub::OnSetCallWaiting(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); bool activate = data.ReadBool(); result = SetCallWaiting(slotId, activate); @@ -494,9 +431,6 @@ int32_t CallManagerServiceStub::OnSetCallWaiting(MessageParcel &data, MessagePar int32_t CallManagerServiceStub::OnGetCallRestriction(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); CallRestrictionType type = static_cast(data.ReadInt32()); result = GetCallRestriction(slotId, type); @@ -528,9 +462,6 @@ int32_t CallManagerServiceStub::OnSetCallRestriction(MessageParcel &data, Messag int32_t CallManagerServiceStub::OnGetTransferNumber(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); CallTransferType type = static_cast(data.ReadInt32()); result = GetCallTransferInfo(slotId, type); @@ -561,9 +492,6 @@ int32_t CallManagerServiceStub::OnSetTransferNumber(MessageParcel &data, Message int32_t CallManagerServiceStub::OnCombineConference(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t mainCallId = data.ReadInt32(); int32_t result = CombineConference(mainCallId); TELEPHONY_LOGI("result:%{public}d", result); @@ -576,9 +504,6 @@ int32_t CallManagerServiceStub::OnCombineConference(MessageParcel &data, Message int32_t CallManagerServiceStub::OnSeparateConference(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = SeparateConference(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -592,9 +517,6 @@ int32_t CallManagerServiceStub::OnSeparateConference(MessageParcel &data, Messag int32_t CallManagerServiceStub::OnJoinConference(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); std::vector numberList; if (!data.ReadString16Vector(&numberList)) { @@ -612,9 +534,6 @@ int32_t CallManagerServiceStub::OnJoinConference(MessageParcel &data, MessagePar int32_t CallManagerServiceStub::OnSetCallPreferenceMode(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); int32_t mode = data.ReadInt32(); result = SetCallPreferenceMode(slotId, mode); @@ -628,9 +547,6 @@ int32_t CallManagerServiceStub::OnSetCallPreferenceMode(MessageParcel &data, Mes int32_t CallManagerServiceStub::OnControlCamera(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string cameraId = data.ReadString16(); result = ControlCamera(cameraId); TELEPHONY_LOGI("result:%{public}d", result); @@ -674,9 +590,6 @@ int32_t CallManagerServiceStub::OnSetDisplayWindow(MessageParcel &data, MessageP int32_t CallManagerServiceStub::OnSetCameraZoom(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } float zoom = data.ReadFloat(); result = SetCameraZoom(zoom); TELEPHONY_LOGI("result:%{public}d", result); @@ -690,9 +603,6 @@ int32_t CallManagerServiceStub::OnSetCameraZoom(MessageParcel &data, MessageParc int32_t CallManagerServiceStub::OnSetPausePicture(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string path = data.ReadString16(); result = SetPausePicture(path); TELEPHONY_LOGI("result:%{public}d", result); @@ -706,9 +616,6 @@ int32_t CallManagerServiceStub::OnSetPausePicture(MessageParcel &data, MessagePa int32_t CallManagerServiceStub::OnSetDeviceDirection(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t rotation = data.ReadInt32(); result = SetDeviceDirection(rotation); TELEPHONY_LOGI("result:%{public}d", result); @@ -721,9 +628,6 @@ int32_t CallManagerServiceStub::OnSetDeviceDirection(MessageParcel &data, Messag int32_t CallManagerServiceStub::OnIsEmergencyPhoneNumber(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string callNumber = data.ReadString16(); int32_t slotId = data.ReadInt32(); int32_t errorCode = TELEPHONY_ERR_FAIL; @@ -738,9 +642,6 @@ int32_t CallManagerServiceStub::OnIsEmergencyPhoneNumber(MessageParcel &data, Me int32_t CallManagerServiceStub::OnFormatPhoneNumber(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string callNumber = data.ReadString16(); std::u16string countryCode = data.ReadString16(); std::u16string formatNumber; @@ -755,9 +656,6 @@ int32_t CallManagerServiceStub::OnFormatPhoneNumber(MessageParcel &data, Message int32_t CallManagerServiceStub::OnFormatPhoneNumberToE164(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } std::u16string callNumber = data.ReadString16(); std::u16string countryCode = data.ReadString16(); std::u16string formatNumber; @@ -772,9 +670,6 @@ int32_t CallManagerServiceStub::OnFormatPhoneNumberToE164(MessageParcel &data, M int32_t CallManagerServiceStub::OnGetMainCallId(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); int32_t result = GetMainCallId(callId); TELEPHONY_LOGI("result:%{public}d", result); @@ -787,9 +682,6 @@ int32_t CallManagerServiceStub::OnGetMainCallId(MessageParcel &data, MessageParc int32_t CallManagerServiceStub::OnGetSubCallIdList(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); std::vector result = GetSubCallIdList(callId); if (!reply.WriteString16Vector(result)) { @@ -801,9 +693,6 @@ int32_t CallManagerServiceStub::OnGetSubCallIdList(MessageParcel &data, MessageP int32_t CallManagerServiceStub::OnGetCallIdListForConference(MessageParcel &data, MessageParcel &reply) { - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); std::vector result = GetCallIdListForConference(callId); if (!reply.WriteString16Vector(result)) { @@ -816,9 +705,6 @@ int32_t CallManagerServiceStub::OnGetCallIdListForConference(MessageParcel &data int32_t CallManagerServiceStub::OnGetImsConfig(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); int32_t item = data.ReadInt32(); result = GetImsConfig(slotId, static_cast(item)); @@ -832,9 +718,6 @@ int32_t CallManagerServiceStub::OnGetImsConfig(MessageParcel &data, MessageParce int32_t CallManagerServiceStub::OnSetImsConfig(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); int32_t item = data.ReadInt32(); std::u16string value = data.ReadString16(); @@ -849,9 +732,6 @@ int32_t CallManagerServiceStub::OnSetImsConfig(MessageParcel &data, MessageParce int32_t CallManagerServiceStub::OnGetImsFeatureValue(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); FeatureType type = static_cast(data.ReadInt32()); result = GetImsFeatureValue(slotId, type); @@ -865,9 +745,6 @@ int32_t CallManagerServiceStub::OnGetImsFeatureValue(MessageParcel &data, Messag int32_t CallManagerServiceStub::OnSetImsFeatureValue(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); FeatureType type = static_cast(data.ReadInt32()); int32_t value = data.ReadInt32(); @@ -898,9 +775,6 @@ int32_t CallManagerServiceStub::OnUpdateCallMediaMode(MessageParcel &data, Messa int32_t CallManagerServiceStub::OnEnableVoLte(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = EnableImsSwitch(slotId); if (!reply.WriteInt32(result)) { @@ -913,9 +787,6 @@ int32_t CallManagerServiceStub::OnEnableVoLte(MessageParcel &data, MessageParcel int32_t CallManagerServiceStub::OnDisableVoLte(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = DisableImsSwitch(slotId); if (!reply.WriteInt32(result)) { @@ -928,9 +799,6 @@ int32_t CallManagerServiceStub::OnDisableVoLte(MessageParcel &data, MessageParce int32_t CallManagerServiceStub::OnIsVoLteEnabled(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = IsImsSwitchEnabled(slotId); if (!reply.WriteInt32(result)) { @@ -943,9 +811,6 @@ int32_t CallManagerServiceStub::OnIsVoLteEnabled(MessageParcel &data, MessagePar int32_t CallManagerServiceStub::OnEnableLteEnhanceMode(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = EnableLteEnhanceMode(slotId); if (!reply.WriteInt32(result)) { @@ -958,9 +823,6 @@ int32_t CallManagerServiceStub::OnEnableLteEnhanceMode(MessageParcel &data, Mess int32_t CallManagerServiceStub::OnDisableEnhanceMode(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t slotId = data.ReadInt32(); result = DisableLteEnhanceMode(slotId); if (!reply.WriteInt32(result)) { @@ -985,9 +847,6 @@ int32_t CallManagerServiceStub::OnIsLteEnhanceModeEnabled(MessageParcel &data, M int32_t CallManagerServiceStub::OnStartRtt(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); std::u16string msg = data.ReadString16(); result = StartRtt(callId, msg); @@ -1001,9 +860,6 @@ int32_t CallManagerServiceStub::OnStartRtt(MessageParcel &data, MessageParcel &r int32_t CallManagerServiceStub::OnStopRtt(MessageParcel &data, MessageParcel &reply) { int32_t result = TELEPHONY_ERR_FAIL; - if (!data.ContainFileDescriptors()) { - TELEPHONY_LOGW("sent raw data is less than 32k"); - } int32_t callId = data.ReadInt32(); result = StopRtt(callId); if (!reply.WriteInt32(result)) { @@ -1052,5 +908,16 @@ int32_t CallManagerServiceStub::OnReportOttCallEventInfo(MessageParcel &data, Me } return TELEPHONY_SUCCESS; } + +int32_t CallManagerServiceStub::OnGetProxyObjectPtr(MessageParcel &data, MessageParcel &reply) +{ + CallManagerProxyType proxyType = static_cast(data.ReadInt32()); + sptr objectPtr = GetProxyObjectPtr(proxyType); + if (!reply.WriteRemoteObject(objectPtr)) { + TELEPHONY_LOGE("OnGetProxyObjectPtr fail to write parcel"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} } // namespace Telephony } // namespace OHOS diff --git a/services/call_report/include/call_ability_callback_proxy.h b/services/call_report/include/call_ability_callback_proxy.h old mode 100755 new mode 100644 index 9e5bfc65b0455c7831ad24c7e8ed8f96591dc4e9..a5243180e1aca3bc63a231844d8531c817b6d1d8 --- a/services/call_report/include/call_ability_callback_proxy.h +++ b/services/call_report/include/call_ability_callback_proxy.h @@ -33,13 +33,13 @@ public: int32_t OnCallDisconnectedCause(DisconnectedDetails cause) override; int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) override; int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) override; + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) override; private: void PackDataParcel(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo, MessageParcel &dataParcel); private: static inline BrokerDelegator delegator_; - static constexpr HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, LOG_DOMAIN, "CallManager"}; }; } // namespace Telephony } // namespace OHOS diff --git a/services/call_report/include/call_ability_report_proxy.h b/services/call_report/include/call_ability_report_proxy.h old mode 100755 new mode 100644 index aa32fee89ceb7945c79915f249b3e60a6464491d..55502f9415df9df141e6829ae6666a36880e98d4 --- a/services/call_report/include/call_ability_report_proxy.h +++ b/services/call_report/include/call_ability_report_proxy.h @@ -37,7 +37,7 @@ public: void CallDestroyed(int32_t cause) override; int32_t ReportAsyncResults(const CallResultReportId reportId, AppExecFwk::PacMap &resultInfo); int32_t OttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info); - bool IsBundleNameConflict(std::string &bundleName); + int32_t ReportMmiCodeResult(const MmiCodeInfo &info); private: int32_t ReportCallStateInfo(const CallAttributeInfo &info); diff --git a/services/call_report/include/call_state_report_proxy.h b/services/call_report/include/call_state_report_proxy.h old mode 100755 new mode 100644 diff --git a/services/call_report/src/call_ability_callback_proxy.cpp b/services/call_report/src/call_ability_callback_proxy.cpp old mode 100755 new mode 100644 index 45447a5283e252f73396c1e322a1604677c95686..d09038c5c28eccd917eda6b3e7cb0d8dcae5bebd --- a/services/call_report/src/call_ability_callback_proxy.cpp +++ b/services/call_report/src/call_ability_callback_proxy.cpp @@ -118,6 +118,30 @@ int32_t CallAbilityCallbackProxy::OnReportAsyncResults(CallResultReportId report return replyParcel.ReadInt32(); } +int32_t CallAbilityCallbackProxy::OnReportMmiCodeResult(const MmiCodeInfo &info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) { + TELEPHONY_LOGE("write descriptor fail"); + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(MmiCodeInfo); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&info, length); + if (Remote() == nullptr) { + TELEPHONY_LOGE("function Remote() return nullptr!"); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + int32_t error = Remote()->SendRequest(UPDATE_MMI_CODE_RESULT_REQUEST, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("report async results failed, error: %{public}d", error); + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + void CallAbilityCallbackProxy::PackDataParcel( CallResultReportId reportId, AppExecFwk::PacMap &resultInfo, MessageParcel &dataParcel) { diff --git a/services/call_report/src/call_ability_report_proxy.cpp b/services/call_report/src/call_ability_report_proxy.cpp old mode 100755 new mode 100644 index 6fffdeec151d5b517dc80522eb124a64e316bda7..9a444c940b91cab751a0d6e0b983670c646d0081 --- a/services/call_report/src/call_ability_report_proxy.cpp +++ b/services/call_report/src/call_ability_report_proxy.cpp @@ -47,7 +47,6 @@ CallAbilityReportProxy::~CallAbilityReportProxy() int32_t CallAbilityReportProxy::RegisterCallBack( sptr callAbilityCallbackPtr, std::string &bundleName) { - std::string tmpName = ""; if (callAbilityCallbackPtr == nullptr) { TELEPHONY_LOGE("callAbilityCallbackPtr is null"); return TELEPHONY_ERR_LOCAL_PTR_NULL; @@ -55,9 +54,8 @@ int32_t CallAbilityReportProxy::RegisterCallBack( callAbilityCallbackPtr->SetBundleName(bundleName); std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { - (*it)->GetBundleName(tmpName); - if (tmpName == bundleName) { + for (; it != callbackPtrList_.end(); ++it) { + if ((*it)->GetBundleName() == bundleName) { (*it).clear(); (*it) = callAbilityCallbackPtr; TELEPHONY_LOGI("%{public}s RegisterCallBack success", bundleName.c_str()); @@ -65,19 +63,6 @@ int32_t CallAbilityReportProxy::RegisterCallBack( } } callbackPtrList_.emplace_back(callAbilityCallbackPtr); - if ((bundleName == "com.example.callmanager") || (bundleName == "com.ohos.calldemo") || - (bundleName == "com.example.telephone_demo")) { - std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { - (*it)->GetBundleName(tmpName); - if (tmpName == "com.ohos.callui") { - callAbilityCallbackPtr_ = (*it); - callbackPtrList_.erase(it++); - callbackPtrList_.emplace_back(callAbilityCallbackPtr_); - break; - } - } - } TELEPHONY_LOGI("%{public}s successfully registered the callback for the first time!", bundleName.c_str()); return TELEPHONY_SUCCESS; } @@ -88,12 +73,10 @@ int32_t CallAbilityReportProxy::UnRegisterCallBack(std::string &bundleName) TELEPHONY_LOGE("callbackPtrList_ is null! %{public}s UnRegisterCallBack failed", bundleName.c_str()); return TELEPHONY_ERR_LOCAL_PTR_NULL; } - std::string tmpName = ""; std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { - (*it)->GetBundleName(tmpName); - if (tmpName == bundleName) { + for (; it != callbackPtrList_.end(); ++it) { + if ((*it)->GetBundleName() == bundleName) { callbackPtrList_.erase(it); TELEPHONY_LOGI("%{public}s UnRegisterCallBack success", bundleName.c_str()); return TELEPHONY_SUCCESS; @@ -123,16 +106,14 @@ void CallAbilityReportProxy::CallEventUpdated(CallEventInfo &info) void CallAbilityReportProxy::CallDestroyed(int32_t cause) { int32_t ret = TELEPHONY_ERR_FAIL; - std::string bundleName = ""; std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { + for (; it != callbackPtrList_.end(); ++it) { if ((*it)) { ret = (*it)->OnCallDisconnectedCause((DisconnectedDetails)cause); if (ret != TELEPHONY_SUCCESS) { - (*it)->GetBundleName(bundleName); TELEPHONY_LOGW("OnCallDisconnectedCause failed, errcode:%{public}d, bundleName:%{public}s", ret, - bundleName.c_str()); + ((*it)->GetBundleName()).c_str()); continue; } } @@ -146,16 +127,13 @@ int32_t CallAbilityReportProxy::ReportCallStateInfo(const CallAttributeInfo &inf std::string bundleName = ""; std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { + for (; it != callbackPtrList_.end(); ++it) { if ((*it)) { - (*it)->GetBundleName(bundleName); - if (IsBundleNameConflict(bundleName)) { - continue; - } + bundleName = (*it)->GetBundleName(); ret = (*it)->OnCallDetailsChange(info); if (ret != TELEPHONY_SUCCESS) { callbackPtrList_.erase(it++); - it--; + --it; TELEPHONY_LOGW("OnCallDetailsChange failed, errcode:%{public}d, bundleName:%{public}s", ret, bundleName.c_str()); continue; @@ -170,17 +148,15 @@ int32_t CallAbilityReportProxy::ReportCallStateInfo(const CallAttributeInfo &inf int32_t CallAbilityReportProxy::ReportCallEvent(const CallEventInfo &info) { int32_t ret = TELEPHONY_ERR_FAIL; - std::string bundleName = ""; TELEPHONY_LOGI("report call event, eventId:%{public}d", info.eventId); std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { + for (; it != callbackPtrList_.end(); ++it) { if ((*it)) { ret = (*it)->OnCallEventChange(info); if (ret != TELEPHONY_SUCCESS) { - (*it)->GetBundleName(bundleName); TELEPHONY_LOGW("OnCallEventChange failed, errcode:%{public}d, bundleName:%{public}s", ret, - bundleName.c_str()); + ((*it)->GetBundleName()).c_str()); continue; } } @@ -193,16 +169,14 @@ int32_t CallAbilityReportProxy::ReportAsyncResults( const CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) { int32_t ret = TELEPHONY_ERR_FAIL; - std::string bundleName = ""; std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { + for (; it != callbackPtrList_.end(); ++it) { if ((*it)) { ret = (*it)->OnReportAsyncResults(reportId, resultInfo); if (ret != TELEPHONY_SUCCESS) { - (*it)->GetBundleName(bundleName); TELEPHONY_LOGW("ReportAsyncResults failed, errcode:%{public}d, bundleName:%{public}s", ret, - bundleName.c_str()); + ((*it)->GetBundleName()).c_str()); continue; } } @@ -211,14 +185,33 @@ int32_t CallAbilityReportProxy::ReportAsyncResults( return ret; } +int32_t CallAbilityReportProxy::ReportMmiCodeResult(const MmiCodeInfo &info) +{ + int32_t ret = TELEPHONY_ERR_FAIL; + std::lock_guard lock(mutex_); + std::list>::iterator it = callbackPtrList_.begin(); + for (; it != callbackPtrList_.end(); ++it) { + if ((*it)) { + ret = (*it)->OnReportMmiCodeResult(info); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGW("ReportMmiCodeResult failed, errcode:%{public}d, bundleName:%{public}s", ret, + ((*it)->GetBundleName()).c_str()); + continue; + } + } + } + TELEPHONY_LOGI("ReportMmiCodeResult success"); + return ret; +} + int32_t CallAbilityReportProxy::OttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) { int32_t ret = TELEPHONY_ERR_FAIL; std::string name = ""; std::lock_guard lock(mutex_); std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { - (*it)->GetBundleName(name); + for (; it != callbackPtrList_.end(); ++it) { + name = (*it)->GetBundleName(); if (name == "com.ohos.callservice") { ret = (*it)->OnOttCallRequest(requestId, info); if (ret != TELEPHONY_SUCCESS) { @@ -231,20 +224,5 @@ int32_t CallAbilityReportProxy::OttCallRequest(OttCallRequestId requestId, AppEx TELEPHONY_LOGI("OttCallRequest success, requestId:%{public}d", requestId); return ret; } - -bool CallAbilityReportProxy::IsBundleNameConflict(std::string &bundleName) -{ - std::string tmpName = ""; - std::list>::iterator it = callbackPtrList_.begin(); - for (; it != callbackPtrList_.end(); it++) { - (*it)->GetBundleName(tmpName); - if ((tmpName == "com.example.callmanager" || tmpName == "com.ohos.calldemo" || - tmpName == "com.example.telephone_demo") && - (bundleName == "com.ohos.callui")) { - return true; - } - } - return false; -} } // namespace Telephony } // namespace OHOS diff --git a/services/call_report/src/call_state_report_proxy.cpp b/services/call_report/src/call_state_report_proxy.cpp old mode 100755 new mode 100644 diff --git a/services/call_setting/include/call_setting_manager.h b/services/call_setting/include/call_setting_manager.h old mode 100755 new mode 100644 index 9fb8c858caf345a2c99f8a6bea9092ca6b30c582..ec2dba3e2f96b38a57191e4f8dfadb384c4e350c --- a/services/call_setting/include/call_setting_manager.h +++ b/services/call_setting/include/call_setting_manager.h @@ -21,7 +21,6 @@ #include "pac_map.h" -#include "cellular_call_types.h" #include "cellular_call_connection.h" namespace OHOS { diff --git a/services/call_setting/src/call_setting_manager.cpp b/services/call_setting/src/call_setting_manager.cpp old mode 100755 new mode 100644 index 7701ae1fc576419c22f341089d74db04997a6f56..e3cbf4d080f2b48f58e9c5a185c8499c75083b35 --- a/services/call_setting/src/call_setting_manager.cpp +++ b/services/call_setting/src/call_setting_manager.cpp @@ -15,7 +15,6 @@ #include "call_setting_manager.h" -#include "cellular_call_data_struct.h" #include "call_manager_errors.h" #include "telephony_log_wrapper.h" @@ -74,9 +73,8 @@ int32_t CallSettingManager::GetCallRestriction(int32_t slotId, CallRestrictionTy int32_t CallSettingManager::SetCallRestriction(int32_t slotId, CallRestrictionInfo &info) { TELEPHONY_LOGI( - "SetCallRestriction: slotId = %{public}d, mode = %{public}d, type = %{public}d, password = " - "%{public}s", - slotId, info.mode, info.fac, info.password); + "SetCallRestriction: slotId = %{public}d, mode = %{public}d, type = %{public}d", + slotId, info.mode, info.fac); int32_t ret = SetCallRestrictionPolicy(slotId, info); if (ret != TELEPHONY_SUCCESS) { TELEPHONY_LOGE("Invalid data!"); diff --git a/services/telephony_interaction/include/call_status_callback.h b/services/telephony_interaction/include/call_status_callback.h old mode 100755 new mode 100644 index 7b76bc288ed68cf85bb1d893fe92e2f80b05f5a7..b40e1d257735ebc656f53c256094b91e2f3db48b --- a/services/telephony_interaction/include/call_status_callback.h +++ b/services/telephony_interaction/include/call_status_callback.h @@ -58,6 +58,7 @@ public: int32_t SetLteEnhanceModeResult(const int32_t result) override; int32_t ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse &response) override; int32_t InviteToConferenceResult(const int32_t result) override; + int32_t SendMmiCodeResult(const MmiCodeInfo &info) override; }; } // namespace Telephony } // namespace OHOS diff --git a/services/telephony_interaction/include/call_status_callback_proxy.h b/services/telephony_interaction/include/call_status_callback_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..9f45c7ec87019e24c614bf781ccd07fd9a66e57d --- /dev/null +++ b/services/telephony_interaction/include/call_status_callback_proxy.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2021 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 CALL_STATUS_CALLBACK_PROXY_H +#define CALL_STATUS_CALLBACK_PROXY_H + +#include "iremote_proxy.h" +#include "i_call_status_callback.h" + +namespace OHOS { +namespace Telephony { +class CallStatusCallbackProxy : public IRemoteProxy { +public: + explicit CallStatusCallbackProxy(const sptr &impl); + virtual ~CallStatusCallbackProxy() = default; + + int32_t UpdateCallReportInfo(const CallReportInfo &info) override; + int32_t UpdateCallsReportInfo(const CallsReportInfo &info) override; + int32_t UpdateDisconnectedCause(const DisconnectedDetails &cause) override; + int32_t UpdateEventResultInfo(const CellularCallEventInfo &info) override; + int32_t UpdateRBTPlayInfo(const RBTPlayInfo info) override; + int32_t UpdateGetWaitingResult(const CallWaitResponse &callWaitResponse) override; + int32_t UpdateSetWaitingResult(const int32_t result) override; + int32_t UpdateGetRestrictionResult(const CallRestrictionResponse &callRestrictionResult) override; + int32_t UpdateSetRestrictionResult(const int32_t result) override; + int32_t UpdateGetTransferResult(const CallTransferResponse &callTransferResponse) override; + int32_t UpdateSetTransferResult(const int32_t result) override; + int32_t UpdateGetCallClipResult(const ClipResponse &clipResponse) override; + int32_t UpdateGetCallClirResult(const ClirResponse &clirResponse) override; + int32_t UpdateSetCallClirResult(const int32_t result) override; + int32_t GetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) override; + int32_t SetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) override; + int32_t StartRttResult(const int32_t result) override; + int32_t StopRttResult(const int32_t result) override; + int32_t GetImsConfigResult(const GetImsConfigResponse &response) override; + int32_t SetImsConfigResult(const int32_t result) override; + int32_t GetImsFeatureValueResult(const GetImsFeatureValueResponse &response) override; + int32_t SetImsFeatureValueResult(const int32_t result) override; + int32_t GetLteEnhanceModeResult(const GetLteEnhanceModeResponse &response) override; + int32_t SetLteEnhanceModeResult(const int32_t result) override; + int32_t ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse &response) override; + int32_t InviteToConferenceResult(const int32_t result) override; + int32_t StartDtmfResult(const int32_t result) override; + int32_t StopDtmfResult(const int32_t result) override; + int32_t SendUssdResult(const int32_t result) override; + int32_t GetImsCallDataResult(const int32_t result) override; + int32_t SendMmiCodeResult(const MmiCodeInfo &info) override; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace Telephony +} // namespace OHOS + +#endif diff --git a/services/telephony_interaction/include/call_status_callback_stub.h b/services/telephony_interaction/include/call_status_callback_stub.h old mode 100755 new mode 100644 index ba598ece07f242b1a0e1b75983789d15dd0aabaa..598ef289be9d0e9380caec91518d68308d6590f6 --- a/services/telephony_interaction/include/call_status_callback_stub.h +++ b/services/telephony_interaction/include/call_status_callback_stub.h @@ -65,6 +65,7 @@ private: int32_t OnStopDtmfResult(MessageParcel &data, MessageParcel &reply); int32_t OnSendUssdResult(MessageParcel &data, MessageParcel &reply); int32_t OnGetImsCallDataResult(MessageParcel &data, MessageParcel &reply); + int32_t OnSendMmiCodeResult(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; }; diff --git a/services/telephony_interaction/include/cellular_call_connection.h b/services/telephony_interaction/include/cellular_call_connection.h old mode 100755 new mode 100644 diff --git a/services/telephony_interaction/include/cellular_call_death_recipient.h b/services/telephony_interaction/include/cellular_call_death_recipient.h new file mode 100644 index 0000000000000000000000000000000000000000..4ef9200e71b4ad91a28da354a409ff0f5fd63a29 --- /dev/null +++ b/services/telephony_interaction/include/cellular_call_death_recipient.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 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_CELLULAR_CALL_DEATH_RECIPIENT_H +#define TELEPHONY_CELLULAR_CALL_DEATH_RECIPIENT_H + +#include "iremote_broker.h" + +namespace OHOS { +namespace Telephony { +class CellularCallDeathRecipient : public IRemoteObject::DeathRecipient { +public: + explicit CellularCallDeathRecipient(const std::function &object)> &deathCallback); + virtual ~CellularCallDeathRecipient() = default; + void OnRemoteDied(const wptr &object) override; + +private: + std::function &object)> deathCallback_; +}; +} // namespace Telephony +} // namespace OHOS +#endif // TELEPHONY_CELLULAR_CALL_DEATH_RECIPIENT_H diff --git a/services/telephony_interaction/include/cellular_call_interface.h b/services/telephony_interaction/include/cellular_call_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..77d327fb74eb735037ac835e8da4bd8dd7772beb --- /dev/null +++ b/services/telephony_interaction/include/cellular_call_interface.h @@ -0,0 +1,502 @@ +/* + * Copyright (C) 2021 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 CELLULAR_CALL_INTERFACE_H +#define CELLULAR_CALL_INTERFACE_H +#include "telephony_types.h" + +#include "i_call_status_callback.h" + +namespace OHOS { +namespace Telephony { +class CellularCallInterface : public IRemoteBroker { +public: + // operation type + enum class OperationType : uint32_t { + /****************** basic ******************/ + DIAL = 1, + HANG_UP, + REJECT, + ANSWER, + HOLD_CALL, + UN_HOLD_CALL, + SWITCH_CALL, + EMERGENCY_CALL, + SET_EMERGENCY_CALL_LIST, + COMBINE_CONFERENCE, + SEPARATE_CONFERENCE, + INVITE_TO_CONFERENCE, + KICK_OUT_CONFERENCE, + HANG_UP_ALL_CONNECTION, + UPDATE_CALL_MEDIA_MODE, + REGISTER_CALLBACK, + UNREGISTER_CALLBACK, + + /****************** dtmf、rtt ******************/ + START_DTMF = 100, + STOP_DTMF, + SEND_DTMF, + START_RTT, + STOP_RTT, + + /****************** supplement ******************/ + SET_CALL_TRANSFER = 200, + GET_CALL_TRANSFER, + SET_CALL_WAITING, + GET_CALL_WAITING, + SET_CALL_RESTRICTION, + GET_CALL_RESTRICTION, + + /****************** config ******************/ + SET_DOMAIN_PREFERENCE_MODE = 300, + GET_DOMAIN_PREFERENCE_MODE, + SET_LTE_IMS_SWITCH_STATUS, + GET_LTE_IMS_SWITCH_STATUS, + SET_IMS_CONFIG_STRING, + SET_IMS_CONFIG_INT, + GET_IMS_CONFIG, + SET_IMS_FEATURE, + GET_IMS_FEATURE, + SET_IMS_SWITCH_ENHANCE_MODE, + GET_IMS_SWITCH_ENHANCE_MODE, + SET_MUTE, + GET_MUTE, + + /****************** video settings ******************/ + CTRL_CAMERA = 400, + SET_PREVIEW_WINDOW, + SET_DISPLAY_WINDOW, + SET_CAMERA_ZOOM, + SET_PAUSE_IMAGE, + SET_DEVICE_DIRECTION, + }; + + /** + * Call management dial interface + * + * @param CellularCallInfo, dial param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t Dial(const CellularCallInfo &callInfo) = 0; + + /** + * HangUp. + * + * @param CellularCallInfo, HangUp param. + * @param CallSupplementType + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) = 0; + + /** + * Answer. + * + * @param CellularCallInfo, Answer param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t Answer(const CellularCallInfo &callInfo) = 0; + + /** + * Reject. + * + * @param CellularCallInfo, Reject param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t Reject(const CellularCallInfo &callInfo) = 0; + + /** + * HoldCall. + * + * @param CellularCallInfo, Hold param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t HoldCall(const CellularCallInfo &callInfo) = 0; + + /** + * UnHoldCall. + * + * @param CellularCallInfo, UnHold param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t UnHoldCall(const CellularCallInfo &callInfo) = 0; + + /** + * SwitchCall. + * + * @param CellularCallInfo, SwitchCall param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SwitchCall(const CellularCallInfo &callInfo) = 0; + + /** + * IsEmergencyPhoneNumber. + * + * @param slotId. + * @param phone number. + * @param error Code. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, int32_t &errorCode) = 0; + + /** + * Merge into multiple calls + * + * @param CellularCallInfo, SwitchCall param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t CombineConference(const CellularCallInfo &callInfo) = 0; + + /** + * Separate Conference. + * + * @param CellularCallInfo, SwitchCall param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SeparateConference(const CellularCallInfo &callInfo) = 0; + + /** + * InviteToConference interface + * + * @param numberList + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t InviteToConference(int32_t slotId, const std::vector &numberList) = 0; + + /** + * KickOutFromConference interface + * + * @param numberList + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t KickOutFromConference(int32_t slotId, const std::vector &numberList) = 0; + + /** + * Hang Up All Connection. + * + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t HangUpAllConnection() = 0; + + /** + * IMS Update Call Media Mode + * + * @param CellularCallInfo + * @param ImsCallMode + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t UpdateImsCallMode(const CellularCallInfo &callInfo, ImsCallMode mode) = 0; + + /** + * Start Dtmf. + * + * @param Dtmf Code. + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo) = 0; + + /** + * Stop Dtmf. + * + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t StopDtmf(const CellularCallInfo &callInfo) = 0; + + /** + * Send Dtmf. + * + * @param Dtmf Code. + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo) = 0; + + /** + * Start Rtt interface + * + * @param msg + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t StartRtt(int32_t slotId, const std::string &msg) = 0; + + /** + * Stop Rtt interface + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t StopRtt(int32_t slotId) = 0; + + /** + * Set Call Transfer + * + * @param CallTransferInfo + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetCallTransferInfo(int32_t slotId, const CallTransferInfo &ctInfo) = 0; + + /** + * Get Call Transfer + * + * @param CallTransferType + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type) = 0; + + /** + * Set Call Waiting + * + * @param activate + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetCallWaiting(int32_t slotId, bool activate) = 0; + + /** + * Get Call Waiting + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetCallWaiting(int32_t slotId) = 0; + + /** + * Set Call Restriction + * + * @param CallRestrictionInfo + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetCallRestriction(int32_t slotId, const CallRestrictionInfo &cRInfo) = 0; + + /** + * Get Call Restriction + * + * @param CallRestrictionType + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetCallRestriction(int32_t slotId, CallRestrictionType facType) = 0; + + /** + * Register CallBack + * + * @param sptr + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t RegisterCallManagerCallBack(const sptr &callback) = 0; + + /** + * UnRegister CallBack + * + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t UnRegisterCallManagerCallBack() = 0; + + /** + * Set Domain Preference Mode + * + * @param mode + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode) = 0; + + /** + * Get Domain Preference Mode + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetDomainPreferenceMode(int32_t slotId) = 0; + + /** + * Set Lte Ims Switch Status + * + * @param active + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetLteImsSwitchStatus(int32_t slotId, bool active) = 0; + + /** + * Get Lte Ims Switch Status + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetLteImsSwitchStatus(int32_t slotId) = 0; + + /** + * Set Ims Config + * + * @param ImsConfigItem + * @param value + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value) = 0; + + /** + * Set Ims Config + * + * @param ImsConfigItem + * @param value + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value) = 0; + + /** + * Get Ims Config + * + * @param ImsConfigItem + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetImsConfig(int32_t slotId, ImsConfigItem item) = 0; + + /** + * Set Ims Feature Value + * + * @param FeatureType + * @param value + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value) = 0; + + /** + * Get Ims Feature Value + * + * @param FeatureType + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetImsFeatureValue(int32_t slotId, FeatureType type) = 0; + + /** + * Set Ims Switch Enhance Mode + * + * @param value + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetImsSwitchEnhanceMode(int32_t slotId, bool value) = 0; + + /** + * Get Ims Switch Enhance Mode + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetImsSwitchEnhanceMode(int32_t slotId) = 0; + + /** + * CtrlCamera + * + * @param cameraId + * @param callingUid + * @param callingPid + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid) = 0; + + /** + * SetPreviewWindow + * + * @param x + * @param y + * @param z + * @param width + * @param height + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) = 0; + + /** + * SetDisplayWindow + * + * @param x + * @param y + * @param z + * @param width + * @param height + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) = 0; + + /** + * SetCameraZoom + * + * @param zoomRatio + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetCameraZoom(float zoomRatio) = 0; + + /** + * SetPauseImage + * + * @param path + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetPauseImage(const std::u16string &path) = 0; + + /** + * SetDeviceDirection + * + * @param rotation + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetDeviceDirection(int32_t rotation) = 0; + + /** + * SetMute + * + * @param mute + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t SetMute(int32_t slotId, int32_t mute) = 0; + + /** + * GetMute + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + virtual int32_t GetMute(int32_t slotId) = 0; + + /** + * SetEmergencyCallList + * + * @brief Is it an emergency call + * @param eccVecr[in], Phone number to be formatted + * @param slotId[in], The slot id + * @return Returns 0 on ture, others on false. + */ + virtual int32_t SetEmergencyCallList(int32_t slotId, std::vector &eccVec) = 0; + +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.CellularCallInterface"); +}; +} // namespace Telephony +} // namespace OHOS +#endif // CELLULAR_CALL_INTERFACE_H diff --git a/services/telephony_interaction/include/cellular_call_proxy.h b/services/telephony_interaction/include/cellular_call_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..f645a4a1de99578b1161afa774c9525d0aa2d0db --- /dev/null +++ b/services/telephony_interaction/include/cellular_call_proxy.h @@ -0,0 +1,449 @@ +/* + * Copyright (C) 2021 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 CELLULAR_CALL_PROXY_H +#define CELLULAR_CALL_PROXY_H + +#include "cellular_call_interface.h" +#include "iremote_proxy.h" + +namespace OHOS { +namespace Telephony { +class CellularCallProxy : public IRemoteProxy { +public: + /** + * CellularCallProxy + * + * @param impl + */ + explicit CellularCallProxy(const sptr &impl) : IRemoteProxy(impl) {} + + /** + * ~CellularCallProxy + * + */ + ~CellularCallProxy() = default; + + /** + * Call management dial interface + * + * @param CellularCallInfo, dial param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t Dial(const CellularCallInfo &callInfo) override; + + /** + * HangUp. + * + * @param CellularCallInfo, HangUp param. + * @param CallSupplementType + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) override; + + /** + * Reject. + * + * @param CellularCallInfo, Reject param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t Reject(const CellularCallInfo &callInfo) override; + + /** + * Answer. + * + * @param CellularCallInfo, Answer param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t Answer(const CellularCallInfo &callInfo) override; + + /** + * HoldCall. + * + * @param CellularCallInfo, Hold param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t HoldCall(const CellularCallInfo &callInfo) override; + + /** + * UnHoldCall. + * + * @param CellularCallInfo, UnHold param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t UnHoldCall(const CellularCallInfo &callInfo) override; + + /** + * SwitchCall. + * + * @param CellularCallInfo, SwitchCall param. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SwitchCall(const CellularCallInfo &callInfo) override; + + /** + * IsEmergencyPhoneNumber. + * + * @param phone number. + * @param slotId. + * @param error Code. + * @return Is Urgent Call. + */ + int32_t IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, int32_t &errorCode) override; + + /** + * Merge into multiple calls + * + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t CombineConference(const CellularCallInfo &callInfo) override; + + /** + * SeparateConference. + * + * @param std::string splitString + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SeparateConference(const CellularCallInfo &callInfo) override; + + /** + * InviteToConference interface + * + * @param numberList + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t InviteToConference(int32_t slotId, const std::vector &numberList) override; + + /** + * KickOutFromConference interface + * + * @param numberList + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t KickOutFromConference(int32_t slotId, const std::vector &numberList) override; + + /** + * Hang Up All Connection. + * + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t HangUpAllConnection() override; + + /** + * IMS Update Call Media Mode + * + * @param CellularCallInfo + * @param ImsCallMode + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t UpdateImsCallMode(const CellularCallInfo &callInfo, ImsCallMode mode) override; + + /** + * StartDtmf. + * + * @param Dtmf Code. + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo) override; + + /** + * StopDtmf. + * + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t StopDtmf(const CellularCallInfo &callInfo) override; + + /** + * SendDtmf. + * + * @param Dtmf Code. + * @param CellularCallInfo. + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo) override; + + /** + * Start Rtt + * + * @param msg + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t StartRtt(int32_t slotId, const std::string &msg) override; + + /** + * Stop Rtt + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t StopRtt(int32_t slotId) override; + + /** + * Set Call Transfer + * + * @param CallTransferInfo + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetCallTransferInfo(int32_t slotId, const CallTransferInfo &cfInfo) override; + + /** + * Inquire Call Transfer + * + * @param CallTransferType + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type) override; + + /** + * Set Call Waiting + * + * @param activate + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetCallWaiting(int32_t slotId, bool activate) override; + + /** + * Inquire Call Waiting + * + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetCallWaiting(int32_t slotId) override; + + /** + * Set Call Restriction + * + * @param CallRestrictionInfo + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo) override; + + /** + * Inquire Call Restriction + * + * @param CallRestrictionType + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetCallRestriction(int32_t slotId, CallRestrictionType facType) override; + + /** + * RegisterCallManagerCallBack + * + * @param sptr + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t RegisterCallManagerCallBack(const sptr &callback) override; + + /** + * UnRegister CallManager CallBack + * + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t UnRegisterCallManagerCallBack() override; + + /** + * Set Domain Preference Mode + * + * @param mode + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode) override; + + /** + * Get Domain Preference Mode + * + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetDomainPreferenceMode(int32_t slotId) override; + + /** + * Set Lte Ims Switch Status + * + * @param active + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetLteImsSwitchStatus(int32_t slotId, bool active) override; + + /** + * Get Lte Ims Switch Status + * + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetLteImsSwitchStatus(int32_t slotId) override; + + /** + * Set Ims Config + * + * @param ImsConfigItem + * @param value + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value) override; + + /** + * Set Ims Config + * + * @param ImsConfigItem + * @param value + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value) override; + + /** + * Get Ims Config + * + * @param ImsConfigItem + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetImsConfig(int32_t slotId, ImsConfigItem item) override; + + /** + * Set Ims Feature Value + * + * @param FeatureType + * @param value + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value) override; + + /** + * Get Ims Feature Value + * + * @param FeatureType + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetImsFeatureValue(int32_t slotId, FeatureType type) override; + + /** + * Set Ims Switch Enhance Mode + * + * @param value + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetImsSwitchEnhanceMode(int32_t slotId, bool value) override; + + /** + * Get Ims Switch Enhance Mode + * @param slot Id + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetImsSwitchEnhanceMode(int32_t slotId) override; + + /** + * CtrlCamera + * + * @param cameraId + * @param callingUid + * @param callingPid + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid) override; + + /** + * SetPreviewWindow + * + * @param x + * @param y + * @param z + * @param width + * @param height + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) override; + + /** + * SetDisplayWindow + * + * @param x + * @param y + * @param z + * @param width + * @param height + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) override; + + /** + * SetCameraZoom + * + * @param zoomRatio + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetCameraZoom(float zoomRatio) override; + + /** + * SetPauseImage + * + * @param path + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetPauseImage(const std::u16string &path) override; + + /** + * SetDeviceDirection + * + * @param rotation + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetDeviceDirection(int32_t rotation) override; + + /** + * SetMute + * + * @param mute + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SetMute(int32_t mute, int32_t slotId) override; + + /** + * GetMute + * + * @param slotId + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t GetMute(int32_t slotId) override; + + int32_t SetEmergencyCallList(int32_t slotId, std::vector &eccVec) override; + +private: + const int32_t MAX_SIZE = 10; + static inline BrokerDelegator delegator_; +}; +} // namespace Telephony +} // namespace OHOS +#endif // CELLULAR_CALL_PROXY_H diff --git a/services/telephony_interaction/include/core_service_connection.h b/services/telephony_interaction/include/core_service_connection.h old mode 100755 new mode 100644 diff --git a/services/telephony_interaction/include/i_call_status_callback.h b/services/telephony_interaction/include/i_call_status_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..bde63c3f1817d4b23d6d85cd0840df0ea5aa9ca9 --- /dev/null +++ b/services/telephony_interaction/include/i_call_status_callback.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2021 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 I_CALL_STATUS_CALLBACK_H +#define I_CALL_STATUS_CALLBACK_H + +#include "iremote_broker.h" +#include "call_manager_inner_type.h" + +namespace OHOS { +namespace Telephony { +class ICallStatusCallback : public IRemoteBroker { +public: + virtual ~ICallStatusCallback() = default; + + virtual int32_t UpdateCallReportInfo(const CallReportInfo &info) = 0; + virtual int32_t UpdateCallsReportInfo(const CallsReportInfo &info) = 0; + virtual int32_t UpdateDisconnectedCause(const DisconnectedDetails &cause) = 0; + virtual int32_t UpdateEventResultInfo(const CellularCallEventInfo &info) = 0; + virtual int32_t UpdateRBTPlayInfo(const RBTPlayInfo info) = 0; + virtual int32_t UpdateGetWaitingResult(const CallWaitResponse &callWaitResponse) = 0; + virtual int32_t UpdateSetWaitingResult(const int32_t result) = 0; + virtual int32_t UpdateGetRestrictionResult(const CallRestrictionResponse &callRestrictionResult) = 0; + virtual int32_t UpdateSetRestrictionResult(int32_t result) = 0; + virtual int32_t UpdateGetTransferResult(const CallTransferResponse &callTransferResponse) = 0; + virtual int32_t UpdateSetTransferResult(const int32_t result) = 0; + virtual int32_t UpdateGetCallClipResult(const ClipResponse &clipResponse) = 0; + virtual int32_t UpdateGetCallClirResult(const ClirResponse &clirResponse) = 0; + virtual int32_t UpdateSetCallClirResult(const int32_t result) = 0; + virtual int32_t GetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) = 0; + virtual int32_t SetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) = 0; + virtual int32_t StartRttResult(const int32_t result) = 0; + virtual int32_t StopRttResult(const int32_t result) = 0; + virtual int32_t GetImsConfigResult(const GetImsConfigResponse &response) = 0; + virtual int32_t SetImsConfigResult(const int32_t result) = 0; + virtual int32_t GetImsFeatureValueResult(const GetImsFeatureValueResponse &response) = 0; + virtual int32_t SetImsFeatureValueResult(const int32_t result) = 0; + virtual int32_t GetLteEnhanceModeResult(const GetLteEnhanceModeResponse &response) = 0; + virtual int32_t SetLteEnhanceModeResult(const int32_t result) = 0; + virtual int32_t ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse &response) = 0; + virtual int32_t InviteToConferenceResult(const int32_t result) = 0; + virtual int32_t StartDtmfResult(const int32_t result) = 0; + virtual int32_t StopDtmfResult(const int32_t result) = 0; + virtual int32_t SendUssdResult(const int32_t result) = 0; + virtual int32_t GetImsCallDataResult(const int32_t result) = 0; + virtual int32_t SendMmiCodeResult(const MmiCodeInfo &info) = 0; + + enum CallManagerCallStatusCode { + UPDATE_CALL_INFO = 0, + UPDATE_CALLS_INFO, + UPDATE_DISCONNECTED_CAUSE, + UPDATE_EVENT_RESULT_INFO, + UPDATE_RBT_PLAY_INFO, + UPDATE_GET_WAITING, + UPDATE_SET_WAITING, + UPDATE_GET_RESTRICTION, + UPDATE_SET_RESTRICTION, + UPDATE_GET_TRANSFER, + UPDATE_SET_TRANSFER, + UPDATE_GET_CALL_CLIP, + UPDATE_GET_CALL_CLIR, + UPDATE_SET_CALL_CLIR, + GET_VOLTE_SWITCH_STATUS, + SET_VOLTE_SWITCH_STATUS, + UPDATE_STARTRTT_STATUS, + UPDATE_STOPRTT_STATUS, + GET_IMS_CONFIG, + SET_IMS_CONFIG, + GET_IMS_FEATURE_VALUE, + SET_IMS_FEATURE_VALUE, + GET_LTE_ENHANCE_MODE, + SET_LTE_ENHANCE_MODE, + RECEIVE_UPDATE_MEDIA_MODE_RESPONSE, + INVITE_TO_CONFERENCE, + START_DTMF, + STOP_DTMF, + SEND_USSD, + GET_IMS_CALL_DATA, + MMI_CODE_INFO_RESPONSE, + }; + +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.ICallStatusCallback"); +}; +} // namespace Telephony +} // namespace OHOS + +#endif diff --git a/services/telephony_interaction/include/report_call_info_handler.h b/services/telephony_interaction/include/report_call_info_handler.h old mode 100755 new mode 100644 diff --git a/services/telephony_interaction/src/call_status_callback.cpp b/services/telephony_interaction/src/call_status_callback.cpp old mode 100755 new mode 100644 index 6d6aecc140bdd56e0a661ab9a9cb5d1805eaf7ff..1dcecb52ff3cf481004c65c4fe407a1a18860528 --- a/services/telephony_interaction/src/call_status_callback.cpp +++ b/services/telephony_interaction/src/call_status_callback.cpp @@ -54,7 +54,7 @@ int32_t CallStatusCallback::UpdateCallsReportInfo(const CallsReportInfo &info) CallDetailInfo detailInfo; CallsReportInfo callsInfo = info; std::vector::iterator it = callsInfo.callVec.begin(); - for (; it != callsInfo.callVec.end(); it++) { + for (; it != callsInfo.callVec.end(); ++it) { detailInfo.callType = (*it).callType; detailInfo.accountId = (*it).accountId; detailInfo.index = (*it).index; @@ -136,6 +136,18 @@ int32_t CallStatusCallback::SendUssdResult(const int32_t result) return DelayedSingleton::GetInstance()->ReportAsyncResults(reportId, resultInfo); } +int32_t CallStatusCallback::SendMmiCodeResult(const MmiCodeInfo &info) +{ + TELEPHONY_LOGI("SendMmiCodeResult result = %{public}d, message = %{public}s", info.result, info.message); + int32_t ret = DelayedSingleton::GetInstance()->ReportMmiCodeResult(info); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("UpdateDisconnectedCause failed! errCode:%{public}d", ret); + } else { + TELEPHONY_LOGI("UpdateDisconnectedCause success!"); + } + return ret; +} + int32_t CallStatusCallback::GetImsCallDataResult(const int32_t result) { CallResultReportId reportId = CallResultReportId::GET_IMS_CALL_DATA_REPORT_ID; @@ -198,6 +210,8 @@ int32_t CallStatusCallback::UpdateGetTransferResult(const CallTransferResponse & resultInfo.PutIntValue("classx", response.classx); resultInfo.PutStringValue("number", response.number); resultInfo.PutIntValue("type", response.type); + resultInfo.PutIntValue("reason", response.reason); + resultInfo.PutIntValue("time", response.time); return DelayedSingleton::GetInstance()->ReportAsyncResults(reportId, resultInfo); } diff --git a/services/telephony_interaction/src/call_status_callback_proxy.cpp b/services/telephony_interaction/src/call_status_callback_proxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..751f5e27ec40af15bb80c3d6767ed16a8d108b30 --- /dev/null +++ b/services/telephony_interaction/src/call_status_callback_proxy.cpp @@ -0,0 +1,684 @@ +/* + * Copyright (C) 2021 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 "call_status_callback_proxy.h" + +#include "message_option.h" +#include "message_parcel.h" + +#include "telephony_log_wrapper.h" +#include "call_manager_errors.h" + +namespace OHOS { +namespace Telephony { +CallStatusCallbackProxy::CallStatusCallbackProxy(const sptr &impl) + : IRemoteProxy(impl) +{} + +int32_t CallStatusCallbackProxy::UpdateCallReportInfo(const CallReportInfo &info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CallReportInfo); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&info, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_CALL_INFO, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateCallsReportInfo(const CallsReportInfo &info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t length = sizeof(CallReportInfo); + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(info.callVec.size()); + for (auto &it : info.callVec) { + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&it, length); + } + dataParcel.WriteInt32(info.slotId); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_CALLS_INFO, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateDisconnectedCause(const DisconnectedDetails &cause) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(static_cast(cause)); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_DISCONNECTED_CAUSE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateEventResultInfo(const CellularCallEventInfo &info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CellularCallEventInfo); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&info, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_EVENT_RESULT_INFO, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateRBTPlayInfo(const RBTPlayInfo info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32((int32_t)info); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_RBT_PLAY_INFO, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateGetWaitingResult(const CallWaitResponse &callWaitResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CallWaitResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&callWaitResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_GET_WAITING, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateSetWaitingResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_SET_WAITING, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateGetRestrictionResult(const CallRestrictionResponse &callRestrictionResult) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CallRestrictionResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&callRestrictionResult, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_GET_RESTRICTION, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateSetRestrictionResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_SET_RESTRICTION, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateGetTransferResult(const CallTransferResponse &callTransferResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CallTransferResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&callTransferResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_GET_TRANSFER, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateSetTransferResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_SET_TRANSFER, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateGetCallClipResult(const ClipResponse &clipResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(ClipResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&clipResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_GET_CALL_CLIP, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateGetCallClirResult(const ClirResponse &clirResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(ClirResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&clirResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_GET_CALL_CLIR, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::UpdateSetCallClirResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_SET_CALL_CLIR, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::GetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(LteImsSwitchResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&switchResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(GET_VOLTE_SWITCH_STATUS, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SetVoLteStatusResult(const LteImsSwitchResponse &switchResponse) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(LteImsSwitchResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&switchResponse, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(SET_VOLTE_SWITCH_STATUS, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::StartRttResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_STARTRTT_STATUS, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::StopRttResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(UPDATE_STOPRTT_STATUS, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::GetImsConfigResult(const GetImsConfigResponse &response) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(GetImsConfigResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&response, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(GET_IMS_CONFIG, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SetImsConfigResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(SET_IMS_CONFIG, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::GetImsFeatureValueResult(const GetImsFeatureValueResponse &response) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(GetImsFeatureValueResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&response, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(GET_IMS_FEATURE_VALUE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SetImsFeatureValueResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(SET_IMS_FEATURE_VALUE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::GetLteEnhanceModeResult(const GetLteEnhanceModeResponse &response) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(GetLteEnhanceModeResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&response, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(GET_LTE_ENHANCE_MODE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SetLteEnhanceModeResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(SET_LTE_ENHANCE_MODE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::ReceiveUpdateCallMediaModeResponse(const CallMediaModeResponse &response) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = TELEPHONY_ERR_FAIL; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(CallMediaModeResponse); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&response, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(RECEIVE_UPDATE_MEDIA_MODE_RESPONSE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::InviteToConferenceResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(INVITE_TO_CONFERENCE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::StartDtmfResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(START_DTMF, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::StopDtmfResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(STOP_DTMF, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SendUssdResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(SEND_USSD, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::SendMmiCodeResult(const MmiCodeInfo &info) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + int32_t length = sizeof(MmiCodeInfo); + dataParcel.WriteInt32(length); + dataParcel.WriteRawData((const void *)&info, length); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(MMI_CODE_INFO_RESPONSE, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} + +int32_t CallStatusCallbackProxy::GetImsCallDataResult(const int32_t result) +{ + MessageParcel dataParcel; + MessageParcel replyParcel; + MessageOption option; + int32_t error = CALL_ERR_ILLEGAL_CALL_OPERATION; + if (!dataParcel.WriteInterfaceToken(CallStatusCallbackProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + dataParcel.WriteInt32(result); + if (Remote() == nullptr) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + error = Remote()->SendRequest(GET_IMS_CALL_DATA, dataParcel, replyParcel, option); + if (error != TELEPHONY_SUCCESS) { + return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; + } + return replyParcel.ReadInt32(); +} +} // namespace Telephony +} // namespace OHOS diff --git a/services/telephony_interaction/src/call_status_callback_stub.cpp b/services/telephony_interaction/src/call_status_callback_stub.cpp old mode 100755 new mode 100644 index f72c0028798dbd04499da0a9e9998f7c4d3b9ed7..075186aafd7e56a2dfe3804dddd7cdc56fab0308 --- a/services/telephony_interaction/src/call_status_callback_stub.cpp +++ b/services/telephony_interaction/src/call_status_callback_stub.cpp @@ -18,7 +18,6 @@ #include #include "call_manager_errors.h" -#include "cellular_call_types.h" #include "telephony_log_wrapper.h" namespace OHOS { @@ -55,6 +54,7 @@ CallStatusCallbackStub::CallStatusCallbackStub() memberFuncMap_[UPDATE_STARTRTT_STATUS] = &CallStatusCallbackStub::OnStartRttResult; memberFuncMap_[UPDATE_STOPRTT_STATUS] = &CallStatusCallbackStub::OnStopRttResult; memberFuncMap_[INVITE_TO_CONFERENCE] = &CallStatusCallbackStub::OnInviteToConferenceResult; + memberFuncMap_[MMI_CODE_INFO_RESPONSE] = &CallStatusCallbackStub::OnSendMmiCodeResult; } CallStatusCallbackStub::~CallStatusCallbackStub() @@ -673,6 +673,31 @@ int32_t CallStatusCallbackStub::OnSendUssdResult(MessageParcel &data, MessagePar return TELEPHONY_SUCCESS; } +int32_t CallStatusCallbackStub::OnSendMmiCodeResult(MessageParcel &data, MessageParcel &reply) +{ + int32_t result = TELEPHONY_ERR_FAIL; + const MmiCodeInfo *parcelPtr = nullptr; + if (!data.ContainFileDescriptors()) { + TELEPHONY_LOGW("sent raw data is less than 32k"); + } + int32_t len = data.ReadInt32(); + if (len <= TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len); + return TELEPHONY_ERR_ARGUMENT_INVALID; + } + if ((parcelPtr = reinterpret_cast(data.ReadRawData(len))) == nullptr) { + TELEPHONY_LOGE("reading raw data failed, length = %d", len); + return TELEPHONY_ERR_LOCAL_PTR_NULL; + } + + result = SendMmiCodeResult(*parcelPtr); + if (!reply.WriteInt32(result)) { + TELEPHONY_LOGE("writing parcel failed"); + return TELEPHONY_ERR_WRITE_REPLY_FAIL; + } + return TELEPHONY_SUCCESS; +} + int32_t CallStatusCallbackStub::OnGetImsCallDataResult(MessageParcel &data, MessageParcel &reply) { int32_t error = TELEPHONY_ERR_FAIL; diff --git a/services/telephony_interaction/src/cellular_call_connection.cpp b/services/telephony_interaction/src/cellular_call_connection.cpp old mode 100755 new mode 100644 index 1959b894b553fb1102538f7a4f5d9b67483034d4..2f8a3e0d73479977c2a8ea4b2e7b95d361631894 --- a/services/telephony_interaction/src/cellular_call_connection.cpp +++ b/services/telephony_interaction/src/cellular_call_connection.cpp @@ -45,8 +45,10 @@ void CellularCallConnection::Init(int32_t systemAbilityId) systemAbilityId_ = systemAbilityId; int32_t result = ConnectService(); if (result != TELEPHONY_SUCCESS) { +#ifdef CELLULAR_SUPPORT TELEPHONY_LOGE("connect service failed,errCode: %{public}X", result); Timer::start(CONNECT_SERVICE_WAIT_TIME, CellularCallConnection::task); +#endif return; } TELEPHONY_LOGI("connected to cellular call service successfully!"); @@ -135,6 +137,7 @@ void CellularCallConnection::DisconnectService() int32_t CellularCallConnection::ReConnectService() { +#ifdef CELLULAR_SUPPORT if (cellularCallInterfacePtr_ == nullptr) { TELEPHONY_LOGI("try to reconnect cellular call service now..."); int32_t result = ConnectService(); @@ -143,6 +146,7 @@ int32_t CellularCallConnection::ReConnectService() return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL; } } +#endif return TELEPHONY_SUCCESS; } @@ -178,7 +182,7 @@ void CellularCallConnection::NotifyDeath() std::this_thread::sleep_for(std::chrono::milliseconds(CONNECT_SERVICE_WAIT_TIME)); int32_t result = ConnectService(); if (result != TELEPHONY_SUCCESS) { - TELEPHONY_LOGI("connect cellular call service successful"); + TELEPHONY_LOGI("connect cellular call service successfully"); return; } } diff --git a/services/telephony_interaction/src/cellular_call_death_recipient.cpp b/services/telephony_interaction/src/cellular_call_death_recipient.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b18cf3f47a7486109beafe9319f8d9058e1cd97 --- /dev/null +++ b/services/telephony_interaction/src/cellular_call_death_recipient.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2021 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 "cellular_call_death_recipient.h" + +namespace OHOS { +namespace Telephony { +CellularCallDeathRecipient::CellularCallDeathRecipient( + const std::function &object)> &deathCallback) + : deathCallback_(deathCallback) +{} + +void CellularCallDeathRecipient::OnRemoteDied(const OHOS::wptr &object) +{ + if (deathCallback_) { + deathCallback_(object); + } +} +} // namespace Telephony +} // namespace OHOS diff --git a/services/telephony_interaction/src/cellular_call_proxy.cpp b/services/telephony_interaction/src/cellular_call_proxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..45f4da928120e1b2a93a015ffe858deec5a57af1 --- /dev/null +++ b/services/telephony_interaction/src/cellular_call_proxy.cpp @@ -0,0 +1,1142 @@ +/* + * Copyright (C) 2021 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 "cellular_call_proxy.h" +#include "call_manager_errors.h" + +namespace OHOS { +namespace Telephony { +int32_t CellularCallProxy::Dial(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::DIAL), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::HangUp(const CellularCallInfo &callInfo, CallSupplementType type) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32((int32_t)type)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + + int32_t error = Remote()->SendRequest(static_cast(OperationType::HANG_UP), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::Reject(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::REJECT), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::Answer(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::ANSWER), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::HoldCall(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::HOLD_CALL), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::UnHoldCall(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::UN_HOLD_CALL), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SwitchCall(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SWITCH_CALL), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::RegisterCallManagerCallBack(const sptr &callback) +{ + if (callback == nullptr) { + return TELEPHONY_ERR_ARGUMENT_INVALID; + } + + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + + int32_t error = Remote()->SendRequest(static_cast(OperationType::REGISTER_CALLBACK), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::UnRegisterCallManagerCallBack() +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::UNREGISTER_CALLBACK), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, int32_t &errorCode) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteString(phoneNum)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(errorCode)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t ret = Remote()->SendRequest(static_cast(OperationType::EMERGENCY_CALL), in, out, option); + if (ret == ERR_NONE) { + ret = out.ReadInt32(); + errorCode = out.ReadInt32(); + } + return ret; +} + +int32_t CellularCallProxy::CombineConference(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::COMBINE_CONFERENCE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SeparateConference(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SEPARATE_CONFERENCE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::InviteToConference(int32_t slotId, const std::vector &numberList) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteStringVector(numberList)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::INVITE_TO_CONFERENCE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::KickOutFromConference(int32_t slotId, const std::vector &numberList) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteStringVector(numberList)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::KICK_OUT_CONFERENCE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::HangUpAllConnection() +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::HANG_UP_ALL_CONNECTION), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::UpdateImsCallMode(const CellularCallInfo &callInfo, ImsCallMode mode) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32((int32_t)mode)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::UPDATE_CALL_MEDIA_MODE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteCString(&cDtmfCode)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::START_DTMF), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::StopDtmf(const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::STOP_DTMF), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteCString(&cDtmfCode)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SEND_DTMF), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::StartRtt(int32_t slotId, const std::string &msg) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteString(msg)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::START_RTT), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::StopRtt(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::STOP_RTT), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetCallTransferInfo(int32_t slotId, const CallTransferInfo &ctInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&ctInfo, sizeof(CallTransferInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_CALL_TRANSFER), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetCallTransferInfo(int32_t slotId, CallTransferType type) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32((int32_t)type)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_CALL_TRANSFER), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetCallWaiting(int32_t slotId, bool activate) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteBool(activate)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_CALL_WAITING), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetCallWaiting(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_CALL_WAITING), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteRawData((const void *)&crInfo, sizeof(CallRestrictionInfo))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_CALL_RESTRICTION), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetCallRestriction(int32_t slotId, CallRestrictionType facType) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32((int32_t)facType)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_CALL_RESTRICTION), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetDomainPreferenceMode(int32_t slotId, int32_t mode) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(mode)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::SET_DOMAIN_PREFERENCE_MODE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetDomainPreferenceMode(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::GET_DOMAIN_PREFERENCE_MODE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetLteImsSwitchStatus(int32_t slotId, bool active) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteBool(active)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::SET_LTE_IMS_SWITCH_STATUS), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetLteImsSwitchStatus(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::GET_LTE_IMS_SWITCH_STATUS), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(item)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteString(value)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::SET_IMS_CONFIG_STRING), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(item)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(value)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_IMS_CONFIG_INT), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetImsConfig(int32_t slotId, ImsConfigItem item) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(item)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_IMS_CONFIG), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(type)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(value)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_IMS_FEATURE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetImsFeatureValue(int32_t slotId, FeatureType type) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(type)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_IMS_FEATURE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetImsSwitchEnhanceMode(int32_t slotId, bool value) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteBool(value)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::SET_IMS_SWITCH_ENHANCE_MODE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetImsSwitchEnhanceMode(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = + Remote()->SendRequest(static_cast(OperationType::GET_IMS_SWITCH_ENHANCE_MODE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteString16(cameraId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(callingUid)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(callingPid)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::CTRL_CAMERA), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(x)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(y)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(z)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(width)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(height)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_PREVIEW_WINDOW), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(x)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(y)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(z)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(width)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(height)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_DISPLAY_WINDOW), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetCameraZoom(float zoomRatio) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteFloat(zoomRatio)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_CAMERA_ZOOM), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetPauseImage(const std::u16string &path) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteString16(path)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_PAUSE_IMAGE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetDeviceDirection(int32_t rotation) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(rotation)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_DEVICE_DIRECTION), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetMute(int32_t slotId, int32_t mute) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(mute)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_MUTE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::GetMute(int32_t slotId) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + int32_t error = Remote()->SendRequest(static_cast(OperationType::GET_MUTE), in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} + +int32_t CellularCallProxy::SetEmergencyCallList(int32_t slotId, std::vector &eccVec) +{ + MessageOption option; + MessageParcel in; + MessageParcel out; + if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) { + return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL; + } + if (!in.WriteInt32(MAX_SIZE)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (!in.WriteInt32(slotId)) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + + if (eccVec.size() <= 0) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + + if (!in.WriteInt32(static_cast(eccVec.size()))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + + for (auto ecc : eccVec) { + if (!in.WriteRawData((const void *)&ecc, sizeof(EmergencyCall))) { + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + } + + int32_t error = Remote()->SendRequest(static_cast(OperationType::SET_EMERGENCY_CALL_LIST), + in, out, option); + if (error == ERR_NONE) { + return out.ReadInt32(); + } + return error; +} +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/services/telephony_interaction/src/core_service_connection.cpp b/services/telephony_interaction/src/core_service_connection.cpp old mode 100755 new mode 100644 index e4f3642ad3cf15e69d73dc63a309b33e26380387..9e6134c44507850dcc820dd3065ac339e0585f66 --- a/services/telephony_interaction/src/core_service_connection.cpp +++ b/services/telephony_interaction/src/core_service_connection.cpp @@ -33,7 +33,7 @@ std::vector CoreServiceConnection::GetFdnNumberList(int slotId) return numberVec; } for (std::vector>::iterator it = diallingNumbers.begin(); - it != diallingNumbers.end(); it++) { + it != diallingNumbers.end(); ++it) { numberVec.push_back((*it)->GetNumber()); } return numberVec; diff --git a/services/telephony_interaction/src/report_call_info_handler.cpp b/services/telephony_interaction/src/report_call_info_handler.cpp old mode 100755 new mode 100644 index f932a94ed97f96a9397deb331ca2a764f805c09f..4f98d89caa5e30006c09288f7c89067bf1f99138 --- a/services/telephony_interaction/src/report_call_info_handler.cpp +++ b/services/telephony_interaction/src/report_call_info_handler.cpp @@ -199,9 +199,7 @@ ReportCallInfoHandlerService::~ReportCallInfoHandlerService() eventLoop_->Stop(); eventLoop_ = nullptr; } - if (handler_ != nullptr) { - handler_ = nullptr; - } + handler_ = nullptr; } void ReportCallInfoHandlerService::Start() @@ -275,7 +273,7 @@ int32_t ReportCallInfoHandlerService::UpdateDisconnectedCause(const Disconnected if (!ret) { TELEPHONY_LOGE("SendEvent failed! DisconnectedDetails:%{public}d", cause); } - TELEPHONY_LOGE("UpdateDisconnectedCause success, cause:%{public}d", cause); + TELEPHONY_LOGI("UpdateDisconnectedCause success, cause:%{public}d", cause); return TELEPHONY_SUCCESS; } @@ -328,7 +326,10 @@ int32_t ReportCallInfoHandlerService::UpdateMediaModeResponse(const CallMediaMod TELEPHONY_LOGE("make_unique CellularCallEventInfo failed!"); return TELEPHONY_ERR_LOCAL_PTR_NULL; } - (void)memcpy_s(para->phoneNum, kMaxNumberLen, 0, kMaxNumberLen); + if (memcpy_s(para->phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) { + TELEPHONY_LOGE("memcpy_s para->phoneNum failed!"); + return TELEPHONY_ERR_MEMSET_FAIL; + } para->result = response.result; bool ret = handler_->SendEvent(HANDLE_UPDATE_MEDIA_MODE_RESPONSE, std::move(para)); if (!ret) { diff --git a/services/video/include/video_control_manager.h b/services/video/include/video_control_manager.h old mode 100755 new mode 100644 diff --git a/services/video/src/video_control_manager.cpp b/services/video/src/video_control_manager.cpp old mode 100755 new mode 100644 diff --git a/test/mock/BUILD.gn b/test/mock/BUILD.gn old mode 100755 new mode 100644 diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn old mode 100755 new mode 100644 diff --git a/test/unittest/call_manager_gtest/BUILD.gn b/test/unittest/call_manager_gtest/BUILD.gn old mode 100755 new mode 100644 index 6c38e2ddffa433aa5e02e99194a275e320900b37..9a32ccbd5c938d56368764795c6a4ff778e97067 --- a/test/unittest/call_manager_gtest/BUILD.gn +++ b/test/unittest/call_manager_gtest/BUILD.gn @@ -40,10 +40,10 @@ ohos_unittest("tel_call_manager_gtest") { ] external_deps = [ - "ability_runtime:want", - "appexecfwk_standard:libeventhandler", - "ces_standard:cesfwk_innerkits", + "ability_base:want", + "common_event_service:cesfwk_innerkits", "core_service:tel_core_service_api", + "eventhandler:libeventhandler", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", @@ -53,6 +53,9 @@ ohos_unittest("tel_call_manager_gtest") { "TELEPHONY_LOG_TAG = \"CallManagerGtest\"", "LOG_DOMAIN = 0xD002B01", ] + if ("${product_name}" == "rk3568" || "${product_name}" == "DAYU") { + defines += [ "TEL_TEST_UNSUPPORT" ] + } if (is_standard_system) { external_deps += [ "hiviewdfx_hilog_native:libhilog" ] diff --git a/test/unittest/call_manager_gtest/include/call_manager_connect.h b/test/unittest/call_manager_gtest/include/call_manager_connect.h old mode 100755 new mode 100644 index b48d89ee9803777c8a1196419c3c2d8c586fdbe0..03a5b33ac31a00b9144afb4f346fa2bce83d4533 --- a/test/unittest/call_manager_gtest/include/call_manager_connect.h +++ b/test/unittest/call_manager_gtest/include/call_manager_connect.h @@ -121,6 +121,12 @@ public: return TELEPHONY_SUCCESS; } + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) + { + TELEPHONY_LOGI("OnReportMmiCodeResult success!"); + return TELEPHONY_SUCCESS; + } + int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) { TELEPHONY_LOGI("OnOttCallRequest success!"); @@ -194,6 +200,8 @@ private: resultInfo.PutIntValue("classx", data.ReadInt32()); resultInfo.PutStringValue("number", data.ReadString()); resultInfo.PutIntValue("type", data.ReadInt32()); + resultInfo.PutIntValue("reason", data.ReadInt32()); + resultInfo.PutIntValue("time", data.ReadInt32()); break; case CallResultReportId::GET_CALL_CLIP_ID: resultInfo.PutIntValue("action", data.ReadInt32()); @@ -204,6 +212,7 @@ private: resultInfo.PutIntValue("clirStat", data.ReadInt32()); break; case CallResultReportId::GET_CALL_VOTLE_REPORT_ID: + case CallResultReportId::START_RTT_REPORT_ID: resultInfo.PutIntValue("active", data.ReadInt32()); break; case CallResultReportId::GET_IMS_CONFIG_REPORT_ID: @@ -211,9 +220,6 @@ private: case CallResultReportId::GET_LTE_ENHANCE_MODE_REPORT_ID: resultInfo.PutIntValue("value", data.ReadInt32()); break; - case CallResultReportId::START_RTT_REPORT_ID: - resultInfo.PutIntValue("active", data.ReadInt32()); - break; case CallResultReportId::STOP_RTT_REPORT_ID: resultInfo.PutIntValue("inactive", data.ReadInt32()); break; diff --git a/test/unittest/call_manager_gtest/include/call_manager_gtest.h b/test/unittest/call_manager_gtest/include/call_manager_gtest.h old mode 100755 new mode 100644 diff --git a/test/unittest/call_manager_gtest/src/call_manager_gtest.cpp b/test/unittest/call_manager_gtest/src/call_manager_gtest.cpp old mode 100755 new mode 100644 index 347622fb4e87ca34669adb726cb7e55f730c2701..a1004bc3576f6fe37f24d12cf9d4cf87d0dfb8c1 --- a/test/unittest/call_manager_gtest/src/call_manager_gtest.cpp +++ b/test/unittest/call_manager_gtest/src/call_manager_gtest.cpp @@ -22,6 +22,7 @@ namespace OHOS { namespace Telephony { using namespace testing::ext; +#ifndef TEL_TEST_UNSUPPORT constexpr int16_t SIM1_SLOTID = 0; constexpr int16_t SIM1_SLOTID_NO_CARD = 0; constexpr int16_t RETURN_VALUE_IS_ZERO = 0; @@ -30,6 +31,7 @@ constexpr int16_t INVALID_POSITIVE_ID = 100; constexpr int16_t CALL_MANAGER_ERROR = -1; constexpr int16_t CAMERA_ROTATION_90 = 90; constexpr int16_t CAMERA_ROTATION_ERROR = 50; +#endif // TEL_TEST_UNSUPPORT constexpr int16_t SLEEP_1000_MS = 1000; const std::string PHONE_NUMBER = "xxxxx"; @@ -102,6 +104,7 @@ void CallInfoManager::LockCallState(bool eq, int32_t targetState, int32_t slipMs EXPECT_EQ(callState, targetState); } +#ifndef TEL_TEST_UNSUPPORT /********************************************* Test DialCall()***********************************************/ /** * @tc.number Telephony_CallManager_DialCall_0100 @@ -358,7 +361,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_HoldCall_0200, Function | Mediu /** * @tc.number Telephony_CallManager_HoldCall_0600 to do ... - * @tc.name coming a active call test hold call, return 0 + * @tc.name coming an active call test hold call, return 0 * wait for the correct status of the callback to execute correctly * @tc.desc Function test */ @@ -1177,7 +1180,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_FormatPhoneNumberToE164_0700, F /********************************************* Test SetCallWaiting() ***********************************************/ /** * @tc.number Telephony_CallManager_SetCallWaiting_0100 - * @tc.name test SetCallWaiting + * @tc.name input slotId 0, test SetCallWaiting() enable callWaiting * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallWaiting_0100, Function | MediumTest | Level3) @@ -1192,7 +1195,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallWaiting_0100, Function | /********************************************* Test SetCallWaiting() ***********************************************/ /** * @tc.number Telephony_CallManager_SetCallWaiting_0200 - * @tc.name test SetCallWaiting + * @tc.name input slotId 0, test SetCallWaiting() disable callWaiting * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallWaiting_0200, Function | MediumTest | Level3) @@ -1207,7 +1210,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallWaiting_0200, Function | /******************************************* Test GetCallRestriction() ********************************************/ /** * @tc.number Telephony_CallManager_GetCallRestriction_0100 - * @tc.name test GetCallRestriction + * @tc.name input slotId 0, CallRestrictionType RESTRICTION_TYPE_ALL_INCOMING, test GetCallRestriction() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallRestriction_0100, Function | MediumTest | Level3) @@ -1224,7 +1227,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallRestriction_0100, Functi /******************************************* Test GetCallRestriction() ********************************************/ /** * @tc.number Telephony_CallManager_GetCallRestriction_0200 - * @tc.name test GetCallRestriction + * @tc.name input slotId 0, CallRestrictionType RESTRICTION_TYPE_ALL_OUTGOING, test GetCallRestriction() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallRestriction_0200, Function | MediumTest | Level3) @@ -1241,7 +1244,9 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallRestriction_0200, Functi /******************************************* Test SetCallRestriction() ********************************************/ /** * @tc.number Telephony_CallManager_SetCallRestriction_0100 - * @tc.name test SetCallRestriction + * @tc.name input slotId 0, CallRestrictionType RESTRICTION_TYPE_ALL_OUTGOING, + * CallRestrictionMode::RESTRICTION_MODE_ACTIVATION, + * test SetCallRestriction() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallRestriction_0100, Function | MediumTest | Level3) @@ -1252,7 +1257,10 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallRestriction_0100, Functi CallRestrictionInfo info; info.fac = CallRestrictionType::RESTRICTION_TYPE_ALL_OUTGOING; info.mode = CallRestrictionMode::RESTRICTION_MODE_ACTIVATION; - strcpy(info.password, "123"); + if (strcpy_s(info.password, kMaxNumberLen + 1, "123") != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + return; + } EXPECT_EQ(CallManagerGtest::clientPtr_->SetCallRestriction(SIM1_SLOTID, info), RETURN_VALUE_IS_ZERO); } @@ -1260,7 +1268,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallRestriction_0100, Functi /******************************************* Test GetCallTransferInfo() ********************************************/ /** * @tc.number Telephony_CallManager_GetCallRestriction_0100 - * @tc.name test GetCallTransferInfo + * @tc.name input slotId 0, CallTransferType TRANSFER_TYPE_BUSY, test GetCallTransferInfo() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0100, Function | MediumTest | Level3) @@ -1276,7 +1284,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0100, Funct /******************************************* Test GetCallTransferInfo() ********************************************/ /** * @tc.number Telephony_CallManager_GetCallRestriction_0200 - * @tc.name test GetCallTransferInfo + * @tc.name input slotId 0, CallTransferType TRANSFER_TYPE_NO_REPLY, test GetCallTransferInfo() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0200, Function | MediumTest | Level3) @@ -1293,7 +1301,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0200, Funct /******************************************* Test GetCallTransferInfo() ********************************************/ /** * @tc.number Telephony_CallManager_GetCallRestriction_0300 - * @tc.name test GetCallTransferInfo + * @tc.name input slotId 0, CallTransferType TRANSFER_TYPE_NOT_REACHABLE, test GetCallTransferInfo() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0300, Function | MediumTest | Level3) @@ -1310,7 +1318,8 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetCallTransferInfo_0300, Funct /******************************************* Test SetCallTransferInfo() ********************************************/ /** * @tc.number Telephony_CallManager_SetCallTransferInfo_0100 - * @tc.name test SetCallTransferInfo + * @tc.name input slotId 0, CallTransferSettingType CALL_TRANSFER_ENABLE, CallTransferType TRANSFER_TYPE_BUSY, + * test SetCallTransferInfo() * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallTransferInfo_0100, Function | MediumTest | Level3) @@ -1321,7 +1330,10 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallTransferInfo_0100, Funct CallTransferInfo info; info.settingType = CallTransferSettingType::CALL_TRANSFER_ENABLE; info.type = CallTransferType::TRANSFER_TYPE_BUSY; - strcpy(info.transferNum, "123"); + if (strcpy_s(info.transferNum, kMaxNumberLen + 1, "123") != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + return; + } EXPECT_EQ(CallManagerGtest::clientPtr_->SetCallTransferInfo(SIM1_SLOTID, info), RETURN_VALUE_IS_ZERO); } @@ -1329,7 +1341,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCallTransferInfo_0100, Funct /******************************************* Test EnableImsSwitch() ********************************************/ /** * @tc.number Telephony_CallManager_EnableVoLte_0100 - * @tc.name test EnableImsSwitch + * @tc.name input slotId 0, test EnableImsSwitch * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_EnableVoLte_0100, Function | MediumTest | Level3) @@ -1344,7 +1356,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_EnableVoLte_0100, Function | Me /******************************************* Test DisableImsSwitch() ********************************************/ /** * @tc.number Telephony_CallManager_DisableVoLte_0100 - * @tc.name test DisableImsSwitch + * @tc.name input slotId 0, test DisableImsSwitch * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_DisableVoLte_0100, Function | MediumTest | Level3) @@ -1359,7 +1371,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_DisableVoLte_0100, Function | M /******************************************* Test IsImsSwitchEnabled() ********************************************/ /** * @tc.number Telephony_CallManager_IsVoLteEnabled_0100 - * @tc.name test IsImsSwitchEnabled + * @tc.name input slotId 0, test IsImsSwitchEnabled * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_IsVoLteEnabled_0100, Function | MediumTest | Level3) @@ -1374,7 +1386,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_IsVoLteEnabled_0100, Function | /******************************************* Test SetLteEnhanceMode() ********************************************/ /** * @tc.number Telephony_CallManager_SetLteEnhanceMode_0100 - * @tc.name test SetLteEnhanceMode + * @tc.name input slotId 0, test SetLteEnhanceMode * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetLteEnhanceMode_0100, Function | MediumTest | Level3) @@ -1389,7 +1401,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetLteEnhanceMode_0100, Functio /******************************************* Test SetLteEnhanceMode() ********************************************/ /** * @tc.number Telephony_CallManager_SetLteEnhanceMode_0200 - * @tc.name test SetLteEnhanceMode + * @tc.name input slotId 0, test SetLteEnhanceMode, disable LteEnhanceMode * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetLteEnhanceMode_0200, Function | MediumTest | Level3) @@ -1404,7 +1416,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetLteEnhanceMode_0200, Functio /******************************************* Test GetLteEnhanceMode() ********************************************/ /** * @tc.number Telephony_CallManager_GetLteEnhanceMode_0100 - * @tc.name test GetLteEnhanceMode + * @tc.name input slotId 0, test GetLteEnhanceMode * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetLteEnhanceMode_0100, Function | MediumTest | Level3) @@ -1419,7 +1431,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_GetLteEnhanceMode_0100, Functio /******************************************* Test ControlCamera() *********************************************/ /** * @tc.number Telephony_CallManager_ControlCamera_0100 - * @tc.name Test returns 0 after ControlCamera + * @tc.name input camera id lcam001, Test ControlCamera, returns 0 if success * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0100, Function | MediumTest | Level0) @@ -1436,7 +1448,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0100, Function | /** * @tc.number Telephony_CallManager_ControlCamera_0200 - * @tc.name Test returns error after ControlCamera + * @tc.name input error camera id xtsautotest123456, Test ControlCamera, return err code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0200, Function | MediumTest | Level2) @@ -1452,7 +1464,8 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0200, Function | /** * @tc.number Telephony_CallManager_ControlCamera_0300 - * @tc.name Test returns error after ControlCamera + * @tc.name input error camera id xtsautotest123456, Test ControlCamera, + * then input empty camera id, Test ControlCamera * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0300, Function | MediumTest | Level2) @@ -1472,7 +1485,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0300, Function | /** * @tc.number Telephony_CallManager_ControlCamera_0600 - * @tc.name Test returns error after ControlCamera + * @tc.name input empty camera id, Test ControlCamera, returns error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0600, Function | MediumTest | Level2) @@ -1489,7 +1502,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_ControlCamera_0600, Function | /******************************************* Test SetPreviewWindow() *********************************************/ /** * @tc.number Telephony_CallManager_SetPreviewWindow_0100 - * @tc.name Test returns error after set preview window + * @tc.name input x:0, y:0, z:-1, width:200, height:200, Test set preview window * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPreviewWindow_0100, Function | MediumTest | Level2) @@ -1508,7 +1521,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPreviewWindow_0100, Function /** * @tc.number Telephony_CallManager_SetPreviewWindow_0200 - * @tc.name Test returns 0 after set preview window + * @tc.name input x:0, y:0, z:0, width:200, height:200, Test set preview window * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPreviewWindow_0200, Function | MediumTest | Level2) @@ -1528,7 +1541,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPreviewWindow_0200, Function /******************************************* Test SetDisplayWindow() *********************************************/ /** * @tc.number Telephony_CallManager_SetDisplayWindow_0100 - * @tc.name Test returns error after set display window + * @tc.name input x:10, y:10, z:10, width:100, height:200, Test set display window * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDisplayWindow_0100, Function | MediumTest | Level2) @@ -1547,7 +1560,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDisplayWindow_0100, Function /** * @tc.number Telephony_CallManager_SetDisplayWindow_0200 - * @tc.name Test returns 0 after set display window + * @tc.name input x:10, y:10, z:0, width:200, height:200, Test set display window * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDisplayWindow_0200, Function | MediumTest | Level2) @@ -1567,7 +1580,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDisplayWindow_0200, Function /******************************************* Test SetDeviceDirection() *********************************************/ /** * @tc.number Telephony_CallManager_SetDeviceDirection_0100 - * @tc.name Test returns error after set device direction + * @tc.name input invalid rotation, Test SetDeviceDirection, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0100, Function | MediumTest | Level2) @@ -1581,7 +1594,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0100, Functi /** * @tc.number Telephony_CallManager_SetDeviceDirection_0200 - * @tc.name Test returns error after set device direction + * @tc.name input rotation 0, Test SetDeviceDirection, return 0 if success * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0200, Function | MediumTest | Level2) @@ -1595,7 +1608,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0200, Functi /** * @tc.number Telephony_CallManager_SetDeviceDirection_0300 - * @tc.name Test returns 0 after set device direction + * @tc.name input rotation 90, Test SetDeviceDirection * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0300, Function | MediumTest | Level1) @@ -1610,7 +1623,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetDeviceDirection_0300, Functi /******************************************* Test SetCameraZoom() *********************************************/ /** * @tc.number Telephony_CallManager_SetDeviceDirection_0100 - * @tc.name Test returns error after set camera zoom + * @tc.name input zoomRatio 5.0, Test SetCameraZoom * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0100, Function | MediumTest | Level2) @@ -1624,7 +1637,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0100, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0200 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input zoomRatio 0.1, Test SetCameraZoom * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0200, Function | MediumTest | Level1) @@ -1638,7 +1651,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0200, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0300 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input zoomRatio 10.0, Test SetCameraZoom * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0300, Function | MediumTest | Level1) @@ -1652,7 +1665,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0300, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0400 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input invalid para zoomRatio 15.0, Test SetCameraZoom, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0400, Function | MediumTest | Level1) @@ -1666,7 +1679,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0400, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0500 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input invalid para zoomRatio 0.0, Test SetCameraZoom, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0500, Function | MediumTest | Level1) @@ -1680,7 +1693,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0500, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0600 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input invalid para zoomRatio -1.0, Test SetCameraZoom, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0600, Function | MediumTest | Level1) @@ -1694,7 +1707,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0600, Function | /** * @tc.number Telephony_CallManager_SetDeviceDirection_0700 - * @tc.name Test returns 0 after set camera zoom + * @tc.name input invalid para zoomRatio 10.1, Test SetCameraZoom, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0700, Function | MediumTest | Level1) @@ -1708,7 +1721,8 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetCameraZoom_0700, Function | /******************************************* Test SetPausePicture() *********************************************/ /** * @tc.number Telephony_CallManager_SetPausePicture_0100 - * @tc.name Test returns 0 after set pause picture + * @tc.name input locale picture path /system/bin/test.png that does not exist, Test SetPausePicture, + * return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0100, Function | MediumTest | Level1) @@ -1723,7 +1737,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0100, Function /** * @tc.number Telephony_CallManager_SetPausePicture_0200 - * @tc.name Test returns 0 after set pause picture + * @tc.name input an invalid image format file path, Test SetPausePicture, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0200, Function | MediumTest | Level1) @@ -1738,7 +1752,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0200, Function /** * @tc.number Telephony_CallManager_SetPausePicture_0300 - * @tc.name Test returns 0 after set pause picture + * @tc.name input an invalid image format file path, Test SetPausePicture, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0300, Function | MediumTest | Level1) @@ -1753,7 +1767,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0300, Function /** * @tc.number Telephony_CallManager_SetPausePicture_0400 - * @tc.name Test returns 0 after set pause picture + * @tc.name input an invalid image format file path, Test SetPausePicture, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0400, Function | MediumTest | Level1) @@ -1768,7 +1782,8 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0400, Function /** * @tc.number Telephony_CallManager_SetPausePicture_0500 - * @tc.name Test returns 0 after set pause picture + * @tc.name input remote picture path http://callManager.jpg that does not exist, Test SetPausePicture, + * return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0500, Function | MediumTest | Level1) @@ -1783,7 +1798,7 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0500, Function /** * @tc.number Telephony_CallManager_SetPausePicture_0600 - * @tc.name Test returns 0 after set pause picture + * @tc.name input empty picture path , Test SetPausePicture, return error code if failed * @tc.desc Function test */ HWTEST_F(CallManagerGtest, Telephony_CallManager_SetPausePicture_0600, Function | MediumTest | Level1) @@ -1810,5 +1825,19 @@ HWTEST_F(CallManagerGtest, Telephony_CallManager_RegisterCallBack_0100, Function EXPECT_EQ(CallManagerGtest::clientPtr_->RegisterCallBack(), RETURN_VALUE_IS_ZERO); } + +#else // TEL_TEST_UNSUPPORT +/***************************************** Test For Unsupport Platform ***********************************************/ +/** + * @tc.number Telephony_CallManager_Mock_0100 + * @tc.name test for unsupported platform + * @tc.desc Function test + */ +HWTEST_F(CallManagerGtest, Telephony_CallManager_Mock_0100, Function | MediumTest | Level3) +{ + EXPECT_TRUE(true); +} + +#endif // TEL_TEST_UNSUPPORT } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/test/unittest/ui_client/BUILD.gn b/test/unittest/ui_client/BUILD.gn old mode 100755 new mode 100644 index d130ffbcb064dec7173388d03fe8c37c2c1dc0b9..786f54273d4bed41a3446315ab048faf5c395556 --- a/test/unittest/ui_client/BUILD.gn +++ b/test/unittest/ui_client/BUILD.gn @@ -11,11 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/telephony/call_manager/call_manager_aafwk.gni") import("//build/ohos.gni") ohos_executable("tel_call_manager_ui_test") { install_enable = true sources = [ + "bluetooth_call_test.cpp", "call_manager_callback_test.cpp", "common_event_subscriber_test.cpp", "ui_client_test.cpp", @@ -23,13 +25,13 @@ ohos_executable("tel_call_manager_ui_test") { include_dirs = [ "//base/telephony/call_manager/services/audio/include", - "//foundation/multimedia/camera_standard/interfaces/innerkits/native/camera/include", + "//foundation/multimedia/camera_standard/interfaces/inner_api/native/camera/include", "//foundation/multimedia/camera_standard/services/camera_service/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/base/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/client/include", "//foundation/multimedia/camera_standard/services/camera_service/binder/server/include", - "//foundation/graphic/standard/frameworks/surface/include", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata/include", + "//foundation/graphic/graphic/frameworks/surface/include", + "//drivers/peripheral/camera/interfaces/metadata/include", "//utils/system/safwk/native/include", "//drivers/framework/include/utils", "//drivers/adapter/uhdf2/utils/include", @@ -41,27 +43,24 @@ ohos_executable("tel_call_manager_ui_test") { "//drivers/peripheral/camera/interfaces/include/callback/operator", "//drivers/peripheral/camera/interfaces/include/callback/host", "/utils/native/base/include", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include/permission/", ] configs = [ "//base/telephony/core_service/utils:telephony_log_config" ] deps = [ - "//base/security/permission/frameworks/permission_standard/permissioninfrastructure:permission_standard_infrastructure_cxx", - "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk:libpermissionsdk_standard", - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/graphic/standard:libsurface", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/camera:camera_framework", - "//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata:metadata", + "${aafwk_kits_path}/ability/native:abilitykit_native", + "//drivers/peripheral/camera/interfaces/metadata:metadata", + "//foundation/graphic/graphic:libsurface", + "//foundation/multimedia/camera_standard/frameworks/native/camera:camera_framework", "//utils/native/base:utils", ] external_deps = [ - "ability_runtime:want", - "appexecfwk_standard:libeventhandler", + "ability_base:want", "call_manager:tel_call_manager_api", - "ces_standard:cesfwk_innerkits", + "common_event_service:cesfwk_innerkits", "core_service:tel_core_service_api", + "eventhandler:libeventhandler", "ipc:ipc_core", "multimedia_audio_standard:audio_client", "multimedia_audio_standard:audio_renderer", diff --git a/test/unittest/ui_client/bluetooth_call_test.cpp b/test/unittest/ui_client/bluetooth_call_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3bbdf0720b7b9fbfc2fc8cf9e3219e99dd133039 --- /dev/null +++ b/test/unittest/ui_client/bluetooth_call_test.cpp @@ -0,0 +1,402 @@ +/* + * Copyright (C) 2021 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 "bluetooth_call_test.h" + +#include + +#include "call_manager_errors.h" + +#include "bluetooth_call_client.h" +#include "call_manager_test_types.h" +#include "call_manager_callback_test.h" + +namespace OHOS { +namespace Telephony { +std::shared_ptr g_bluetoothCallPtr = nullptr; + +int32_t BluetoothCallTest::Init() +{ + g_bluetoothCallPtr = DelayedSingleton::GetInstance(); + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return TELEPHONY_ERROR; + } + g_bluetoothCallPtr->Init(); + std::unique_ptr callbackPtr = std::make_unique(); + if (callbackPtr == nullptr) { + std::cout << "make_unique CallManagerCallbackTest failed!" << std::endl; + return TELEPHONY_ERROR; + } + int32_t ret = g_bluetoothCallPtr->RegisterCallBack(std::move(callbackPtr)); + if (ret != TELEPHONY_SUCCESS) { + std::cout << "RegisterCallBack failed!" << std::endl; + return TELEPHONY_ERROR; + } + std::cout << "RegisterCallBack success!" << std::endl; + InitFunMap(); + return TELEPHONY_SUCCESS; +} + +void BluetoothCallTest::RunBluetoothCallTest() +{ + int32_t interfaceNum = OHOS::Telephony::DEFAULT_VALUE; + const int32_t exitNumber = 1000; + while (true) { + PrintfUsage(); + std::cin >> interfaceNum; + if (interfaceNum == exitNumber) { + std::cout << "start to exit now...." << std::endl; + break; + } + auto itFunc = memberFuncMap_.find(interfaceNum); + if (itFunc != memberFuncMap_.end() && itFunc->second != nullptr) { + auto BluetoothCallFunc = itFunc->second; + (this->*BluetoothCallFunc)(); + continue; + } + std::cout << "err: invalid input!" << std::endl; + } + memberFuncMap_.clear(); +} + +void BluetoothCallTest::PrintfUsage() +{ + std::cout << "\n\n-----------bluetooth call test start--------------\n" + << "usage:please input a cmd num:\n" + << "0:dial\n" + << "1:answer\n" + << "2:reject\n" + << "3:hangup\n" + << "4:getCallState\n" + << "5:hold\n" + << "6:unhold\n" + << "7:switchCall\n" + << "8:combineConference\n" + << "9:separateConference\n" + << "10:startDtmf\n" + << "11:stopRtt\n" + << "12:isRinging\n" + << "13:hasCall\n" + << "14:isNewCallAllowed\n" + << "15:isInEmergencyCall\n" + << "16:setMuted\n" + << "17:muteRinger\n" + << "18:setAudioDevice\n" + << "19:GetCurrentCallList\n" + << "1000:exit\n"; +} + +void BluetoothCallTest::InitFunMap() +{ + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_DIAL)] = &BluetoothCallTest::DialCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_ANSWER)] = &BluetoothCallTest::AnswerCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_REJECT)] = &BluetoothCallTest::RejectCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_HANGUP)] = &BluetoothCallTest::HangUpCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_GET_CALL_STATE)] = + &BluetoothCallTest::GetCallState; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_HOLD)] = &BluetoothCallTest::HoldCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_UNHOLD)] = &BluetoothCallTest::UnHoldCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_SWITCH)] = &BluetoothCallTest::SwitchCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_COMBINE_CONFERENCE)] = + &BluetoothCallTest::CombineConference; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_SEPARATE_CONFERENCE)] = + &BluetoothCallTest::SeparateConference; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_START_DTMF)] = &BluetoothCallTest::StartDtmf; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_STOP_DTMF)] = &BluetoothCallTest::StopDtmf; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_IS_RINGING)] = &BluetoothCallTest::IsRinging; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_HAS_CALL)] = &BluetoothCallTest::HasCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_IS_NEW_CALL_ALLOWED)] = + &BluetoothCallTest::IsNewCallAllowed; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_IS_IN_EMERGENCY_CALL)] = + &BluetoothCallTest::IsInEmergencyCall; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_SET_MUTED)] = &BluetoothCallTest::SetMute; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_MUTE_RINGER)] = &BluetoothCallTest::MuteRinger; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_SET_AUDIO_DEVICE)] = + &BluetoothCallTest::SetAudioDevice; + memberFuncMap_[static_cast(BluetoothCallFuncCode::TEST_GET_CURRENT_CALL_LIST)] = + &BluetoothCallTest::GetCurrentCallList; +} + +void BluetoothCallTest::DialCall() +{ + int32_t accountId = DEFAULT_ACCOUNT_ID; + int32_t videoState = DEFAULT_VIDEO_STATE; + int32_t dialScene = DEFAULT_DIAL_SCENE; + int32_t dialType = DEFAULT_DIAL_TYPE; + int32_t callType = DEFAULT_CALL_TYPE; + std::u16string phoneNumber; + std::string tmpStr; + AppExecFwk::PacMap dialInfo; + std::cout << "------Dial------" << std::endl; + std::cout << "please input phone number:" << std::endl; + phoneNumber.clear(); + tmpStr.clear(); + std::cin >> tmpStr; + phoneNumber = Str8ToStr16(tmpStr); + std::cout << "you want to call " << tmpStr << std::endl; + std::cout << "please input accountId:" << std::endl; + std::cin >> accountId; + std::cout << "please input videoState[0:audio,1:video]:" << std::endl; + std::cin >> videoState; + std::cout << "please input dialScene[0:normal,1:privileged,2:emergency]:" << std::endl; + std::cin >> dialScene; + std::cout << "please input dialType[0:carrier,1:voice mail,2:ott]:" << std::endl; + std::cin >> dialType; + std::cout << "please input callType[0:cs,1:ims,2:ott]:" << std::endl; + std::cin >> callType; + + dialInfo.PutIntValue("accountId", accountId); + dialInfo.PutIntValue("videoState", videoState); + dialInfo.PutIntValue("dialScene", dialScene); + dialInfo.PutIntValue("dialType", dialType); + dialInfo.PutIntValue("callType", callType); + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->DialCall(phoneNumber, dialInfo); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::AnswerCall() +{ + std::cout << "------Answer------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->AnswerCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::RejectCall() +{ + std::cout << "------Reject------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->RejectCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::HangUpCall() +{ + std::cout << "------HangUpCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->HangUpCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::GetCallState() +{ + std::cout << "------GetCallState------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->GetCallState(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::HoldCall() +{ + std::cout << "------HoldCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->HoldCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::UnHoldCall() +{ + std::cout << "------UnHoldCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->UnHoldCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::CombineConference() +{ + std::cout << "------CombineConference------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->CombineConference(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::SeparateConference() +{ + std::cout << "------SeparateConference------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->SeparateConference(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::SwitchCall() +{ + std::cout << "------SwitchCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->SwitchCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::HasCall() +{ + std::cout << "------HasCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->HasCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::IsNewCallAllowed() +{ + std::cout << "------IsNewCallAllowed------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->IsNewCallAllowed(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::IsRinging() +{ + std::cout << "------IsRinging------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->IsRinging(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::IsInEmergencyCall() +{ + std::cout << "------IsInEmergencyCall------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->IsInEmergencyCall(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::StartDtmf() +{ + char c = DEFAULT_VALUE; + std::cout << "------StartDtmf------" << std::endl; + std::cout << "Please enter to send dtmf characters:" << std::endl; + std::cin >> c; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->StartDtmf(c); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::StopDtmf() +{ + std::cout << "------StopDtmf------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->StopDtmf(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::SetMute() +{ + int32_t isMute = DEFAULT_VALUE; + std::cout << "------SetMute------" << std::endl; + std::cout << "please input mute state(0:false 1:true):" << std::endl; + std::cin >> isMute; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->SetMuted((isMute == 1) ? true : false); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::MuteRinger() +{ + std::cout << "------MuteRinger------" << std::endl; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + int32_t ret = g_bluetoothCallPtr->MuteRinger(); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::SetAudioDevice() +{ + int32_t deviceType = DEFAULT_VALUE; + std::cout << "------SetAudioDevice------" << std::endl; + std::cout << "please input device type(0:earpiece 1:speaker 2:wired headset 3:bluetooth sco):" << std::endl; + std::cin >> deviceType; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + AudioDevice device = AudioDevice::DEVICE_UNKNOWN; + device = static_cast(deviceType); + int32_t ret = g_bluetoothCallPtr->SetAudioDevice(device); + std::cout << "return value:" << ret << std::endl; +} + +void BluetoothCallTest::GetCurrentCallList() +{ + int32_t slotId = DEFAULT_VALUE; + std::cout << "------GetCurrentCallList------" << std::endl; + std::cout << "Please enter slotId:" << std::endl; + std::cin >> slotId; + if (g_bluetoothCallPtr == nullptr) { + std::cout << "g_bluetoothCallPtr is nullptr" << std::endl; + return; + } + std::vector callVec = g_bluetoothCallPtr->GetCurrentCallList(slotId); + std::cout << "call list count:" << callVec.size() << std::endl; + std::vector::iterator it = callVec.begin(); + for (; it != callVec.end(); ++it) { + std::cout << "number:" << (*it).accountNumber << ", callState:" + << static_cast((*it).callState) << std::endl; + } +} +} // namespace Telephony +} // namespace OHOS diff --git a/test/unittest/ui_client/bluetooth_call_test.h b/test/unittest/ui_client/bluetooth_call_test.h new file mode 100644 index 0000000000000000000000000000000000000000..951aae657f514c13a3d98a7b40cb439a4e9166e1 --- /dev/null +++ b/test/unittest/ui_client/bluetooth_call_test.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2021 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 BLUETOOTH_CALL_TEST_H +#define BLUETOOTH_CALL_TEST_H + +#include + +namespace OHOS { +namespace Telephony { +enum class BluetoothCallFuncCode { + TEST_DIAL = 0, + TEST_ANSWER, + TEST_REJECT, + TEST_HANGUP, + TEST_GET_CALL_STATE, + TEST_HOLD, + TEST_UNHOLD, + TEST_SWITCH, + TEST_COMBINE_CONFERENCE, + TEST_SEPARATE_CONFERENCE, + TEST_START_DTMF, + TEST_STOP_DTMF, + TEST_IS_RINGING, + TEST_HAS_CALL, + TEST_IS_NEW_CALL_ALLOWED, + TEST_IS_IN_EMERGENCY_CALL, + TEST_SET_MUTED, + TEST_MUTE_RINGER, + TEST_SET_AUDIO_DEVICE, + TEST_GET_CURRENT_CALL_LIST, +}; + +class BluetoothCallTest { +public: + BluetoothCallTest() = default; + ~BluetoothCallTest() = default; + int32_t Init(); + void RunBluetoothCallTest(); + +private: + void PrintfUsage(); + void InitFunMap(); + using BluetoothCallFunc = void (BluetoothCallTest::*)(); + + void DialCall(); + void AnswerCall(); + void RejectCall(); + void HangUpCall(); + void GetCallState(); + void HoldCall(); + void UnHoldCall(); + void SwitchCall(); + void CombineConference(); + void SeparateConference(); + void StartDtmf(); + void StopDtmf(); + void IsRinging(); + void HasCall(); + void IsNewCallAllowed(); + void IsInEmergencyCall(); + void SetMute(); + void MuteRinger(); + void SetAudioDevice(); + void GetCurrentCallList(); + + std::map memberFuncMap_; +}; +} // namespace Telephony +} // namespace OHOS +#endif // CALL_MANAGER_CALLBACK_TEST_H diff --git a/test/unittest/ui_client/call_manager_callback_test.cpp b/test/unittest/ui_client/call_manager_callback_test.cpp old mode 100755 new mode 100644 index ad15f6d96e828f1377f20a597a256c2557b0d868..b55b49ca30d376506f47e8d6f3e29dcb80920bda --- a/test/unittest/ui_client/call_manager_callback_test.cpp +++ b/test/unittest/ui_client/call_manager_callback_test.cpp @@ -57,5 +57,13 @@ int32_t CallManagerCallbackTest::OnOttCallRequest(OttCallRequestId requestId, Ap << "requestId:" << (int32_t)requestId << std::endl; return RETURN_SUCCESS; } + +int32_t CallManagerCallbackTest::OnReportMmiCodeResult(const MmiCodeInfo &info) +{ + std::cout << "----------OnReportMmiCodeResult--------" << std::endl + << "result:" << info.result << std::endl + << "message:" << info.message << std::endl; + return RETURN_SUCCESS; +} } // namespace Telephony } // namespace OHOS diff --git a/test/unittest/ui_client/call_manager_callback_test.h b/test/unittest/ui_client/call_manager_callback_test.h old mode 100755 new mode 100644 index b02164268ec7280f152d58afe00532b437e6acd2..c9174d5cdfdccf5e08a085405b136807f8a03455 --- a/test/unittest/ui_client/call_manager_callback_test.h +++ b/test/unittest/ui_client/call_manager_callback_test.h @@ -33,6 +33,7 @@ public: int32_t OnCallDisconnectedCause(DisconnectedDetails cause) override; int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) override; int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) override; + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) override; }; } // namespace Telephony } // namespace OHOS diff --git a/test/unittest/ui_client/call_manager_test_types.h b/test/unittest/ui_client/call_manager_test_types.h new file mode 100644 index 0000000000000000000000000000000000000000..ded9035a3206505a48ba643d0087f65733e315c2 --- /dev/null +++ b/test/unittest/ui_client/call_manager_test_types.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 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 CALL_MANAGER_TEST_TYPES_H +#define CALL_MANAGER_TEST_TYPES_H + +namespace OHOS { +namespace Telephony { +constexpr int16_t MIN_VOLUME = 0; +constexpr int16_t MAX_VOLUME = 15; +constexpr int16_t READ_SIZE = 1; +constexpr int16_t MIN_BYTES = 4; +constexpr int16_t RING_PATH_MAX_LENGTH = 100; +constexpr int16_t SIM1_SLOTID = 0; +constexpr int16_t DEFAULT_ACCOUNT_ID = 0; +constexpr int16_t DEFAULT_VIDEO_STATE = 0; +constexpr int16_t DEFAULT_DIAL_SCENE = 0; +constexpr int16_t DEFAULT_DIAL_TYPE = 0; +constexpr int16_t DEFAULT_CALL_TYPE = 0; +constexpr int16_t DEFAULT_CALL_ID = 0; +constexpr int16_t DEFAULT_VALUE = 0; +constexpr size_t DEFAULT_SIZE = 0; +constexpr int16_t WINDOWS_X_START = 0; +constexpr int16_t WINDOWS_Y_START = 0; +constexpr int16_t WINDOWS_Z_ERROR = -1; +constexpr int16_t WINDOWS_Z_TOP = 1; +constexpr int16_t WINDOWS_Z_BOTTOM = 0; +constexpr int16_t WINDOWS_WIDTH = 200; +constexpr int16_t WINDOWS_HEIGHT = 200; +constexpr size_t DEFAULT_PREFERENCEMODE = 3; +constexpr int16_t EVENT_BLUETOOTH_SCO_CONNECTED_CODE = 0; +constexpr int16_t EVENT_BLUETOOTH_SCO_DISCONNECTED_CODE = 1; +constexpr size_t DEFAULT_NET_TYPE = 0; +constexpr size_t DEFAULT_ITEM_VALUE = 0; +const int32_t DEFINE_INIT_PERMISSIONS = 93; +const int32_t DEFINE_VERIFY_PERMISSIONS = 94; +const int32_t DEFINE_CONNECT_BT_SCO = 95; +const int32_t DEFINE_DISCONNECT_BT_SCO = 96; +const int32_t DEFINE_SUBSCRIBERCOMMON_EVENT = 97; +const std::string TEST_BUNDLE_NAME = "com.ohos.callManagerTest"; +const std::string CALL_UI_BUNDLE_NAME = "com.ohos.videocall"; +const std::string TEST_PERMISSION_NAME_CAMERA = "ohos.permission.camera"; +const std::string TEST_LABEL = "test label"; +const std::string TEST_DESCRIPTION = "test description"; + +const int32_t TEST_LABEL_ID = 9527; +const int32_t TEST_DESCRIPTION_ID = 9528; +const int32_t TEST_USER_ID = 0; +} // namespace Telephony +} // namespace OHOS +#endif \ No newline at end of file diff --git a/test/unittest/ui_client/common_event_subscriber_test.cpp b/test/unittest/ui_client/common_event_subscriber_test.cpp old mode 100755 new mode 100644 diff --git a/test/unittest/ui_client/common_event_subscriber_test.h b/test/unittest/ui_client/common_event_subscriber_test.h old mode 100755 new mode 100644 diff --git a/test/unittest/ui_client/ui_client_test.cpp b/test/unittest/ui_client/ui_client_test.cpp old mode 100755 new mode 100644 index f36b691c06848969a8cbf4e0725c2d3fa38f734d..3e9d8836cb4ec091614d42e3cf6bd9f6181176fb --- a/test/unittest/ui_client/ui_client_test.cpp +++ b/test/unittest/ui_client/ui_client_test.cpp @@ -13,70 +13,34 @@ * limitations under the License. */ +#include #include #include #include "audio_system_manager.h" #include "system_ability_definition.h" #include "input/camera_manager.h" -#include "permission_kit.h" #include "i_call_manager_service.h" #include "call_manager_client.h" #include "audio_player.h" +#include "bluetooth_call_test.h" #include "call_manager_inner_type.h" #include "call_manager_errors.h" #include "call_manager_callback_test.h" +#include "call_manager_test_types.h" #include "common_event_subscriber_test.h" namespace OHOS { namespace Telephony { +enum class CallManagerInterfaceType { + INTERFACE_CALL_MANAGER_TYPE = 1, + INTERFACE_BLUETOOTH_CALL_TYPE, +}; + std::shared_ptr g_clientPtr = nullptr; using CallManagerServiceFunc = void (*)(); std::map g_memberFuncMap; -std::vector permDefList; -constexpr int16_t MIN_VOLUME = 0; -constexpr int16_t MAX_VOLUME = 15; -constexpr int16_t READ_SIZE = 1; -constexpr int16_t MIN_BYTES = 4; -constexpr int16_t RING_PATH_MAX_LENGTH = 100; -constexpr int16_t SIM1_SLOTID = 0; -constexpr int16_t DEFAULT_ACCOUNT_ID = 0; -constexpr int16_t DEFAULT_VIDEO_STATE = 0; -constexpr int16_t DEFAULT_DIAL_SCENE = 0; -constexpr int16_t DEFAULT_DIAL_TYPE = 0; -constexpr int16_t DEFAULT_CALL_TYPE = 0; -constexpr int16_t DEFAULT_CALL_ID = 0; -constexpr int16_t DEFAULT_VALUE = 0; -constexpr size_t DEFAULT_SIZE = 0; -constexpr int16_t WINDOWS_X_START = 0; -constexpr int16_t WINDOWS_Y_START = 0; -constexpr int16_t WINDOWS_Z_ERROR = -1; -constexpr int16_t WINDOWS_Z_TOP = 1; -constexpr int16_t WINDOWS_Z_BOTTOM = 0; -constexpr int16_t WINDOWS_WIDTH = 200; -constexpr int16_t WINDOWS_HEIGHT = 200; -constexpr size_t DEFAULT_PREFERENCEMODE = 3; -constexpr int16_t EVENT_BLUETOOTH_SCO_CONNECTED_CODE = 0; -constexpr int16_t EVENT_BLUETOOTH_SCO_DISCONNECTED_CODE = 1; -const std::string EVENT_BLUETOOTH_SCO_CONNECTED = "usual.event.BLUETOOTH_SCO_CONNECTED"; -const std::string EVENT_BLUETOOTH_SCO_DISCONNECTED = "usual.event.BLUETOOTH_SCO_DISCONNECTED"; -constexpr size_t DEFAULT_NET_TYPE = 0; -constexpr size_t DEFAULT_ITEM_VALUE = 0; -const int32_t DEFINE_INIT_PERMISSIONS = 93; -const int32_t DEFINE_VERIFY_PERMISSIONS = 94; -const int32_t DEFINE_CONNECT_BT_SCO = 95; -const int32_t DEFINE_DISCONNECT_BT_SCO = 96; -const int32_t DEFINE_SUBSCRIBERCOMMON_EVENT = 97; -const std::string TEST_BUNDLE_NAME = "com.ohos.callManagerTest"; -const std::string CALL_UI_BUNDLE_NAME = "com.ohos.videocall"; -const std::string TEST_PERMISSION_NAME_CAMERA = "ohos.permission.camera"; -const std::string TEST_LABEL = "test label"; -const std::string TEST_DESCRIPTION = "test description"; - -const int32_t TEST_LABEL_ID = 9527; -const int32_t TEST_DESCRIPTION_ID = 9528; -const int32_t TEST_USER_ID = 0; void DialCall() { @@ -559,7 +523,7 @@ void GetSubCallIdList() std::cin >> callId; std::vector ret = g_clientPtr->GetSubCallIdList(callId); std::vector::iterator it = ret.begin(); - for (; it != ret.end(); it++) { + for (; it != ret.end(); ++it) { std::cout << "callId:" << Str16ToStr8(*it) << std::endl; } } @@ -571,7 +535,7 @@ void GetCallIdListForConference() std::cin >> callId; std::vector ret = g_clientPtr->GetCallIdListForConference(callId); std::vector::iterator it = ret.begin(); - for (; it != ret.end(); it++) { + for (; it != ret.end(); ++it) { std::cout << "callId:" << Str16ToStr8(*it) << std::endl; } } @@ -690,6 +654,10 @@ void SetVolume() bool InitRenderer(const std::unique_ptr &audioRenderer, const wav_hdr &wavHeader) { + if (audioRenderer == nullptr) { + std::cout << "audioRenderer is null" << std::endl; + return false; + } AudioStandard::AudioRendererParams rendererParams; rendererParams.sampleFormat = static_cast(wavHeader.bitsPerSample); rendererParams.sampleRate = static_cast(wavHeader.SamplesPerSec); @@ -895,32 +863,6 @@ void SubscribeCommonEvent() std::cout << "subscribe common event : " << eventType << ", result : " << result << std::endl; } -void SendConnectBluetoothScoBroadcast() -{ - AAFwk::Want want; - want.SetAction(EVENT_BLUETOOTH_SCO_CONNECTED); - EventFwk::CommonEventData data; - data.SetWant(want); - data.SetCode(EVENT_BLUETOOTH_SCO_CONNECTED_CODE); - OHOS::EventFwk::CommonEventPublishInfo publishInfo; - publishInfo.SetOrdered(true); - bool result = EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr); - std::cout << "publish common event : EVENT_BLUETOOTH_SCO_CONNECTED , result : " << result << std::endl; -} - -void SendDisconnectBluetoothScoBroadcast() -{ - AAFwk::Want want; - want.SetAction(EVENT_BLUETOOTH_SCO_DISCONNECTED); - EventFwk::CommonEventData data; - data.SetWant(want); - data.SetCode(EVENT_BLUETOOTH_SCO_DISCONNECTED_CODE); - OHOS::EventFwk::CommonEventPublishInfo publishInfo; - publishInfo.SetOrdered(true); - bool result = EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr); - std::cout << "publish common event : EVENT_BLUETOOTH_SCO_DISCONNECTED , result : " << result << std::endl; -} - void GetImsConfig() { int32_t slotId = SIM1_SLOTID; @@ -1151,82 +1093,17 @@ void StopRtt() void AddPermission() { - using namespace OHOS::Security::Permission; - PermissionDef permissionDefAlpha = {.permissionName = TEST_PERMISSION_NAME_CAMERA, - .bundleName = TEST_BUNDLE_NAME, - .grantMode = GrantMode::USER_GRANT, - .availableScope = AVAILABLE_SCOPE_ALL, - .label = TEST_LABEL, - .labelId = TEST_LABEL_ID, - .description = TEST_DESCRIPTION, - .descriptionId = TEST_DESCRIPTION_ID}; - - PermissionDef permissionDefBeta = {.permissionName = TEST_PERMISSION_NAME_CAMERA, - .bundleName = CALL_UI_BUNDLE_NAME, - .grantMode = GrantMode::SYSTEM_GRANT, - .availableScope = AVAILABLE_SCOPE_ALL, - .label = TEST_LABEL, - .labelId = TEST_LABEL_ID, - .description = TEST_DESCRIPTION, - .descriptionId = TEST_DESCRIPTION_ID}; - - permDefList.emplace_back(permissionDefAlpha); - permDefList.emplace_back(permissionDefBeta); - PermissionKit::AddDefPermissions(permDefList); - - std::vector permList; - permList.push_back(TEST_PERMISSION_NAME_CAMERA); - int32_t ret = PermissionKit::AddUserGrantedReqPermissions(TEST_BUNDLE_NAME, permList, TEST_USER_ID); - std::cout << TEST_BUNDLE_NAME << " AddPermission AddUserGrantedReqPermissions return:" << ret << std::endl; - ret = PermissionKit::GrantUserGrantedPermission(TEST_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - std::cout << TEST_BUNDLE_NAME << " AddPermission GrantUserGrantedPermission return:" << ret << std::endl; - - ret = PermissionKit::AddUserGrantedReqPermissions(CALL_UI_BUNDLE_NAME, permList, TEST_USER_ID); - std::cout << CALL_UI_BUNDLE_NAME << " AddPermission AddUserGrantedReqPermissions return:" << ret << std::endl; - ret = PermissionKit::GrantUserGrantedPermission(CALL_UI_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - std::cout << CALL_UI_BUNDLE_NAME << " AddPermission GrantUserGrantedPermission return:" << ret << std::endl; + return; } void InitPermission() { - using namespace OHOS::Security::Permission; - std::cout << "------InitPermission------" << std::endl; - int32_t ret = PermissionKit::VerifyPermission(TEST_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - std::cout << "VerifyPermission return ret:" << ret << std::endl; - - int32_t retCallUI = - PermissionKit::VerifyPermission(CALL_UI_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - std::cout << "VerifyPermission return retCallUI:" << retCallUI << std::endl; - if (ret != PermissionKitRet::RET_SUCCESS || retCallUI != PermissionKitRet::RET_SUCCESS) { - AddPermission(); - } + return; } void VerifyPermission() { - using namespace OHOS::Security::Permission; - std::cout << "------VerifyPermission------" << std::endl; - int32_t ret = PermissionKit::VerifyPermission(TEST_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - if (ret == PermissionKitRet::RET_SUCCESS) { - std::cout << TEST_BUNDLE_NAME << " VerifyPermission success:" << ret << std::endl; - } else { - std::cout << TEST_BUNDLE_NAME << " VerifyPermission failed:" << ret << std::endl; - } - - ret = PermissionKit::VerifyPermission(CALL_UI_BUNDLE_NAME, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - if (ret == PermissionKitRet::RET_SUCCESS) { - std::cout << CALL_UI_BUNDLE_NAME << " VerifyPermission success:" << ret << std::endl; - } else { - std::cout << CALL_UI_BUNDLE_NAME << " VerifyPermission failed:" << ret << std::endl; - } - - const std::string bundleName = "com.ohos.errorpkg"; - ret = PermissionKit::VerifyPermission(bundleName, TEST_PERMISSION_NAME_CAMERA, TEST_USER_ID); - if (ret == PermissionKitRet::RET_SUCCESS) { - std::cout << bundleName << " VerifyPermission success:" << ret << std::endl; - } else { - std::cout << bundleName << " VerifyPermission failed:" << ret << std::endl; - } + return; } void InitCallBasicPower() @@ -1318,13 +1195,6 @@ void InitImsServicePower() &OHOS::Telephony::IsLteEnhanceModeEnabled; } -void InitBluetooth() -{ - g_memberFuncMap[DEFINE_CONNECT_BT_SCO] = &OHOS::Telephony::SendConnectBluetoothScoBroadcast; - g_memberFuncMap[DEFINE_DISCONNECT_BT_SCO] = &OHOS::Telephony::SendDisconnectBluetoothScoBroadcast; - g_memberFuncMap[DEFINE_SUBSCRIBERCOMMON_EVENT] = &OHOS::Telephony::SubscribeCommonEvent; -} - int32_t Init() { g_clientPtr = DelayedSingleton::GetInstance(); @@ -1335,7 +1205,7 @@ int32_t Init() g_clientPtr->Init(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID); std::unique_ptr callbackPtr = std::make_unique(); if (callbackPtr == nullptr) { - std::cout << "make_unique NapiCallManagerCallback failed!" << std::endl; + std::cout << "make_unique CallManagerCallbackTest failed!" << std::endl; return TELEPHONY_ERROR; } int32_t ret = g_clientPtr->RegisterCallBack(std::move(callbackPtr)); @@ -1467,44 +1337,79 @@ int32_t mainExit() std::cout << "exit success" << std::endl; return OHOS::Telephony::TELEPHONY_SUCCESS; } -} // namespace Telephony -} // namespace OHOS -int32_t main() +int32_t RunTest() { std::cout << "callManager test start...." << std::endl; - int32_t interfaceNum = OHOS::Telephony::DEFAULT_VALUE; + int32_t interfaceNum = DEFAULT_VALUE; const int32_t exitNumber = 1000; const int32_t getVolumeNumber = 98; const int32_t setVolumeNumber = 99; const int32_t playRingtoneNumber = 100; - if (OHOS::Telephony::Init() != OHOS::Telephony::TELEPHONY_SUCCESS) { + if (Init() != TELEPHONY_SUCCESS) { std::cout << "callManager test init failed!" << std::endl; - return OHOS::Telephony::TELEPHONY_SUCCESS; + return TELEPHONY_SUCCESS; } while (true) { - OHOS::Telephony::PrintfUsage(); + PrintfUsage(); std::cin >> interfaceNum; if (interfaceNum == exitNumber) { std::cout << "start to exit now...." << std::endl; break; } else if (interfaceNum == playRingtoneNumber) { - OHOS::Telephony::PlayRingtone(); + PlayRingtone(); continue; } else if (interfaceNum == setVolumeNumber) { - OHOS::Telephony::SetVolume(); + SetVolume(); continue; } else if (interfaceNum == getVolumeNumber) { - OHOS::Telephony::GetVolume(); + GetVolume(); continue; } - auto itFunc = OHOS::Telephony::g_memberFuncMap.find(interfaceNum); - if (itFunc != OHOS::Telephony::g_memberFuncMap.end() && itFunc->second != nullptr) { + auto itFunc = g_memberFuncMap.find(interfaceNum); + if (itFunc != g_memberFuncMap.end() && itFunc->second != nullptr) { auto memberFunc = itFunc->second; (*memberFunc)(); continue; } std::cout << "err: invalid input!" << std::endl; } - return OHOS::Telephony::mainExit(); + return mainExit(); +} +} // namespace Telephony +} // namespace OHOS + +int32_t main() +{ + int32_t code = OHOS::Telephony::DEFAULT_VALUE; + const int32_t exitCode = 1000; + std::cout << "Please select interface type...." << std::endl; + while (true) { + std::cout << "1:callManager interface\n" + << "2:bluetooth call interface\n" + << "1000:exit\n"; + std::cin >> code; + switch (code) { + case static_cast(OHOS::Telephony::CallManagerInterfaceType::INTERFACE_CALL_MANAGER_TYPE): + OHOS::Telephony::RunTest(); + OHOS::Telephony::mainExit(); + break; + case static_cast(OHOS::Telephony::CallManagerInterfaceType::INTERFACE_BLUETOOTH_CALL_TYPE): { + std::unique_ptr testPtr = + std::make_unique(); + if (testPtr != nullptr) { + testPtr->Init(); + testPtr->RunBluetoothCallTest(); + } + break; + } + default: + std::cout << "invalid input" << std::endl; + break; + } + if (code == exitCode) { + break; + } + } + return OHOS::Telephony::TELEPHONY_SUCCESS; } diff --git a/utils/include/call_number_utils.h b/utils/include/call_number_utils.h old mode 100755 new mode 100644 diff --git a/utils/include/timer.h b/utils/include/timer.h old mode 100755 new mode 100644 diff --git a/utils/src/call_number_utils.cpp b/utils/src/call_number_utils.cpp old mode 100755 new mode 100644 index 9387433cd9ac3e16d39787bda486c3c3cb1fe7a8..eb8deba53e4ebd3963d44ab68c07f620a63c51dc --- a/utils/src/call_number_utils.cpp +++ b/utils/src/call_number_utils.cpp @@ -18,6 +18,7 @@ #include "phonenumbers/phonenumber.pb.h" #include "telephony_log_wrapper.h" +#include "telephony_types.h" #include "call_manager_errors.h" #include "cellular_call_connection.h"