* Author:
* Create: 2021-10-12
*/
-#include "makephone/include/CallingView.h"
-#include "makephone/include/MainCallingPresenter.h"
+#include "makephone/CallingView.h"
+#include "makephone/MainCallingPresenter.h"
#include "wearable_log.h"
#include "UiConfig.h"
-#include "phoneservice/include/PhoneService.h"
-#ifdef SUPPORT_CAT1_SERVICE
-#include "cat1_server.h"
-#include "cat1_server_hal.h"
-#endif
-#include "custom_utils.h"
-#include "phone/include/phoneaddressmodel.h"
-
-
-#ifdef SUPPORT_BLE_SERVICE
-#include <bleEvent.h>
-#include "bleService.h"
-#include "bleInstruct.h"
-#endif
-
-#include "ui_resource_string.h"
-
-#ifdef SUPPORT_CAT1_HFP_AG_SERV
-#include "phoneservice/include/PhoneAGService.h"
-#endif
namespace OHOS {
static constexpr uint16 MATH_ZERO = 0;
static constexpr uint16 LABEL_DISPLAY_FONE_SIZE = 40;
static CallingView *g_pMainView = nullptr;
-#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin"
-#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin"
-
CallingView::CallingView()
{
g_pMainView = this;
}
-
CallingView::~CallingView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallingView::~CallingView");
delete group;
group = nullptr;
- delete imagedial;
- imagedial = nullptr;
-
-
- delete imageheadset;
- imageheadset = nullptr;
-
- delete imageperson;
- imageperson = nullptr;
-
-
- if(dial_group)
- {
- dial_group->RemoveAll();
- for( int i=0;i<12;i++)
- {
- delete labelButton[i];
- labelButton[i]=nullptr;
- }
- delete image_line;
- image_line= nullptr;
-
-
- delete label_number;
- label_number= nullptr;
-
- delete dial_group;
- dial_group = nullptr;
- }
-
-
g_pMainView = nullptr;
}
imageMicrophone->SetOnClickListener(clickLeftListener);
imageHandUp->SetOnClickListener(clickLeftListener);
imageHorns->SetOnClickListener(clickLeftListener);
- imagedial->SetOnClickListener(clickLeftListener);
- imageheadset->SetOnClickListener(clickLeftListener);
- for( int i=0;i<12;i++)
- {
- labelButton[i]->SetOnClickListener(clickLeftListener);
- }
return true;
}
UILabel *CallingView::GetCallingDurationLabel()
{
- return currentTimes;
-}
-
-void CallingView::updataCallingname(void)
-{
- if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0)
- {
- if(CallerLogModel::GetInstance()->Getphonename().length()!=0)
- callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str());
- }
+ return callDuration;
}
bool CallingView::InitImageViewDisplay()
if (imageMicrophone == nullptr) {
return false;
}
- imageMicrophone->SetPosition(46, 207); // 30 : offset
- imageMicrophone->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH);
+ imageMicrophone->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset
+ imageMicrophone->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH);
imageMicrophone->SetTouchable(true);
imageMicrophone->SetViewId("microphoneChange");
-
-
-
group->Add(imageMicrophone);
imageHandUp = new UIImageView();
if (imageHandUp == nullptr) {
return false;
}
- imageHandUp->SetPosition(188, 340); // 30 : offset
- imageHandUp->SetSrc(PNG_230_VECTOR_IMAGE_PATH);
+ imageHandUp->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y); // 30 : offset
+ imageHandUp->SetSrc(PNG_DISSGREE_IMAGE_PATH);
imageHandUp->SetTouchable(true);
imageHandUp->SetViewId("callingHandUp");
group->Add(imageHandUp);
if (imageHorns == nullptr) {
return false;
}
- imageHorns->SetPosition(369, 207); // 30 : offset
- imageHorns->SetSrc(PNG_230_VOICE_OPEN_IMAGE_PATH);
+ imageHorns->SetPosition(IMAGE_HONRS_POSITION_X, IMAGE_HONRS_POSITION_Y); // 30 : offset
+ imageHorns->SetSrc(PNG_SOUNDBUTTON2);
imageHorns->SetTouchable(true);
imageHorns->SetViewId("volumeSwitch");
- group->Add(imageHorns);
-
- imagedial = new UIImageView();
- if (imagedial == nullptr) {
- return false;
- }
- imagedial->SetPosition(80, 296); // 30 : offset
- imagedial->SetSrc(PNG_230_DIAL_IMAGE_PATH);
- imagedial->SetTouchable(true);
- imagedial->SetViewId("dial");
- group->Add(imagedial);
-
-
- imageheadset = new UIImageView();
- if (imagedial == nullptr) {
- return false;
- }
- imageheadset->SetPosition(296, 296); // 30 : offset
-
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
- if(headset_SCO_Is_connect())
- {
- imageheadset->SetSrc(PNG_230_HEADSET_2_IIMAGE_PATH);
- imageheadset->SetViewId("callingheadset");
- }
- else if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1)
- {
- imageheadset->SetSrc(PNG_230_HEADSET_3_IIMAGE_PATH);
- imageheadset->SetViewId("callingheadset");
- }
- else
- #endif
-
- {
- imageheadset->SetSrc(PNG_230_HEADSET_1_IIMAGE_PATH);
- imageheadset->SetViewId("headset");
- }
-
-
- imageheadset->SetTouchable(true);
-
- group->Add(imageheadset);
-
- imageperson = new UIImageView();
- if (imagedial == nullptr) {
- return false;
- }
- imageperson->SetPosition(158, 158); // 30 : offset
- imageperson->SetSrc(PNG_230_PERSON_IMAGE_PATH);
- imageperson->SetTouchable(true);
- imageperson->SetViewId("imageperson");
- group->Add(imageperson);
-
- char name_buf[NAME_LEN+1]={0};
- uint8_t sex;
- if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex))
- {
- if(sex==1)
- imageperson->SetSrc(PHONE_DIR_BOY_1);
- else
- imageperson->SetSrc(PHONE_DIR_GIRL_1);
- }
-
- return true;
-}
-void CallingView::update_headset_state(uint8_t state)
-{
- if(imageheadset)
- {
- if(state)
- {
- imageheadset->SetSrc(PNG_230_HEADSET_2_IIMAGE_PATH);
- }
- else
- {
- imageheadset->SetSrc(PNG_230_HEADSET_3_IIMAGE_PATH);
- }
- }
-
+ group->Add(imageHorns);
+ return true;
}
-
-
-
UIImageView *CallingView::GetImageMicrophone()
{
return imageMicrophone;
if (callerDisplay == nullptr) {
return false;
}
- callerDisplay->SetPosition(88, 81,
- 289, 40);
+ callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y,
+ VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT);
callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
-
- char name_buf[NAME_LEN+1]={0};
- if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL))
- {
- callerDisplay->SetText(name_buf);
- }
- else
- {
- callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
- }
-
- // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone)
- updataCallingname();
-
+ callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER);
callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE);
callerDisplay->SetTextColor(Color::White());
- callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
group->Add(callerDisplay);
- // callDuration = new UILabel();
- // if (callDuration == nullptr) {
- // return false;
- // }
- // callDuration->SetPosition(194, 38,
- // 79, 35);
- // callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
- // callDuration->SetAlign(TEXT_ALIGNMENT_CENTER);
- // callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str());
- // callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- // callDuration->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff));
- // group->Add(callDuration);
-
-
- currentTimes = new UILabelExt();
+ callDuration = new UILabel();
+ if (callDuration == nullptr) {
+ return false;
+ }
+ callDuration->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y,
+ VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT);
+ callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
+ callDuration->SetAlign(TEXT_ALIGNMENT_CENTER);
+ callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str());
+ callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE);
+ callDuration->SetTextColor(Color::White());
+ group->Add(callDuration);
+
+ currentTimes = new UILabel();
if (currentTimes == nullptr) {
return false;
}
- currentTimes->SetPosition(133, 38,
- 200, 35);
+ currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y,
+ VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT);
currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER);
- currentTimes->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str());
-
-
-
-
- currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- currentTimes->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff));
+ currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_TIME_FONT_SIZE);
+ currentTimes->SetTextColor(Color::White());
group->Add(currentTimes);
return true;
}
-static char *dial_id_str[]={"1","2","3","4","5","6","7","8","9","*","0","#"};
-void CallingView::showdial(bool flag)
-{
- if(flag)
- {
- label_number->SetText("");
- dial_group->SetVisible(true);
- }
- else
- {
- dial_group->SetVisible(false);
- }
- return;
-}
-
-void CallingView::text_updata_buf(const char *buf)
-{
- #ifdef FD230_650
- if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1){
- SendDtfmStrNumberToCat1(buf[0]);
- }
- else{
- uapi_hfp_send_DTMF_CODE(buf[0]);
- }
- #endif
-
- char new_buf[16]={0};
- const char*text_buf=label_number->GetText();
- sprintf_s(new_buf,16,"%s%s",text_buf,buf);
- label_number->SetText(new_buf);
- RootView::GetInstance()->Invalidate();
-
- return;
-}
-
-
-bool CallingView::Initshowdial()
-{
- dial_group = new UIViewGroup();
- if (dial_group == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error");
- return false;
- }
- dial_group->SetPosition(MATH_ZERO, MATH_ZERO);
- dial_group->Resize(466, 466); // 454 : value
- dial_group->SetViewId("dialing");
- dial_group->SetTouchable(true);
- dial_group->SetDraggable(true);
-
- dragListener = (UIView::OnDragListener*)OHOS::MainCallingPresenter::GetInstance();
- if (dragListener == nullptr) {
-
- return false;
- }
- dial_group->SetOnDragListener(dragListener);
-
- uint8_t showdial_i=0;
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<3;j++)
- {
- if (labelButton[showdial_i] == nullptr) {
- labelButton[showdial_i] = new UILabelButton();
- }
- if(labelButton[showdial_i]==nullptr)
- {
- return false;
- }
- labelButton[showdial_i]->SetPosition(69+(j*111), 107+(i*78)); // widget's left position and top position
-
- labelButton[showdial_i]->Resize(107, 70); // widget's width and height
- labelButton[showdial_i]->SetViewId(dial_id_str[showdial_i]);// Set style
- labelButton[showdial_i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
-
- labelButton[showdial_i]->SetText(dial_id_str[showdial_i]);
- labelButton[showdial_i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
- labelButton[showdial_i]->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);
-
- dial_group->Add(labelButton[showdial_i]);
- labelButton[showdial_i]->SetVisible(true);
- showdial_i++;
- }
- }
-
- if (image_line == nullptr) {
- image_line = new UIImageView();
- }
- if(image_line == nullptr)
- {
- return false;
- }
- image_line->SetPosition(193, 25); // widget's left position and top position
- image_line->Resize(80, 8); // widget's width and height
- image_line->SetViewId("image1");// Set style
- image_line->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- image_line->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- image_line->SetStyle(STYLE_BORDER_RADIUS, 100);
-
- dial_group->Add(image_line);
- image_line->SetVisible(true);
-
- // Add Label to App
- if (label_number == nullptr) {
- label_number = new UILabel();
- }
- if(label_number == nullptr)
- {
- return false;
- }
- label_number->SetPosition(100, 43); // widget's left position and top position
- label_number->Resize(265, 60); // widget's width and height
- label_number->SetViewId("label3");// Set style
- label_number->SetStyle(STYLE_TEXT_FONT, 40);
-
- // Set additional property
- label_number->SetText("");
- label_number->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
- label_number->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- label_number->SetRollSpeed(0);
- label_number->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
- dial_group->Add(label_number);
-
- group->Add(dial_group);
- dial_group->SetVisible(false);
- return true;
-
-}
-
UIViewGroup *CallingView::CreateUIViewGroup()
{
group = new UIViewGroup();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error");
return nullptr;
}
- if (!InitUILabelDisplay()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error");
- return nullptr;
- }
- if(!Initshowdial())
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error");
- return nullptr;
- }
if (!InitAddOnclickevent()) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error");
return nullptr;
}
- return group;
-}
-
-UIViewGroup *CallingView::CreateUIViewGroup(uint8_t type)
-{
- group = new UIViewGroup();
- if (group == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::UIViewGroup::new group error");
- return nullptr;
- }
- group->SetPosition(MATH_ZERO, MATH_ZERO);
- group->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); // 454 : value
- if (!InitImageViewDisplay()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitImageViewDisplay error");
- return nullptr;
- }
if (!InitUILabelDisplay()) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error");
return nullptr;
}
- currentTimes->SetTextId(STR_CALLING); /* code */
- imageMicrophone->SetStyle(STYLE_IMAGE_OPA, 97);
-
- if(!Initshowdial())
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitUILabelDisplay error");
- return nullptr;
- }
- if (!InitAddOnclickevent()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallingView::InitAddOnclickevent error");
- return nullptr;
- }
+
return group;
}
-
}
\ No newline at end of file
uint32_t current_baudrate;
bool auto_baudrate_mode;
ppp_at_response_t last_response;
- osal_timer *at_timer;
+ osal_timer at_timer;
osal_mutex *at_mutex;
} g_at_ctx = {0};
/* AT命令响应解析 */
static bool ppp_at_parse_response(const char *response, const char *expected);
static ppp_error_t ppp_at_wait_response(ppp_at_response_t *response, uint32_t timeout);
-static void ppp_at_timeout_handler(void *arg);
+static void ppp_at_timeout_handler(unsigned long data);
/**
* @brief 初始化AT命令处理模块
return PPP_ERR_MEMORY;
}
- /* 创建定时器 */
- if (osal_timer_create(&g_at_ctx.at_timer, ppp_at_timeout_handler, NULL) != OSAL_SUCCESS) {
- PPP_DEBUG_ERROR("Failed to create AT timer");
- osal_mutex_destroy(g_at_ctx.at_mutex);
- return PPP_ERR_MEMORY;
+ // 初始化定时器
+ g_at_ctx.at_timer.handler = ppp_at_timeout_handler;
+ g_at_ctx.at_timer.data = 0;
+ g_at_ctx.at_timer.interval = PPP_AT_DEFAULT_TIMEOUT;
+
+ if (osal_timer_init(&g_at_ctx.at_timer) != OSAL_SUCCESS) {
+ PPP_DEBUG_PRINT("Failed to initialize AT timer\n");
+ g_at_ctx.initialized = false;
+ return PPP_ERR_AT_FAILED;
}
g_at_ctx.initialized = true;
return;
}
- if (g_at_ctx.at_timer) {
- osal_timer_destroy(g_at_ctx.at_timer);
- g_at_ctx.at_timer = NULL;
+ if (g_at_ctx.at_timer.handler) {
+ osal_timer_destroy(&g_at_ctx.at_timer);
+ g_at_ctx.at_timer.handler = NULL;
}
if (g_at_ctx.at_mutex) {
return PPP_ERR_OK;
}
-/**
- * @brief 发送PPP拨号命令
- */
-ppp_error_t ppp_at_dial_ppp(const char *dial_string)
-{
- if (!g_at_ctx.initialized || !dial_string) {
- return PPP_ERR_INVALID_PARAM;
- }
-
- PPP_DEBUG_INFO("Starting PPP dial: %s", dial_string);
-
- /* 发送拨号命令 */
- ppp_at_response_t response;
- ppp_error_t ret = ppp_at_send_command(dial_string, "CONNECT", PPP_DIAL_TIMEOUT, &response);
-
- if (ret != PPP_ERR_OK) {
- PPP_DEBUG_ERROR("PPP dial failed");
- return ret;
- }
-
- PPP_DEBUG_INFO("PPP dial successful, entering data mode");
- return PPP_ERR_OK;
-}
-
/**
* @brief 挂断PPP连接
*/
}
/* 设置并启动超时定时器 */
- if (osal_timer_mod(g_at_ctx.at_timer, timeout) != OSAL_SUCCESS) {
+ if (osal_timer_mod(&g_at_ctx.at_timer, timeout) != OSAL_SUCCESS) {
PPP_DEBUG_ERROR("Failed to set AT timer timeout");
return PPP_ERR_MEMORY;
}
- if (osal_timer_start(g_at_ctx.at_timer) != OSAL_SUCCESS) {
+ if (osal_timer_start(&g_at_ctx.at_timer) != OSAL_SUCCESS) {
PPP_DEBUG_ERROR("Failed to start AT timer");
return PPP_ERR_MEMORY;
}
- uint32_t start_time = osal_get_tick();
+ uint32_t start_time = (uint32_t)osal_get_jiffies();
uint32_t bytes_received = 0;
bool response_complete = false;
- while (!response_complete && (osal_get_tick() - start_time) < timeout) {
+ while (!response_complete && (osal_get_jiffies() - start_time) < osal_msecs_to_jiffies(timeout)) {
uint8_t buffer[256];
uint32_t bytes_read = 0;
}
/* 停止定时器 */
- osal_timer_stop(g_at_ctx.at_timer);
+ osal_timer_stop(&g_at_ctx.at_timer);
if (!response_complete) {
PPP_DEBUG_ERROR("AT command timeout");
/**
* @brief AT命令超时处理
*/
-static void ppp_at_timeout_handler(void *arg)
+static void ppp_at_timeout_handler(unsigned long data)
{
- (void)arg;
+ (void)data;
PPP_DEBUG_WARN("AT command timeout");
}
\ No newline at end of file