增加判断设备是否有网接口
authorCaisking <Casiking@zhihuishixun.com>
Thu, 26 Jun 2025 02:12:27 +0000 (10:12 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Thu, 26 Jun 2025 02:12:27 +0000 (10:12 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/application/wearable/service/ble_service/bleservice/bleService.h

index ae014eb..f50c4f3 100644 (file)
@@ -188,15 +188,12 @@ namespace OHOS
                 viewId = VIEW_CHECK_INVALID;
             }
 #if defined(BOARD_W9) || defined(BOARD_N9)
-            bool isbleconnected = get_ble_connect(); // 获取蓝牙连接状态
-            bool is4Gconnected = uapi_dev_runtime_get_cat1_networkstat(); // 获取4G连接状态
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"isbleconnected = %d is4Gconnected = %d",isbleconnected,is4Gconnected);
             if(viewId ==  VIEW_PRESSURE || viewId == VIEW_EMOTION || viewId == VIEW_ECG 
                 || viewId == VIEW_FATIGUE || viewId == VIEW_BLOOD_PRESSURE_CHECK 
                 || viewId == VIEW_BLOOD_PRESSURE_CALIBRATION)
             {
                 // 必须至少有一个状态成功才可以正常进入应用,否则进入未连接界面。
-                if (isbleconnected == false && is4Gconnected == false)
+                if (!uapi_is_device_online())
                 {
                     viewId = VIEW_UNCONNECTED;
                 }
index feac999..cb609bc 100644 (file)
@@ -150,13 +150,10 @@ namespace OHOS
         AppViewId viewId = settingItemView->GetViewId();
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%d\n", viewId);
 #if defined(BOARD_W9) || defined(BOARD_N9)
-            bool isbleconnected = get_ble_connect(); // 获取蓝牙连接状态
-            bool is4Gconnected = uapi_dev_runtime_get_cat1_networkstat(); // 获取4G连接状态
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"isbleconnected = %d is4Gconnected = %d",isbleconnected,is4Gconnected);
             if( viewId == VIEW_BLOOD_PRESSURE_CHECK  || viewId == VIEW_BLOOD_PRESSURE_CALIBRATION)
             {
                 // 必须至少有一个状态成功才可以正常进入应用,否则进入未连接界面。
-                if (isbleconnected == false && is4Gconnected == false)
+                if (!uapi_is_device_online())
                 {
                     viewId = VIEW_UNCONNECTED;
                 }
index d948c43..1eab3d5 100644 (file)
@@ -2803,6 +2803,20 @@ int send_msg_data_into_Ai_msg_queue(void *buff,uint16_t len,uint8_t type)
     return ret;\r
 }\r
 \r
+//获取设备是否有网(4G,蓝牙)\r
+bool uapi_is_device_online(void)\r
+{\r
+    bool isbleconnected = get_ble_connect(); // 获取蓝牙连接状态\r
+    bool is4Gconnected = uapi_dev_runtime_get_cat1_networkstat(); // 获取4G连接状态\r
+    if(isbleconnected || is4Gconnected)\r
+    {\r
+        return true;\r
+    }\r
+    else\r
+    {\r
+        return false;\r
+    }\r
+}\r
 \r
 \r
 #ifdef __cplusplus\r
index a08ef4c..42b1eaf 100644 (file)
@@ -82,6 +82,10 @@ void ble_test_ANCS_notify(uint8_t type);
 
 bool get_ble_connect(void);
 
+//获取设备是否有网(4G,蓝牙)
+bool uapi_is_device_online(void);
+
+
 bool get_ble_adv_status(void);
 
 void get_adv_data(char *data);