增加语音助手Slice
authorCaisking <3449750381@qq.com>
Mon, 30 Sep 2024 14:09:45 +0000 (22:09 +0800)
committerCaisking <3449750381@qq.com>
Mon, 30 Sep 2024 14:09:45 +0000 (22:09 +0800)
23 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantAnswerView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantBleView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantHfpView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantStartFailedView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantAnswerView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantBleView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantHfpView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantStartFailedView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c

index 80c57f0..9904e5e 100644 (file)
@@ -714,6 +714,16 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/safemodemanager/src/ResourceCheckAdapter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/safemodemanager/src/RepairView.cpp
 
+    #语音助手
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantAnswerView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantBleView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantHfpView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/assistant/src/AssistantStartFailedView.cpp
+
+
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp
index 3347c9d..eccae22 100644 (file)
@@ -136,7 +136,7 @@ typedef enum : uint16_t
 #endif
     VIEW_CALENDAR,  // 日历
     VIEW_SAFE_MODE, // 安全模式
-
+    VIEW_ASSISTANT, // 智能助手
     /*表盘功能相关VIEW_ID 请勿移动 请勿在下方增加slice*/
     VIEW_DIAL_FUN_ID = 200,
     VIEW_GOAL,    // 每日目标
index d118988..4adbb5c 100644 (file)
@@ -115,6 +115,7 @@ namespace OHOS
         void InitFastTrainingAttentionSlice(void);
         void InitCodedlockSlice(void);
         void InitSafeModeSlice(void);
+        void InitAssistantSlice(void);
         /* -------------------------------------------------------------------------- */
         // void InitPhoneSlice(void);
         void InitPhoneCallSlice(void);
index 9f3572e..2c3c710 100644 (file)
@@ -283,6 +283,37 @@ namespace OHOS
     static constexpr const char *PNG_TAKE_PHOTO_IMAGE_47 = APP_RES_PATH "/takephotos/cream/48.bin";  
     static constexpr const char *PNG_TAKE_PHOTO_IMAGE_48 = APP_RES_PATH "/takephotos/cream/49.bin";  
     static constexpr const char *PNG_TAKE_PHOTO_IMAGE_49 = APP_RES_PATH "/takephotos/cream/50.bin";
+    /*语音助手*/  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_0 = APP_RES_PATH "/assistant/assistant_gif/assistant_01.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_1 = APP_RES_PATH "/assistant/assistant_gif/assistant_02.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_2 = APP_RES_PATH "/assistant/assistant_gif/assistant_03.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_3 = APP_RES_PATH "/assistant/assistant_gif/assistant_04.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_4 = APP_RES_PATH "/assistant/assistant_gif/assistant_05.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_5 = APP_RES_PATH "/assistant/assistant_gif/assistant_06.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_6 = APP_RES_PATH "/assistant/assistant_gif/assistant_07.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_7 = APP_RES_PATH "/assistant/assistant_gif/assistant_08.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_8 = APP_RES_PATH "/assistant/assistant_gif/assistant_09.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_9 = APP_RES_PATH "/assistant/assistant_gif/assistant_10.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_10 = APP_RES_PATH "/assistant/assistant_gif/assistant_11.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_11 = APP_RES_PATH "/assistant/assistant_gif/assistant_12.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_12 = APP_RES_PATH "/assistant/assistant_gif/assistant_13.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_13 = APP_RES_PATH "/assistant/assistant_gif/assistant_14.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_14 = APP_RES_PATH "/assistant/assistant_gif/assistant_15.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_15 = APP_RES_PATH "/assistant/assistant_gif/assistant_16.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_16 = APP_RES_PATH "/assistant/assistant_gif/assistant_17.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_17 = APP_RES_PATH "/assistant/assistant_gif/assistant_18.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_18 = APP_RES_PATH "/assistant/assistant_gif/assistant_19.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_19 = APP_RES_PATH "/assistant/assistant_gif/assistant_20.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_20 = APP_RES_PATH "/assistant/assistant_gif/assistant_21.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_21 = APP_RES_PATH "/assistant/assistant_gif/assistant_22.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_22 = APP_RES_PATH "/assistant/assistant_gif/assistant_23.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_23 = APP_RES_PATH "/assistant/assistant_gif/assistant_24.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_24 = APP_RES_PATH "/assistant/assistant_gif/assistant_25.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_25 = APP_RES_PATH "/assistant/assistant_gif/assistant_26.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_26 = APP_RES_PATH "/assistant/assistant_gif/assistant_27.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_27 = APP_RES_PATH "/assistant/assistant_gif/assistant_28.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_28 = APP_RES_PATH "/assistant/assistant_gif/assistant_29.bin";  
+    static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE_29 = APP_RES_PATH "/assistant/assistant_gif/assistant_30.bin";
     /* -------------------------------------------------------------------------- */
     static constexpr const char *PNG_ALIPAY_BIND_FAILURE = APP_RES_PATH "/alipay/ALIPAY_BIND_FAILURE.bin";
     static constexpr const char *PNG_ALIPAY_BIND_SUCCESS = APP_RES_PATH "/alipay/ALIPAY_BIND_SUCCESS.bin";
@@ -522,7 +553,6 @@ namespace OHOS
     static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH "/VOICE_ASSISTANT_70.bin";
     static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH "/VOICE_ASSISTANT_71.bin";
     static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH "/APPLIST_VOCASSIST_IMAGE.bin";
-
     /* -------------------------------- 已删除的不必要图片 ------------------------------- */
     static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标
     static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin";
index 5804b38..0607ad0 100644 (file)
 /*安全模式*/
 #include "safemodemanager/include/SafeModeManagerView.h"
 #include "safemodemanager/include/SafeModeManagerPresenter.h"
+/*语音助手*/
+#include "assistant/include/AssistantView.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "assistant/include/AssistantModel.h"
 /* -------------------------------------------------------------------------- */
 #include "secondaryfunction/include/SecondaryFunctionPresenter.h"
 #include "secondaryfunction/include/SecondaryFunctionView.h"
@@ -426,6 +430,8 @@ namespace OHOS
         {VIEW_CODED_LOCK, &NativeLauncher::InitCodedlockSlice},
         /*安全模式*/
         {VIEW_SAFE_MODE, &NativeLauncher::InitSafeModeSlice},
+        /*语音助手*/
+        {VIEW_ASSISTANT, &NativeLauncher::InitAssistantSlice},
         /* -------------------------------------------------------------------------- */
         /*智能助手*/
         {VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice},
@@ -519,6 +525,7 @@ namespace OHOS
             TraingModel::GetInstance()->Init();     // 训练消息订阅
             TakephotosModel::GetInstance()->Init(); // 拍照消息订阅
             MessageModel::GetInstance().Init();     // 消息订阅监听
+            AssistantModel::GetInstance()->Init();  // 语音助手消息订阅
 
             // 初始化默认首页
             ScreenModels::GetInstance()->PreLoadAppimages();
@@ -1322,6 +1329,17 @@ namespace OHOS
         }
         NativeAbility::GetInstance().AddSliceProxy(VIEW_SAFE_MODE, safemodeView);
     }
+    //语音助手
+    void NativeLauncher::InitAssistantSlice(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitAssistantSlice");
+        SliceProxy *assistantView = new AbilitySliceProxy<AssistantView, AssistantPresenter>;
+        if (assistantView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "assistantView is nullptr");
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_ASSISTANT, assistantView);
+    }
     /* -------------------------------------------------------------------------- */
     // 查找手机
     void NativeLauncher::InitFindPhoneSlice(void)
index 4116e47..6602e79 100644 (file)
@@ -81,7 +81,7 @@ namespace OHOS
         {VIEW_MAIN_ALARM, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_DEFAULT_IMG, "闹钟", STR_ALARM, nullptr},
         {VIEW_FIND_PHONE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "查找手机", STR_FIND_PHONE, nullptr},
         {VIEW_MUSIC_PLAYER, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_DEFAULT_IMG, "音乐播放器", STR_MUSIC, nullptr},
-        {VIEW_OFFLINEVOICE, PNG_APPLIST_SMART_IMAGE, PNG_APPLIST_SMART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "语音助手", STR_VOICE_ASSISTANT, nullptr},
+        {VIEW_ASSISTANT, PNG_APPLIST_SMART_IMAGE, PNG_APPLIST_SMART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "语音助手", STR_VOICE_ASSISTANT, nullptr},
         {VIEW_SCHEDULE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "schedule", STR_SCHEDULE, nullptr},
         {VIEW_CALENDAR, PNG_APPLIST_CALENDAR_IMAGE, PNG_APPLIST_CALENDAR_IMAGE, PNG_APPLIST_DEFAULT_IMG, "日历", STR_CALENDAR, nullptr},
         {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "设置", STR_SETTINGS, nullptr},
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantAnswerView.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantAnswerView.h
new file mode 100644 (file)
index 0000000..df9088f
--- /dev/null
@@ -0,0 +1,41 @@
+
+#ifndef AssistantAnswer_VIEW_H
+#define AssistantAnswer_VIEW_H
+
+#include "BaseView.h"
+#include "UiConfig.h"
+#include "View.h"
+#include "components/ui_button.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+class AssistantAnswerView {
+public:
+  AssistantAnswerView();
+  virtual ~AssistantAnswerView();
+  static AssistantAnswerView *GetInstance(void);
+
+  UIScrollView *AssistantAnswerViewInit(void);
+  void ClearAll(void);
+
+  void InitScrollView(void);
+  void InitNoteLabel(void);
+  void InitImageAnimator(void);
+  void InitStopButton(void);
+
+private:
+  UIScrollView *scrollView{nullptr};
+  UILabelExt *notelabel{nullptr};
+  UIImageAnimatorView *imageAnimator{nullptr};
+  UILabelButtonExt *stopButton{nullptr};
+  bool initViewStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantBleView.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantBleView.h
new file mode 100644 (file)
index 0000000..94d7199
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-08-12 11:31:35
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-09-03 20:13:24
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/AssistantBleView.cpp
+ */
+#ifndef AssistantBleView_VIEW_H
+#define AssistantBleView_VIEW_H
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_button.h"
+namespace OHOS
+{
+    class AssistantBleView 
+    {
+    public:
+        AssistantBleView();
+        ~AssistantBleView();
+        UIScrollView *CreateAssistantBleView(void);
+
+    private:
+        bool CreateAssistantBleViewLabel();
+        bool CreateAssistantBleViewButton();
+        void ClearAll();
+        void get_bt_name(void);
+        UIScrollView *scrollView{nullptr};
+        UILabelExt *titleLabel{nullptr}; // 标题
+        UILabelExt *IPoneLabel{nullptr};
+        UILabelExt *AndroidLabel{nullptr};
+        UILabelExt *BTNoteLabel1{nullptr};
+        UILabelExt *BTNoteLabel2{nullptr};
+        UILabelExt *BTNoteLabel3{nullptr};
+        UILabelExt *CloseLabel{nullptr};
+        UIButton *CloseButton{nullptr};
+        UIView::OnDragListener *dragListener{nullptr};
+        uint8_t ble_name[30]{0};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantHfpView.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantHfpView.h
new file mode 100644 (file)
index 0000000..243079e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-08-10 16:23:34
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-08-10 17:42:47
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/AssistantHfpView.h
+ */
+#ifndef AssistantHfpView_VIEW_H
+#define AssistantHfpView_VIEW_H
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+
+namespace OHOS {
+class AssistantHfpView {
+public:
+  struct LabelConfig {
+    int16_t left;
+    int16_t top;
+    int16_t width;
+    int16_t height;
+    int16_t fontSize;
+    int16_t lineHeigh;
+    uint16_t textId;
+    uint8_t lineBreakMode;
+  };
+  AssistantHfpView();
+  ~AssistantHfpView();
+  UIScrollView *CreateAssistantHfpView(void);
+
+private:
+  UILabelExt *AssistantHfpViewLabelInit(LabelConfig &labelconfig);
+  bool CreateAssistantHfpViewLabel(void);
+  bool CreateAssistantHfpViewImage(void);
+  bool CreateAssistantHfpViewButton(void);
+
+  void ClearAll();
+  UIScrollView *scrollView{nullptr};
+  UILabelExt *titleLabel{nullptr}; // 标题
+  UIImageView *bluetoothImage{nullptr};
+  UIImageView *image66{nullptr};
+  UIImageView *image99{nullptr};
+  UILabelExt *noteLabel{nullptr};
+  UIButton *OkButton{nullptr};
+  UILabelExt *OkLabel{nullptr};
+  UIView::OnDragListener *dragListener{nullptr};
+};
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantModel.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantModel.h
new file mode 100644 (file)
index 0000000..beb08a0
--- /dev/null
@@ -0,0 +1,36 @@
+
+
+#ifndef Assistant_MODEL_H
+#define Assistant_MODEL_H
+
+#include <functional>
+#include <map>
+#include <string>
+#include <vector>
+
+namespace OHOS {
+
+class AssistantModel {
+public:
+  // 获取单例实例
+  AssistantModel();
+  ~AssistantModel();
+  static AssistantModel *GetInstance();
+
+  void Init();
+  //获取状态[hfp]
+  bool GetHFPStatus(void);
+  //开启语音助手[soc]
+  bool StartAssistant(void);
+  //关闭语音助手
+  void StopAssistant(void);
+
+private:
+  // 禁止拷贝构造和赋值操作
+  AssistantModel(const AssistantModel &) = delete;
+  AssistantModel &operator=(const AssistantModel &) = delete;
+};
+
+} // namespace OHOS
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantPresenter.h
new file mode 100644 (file)
index 0000000..df0defc
--- /dev/null
@@ -0,0 +1,43 @@
+
+
+#ifndef _Assistant_PRESENTER_H
+#define _Assistant_PRESENTER_H
+
+#include "AssistantView.h"
+#include "ModelListenerSample.h"
+#include "Presenter.h"
+
+namespace OHOS {
+
+static constexpr const char *WAKE_ASSISTANT = "wake_assistant";
+static constexpr const char *STOP_ASSISTANT = "stop_assistant";
+static constexpr const char *STOP_ASSISTANT_FAIL = "stop_assistant_fail";
+static constexpr const char *STOP_ASSISTANT_HFP_FAIL = "stop_assistant_hfp_fail";
+static constexpr const char *ASSISTANT_HFP_BLE = "stop_assistant_hfp_ble";
+static constexpr const char *ASSISTANT_BLE_NOTE = "assistant_ble_note";
+
+class AssistantView;
+class AssistantPresenter : public Presenter<AssistantView>,
+                           public UIView::OnClickListener,
+                           public UIView::OnDragListener,
+                           public RootView::OnKeyActListener {
+public:
+  AssistantPresenter();
+  virtual ~AssistantPresenter();
+
+  void OnStart() override;
+  void OnPause() override;
+  void OnResume() override;
+  void OnStop() override;
+
+  static AssistantPresenter *GetInstance();
+
+private:
+  // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+  bool OnClick(UIView &view, const ClickEvent &event) override;
+  bool OnDrag(UIView &view, const DragEvent &event) override;
+  bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+};
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantStartFailedView.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantStartFailedView.h
new file mode 100644 (file)
index 0000000..b752060
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-08-12 11:31:35
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-09-03 20:13:24
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/AssistantStartFailedView.cpp
+ */
+#ifndef AssistantStartFailedView_VIEW_H
+#define AssistantStartFailedView_VIEW_H
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+namespace OHOS {
+class AssistantStartFailedView {
+public:
+  AssistantStartFailedView();
+  ~AssistantStartFailedView();
+  UIScrollView *CreateAssistantStartFailedView(void);
+
+private:
+  void ClearAll();
+  UIScrollView *scrollView{nullptr};
+  UILabelExt *Label{nullptr};
+  UIImageView *ImageView{nullptr};
+  UILabelButtonExt *LabelButton = nullptr;
+};
+
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantView.h b/code/sdk/application/wearable/fd230app/nativeui/assistant/include/AssistantView.h
new file mode 100644 (file)
index 0000000..f67d0a8
--- /dev/null
@@ -0,0 +1,80 @@
+
+#ifndef ASSISTANT_VIEW_H
+#define ASSISTANT_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+#include "ui_resource_string.h"
+#include <iostream>
+#include <map>
+#include <string>
+
+#include "assistant/include/AssistantAnswerView.h"
+#include "assistant/include/AssistantBleView.h"
+#include "assistant/include/AssistantHfpView.h"
+#include "assistant/include/AssistantStartFailedView.h"
+
+namespace OHOS {
+
+typedef enum {
+  /** 主界面 */
+  ASSISTANT_MAIN_VIEW,
+  /** 功能界面 */
+  ASSISTANT_ANSWER_VIEW,
+  /** HFP 唤醒失败 */
+  ASSISTANT_HFP_FAIL_VIEW,
+  /** 蓝牙连接错误说明 */
+  ASSISTANT_BLE_NOTE_VIEW,
+  /** 启动失败 */
+  ASSISTANT_START_FAILED_VIEW,
+  /** 最大视图数,用于界限检查 */
+  MAX_ASSISTANT_VIEWID,
+} ASSISTANT_VIEWID;
+
+class AssistantPresenter;
+
+class AssistantView : public View<AssistantPresenter> {
+public:
+  AssistantView();
+  ~AssistantView();
+  static AssistantView *GetInstance(void);
+  void OnStart() override;
+  void OnSetUpView() override;
+  void OnTearDownView() override;
+  void OnStop() override;
+
+  bool ClickFunc(int16_t interface);
+  bool CheckViewParam(int16_t hideView, int16_t showView);
+  void ChangeView(int16_t hideView, int16_t showView);
+
+  bool ChangeToMainView(int16_t thisView);
+  bool ChangeToAnswerView(int16_t thisView);
+  bool ChangeToHfpView(int16_t thisView);
+  bool ChangeToBleView(int16_t thisView);
+  bool ChangeToStartFailedView(int16_t thisView);
+  UIScrollView *GetAssistantScrollView(int ViewId);
+
+  void InitView();
+
+private:
+  AssistantView *p_MianView{nullptr};
+  AssistantAnswerView *p_AnswerView{nullptr};
+  AssistantHfpView *p_HfpView{nullptr};
+  AssistantBleView *p_BleView{nullptr};
+  AssistantStartFailedView *p_StartFailedView{nullptr};
+
+private:
+  UILabelExt *noteLabel{nullptr};
+  UIButton *wakeButton{nullptr};
+
+  UIScrollView *AssistantScrollView[MAX_ASSISTANT_VIEWID]{nullptr};
+  AssistantView(AssistantView &&) = delete;
+  AssistantView &operator=(AssistantView &&) = delete;
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantAnswerView.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantAnswerView.cpp
new file mode 100644 (file)
index 0000000..db71630
--- /dev/null
@@ -0,0 +1,317 @@
+
+
+#include "UiConfig.h"
+#include "power_display_service.h"
+#include "ui_image_animator.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+
+#include "assistant/include/AssistantAnswerView.h"
+#include "assistant/include/AssistantPresenter.h"
+
+namespace OHOS {
+
+// 动态刷新设置
+static constexpr uint16_t IMAGE_SIZE_X = 396;
+static constexpr uint16_t IMAGE_SIZE_Y = 176;
+static constexpr uint16_t IMAGE_POSITION_X = 36;
+static constexpr uint16_t IMAGE_POSITION_Y = 193;
+static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SIZE = 30;
+static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SPEED = 30;
+
+static ImageAnimatorInfo g_imageAnimatorInfo_assistant[30] = {
+    {PNG_VOICE_ASSISTANT_IMAGE_0,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_1,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_2,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_3,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_4,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_5,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_6,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_7,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_8,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_9,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_10,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_11,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_12,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_13,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_14,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_15,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_16,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_17,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_18,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_19,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_20,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_21,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_22,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_23,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_24,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_25,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_26,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_27,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_28,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+    {PNG_VOICE_ASSISTANT_IMAGE_29,
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},
+     IMAGE_SIZE_X,
+     IMAGE_SIZE_Y,
+     IMG_SRC_FILE_PATH},
+};
+// 静态指针,用于获取单例实例
+static AssistantAnswerView *g_pAssistantAnswer{nullptr};
+AssistantAnswerView::AssistantAnswerView() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantAnswerView::AssistantAnswerView");
+  g_pAssistantAnswer = this; // 设置单例指针
+}
+AssistantAnswerView::~AssistantAnswerView() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantAnswerView::~AssistantAnswerView");
+  ClearAll();                   // 清理资源
+  g_pAssistantAnswer = nullptr; // 释放单例指针
+}
+AssistantAnswerView *AssistantAnswerView::GetInstance() {
+  return g_pAssistantAnswer; // 返回单例实例
+}
+void AssistantAnswerView::ClearAll() {
+
+  scrollView->RemoveAll();
+
+  delete notelabel; // 删除提示标签
+  notelabel = nullptr;
+
+  delete stopButton; // 删除按键
+  stopButton = nullptr;
+
+  if (imageAnimator) {
+    imageAnimator->Stop();
+    delete imageAnimator;
+    imageAnimator = nullptr;
+  }
+
+  delete scrollView; // 删除滚动视图
+  scrollView = nullptr;
+}
+
+UIScrollView *AssistantAnswerView::AssistantAnswerViewInit() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+    if (scrollView == nullptr) {
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                    "AssistantAnswerView::新建滚动视图失败!");
+      return nullptr; // 创建失败,返回空指针
+    }
+  }
+  // 初始化滚动视图属性
+  InitScrollView();
+
+  // 设置拖拽监听器
+  UIView::OnDragListener *dragListener =
+      static_cast<UIView::OnDragListener *>(AssistantPresenter::GetInstance());
+  if (!dragListener) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                  "AssistantPresenter::获取实例失败!");
+    return nullptr; // 获取失败,返回空指针
+  }
+  scrollView->SetOnDragListener(dragListener);
+
+  // 初始化提示标签
+  InitNoteLabel();
+
+  // 初始化动画
+  InitImageAnimator();
+
+  // 初始化按键
+  InitStopButton();
+
+  // 添加视图到滚动视图中
+
+  scrollView->Add(imageAnimator);
+  scrollView->Add(stopButton);
+  scrollView->Add(notelabel);
+
+  return scrollView; // 返回初始化后的滚动视图
+}
+
+void AssistantAnswerView::InitScrollView() {
+  // 设置滚动视图的初始位置和样式
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+  scrollView->SetScrollBlankSize(100);
+  scrollView->SetMaxScrollDistance(1000);
+  scrollView->SetThrowDrag(true);
+  scrollView->SetHorizontalScrollState(false); // 禁止水平滑动
+  // scrollView->SetVerticalScrollState(false);   // 禁止垂直滑动
+}
+
+void AssistantAnswerView::InitImageAnimator() {
+
+  imageAnimator = new UIImageAnimatorView();
+  if (imageAnimator == nullptr) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                  "AssistantAnswerView::new UIImageAnimatorView fail");
+    return;
+  }
+  imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_assistant,
+                                     DETECTION_IMAGE_ANIMATORVIEW_SIZE,
+                                     DETECTION_IMAGE_ANIMATORVIEW_SPEED);
+  imageAnimator->SetRepeat(true);
+  imageAnimator->Start();
+}
+void AssistantAnswerView::InitNoteLabel() {
+  notelabel = new UILabelExt();
+  if (!notelabel) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                  "AssistantAnswerView::新建标题失败!");
+    return;
+  }
+  // 设置标签的基本属性
+  notelabel->SetPosition(43, 100);
+  notelabel->Resize(380, 60);
+  notelabel->SetViewId("notelabel");
+  notelabel->SetStyle(STYLE_TEXT_FONT, 30);
+  notelabel->SetText("试试对我说“打电话给某人”");
+  notelabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+  notelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  notelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+void AssistantAnswerView::InitStopButton() {
+  if (stopButton == nullptr) {
+    stopButton = new UILabelButtonExt();
+    if (stopButton == nullptr) {
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stopButton new fail");
+      return;
+    }
+  }
+  stopButton->SetPosition(0, 366, 466, 100);
+  stopButton->SetViewId(STOP_ASSISTANT);
+  stopButton->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE);
+  stopButton->SetTextId(STR_STOP);
+  stopButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  stopButton->SetStyle(STYLE_LINE_HEIGHT, 35);
+  stopButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
+  UIView::OnClickListener *buttonClick =
+      static_cast<UIView::OnClickListener *>(AssistantPresenter::GetInstance());
+  if (buttonClick == nullptr) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "buttonClick new fail");
+    return;
+  }
+  stopButton->SetOnClickListener(buttonClick);
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantBleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantBleView.cpp
new file mode 100644 (file)
index 0000000..7deda15
--- /dev/null
@@ -0,0 +1,252 @@
+#include "assistant/include/AssistantBleView.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "player/include/PlayersView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <custom_utils.h>
+namespace OHOS {
+static constexpr const char *CLOSEBUTTON_VIEWID = "CLOSEButton";
+AssistantBleView::AssistantBleView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantBleView::AssistantBleView");
+}
+
+AssistantBleView::~AssistantBleView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantBleView::~AssistantBleView");
+  ClearAll();
+}
+void AssistantBleView::ClearAll() {
+
+  if (scrollView != nullptr) {
+    scrollView->RemoveAll();
+    if (titleLabel != nullptr) {
+      delete titleLabel;
+      titleLabel = nullptr;
+    }
+    if (IPoneLabel != nullptr) {
+      delete IPoneLabel;
+      IPoneLabel = nullptr;
+    }
+    if (AndroidLabel != nullptr) {
+      delete AndroidLabel;
+      AndroidLabel = nullptr;
+    }
+    if (BTNoteLabel1 != nullptr) {
+      delete BTNoteLabel1;
+      BTNoteLabel1 = nullptr;
+    }
+    if (BTNoteLabel2 != nullptr) {
+      delete BTNoteLabel2;
+      BTNoteLabel2 = nullptr;
+    }
+    if (BTNoteLabel3 != nullptr) {
+      delete BTNoteLabel3;
+      BTNoteLabel3 = nullptr;
+    }
+    if (CloseLabel != nullptr) {
+      delete CloseLabel;
+      CloseLabel = nullptr;
+    }
+    if (CloseButton != nullptr) {
+      delete CloseButton;
+      CloseButton = nullptr;
+    }
+    delete scrollView;
+    scrollView = nullptr;
+  }
+}
+
+bool AssistantBleView::CreateAssistantBleViewLabel() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "AssistantBleView::CreateAssistantBleViewLabel");
+  /* ------------------------------- titleLabel -------------------------------
+   */
+  if (titleLabel == nullptr) {
+    titleLabel = new UILabelExt();
+    if (titleLabel == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail");
+      return false;
+    }
+  }
+  titleLabel->SetPosition(83, 50, 300, 35);
+  titleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+  titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+  titleLabel->SetTextId(STR_BLUETOOTH_CONNECTION_FAILED); // 蓝牙连接失败
+  titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------- BTNoteLabel1 ------------------------------
+   */
+  if (BTNoteLabel1 == nullptr) {
+    BTNoteLabel1 = new UILabelExt();
+    if (BTNoteLabel1 == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel1 new fail");
+      return false;
+    }
+  }
+  BTNoteLabel1->SetPosition(53, 140, 360, 35);
+  BTNoteLabel1->SetStyle(STYLE_TEXT_FONT, 30);
+  BTNoteLabel1->SetStyle(STYLE_LINE_HEIGHT, 35);
+  BTNoteLabel1->SetTextId(STR_SOLUTION);
+  BTNoteLabel1->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  BTNoteLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------- IPoneLabel -------------------------------
+   */
+  if (IPoneLabel == nullptr) {
+    IPoneLabel = new UILabelExt();
+    if (IPoneLabel == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "IPoneLabel new fail");
+      return false;
+    }
+  }
+  IPoneLabel->SetPosition(
+      53, BTNoteLabel1->GetY() + BTNoteLabel1->GetTextHeight(), 360, 35);
+  IPoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
+  IPoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+  IPoneLabel->SetTextId(STR_IPHONE);
+  IPoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  IPoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------ BTNoteLabel2 ------------------------------
+   */
+  if (BTNoteLabel2 == nullptr) {
+    BTNoteLabel2 = new UILabelExt();
+    if (BTNoteLabel2 == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel2 new fail");
+      return false;
+    }
+  }
+  BTNoteLabel2->SetPosition(
+      53, IPoneLabel->GetY() + IPoneLabel->GetTextHeight(), 360, 455);
+  BTNoteLabel2->SetStyle(STYLE_TEXT_FONT, 30);
+  BTNoteLabel2->SetStyle(STYLE_LINE_HEIGHT, 35);
+  BTNoteLabel2->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE);
+  UpdateLabel(BTNoteLabel2, (char *)ble_name,
+              STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE);
+  BTNoteLabel2->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+  BTNoteLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------- AndroidLabel
+   * ------------------------------- */
+  if (AndroidLabel == nullptr) {
+    AndroidLabel = new UILabelExt();
+    if (AndroidLabel == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AndroidLabel new fail");
+      return false;
+    }
+  }
+  AndroidLabel->SetPosition(
+      53, BTNoteLabel2->GetY() + BTNoteLabel2->GetTextHeight() + 40, 360, 35);
+  AndroidLabel->SetStyle(STYLE_TEXT_FONT, 30);
+  AndroidLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+  AndroidLabel->SetTextId(STR_ANDROID);
+  AndroidLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  AndroidLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------ BTNoteLabel3 ------------------------------
+   */
+  if (BTNoteLabel3 == nullptr) {
+    BTNoteLabel3 = new UILabelExt();
+    if (BTNoteLabel3 == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BTNoteLabel2 new fail");
+      return false;
+    }
+  }
+  BTNoteLabel3->SetPosition(
+      53, AndroidLabel->GetY() + AndroidLabel->GetTextHeight(), 360, 455);
+  BTNoteLabel3->SetStyle(STYLE_TEXT_FONT, 30);
+  BTNoteLabel3->SetStyle(STYLE_LINE_HEIGHT, 35);
+  BTNoteLabel3->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID);
+  UpdateLabel(BTNoteLabel3, (char *)ble_name,
+              STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID);
+  BTNoteLabel3->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+  BTNoteLabel3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  /* ------------------------------- CloseLabel -------------------------------
+   */
+  if (CloseLabel == nullptr) {
+    CloseLabel = new UILabelExt();
+    if (CloseLabel == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CloseLabel new fail");
+      return false;
+    }
+  }
+  CloseLabel->SetPosition(
+      83, BTNoteLabel3->GetY() + BTNoteLabel3->GetTextHeight() + 40 + 29, 300,
+      35);
+  CloseLabel->SetStyle(STYLE_TEXT_FONT, 30);
+  CloseLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+  CloseLabel->SetTextId(STR_CLOSE); // 关闭
+  CloseLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  CloseLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+  CloseLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  return true;
+}
+
+bool AssistantBleView::CreateAssistantBleViewButton() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "AssistantBleView::CreateAssistantBleViewButton");
+  if (CloseButton == nullptr) {
+    CloseButton = new UIButton();
+    if (CloseButton == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CloseButton new fail!!");
+      return false;
+    }
+  }
+  CloseButton->SetPosition(
+      43, BTNoteLabel3->GetY() + BTNoteLabel3->GetTextHeight() + 40, 380, 100);
+  CloseButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+  CloseButton->SetViewId(ASSISTANT_BLE_NOTE);
+  CloseButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838,
+                                UIButton::PRESSED);
+  UIView::OnClickListener *buttonClick =
+      static_cast<UIView::OnClickListener *>(AssistantPresenter::GetInstance());
+  if (buttonClick == nullptr) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "buttonClick new fail");
+    return false;
+  }
+  CloseButton->SetOnClickListener(buttonClick);
+  return true;
+}
+
+UIScrollView *AssistantBleView::CreateAssistantBleView(void) {
+  WEARABLE_LOGD(
+      WEARABLE_LOG_MODULE_APP,
+      "MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConView");
+  /* --------------------------------------------------------------------------
+   */
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+    if (scrollView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail");
+      return nullptr;
+    }
+  }
+  scrollView->SetPosition(0, 0, 466, 466);
+  scrollView->SetScrollBlankSize(50);
+  scrollView->SetReboundSize(35);
+  scrollView->SetThrowDrag(true);
+  scrollView->SetMaxScrollDistance(1000);
+  scrollView->SetDirection(UIScrollView::VERTICAL);
+
+  /* --------------------------------- 获取蓝牙名称*
+   * --------------------------------- */
+  get_bt_name();
+  /* --------------------------------------------------------------------------
+   */
+  if (!CreateAssistantBleViewLabel() || !CreateAssistantBleViewButton()) {
+    return nullptr;
+  }
+  scrollView->Add(titleLabel);
+  scrollView->Add(BTNoteLabel1);
+  scrollView->Add(IPoneLabel);
+  scrollView->Add(AndroidLabel);
+  scrollView->Add(BTNoteLabel2);
+  scrollView->Add(BTNoteLabel3);
+  scrollView->Add(CloseButton);
+  scrollView->Add(CloseLabel);
+  return scrollView;
+}
+
+void AssistantBleView::get_bt_name(void) {
+  uint32_t ble_name_len = sizeof(ble_name);
+  uapi_get_nv_btname(ble_name, &ble_name_len);
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantHfpView.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantHfpView.cpp
new file mode 100644 (file)
index 0000000..ec8558a
--- /dev/null
@@ -0,0 +1,249 @@
+#include "assistant/include/AssistantHfpView.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "player/include/PlayersView.h"
+#include "string.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "wearable_log.h"
+namespace OHOS {
+
+static constexpr const char *OKBUTTON_VIEWID = "OkButton";
+AssistantHfpView::AssistantHfpView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantHfpView::AssistantHfpView");
+}
+
+AssistantHfpView::~AssistantHfpView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantHfpView::~AssistantHfpView");
+  ClearAll();
+}
+void AssistantHfpView::ClearAll() {
+
+  if (scrollView != nullptr) {
+    scrollView->RemoveAll();
+    if (titleLabel != nullptr) {
+      delete titleLabel;
+      titleLabel = nullptr;
+    }
+    if (bluetoothImage != nullptr) {
+      delete bluetoothImage;
+      bluetoothImage = nullptr;
+    }
+    if (image66 != nullptr) {
+      delete image66;
+      image66 = nullptr;
+    }
+    if (image99 != nullptr) {
+      delete image99;
+      image99 = nullptr;
+    }
+    if (noteLabel != nullptr) {
+      delete noteLabel;
+      noteLabel = nullptr;
+    }
+    if (OkButton != nullptr) {
+      delete OkButton;
+      OkButton = nullptr;
+    }
+    if (OkLabel != nullptr) {
+      delete OkLabel;
+      OkLabel = nullptr;
+    }
+    delete scrollView;
+    scrollView = nullptr;
+  }
+}
+
+UILabelExt *
+AssistantHfpView::AssistantHfpViewLabelInit(LabelConfig &labelconfig) {
+  UILabelExt *label = new UILabelExt();
+  if (label == nullptr) {
+    return nullptr;
+  }
+  label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width,
+                     labelconfig.height);
+  label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);
+  label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);
+  label->SetTextId(labelconfig.textId);
+  label->SetLineBreakMode(labelconfig.lineBreakMode);
+  label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  label->SetRollSpeed(70);
+  label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+  return label;
+}
+
+bool AssistantHfpView::CreateAssistantHfpViewLabel(void) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantHfpView::CreateAssistantHfpViewLabel");
+  LabelConfig labelConfig = {
+      .left = 83,
+      .top = 50,
+      .width = 300,
+      .height = 35,
+      .fontSize = 30,
+      .lineHeigh = 35,
+      .textId = STR_BLUETOOTH_DISCONNECTED, /*蓝牙未连接*/
+      .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+  };
+  titleLabel = AssistantHfpViewLabelInit(labelConfig);
+  if (nullptr == titleLabel) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!");
+    return false;
+  }
+  /* --------------------------------------------------------------------------
+   */
+  labelConfig = {
+      .left = 53,
+      .top = 230,
+      .width = 360,
+      .height = 105,
+      .fontSize = 30,
+      .lineHeigh = 35,
+      .textId =
+          STR_MUSIC_PLAYER_SOURCE_NOTE, /*请从手表端应用界面进入“音乐”-“音乐来源”,设置为“手机模式”后重试*/
+      .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+  };
+  noteLabel = AssistantHfpViewLabelInit(labelConfig);
+  if (nullptr == noteLabel) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "noteLabel new fail!!");
+    return false;
+  }
+
+  /* --------------------------------------------------------------------------
+   */
+  int16_t y = noteLabel->GetY() + noteLabel->GetTextHeight() + 30 + 33;
+  labelConfig = {
+      .left = 133,
+      .top = y,
+      .width = 200,
+      .height = 35,
+      .fontSize = 30,
+      .lineHeigh = 35,
+      .textId = STR_KONW, /*知道了*/
+      .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+  };
+  OkLabel = AssistantHfpViewLabelInit(labelConfig);
+  if (nullptr == OkLabel) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OkLabel new fail!!");
+    return false;
+  }
+
+  return true;
+}
+
+bool AssistantHfpView::CreateAssistantHfpViewImage(void) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantHfpView::CreateAssistantHfpViewImage");
+  if (bluetoothImage == nullptr) {
+    bluetoothImage = new UIImageView();
+    if (bluetoothImage == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+      return false;
+    }
+    bluetoothImage->SetPosition(209, 120, 48, 80);
+    if (!PlayersView::LoadPlayerImage(bluetoothImage, PLAYER_BLUETOOTH_COLOR)) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail");
+      return false;
+    }
+  }
+
+  /* --------------------------------------------------------------------------
+   */
+  if (image66 == nullptr) {
+    image66 = new UIImageView();
+    if (image66 == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+      return false;
+    }
+    image66->SetPosition(33, 200, 74, 52);
+    if (!PlayersView::LoadPlayerImage(image66, PLAYER_UP_66)) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail");
+      return false;
+    }
+    image66->SetAutoEnable(false);
+    image66->SetResizeMode(UIImageView::CENTER);
+  }
+
+  if (image99 == nullptr) {
+    image99 = new UIImageView();
+    if (image99 == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+      return false;
+    }
+    image99->SetPosition(
+        344, noteLabel->GetY() + noteLabel->GetTextHeight() - 35, 74, 52);
+    if (!PlayersView::LoadPlayerImage(image99, PLAYER_DOWM_66)) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail");
+      return false;
+    }
+    image99->SetAutoEnable(false);
+    image99->SetResizeMode(UIImageView::CENTER);
+  }
+
+  return true;
+}
+
+bool AssistantHfpView::CreateAssistantHfpViewButton(void) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantHfpView::CreateAssistantHfpViewButton");
+  if (OkButton == nullptr) {
+    OkButton = new UIButton();
+    if (OkButton == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OkButton new fail!!");
+      return false;
+    }
+  }
+  OkButton->SetPosition(0, noteLabel->GetY() + noteLabel->GetTextHeight() + 30,
+                        466, 100);
+  OkButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
+  OkButton->SetViewId(STOP_ASSISTANT_HFP_FAIL);
+  OkButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838,
+                             UIButton::PRESSED);
+  UIView::OnClickListener *buttonClick =
+      static_cast<UIView::OnClickListener *>(AssistantPresenter::GetInstance());
+  if (buttonClick == nullptr) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "buttonClick new fail");
+    return false;
+  }
+  OkButton->SetOnClickListener(buttonClick);
+  return true;
+}
+
+UIScrollView *AssistantHfpView::CreateAssistantHfpView(void) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "AssistantHfpView::CreateAssistantHfpView");
+  /* --------------------------------------------------------------------------
+   */
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+    if (scrollView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail");
+      return nullptr;
+    }
+  }
+  scrollView->SetPosition(0, 0, 466, 466);
+  scrollView->SetScrollBlankSize(50);
+  scrollView->SetViewId(ASSISTANT_HFP_BLE);
+  scrollView->SetReboundSize(35);
+  scrollView->SetDirection(UIScrollView::VERTICAL);
+  UIView::OnClickListener *buttonClick =
+      static_cast<UIView::OnClickListener *>(AssistantPresenter::GetInstance());
+  if (buttonClick == nullptr) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "buttonClick new fail");
+    return nullptr;
+  }
+  scrollView->SetOnClickListener(buttonClick);
+
+  if (!CreateAssistantHfpViewLabel() || !CreateAssistantHfpViewImage() ||
+      !CreateAssistantHfpViewButton()) {
+    return nullptr;
+  }
+  scrollView->Add(titleLabel);
+  scrollView->Add(bluetoothImage);
+  scrollView->Add(image66);
+  scrollView->Add(image99);
+  scrollView->Add(noteLabel);
+  scrollView->Add(OkButton);
+  scrollView->Add(OkLabel);
+  return scrollView;
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantModel.cpp
new file mode 100644 (file)
index 0000000..4352f7e
--- /dev/null
@@ -0,0 +1,177 @@
+
+
+#include "assistant/include/AssistantModel.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "assistant/include/AssistantView.h"
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "bleEvent.h"
+#include "broadcast_feature.h"
+#include "broadcast_service.h"
+#include "cat1_ctl.h"
+#include "cat1_server.h"
+#include "custom_runtime.h"
+#include "custom_utils.h"
+#include "graphic_service.h"
+#include "lwip/apps/http_client.h"
+#include "samgr_lite.h"
+#include "tcxo.h"
+#include "thread_adapter.h"
+#include "thread_init.h"
+#include "vibrator_service.h"
+#include "wearable_log.h"
+#include <array>
+#include <cmsis_os2.h>
+#include <cstdint>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <service/graphic_service.h>
+#include <string>
+#include <vector>
+
+#include "PhoneService.h"
+#include "PhoneServiceC.h"
+
+extern "C" {
+int uapi_open_voice_recognition(void);
+int uapi_close_voice_recognition(void);
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+static void Notify(void *args, const Topic topic, Request *request);
+
+using namespace OHOS;
+
+Subscriber AssistantSubscirber = {
+    .identity = NULL,
+    .args = NULL,
+    .Notify = Notify,
+};
+void AssistantSubscribeTopic(Topic topic) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, topic=%u", topic);
+  BroadcastApi *broadcastApi = NULL;
+  IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME,
+                                                     BROADCAST_FEATURE_NAME);
+  if (api == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "stepsubscribeTopic, GetFeatureApi failed");
+    return;
+  }
+  int result =
+      api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi);
+  if (result != 0 || broadcastApi == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "stepsubscribeTopic, QueryInterface failed");
+    return;
+  }
+  broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic,
+                               &AssistantSubscirber);
+  broadcastApi->Release((IUnknown *)broadcastApi);
+}
+
+void AssistantUnsubscribeTopic(Topic topic) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AssistantUnsubscribeTopic, topic=%u",
+                topic);
+  BroadcastApi *broadcastApi = NULL;
+  IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME,
+                                                     BROADCAST_FEATURE_NAME);
+  if (api == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantUnsubscribeTopic, GetFeatureApi failed");
+    return;
+  }
+  int result =
+      api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi);
+  if (result != 0 || broadcastApi == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantUnsubscribeTopic, QueryInterface failed");
+    return;
+  }
+  broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic,
+                                 &AssistantSubscirber);
+  broadcastApi->Release((IUnknown *)broadcastApi);
+}
+
+static void Notify(void *args, const Topic topic, Request *request) {
+  UNUSED(args);
+  UNUSED(topic);
+  if (request == NULL) {
+    return;
+  }
+  // 退出语音助手
+  if (request->msgId == TOPIC_EVENT_ASSISTANT_NOTE) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "退出语音助手\r\n");
+    AssistantView *p_AssistantView = AssistantView::GetInstance();
+    if (p_AssistantView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    " AssistantView::GetInstance fail!");
+      return;
+    }
+    if ((p_AssistantView->GetAssistantScrollView(ASSISTANT_ANSWER_VIEW))
+                ->IsVisible() == true &&
+        p_AssistantView->GetAssistantScrollView(ASSISTANT_MAIN_VIEW)
+                ->IsVisible() == false) {
+      p_AssistantView->ChangeView(ASSISTANT_ANSWER_VIEW, ASSISTANT_MAIN_VIEW);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "退出语音助手成功\r\n");
+    }
+  }
+}
+#ifdef __cplusplus
+}
+#endif
+
+namespace OHOS {
+
+// 启动 uapi_open_voice_recognition()
+// hfp是否连接 uapi_hfp_connect_state()
+// 关闭 uapi_close_voice_recognition()
+// 断联 HFP_SCO_STATE_DISCONNECTING
+
+//取消订阅
+
+AssistantModel::AssistantModel() {}
+AssistantModel::~AssistantModel() {
+  AssistantUnsubscribeTopic(TOPIC_EVENT_ASSISTANT_NOTE);
+}
+AssistantModel *AssistantModel::GetInstance(void) {
+  static AssistantModel instance;
+  return &instance;
+}
+//进行语音助手订阅
+void AssistantModel::Init() {
+  AssistantSubscribeTopic(TOPIC_EVENT_ASSISTANT_NOTE);
+}
+
+//获取状态[hfp]
+bool AssistantModel::GetHFPStatus(void) {
+  bool hfp_status = uapi_hfp_connect_state();
+  WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "hfp_status:%d", hfp_status);
+  return hfp_status;
+}
+//开启语音助手[soc]
+bool AssistantModel::StartAssistant(void) {
+  if (uapi_open_voice_recognition() == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_open_voice_recognition is ok");
+    return true;
+  }
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "uapi_open_voice_recognition is failed");
+  return false;
+}
+//关闭语音助手
+void AssistantModel::StopAssistant(void) {
+
+  if (uapi_close_voice_recognition() == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "uapi_close_voice_recognition is ok");
+  } else {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "uapi_close_voice_recognition is failed");
+  }
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantPresenter.cpp
new file mode 100644 (file)
index 0000000..00cc441
--- /dev/null
@@ -0,0 +1,125 @@
+
+#include "AppViewIDs.h"
+#include "KeyInputListener.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include "components/ui_label_ext.h"
+#include "custom_utils.h"
+#include "ui_resource_string.h"
+
+#include "broadcast_service.h"
+
+#include "assistant/include/AssistantModel.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "custom_runtime.h"
+#include "custom_utils.h"
+#include "gfx_utils/mem_check.h"
+#include "graphic_service.h"
+namespace OHOS {
+
+// 当前Presenter属性实例化的内存指针
+static AssistantPresenter *g_pAssistantPresenter = nullptr;
+AssistantPresenter::AssistantPresenter() { g_pAssistantPresenter = this; }
+
+AssistantPresenter::~AssistantPresenter() { g_pAssistantPresenter = nullptr; }
+
+AssistantPresenter *AssistantPresenter::GetInstance() {
+
+  return g_pAssistantPresenter;
+}
+
+void AssistantPresenter::OnStart() { Presenter<AssistantView>::OnStart(); }
+
+void AssistantPresenter::OnPause(void) { Presenter<AssistantView>::OnPause(); }
+
+void AssistantPresenter::OnResume(void) {
+
+  Presenter<AssistantView>::OnResume();
+}
+
+void AssistantPresenter::OnStop(void) { Presenter<AssistantView>::OnStop(); }
+
+bool AssistantPresenter::OnDrag(UIView &view, const DragEvent &event) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AssistantPresenter::OnDrag");
+  AssistantView *p_AssistantView = AssistantView::GetInstance();
+  if (p_AssistantView == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " AssistantView::GetInstance fail!");
+    return false;
+  }
+  if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+      (event.GetDeltaX() > 20) &&
+      (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) {
+    /*在主界面进行退出*/
+    if (&view == p_AssistantView->GetAssistantScrollView(ASSISTANT_MAIN_VIEW)) {
+      NativeAbility::GetInstance().Back();
+    }
+    if (&view ==
+        p_AssistantView->GetAssistantScrollView(ASSISTANT_ANSWER_VIEW)) {
+      p_AssistantView->ChangeView(ASSISTANT_ANSWER_VIEW, ASSISTANT_MAIN_VIEW);
+    }
+    /*在其他界面返回主界面*/
+  }
+  return true;
+}
+
+bool AssistantPresenter::OnClick(UIView &view, const ClickEvent &event) {
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantPresenter::OnClick %s",
+                view.GetViewId());
+  AssistantView *p_AssistantView = AssistantView::GetInstance();
+  if (p_AssistantView == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " AssistantView::GetInstance fail!");
+    return false;
+  }
+  /*唤醒语音助手*/
+  if (strcmp(view.GetViewId(), WAKE_ASSISTANT) == 0) {
+
+    //校验hfp
+    if (AssistantModel::GetInstance()->GetHFPStatus()) {
+      //校验开启状态
+      if (AssistantModel::GetInstance()->StartAssistant()) {
+        p_AssistantView->ChangeView(ASSISTANT_MAIN_VIEW, ASSISTANT_ANSWER_VIEW);
+      } else {
+        p_AssistantView->ChangeView(ASSISTANT_MAIN_VIEW,
+                                    ASSISTANT_START_FAILED_VIEW);
+      }
+    } else {
+      p_AssistantView->ChangeView(ASSISTANT_MAIN_VIEW, ASSISTANT_HFP_FAIL_VIEW);
+    }
+  }
+  /*停止语音助手*/
+  if (strcmp(view.GetViewId(), STOP_ASSISTANT) == 0) {
+    p_AssistantView->ChangeView(ASSISTANT_ANSWER_VIEW, ASSISTANT_MAIN_VIEW);
+    AssistantModel::GetInstance()->StopAssistant();
+  }
+  /*唤醒失败*/
+  if (strcmp(view.GetViewId(), STOP_ASSISTANT_FAIL) == 0) {
+    p_AssistantView->ChangeView(ASSISTANT_START_FAILED_VIEW,
+                                ASSISTANT_MAIN_VIEW);
+  }
+  /*hfp失败*/
+  if (strcmp(view.GetViewId(), STOP_ASSISTANT_HFP_FAIL) == 0) {
+    p_AssistantView->ChangeView(ASSISTANT_HFP_FAIL_VIEW, ASSISTANT_MAIN_VIEW);
+  }
+  /*hfp->blenote*/
+  if (strcmp(view.GetViewId(), ASSISTANT_HFP_BLE) == 0) {
+    p_AssistantView->ChangeView(ASSISTANT_MAIN_VIEW, ASSISTANT_BLE_NOTE_VIEW);
+  }
+  /*ble提醒*/
+  if (strcmp(view.GetViewId(), ASSISTANT_BLE_NOTE) == 0) {
+    p_AssistantView->ChangeView(ASSISTANT_BLE_NOTE_VIEW, ASSISTANT_MAIN_VIEW);
+  }
+  return true;
+}
+
+bool AssistantPresenter::OnKeyAct(UIView &view, const KeyEvent &event) {
+  unsigned short keyID = event.GetKeyId();
+  unsigned short keyState = event.GetState();
+  // 如果是power键,且是亮屏状态,按键释放就返回上一级
+  if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) &&
+      keyState == 1 && uapi_get_screen_state() == 0) {
+    NativeAbility::GetInstance().Back();
+  }
+  return true;
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantStartFailedView.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantStartFailedView.cpp
new file mode 100644 (file)
index 0000000..0c57528
--- /dev/null
@@ -0,0 +1,110 @@
+#include "assistant/include/AssistantStartFailedView.h"
+#include "assistant/include/AssistantPresenter.h"
+#include "string.h"
+#include "ui_resource_string.h"
+#include "wearable_log.h"
+namespace OHOS {
+
+static constexpr const char *OKBUTTON_VIEWID = "OkButton";
+AssistantStartFailedView::AssistantStartFailedView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "AssistantStartFailedView::AssistantStartFailedView");
+}
+
+AssistantStartFailedView::~AssistantStartFailedView() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "AssistantStartFailedView::~AssistantStartFailedView");
+  ClearAll();
+}
+void AssistantStartFailedView::ClearAll() {
+
+  if (scrollView != nullptr) {
+    scrollView->RemoveAll();
+    if (Label != nullptr) {
+      delete Label;
+      Label = nullptr;
+    }
+    if (ImageView != nullptr) {
+      delete ImageView;
+      ImageView = nullptr;
+    }
+    if (LabelButton != nullptr) {
+      delete LabelButton;
+      LabelButton = nullptr;
+    }
+    delete scrollView;
+    scrollView = nullptr;
+  }
+}
+
+UIScrollView *AssistantStartFailedView::CreateAssistantStartFailedView(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View::ViewInit_BlueToothConnected");
+  if (scrollView == nullptr) {
+    /* --------------------------- scrollView --------------------------- */
+    if (scrollView == nullptr) {
+      scrollView = new UIScrollView();
+      if (scrollView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail");
+        return nullptr;
+      }
+    }
+    scrollView->SetPosition(0, 0, 466, 466);
+    scrollView->SetScrollBlankSize(50);
+    scrollView->SetReboundSize(35);
+    scrollView->SetDirection(UIScrollView::VERTICAL);
+    /* ----------------------- ImageView ---------------------- */
+    ImageView = new UIImageView();
+    if (ImageView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "[ViewInit_BlueToothConnected] TitleLabel new fail!!");
+      return nullptr;
+    }
+    ImageView->SetPosition(193, 120, 80, 80);
+    ImageView->SetSrc(PNG_ATTENTION_IMAGE);
+    /* ----------------------------- Label ----------------------------- */
+    Label = new UILabelExt();
+    if (Label == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "[CreateDeviceUnBindingView] Label new fail");
+      return nullptr;
+    }
+    Label->SetPosition(53, 250, 360, 35);
+    Label->SetStyle(STYLE_TEXT_FONT, 30);
+    Label->SetStyle(STYLE_LINE_HEIGHT, 35);
+    Label->SetText("启用语音助手失败"); //启用语音助手失败 TODO::多国语言
+    Label->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+    Label->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+    Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    /* -------------------------- LabelButton -------------------------- */
+    LabelButton = new UILabelButtonExt();
+    if (LabelButton == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "[CreateDeviceUnBindingView] LabelButton new fail");
+      return nullptr;
+    }
+    LabelButton->SetPosition(0, 366, 466, 100);
+    LabelButton->SetViewId(STOP_ASSISTANT_FAIL);
+    LabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE,
+                             PNG_BUTTON_466x100_IMAGE);
+    LabelButton->SetTextId(STR_CLOSE); //关闭
+    LabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    LabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928,
+                                  UIButton::PRESSED);
+    UIView::OnClickListener *buttonClick =
+        static_cast<UIView::OnClickListener *>(
+            AssistantPresenter::GetInstance());
+    if (buttonClick == nullptr) {
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "buttonClick new fail");
+      return nullptr;
+    }
+    LabelButton->SetOnClickListener(buttonClick);
+    /* ----------------------------------- Add
+     * ---------------------------------- */
+    scrollView->Add(ImageView);
+    scrollView->Add(Label);
+    scrollView->Add(LabelButton);
+  }
+  return scrollView;
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantView.cpp b/code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantView.cpp
new file mode 100644 (file)
index 0000000..e206c98
--- /dev/null
@@ -0,0 +1,277 @@
+#include "assistant/include/AssistantView.h"
+#include "assistant/include/AssistantModel.h"
+#include "assistant/include/AssistantPresenter.h"
+
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_scroll_view.h"
+#include "custom_utils.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <ui_scroll_view.h>
+
+namespace OHOS {
+
+static AssistantView *g_pAssistantView{nullptr};
+static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;
+static const char *WAKE_IMAGE = "/user/res/assistant/assistant.bin";
+
+AssistantView::AssistantView() { g_pAssistantView = this; }
+
+AssistantView::~AssistantView() {
+
+  if (AssistantScrollView[ASSISTANT_MAIN_VIEW]) {
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->RemoveAll();
+    if (noteLabel) {
+      delete noteLabel;
+      noteLabel = nullptr;
+    }
+    if (wakeButton) {
+      delete wakeButton;
+      wakeButton = nullptr;
+    }
+    delete AssistantScrollView[ASSISTANT_MAIN_VIEW];
+    AssistantScrollView[ASSISTANT_MAIN_VIEW] = nullptr;
+  }
+  for (int i = 0; i < MAX_ASSISTANT_VIEWID; i++) {
+    if (AssistantScrollView[i]) {
+      AssistantScrollView[i] = nullptr;
+    }
+  }
+  if (p_MianView) {
+    delete p_MianView;
+    p_MianView = nullptr;
+  }
+  if (p_AnswerView) {
+    delete p_AnswerView;
+    p_AnswerView = nullptr;
+  }
+  if (p_BleView) {
+    delete p_BleView;
+    p_BleView = nullptr;
+  }
+  if (p_HfpView) {
+    delete p_HfpView;
+    p_HfpView = nullptr;
+  }
+  if (p_StartFailedView) {
+    delete p_StartFailedView;
+    p_StartFailedView = nullptr;
+  }
+  g_pAssistantView = nullptr;
+}
+
+AssistantView *AssistantView::GetInstance() { return g_pAssistantView; }
+
+void AssistantView::InitView() {
+  if (AssistantScrollView[ASSISTANT_MAIN_VIEW] == nullptr) {
+    AssistantScrollView[ASSISTANT_MAIN_VIEW] = new UIScrollView();
+    if (AssistantScrollView[ASSISTANT_MAIN_VIEW] == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "AssistantScrollView[ASSISTANT_MAIN_VIEW]  new fail");
+      return;
+    }
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetScrollBlankSize(35);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetReboundSize(50);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetPosition(
+        0, 0, Screen::GetInstance().GetWidth(),
+        Screen::GetInstance().GetHeight());
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetHorizontalScrollState(false);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetOnDragListener(presenter_);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetTouchable(true);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetDraggable(true);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetStyle(STYLE_BACKGROUND_COLOR,
+                                                       BACK_GROUND_COLOR);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->SetStyle(STYLE_BACKGROUND_COLOR,
+                                                       Color::Black().full);
+    //初始化label TODO::多国语言
+    InitLabel(noteLabel, 53, 339, 360, 35, "label", "点击唤醒语音助手",
+              DEFAULT_VECTOR_FONT_FILENAME, 30);
+    //初始化button
+    InitButton(wakeButton, 128, 91, 210, 210, WAKE_ASSISTANT);
+    wakeButton->SetImageSrc(WAKE_IMAGE, WAKE_IMAGE);
+    wakeButton->SetOnClickListener(presenter_);
+
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->Add(wakeButton);
+    AssistantScrollView[ASSISTANT_MAIN_VIEW]->Add(noteLabel);
+  }
+}
+/* -------------------------------------------------------------------------- */
+// 主视图
+bool AssistantView::ChangeToMainView(int16_t thisView) {
+  if (AssistantScrollView[thisView] == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantView::ChangeToMainView");
+    container_->Add(AssistantScrollView[thisView]);
+  }
+  return true;
+}
+
+bool AssistantView::ChangeToAnswerView(int16_t thisView) {
+  if (AssistantScrollView[thisView] == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantView::ChangeToAnswerView");
+    p_AnswerView = new AssistantAnswerView();
+    if (p_AnswerView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "AssistantView:: new scrollView[%d] fail", thisView);
+      return false;
+    }
+    AssistantScrollView[thisView] = p_AnswerView->AssistantAnswerViewInit();
+    container_->Add(AssistantScrollView[thisView]);
+  }
+  return true;
+}
+
+bool AssistantView::ChangeToHfpView(int16_t thisView) {
+  if (AssistantScrollView[thisView] == nullptr) {
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantView::ChangeToHfpView");
+    p_HfpView = new AssistantHfpView();
+    if (p_HfpView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "AssistantView:: new scrollView[%d] fail", thisView);
+      return false;
+    }
+    AssistantScrollView[thisView] = p_HfpView->CreateAssistantHfpView();
+    container_->Add(AssistantScrollView[thisView]);
+  }
+  return true;
+}
+
+bool AssistantView::ChangeToBleView(int16_t thisView) {
+  if (AssistantScrollView[thisView] == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AssistantView::ChangeToBleView");
+    p_BleView = new AssistantBleView();
+    if (p_BleView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "AssistantView:: new scrollView[%d] fail", thisView);
+      return false;
+    }
+    AssistantScrollView[thisView] = p_BleView->CreateAssistantBleView();
+    container_->Add(AssistantScrollView[thisView]);
+  }
+  return true;
+}
+
+bool AssistantView::ChangeToStartFailedView(int16_t thisView) {
+  if (AssistantScrollView[thisView] == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantView::ChangeToStartFailedView");
+    p_StartFailedView = new AssistantStartFailedView();
+    if (p_StartFailedView == nullptr) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "AssistantView:: new scrollView[%d] fail", thisView);
+      return false;
+    }
+    AssistantScrollView[thisView] =
+        p_StartFailedView->CreateAssistantStartFailedView();
+    container_->Add(AssistantScrollView[thisView]);
+  }
+  return true;
+}
+
+struct AssistantViewMapper {
+  const int16_t viewId;
+  bool (AssistantView::*func)(int16_t thisView);
+};
+
+static const AssistantViewMapper ViewMapper[] = {
+    {ASSISTANT_MAIN_VIEW, &AssistantView::ChangeToMainView},
+    {ASSISTANT_ANSWER_VIEW, &AssistantView::ChangeToAnswerView},
+    {ASSISTANT_HFP_FAIL_VIEW, &AssistantView::ChangeToHfpView},
+    {ASSISTANT_BLE_NOTE_VIEW, &AssistantView::ChangeToBleView},
+    {ASSISTANT_START_FAILED_VIEW, &AssistantView::ChangeToStartFailedView},
+};
+
+// 根据传入的interface参数执行相应视图ID关联的成员函数。
+bool AssistantView::ClickFunc(int16_t interface) {
+  int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[ASSISTANT_MAIN_VIEW]);
+  for (int i = 0; i < funcSize; i++) {
+    if (interface == ViewMapper[i].viewId) {
+      bool jug = (this->*(ViewMapper[i].func))(interface);
+      if (jug == false) {
+        return false;
+      }
+      return true;
+    }
+  }
+  return false;
+}
+
+/*检查传入的两个视图参数 hideView 和 showView 的有效性。*/
+bool AssistantView::CheckViewParam(int16_t hideView, int16_t showView) {
+  if (showView < 0 || showView >= MAX_ASSISTANT_VIEWID) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantView::CheckViewParam showView err.");
+    return false;
+  }
+
+  if (hideView < 0 || hideView > MAX_ASSISTANT_VIEWID) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantView::CheckViewParam hideView err.");
+    return false;
+  }
+
+  return true;
+}
+
+// 切换视图
+void AssistantView::ChangeView(int16_t hideView, int16_t showView) {
+  if (!CheckViewParam(hideView, showView)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "AssistantView::CheckViewParam failed.");
+    return;
+  }
+  AssistantScrollView[hideView]->SetVisible(false);
+  ClickFunc(showView);
+  AssistantScrollView[showView]->SetVisible(true);
+  Draw();
+}
+UIScrollView *AssistantView::GetAssistantScrollView(int ViewId) {
+  if (AssistantScrollView[ViewId] == nullptr) {
+    return nullptr;
+  }
+  return AssistantScrollView[ViewId];
+}
+
+/* -------------------------------------------------------------------------- */
+void AssistantView::OnStart() {
+  View<AssistantPresenter>::OnStart();
+  SetContainerView(new UIViewGroup());
+  if (GetContainer() == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");
+    return;
+  }
+  container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+
+  InitView();
+
+  SetContainerView(container_);
+  RootView::GetInstance()->SetOnKeyActListener(presenter_);
+}
+
+void AssistantView::OnSetUpView() {
+  View<AssistantPresenter>::OnSetUpView();
+  container_->Add(AssistantScrollView[ASSISTANT_MAIN_VIEW]);
+  Draw();
+}
+
+void AssistantView::OnTearDownView() {
+  View<AssistantPresenter>::OnTearDownView();
+  return;
+}
+
+void AssistantView::OnStop() {
+  View<AssistantPresenter>::OnStop();
+  if (container_ != nullptr) {
+    container_->RemoveAll();
+    delete container_;
+    container_ = nullptr;
+  }
+  RootView::GetInstance()->RemoveAll();
+  return;
+}
+
+} // namespace OHOS
\ No newline at end of file
index 3397d0f..a20334d 100644 (file)
@@ -703,6 +703,7 @@ static void ScoStateChanged(const bd_addr_t *bdAddr, hfp_sco_connect_state_t sta
         g_scoFlag, g_currCallNum);
 
     switch (state) {
+        // SCO连接中
         case HFP_SCO_STATE_CONNECTING:
             PhoneServiceScreenCtr(1);
             if (g_scoFlag != HFP_SCO_STATE_CONNECTED) {
@@ -715,12 +716,13 @@ static void ScoStateChanged(const bd_addr_t *bdAddr, hfp_sco_connect_state_t sta
         case HFP_SCO_STATE_CONNECTED:
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoStateChanged] SCO connected!");
             break;
-
+        // SCO断连中
         case HFP_SCO_STATE_DISCONNECTING:
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoStateChanged] SCO disconnecting!");
             break;
-
         case HFP_SCO_STATE_DISCONNECTED:
+            //语音助手断联
+            CustomEventPublish(TOPIC_EVENT_ASSISTANT_NOTE,NULL,0);
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoStateChanged] SCO disconnected!");
             ScoDisconnectPro();
             PhoneServiceScreenCtr(0);
index 53ee572..09e6ed1 100644 (file)
@@ -94,6 +94,7 @@ typedef enum {
     TOPIC_EVENT_MESSAGENOTE, //消息通知
     TOPIC_EVENT_MESSAGE_UPDATA, //消息更新通知
     TOPIC_EVENT_SLEEPNOTE, //睡眠通知
+    TOPIC_EVENT_ASSISTANT_NOTE,//语音助手结束
     TOPIC_END_NUM = 20000,
 } TopicNum;
 
index 8637603..9533787 100644 (file)
@@ -66,6 +66,7 @@ static const TopicToCore topicToCoreArray[] = {
     // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,A_CORE_MASK, 1},
 #endif
     {TOPIC_EVENT_ENTER_CMAERA,A_CORE_MASK, 1},//遥控拍照
+    {TOPIC_EVENT_ASSISTANT_NOTE,A_CORE_MASK, 1},//语音助手
     {TOPIC_EVENT_CANCEL_CMAERA,A_CORE_MASK, 1},
     {TOPIC_EVENT_FIND_WATCH,A_CORE_MASK, 1},//查找手表
     {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1},