diff --git a/bundle.json b/bundle.json index c05b39033dd3a5418f8e909fae2d986f3edc4f97..b003437f26da9d9bb48b151cdb5b04f26dba5b81 100644 --- a/bundle.json +++ b/bundle.json @@ -70,7 +70,8 @@ "dsoftbus", "input", "device_manager", - "openssl" + "openssl", + "runtime_core" ], "third_party": [ "libphonenumber", @@ -83,7 +84,8 @@ "base_group": [ ], "fwk_group": [ - "//base/telephony/call_manager/frameworks/js:call" + "//base/telephony/call_manager/frameworks/js:call", + "//base/telephony/call_manager/frameworks/ets/taihe:telephony_call_taihe" ], "service_group": [ "//base/telephony/call_manager:tel_call_manager", @@ -104,6 +106,9 @@ "header_files": [] }, "name":"//base/telephony/call_manager/frameworks/cj:cj_telephony_call_ffi" + }, + { + "name":"//base/telephony/call_manager/frameworks/ets/taihe:copy_telephonycall" } ], "test": [ diff --git a/frameworks/ets/taihe/BUILD.gn b/frameworks/ets/taihe/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b73855282ab7305a3a8d54725c441234ea3fec6b --- /dev/null +++ b/frameworks/ets/taihe/BUILD.gn @@ -0,0 +1,101 @@ +# +# Copyright (c) 2025-2025 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("//build/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") +import("//build/ohos/taihe_idl/taihe.gni") +import("//base/telephony/call_manager/callmanager.gni") + +copy_taihe_idl("copy_telephonycall") { + sources = [ "idl/ohos.telephony.call.taihe" ] +} + +subsystem_name = "telephony" +part_name = "call_manager" +taihe_generated_file_path = "$taihe_file_path/out/$subsystem_name/$part_name" + +ohos_taihe("run_taihe") { + taihe_generated_file_path = "$taihe_generated_file_path" + deps = [ ":copy_telephonycall" ] + outputs = [ + "$taihe_generated_file_path/src/ohos.telephony.call.ani.cpp", + "$taihe_generated_file_path/src/ohos.telephony.call.abi.c", + ] +} + +taihe_shared_library("telephony_call_taihe_native") { + taihe_generated_file_path = "$taihe_generated_file_path" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + sources = get_target_outputs(":run_taihe") + include_dirs = [ + "${call_manager_path}/frameworks/ets/taihe/include", + ] + sources += [ + "src/ani_constructor.cpp", + "src/ohos.telephony.call.impl.cpp", + "src/taihe_call_ability_callback.cpp", + "src/taihe_call_manager_callback.cpp", + "src/taihe_call_manager.cpp", + "src/util.cpp", + ] + deps = [ + ":run_taihe", + "//base/telephony/call_manager/frameworks/native:tel_call_manager_api" + ] + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_runtime:ability_manager", + "ability_runtime:napi_common", + "c_utils:utils", + "core_service:libtel_common", + "core_service:tel_core_service_api", + "hilog:libhilog", + "image_framework:image", + "image_framework:image_native", + "init:libbegetutil", + "libuv:uv", + "napi:ace_napi", + ] + + sanitize = { + cfi = false + cfi_cross_dso = false + debug = false + } + branch_protector_ret = "pac_ret" +} + +generate_static_abc("telephony_call_abc") { + base_url = "$taihe_generated_file_path" + files = [ "$taihe_generated_file_path/@ohos.telephony.call.ets" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/telephony_call_abc.abc" + dependencies = [ ":run_taihe" ] +} + +ohos_prebuilt_etc("telephony_call_etc") { + source = "$target_out_dir/telephony_call_abc.abc" + module_install_dir = "framework" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + deps = [ ":telephony_call_abc" ] +} +group("telephony_call_taihe") { + deps = [ + ":telephony_call_etc", + ":telephony_call_taihe_native", + ] +} \ No newline at end of file diff --git a/frameworks/ets/taihe/idl/ohos.telephony.call.taihe b/frameworks/ets/taihe/idl/ohos.telephony.call.taihe new file mode 100644 index 0000000000000000000000000000000000000000..a4f04daf18724a6bcc8969cd34042533a4f7bb65 --- /dev/null +++ b/frameworks/ets/taihe/idl/ohos.telephony.call.taihe @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2025-2025 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. + */ + +@!sts_inject_into_module("import Context from 'application.Context';") +@!namespace("@ohos.telephony.call", "call") +@!sts_inject(""" +static { loadLibrary("telephony_call_taihe_native.z") } +""") +@!sts_inject_into_module("import Context from 'application.Context';") +@!sts_inject_into_module("import {AsyncCallback , Callback} from '@ohos.base';") +@!sts_inject_into_module("import image from '@ohos.multimedia.image';") + +enum CallState: i32 { + CALL_STATE_UNKNOWN = -1, + CALL_STATE_IDLE = 0, + CALL_STATE_RINGING = 1, + CALL_STATE_OFFHOOK = 2, + CALL_STATE_ANSWERED = 3 +} +enum VideoStateType: i32 { + TYPE_VOICE = 0, + TYPE_VIDEO, + TYPE_VIDEO_SEND_ONLY = 1, + TYPE_VIDEO_RECEIVE_ONLY, + TYPE_VIDEO_BIDIRECTIONAL, +} +enum CallType: i32 { + TYPE_CS = 0, + TYPE_IMS = 1, + TYPE_OTT = 2, + TYPE_ERR_CALL = 3, + TYPE_VOIP = 4, +} +enum DetailedCallState: i32 { + CALL_STATUS_ACTIVE = 0, + CALL_STATUS_HOLDING = 1, + CALL_STATUS_DIALING = 2, + CALL_STATUS_ALERTING = 3, + CALL_STATUS_INCOMING = 4, + CALL_STATUS_WAITING = 5, + CALL_STATUS_DISCONNECTED = 6, + CALL_STATUS_DISCONNECTING = 7, + CALL_STATUS_IDLE = 8 +} +enum ConferenceState: i32 { + TEL_CONFERENCE_IDLE = 0, + TEL_CONFERENCE_ACTIVE, + TEL_CONFERENCE_DISCONNECTING, + TEL_CONFERENCE_DISCONNECTED, +} +enum CallAbilityEventId: i32 { + EVENT_DIAL_NO_CARRIER = 1, + EVENT_INVALID_FDN_NUMBER = 2, + EVENT_HOLD_CALL_FAILED = 3, + EVENT_SWAP_CALL_FAILED = 4, + EVENT_COMBINE_CALL_FAILED = 5, + EVENT_SPLIT_CALL_FAILED = 6, + EVENT_SHOW_FULL_SCREEN = 7, + EVENT_SHOW_FLOAT_WINDOW = 8, +} +enum DisconnectedReason: i32 { + UNASSIGNED_NUMBER = 1, + NO_ROUTE_TO_DESTINATION = 3, + CHANNEL_UNACCEPTABLE = 6, + OPERATOR_DETERMINED_BARRING = 8, + CALL_COMPLETED_ELSEWHERE = 13, + NORMAL_CALL_CLEARING = 16, + USER_BUSY = 17, + NO_USER_RESPONDING = 18, + USER_ALERTING_NO_ANSWER = 19, + CALL_REJECTED = 21, + NUMBER_CHANGED = 22, + CALL_REJECTED_DUE_TO_FEATURE_AT_THE_DESTINATION = 24, + FAILED_PRE_EMPTION = 25, + NON_SELECTED_USER_CLEARING = 26, + DESTINATION_OUT_OF_ORDER = 27, + INVALID_NUMBER_FORMAT = 28, + FACILITY_REJECTED = 29, + RESPONSE_TO_STATUS_ENQUIRY = 30, + NORMAL_UNSPECIFIED = 31, + NO_CIRCUIT_CHANNEL_AVAILABLE = 34, + NETWORK_OUT_OF_ORDER = 38, + TEMPORARY_FAILURE = 41, + SWITCHING_EQUIPMENT_CONGESTION = 42, + ACCESS_INFORMATION_DISCARDED = 43, + REQUEST_CIRCUIT_CHANNEL_NOT_AVAILABLE = 44, + RESOURCES_UNAVAILABLE_UNSPECIFIED = 47, + QUALITY_OF_SERVICE_UNAVAILABLE = 49, + REQUESTED_FACILITY_NOT_SUBSCRIBED = 50, + INCOMING_CALLS_BARRED_WITHIN_THE_CUG = 55, + BEARER_CAPABILITY_NOT_AUTHORIZED = 57, + BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE = 58, + SERVICE_OR_OPTION_NOT_AVAILABLE_UNSPECIFIED = 63, + BEARER_SERVICE_NOT_IMPLEMENTED = 65, + ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE = 68, + REQUESTED_FACILITY_NOT_IMPLEMENTED = 69, + ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE = 70, + SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED = 79, + INVALID_TRANSACTION_IDENTIFIER_VALUE = 81, + USER_NOT_MEMBER_OF_CUG = 87, + INCOMPATIBLE_DESTINATION = 88, + INVALID_TRANSIT_NETWORK_SELECTION = 91, + SEMANTICALLY_INCORRECT_MESSAGE = 95, + INVALID_MANDATORY_INFORMATION = 96, + MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED = 97, + MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98, + INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED = 99, + CONDITIONAL_IE_ERROR = 100, + MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101, + RECOVERY_ON_TIMER_EXPIRED = 102, + PROTOCOL_ERROR_UNSPECIFIED = 111, + INTERWORKING_UNSPECIFIED = 127, + CALL_BARRED = 240, + FDN_BLOCKED = 241, + IMSI_UNKNOWN_IN_VLR = 242, + IMEI_NOT_ACCEPTED = 243, + DIAL_MODIFIED_TO_USSD = 244, + DIAL_MODIFIED_TO_SS = 245, + DIAL_MODIFIED_TO_DIAL = 246, + RADIO_OFF = 247, + OUT_OF_SERVICE = 248, + NO_VALID_SIM = 249, + RADIO_INTERNAL_ERROR = 250, + NETWORK_RESP_TIMEOUT = 251, + NETWORK_REJECT = 252, + RADIO_ACCESS_FAILURE = 253, + RADIO_LINK_FAILURE = 254, + RADIO_LINK_LOST = 255, + RADIO_UPLINK_FAILURE = 256, + RADIO_SETUP_FAILURE = 257, + RADIO_RELEASE_NORMAL = 258, + RADIO_RELEASE_ABNORMAL = 259, + ACCESS_CLASS_BLOCKED = 260, + NETWORK_DETACH = 261, + INVALID_PARAMETER = 1025, + SIM_NOT_EXIT = 1026, + SIM_PIN_NEED = 1027, + CALL_NOT_ALLOW = 1029, + SIM_INVALID = 1045, + UNKNOWN = 1279 +} +enum MmiCodeResult: i32 { + MMI_CODE_SUCCESS = 0, + MMI_CODE_FAILED = 1 +} +enum AudioDeviceType: i32 { + DEVICE_EARPIECE, + DEVICE_SPEAKER, + DEVICE_WIRED_HEADSET, + DEVICE_BLUETOOTH_SCO, + DEVICE_DISTRIBUTED_AUTOMOTIVE +} +enum VideoRequestResultType: i32 { + TYPE_REQUEST_SUCCESS = 0, + TYPE_REQUEST_FAILURE, + TYPE_REQUEST_INVALID, + TYPE_REQUEST_TIMED_OUT, + TYPE_REQUEST_REJECTED_BY_REMOTE, + TYPE_REQUEST_UPGRADE_CANCELED, + TYPE_DOWNGRADE_RTP_OR_RTCP_TIMEOUT = 100, + TYPE_DOWNGRADE_RTP_AND_RTCP_TIMEOUT, +} +enum ImsCallMode: i32 { + CALL_MODE_AUDIO_ONLY = 0, + CALL_MODE_SEND_ONLY, + CALL_MODE_RECEIVE_ONLY, + CALL_MODE_SEND_RECEIVE, + CALL_MODE_VIDEO_PAUSED, +} +enum CallSessionEventId: i32 { + EVENT_CONTROL_CAMERA_FAILURE = 0, + EVENT_CONTROL_CAMERA_READY, + EVENT_DISPLAY_SURFACE_RELEASED = 100, + EVENT_PREVIEW_SURFACE_RELEASED, +} +enum VoNRState: i32 { + VONR_STATE_OFF = 0, + VONR_STATE_ON = 1, +} +enum CallRestrictionType: i32 { + RESTRICTION_TYPE_ALL_INCOMING = 0, + RESTRICTION_TYPE_ALL_OUTGOING = 1, + RESTRICTION_TYPE_INTERNATIONAL = 2, + RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME = 3, + RESTRICTION_TYPE_ROAMING_INCOMING = 4, + RESTRICTION_TYPE_ALL_CALLS = 5, + RESTRICTION_TYPE_OUTGOING_SERVICES = 6, + RESTRICTION_TYPE_INCOMING_SERVICES = 7, +} +enum CallTransferType: i32 { + TRANSFER_TYPE_UNCONDITIONAL = 0, + TRANSFER_TYPE_BUSY = 1, + TRANSFER_TYPE_NO_REPLY = 2, + TRANSFER_TYPE_NOT_REACHABLE = 3, +} +enum CallTransferSettingType: i32 { + CALL_TRANSFER_DISABLE = 0, + CALL_TRANSFER_ENABLE = 1, + CALL_TRANSFER_REGISTRATION = 3, + CALL_TRANSFER_ERASURE = 4, +} +enum DeviceDirection: i32 { + DEVICE_DIRECTION_0 = 0, + DEVICE_DIRECTION_90 = 90, + DEVICE_DIRECTION_180 = 180, + DEVICE_DIRECTION_270 = 270, +} +enum CallRestrictionMode: i32 { + RESTRICTION_MODE_DEACTIVATION = 0, + RESTRICTION_MODE_ACTIVATION = 1, +} +enum DialScene: i32 { + CALL_NORMAL = 0, + CALL_PRIVILEGED = 1, + CALL_EMERGENCY = 2, +} +enum DialType: i32 { + DIAL_CARRIER_TYPE = 0, + DIAL_VOICE_MAIL_TYPE = 1, + DIAL_OTT_TYPE = 2, +} +enum CallWaitingStatus: i32 { + CALL_WAITING_DISABLE = 0, + CALL_WAITING_ENABLE = 1, +} +enum RestrictionStatus: i32 { + RESTRICTION_DISABLE = 0, + RESTRICTION_ENABLE = 1, +} +enum TransferStatus: i32 { + TRANSFER_DISABLE = 0, + TRANSFER_ENABLE = 1, +} +enum MarkType: i32 { + MARK_TYPE_NONE = 0, + MARK_TYPE_CRANK = 1, + MARK_TYPE_FRAUD = 2, + MARK_TYPE_EXPRESS = 3, + MARK_TYPE_PROMOTE_SALES = 4, + MARK_TYPE_HOUSE_AGENT = 5, + MARK_TYPE_INSURANCE = 6, + MARK_TYPE_TAXI = 7, + MARK_TYPE_CUSTOM = 8, + MARK_TYPE_OTHERS = 9, + MARK_TYPE_YELLOW_PAGE = 10, + MARK_TYPE_ENTERPRISE = 11, +} +struct NumberFormatOptions { + countryCode: Optional; +} +struct VoipCallAttribute { + voipCallId: String; + userName: String; + userProfile: @sts_type("image.PixelMap") Opaque; + extensionId: String; + abilityName: String; + voipBundleName: String; + showBannerForIncomingCall: Optional; + isConferenceCall: Optional; + isVoiceAnswerSupported: Optional; +} +struct NumberMarkInfo { + markType: MarkType; + markContent: Optional; + markCount: Optional; + markSource: Optional; + isCloud: Optional; + markDetails: Optional; +} +struct CallAttributeOptions { + accountNumber: String; + speakerphoneOn: bool; + accountId: i32; + videoState: VideoStateType; + startTime: f64; + isEcc: bool; + callType: CallType; + callId: i32; + callState: DetailedCallState; + conferenceState: ConferenceState; + crsType: i32; + originalCallType: i32; + numberLocation: Optional; +} +struct CallEventOptions { + eventId: CallAbilityEventId; +} +struct DisconnectedDetails { + reason: DisconnectedReason; + message: String; +} +struct MmiCodeResults { + result: MmiCodeResult; + message: String; +} +struct AudioDevice { + deviceType: AudioDeviceType; + address: Optional; + deviceName: Optional; +} +struct AudioDeviceCallbackInfo { + audioDeviceList: Array; + currentAudioDevice: AudioDevice; + isMuted: bool; +} +struct ImsCallModeInfo { + callId: i32; + result: VideoRequestResultType; + isRequestInfo: bool; + imsCallMode: ImsCallMode; +} +struct CallSessionEvent { + callId: i32; + eventId: CallSessionEventId; +} +struct PeerDimensionsDetail { + callId: i32; + width: i32; + height: i32; +} +struct CameraCapabilities { + callId: i32; + width: i32; + height: i32; +} +struct CallTransferInfo { + transferNum: String; + type: CallTransferType; + settingType: CallTransferSettingType; + startHour: Optional; + startMinute: Optional; + endHour: Optional; + endMinute: Optional; +} +struct CallRestrictionInfo { + type: CallRestrictionType; + password: String; + mode: CallRestrictionMode; +} +struct DialOptions { + extras: Optional; + accountId: Optional; + videoState: Optional; + dialScene: Optional; + dialType: Optional; +} +struct DialCallOptions { + accountId: Optional; + videoState: Optional; + dialScene: Optional; + dialType: Optional; + extraParams: Optional<@record Map>; +} +struct RejectMessageOptions { + messageContent: String; +} +struct EmergencyNumberOptions { + slotId: Optional; +} +@gen_async("makeCall") +@gen_promise("makeCall") +function makeCallSync(phoneNumber: String): void; + +@gen_promise("makeCall") +function makeCallSync2(context: @sts_type("Context") Opaque, phoneNumber: String): void; + +function HasVoiceCapability(): bool; + +@gen_async("formatPhoneNumber") +@gen_promise("formatPhoneNumber") +function formatPhoneNumberSync(phoneNumber: String, options: NumberFormatOptions): void; + +@gen_async("formatPhoneNumber") +function formatPhoneNumberSync2(phoneNumber: String): void; + +function getCallStateSync(): CallState; + +function HasCallSync(): bool; + +@!sts_inject(""" +export function on(type: string, cb: (arg_0: Object) => void) { + switch(type) { + case "callDetailsChange": return onCallDetailsChange(cb); + case "callEventChange": return onCallEventChange(cb); + case "callDisconnectedCause": return onCallDisconnectedCauses(cb); + case "mmiCodeResult": return onMmiCodeResult(cb); + case "audioDeviceChange": return onAudioDeviceChange(cb); + case "postDialDelay": return onPostDialDelay(cb); + case "imsCallModeChange": return onImsCallModeChange(cb); + case "callSessionEvent": return onCallSessionEvent(cb); + case "peerDimensionsChange": return onPeerDimensionsChange(cb); + case "cameraCapabilitiesChange": return onCameraCapabilitiesChange(cb); + default: throw new Error(`Unknown type: ${type}`); + } +} +export function off(type: string, cb?: (arg_0: Object) => void) { + switch(type) { + case "callDetailsChange": return offCallDetailsChange(cb as (((data: CallAttributeOptions) => void) | undefined)); + case "callEventChange": return offCallEventChange(cb as (((data: CallEventOptions) => void) | undefined)); + case "callDisconnectedCause": return offCallDisconnectedCauses(cb as (((data: DisconnectedDetails) => void) | undefined)); + case "mmiCodeResult": return offMmiCodeResult(cb as (((data: MmiCodeResults) => void) | undefined)); + case "audioDeviceChange": return offAudioDeviceChange(cb as (((data: AudioDeviceCallbackInfo) => void) | undefined)); + case "postDialDelay": return offPostDialDelay(cb as (((data: string) => void) | undefined)); + case "imsCallModeChange": return offImsCallModeChange(cb as (((data: ImsCallModeInfo) => void) | undefined)); + case "callSessionEvent": return offCallSessionEvent(cb as (((data: CallSessionEvent) => void) | undefined)); + case "peerDimensionsChange": return offPeerDimensionsChange(cb as (((data: PeerDimensionsDetail) => void) | undefined)); + case "cameraCapabilitiesChange": return offCameraCapabilitiesChange(cb as (((data: CameraCapabilities) => void) | undefined)); + default: throw new Error(`Unknown type: ${type}`); + } +} +""") + +// 通话详情变化回调 +function onCallDetailsChange(callback: (data: CallAttributeOptions) => void): void; +function offCallDetailsChange(callback: Optional<(data: CallAttributeOptions) => void>): void; + +// 通话事件变化回调 +function onCallEventChange(callback: (data: CallEventOptions) => void): void; +function offCallEventChange(callback: Optional<(data: CallEventOptions) => void>): void; + +// 通话断开原因回调 +function onCallDisconnectedCauses(callback: (data: DisconnectedDetails) => void): void; +function offCallDisconnectedCauses(callback: Optional<(data: DisconnectedDetails) => void>): void; + +// MMI码结果回调 +function onMmiCodeResult(callback: (data: MmiCodeResults) => void): void; +function offMmiCodeResult(callback: Optional<(data: MmiCodeResults) => void>): void; + +// 音频设备变化回调 +function onAudioDeviceChange(callback: (data: AudioDeviceCallbackInfo) => void): void; +function offAudioDeviceChange(callback: Optional<(data: AudioDeviceCallbackInfo) => void>): void; + +// 拨号后延迟回调 +function onPostDialDelay(callback: (data: String) => void): void; +function offPostDialDelay(callback: Optional<(data: String) => void>): void; + +// IMS通话模式变化回调 +function onImsCallModeChange(callback: (data: ImsCallModeInfo) => void): void; +function offImsCallModeChange(callback: Optional<(data: ImsCallModeInfo) => void>): void; + +// 通话会话事件回调 +function onCallSessionEvent(callback: (data: CallSessionEvent) => void): void; +function offCallSessionEvent(callback: Optional<(data: CallSessionEvent) => void>): void; + +// 对端尺寸变化回调 +function onPeerDimensionsChange(callback: (data: PeerDimensionsDetail) => void): void; +function offPeerDimensionsChange(callback: Optional<(data: PeerDimensionsDetail) => void>): void; + +// 相机能力变化回调 +function onCameraCapabilitiesChange(callback: (data: CameraCapabilities) => void): void; +function offCameraCapabilitiesChange(callback: Optional<(data: CameraCapabilities) => void>): void; \ No newline at end of file diff --git a/frameworks/ets/taihe/include/taihe_call_ability_callback.h b/frameworks/ets/taihe/include/taihe_call_ability_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..20f7d3fe10bb48486b28fb88c7cefa263b82b98b --- /dev/null +++ b/frameworks/ets/taihe/include/taihe_call_ability_callback.h @@ -0,0 +1,93 @@ +/* + * 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. + */ + +#ifndef TAIHE_CALL_ABILITY_CALLBACK_H +#define TAIHE_CALL_ABILITY_CALLBACK_H + +#include +#include +#include "call_manager_inner_type.h" + +#include "ohos.telephony.call.proj.hpp" +#include "ohos.telephony.call.impl.hpp" + +namespace OHOS { +namespace Telephony { + +class TaiheCallAbilityCallback { +public: + static TaiheCallAbilityCallback &GetInstance(); + + // 禁止拷贝和赋值 + TaiheCallAbilityCallback(const TaiheCallAbilityCallback &) = delete; + TaiheCallAbilityCallback &operator=(const TaiheCallAbilityCallback &) = delete; + + // 通话详情变化回调 + int32_t UpdateCallStateInfo(const CallAttributeInfo &info); + + // 通话事件变化回调 + int32_t UpdateCallEventInfo(const CallEventInfo &info); + + // 通话断开原因回调 + int32_t UpdateDisconnectedCause(const DisconnectedDetails &details); + + // MMI码结果回调 + int32_t UpdateMmiCodeResult(const MmiCodeInfo &info); + + // 音频设备变化回调 + int32_t UpdateAudioDeviceInfo(const AudioDeviceInfo &info); + + // 拨号后延迟回调 + int32_t UpdatePostDialDelay(const std::string &str); + + // IMS通话模式变化回调 + int32_t UpdateImsCallModeInfo(const CallMediaModeInfo &info); + + // 通话会话事件回调 + int32_t UpdateCallSessionEvent(const CallSessionEvent &event); + + // 对端尺寸变化回调 + int32_t UpdatePeerDimensions(const PeerDimensionsDetail &detail); + + // 相机能力变化回调 + int32_t UpdateCameraCapabilities(const CameraCapabilities &capabilities); + + ::taihe::optional> callStateCallback_; + ::taihe::optional> callEventCallback_;; + ::taihe::optional> disconnectedCauseCallback_; + ::taihe::optional> mmiCodeResultCallback_; + ::taihe::optional> audioDeviceCallback_; + ::taihe::optional> postDialDelayCallback_; + ::taihe::optional> imsCallModeCallback_; + ::taihe::optional> callSessionEventCallback_; + ::taihe::optional> peerDimensionsCallback_; + ::taihe::optional> cameraCapabilitiesCallback_; + +private: + TaiheCallAbilityCallback() = default; + ~TaiheCallAbilityCallback() = default; + + std::mutex callbackMutex_; +}; + +} // namespace Telephony +} // namespace OHOS + +#endif // TAIHE_CALL_ABILITY_CALLBACK_H \ No newline at end of file diff --git a/frameworks/ets/taihe/include/taihe_call_manager.h b/frameworks/ets/taihe/include/taihe_call_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..f2c0708fec438a39758a7fb5d06694a8037b63ef --- /dev/null +++ b/frameworks/ets/taihe/include/taihe_call_manager.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef TAIHE_CALL_MANAGER_H +#define TAIHE_CALL_MANAGER_H + +#include "call_manager_client.h" + +namespace OHOS { +namespace Telephony { + +class TaiheCallManager { +public: + static TaiheCallManager &GetInstance(); + void RegisterCallBack(); + +private: + TaiheCallManager(); + ~TaiheCallManager(); + +private: + int32_t registerStatus_; +}; + +} // namespace Telephony +} // namespace OHOS + +#endif // TAIHE_CALL_MANAGER_H \ No newline at end of file diff --git a/frameworks/ets/taihe/include/taihe_call_manager_callback.h b/frameworks/ets/taihe/include/taihe_call_manager_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..cdacc8f7b1047625d660e5f9cb8b68ceff40056a --- /dev/null +++ b/frameworks/ets/taihe/include/taihe_call_manager_callback.h @@ -0,0 +1,51 @@ +/* + * 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. + */ + +#ifndef TAIHE_CALL_MANAGER_CALLBACK_H +#define TAIHE_CALL_MANAGER_CALLBACK_H + +#include "pac_map.h" +#include "call_manager_callback.h" + +namespace OHOS { +namespace Telephony { + +class TaiheCallManagerCallback : public CallManagerCallback { +public: + TaiheCallManagerCallback(); + ~TaiheCallManagerCallback() override; + + int32_t OnCallDetailsChange(const CallAttributeInfo &info) override; + int32_t OnCallEventChange(const CallEventInfo &info) override; + int32_t OnCallDisconnectedCause(const DisconnectedDetails &details) override; + int32_t OnReportMmiCodeResult(const MmiCodeInfo &info) override; + int32_t OnReportAudioDeviceChange(const AudioDeviceInfo &info) override; + int32_t OnReportPostDialDelay(const std::string &str) override; + int32_t OnUpdateImsCallModeChange(const CallMediaModeInfo &imsCallModeInfo) override; + int32_t OnCallSessionEventChange(const CallSessionEvent &callSessionEventOptions) override; + int32_t OnPeerDimensionsChange(const PeerDimensionsDetail &peerDimensionsDetail) override; + int32_t OnUpdateCameraCapabilities(const CameraCapabilities &cameraCapabilities) override; + int32_t OnMeeTimeDetailsChange(const CallAttributeInfo &info) override; + int32_t OnCallDataUsageChange(const int64_t dataUsage) override; + int32_t OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) override; + int32_t OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) override; + int32_t OnPhoneStateChange( + int32_t numActive, int32_t numHeld, int32_t callState, const std::string &number) override; +}; + +} // namespace Telephony +} // namespace OHOS + +#endif // TAihe_CALL_MANAGER_CALLBACK_H \ No newline at end of file diff --git a/frameworks/ets/taihe/include/util.h b/frameworks/ets/taihe/include/util.h new file mode 100644 index 0000000000000000000000000000000000000000..1597d7a711cf70d6bbe6982060481bdeeed87e4a --- /dev/null +++ b/frameworks/ets/taihe/include/util.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2025 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 UTIL_H +#define UTIL_H + +#include "call_manager_inner_type.h" +#include "ohos.telephony.call.proj.hpp" +#include "ohos.telephony.call.impl.hpp" + +namespace OHOS { +namespace Telephony { +class Utils { +public: + static void CallAttributeInfoToTaihe(::ohos::telephony::call::CallAttributeOptions& taiheCallAttributeInfo, + const CallAttributeInfo &info); + static void CallEventInfoToTaihe(::ohos::telephony::call::CallEventOptions& taiheCallEventInfo, + const CallEventInfo &info); + static void DisconnectedDetailsToTaihe(::ohos::telephony::call::DisconnectedDetails& taiheDisconnectedDetails, + const DisconnectedDetails &details); + static void MmiCodeInfoToTaihe(::ohos::telephony::call::MmiCodeResults& taiheMmiCodeInfo, + const MmiCodeInfo &info); + static void AudioDeviceInfoToTaihe(::ohos::telephony::call::AudioDeviceCallbackInfo& taiheAudioDeviceInfo, + const AudioDeviceInfo &info); + static void CallMediaModeInfoToTaihe(::ohos::telephony::call::ImsCallModeInfo& taiheCallMediaModeInfo, + const CallMediaModeInfo &info); + static void CallSessionEventToTaihe(::ohos::telephony::call::CallSessionEvent& taiheCallSessionEvent, + const CallSessionEvent &event); + static void PeerDimensionsDetailToTaihe(::ohos::telephony::call::PeerDimensionsDetail& taihePeerDimensionsDetail, + const PeerDimensionsDetail &detail); + static void CameraCapabilitiesToTaihe(::ohos::telephony::call::CameraCapabilities& taiheCameraCapabilities, + const CameraCapabilities &capabilities); +}; +} +} +#endif \ No newline at end of file diff --git a/frameworks/ets/taihe/src/ani_constructor.cpp b/frameworks/ets/taihe/src/ani_constructor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d2d6406956b103090c05d80323033e31098233b4 --- /dev/null +++ b/frameworks/ets/taihe/src/ani_constructor.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2025-2025 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 "taihe/runtime.hpp" +#include "ohos.telephony.call.ani.hpp" + +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +{ + ani_env *env; + if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { + return ANI_ERROR; + } + if (ANI_OK != ohos::telephony::call::ANIRegister(env)) { + std::cerr << "Error from ohos::telephony::call::ANIRegister" << std::endl; + return ANI_ERROR; + } + *result = ANI_VERSION_1; + return ANI_OK; +} \ No newline at end of file diff --git a/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp b/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1e74d08927f28c156b73c3730734fb370db10f27 --- /dev/null +++ b/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (C) 2025-2025 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 "ohos.telephony.call.proj.hpp" +#include "ohos.telephony.call.impl.hpp" +#include "taihe/runtime.hpp" +#include "stdexcept" + +#include "call_manager_client.h" +#include "telephony_errors.h" +#include "telephony_log_wrapper.h" +#include + +#include "taihe_call_manager.h" +#include "taihe_call_ability_callback.h" + +using namespace taihe; +using namespace OHOS::Telephony; +namespace { + +void makeCallSync(::taihe::string_view phoneNumber) +{ + auto errCode = OHOS::DelayedSingleton::GetInstance()->MakeCall(std::string(phoneNumber)); + if (errCode != TELEPHONY_ERR_SUCCESS) { + set_business_error(errCode, "makeCall return error"); + } + return; +} + +void makeCallSync2(uintptr_t context, ::taihe::string_view phoneNumber) +{ + auto errCode = OHOS::DelayedSingleton::GetInstance()->MakeCall(std::string(phoneNumber)); + if (errCode != TELEPHONY_ERR_SUCCESS) { + set_business_error(errCode, "makeCall2 return error"); + } + return; +} + +bool HasVoiceCapability() +{ + auto ret = OHOS::DelayedSingleton::GetInstance()->HasVoiceCapability(); + return static_cast(ret); +} + +void formatPhoneNumberSync( + ::taihe::string_view phoneNumber, ::ohos::telephony::call::NumberFormatOptions const& options) +{ + std::u16string phoneNum = OHOS::Str8ToStr16(std::string(phoneNumber)); + std::u16string countryCode = OHOS::Str8ToStr16(std::string(options.countryCode.value_or("cn"))); + std::u16string formatNum = OHOS::Str8ToStr16(""); + auto errCode = OHOS::DelayedSingleton::GetInstance()->FormatPhoneNumber( + phoneNum, countryCode, formatNum); + if (errCode != TELEPHONY_ERR_SUCCESS) { + set_business_error(errCode, "formatPhoneNumber return error"); + } + return; +} + +void formatPhoneNumberSync2(::taihe::string_view phoneNumber) +{ + std::u16string phoneNum = OHOS::Str8ToStr16(std::string(phoneNumber)); + std::u16string countryCode = OHOS::Str8ToStr16(""); + std::u16string formatNum = OHOS::Str8ToStr16(""); + auto errCode = OHOS::DelayedSingleton::GetInstance()->FormatPhoneNumber( + phoneNum, countryCode, formatNum); + if (errCode != TELEPHONY_ERR_SUCCESS) { + set_business_error(errCode, "formatPhoneNumber2 return error"); + } + return; +} + +::ohos::telephony::call::CallState getCallStateSync() +{ + int32_t callState = static_cast(CallStateToApp::CALL_STATE_UNKNOWN); + callState = OHOS::DelayedSingleton::GetInstance()->GetCallState(); + return static_cast<::ohos::telephony::call::CallState::key_t>(callState); +} + +bool HasCallSync() +{ + auto ret = OHOS::DelayedSingleton::GetInstance()->HasCall(); + return static_cast(ret); +} + +void onCallDetailsChange( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().callStateCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offCallDetailsChange( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().callStateCallback_.reset(); + return; +} + +void onCallEventChange(::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().callEventCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offCallEventChange( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().callEventCallback_.reset(); + return; +} + +void onCallDisconnectedCauses( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().disconnectedCauseCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offCallDisconnectedCauses( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().disconnectedCauseCallback_.reset(); + return; +} + +void onMmiCodeResult(::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().mmiCodeResultCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offMmiCodeResult( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().mmiCodeResultCallback_.reset(); + return; +} + +void onAudioDeviceChange( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().audioDeviceCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offAudioDeviceChange(::taihe::optional_view< + ::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().audioDeviceCallback_.reset(); + return; +} + +void onPostDialDelay(::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().postDialDelayCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offPostDialDelay(::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().postDialDelayCallback_.reset(); + return; +} + +void onImsCallModeChange( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().imsCallModeCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offImsCallModeChange( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().imsCallModeCallback_.reset(); + return; +} + +void onCallSessionEvent(::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().callSessionEventCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offCallSessionEvent( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().callSessionEventCallback_.reset(); + return; +} + +void onPeerDimensionsChange( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().peerDimensionsCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offPeerDimensionsChange( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().peerDimensionsCallback_.reset(); + return; +} + +void onCameraCapabilitiesChange( + ::taihe::callback_view callback) +{ + TaiheCallManager::GetInstance().RegisterCallBack(); + TaiheCallAbilityCallback::GetInstance().cameraCapabilitiesCallback_ = + ::taihe::optional>{ + std::in_place_t{}, + callback}; + return; +} + +void offCameraCapabilitiesChange( + ::taihe::optional_view<::taihe::callback> callback) +{ + TaiheCallAbilityCallback::GetInstance().cameraCapabilitiesCallback_.reset(); + return; +} +} // namespace + +// Since these macros are auto-generate, lint will cause false positive. +// NOLINTBEGIN +TH_EXPORT_CPP_API_makeCallSync(makeCallSync); +TH_EXPORT_CPP_API_makeCallSync2(makeCallSync2); +TH_EXPORT_CPP_API_HasVoiceCapability(HasVoiceCapability); +TH_EXPORT_CPP_API_formatPhoneNumberSync(formatPhoneNumberSync); +TH_EXPORT_CPP_API_formatPhoneNumberSync2(formatPhoneNumberSync2); +TH_EXPORT_CPP_API_getCallStateSync(getCallStateSync); +TH_EXPORT_CPP_API_HasCallSync(HasCallSync); +TH_EXPORT_CPP_API_onCallDetailsChange(onCallDetailsChange); +TH_EXPORT_CPP_API_offCallDetailsChange(offCallDetailsChange); +TH_EXPORT_CPP_API_onCallEventChange(onCallEventChange); +TH_EXPORT_CPP_API_offCallEventChange(offCallEventChange); +TH_EXPORT_CPP_API_onCallDisconnectedCauses(onCallDisconnectedCauses); +TH_EXPORT_CPP_API_offCallDisconnectedCauses(offCallDisconnectedCauses); +TH_EXPORT_CPP_API_onMmiCodeResult(onMmiCodeResult); +TH_EXPORT_CPP_API_offMmiCodeResult(offMmiCodeResult); +TH_EXPORT_CPP_API_onAudioDeviceChange(onAudioDeviceChange); +TH_EXPORT_CPP_API_offAudioDeviceChange(offAudioDeviceChange); +TH_EXPORT_CPP_API_onPostDialDelay(onPostDialDelay); +TH_EXPORT_CPP_API_offPostDialDelay(offPostDialDelay); +TH_EXPORT_CPP_API_onImsCallModeChange(onImsCallModeChange); +TH_EXPORT_CPP_API_offImsCallModeChange(offImsCallModeChange); +TH_EXPORT_CPP_API_onCallSessionEvent(onCallSessionEvent); +TH_EXPORT_CPP_API_offCallSessionEvent(offCallSessionEvent); +TH_EXPORT_CPP_API_onPeerDimensionsChange(onPeerDimensionsChange); +TH_EXPORT_CPP_API_offPeerDimensionsChange(offPeerDimensionsChange); +TH_EXPORT_CPP_API_onCameraCapabilitiesChange(onCameraCapabilitiesChange); +TH_EXPORT_CPP_API_offCameraCapabilitiesChange(offCameraCapabilitiesChange); +// NOLINTEND \ No newline at end of file diff --git a/frameworks/ets/taihe/src/taihe_call_ability_callback.cpp b/frameworks/ets/taihe/src/taihe_call_ability_callback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..971d94a0f72d81cefe476000c79108f2281b3c38 --- /dev/null +++ b/frameworks/ets/taihe/src/taihe_call_ability_callback.cpp @@ -0,0 +1,201 @@ +/* + * 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. + */ + +#include "taihe_call_ability_callback.h" +#include "telephony_log_wrapper.h" +#include "telephony_errors.h" +#include "util.h" + +namespace OHOS { +namespace Telephony { + +TaiheCallAbilityCallback &TaiheCallAbilityCallback::GetInstance() +{ + static TaiheCallAbilityCallback instance; + return instance; +} + +// 通话详情变化回调 +int32_t TaiheCallAbilityCallback::UpdateCallStateInfo(const CallAttributeInfo &info) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::CallAttributeOptions taiheCallAttributeInfo = + ::ohos::telephony::call::CallAttributeOptions{ + .accountNumber = "", + .speakerphoneOn = false, + .accountId = -1, + .videoState = ::ohos::telephony::call::VideoStateType::key_t::TYPE_VOICE, + .startTime = -1, + .isEcc = false, + .callType = ::ohos::telephony::call::CallType::key_t::TYPE_CS, + .callId = -1, + .callState = ::ohos::telephony::call::DetailedCallState::key_t::CALL_STATUS_IDLE, + .conferenceState = ::ohos::telephony::call::ConferenceState::key_t::TEL_CONFERENCE_IDLE, + .crsType = -1, + .originalCallType = -1, + .numberLocation = ::taihe::optional<::taihe::string>(std::in_place_t{}, "") + }; + Utils::CallAttributeInfoToTaihe(taiheCallAttributeInfo, info); + if (callStateCallback_) { + (*callStateCallback_)(taiheCallAttributeInfo); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 通话事件变化回调 +int32_t TaiheCallAbilityCallback::UpdateCallEventInfo(const CallEventInfo &info) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::CallEventOptions taiheCallEventInfo = ::ohos::telephony::call::CallEventOptions{ + .eventId = ::ohos::telephony::call::CallAbilityEventId::key_t::EVENT_DIAL_NO_CARRIER + }; + Utils::CallEventInfoToTaihe(taiheCallEventInfo, info); + if (callEventCallback_) { + (*callEventCallback_)(taiheCallEventInfo); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 通话断开原因回调 +int32_t TaiheCallAbilityCallback::UpdateDisconnectedCause(const DisconnectedDetails &details) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::DisconnectedDetails taiheDisconnectedDetails = + ::ohos::telephony::call::DisconnectedDetails{ + .reason = ::ohos::telephony::call::DisconnectedReason::key_t::UNKNOWN, + .message = "" + }; + Utils::DisconnectedDetailsToTaihe(taiheDisconnectedDetails, details); + if (disconnectedCauseCallback_) { + (*disconnectedCauseCallback_)(taiheDisconnectedDetails); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// MMI码结果回调 +int32_t TaiheCallAbilityCallback::UpdateMmiCodeResult(const MmiCodeInfo &info) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::MmiCodeResults taiheMmiCodeInfo = ::ohos::telephony::call::MmiCodeResults{ + .result = ::ohos::telephony::call::MmiCodeResult::key_t::MMI_CODE_SUCCESS, + .message = "" + }; + Utils::MmiCodeInfoToTaihe(taiheMmiCodeInfo, info); + if (mmiCodeResultCallback_) { + (*mmiCodeResultCallback_)(taiheMmiCodeInfo); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 音频设备变化回调 +int32_t TaiheCallAbilityCallback::UpdateAudioDeviceInfo(const AudioDeviceInfo &info) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::AudioDeviceCallbackInfo taiheAudioDeviceInfo = + ::ohos::telephony::call::AudioDeviceCallbackInfo{ + .audioDeviceList = ::taihe::array<::ohos::telephony::call::AudioDevice>{}, + .currentAudioDevice = ::ohos::telephony::call::AudioDevice{ + .deviceType = ::ohos::telephony::call::AudioDeviceType::key_t::DEVICE_EARPIECE, + .address = ::taihe::optional<::taihe::string>(std::in_place_t{}, ""), + .deviceName = ::taihe::optional<::taihe::string>(std::in_place_t{}, "") + }, + .isMuted = false + }; + Utils::AudioDeviceInfoToTaihe(taiheAudioDeviceInfo, info); + if (audioDeviceCallback_) { + (*audioDeviceCallback_)(taiheAudioDeviceInfo); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 拨号后延迟回调 +int32_t TaiheCallAbilityCallback::UpdatePostDialDelay(const std::string &str) +{ + std::lock_guard lock(callbackMutex_); + if (postDialDelayCallback_) { + (*postDialDelayCallback_)(::taihe::string_view(str)); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// IMS通话模式变化回调 +int32_t TaiheCallAbilityCallback::UpdateImsCallModeInfo(const CallMediaModeInfo &info) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::ImsCallModeInfo taiheCallMediaModeInfo = ::ohos::telephony::call::ImsCallModeInfo{ + .callId = -1, + .result = ::ohos::telephony::call::VideoRequestResultType::key_t::TYPE_REQUEST_SUCCESS, + .isRequestInfo = false, + .imsCallMode = ::ohos::telephony::call::ImsCallMode::key_t::CALL_MODE_AUDIO_ONLY + }; + Utils::CallMediaModeInfoToTaihe(taiheCallMediaModeInfo, info); + if (imsCallModeCallback_) { + (*imsCallModeCallback_)(taiheCallMediaModeInfo); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 通话会话事件回调 +int32_t TaiheCallAbilityCallback::UpdateCallSessionEvent(const CallSessionEvent &event) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::CallSessionEvent taiheCallSessionEvent = ::ohos::telephony::call::CallSessionEvent{ + .callId = -1, + .eventId = ::ohos::telephony::call::CallSessionEventId::key_t::EVENT_CONTROL_CAMERA_FAILURE + }; + Utils::CallSessionEventToTaihe(taiheCallSessionEvent, event); + if (callSessionEventCallback_) { + (*callSessionEventCallback_)(taiheCallSessionEvent); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 对端尺寸变化回调 +int32_t TaiheCallAbilityCallback::UpdatePeerDimensions(const PeerDimensionsDetail &detail) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::PeerDimensionsDetail taihePeerDimensionsDetail = + ::ohos::telephony::call::PeerDimensionsDetail{}; + Utils::PeerDimensionsDetailToTaihe(taihePeerDimensionsDetail, detail); + if (peerDimensionsCallback_) { + (*peerDimensionsCallback_)(taihePeerDimensionsDetail); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +// 相机能力变化回调 +int32_t TaiheCallAbilityCallback::UpdateCameraCapabilities(const CameraCapabilities &capabilities) +{ + std::lock_guard lock(callbackMutex_); + ::ohos::telephony::call::CameraCapabilities taiheCameraCapabilities = ::ohos::telephony::call::CameraCapabilities{}; + Utils::CameraCapabilitiesToTaihe(taiheCameraCapabilities, capabilities); + if (cameraCapabilitiesCallback_) { + (*cameraCapabilitiesCallback_)(taiheCameraCapabilities); + return TELEPHONY_SUCCESS; + } + return TELEPHONY_ERR_FAIL; +} + +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/ets/taihe/src/taihe_call_manager.cpp b/frameworks/ets/taihe/src/taihe_call_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f76bb0f17c19fc155d1821cf7e3a7e0239873aea --- /dev/null +++ b/frameworks/ets/taihe/src/taihe_call_manager.cpp @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#include "taihe_call_manager.h" +#include "taihe_call_manager_callback.h" +#include "telephony_errors.h" +#include "telephony_log_wrapper.h" +#include "singleton.h" +#include "system_ability_definition.h" + +namespace OHOS { +namespace Telephony { + +TaiheCallManager &TaiheCallManager::GetInstance() +{ + static TaiheCallManager instance; + return instance; +} + +TaiheCallManager::TaiheCallManager() + : registerStatus_(TELEPHONY_ERR_UNINIT) +{ +} + +TaiheCallManager::~TaiheCallManager() +{ +} + +void TaiheCallManager::RegisterCallBack() +{ + if (registerStatus_ == TELEPHONY_SUCCESS) { + TELEPHONY_LOGW("you have already registered TaiheCallManager RegisterCallBack!"); + return; + } + std::unique_ptr callbackPtr = std::make_unique(); + if (callbackPtr == nullptr) { + TELEPHONY_LOGE("make_unique TaiheCallManagerCallback failed!"); + return; + } + DelayedSingleton::GetInstance()->Init(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID); + registerStatus_ = DelayedSingleton::GetInstance()->RegisterCallBack(std::move(callbackPtr)); + if (registerStatus_ != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("Taihe RegisterCallBack failed!"); + return; + } +} + +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/ets/taihe/src/taihe_call_manager_callback.cpp b/frameworks/ets/taihe/src/taihe_call_manager_callback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7052a6ea04dcc07ee1a56386029816c84dff71f5 --- /dev/null +++ b/frameworks/ets/taihe/src/taihe_call_manager_callback.cpp @@ -0,0 +1,199 @@ +/* + * 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. + */ + +#include "taihe_call_manager_callback.h" + +#include +#include "call_manager_errors.h" +#include "telephony_log_wrapper.h" +#include "taihe_call_ability_callback.h" + +namespace OHOS { +namespace Telephony { + +TaiheCallManagerCallback::TaiheCallManagerCallback() +{ +} + +TaiheCallManagerCallback::~TaiheCallManagerCallback() +{ +} + +int32_t TaiheCallManagerCallback::OnCallDetailsChange(const CallAttributeInfo &info) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateCallStateInfo(info); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("UpdateCallStateInfoHandler success! state:%{public}d, videoState:%{public}d, " + "index:%{public}d, callType:%{public}d", info.callState, info.videoState, info.index, info.callType); + } else { + TELEPHONY_LOGE("UpdateCallStateInfoHandler failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnCallEventChange(const CallEventInfo &info) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateCallEventInfo(info); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnCallEventChange success! eventId:%{public}d, phoneNum:%{public}s, " + "bundleName:%{public}s", info.eventId, info.phoneNum, info.bundleName); + } else { + TELEPHONY_LOGE("OnCallEventChange failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnCallDisconnectedCause(const DisconnectedDetails &details) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateDisconnectedCause(details); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnCallDisconnectedCause success! reason:%{public}d, message:%{public}s", + details.reason, details.message.c_str()); + } else { + TELEPHONY_LOGE("OnCallDisconnectedCause failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnReportMmiCodeResult(const MmiCodeInfo &info) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateMmiCodeResult(info); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnReportMmiCodeResult success! result:%{public}d, message:%{public}s, " + "mmiCodeType:%{public}d", info.result, info.message, info.mmiCodeType); + } else { + TELEPHONY_LOGE("OnReportMmiCodeResult failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnReportAudioDeviceChange(const AudioDeviceInfo &info) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateAudioDeviceInfo(info); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnReportAudioDeviceChange success! currentDevice:%{public}d, isMuted:%{public}d, " + "callId:%{public}d, deviceCount:%{public}zu", + info.currentAudioDevice.deviceType, info.isMuted, info.callId, info.audioDeviceList.size()); + } else { + TELEPHONY_LOGE("OnReportAudioDeviceChange failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnReportPostDialDelay(const std::string &str) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdatePostDialDelay(str); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnReportPostDialDelay success! str:%{public}s", str.c_str()); + } else { + TELEPHONY_LOGE("OnReportPostDialDelay failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnUpdateImsCallModeChange(const CallMediaModeInfo &imsCallModeInfo) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateImsCallModeInfo(imsCallModeInfo); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnUpdateImsCallModeChange success! callId:%{public}d, isRequestInfo:%{public}d, " + "result:%{public}d, callMode:%{public}d", + imsCallModeInfo.callId, imsCallModeInfo.isRequestInfo, + imsCallModeInfo.result, imsCallModeInfo.callMode); + } else { + TELEPHONY_LOGE("OnUpdateImsCallModeChange failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnCallSessionEventChange(const CallSessionEvent &callSessionEventOptions) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateCallSessionEvent(callSessionEventOptions); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnCallSessionEventChange success! callId:%{public}d, eventId:%{public}d", + callSessionEventOptions.callId, callSessionEventOptions.eventId); + } else { + TELEPHONY_LOGE("OnCallSessionEventChange failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnPeerDimensionsChange(const PeerDimensionsDetail &peerDimensionsDetail) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdatePeerDimensions(peerDimensionsDetail); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnPeerDimensionsChange success! callId:%{public}d, width:%{public}d, height:%{public}d", + peerDimensionsDetail.callId, peerDimensionsDetail.width, peerDimensionsDetail.height); + } else { + TELEPHONY_LOGE("OnPeerDimensionsChange failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnUpdateCameraCapabilities(const CameraCapabilities &cameraCapabilities) +{ + int32_t ret = TaiheCallAbilityCallback::GetInstance().UpdateCameraCapabilities(cameraCapabilities); + if (ret == TELEPHONY_SUCCESS) { + TELEPHONY_LOGI("OnUpdateCameraCapabilities success! callId:%{public}d, width:%{public}d, height:%{public}d", + cameraCapabilities.callId, cameraCapabilities.width, cameraCapabilities.height); + } else { + TELEPHONY_LOGE("OnUpdateCameraCapabilities failed! ret:%{public}d", ret); + } + return ret; +} + +int32_t TaiheCallManagerCallback::OnMeeTimeDetailsChange(const CallAttributeInfo &info) +{ + TELEPHONY_LOGI("OnMeeTimeDetailsChange"); + // 这里可以根据具体需求处理 + // 目前暂时返回成功,后续可以根据业务需求进行扩展 + return TELEPHONY_SUCCESS; +} + +int32_t TaiheCallManagerCallback::OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo) +{ + TELEPHONY_LOGI("OnReportAsyncResults reportId:%{public}d", reportId); + // 这里可以根据具体需求处理异步结果 + // 目前暂时返回成功,后续可以根据业务需求进行扩展 + return TELEPHONY_SUCCESS; +} + +int32_t TaiheCallManagerCallback::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info) +{ + TELEPHONY_LOGI("OnOttCallRequest requestId:%{public}d", requestId); + // 这里可以根据具体需求处理OTT通话请求 + // 目前暂时返回成功,后续可以根据业务需求进行扩展 + return TELEPHONY_SUCCESS; +} + +int32_t TaiheCallManagerCallback::OnCallDataUsageChange(const int64_t dataUsage) +{ + TELEPHONY_LOGI("OnCallDataUsageChange dataUsage:%{public}" PRId64, dataUsage); + // 这里可以根据具体需求处理数据使用量变化 + // 目前暂时返回成功,后续可以根据业务需求进行扩展 + return TELEPHONY_SUCCESS; +} + +int32_t TaiheCallManagerCallback::OnPhoneStateChange(int32_t numActive, int32_t numHeld, int32_t callState, + const std::string &number) +{ + TELEPHONY_LOGI("OnPhoneStateChange numActive:%{public}d, numHeld:%{public}d, " + "callState:%{public}d, number:%{public}s", numActive, numHeld, callState, number.c_str()); + // 这里可以根据具体需求处理电话状态变化 + // 目前暂时返回成功,后续可以根据业务需求进行扩展 + return TELEPHONY_SUCCESS; +} + +} // namespace Telephony +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/ets/taihe/src/util.cpp b/frameworks/ets/taihe/src/util.cpp new file mode 100644 index 0000000000000000000000000000000000000000..101cc81219ab9bd28e683b5c581f14d96c295abe --- /dev/null +++ b/frameworks/ets/taihe/src/util.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2025 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 "util.h" + +namespace OHOS { +namespace Telephony { + +void Utils::CallAttributeInfoToTaihe(::ohos::telephony::call::CallAttributeOptions& taiheCallAttributeInfo, + const CallAttributeInfo &info) +{ + taiheCallAttributeInfo.accountNumber = ::taihe::string_view(info.accountNumber); + taiheCallAttributeInfo.speakerphoneOn = info.speakerphoneOn; + taiheCallAttributeInfo.accountId = info.accountId; + taiheCallAttributeInfo.videoState = + ::ohos::telephony::call::VideoStateType::from_value(static_cast(info.videoState)); + taiheCallAttributeInfo.startTime = info.startTime; + taiheCallAttributeInfo.isEcc = info.isEcc; + taiheCallAttributeInfo.callType = + ::ohos::telephony::call::CallType::from_value(static_cast(info.callType)); + taiheCallAttributeInfo.callId = info.callId; + taiheCallAttributeInfo.callState = + ::ohos::telephony::call::DetailedCallState::from_value(static_cast(info.callState)); + taiheCallAttributeInfo.conferenceState = + ::ohos::telephony::call::ConferenceState::from_value(static_cast(info.conferenceState)); + taiheCallAttributeInfo.crsType = info.crsType; + taiheCallAttributeInfo.originalCallType = info.originalCallType; + taiheCallAttributeInfo.numberLocation = ::taihe::optional<::taihe::string>(std::in_place_t{}, info.numberLocation); +} + +void Utils::CallEventInfoToTaihe(::ohos::telephony::call::CallEventOptions& taiheCallEventInfo, + const CallEventInfo &info) +{ + taiheCallEventInfo.eventId = + ::ohos::telephony::call::CallAbilityEventId::from_value(static_cast(info.eventId)); +} + +void Utils::DisconnectedDetailsToTaihe(::ohos::telephony::call::DisconnectedDetails& taiheDisconnectedDetails, + const DisconnectedDetails &details) +{ + taiheDisconnectedDetails.reason = + ::ohos::telephony::call::DisconnectedReason::from_value(static_cast(details.reason)); + taiheDisconnectedDetails.message = ::taihe::string_view(details.message); +} + +void Utils::MmiCodeInfoToTaihe(::ohos::telephony::call::MmiCodeResults& taiheMmiCodeInfo, + const MmiCodeInfo &info) +{ + taiheMmiCodeInfo.result = ::ohos::telephony::call::MmiCodeResult::from_value(static_cast(info.result)); + taiheMmiCodeInfo.message = info.message; +} + +void Utils::AudioDeviceInfoToTaihe(::ohos::telephony::call::AudioDeviceCallbackInfo& taiheAudioDeviceInfo, + const AudioDeviceInfo &info) +{ + std::vector<::ohos::telephony::call::AudioDevice> taiheAudioDeviceList; + for (auto iter = info.audioDeviceList.begin(); iter != info.audioDeviceList.end(); ++iter) { + auto audioDevice = *iter; + ::ohos::telephony::call::AudioDevice taiheAudioDevice = ::ohos::telephony::call::AudioDevice{ + .deviceType = ::ohos::telephony::call::AudioDeviceType::from_value( + static_cast(audioDevice.deviceType)), + .address = ::taihe::optional<::taihe::string>(std::in_place_t{}, audioDevice.address), + .deviceName = ::taihe::optional<::taihe::string>(std::in_place_t{}, audioDevice.deviceName) + }; + taiheAudioDeviceList.push_back(taiheAudioDevice); + } + taiheAudioDeviceInfo.audioDeviceList = ::taihe::array<::ohos::telephony::call::AudioDevice>{taihe::copy_data_t{}, + taiheAudioDeviceList.data(), taiheAudioDeviceList.size()}; + taiheAudioDeviceInfo.currentAudioDevice = ::ohos::telephony::call::AudioDevice{ + .deviceType = ::ohos::telephony::call::AudioDeviceType::from_value( + static_cast(info.currentAudioDevice.deviceType)), + .address = ::taihe::optional<::taihe::string>(std::in_place_t{}, info.currentAudioDevice.address), + .deviceName = ::taihe::optional<::taihe::string>(std::in_place_t{}, info.currentAudioDevice.deviceName) + }; + taiheAudioDeviceInfo.isMuted = info.isMuted; +} + +void Utils::CallMediaModeInfoToTaihe(::ohos::telephony::call::ImsCallModeInfo& taiheCallMediaModeInfo, + const CallMediaModeInfo &info) +{ + taiheCallMediaModeInfo.callId = info.callId; + taiheCallMediaModeInfo.isRequestInfo = info.isRequestInfo; + taiheCallMediaModeInfo.result = + ::ohos::telephony::call::VideoRequestResultType::from_value(static_cast(info.result)); + taiheCallMediaModeInfo.imsCallMode = ::ohos::telephony::call::ImsCallMode::from_value( + static_cast(info.callMode)); +} + +void Utils::CallSessionEventToTaihe(::ohos::telephony::call::CallSessionEvent& taiheCallSessionEvent, + const CallSessionEvent &event) +{ + taiheCallSessionEvent.eventId = + ::ohos::telephony::call::CallSessionEventId::from_value(static_cast(event.eventId)); + taiheCallSessionEvent.callId = event.callId; +} + +void Utils::PeerDimensionsDetailToTaihe(::ohos::telephony::call::PeerDimensionsDetail& taihePeerDimensionsDetail, + const PeerDimensionsDetail &detail) +{ + taihePeerDimensionsDetail.callId = detail.callId; + taihePeerDimensionsDetail.width = detail.width; + taihePeerDimensionsDetail.height = detail.height; +} + +void Utils::CameraCapabilitiesToTaihe(::ohos::telephony::call::CameraCapabilities& taiheCameraCapabilities, + const CameraCapabilities &capabilities) +{ + taiheCameraCapabilities.callId = capabilities.callId; + taiheCameraCapabilities.width = capabilities.width; + taiheCameraCapabilities.height = capabilities.height; +} + +} +} \ No newline at end of file diff --git a/utils/src/motion_recognition.cpp b/utils/src/motion_recognition.cpp index 1ada7d4f0bdcde16b3e7730cddd32f8c84dabadc..7853bddeb94bc59826b92d3e748d7ad274fa1bde 100644 --- a/utils/src/motion_recognition.cpp +++ b/utils/src/motion_recognition.cpp @@ -134,6 +134,7 @@ void FlipMotionEventCallback(const Rosen::MotionSensorEvent &motionData) controlManager->MuteRinger(); TELEPHONY_LOGI("flip motion muteRinger"); } + controlManager->StopFlashRemind(); } break; case MOTION_TYPE_PICKUP: @@ -141,6 +142,9 @@ void FlipMotionEventCallback(const Rosen::MotionSensorEvent &motionData) break; } MotionRecogntion::UnsubscribePickupSensor(); + if (cotrolManager != nullptr) { + controlManager->StopFlashRemind(); + } ffrt::submit([=]() { MotionRecogntion::ReduceRingToneVolume(); }); @@ -214,6 +218,7 @@ void CloseToEarMotionEventCallback(const Rosen::MotionSensorEvent &motionData) controlManager->SetAudioDevice(device); } } + controlManager->StopFlashRemind(); break; default: break;