diff --git a/application/HuntingCamera/build/hunting_camera.cmake b/application/HuntingCamera/build/hunting_camera.cmake index fceaeaec..3af19096 100644 --- a/application/HuntingCamera/build/hunting_camera.cmake +++ b/application/HuntingCamera/build/hunting_camera.cmake @@ -7,9 +7,10 @@ set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_S set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/FilesManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/StorageManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade/include") +set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/IpcConfig/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/StatusCode/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/Log/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${HAL_SOURCE_PATH}/include") -set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager FilesManager StorageManager HuntingUpgrade IpcConfig StatusCode Log Hal pthread dl) \ No newline at end of file +set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager FilesManager StorageManager HuntingUpgrade IpcConfig DeviceManager StatusCode Log Hal pthread dl) \ No newline at end of file diff --git a/application/HuntingCamera/src/MainThread.cpp b/application/HuntingCamera/src/MainThread.cpp index 628e91ec..b1456515 100644 --- a/application/HuntingCamera/src/MainThread.cpp +++ b/application/HuntingCamera/src/MainThread.cpp @@ -14,6 +14,7 @@ */ #include "MainThread.h" #include "IAppManager.h" +#include "IDeviceManager.h" #include "IFilesManager.h" #include "IHalCpp.h" #include "IHuntingUpgrade.h" @@ -65,6 +66,7 @@ StatusCode MainThread::Init(void) mMainThreadRuning = true; CreateAllModules(); IHalCpp::GetInstance()->Init(); + IDeviceManager::GetInstance()->Init(); IMcuManager::GetInstance()->Init(); IStorageManager::GetInstance()->Init(); IIpcConfig::GetInstance()->Init(); @@ -79,6 +81,7 @@ StatusCode MainThread::UnInit(void) IIpcConfig::GetInstance()->UnInit(); IStorageManager::GetInstance()->UnInit(); IMcuManager::GetInstance()->UnInit(); + IDeviceManager::GetInstance()->UnInit(); IHalCpp::GetInstance()->UnInit(); DestoryAllModules(); ILogUnInit(); @@ -96,6 +99,7 @@ StatusCode MainThread::CreateAllModules(void) CreateMediaManagerModule(); CreateHuntingUpgradeModule(); CreateIpcConfigModule(); + CreateDeviceManagerModule(); return CreateStatusCode(STATUS_CODE_OK); } void MainThread::DestoryAllModules(void) @@ -110,6 +114,7 @@ void MainThread::DestoryAllModules(void) DestroyMcuManager(); DestroyHalCppModule(); DestroyIpcConfigModule(); + DestroyDeviceManagerModule(); } void MainThread::ResetAllPtrMaker(void) { diff --git a/hal/abstract/IHalCpp.cpp b/hal/abstract/IHalCpp.cpp index 92e05687..2e015841 100644 --- a/hal/abstract/IHalCpp.cpp +++ b/hal/abstract/IHalCpp.cpp @@ -21,26 +21,37 @@ camera_report_event::camera_report_event(const std::string &fileName, const Came } void VKeyHalMonitor::KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } void VKeyHal::CheckKeyStatus(void) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } void VKeyHal::GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } void VKeyHal::SetKeyMonitor(std::shared_ptr &monitor) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } +// std::string VKeyHal::GetKeyHalName(void) +// { +// return "undefined"; +// } StatusCode VWifiHal::OpenApMode(void) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode VWifiHal::CloseApMode(void) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } void VCameraHalMonitor::ReportEvent(const CameraReportEvent &event) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } void VCameraHal::SetCameraMonitor(std::shared_ptr &monitor) { @@ -48,6 +59,7 @@ void VCameraHal::SetCameraMonitor(std::shared_ptr &monitor) } void VSdCardHalMonitor::ReportEvent(const SdCardHalStatus &status) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); } std::shared_ptr &IHalCpp::GetInstance(std::shared_ptr *impl) { @@ -75,6 +87,7 @@ SdCardHalStatus VSdCardHal::GetSdCardStatus(void) StatusCode VSdCardHal::GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB, unsigned long long &usedSizeMB) { + LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode IHalCpp::Init(void) diff --git a/hal/include/IHalCpp.h b/hal/include/IHalCpp.h index 5fe8a8d8..84eb0548 100644 --- a/hal/include/IHalCpp.h +++ b/hal/include/IHalCpp.h @@ -63,6 +63,7 @@ public: virtual void CheckKeyStatus(void); virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event); virtual void SetKeyMonitor(std::shared_ptr &monitor); + // virtual std::string GetKeyHalName(void); }; class VLedHal { diff --git a/hal/src/HalCpp.cpp b/hal/src/HalCpp.cpp index 96078c7e..1e0a6c5b 100644 --- a/hal/src/HalCpp.cpp +++ b/hal/src/HalCpp.cpp @@ -58,6 +58,19 @@ StatusCode HalCpp::GetSdCardHal(std::shared_ptr &sdCard) sdCard = mSdCardHal; return CreateStatusCode(STATUS_CODE_OK); } +StatusCode HalCpp::GetAllKeys(std::map> &allKeys) +{ + LogInfo("GetAllKeys\n"); + for (auto &key : mKeys) { + std::shared_ptr keyControl = std::dynamic_pointer_cast(key); + if (nullptr == keyControl) { + LogError("keyControl is nullptr\n"); + continue; + } + allKeys.insert(std::make_pair(key->GetKeyName(), keyControl)); + } + return CreateStatusCode(STATUS_CODE_OK); +} void HalCpp::CheckAllPinVauleThread(void) { // mThreadRuning = true; diff --git a/hal/src/HalCpp.h b/hal/src/HalCpp.h index 427a74c7..87e627ba 100644 --- a/hal/src/HalCpp.h +++ b/hal/src/HalCpp.h @@ -27,6 +27,7 @@ public: StatusCode UnInit(void) override; StatusCode GetWifiHal(std::shared_ptr &wifi) override; StatusCode GetSdCardHal(std::shared_ptr &sdCard) override; + StatusCode GetAllKeys(std::map> &allKeys) override; private: void CheckAllPinVauleThread(void); diff --git a/middleware/DeviceManager/src/KeyManager.cpp b/middleware/DeviceManager/src/KeyManager.cpp index 74b4a75a..bb29d792 100644 --- a/middleware/DeviceManager/src/KeyManager.cpp +++ b/middleware/DeviceManager/src/KeyManager.cpp @@ -62,6 +62,7 @@ void KeyManager::StopTimer(void) } void KeyManager::Timer(void) { + LogInfo("Key timer started.\n"); mTimerRuning = true; std::map>::iterator iter; while (mTimerRuning) { diff --git a/test/application/HuntingCamera/CMakeLists.txt b/test/application/HuntingCamera/CMakeLists.txt index fadba1b5..f68cb66b 100644 --- a/test/application/HuntingCamera/CMakeLists.txt +++ b/test/application/HuntingCamera/CMakeLists.txt @@ -9,6 +9,8 @@ include_directories( ${HUNTTING_MAIN_INCLUDE_PATH} ${MIDDLEWARE_SOURCE_PATH}/McuManager/include ${MIDDLEWARE_SOURCE_PATH}/McuManager/src + ${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include + ${MIDDLEWARE_SOURCE_PATH}/DeviceManager/src ${UTILS_SOURCE_PATH}/McuProtocol/include ${UTILS_SOURCE_PATH}/UartDevice/include ${UTILS_SOURCE_PATH}/LedControl/include @@ -16,6 +18,7 @@ include_directories( ${TEST_SOURCE_PATH}/application/MissionManager/tool/include ${TEST_SOURCE_PATH}/middleware/McuManager/tool/include ${TEST_SOURCE_PATH}/middleware/AppManager/tool/include + ${TEST_SOURCE_PATH}/middleware/DeviceManager/tool/include ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include ${TEST_SOURCE_PATH}/utils/TestManager/include ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include @@ -38,7 +41,8 @@ endif() set(TARGET_NAME HuntingCameraTest) add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES}) -target_link_libraries(${TARGET_NAME} HuntingMainLib MissionManagerTestTool McuManagerTestTool McuAskBaseTestTool AppManagerTestTool HalTestTool TestManager gtest gmock pthread) +target_link_libraries(${TARGET_NAME} HuntingMainLib MissionManagerTestTool McuManagerTestTool McuAskBaseTestTool + AppManagerTestTool HalTestTool DeviceManagerTestTool TestManager gtest gmock pthread) if(${TEST_COVERAGE} MATCHES "true") target_link_libraries(${TARGET_NAME} gcov) endif() diff --git a/test/application/HuntingCamera/src_mock/DeviceManager_Mock_Test.cpp b/test/application/HuntingCamera/src_mock/DeviceManager_Mock_Test.cpp new file mode 100644 index 00000000..c9cd013d --- /dev/null +++ b/test/application/HuntingCamera/src_mock/DeviceManager_Mock_Test.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "AppManagerTestTool.h" +#include "GtestUsing.h" +#include "HalTestTool.h" +#include "HuntingCameraTest.h" +#include "ILog.h" +#include "MainThread.h" +#include "McuManagerTestTool.h" +#include "MissionManagerTestTool.h" +#include "TestManager.h" +#include +namespace DeviceManager_Mock_Test +{ +/** + * @brief Construct a new test f object + * ../output_files/test/bin/HuntingCameraTest + * --gtest_filter=HuntingCameraTest.HS_INTEGRATION_HunttingCamera_EXAMPLE_KeyControl + */ +TEST_F(HuntingCameraTest, HS_INTEGRATION_HunttingCamera_EXAMPLE_KeyControl) +{ + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + HalTestTool::MockKeyClick("reset", 1000); // Simulate pressing a button. + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MainThread::GetInstance()->Runing(); +} +} // namespace DeviceManager_Mock_Test \ No newline at end of file diff --git a/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp b/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp index 45833a80..9759b887 100644 --- a/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp +++ b/test/application/HuntingCamera/src_mock/HuntingCameraTest.cpp @@ -17,6 +17,7 @@ #include "ILog.h" #include "MainThread.h" #include +const char *KEY_RESET = "reset"; void MainThreadTest::CustomizationInit(void) { // Do nothing here to make sure test tool work. @@ -42,6 +43,7 @@ void HuntingCameraTest::SetUp() std::shared_ptr mainThread = std::make_shared(); MainThread::GetInstance(&mainThread); HalTestTool::Init(); + CreateAllKeysMcok(); AppManagerTestTool::Init(); MissionManagerTestTool::Init(); mLinuxTest = LinuxTest::CreateLinuxTest(); @@ -50,6 +52,7 @@ void HuntingCameraTest::SetUp() LinuxApiMock::GetInstance()->Init(); McuManagerTestTool::Init(mLinuxTest); HalTestTool::InitSdCardHal(mLinuxTest); + DeviceManagerTestTool::Init(); TestManager::Init(); } void HuntingCameraTest::TearDown() @@ -66,7 +69,9 @@ void HuntingCameraTest::TearDown() MainThread::GetInstance()->UnInit(); std::shared_ptr mainThread = std::make_shared(); MainThread::GetInstance(&mainThread); + DeviceManagerTestTool::UnInit(); DestroyAllCamerasMock(); + DestroyAllKeysMock(); } void HuntingCameraTest::CreateAllCamerasMcok(void) { @@ -76,4 +81,18 @@ void HuntingCameraTest::CreateAllCamerasMcok(void) void HuntingCameraTest::DestroyAllCamerasMock(void) { mAllCamerasMock.clear(); +} +void HuntingCameraTest::CreateAllKeysMcok(void) +{ + std::shared_ptr key = HalTestTool::MakeKeyHalTest(KEY_RESET); + mAllKeysMock[KEY_RESET] = key; + // std::shared_ptr led = HalTestTool::MakeLedHalTest(LED_TEST); + // mAllLedsMock[LED_TEST] = led; + HalTestTool::SetAllKeysResult(mAllKeysMock); +} +void HuntingCameraTest::DestroyAllKeysMock(void) +{ + + mAllKeysMock.clear(); + // mAllLedsMock.clear(); } \ No newline at end of file diff --git a/test/application/HuntingCamera/src_mock/HuntingCameraTest.h b/test/application/HuntingCamera/src_mock/HuntingCameraTest.h index cfb656c9..3cae61d3 100644 --- a/test/application/HuntingCamera/src_mock/HuntingCameraTest.h +++ b/test/application/HuntingCamera/src_mock/HuntingCameraTest.h @@ -15,6 +15,7 @@ #ifndef HUNTING_CAMERA_TEST_H #define HUNTING_CAMERA_TEST_H #include "AppManagerTestTool.h" +#include "DeviceManagerTestTool.h" #include "GtestUsing.h" #include "HalTestTool.h" #include "LinuxApiMock.h" @@ -31,11 +32,12 @@ public: void CustomizationInit(void) override; }; class HuntingCameraTest : public testing::Test, - public TestManager, - public MissionManagerTestTool, - public McuManagerTestTool, - public AppManagerTestTool, - public HalTestTool + public TestManager, + public MissionManagerTestTool, + public McuManagerTestTool, + public AppManagerTestTool, + public DeviceManagerTestTool, + virtual public HalTestTool { public: HuntingCameraTest(); @@ -48,10 +50,13 @@ public: private: void CreateAllCamerasMcok(void); void DestroyAllCamerasMock(void); + void CreateAllKeysMcok(void); + void DestroyAllKeysMock(void); protected: std::shared_ptr mLinuxTest; std::map> mAllCamerasMock; + std::map> mAllKeysMock; }; #endif \ No newline at end of file diff --git a/test/hal/tool/src/HalMakePtrTest.cpp b/test/hal/tool/src/HalMakePtrTest.cpp index ca38a6d2..49ecd77b 100644 --- a/test/hal/tool/src/HalMakePtrTest.cpp +++ b/test/hal/tool/src/HalMakePtrTest.cpp @@ -58,4 +58,15 @@ StatusCode HalMakePtrTest::CreateSdCardHal(std::shared_ptr &impl) { impl = mSdCardHalMock; return CreateStatusCode(STATUS_CODE_OK); +} +StatusCode HalMakePtrTest::CreateAllKeyHal(std::vector> &keys) +{ + if (mKeysMock.size() > 0) { + LogInfo("Create mock keys.size = %d\n", mKeysMock.size()); + keys = mKeysMock; + } + else { + HalMakePtr::CreateAllKeyHal(keys); + } + return CreateStatusCode(STATUS_CODE_OK); } \ No newline at end of file diff --git a/test/hal/tool/src/HalMakePtrTest.h b/test/hal/tool/src/HalMakePtrTest.h index 93cf6c1d..d2ca99db 100644 --- a/test/hal/tool/src/HalMakePtrTest.h +++ b/test/hal/tool/src/HalMakePtrTest.h @@ -28,9 +28,11 @@ public: virtual ~HalMakePtrTest(); StatusCode CreateHalSharePtr(std::shared_ptr &impl) override; StatusCode CreateSdCardHal(std::shared_ptr &impl) override; + StatusCode CreateAllKeyHal(std::vector> &keys) override; public: std::shared_ptr mHalCppMock; std::shared_ptr mSdCardHalMock; + std::vector> mKeysMock; }; #endif \ No newline at end of file diff --git a/test/hal/tool/src/HalTestTool.cpp b/test/hal/tool/src/HalTestTool.cpp index 2a42fe75..6634a1d5 100644 --- a/test/hal/tool/src/HalTestTool.cpp +++ b/test/hal/tool/src/HalTestTool.cpp @@ -199,9 +199,26 @@ void HalTestTool::SetAllKeysResult(std::shared_ptr &vMock, LogError("vMock error.\n"); return; } - EXPECT_CALL(*mock.get(), GetAllKeysTrace(_)) - .WillRepeatedly(DoAll(SetArgReferee<0>(allKeys), Return(CreateStatusCode(STATUS_CODE_OK)))); - InitAllKeysMock(allKeys); + // EXPECT_CALL(*mock.get(), GetAllKeysTrace(_)) + // .WillRepeatedly(DoAll(SetArgReferee<0>(allKeys), Return(CreateStatusCode(STATUS_CODE_OK)))); + // InitAllKeysMock(allKeys); + std::vector> keysMock; + std::shared_ptr impl = HalMakePtr::GetInstance(); + std::shared_ptr test = std::dynamic_pointer_cast(impl); + if (test) { + for (auto &key : allKeys) { + std::shared_ptr keyMock = std::dynamic_pointer_cast(key.second); + if (keyMock) { + keysMock.push_back(keyMock); + LogInfo("Create key mock. name = %s\n", keyMock->GetKeyName().c_str()); + } + else { + LogWarning("Can't create key mock.\n"); + } + } + test->mKeysMock = keysMock; + LogInfo("Create all keys mock. size = %d\n", keysMock.size()); + } } void HalTestTool::SetAllLedsResult(std::shared_ptr &vMock, std::map> &allLeds) diff --git a/test/utils/LinuxApiMock/src/LinuxTestImpl.cpp b/test/utils/LinuxApiMock/src/LinuxTestImpl.cpp index 39d1966f..5fc68e4f 100644 --- a/test/utils/LinuxApiMock/src/LinuxTestImpl.cpp +++ b/test/utils/LinuxApiMock/src/LinuxTestImpl.cpp @@ -151,14 +151,14 @@ void LinuxTestImpl::ApiUnlock(void) } void LinuxTestImpl::ApiUnlockThread(void) { - LogInfo("ApiUnlockThread\n"); - if (mApiThread.joinable()) { - mApiThread.join(); - } - auto api_unlock = [](std::shared_ptr test) { - std::this_thread::sleep_for(std::chrono::milliseconds(API_LOCK_TIME_MS)); - test->ApiUnlock(); - }; - std::shared_ptr test = std::dynamic_pointer_cast(LinuxTest::shared_from_this()); - mApiThread = std::thread(api_unlock, test); + // LogInfo("ApiUnlockThread\n"); + // if (mApiThread.joinable()) { + // mApiThread.join(); + // } + // auto api_unlock = [](std::shared_ptr test) { + // std::this_thread::sleep_for(std::chrono::milliseconds(API_LOCK_TIME_MS)); + // test->ApiUnlock(); + // }; + // std::shared_ptr test = std::dynamic_pointer_cast(LinuxTest::shared_from_this()); + // mApiThread = std::thread(api_unlock, test); } \ No newline at end of file diff --git a/test/utils/LinuxApiMock/src/WrapApi.cpp b/test/utils/LinuxApiMock/src/WrapApi.cpp index 688eaa84..731ffeaa 100644 --- a/test/utils/LinuxApiMock/src/WrapApi.cpp +++ b/test/utils/LinuxApiMock/src/WrapApi.cpp @@ -15,52 +15,60 @@ #include "WrapApi.h" #include "LinuxApiMock.h" #include -static std::mutex gMutex; #ifdef __cplusplus extern "C" { #endif int __wrap_fx_open(const char *pathname, int flags) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_open(pathname, flags); } int __wrap_fx_tcgetattr(int fd, struct termios *termios_p) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_tcgetattr(fd, termios_p); } int __wrap_fx_tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_tcsetattr(fd, optional_actions, termios_p); } ssize_t __wrap_fx_write(int fd, const void *buf, size_t count) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_write(fd, buf, count); } ssize_t __wrap_fx_read(int fd, void *buf, size_t count) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_read(fd, buf, count); } int __wrap_fx_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { - std::lock_guard locker(gMutex); + static std::mutex gMutex; + std::lock_guard locker(gMutex); // TODO: The select function can cause severe blocking here. return LinuxApiMock::GetInstance()->fx_select(nfds, readfds, writefds, exceptfds, timeout); } int __wrap_fx_fstat(int fd, struct stat *statbuf) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_fstat(fd, statbuf); } int __wrap_fx_access(const char *pathname, int mode) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_access(pathname, mode); } FILE *__wrap_fx_fopen(const char *pathname, const char *mode) { + static std::mutex gMutex; std::lock_guard locker(gMutex); return LinuxApiMock::GetInstance()->fx_fopen(pathname, mode); } diff --git a/tools/version_release/VersionReleaseTool b/tools/version_release/VersionReleaseTool index c08691d5..95da2739 100755 Binary files a/tools/version_release/VersionReleaseTool and b/tools/version_release/VersionReleaseTool differ diff --git a/utils/KeyControl/src/KeyControl.cpp b/utils/KeyControl/src/KeyControl.cpp index eac5f610..01ab7e09 100644 --- a/utils/KeyControl/src/KeyControl.cpp +++ b/utils/KeyControl/src/KeyControl.cpp @@ -86,6 +86,7 @@ void KeyControl::KeyPressingTrigger(const std::string &key) * long press events at the application level. */ } + // LogInfo("KeyPressingTrigger: %s, %d", key.c_str(), mPressingTime); if (mPressingTime != KEY_NOT_PRESSING && mPressingTime % KEY_ACTION_HOLD_DWON == 0) { KeyEventTrigger(key, KeyEvent::HOLD_DOWN, mPressingTime); } diff --git a/utils/Log/abstract/ILog.cpp b/utils/Log/abstract/ILog.cpp index fb928513..a07cb08f 100644 --- a/utils/Log/abstract/ILog.cpp +++ b/utils/Log/abstract/ILog.cpp @@ -52,6 +52,8 @@ void NewILog(ILog **object) } void ResetLogImpl(ILog *impl) { - // log_instance->free(log_instance); + if (log_instance) { + log_instance->free(log_instance); + } log_instance = impl; } \ No newline at end of file