diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index a303882b..ecb8836e 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -333,6 +333,7 @@ bool CPhoneDevice::SelfTest(std::string& result) std::string path = m_appPath + (APP_PATH_CHANNELS DIR_SEP_STR); unsigned char cameraId = 0; + unsigned char usbCamera = 0; Json::Value channelCfg = Json::objectValue; content.clear(); filePath = m_appPath + (APP_DATA_DIR DIR_SEP_STR APP_FILE_NAME_APP_CONF); @@ -348,7 +349,7 @@ bool CPhoneDevice::SelfTest(std::string& result) const char* doc = (const char*)&(content[0]); if (reader->parse(doc, doc + content.size(), &channelCfg, NULL)) { - unsigned char val = 0; + GetJSONUInt8Value(channelCfg, "usbCamera", usbCamera); if (GetJSONUInt8Value(channelCfg, "cameraId", cameraId)) { result += "通道" + std::to_string(channel) + " Camera ID为 " + std::to_string(cameraId) + "\r\n"; @@ -368,8 +369,19 @@ bool CPhoneDevice::SelfTest(std::string& result) int32_t width = 0; int32_t height = 0; NdkCamera::CAMERA_PARAMS params = { 0 }; + if (usbCamera) + { + TurnOnOtg(NULL); + } + TurnOnCameraPower(NULL); + NdkCamera camera(width, height, params); int res = camera.selfTest(std::to_string(cameraId), width, height); + TurnOffCameraPower(NULL); + if (usbCamera) + { + TurnOffOtg(NULL); + } if (res == 0) { result += "通道" + std::to_string(channel) + "正常:最大分辨率:" + std::to_string(width) + "x" + std::to_string(height) + "\r\n";