From f7a8c120b038a87c8867215e64b2d5616520193a Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 12 Jun 2024 09:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=A3=80=E5=A2=9E=E5=8A=A0=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=8E=A5=E5=8F=A3=E7=9A=84=E4=BF=A1=E6=81=AF=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 42 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 95fb9da9..108817c4 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -294,14 +294,14 @@ bool CPhoneDevice::SelfTest(std::string& result) unsigned int numberOfChannels = 0; - result += "自检。Version:" + GetVersion() + "\r\n"; + result += "设备自检 版本:" + GetVersion() + NEW_LINE_TAG; Json::Value appConfig = Json::objectValue; std::vector content; std::string filePath = m_appPath + (APP_DATA_DIR DIR_SEP_STR APP_FILE_NAME_APP_CONF); if (!readFile(filePath, content)) { - result += "读取系统配置文件App.json失败\r\n"; + result += ("读取系统配置文件App.json失败" NEW_LINE_TAG); } else { @@ -315,16 +315,16 @@ bool CPhoneDevice::SelfTest(std::string& result) if (GetJSONUInt32Value(appConfig, "channels", val) && (val > 0 && val <= 255)) { numberOfChannels = val; - result += "通道数:" + std::to_string(numberOfChannels) + "\r\n"; + result += "通道数:" + std::to_string(numberOfChannels) + NEW_LINE_TAG; } else { - result += "通道数未定义或者无效\r\n"; + result += "通道数未定义或者无效" NEW_LINE_TAG; } } else { - result += "解析系统配置文件App.json失败\r\n"; + result += "解析系统配置文件App.json失败" NEW_LINE_TAG; } } @@ -339,7 +339,7 @@ bool CPhoneDevice::SelfTest(std::string& result) filePath = m_appPath + (APP_DATA_DIR DIR_SEP_STR APP_FILE_NAME_APP_CONF); if (!readFile(filePath, content)) { - result += "读取通道" + std::to_string(channel) + "配置文件失败\r\n"; + result += "读取通道" + std::to_string(channel) + "配置文件失败" NEW_LINE_TAG; } else { @@ -352,17 +352,17 @@ bool CPhoneDevice::SelfTest(std::string& result) GetJSONUInt8Value(channelCfg, "usbCamera", usbCamera); if (GetJSONUInt8Value(channelCfg, "cameraId", cameraId)) { - result += "通道" + std::to_string(channel) + " Camera ID为 " + std::to_string(cameraId) + "\r\n"; + result += "通道" + std::to_string(channel) + " Camera ID为 " + std::to_string(cameraId) + NEW_LINE_TAG; } else { cameraId = channel - 1; - result += "通道" + std::to_string(channel) + "未定义Camera ID, 使用默认值 " + std::to_string(cameraId) + "\r\n"; + result += "通道" + std::to_string(channel) + "未定义Camera ID, 使用默认值 " + std::to_string(cameraId) + NEW_LINE_TAG; } } else { - result += "解析通道" + std::to_string(channel) + "配置文件App.json失败\r\n"; + result += "解析通道" + std::to_string(channel) + "配置文件App.json失败" NEW_LINE_TAG; } } @@ -384,11 +384,11 @@ bool CPhoneDevice::SelfTest(std::string& result) } if (res == 0) { - result += "通道" + std::to_string(channel) + "正常:最大分辨率:" + std::to_string(width) + "x" + std::to_string(height) + "\r\n"; + result += "通道" + std::to_string(channel) + "正常:最大分辨率:" + std::to_string(width) + "x" + std::to_string(height) + NEW_LINE_TAG; } else { - result += "通道" + std::to_string(channel) + " 异常 err=" + std::to_string(res) + "\r\n"; + result += "通道" + std::to_string(channel) + " 异常 err=" + std::to_string(res) + NEW_LINE_TAG; } } @@ -396,19 +396,19 @@ bool CPhoneDevice::SelfTest(std::string& result) if (bv > 0) { bv -= bv % 100; - result += std::string("电池电压:") + std::to_string(bv / 1000) + std::string(".") + std::to_string((bv % 1000) / 100) + "\r\n"; + result += std::string("电池电压:") + std::to_string(bv / 1000) + std::string(".") + std::to_string((bv % 1000) / 100) + NEW_LINE_TAG; } fs::space_info si = fs::space("/data"); double fr = ((double)si.available * 100.0f) / ((double)si.capacity); result += "可用存储:"; result += std::to_string((int)fr); - result += "%%\r\n"; + result += "%%" NEW_LINE_TAG; long fm = android_os_Process_getFreeMemory(); long tm = android_os_Process_getTotalMemory(); double fmp = ((double)fm * 100.0f) / ((double)tm); - result += std::string("可用内存:") + std::to_string((int)fmp) + std::string("%%\r\n"); + result += std::string("可用内存:") + std::to_string((int)fmp) + std::string("%%" NEW_LINE_TAG); if (!m_tfCardPath.empty()) { @@ -416,12 +416,22 @@ bool CPhoneDevice::SelfTest(std::string& result) double fr2 = ((double)si2.available * 100.0f) / ((double)si2.capacity); result += "TF卡可用空间:"; result += std::to_string((int)fr2); - result += "%%\r\n"; + result += "%%" NEW_LINE_TAG; } result += "4G信号强度:"; result += std::to_string(m_signalLevel); - result += "\r\n"; + result += NEW_LINE_TAG; + + result += "网络接口:"; + std::vector devices; + GetNetDevices(devices); + for (auto it = devices.cbegin(); it != devices.cend(); ++it) + { + result += (*it); + result += " "; + } + // result += NEW_LINE_TAG; return true; }