From 59fc1b93e033ea62446686be84f0f8b03825f948 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AD=99=E6=98=A5=E9=98=B3?= Date: Thu, 11 Sep 2025 19:39:12 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E9=9B=B7=E9=B8=9F=20=E8=93=9D?= =?utf8?q?=E7=89=99=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BB=A5?= =?utf8?q?=E5=8F=8Appp=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/BluetoothDeviceCaseListAdapter.cpp | 13 +- .../bluetooth/src/BluetoothItemView.cpp | 24 +- .../nativeui/bluetooth/src/BluetoothModel.cpp | 30 -- .../nativeui/callerlog/src/CallerLogModel.cpp | 24 -- .../nativeui/makephone/src/CallingView.cpp | 404 ++---------------- .../phoneservice/src/PhoneService.cpp | 23 +- code/sdk/open_source/musl/include/arpa/inet.h | 2 +- code/sdk/open_source/musl/include/endian.h | 2 +- .../sdk/open_source/musl/include/netinet/in.h | 2 +- .../lwip/lwip_v2.1.3/src/netif/ppp/ipcp.c | 3 +- code/sdk/zhihui/ppp/CMakeLists.txt | 2 +- code/sdk/zhihui/ppp/example/ppp_example.c | 8 +- code/sdk/zhihui/ppp/include/ppp_at_handler.h | 12 + code/sdk/zhihui/ppp/include/ppp_config.h | 9 +- code/sdk/zhihui/ppp/src/ppp_api.c | 45 +- code/sdk/zhihui/ppp/src/ppp_at_handler.c | 62 +-- code/sdk/zhihui/ppp/src/ppp_cat1_api.c | 2 +- code/sdk/zhihui/ppp/src/ppp_power_ctl.c | 8 - code/sdk/zhihui/ppp/src/ppp_serial.c | 4 +- 19 files changed, 131 insertions(+), 548 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp index 9778aeb53..ed234cca2 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp @@ -13,9 +13,16 @@ #include "UiConfig.h" #include "bluetooth/BluetoothPresenter.h" -#ifdef SUPPORT_CAT1_HFP_AG_SERV -#include "phoneservice/include/PhoneAGService.h" -#endif +namespace OHOS { +BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::~BluetoothDeviceCaseListAdapter"); + UIView::OnClickListener *click = item->GetOnClickListener(); + if (click != nullptr) { + delete click; + click = nullptr; + } +} uint16_t BluetoothDeviceCaseListAdapter::GetCount() { diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp index 39b3a3deb..a05ca8591 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothItemView.cpp @@ -10,22 +10,14 @@ #include "UiConfig.h" #include "common/image_cache_manager.h" -#ifdef SUPPORT_CAT1_HFP_AG_SERV -#include "phoneservice/include/PhoneAGService.h" -#endif - -#include "ConfigModel.h" -#include "languagecode/LanguageInit.h" - -namespace OHOS -{ - constexpr uint16_t BUTTON_WIDTH = 351; - constexpr uint16_t BUTTON_HEIGHT = 81; - constexpr uint16_t IMAGE_WIDTH = 81; - constexpr uint16_t IMAGE_HEIGHT = 81; - constexpr uint16_t LABEL_HEIGHT = 81; - constexpr uint16_t LABEL_WIDTH = 189; - constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81; +namespace OHOS { +constexpr uint16_t BUTTON_WIDTH = 351; +constexpr uint16_t BUTTON_HEIGHT = 81; +constexpr uint16_t IMAGE_WIDTH = 81; +constexpr uint16_t IMAGE_HEIGHT = 81; +constexpr uint16_t LABEL_HEIGHT = 81; +constexpr uint16_t LABEL_WIDTH = 189; +constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81; #define BLUETOOTH_CONNECT_DELAY 200 #define BLUETOOTH_CONNECT_X 294 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index f02b7bb6a..cf54e84df 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -40,36 +40,6 @@ #if defined(SUPPORT_LWIP) && defined(SUPPORT_BREDR) #include "lwip_driver_adapter.h" #endif - -#ifdef SUPPORT_BLE_SERVICE -#include -#include "bleService.h" -#include "bleInstruct.h" -#endif - -//#include "hfp_hf_service.h" -#include "uiservice/include/ui_service.h" -#include "phoneservice/include/PhoneService.h" -#ifdef SUPPORT_OHOSFWK -#include "bluetooth/include/BluetoothWrapper.h" -#endif -#include "bluetooth/include/Bluetooyhpabpserver.h" -#include "bluetooth/include/BluetoothChangeBle.h" - - - -#include "ConfigModelC.h" -#include "uiservice/include/ui_service.h" -#include "vibrator_service.h" -#include "ConfigModel.h" - -#ifdef SUPPORT_CAT1_HFP_AG_SERV -#include "phoneservice/include/PhoneAGService.h" -#endif - -#include "custom_save_runtime.h" -#include "bluetooth/include/BluetoothHeadsetEvent.h" - namespace OHOS { #define BT_SPP_TASK_STACK_SIZE 2048 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp index 9f674f452..11d24831b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -14,30 +14,6 @@ #include "makephone/MainCallingPresenter.h" #include "player/PlayersModel.h" #include "graphic_service.h" -#include "notification_manager.h" -#include "osal_timer.h" -#include "cmsis_os2.h" -#include "custom_utils.h" -#include "ConfigModel.h" -#include "vibrator_service.h" -#include "custom_runtime.h" -#include "makephone/include/MainCallingView.h" - -#ifdef FD230_650 -#include "dial_sos_c.h" -#endif - -#ifdef SUPPORT_CAT1_SERVICE -#include "cat1_ctl.h" -#include "cat1_server.h" -#endif -#include "alarm/include/AlarmClockModel.h" - -#ifdef SUPPORT_CAT1_HFP_AG_SERV -#include "phoneservice/include/PhoneAGService.h" -#endif - -#include "custom_save_runtime.h" #ifdef __cplusplus extern "C" { diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/makephone/src/CallingView.cpp index 844b1af03..135df1b32 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/makephone/src/CallingView.cpp @@ -4,31 +4,11 @@ * 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 -#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; @@ -58,15 +38,11 @@ static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; 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"); @@ -92,37 +68,6 @@ 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; } @@ -141,29 +86,14 @@ bool CallingView::InitAddOnclickevent() 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() @@ -172,21 +102,18 @@ 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); @@ -195,95 +122,15 @@ bool CallingView::InitImageViewDisplay() 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; @@ -300,192 +147,44 @@ bool CallingView::InitUILabelDisplay() 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(); @@ -500,54 +199,17 @@ UIViewGroup *CallingView::CreateUIViewGroup() 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 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/phoneservice/src/PhoneService.cpp index c9f0f419c..66b889773 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/phoneservice/src/PhoneService.cpp @@ -24,29 +24,8 @@ #include "service_id_define.h" #include "graphic_mutex.h" #include "samgr_lite.h" -#include "uiservice/include/ui_service.h" -#ifdef SUPPORT_CAT1_SERVICE -#include "cat1_server_hal.h" -#include "cat1_ctl.h" -#endif -#include "bluetooth/include/BluetoothModel.h" -#include "notification_manager.h" -#include "callerlog/include/CallerLogModel.h" -#include "custom_utils.h" -// #include "BluetoothHpabpserver.h" -#include "alarm/include/AlarmClockModel.h" -#include "ConfigModel.h" -#include "custom_runtime.h" -#include "vibrator_service.h" -#include "gfx_utils/mem_api.h" -#include "ConfigModelC.h" -#include "UiConfig.h" - -#ifdef SUPPORT_CAT1_HFP_AG_SERV -#include "phoneservice/include/PhoneAGService.h" -#endif +#include "uiservice/ui_service.h" -#include "cmath" #ifdef __cplusplus extern "C" { #endif diff --git a/code/sdk/open_source/musl/include/arpa/inet.h b/code/sdk/open_source/musl/include/arpa/inet.h index 4a4b429b5..bff02ac23 100644 --- a/code/sdk/open_source/musl/include/arpa/inet.h +++ b/code/sdk/open_source/musl/include/arpa/inet.h @@ -13,7 +13,7 @@ extern "C" { #include #include -uint32_t htonl(uint32_t); +uint32_t (uint32_t); uint16_t htons(uint16_t); uint32_t ntohl(uint32_t); uint16_t ntohs(uint16_t); diff --git a/code/sdk/open_source/musl/include/endian.h b/code/sdk/open_source/musl/include/endian.h index 6e1fbf477..e08f9b469 100644 --- a/code/sdk/open_source/musl/include/endian.h +++ b/code/sdk/open_source/musl/include/endian.h @@ -78,7 +78,7 @@ static __inline uint64_t __bswap64(uint64_t __x) #endif #ifdef __XLT_OS__ -#define htonl(x) __bswap32(x) +#define (x) __bswap32(x) #define htons(x) __bswap16(x) #define ntohl(x) __bswap32(x) #define ntohs(x) __bswap16(x) diff --git a/code/sdk/open_source/musl/include/netinet/in.h b/code/sdk/open_source/musl/include/netinet/in.h index 1ff345e8f..c205a7229 100644 --- a/code/sdk/open_source/musl/include/netinet/in.h +++ b/code/sdk/open_source/musl/include/netinet/in.h @@ -73,7 +73,7 @@ extern const struct in6_addr in6addr_any, in6addr_loopback; #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 -uint32_t htonl(uint32_t); +uint32_t (uint32_t); uint16_t htons(uint16_t); uint32_t ntohl(uint32_t); uint16_t ntohs(uint16_t); diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/netif/ppp/ipcp.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/netif/ppp/ipcp.c index b7c766eb0..484726579 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/netif/ppp/ipcp.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/netif/ppp/ipcp.c @@ -63,6 +63,7 @@ #include "netif/ppp/fsm.h" #include "netif/ppp/ipcp.h" +#include "lwip/def.h" #if 0 /* UNUSED */ /* global vars */ @@ -2318,7 +2319,7 @@ static int ipcp_printpkt(const u_char *p, int plen, p += 2; GETLONG(cilong, p); printer(arg, "ms-dns%d %I", (code == CI_MS_DNS1? 1: 2), - htonl(cilong)); + lwip_htonl(cilong)); break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ diff --git a/code/sdk/zhihui/ppp/CMakeLists.txt b/code/sdk/zhihui/ppp/CMakeLists.txt index 996c72a07..9fb16f03b 100644 --- a/code/sdk/zhihui/ppp/CMakeLists.txt +++ b/code/sdk/zhihui/ppp/CMakeLists.txt @@ -68,7 +68,7 @@ set(PUBLIC_DEFINES PRINTPKT_SUPPORT=1 PPP_DEBUG=LWIP_DBG_ON PPP_INPROC_IRQ_SAFE=0 - PPP_OPTIONS=1 + # PPP_OPTIONS=1 SUPPORT_PPP_SERVICE SUPPORT_AT_PPP ) diff --git a/code/sdk/zhihui/ppp/example/ppp_example.c b/code/sdk/zhihui/ppp/example/ppp_example.c index f1b826492..85c89d676 100644 --- a/code/sdk/zhihui/ppp/example/ppp_example.c +++ b/code/sdk/zhihui/ppp/example/ppp_example.c @@ -84,9 +84,9 @@ int ppp_example_main(void) /* 等待连接建立或超时 */ uint32_t timeout = 60000; // 60秒超时 - uint32_t start_time = osal_get_tick(); + uint32_t start_time = (uint32_t)osal_get_jiffies(); - while (!g_ppp_connected && (osal_get_tick() - start_time) < timeout) { + while (!g_ppp_connected && (osal_get_jiffies() - start_time) < osal_msecs_to_jiffies(timeout)) { ppp_state_t state = ppp_get_state(); PRINT("PPP state: %d\r\n", state); @@ -139,9 +139,9 @@ int ppp_example_main(void) /* 等待断开完成 */ timeout = 10000; // 10秒超时 - start_time = osal_get_tick(); + start_time = (uint32_t)osal_get_jiffies(); - while (g_ppp_connected && (osal_get_tick() - start_time) < timeout) { + while (g_ppp_connected && (osal_get_jiffies() - start_time) < osal_msecs_to_jiffies(timeout)) { osal_msleep(100); } diff --git a/code/sdk/zhihui/ppp/include/ppp_at_handler.h b/code/sdk/zhihui/ppp/include/ppp_at_handler.h index a11586dd1..82ab07c59 100644 --- a/code/sdk/zhihui/ppp/include/ppp_at_handler.h +++ b/code/sdk/zhihui/ppp/include/ppp_at_handler.h @@ -59,6 +59,18 @@ ppp_error_t ppp_at_auto_detect_baudrate(void); */ ppp_error_t ppp_at_complete_dial_sequence(const char *apn); +/** + * @brief 挂断PPP连接 + * @return 错误码 + */ +ppp_error_t ppp_at_hangup_ppp(void); + +/** + * @brief 获取当前波特率 + * @return 当前波特率 + */ +uint32_t ppp_at_get_current_baudrate(void); + #ifdef __cplusplus } #endif diff --git a/code/sdk/zhihui/ppp/include/ppp_config.h b/code/sdk/zhihui/ppp/include/ppp_config.h index 62bb67b2c..966b9ac19 100644 --- a/code/sdk/zhihui/ppp/include/ppp_config.h +++ b/code/sdk/zhihui/ppp/include/ppp_config.h @@ -11,17 +11,17 @@ extern "C" { /* PPP配置参数 - UART配置统一使用SIO (在lwipopts_default.h中定义) */ /* SIO设备号配置 - 与SLIP区分开 */ -#define PPP_IFNUM 1 // PPP使用的SIO设备号,与SLIP_IFNUM(0)区分 +#define PPP_IFNUM 0 // PPP使用的SIO设备号,与SLIP_IFNUM(0)区分 /* UART引脚配置 - 对应SIO配置 */ #ifndef SIO_UART_TX_PIN -#define SIO_UART_TX_PIN S_AGPIO_L25 // UART TX引脚 +#define SIO_UART_TX_PIN S_MGPIO19 // UART TX引脚 #endif #ifndef SIO_UART_RX_PIN -#define SIO_UART_RX_PIN S_AGPIO_L26 // UART RX引脚 +#define SIO_UART_RX_PIN S_MGPIO20 // UART RX引脚 #endif #ifndef SIO_UART_BUS -#define SIO_UART_BUS UART_BUS_1 // UART总线 +#define SIO_UART_BUS UART_BUS_0 // UART总线 #endif /* 支持的波特率列表(自适应模式) */ @@ -34,6 +34,7 @@ extern "C" { /* AT命令配置 */ #define PPP_AT_CMD_TIMEOUT 5000 // AT命令超时时间(ms) +#define PPP_AT_DEFAULT_TIMEOUT 5000 // AT默认超时时间(ms) #define PPP_AT_CMD_MAX_LEN 256 // AT命令最大长度 #define PPP_AT_RESPONSE_MAX_LEN 1024 // AT响应最大长度 #define PPP_AT_RETRY_COUNT 3 // AT命令重试次数 diff --git a/code/sdk/zhihui/ppp/src/ppp_api.c b/code/sdk/zhihui/ppp/src/ppp_api.c index db3f2203a..9fe135d0d 100644 --- a/code/sdk/zhihui/ppp/src/ppp_api.c +++ b/code/sdk/zhihui/ppp/src/ppp_api.c @@ -1,8 +1,13 @@ #include "ppp_api.h" +#include "ppp_config.h" #include "ppp_debug.h" #include "ppp_power_ctl.h" #include "ppp_at_handler.h" // 添加AT处理头文件 #include "ppp_serial.h" // 添加串口处理头文件 +#include "ppp_lwip.h" +#include "ppp_cat1_api.h" +#include "soc_osal.h" +#include #include "osal_debug.h" #include "schedule/osal_task.h" #include "securec.h" @@ -23,20 +28,26 @@ extern void cat1_api_enable_cat1(bool isopen); */ errcode_t zhihui_ppp_init(const ppp_config_t *config) { - if (config == NULL) { + if (!config) { PPP_DEBUG_PRINT("PPP init: invalid config parameter\n"); - return ERRCODE_INVALID_PARAM; + return ERRCODE_FAIL; + } + + if (g_ppp_state != PPP_STATE_IDLE) { + PPP_DEBUG_PRINT("PPP init: already initialized, current state: %d\n", g_ppp_state); + return ERRCODE_SUCC; } - // 复制配置参数 - (void)memcpy_s(&g_ppp_config, sizeof(ppp_config_t), - config, sizeof(ppp_config_t)); + PPP_DEBUG_PRINT("Initializing PPP module with zhihui API\n"); + + // 保存用户配置 + memcpy_s(&g_ppp_config, sizeof(ppp_config_t), config, sizeof(ppp_config_t)); // 初始化电源控制 ppp_api_gpio_init(); - ppp_api_uart_init(); g_ppp_state = PPP_STATE_INITIALIZED; + PPP_DEBUG_PRINT("PPP module initialized successfully\n"); return ERRCODE_SUCC; @@ -121,29 +132,29 @@ errcode_t ppp_start_dial(void) return ERRCODE_FAIL; } - // 9. 初始化lwIP PPP协议栈 - ret = ppp_lwip_init(); + // 9. 启动PPP数据接收处理(在lwIP连接之前启动) + ret = ppp_start_data_receive_thread(); if (ret != PPP_ERR_OK) { - PPP_DEBUG_PRINT("Failed to initialize lwIP PPP: %d\n", ret); + PPP_DEBUG_PRINT("Failed to start PPP data receive thread: %d\n", ret); ppp_serial_deinit(); return ERRCODE_FAIL; } - // 10. 启动PPP连接 - ret = ppp_lwip_connect(); + // 10. 初始化lwIP PPP协议栈 + ret = ppp_lwip_init(NULL); // 使用默认配置 if (ret != PPP_ERR_OK) { - PPP_DEBUG_PRINT("Failed to start PPP connection: %d\n", ret); - ppp_lwip_deinit(); + PPP_DEBUG_PRINT("Failed to initialize lwIP PPP: %d\n", ret); + ppp_stop_data_receive_thread(); ppp_serial_deinit(); return ERRCODE_FAIL; } - // 11. 启动PPP数据接收处理 - ret = ppp_start_data_receive_thread(); + // 11. 启动PPP连接(数据接收已准备好) + ret = ppp_lwip_connect(); if (ret != PPP_ERR_OK) { - PPP_DEBUG_PRINT("Failed to start PPP data receive thread: %d\n", ret); - ppp_lwip_disconnect(); + PPP_DEBUG_PRINT("Failed to start PPP connection: %d\n", ret); ppp_lwip_deinit(); + ppp_stop_data_receive_thread(); ppp_serial_deinit(); return ERRCODE_FAIL; } diff --git a/code/sdk/zhihui/ppp/src/ppp_at_handler.c b/code/sdk/zhihui/ppp/src/ppp_at_handler.c index 970af1938..fe7fb339b 100644 --- a/code/sdk/zhihui/ppp/src/ppp_at_handler.c +++ b/code/sdk/zhihui/ppp/src/ppp_at_handler.c @@ -19,7 +19,7 @@ static struct { 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}; @@ -30,7 +30,7 @@ static const uint32_t g_fixed_baudrates[] = PPP_BAUDRATE_FIXED_LIST; /* 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命令处理模块 @@ -52,11 +52,15 @@ ppp_error_t ppp_at_handler_init(uint8_t uart_bus) 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; @@ -74,9 +78,9 @@ void ppp_at_handler_deinit(void) 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) { @@ -325,30 +329,6 @@ ppp_error_t ppp_at_complete_dial_sequence(const char *apn) 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连接 */ @@ -437,21 +417,21 @@ static ppp_error_t ppp_at_wait_response(ppp_at_response_t *response, uint32_t ti } /* 设置并启动超时定时器 */ - 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; @@ -490,7 +470,7 @@ static ppp_error_t ppp_at_wait_response(ppp_at_response_t *response, uint32_t ti } /* 停止定时器 */ - 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"); @@ -504,8 +484,8 @@ static ppp_error_t ppp_at_wait_response(ppp_at_response_t *response, uint32_t ti /** * @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 diff --git a/code/sdk/zhihui/ppp/src/ppp_cat1_api.c b/code/sdk/zhihui/ppp/src/ppp_cat1_api.c index 59b1f0e89..f45a6b208 100644 --- a/code/sdk/zhihui/ppp/src/ppp_cat1_api.c +++ b/code/sdk/zhihui/ppp/src/ppp_cat1_api.c @@ -154,7 +154,7 @@ errcode_t cat1_server_init(void) // 初始化PPP电源控制 ppp_api_gpio_init(); - ppp_api_uart_init(); + ppp_serial_init(); // 初始化运行时状态 (void)memset_s(&g_ppp_runtime, sizeof(ppp_cat1_runtime_status_t), 0, sizeof(ppp_cat1_runtime_status_t)); diff --git a/code/sdk/zhihui/ppp/src/ppp_power_ctl.c b/code/sdk/zhihui/ppp/src/ppp_power_ctl.c index e55342039..2d4c00056 100644 --- a/code/sdk/zhihui/ppp/src/ppp_power_ctl.c +++ b/code/sdk/zhihui/ppp/src/ppp_power_ctl.c @@ -120,14 +120,6 @@ void ppp_api_gpio_init(void) } } -/** - * @brief PPP模块UART初始化 - */ -void ppp_api_uart_init(void) -{ - PPP_DEBUG_PRINT("PPP UART init - delegated to ppp_serial module\n"); - // UART初始化逻辑已移至ppp_serial.c中 -} /** * @brief PPP模块设置电源引脚状态 diff --git a/code/sdk/zhihui/ppp/src/ppp_serial.c b/code/sdk/zhihui/ppp/src/ppp_serial.c index fe33775f3..70531448c 100644 --- a/code/sdk/zhihui/ppp/src/ppp_serial.c +++ b/code/sdk/zhihui/ppp/src/ppp_serial.c @@ -2,7 +2,7 @@ #include "ppp_config.h" #include "ppp_types.h" #include "ppp_debug.h" -#include "driver/uart.h" // 使用完整路径 +#include "uart.h" // 简化路径 #include "schedule/osal_task.h" #include "semaphore/osal_semaphore.h" #include "lock/osal_mutex.h" @@ -508,7 +508,7 @@ static void ppp_serial_rx_callback(const void *buffer, uint16_t length, bool rem osal_mutex_unlock(&g_serial_ctx.rx_mutex); /* 通知有数据到达 */ - osal_sem_signal(&g_serial_ctx.rx_semaphore); + osal_sem_up(&g_serial_ctx.rx_semaphore); /* 调用用户回调函数 */ if (g_serial_ctx.rx_callback) { -- 2.17.1