From 04cb175a323d8bf6bd8db7ed13df808ef584e1c4 Mon Sep 17 00:00:00 2001 From: cheng Date: Tue, 6 Aug 2024 16:27:55 +0800 Subject: [PATCH] =?utf8?q?=E6=9F=A5=E6=89=BE=E6=89=8B=E8=A1=A8=E9=97=AA?= =?utf8?q?=E5=B1=8F=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/notify/findwatch_notification.h | 5 +- .../src/notify/findwatch_notification.cpp | 86 ++++++++++++------- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h index 520642183..952a266ad 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h @@ -74,7 +74,9 @@ namespace OHOS int FindWatchRingPlayerStat(void); bool GetFindWatchNotifyFlag(void); void SetFindWatchNotifyFlag(bool flag); - void SetVibrationAndScreenBrightness(bool state); + void SetVibration(void); + void SetLCDFlicker(bool state); + void SetScreenBrightness(void); void ResumeScreenBrightness(void); void FindWatch_StartTimer(int interval = 500); @@ -99,7 +101,6 @@ namespace OHOS AudioInterrupt interrupt; const char *RingMusicName = "/music/ring/findwatch.mp3"; bool FindWatchNotifyFlag{false}; // 判断是查找手表, 由notify生成界面 - int brightnessValue{51}; bool X_DRAG_FLAG{false}; }; } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp index da2afcec6..e8732b468 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp @@ -37,6 +37,9 @@ #include "ConfigModel.h" #include #include +#include "../../../../../../../middleware/services/gui/uikit/ui/interfaces/innerkits/dock/vibrator_manager.h" +extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType); + namespace OHOS { UIViewGroup *FindWatchGroupView{nullptr}; @@ -121,31 +124,39 @@ namespace OHOS return FindWatchNotifyFlag; } - /*设置100%亮度且手表震动*/ - void FindWatchViewEventListener::SetVibrationAndScreenBrightness(bool state) + void FindWatchViewEventListener::SetVibration(void) + { + if(true == ConfigModel::GetInstance()->GetDnotdisturb()) + { + return; + } + + if(nullptr != FindWatchGroupView) + { + custom_VibratorFunc(OHOS::VibratorType::VIBRATOR_TYPE_ONE); + } + } + + void FindWatchViewEventListener::SetLCDFlicker(bool state) + { + if(nullptr != FindWatchGroupView) + { + FindWatchGroupView->SetStyle(STYLE_BACKGROUND_COLOR, state ? 0xff000000 : 0xffffffff); + FindWatchGroupView->Invalidate(); + } + } + + void FindWatchViewEventListener::SetScreenBrightness(void) { const power_display_svr_api_t *display_api = power_display_svr_get_api(); if (display_api) { - if (state) - { - /*100%亮度*/ - int max_brightness_value = 255; - if (display_api->set_brightness(max_brightness_value) != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindWatchViewEventListener] set_brightness fail!!"); - return; - } - } - else + /*100%亮度*/ + int max_brightness_value = 255; + if (display_api->set_brightness(max_brightness_value) != ERRCODE_SUCC) { - /*20%亮度*/ - int min_brightness_value = 51; - if (display_api->set_brightness(min_brightness_value) != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindWatchViewEventListener] set_brightness fail!!"); - return; - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindWatchViewEventListener] set_brightness fail!!"); + return; } } } @@ -153,12 +164,15 @@ namespace OHOS /*恢复屏幕亮度*/ void FindWatchViewEventListener::ResumeScreenBrightness(void) { - brightnessValue = ConfigModel::GetInstance()->GetBrightness(); const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (display_api->set_brightness(brightnessValue) != ERRCODE_SUCC) + if (display_api) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindWatchViewEventListener] set_brightness fail!"); - return; + int brightnessValue = ConfigModel::GetInstance()->GetBrightness(); + if (display_api->set_brightness(brightnessValue) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindWatchViewEventListener] resume_brightness fail!"); + return; + } } } @@ -300,6 +314,12 @@ namespace OHOS { int32_t timeout = -1; SendMsgToUIService(SCREEN_TURN_ON_TO_UI, 0, &timeout, sizeof(int32_t)); // 亮屏操作 + + if(true == ConfigModel::GetInstance()->GetDnotdisturb()) + { + return; + } + // 将"开启查找手表铃声"任务发布到异步线程 GraphicService::GetInstance()->PostGraphicEvent( std::bind(&FindWatchViewEventListener::FindWatchRingPlayStart, &FindWatchViewEventListener::GetInstance(), path)); @@ -312,15 +332,9 @@ namespace OHOS static void FindWatch_TimerCallbackProc(int data) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindWatch_TimerCallbackProc"); - if (findwatch_time) - { - findwatch_time = true; - } - else - { - findwatch_time = false; - } - FindWatchViewEventListener::GetInstance().SetVibrationAndScreenBrightness(findwatch_time ? true : false); + findwatch_time = !findwatch_time; + FindWatchViewEventListener::GetInstance().SetVibration(); + FindWatchViewEventListener::GetInstance().SetLCDFlicker(findwatch_time); } /* @@ -367,6 +381,7 @@ namespace OHOS g_timer = NULL; return; } + return; } @@ -440,6 +455,9 @@ namespace OHOS FindWatchGroupView->Add(FindWatchButton); } + FindWatchViewEventListener::GetInstance().FindWatch_StartTimer(700); + FindWatchViewEventListener::GetInstance().SetScreenBrightness(); + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeFindWatchView); return FindWatchGroupView; } @@ -461,6 +479,8 @@ namespace OHOS delete FindWatchGroupView; FindWatchGroupView = nullptr; } + + FindWatchViewEventListener::GetInstance().ResumeScreenBrightness(); } /* ----------------------- FindWatchRingPlayerListener ---------------------- */ -- 2.17.1