* @Author: luozheng 1732036298@qq.com
* @Date: 2024-07-18 14:55:27
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-12-06 17:26:44
+ * @LastEditTime: 2024-12-24 18:54:47
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
*/
#include "ui_service.h"
#include "dial_sos_c.h"
#include "broadcast_feature.h"
+#include "notification_manager.h"
#define SAVEMODE 0
#define DEBUGOUTPUT 1
#define VOLUME_50 50
#define VOLUME_100 100
+ //处理闹钟或者查找手表通知
+ static bool HandleAlarmOrFindWatchNotify()
+ {
+ uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
+ if (NotificationManager::GetInstance()->HasNotifyShowing() && (notifyId == TOPIC_EVENT_ALARM_RING || notifyId == TOPIC_EVENT_FIND_WATCH))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleAlarmOrFindWatchNotify:notifyId = %d", notifyId);
+ return true;
+ }
+ return false;
+ }
+
RebootAndShutdownModel::RebootAndShutdownModel() {}
RebootAndShutdownModel::~RebootAndShutdownModel() {}
static void HandlePowerKeyLongPress(void)
{
+ if (HandleAlarmOrFindWatchNotify())
+ return;
GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyLongPressCallBack));
}
static void HandFuncKeyOnLongPress(void)
{
+ if (HandleAlarmOrFindWatchNotify())
+ return;
// GraphicService::GetInstance()->PostGraphicEvent(std::bind(SOSKeyLongPress));
SOSKeyLongPress();
}
bool RebootAndShutdownModel::RegisterFuncKeyLongPressEvent(void)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyLongPressEvent");
- int32_t ret = uapi_button_register_event_cb(SOSKeyLongPress, BUTTON1_LONGPRESS_2S);
+ int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S);
if (ret != ERRCODE_SUCC)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret);
static void HandleFuncKeyDoubleClick(void)
{
+ if (HandleAlarmOrFindWatchNotify())
+ return;
GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyDoubleClickCallBack));
}
class AlarmViewEventListener : public OHOS::UIView::OnClickListener,
public OHOS::UIView::OnLongPressListener,
public OHOS::UIView::OnTouchListener,
+ public RootView::OnKeyActListener,
public OHOS::UIView::OnDragListener {
public:
AlarmViewEventListener();
{
return true;
}
-
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override
+ {
+ return true;
+ }
static uint8_t pre_screen_status;
};
}; // namespace OHOS
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-25 17:31:19
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-12-18 15:22:38
+ * @LastEditTime: 2024-12-24 17:51:31
* @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
*/
#ifndef FIND_WATCH_NOTIFICATION_H
void OnRewindToComplete();
};
- class FindWatchViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener
+ class FindWatchViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener,public RootView::OnKeyActListener
{
public:
static FindWatchViewEventListener &GetInstance(void);
bool OnRelease(UIView &view, const ReleaseEvent &event) override;
bool OnDrag(UIView &view, const DragEvent &event);
bool OnDragEnd(UIView &view, const DragEvent &event) override;
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override
+ {
+ return true;
+ }
const char *GetPath();
/* 订阅事件设定优先级 */
const PriorityMapper PRI_MAPPER[] = {
- {TOPIC_EVENT_ALARM_RING, PRIORITY_TWO},
+ {TOPIC_EVENT_ALARM_RING, PRIORITY_ONE},
{TOPIC_EVENT_ON_TIME,PRIORITY_TWO},
{TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO},
{TOPIC_EVENT_ACTIVITY_UPDATE,PRIORITY_TWO},
// The alarm notification is not displayed if the incoming call notification is already being processed
if (CheckPriority(topic)) {
// AlarmClockModel::GetInstance()->PopInterPlayMusic();
- AlarmViewEventListener::GetInstance()->PopAlarmRing();
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ // AlarmViewEventListener::GetInstance()->PopAlarmRing();
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast<uint16_t>(topic), true);
} else {
// just delay the alarm
constexpr int16_t DELAY_LABEL_FONT = 25;
uint8_t AlarmViewEventListener::pre_screen_status = 0;//屏幕之前的状态
+ static OHOS::RootView::OnKeyActListener *g_onKeyActListener = nullptr;
void StopNotifyCallback()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NoOperateCallback popalarm_time = %d",popalarm_time);
if (popalarm_time <= 0)
{
- AlarmViewEventListener::GetInstance()->CancelAlarmRing();
+ // AlarmViewEventListener::GetInstance()->CancelAlarmRing();
+ NotificationManager::GetInstance()->StopNotify();
}
else
{
g_alarmView->Add(g_StopBtn);
/* -------------------------------------------------------------------------- */
StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING, NOTIFY_ONE_SECOND);
- ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
+
+ AlarmViewEventListener::GetInstance()->PopAlarmRing(); //闹钟响铃
+ g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener();
+ RootView::GetInstance()->SetOnKeyActListener(AlarmViewEventListener::GetInstance());
AlarmViewEventListener::pre_screen_status = uapi_dev_runtime_get_screen_always_on_status();//获取闹钟弹窗之前是否是长亮屏状态
if(!AlarmViewEventListener::pre_screen_status)
{
if (g_alarmView != nullptr)
{
- DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+ AlarmViewEventListener::GetInstance()->CancelAlarmRing();//取消闹钟响铃
g_alarmView->RemoveAll();
if (g_mainLable != nullptr)
{
delete g_StopBtn;
g_StopBtn = nullptr;
}
+ RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener);
RootView::GetInstance()->Remove(g_alarmView);
- delete g_alarmView;
+ delete g_alarmView;
g_alarmView = nullptr;
if(!AlarmViewEventListener::pre_screen_status) //如果闹钟弹窗之前不是长亮屏状态,就取消闹钟弹窗设置的常亮屏
{
{
if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0)
{
- CancelAlarmRing();
+ // CancelAlarmRing();
+ NotificationManager::GetInstance()->StopNotify();
}
}
return true;
if (strcmp(view.GetViewId(), ALARM_IMAGE_STOP) == 0) // 点击停止闹钟响铃
{
// AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
- CancelAlarmRing();
+ // CancelAlarmRing();
+ NotificationManager::GetInstance()->StopNotify();
}
return true;
}
DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
AlarmClockModel::GetInstance()->CancelAlarmRing();
- NotificationManager::GetInstance()->StopNotify();
+ // NotificationManager::GetInstance()->StopNotify();
//如果闹钟铃声停止播放成功,记录该事件
uapi_save_runtime_log(RUNTIME_LOG_RING_PLAY_STOP_ALARM);//TOOD*
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-25 17:33:47
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-12-18 15:23:13
+ * @LastEditTime: 2024-12-24 18:09:10
* @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp
* @details:实现查找手表的功能一般需要手表和智能手机之间的配合,通常是通过手机上的应用(App)或其他设备发送指令给手表,触发手表的查找功能。
* 以下是基本的实现步骤:
UIViewGroup *FindWatchGroupView{nullptr};
UIButton *FindWatchButton{nullptr};
uint8_t FindWatchViewEventListener::pre_screen_status = 0;//屏幕之前的状态
+ static OHOS::RootView::OnKeyActListener *g_onKeyActListener = nullptr;
FindWatchViewEventListener::FindWatchViewEventListener()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::FindWatchViewEventListener");
FindWatchViewEventListener::GetInstance().FindWatch_StartTimer(700);
FindWatchViewEventListener::GetInstance().SetScreenBrightness();
+ g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener();
+ RootView::GetInstance()->SetOnKeyActListener(&FindWatchViewEventListener::GetInstance());
+
FindWatchViewEventListener::pre_screen_status = uapi_dev_runtime_get_screen_always_on_status();//获取查找手表之前是否是长亮屏状态
if(!FindWatchViewEventListener::pre_screen_status)
{
delete FindWatchButton;
FindWatchButton = nullptr;
+ RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener);
RootView::GetInstance()->Remove(FindWatchGroupView);
delete FindWatchGroupView;