From 40956abb535ae0f8117cf53debac2d2d541cd3db Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 24 Aug 2024 15:11:15 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=94=AE=E6=8B=A6?= =?utf8?q?=E6=88=AA=E5=8A=9F=E8=83=BD(=E7=9B=AE=E5=89=8D=E5=8F=AA=E5=9C=A8?= =?utf8?q?function=E9=94=AE=E5=8F=8C=E5=87=BB=E6=B7=BB=E5=8A=A0)=EF=BC=8C?= =?utf8?q?=E8=8B=A5intercept=5Fslice=5Fids=E6=95=B0=E7=BB=84=E4=B8=AD?= =?utf8?q?=E6=9C=89=E7=BB=99=E5=AE=9A=E7=9A=84VIEWID=E5=88=99=E4=B8=8D?= =?utf8?q?=E8=A7=A6=E5=8F=91=E8=AF=A5=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/RebootAndShutdownModel.cpp | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index d3a7c6563..2f89e3b17 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:55:27 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-22 20:02:18 + * @LastEditTime: 2024-08-24 14:48:41 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp */ @@ -24,6 +24,15 @@ extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); namespace OHOS { + static uint16_t intercept_slice_ids[] = { + VIEW_INVALID, + VIEW_SAVEBAT, // 省电模式界面 + VIEW_BLOOD_CHECK, // 血氧检测界面 + VIEW_HEART_CHECK, // 心率检测界面 + VIEW_TRAININGCRAD, // 训练控制卡片 + VIEW_TEST, // 产测测试界面 + }; + RebootAndShutdownModel::RebootAndShutdownModel() {} RebootAndShutdownModel::~RebootAndShutdownModel() {} @@ -91,12 +100,6 @@ namespace OHOS GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyLongPressCallBack)); } - static void SOSKeyLongPress(void) - { - start_SOS_phone_dail(); - } - - /*注册电源键的长按事件*/ bool RebootAndShutdownModel::RegisterPowerKeyLongPressEvent(void) { @@ -107,12 +110,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret); return false; } - ret = uapi_button_register_event_cb(SOSKeyLongPress, BUTTON1_LONGPRESS_8S); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret); - return false; - } return true; } @@ -274,19 +271,24 @@ namespace OHOS } } + static void SOSKeyLongPress(void) + { + start_SOS_phone_dail(); + } + static void HandFuncKeyOnLongPress(void) { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyOnLongPressCallBack)); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(SOSKeyLongPress)); } - /*注册功能键的长按(2s)事件*/ + /*注册功能键的长按(8s)事件*/ bool RebootAndShutdownModel::RegisterFuncKeyLongPressEvent(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyLongPressEvent"); - int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S); + int32_t ret = uapi_button_register_event_cb(SOSKeyLongPress, BUTTON1_LONGPRESS_8S); if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event error, ret = %d", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret); return false; } return true; @@ -381,6 +383,14 @@ namespace OHOS return; } + uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + for (uint16_t i = 0; i < sizeof(intercept_slice_ids) / sizeof(intercept_slice_ids); i++) + { + if (intercept_slice_ids[i] == current_slice_id) + { + return; + } + } const power_display_svr_api_t *display_api = power_display_svr_get_api(); if (!display_api) { @@ -438,7 +448,7 @@ namespace OHOS RegisterPowerKeyDoubleClickEvent(); RegisterPowerKeyLongPressEvent(); RegisterFuncKeyPressEvent(); - // RegisterFuncKeyLongPressEvent(); + RegisterFuncKeyLongPressEvent(); // RegisterFuncKeyClickEvent(); RegisterFuncKeyDoubleClickEvent(); } -- 2.17.1