From a73775877265c1c64ddbed77a145a5c1b3a46ae8 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 15 May 2025 17:33:57 +0800 Subject: [PATCH] =?utf8?q?key=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/UiConfig.h | 6 +- .../nativeui/applist/src/ApplistModel.cpp | 20 --- .../flashlight/src/FlashlightPresenter.cpp | 2 +- .../nativeui/key/include/KeyInputListener.h | 5 +- .../nativeui/key/src/KeyInputListener.cpp | 154 +++++++----------- .../main/include/MainPresenterSample.h | 7 +- .../nativeui/main/src/ConnectedStatusView.cpp | 2 - .../nativeui/main/src/PullUpDownView.cpp | 4 +- .../wstp/at_service/app/app_at_process.c | 12 ++ .../syspara_lite/src/parameter_common.c | 2 +- 10 files changed, 82 insertions(+), 132 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/UiConfig.h index 9ad77d288..0f3677087 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/UiConfig.h @@ -45,9 +45,9 @@ /*主界面上下拉界面*/ typedef enum { - PULLUP,//主界面下拉 - DROPDOWN,//主界面上拉 - UNKOWNPAG, + PULLUP, //主界面下拉 + DROPDOWN, //主界面上拉 + UNKOWNPAG, }PULLPAGE; #ifndef UNUSED diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp index 03bf44dea..a11a9abd2 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -18,26 +18,6 @@ #include "ApplistPresenter.h" #include "SetDesktopView.h" #include "NativeRegisterManager.h" - - -#ifdef XTS_SUPPORT -#include "hal_tick.h" -#ifdef __cplusplus -#if __cplusplus -extern "C" -{ -#endif -#endif -#ifdef XTS_SUPPORT - extern uint8_t is_xts_test_done(void); -#endif -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif -#endif - namespace OHOS { #define FOOTBALL_PLANE_MAX_NUM 20 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/flashlight/src/FlashlightPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/flashlight/src/FlashlightPresenter.cpp index fe26aed4d..3f9c1dc65 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/flashlight/src/FlashlightPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/flashlight/src/FlashlightPresenter.cpp @@ -92,7 +92,7 @@ namespace OHOS return true; } - NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + NativeAbility::GetInstance().Back(); X_DRAG_FLAG = false; } return true; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/include/KeyInputListener.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/include/KeyInputListener.h index 44d87ef6c..86b362cd7 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/include/KeyInputListener.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/include/KeyInputListener.h @@ -21,11 +21,10 @@ public: private: KeyInputListener() {} ~KeyInputListener() {} - void OnKeyPress(void); + void OnKeyPress(const KeyEvent &event); void OnKeyLongPress(const KeyEvent& event); void OnKeyRelease(const KeyEvent& event); - void CallVolumeDipSwitchControl(uint8_t status); - void PlayerVolumeDipSwitchControl(uint8_t status); + void HandlePowerKeyPress(uint16_t currentViewId); private: int32 pressFlag{0}; int32 longPressFlag{0}; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/src/KeyInputListener.cpp index 94f098fa9..cef7b173d 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/key/src/KeyInputListener.cpp @@ -19,110 +19,86 @@ #include "MainCallingPresenter.h" #include "ApplistModel.h" -namespace OHOS { -static bool IsNotifyCallStatus() -{ - uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); - if (NotificationManager::GetInstance()->HasNotifyShowing() && - (notifyId == TOPIC_EVENT_HFP_WATCH_ACTIVE || - notifyId == TOPIC_EVENT_HFP_PHONE_TO_WATCH)) { - return true; - } else { - return false; - } -} - -static void PressAlarmNotify() -{ - uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); - if (NotificationManager::GetInstance()->HasNotifyShowing() && notifyId == TOPIC_EVENT_ALARM_RING) { - AlarmClockModel::GetInstance()->AlarmGetClockNum(); - AlarmPopUpPresenter::GetInstance()->DelayAlarmRing(); - NotificationManager::GetInstance()->StopNotify(); - } -} +#include "UiConfig.h" +#include "custom_runtime.h" +extern "C" uint8_t mcu_pms_is_screen_on(void); +extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); +namespace OHOS { KeyInputListener* KeyInputListener::GetInstance() { static KeyInputListener instance; return &instance; } -void KeyInputListener::OnKeyPress(void) +void KeyInputListener::OnKeyPress(const KeyEvent &event) { pressFlag = 1; // 短按标志 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyPress: pressFlag = %d", pressFlag); + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); + uint16 keyID = event.GetKeyId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + { + if (longPressFlag == 0 && pressFlag == 1) + { + HandlePowerKeyPress(currentViewId); + } + } return; } void KeyInputListener::OnKeyLongPress(const KeyEvent& event) { longPressFlag = 1; // 长按标志 + uint16 keyID = event.GetKeyId(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyLongPress: keyID = %d, longPressFlag = %d", keyID, longPressFlag); + return; +} +void KeyInputListener::OnKeyRelease(const KeyEvent& event) +{ + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); uint16 keyID = event.GetKeyId(); - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 - // 切换到关机/重启卡片 - NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT); - } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // 功能按键 - // 切换到查看系统版本卡片 - } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyRelease: keyID = %d, currentViewId = %d, longPressFlag = %d, pressFlag = %d", + keyID, currentViewId, longPressFlag, pressFlag); + // 重置标志 + pressFlag = 0; + longPressFlag = 0; return; } -void KeyInputListener::CallVolumeDipSwitchControl(uint8_t status) +//处理power键的按下逻辑 +void KeyInputListener::HandlePowerKeyPress(uint16_t currentViewId) { - VolumeSliderEventListener *volumeSliderEventListener = nullptr; - if (MainCallingPresenter::GetInstance() != nullptr && CallerLogModel::GetInstance()->GetCallStatus()) { - if (CallerLogModel::GetInstance()->GetVolumeScreenStatus()) { - VolumeSettingView *settingView = MainCallingPresenter::GetInstance()->GetvolumeSetting(); - if (settingView == nullptr) { - return; - } - volumeSliderEventListener = settingView->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - return; - } - volumeSliderEventListener->ChangeVolume(static_cast(status)); - } else { - MainCallingPresenter::GetInstance()->HonrsViewChange(); - CallerLogModel::GetInstance()->SetVolumeScreenStatus(true); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyPress: currentViewId = %d", currentViewId); + + if (currentViewId != VIEW_MAIN) + { + if (mcu_pms_is_screen_on()) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN,TransitionType::TRANSITION_ZOOM); } } - if (IsNotifyCallStatus()) { - if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) { - VolumeSettingView *settingView = GetvolumeSetting(); - if (settingView == nullptr) { - return; - } - volumeSliderEventListener = settingView->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - return; + else // 当前页面是主表盘 + { + if (mcu_pms_is_screen_on()) + { + if (!MainViewSample::GetInstance()->IsMainClockPage()) + { + if(MainViewSample::GetInstance()->IsPullUpViewPage() == PULLUP) + { + MainViewSample::GetInstance()->HandOnKeyEventSwitchMainPullDownView(); + } + MainViewSample::GetInstance()->SwitchToClockPage(); //当前页面为主表盘的其他页面时,切换回主表盘页面 } - volumeSliderEventListener->ChangeVolume(static_cast(status)); - } else { - HonrsViewChange(); - NotificationManager::GetInstance()->SetVolumeScreenStatus(true); - } - } -} - -void KeyInputListener::OnKeyRelease(const KeyEvent& event) -{ - uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); - uint16 keyID = event.GetKeyId(); - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 - if (longPressFlag == 0 && pressFlag == 1) { // 短按电源键 - if (currentViewId == VIEW_MAEKPHONE_SAMPLE || - NotificationManager::GetInstance()->GetWatchCallStatus()) { // 音量卡片 - // 音量+ - CallVolumeDipSwitchControl(VOLUMEUP); - } else if (currentViewId != VIEW_MAIN) { // 主表盘 - PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); - } else { - PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 - if (!MainViewSample::GetInstance()->IsMainClockPage()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面 - MainViewSample::GetInstance()->SwitchToClockPage(); - } else { + else + { + if (uapi_dev_runtime_get_lock_status()) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK); + } + else + { if (ApplistModel::GetInstance().GetCurrentStyle() == AppListStyle::WATERFALL_STYLE) { NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ENTER_WATERFALL); } else { @@ -131,21 +107,11 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event) } } } - } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // 功能按键 - if (longPressFlag == 0 && pressFlag == 1) { // 短按功能键 - if (currentViewId == VIEW_MAEKPHONE_SAMPLE || - NotificationManager::GetInstance()->GetWatchCallStatus()) { // 音量卡片 - // 音量- - CallVolumeDipSwitchControl(VOLUMEDOWN); - } else { - // 切换到用户配置的快捷卡片 - } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Screen is off"); } } - - pressFlag = 0; - longPressFlag = 0; - return; } bool KeyInputListener::OnKeyAct(UIView& view, const KeyEvent& event) @@ -156,7 +122,7 @@ bool KeyInputListener::OnKeyAct(UIView& view, const KeyEvent& event) switch (state) { case InputDevice::STATE_PRESS: // 短按 - OnKeyPress(); + OnKeyPress(event); break; #ifdef __LITEOS_M__ case InputDevice::STATE_LONG_PRESS: // 长按 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainPresenterSample.h index d544024bd..5b4a2ad6e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainPresenterSample.h @@ -49,10 +49,8 @@ static constexpr const char *DROPDOWN_CLICK_SAVEELE = static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; // ���ֻ� -static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = - "connectedstatusbackgroundbutton"; // ����״̬��ť -static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = - "connectedstatusviewclosebutton"; // ����״̬��ͼ�Ĺرհ�ť +static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = "connectedstatusbackgroundbutton"; // 下拉界面的连接状态按钮视图ID +static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = "connectedstatusviewclosebutton"; // 下拉连接界面的关闭按钮视图ID constexpr uint16_t VERTICAL_STATUS = 1; constexpr uint16_t HORIZONTAL_STATUS = 0; @@ -117,7 +115,6 @@ private: void SetCompassRotate(void); void OpenCompassSensor(void); void CloseCompassSensor(void); - KeyInputListener *keyActListener_{nullptr}; uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; int64_t playerCurrentTime_{0}; int64_t playerMusicDuration_{0}; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/ConnectedStatusView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/ConnectedStatusView.cpp index 51cf38498..9fe460cd5 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/ConnectedStatusView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/ConnectedStatusView.cpp @@ -286,9 +286,7 @@ namespace OHOS return false; } CloseButton->SetPosition(118, 340, 230, 80); -#ifdef FD230_650 CloseButton->SetViewId(CONNECTEDSTATUSVIEWCLOSEBUTTON); -#endif CloseButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); CloseButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); UIView::OnClickListener *listener = static_cast(MainPresenterSample::GetInstance()); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/PullUpDownView.cpp index c6c4099e5..f764cc6ca 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/PullUpDownView.cpp @@ -267,9 +267,7 @@ namespace OHOS } } connectedStatusBackgroundButton->SetPosition(153, 10, 160, 50); -#ifdef FD230_650 connectedStatusBackgroundButton->SetViewId(CONNECTEDSTATUSBACKGROUNDBUTTON); -#endif connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); connectedStatusBackgroundButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED); @@ -895,7 +893,7 @@ namespace OHOS } // bool isCharging = get_charge_stat(); // 获取充电状态 - bool isCharging = true; + bool isCharging = false; if (isCharging) { diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index b12ef2117..b8f53242c 100644 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -2340,6 +2340,18 @@ static uint32_t mcu_pms_get_screen_state(uint8_t *para, uint32_t para_len) wstp_print("app get screen state = %s . \r\n", state==SCREEN_ON?"on":"off"); return ERRCODE_SUCC; } + +uint8_t mcu_pms_is_screen_on(void) +{ + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + screen_state_t state = display_api->get_screen_state(); + wstp_print("app get screen state = %u, on is %u, off is %u. \r\n", state, SCREEN_ON, SCREEN_OFF); + if( state == SCREEN_ON){ + return 1; + }else{ + return 0; + } +} #endif #ifdef FT_DONGLE diff --git a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/parameter_common.c b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/parameter_common.c index e58aff1e7..6cb6b64f0 100644 --- a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/parameter_common.c +++ b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/parameter_common.c @@ -31,7 +31,7 @@ #define BUILD_TYPE "release" #define BUILD_USER "luozheng" #define BUILD_HOST "linux" -#define BUILD_TIME "20250508"//ci处本来是和真正的编译时间一致的,当下写死,因为后面提交的时候也要求必须一致。动态是我们平时release的状态,这个功能以后添加 +#define BUILD_TIME "20250514"//ci处本来是和真正的编译时间一致的,当下写死,因为后面提交的时候也要求必须一致。动态是我们平时release的状态,这个功能以后添加 #define BUILD_ROOTHASH "default" #define HASH_LENGTH 32 -- 2.17.1