From: luozheng <1732036298@qq.com> Date: Mon, 29 Apr 2024 09:28:13 +0000 (+0800) Subject: 拨号视图修改,已测试通过sim卡拨号成功但发现喇叭不出声 X-Git-Tag: release_V1.2.70_20241020_135402~1123^2~5 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=d75bcac4a4b5cd1c3e62536f332702aa717ca1c0;p=mirrors%2FFD230.git 拨号视图修改,已测试通过sim卡拨号成功但发现喇叭不出声 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h index 7f21805c1..6f995e328 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h @@ -11,6 +11,7 @@ namespace OHOS class PhoneCallView; class PhoneCallPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { @@ -33,6 +34,7 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h index 97c709738..e63653e33 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h @@ -11,6 +11,7 @@ namespace OHOS class PhoneDirPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { public: @@ -29,6 +30,8 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h index 76fadc395..394ade7a1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-28 09:58:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 09:24:21 + * @LastEditTime: 2024-04-29 16:21:03 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h */ #ifndef TELEPHONY_INIT_INTERFACE_H @@ -15,6 +15,8 @@ #include "components/ui_image_view.h" #include "iostream" #include "UiConfig.h" +#include "gfx_utils/mem_check.h" +#define DUMPMEMORY 0 namespace OHOS { @@ -31,10 +33,15 @@ namespace OHOS static constexpr const char *PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE = "/user/res/Phone/Telephone/FrequentlyContacted.bin"; // 常用联系人按钮icon图片 static constexpr const char *PNG_TELEPHONELINE_IMAGE = "/user/res/Phone/Telephone/TelephoneLine.bin"; // 线 + // 拨号方式 + static constexpr uint8_t DIALINGMETHOD_USINGWATCHSIM = 1; // 手表SIM卡拨号 + static constexpr uint8_t DIALINGMETHOD_USINGPHONE = 0; // 手机拨号 + class TelephonyInitInterface { public: - static bool X_DRAG_FLAG; // 水平拖拽标志 + static bool X_DRAG_FLAG; // 水平拖拽标志 + static uint8_t DIALINGMETHOD; // 拨号方式 typedef struct { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp index 6d44a9a6d..0b676f405 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 10:01:43 + * @LastEditTime: 2024-04-29 16:18:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/DialingMethodPresenter.cpp */ #include "AppViewIDs.h" @@ -60,11 +60,15 @@ namespace OHOS if (curViewId == USINGWATCHSIMBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGWATCHSIM; // 手表SIM卡拨号 + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } else if (curViewId == USINGPHONEBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGPHONE; // 手机拨号 + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp index 4cb20db41..82d5792a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 10:02:49 + * @LastEditTime: 2024-04-29 15:45:54 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MainPhonePresenter.cpp */ #include "AppViewIDs.h" @@ -63,13 +63,13 @@ namespace OHOS if (curViewId == DIALINGMETHODBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); } else if (curViewId == FREQUENTLYCONTACTEDBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + NativeAbility::GetInstance().EnterSlice(VIEW_PHONEDIR); } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp index 62a93c51c..97447f18a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -8,6 +8,9 @@ #include "cat1_server_hal.h" #include "PhoneService.h" #include "phone/include/PhoneCallView.h" +#include "phone/include/TelephonyInitInterface.h" +#include "common/key_code.h" +#include namespace OHOS { @@ -70,7 +73,7 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().Back(); } @@ -106,7 +109,18 @@ namespace OHOS // 拨号键 //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); //calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); - PhoneCallView::GetInstance()->container_child_SetVisible(true); + //PhoneCallView::GetInstance()->container_child_SetVisible(true); + if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGWATCHSIM) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGWATCHSIM"); + calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + } + else if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGPHONE) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGPHONE"); + DialCall((unsigned char *)phoneNumber.c_str(),phoneNumber.length()); + } + } else if (strcmp(viewId, BUTTONDEL) == 0) { @@ -184,4 +198,19 @@ namespace OHOS printf("**************************\n"); return true; } + + + bool PhoneCallPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index 772266540..496d085d4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -352,6 +352,10 @@ namespace OHOS // GetView(); GetView(); RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneCallPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void PhoneCallView::OnSetUpView() @@ -372,6 +376,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp index 95a17c77a..af177c3f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp @@ -75,7 +75,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), PHONEOFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp index 300d68352..e80cae8f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp @@ -70,7 +70,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), OFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } if (strcmp(view.GetViewId(), "button2") == 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp index cb616295f..5f6e4f308 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -7,7 +7,8 @@ #include "phone/include/PhoneDirView.h" #include "components/ui_button.h" #include "components/ui_label_button_ext.h" - +#include "common/key_code.h" +#include namespace OHOS { @@ -68,7 +69,7 @@ namespace OHOS } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().Back(); } @@ -92,4 +93,19 @@ namespace OHOS // if (strcmp(view.GetViewId(), 控件ID) == 0) return true; } + + + bool PhoneDirPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index 025024b78..e2beaf862 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -423,6 +423,10 @@ namespace OHOS RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void PhoneDirView::OnSetUpView() @@ -443,6 +447,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); return; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp index 38fdf2d7b..621910d9a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp @@ -70,7 +70,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), OFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp index aa04152f2..77e291b74 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp @@ -3,7 +3,8 @@ namespace OHOS { - bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + uint8_t TelephonyInitInterface::DIALINGMETHOD = -1; // 默认未选择任何拨号方式 TelephonyInitInterface::TelephonyInitInterface() {