107 lines
2.9 KiB
C++
107 lines
2.9 KiB
C++
/*----------------------------------------------------------------------------
|
||
* Copyright (c) TJD Technologies Co., Ltd. 2025. All rights reserved.
|
||
*
|
||
* Description: TjdUiAppPhoneModel.cpp
|
||
*
|
||
* Author: luziquan@ss-tjd.com
|
||
*
|
||
* Create: 2025-08-16
|
||
*--------------------------------------------------------------------------*/
|
||
|
||
#include "TjdUiAppPhoneModel.h"
|
||
#include "NativeAbility.h"
|
||
#include "TjdPhoneService.h"
|
||
#include "TjdUiAppPhonePresenter.h"
|
||
#include "graphic_service.h"
|
||
#include "sql_setting.h"
|
||
#include "sys_config.h"
|
||
#include "TjdPhoneAudio.h"
|
||
#include "ble_api.h"
|
||
#include <cmsis_os.h>
|
||
|
||
#define ENABLE_PRINT_INFO 1
|
||
#if ENABLE_PRINT_INFO
|
||
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) // 一般信息打印宏控制
|
||
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) // 警告信息打印一般常开
|
||
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) // 错误信息打印一般常开
|
||
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__) // 调试信息打印一般常开
|
||
#else
|
||
#define static_print_info(...)
|
||
#define static_print_warn(...)
|
||
#define static_print_error(...)
|
||
#define static_print_debug(...)
|
||
#endif
|
||
|
||
extern std::vector<CallLogInfo> ReadCallLogs(void);
|
||
|
||
namespace TJD {
|
||
|
||
bool TjdUiAppPhoneModel::IsBtConnected(void)
|
||
{
|
||
bd_addr_t *btAddr = GetHfpBdAddr();
|
||
for (int i = 0; i < 6; i++) {
|
||
if (btAddr->addr[i] != 0) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
int32_t TjdUiAppPhoneModel::DialCall(const std::string &phoneNumber)
|
||
{
|
||
int ret = DialCallOut(reinterpret_cast<const unsigned char *>(phoneNumber.c_str()),
|
||
static_cast<unsigned char>(phoneNumber.size()));
|
||
if (ret != 0) {
|
||
static_print_error("DialCall failed, ret = %d", ret);
|
||
return -1;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int32_t TjdUiAppPhoneModel::SetMuteCall(bool mute)
|
||
{
|
||
// TODO: 目前没有实现,因为没有实现inband-ring模式
|
||
// bool ret = TjdPhoneAudio::GetInstance().PhoneAudioSetSpeakerMute(mute);
|
||
// if (ret != true) {
|
||
// static_print_error("SetMute failed, ret = %d", ret);
|
||
// return -1;
|
||
// }
|
||
return 0;
|
||
}
|
||
|
||
int32_t TjdUiAppPhoneModel::DialCallEnd()
|
||
{
|
||
int ret = DialCallFinish();
|
||
if (ret != 0) {
|
||
static_print_error("DialCall failed, ret = %d", ret);
|
||
return -1;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int32_t TjdUiAppPhoneModel::CallInAnswer(void)
|
||
{
|
||
int32_t ret = AnswerCallIn();
|
||
if (ret != 0) {
|
||
static_print_error("CallInReject failed, ret = %d", ret);
|
||
return -1;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int32_t TjdUiAppPhoneModel::CallInReply(void) { return 0; }
|
||
|
||
int32_t TjdUiAppPhoneModel::CallInReject(void)
|
||
{
|
||
int32_t ret = RejectCallIn();
|
||
if (ret != 0) {
|
||
static_print_error("CallInReject failed, ret = %d", ret);
|
||
return -1;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
std::vector<CallLogInfo> TjdUiAppPhoneModel::GetCallLogList(void) { return ReadCallLogs(); }
|
||
|
||
} // namespace TJD
|