添加查找弹窗
authorluozheng <1732036298@qq.com>
Tue, 26 Mar 2024 10:30:49 +0000 (18:30 +0800)
committerluozheng <1732036298@qq.com>
Tue, 26 Mar 2024 10:30:49 +0000 (18:30 +0800)
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/msg_center/CMakeLists.txt
code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp

index 13594c3..7169457 100755 (executable)
@@ -73,6 +73,8 @@ typedef enum {
     TOPIC_EVENT_DEVICE_UNBIND,
     TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,
 #endif
+    TOPIC_EVENT_FIND_WATCH, //查找手表
+    TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找
     TOPIC_END_NUM = 20000,
 } TopicNum;
 
index 89ac13c..1df5d87 100755 (executable)
@@ -116,6 +116,7 @@ set(PRIVATE_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/activity/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/rtcservice/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/saveele/include/
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/uiservice/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/player/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include
@@ -147,6 +148,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/vendor_app/baidu/baidu_app.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp
 )
 else()
 set(SOURCES
@@ -156,6 +158,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp
 )
 endif()
 
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
new file mode 100644 (file)
index 0000000..9b931bb
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-03-25 17:31:19
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-03-26 18:03:13
+ * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
+ */
+#ifndef FIND_WATCH_NOTIFICATION_H
+#define FIND_WATCH_NOTIFICATION_H
+
+#include "BaseView.h"
+#include "audio_manager.h"
+#include "../../../../../../middleware/services/media/foundation/utils/include/source.h"
+#include "../../../../../../middleware/services/media/foundation/player/interfaces/kits/player.h"
+namespace OHOS
+{
+    UIViewGroup *CreateFindWatchView(void);
+    void FreeFindWatchView(void);
+
+    using OHOS::Media::Player;
+    using OHOS::Media::Source;
+    using namespace OHOS::Media;
+    using namespace Audio;
+    using Audio::AudioManager;
+
+    // 播放器
+    class FindWatchRingPlayerListener : public InterruptListener
+    {
+    public:
+        FindWatchRingPlayerListener() {}
+        ~FindWatchRingPlayerListener() {}
+
+        void SetOwner(std::shared_ptr<Player> player);
+        void RestFlag();
+        bool IsPaused();
+        bool IsDelayed();
+        bool IsResumed();
+        bool IsBeginStopped();
+        bool IsEndStopped();
+        void StopFindWatchRing();
+        void StartFindWatchRing();
+        void OnInterrupt(int32_t type, int32_t hint) override;
+
+    private:
+        std::shared_ptr<Player> player_{nullptr};
+        bool isPaused_{false};
+        bool isDelayed_{false};
+        bool isResumed_{false};
+        bool isBeginStopped_{false};
+        bool isEndStopped_{false};
+    };
+
+    // 播放器回调
+    class FindWatchRingPlayerCallbackImpl : public OHOS::Media::PlayerCallback
+    {
+    public:
+        FindWatchRingPlayerCallbackImpl() {}
+        ~FindWatchRingPlayerCallbackImpl() {}
+        void OnPlaybackComplete();
+        void OnError(int32_t errorType, int32_t errorCode);
+        void OnInfo(int type, int extra);
+        void OnRewindToComplete();
+    };
+
+    class FindWatchViewEventListener : public UIView::OnTouchListener
+    {
+    public:
+        static FindWatchViewEventListener &GetInstance(void);
+        void PopInterCancelMusic(void);
+        void PopInterPlayMusic(void);
+        int FindWatchRingPlayStop(void);
+        int FindWatchRingPlayStart(void);
+        int FindWatchRingPlayerInit(char *RingMusicName);
+        int FindWatchRingPlayerStat(void);
+        bool GetFindWatchNotifyFlag(void);
+        void SetFindWatchNotifyFlag(bool flag);
+        bool OnRelease(UIView &view, const ReleaseEvent &event) override;
+
+    private:
+        FindWatchViewEventListener();
+        ~FindWatchViewEventListener();
+        FindWatchViewEventListener(const FindWatchViewEventListener &) = delete;
+        const FindWatchViewEventListener &operator=(const FindWatchViewEventListener &);
+        std::string uri;
+        std::shared_ptr<PlayerCallback> playerCallback{nullptr};
+        std::shared_ptr<Player> playerCtr{nullptr};
+        std::map<std::string, std::string> header;
+        std::shared_ptr<Source> source{nullptr};
+        std::shared_ptr<FindWatchRingPlayerListener> playerInterruptListener{nullptr};
+        AudioSession sessionId;
+        AudioInterrupt interrupt;
+        char *RingMusicName = "alarm.mp3";
+        bool FindWatchNotifyFlag{false}; // 判断是查找手表, 由notify生成界面
+    };
+}
+#endif
\ No newline at end of file
index 2e9846b..3dbd415 100755 (executable)
@@ -24,6 +24,7 @@
 #include "alarm_notification.h"
 #include "makephone_notification.h"
 #include "pairing_notification.h"
+#include "findwatch_notification.h"
 
 #define UN_OPACITY 255
 #define HAlf_SCREEN  2
index 1ff0341..67f75d2 100755 (executable)
@@ -83,6 +83,8 @@ const PriorityMapper g_pri_mapper[] = {
     {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO},
     {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO},
 #endif
+    {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO},
+    {TOPIC_EVENT_CANCEL_FIND_WATCH,PRIORITY_TWO},
 };
 
 static bool CheckPriority(const Topic topic)
@@ -141,6 +143,8 @@ void MsgCenterSubscribe()
     MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBIND);
     MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBINDING_REQUEST);
 #endif 
+    MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CANCEL_FIND_WATCH);
 }
 
 static OHOS::UIViewGroup* showAlarmNotify(void)
@@ -181,6 +185,12 @@ static OHOS::UIViewGroup* showDeviceUnbindingRequestNotify(void)
     return OHOS::CreateDeviceUnbindingRequestGroupView();
 }
 
+/*显示查找手表通知*/
+static OHOS::UIViewGroup* showFindWatchNotify(void)
+{
+    return OHOS::CreateFindWatchView();
+}
+
 void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -616,7 +626,7 @@ void MsgCenterNotifyDeviceUnBindProc(const Topic topic, Request* req)
     NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true);
 
 }
-
+//设备解绑请求(与新设备连接)通知
 void MsgCenterNotifyDeviceUnBindingRequestProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -632,6 +642,29 @@ void MsgCenterNotifyDeviceUnBindingRequestProc(const Topic topic, Request* req)
 }
 #endif
 
+//查找手表通知
+void MsgCenterNotifyFindWatchProc(const Topic topic, Request* req)
+{
+    unused(req);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyFindWatchProc !");
+    FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(true);
+    FindWatchViewEventListener::GetInstance().PopInterPlayMusic();//播放铃声
+    NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+    NotificationManager::GetInstance()->ShowNotify(showFindWatchNotify, (uint16_t)topic, true);
+}
+
+//取消查找手表通知
+void MsgCenterNotifyCanCelFindWatchProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(req);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyCanCelFindWatchProc !");
+    FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+    if (FindWatchViewEventListener::GetInstance().GetFindWatchNotifyFlag() == true) {
+        NotificationManager::GetInstance()->StopNotify();
+    }
+    FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(false);
+}
 /* 订阅事件通知逻辑可定制 */
 static msg_center_notify_table_t g_msg_center_notify_table[] = {
     {TOPIC_EVENT_ALARM_RING,         MsgCenterNotifyAlarmProc},
@@ -671,6 +704,8 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = {
     {TOPIC_EVENT_DEVICE_UNBIND,   MsgCenterNotifyDeviceUnBindProc},   
     {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,   MsgCenterNotifyDeviceUnBindingRequestProc},   
 #endif
+    {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
+    {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc},
 };
 
 static msg_center_notify_table_t *MsgCenterGetNotifyTblCb(uint8_t idx)
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
new file mode 100644 (file)
index 0000000..61aa3bb
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-03-25 17:33:47
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-03-26 18:25:06
+ * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp
+ * @details:实现查找手表的功能一般需要手表和智能手机之间的配合,通常是通过手机上的应用(App)或其他设备发送指令给手表,触发手表的查找功能。
+ * 以下是基本的实现步骤:
+ *1. 确保手表与手机的连接
+ 为了使手机能够控制手表,首先确保手表通过蓝牙或Wi-Fi等无线技术与智能手机连接。手表通常与智能手机配对,
+ 通信使用的是低功耗蓝牙(Bluetooth Low Energy, BLE)或传统蓝牙技术。
+ *2. 发送查找指令
+ 实现一个手机应用(App)界面,提供一个“查找手表”的按钮或命令。当用户点击这个按钮时,应用会向配对的手表发送特定的查找指令。
+ *3. 手表接收指令
+ 手表端需要有一个接收指令的模块,它能接收到手机发送的查找指令,并对该指令做出响应。
+ *4. 实现手表的查找功能
+ 手表接收到查找指令后,需要执行以下动作:
+ 间断亮屏与息屏: 设计一个程序循环,使手表的屏幕闪烁(间断地亮屏和息屏),以便用户能够通过视觉识别找到手表。
+ 播放铃声: 触发内置的扬声器播放一个持续的铃声,音量应足够大,以便用户通过声音定位手表。
+ 震动: 使用内置的震动电机产生持续或间断的震动模式,帮助用户通过触感找到手表。
+ *5. 终止查找
+ *一旦手表被找到,用户可以通过在手表上点击一个按钮或在手机应用上再次点击查找按钮来停止查找过程。这将发送一个停止查找的指令,手表收到后终止所有查找动作。
+ *技术考量
+ *安全性:** 确保只有经过授权的设备和应用能够触发查找功能,防止恶意操作。
+ *电量管理:** 查找过程中手表亮屏、播放铃声和震动可能会消耗大量电量,所以设计上应考虑电量管理,例如在低电量模式下只使用震动功能。
+ *用户友好性:** 查找功能的响应应当及时,界面简洁明了,方便用户迅速触发和取消。
+ */
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "components/ui_button.h"
+#include <iostream>
+#include "ui_service.h"
+#include <graphic_service.h>
+namespace OHOS
+{
+    UIViewGroup *FindWatchGroupView{nullptr};
+    UIButton *FindWatchButton{nullptr};
+    FindWatchViewEventListener::FindWatchViewEventListener()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::FindWatchViewEventListener");
+    }
+
+    FindWatchViewEventListener::~FindWatchViewEventListener()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::~FindWatchViewEventListener");
+    }
+
+    FindWatchViewEventListener &FindWatchViewEventListener::GetInstance(void)
+    {
+        static FindWatchViewEventListener instance;
+        return instance;
+    }
+
+    bool FindWatchViewEventListener::OnRelease(UIView &view, const ReleaseEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::OnRelease");
+        UNUSED(event);
+        if (&view == FindWatchButton) // 手表已找到
+        {
+            FindWatchRingPlayStop();
+            NotificationManager::GetInstance()->StopNotify();
+            SetFindWatchNotifyFlag(false);
+        }
+        return true;
+    }
+
+    void FindWatchViewEventListener::SetFindWatchNotifyFlag(bool flag)
+    {
+        FindWatchNotifyFlag = flag;
+    }
+
+    // 获取查找手表通知状态
+    bool FindWatchViewEventListener::GetFindWatchNotifyFlag(void)
+    {
+        return FindWatchNotifyFlag;
+    }
+
+    /*
+     * @brief 初始化查找手表播放铃声的播放器
+     * @param {char*} RingMusicName 铃声文件
+     */
+    int FindWatchViewEventListener::FindWatchRingPlayerInit(char *RingMusicName)
+    {
+        // 本地播放文件路径和状态
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RingPlayerInit start!");
+        std::string strSrcMusic("/user/music");
+        std::string tempStr("/");
+        std::string strName = RingMusicName;
+        uri = strSrcMusic + tempStr + strName;
+        // 创建 AM
+        playerCtr = std::make_shared<Player>();
+        if (playerCtr.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerCtr new fail");
+            return OHOS_FAILURE;
+        }
+        playerCallback = std::make_shared<FindWatchRingPlayerCallbackImpl>();
+        if (playerCallback.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerCallback new fail");
+            return OHOS_FAILURE;
+        }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RingPlayerInit end!");
+        return OHOS_SUCCESS;
+    }
+
+    /*
+     * @brief 准备并播放铃声
+     */
+    int FindWatchViewEventListener::FindWatchRingPlayerStat(void)
+    {
+        /* -------------------------------- 1.检查播放器实例 ------------------------------- */
+        int32_t ret;
+        int32_t state;
+        if (playerCtr.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::FindWatchRingPlayerStat playerCtr nullptr");
+            return OHOS_FAILURE;
+        }
+        playerCtr->GetPlayerState(state);
+        /* -------------------------------- 2.设置播放器回调 ------------------------------- */
+        playerCtr->SetPlayerCallback(playerCallback);
+        /* -------------------------------- 3.创建并设置音频源 -------------------------------- */
+        source = std::make_shared<Source>(uri, header);
+        if (source.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "source new fail");
+            return OHOS_FAILURE;
+        }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindWatchRing Player url:%s", uri.c_str());
+        playerCtr->SetSource(*source);
+        /* --------------------------------- 4.配置播放器 -------------------------------- */
+        playerCtr->SetAudioStreamType(AUDIO_STREAM_ALARM_CLOCK); // 设置播放器的音频流类型为闹钟音乐。
+        playerCtr->Prepare();                                    // 准备播放器对象以播放音频。
+        /* -------------------------------- 5.请求音频焦点 -------------------------------- */
+        AudioManager &amIntance = AudioManager::GetInstance();
+        sessionId = amIntance.MakeSessionId();
+        if (sessionId == AUDIO_SESSION_ID_NONE)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "session invalid");
+            return OHOS_FAILURE;
+        }
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MakeSessionId  %d", sessionId);
+        playerInterruptListener = std::make_shared<FindWatchRingPlayerListener>();
+        if (playerInterruptListener.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerInterruptListener new fail");
+            return OHOS_FAILURE;
+        }
+        playerInterruptListener->SetOwner(playerCtr);
+        interrupt = {AUDIO_STREAM_ALARM_CLOCK, sessionId, playerInterruptListener};
+        // 激活音频中断 5s超时
+        if (amIntance.ActivateAudioInterrupt(interrupt) == INTERRUPT_FAILED)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ActivateAudioInterrupt faild");
+            return OHOS_FAILURE;
+        }
+        // playerCtr->SetVolume(50, 50); // 将左声道和右声道音量都设置为50
+        playerCtr->SetAudioSessionId(sessionId);
+        // 播放
+        playerCtr->Play();
+        return OHOS_SUCCESS;
+    }
+    /*
+     * @brief 停止查找手表铃声
+     */
+    int FindWatchViewEventListener::FindWatchRingPlayStop(void)
+    {
+        int32_t ret = 0;
+        AudioManager &amIntance = AudioManager::GetInstance();
+        if (playerCtr.get() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::FindWatchRingPlayStop playerCtr nullptr");
+            return OHOS_FAILURE;
+        }
+
+        ret = playerCtr->Stop();
+        playerCtr->Reset();
+        playerCtr->Release();
+        if (amIntance.DeactivateAudioInterrupt(interrupt) != 0)
+        {
+            return OHOS_FAILURE;
+        }
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret);
+        return OHOS_SUCCESS;
+    }
+
+    /*
+     * @brief 开启查找手表铃声
+     */
+    int FindWatchViewEventListener::FindWatchRingPlayStart(void)
+    {
+        FindWatchRingPlayerInit(RingMusicName);
+        FindWatchRingPlayerStat();
+        return OHOS_SUCCESS;
+    }
+
+    /*
+     * @brief 停止铃声播放的事件
+     */
+    void FindWatchViewEventListener::PopInterCancelMusic(void)
+    {
+        SendMsgToUIService(SCREEN_TURN_OFF_TO_UI, 0, NULL, 0);
+        GraphicService::GetInstance()->PostGraphicEvent(
+            std::bind(&FindWatchViewEventListener::FindWatchRingPlayStop, &FindWatchViewEventListener::GetInstance()));
+    }
+
+    /*
+     * @brief 开始铃声播放的事件
+     */
+    void FindWatchViewEventListener::PopInterPlayMusic(void)
+    {
+        int32_t timeout = -1;
+        SendMsgToUIService(SCREEN_TURN_ON_TO_UI, 0, &timeout, sizeof(int32_t)); // 亮屏操作
+        // 将"开启查找手表铃声"任务发布到异步线程
+        GraphicService::GetInstance()->PostGraphicEvent(
+            std::bind(&FindWatchViewEventListener::FindWatchRingPlayStart, &FindWatchViewEventListener::GetInstance()));
+    }
+
+    /*
+     * @brief 创建查找手表视图
+     */
+    UIViewGroup *CreateFindWatchView(void)
+    {
+        if (FindWatchGroupView == nullptr)
+        {
+            FindWatchGroupView = new UIViewGroup();
+            if (FindWatchGroupView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateFindWatchView] FindWatchGroupView new fail!!");
+                return nullptr;
+            }
+            FindWatchGroupView->SetPosition(0, 0, 466, 466);
+            FindWatchGroupView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+            FindWatchGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+
+            FindWatchButton = new UIButton();
+            if (FindWatchButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateFindWatchView] FindWatchButton new fail!!");
+                return nullptr;
+            }
+            FindWatchButton->SetPosition(183, 183, 100, 100);
+            FindWatchButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff0000);
+            FindWatchButton->SetStyle(STYLE_BACKGROUND_OPA, 0x20);
+            const char *buttonImgSrc = "/user/res/SYSTEM_CheckOff.bin";
+            FindWatchButton->SetImageSrc(buttonImgSrc, buttonImgSrc);
+            FindWatchButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff0000, UIButton::PRESSED);
+            FindWatchButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x35, UIButton::PRESSED);
+            UIView::OnTouchListener *listener = static_cast<UIView::OnTouchListener *>(&FindWatchViewEventListener::GetInstance());
+            FindWatchButton->SetOnTouchListener(listener);
+
+            FindWatchGroupView->Add(FindWatchButton);
+        }
+
+        return FindWatchGroupView;
+    }
+
+    /*
+     * @brief 释放查找手表视图
+     */
+    void FreeFindWatchView(void)
+    {
+        if (FindWatchGroupView != nullptr)
+        {
+            FindWatchGroupView->Remove(FindWatchButton);
+
+            delete FindWatchButton;
+            FindWatchButton = nullptr;
+
+            RootView::GetInstance()->Remove(FindWatchGroupView);
+
+            delete FindWatchGroupView;
+            FindWatchGroupView = nullptr;
+        }
+    }
+
+    /* ----------------------- FindWatchRingPlayerListener ---------------------- */
+    void FindWatchRingPlayerListener::SetOwner(std::shared_ptr<Player> player)
+    {
+        player_ = player;
+    }
+
+    void FindWatchRingPlayerListener::RestFlag()
+    {
+        isPaused_ = false;
+        isDelayed_ = false;
+        isResumed_ = false;
+        isBeginStopped_ = false;
+        isEndStopped_ = false;
+    }
+
+    bool FindWatchRingPlayerListener::IsPaused()
+    {
+        return isPaused_;
+    }
+
+    bool FindWatchRingPlayerListener::IsDelayed()
+    {
+        return isDelayed_;
+    }
+
+    bool FindWatchRingPlayerListener::IsResumed()
+    {
+        return isResumed_;
+    }
+
+    bool FindWatchRingPlayerListener::IsBeginStopped()
+    {
+        return isBeginStopped_;
+    }
+
+    bool FindWatchRingPlayerListener::IsEndStopped()
+    {
+        return isEndStopped_;
+    }
+
+    static void Start(void)
+    {
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic();
+    }
+
+    static void Stop(void)
+    {
+        FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+    }
+
+    void FindWatchRingPlayerListener::StartFindWatchRing(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FindWatchRingPlayerListener::StopFindWatchRing] start");
+        GraphicService::GetInstance()->PostGraphicEvent(Start);
+    }
+
+    void FindWatchRingPlayerListener::StopFindWatchRing(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FindWatchRingPlayerListener::StopFindWatchRing] start");
+        GraphicService::GetInstance()->PostGraphicEvent(Stop);
+    }
+
+    /*响应外部的音频中断事件*/
+    void FindWatchRingPlayerListener::OnInterrupt(int32_t type, int32_t hint)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnInterrupt go in, type %d, hint %d.", type, hint);
+        if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_PAUSE)
+        {
+            isDelayed_ = true;
+        }
+
+        if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_STOP)
+        {
+            StopFindWatchRing();
+        }
+        else if (type == INTERRUPT_TYPE_END && isDelayed_)
+        {
+            // 重新开始查找手表的音乐播放
+            StartFindWatchRing();
+            isDelayed_ = false;
+        }
+        return;
+    }
+
+    /* --------------------- FindWatchRingPlayerCallbackImpl -------------------- */
+    void FindWatchRingPlayerCallbackImpl::OnPlaybackComplete(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnPlaybackComplete");
+        FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic();
+    }
+
+    void FindWatchRingPlayerCallbackImpl::OnError(int32_t errorType, int32_t errorCode)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnError test, errorType %d, errorCode %d", errorType, errorCode);
+        // 此处实现代码处理错误事件
+    }
+
+    void FindWatchRingPlayerCallbackImpl::OnInfo(int type, int extra)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnInfo test, type %d, extra %d.", type, extra);
+        // 此处实现代码处理普通事件
+    }
+
+    void FindWatchRingPlayerCallbackImpl::OnRewindToComplete(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRewindToComplete test");
+        // 此处实现代码处理进度控制完成的事件
+    }
+
+}
\ No newline at end of file
index 6021262..4fe6130 100755 (executable)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-07 18:27:45
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-03-25 10:21:16
+ * @LastEditTime: 2024-03-25 18:23:17
  * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp
  */
 /*
@@ -33,6 +33,7 @@ void NotificationManager::FreeNotifyViews()
     FreePhoneCallView();
     FreeCallingView();
     FreeCalldialView();
+    FreeFindWatchView();
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     //Do Free notification view
 #endif