From 4a7e8d9ebeaaa202e5777fdbfff65a772cfb00ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=AA=E6=B2=B9=E6=B1=89?= Date: Thu, 11 Sep 2025 17:09:32 +0800 Subject: [PATCH] modify arkts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 猪油汉 --- .../taihe/src/ohos.telephony.call.impl.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp b/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp index 6de25910..d520ac05 100644 --- a/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp +++ b/frameworks/ets/taihe/src/ohos.telephony.call.impl.cpp @@ -29,9 +29,22 @@ using namespace taihe; using namespace OHOS::Telephony; namespace { +const int32_t TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID = 4005; +class CallManagerClientInitializer { +public: + CallManagerClientInitializer() + { + static bool isInit = false; + if (!isInit) { + OHOS::DelayedSingleton::GetInstance()->Init(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID); + isInit = true; + } + } +}; void makeCallSync(::taihe::string_view phoneNumber) { + CallManagerClientInitializer init; auto errCode = OHOS::DelayedSingleton::GetInstance()->MakeCall(std::string(phoneNumber)); if (errCode != TELEPHONY_ERR_SUCCESS) { set_business_error(errCode, "makeCall return error"); @@ -41,6 +54,7 @@ void makeCallSync(::taihe::string_view phoneNumber) void makeCallSync2(uintptr_t context, ::taihe::string_view phoneNumber) { + CallManagerClientInitializer init; auto errCode = OHOS::DelayedSingleton::GetInstance()->MakeCall(std::string(phoneNumber)); if (errCode != TELEPHONY_ERR_SUCCESS) { set_business_error(errCode, "makeCall2 return error"); @@ -50,6 +64,7 @@ void makeCallSync2(uintptr_t context, ::taihe::string_view phoneNumber) bool HasVoiceCapability() { + CallManagerClientInitializer init; auto ret = OHOS::DelayedSingleton::GetInstance()->HasVoiceCapability(); return static_cast(ret); } @@ -57,6 +72,7 @@ bool HasVoiceCapability() void formatPhoneNumberSync( ::taihe::string_view phoneNumber, ::ohos::telephony::call::NumberFormatOptions const& options) { + CallManagerClientInitializer init; std::u16string phoneNum = OHOS::Str8ToStr16(std::string(phoneNumber)); std::u16string countryCode = OHOS::Str8ToStr16(std::string(options.countryCode)); std::u16string formatNum = OHOS::Str8ToStr16(""); @@ -70,6 +86,7 @@ void formatPhoneNumberSync( void formatPhoneNumberSync2(::taihe::string_view phoneNumber) { + CallManagerClientInitializer init; std::u16string phoneNum = OHOS::Str8ToStr16(std::string(phoneNumber)); std::u16string countryCode = OHOS::Str8ToStr16(""); std::u16string formatNum = OHOS::Str8ToStr16(""); @@ -83,6 +100,7 @@ void formatPhoneNumberSync2(::taihe::string_view phoneNumber) ::ohos::telephony::call::CallState getCallStateSync() { + CallManagerClientInitializer init; int32_t callState = static_cast(CallStateToApp::CALL_STATE_UNKNOWN); callState = OHOS::DelayedSingleton::GetInstance()->GetCallState(); return static_cast<::ohos::telephony::call::CallState::key_t>(callState); @@ -90,6 +108,7 @@ void formatPhoneNumberSync2(::taihe::string_view phoneNumber) bool HasCallSync() { + CallManagerClientInitializer init; auto ret = OHOS::DelayedSingleton::GetInstance()->HasCall(); return static_cast(ret); } -- Gitee