From 562f07b53e60b017b10ea7e90617759ca5137e9d Mon Sep 17 00:00:00 2001 From: yangliping Date: Fri, 22 Aug 2025 16:28:24 +0800 Subject: [PATCH] fix warning Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICUA4J?from=project-issue Signed-off-by: yangliping --- compiler_service/include/aot_compiler_impl.h | 1 + .../include/aot_compiler_service.h | 4 +++ compiler_service/src/aot_compiler_impl.cpp | 5 ++++ compiler_service/src/aot_compiler_service.cpp | 15 +++++++++++ .../aotcompilerimpl_unit.cpp | 21 +++------------ .../aotcompilerservice_unit.cpp | 27 +++++++------------ 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/compiler_service/include/aot_compiler_impl.h b/compiler_service/include/aot_compiler_impl.h index 46e4eadb6b..2b1f85988d 100644 --- a/compiler_service/include/aot_compiler_impl.h +++ b/compiler_service/include/aot_compiler_impl.h @@ -45,6 +45,7 @@ public: void HandleThermalLevelChanged(const int32_t level); int32_t SendSysEvent(const std::unordered_map &argsMap) const; std::string ParseArkCacheFromArgs(const std::unordered_map &argsMap) const; + bool IsAllowAotCompiler() const; protected: void DropCapabilities() const; diff --git a/compiler_service/include/aot_compiler_service.h b/compiler_service/include/aot_compiler_service.h index 92060e56cc..8e239ff7d3 100644 --- a/compiler_service/include/aot_compiler_service.h +++ b/compiler_service/include/aot_compiler_service.h @@ -46,6 +46,10 @@ public: int32_t StopAotCompiler() override; int32_t GetAOTVersion(std::string& sigData) override; int32_t NeedReCompile(const std::string& args, bool& sigData) override; + bool IsPowerEventSubscribered() const; + bool IsScreenStatusSubscribered() const; + bool IsThermalLevelEventSubscribered() const; + protected: void OnStart() override; void OnStop() override; diff --git a/compiler_service/src/aot_compiler_impl.cpp b/compiler_service/src/aot_compiler_impl.cpp index d79b7230c6..6fc85de2d9 100644 --- a/compiler_service/src/aot_compiler_impl.cpp +++ b/compiler_service/src/aot_compiler_impl.cpp @@ -365,4 +365,9 @@ void AotCompilerImpl::ResetState() state_.running = false; state_.childPid = -1; } + +bool AotCompilerImpl::IsAllowAotCompiler() const +{ + return allowAotCompiler_.load(); +} } // namespace OHOS::ArkCompiler diff --git a/compiler_service/src/aot_compiler_service.cpp b/compiler_service/src/aot_compiler_service.cpp index d379d69e0b..b9195793be 100644 --- a/compiler_service/src/aot_compiler_service.cpp +++ b/compiler_service/src/aot_compiler_service.cpp @@ -246,4 +246,19 @@ void AotCompilerService::UnRegisterThermalMgrListener() isThermalLevelEventSubscribered_ = false; LOG_SA(INFO) << "AotCompilerService::UnRegisterThermalMgrListener done"; } + +bool AotCompilerService::IsPowerEventSubscribered() const +{ + return isPowerEventSubscribered_; +} + +bool AotCompilerService::IsScreenStatusSubscribered() const +{ + return isScreenStatusSubscribered_; +} + +bool AotCompilerService::IsThermalLevelEventSubscribered() const +{ + return isThermalLevelEventSubscribered_; +} } // namespace OHOS::ArkCompiler \ No newline at end of file diff --git a/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp b/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp index 7411c4dbc6..3372683194 100644 --- a/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp +++ b/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp @@ -271,13 +271,8 @@ HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_006, TestSize.Level0) HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_007, TestSize.Level0) { AotCompilerImpl &aotImpl = AotCompilerImplMock::GetInstance(); - bool viewData1 = true; - int32_t viewData2 = 101010; - std::string viewData3 = "101010"; aotImpl.HandlePowerDisconnected(); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 101010); - EXPECT_STREQ(viewData3.c_str(), "101010"); + EXPECT_TRUE(aotImpl.IsAllowAotCompiler()); } /** @@ -288,13 +283,8 @@ HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_007, TestSize.Level0) HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_008, TestSize.Level0) { AotCompilerImpl &aotImpl = AotCompilerImplMock::GetInstance(); - bool viewData1 = true; - int32_t viewData2 = 010101; - std::string viewData3 = "010101"; aotImpl.HandleScreenOn(); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 010101); - EXPECT_STREQ(viewData3.c_str(), "010101"); + EXPECT_TRUE(aotImpl.IsAllowAotCompiler()); } /** @@ -305,13 +295,8 @@ HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_008, TestSize.Level0) HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_009, TestSize.Level0) { AotCompilerImpl &aotImpl = AotCompilerImplMock::GetInstance(); - bool viewData1 = true; - int32_t viewData2 = 010101; - std::string viewData3 = "010101"; aotImpl.HandleThermalLevelChanged(1); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 010101); - EXPECT_STREQ(viewData3.c_str(), "010101"); + EXPECT_TRUE(aotImpl.IsAllowAotCompiler()); } /** diff --git a/compiler_service/test/unittest/aotcompilerservice_unit/aotcompilerservice_unit.cpp b/compiler_service/test/unittest/aotcompilerservice_unit/aotcompilerservice_unit.cpp index 280f83ad6e..2adcee95da 100644 --- a/compiler_service/test/unittest/aotcompilerservice_unit/aotcompilerservice_unit.cpp +++ b/compiler_service/test/unittest/aotcompilerservice_unit/aotcompilerservice_unit.cpp @@ -226,15 +226,12 @@ HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_010, TestSize.Level0) HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_011, TestSize.Level0) { AotCompilerService aotService; - bool viewData1 = true; - int32_t viewData2 = 101010; - std::string viewData3 = "101010"; aotService.RegisterPowerDisconnectedListener(); + EXPECT_TRUE(aotService.IsPowerEventSubscribered()); aotService.UnRegisterPowerDisconnectedListener(); + EXPECT_FALSE(aotService.IsPowerEventSubscribered()); aotService.UnRegisterPowerDisconnectedListener(); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 101010); - EXPECT_STREQ(viewData3.c_str(), "101010"); + EXPECT_FALSE(aotService.IsPowerEventSubscribered()); } /** @@ -245,15 +242,12 @@ HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_011, TestSize.Level0) HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_012, TestSize.Level0) { AotCompilerService aotService; - bool viewData1 = true; - int32_t viewData2 = 101010; - std::string viewData3 = "101010"; aotService.RegisterScreenStatusSubscriber(); + EXPECT_TRUE(aotService.IsScreenStatusSubscribered()); aotService.UnRegisterScreenStatusSubscriber(); + EXPECT_FALSE(aotService.IsScreenStatusSubscribered()); aotService.UnRegisterScreenStatusSubscriber(); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 101010); - EXPECT_STREQ(viewData3.c_str(), "101010"); + EXPECT_FALSE(aotService.IsScreenStatusSubscribered()); } /** @@ -264,15 +258,12 @@ HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_012, TestSize.Level0) HWTEST_F(AotCompilerServiceTest, AotCompilerServiceTest_013, TestSize.Level0) { AotCompilerService aotService; - bool viewData1 = true; - int32_t viewData2 = 101010; - std::string viewData3 = "101010"; aotService.RegisterThermalMgrListener(); + EXPECT_TRUE(aotService.IsThermalLevelEventSubscribered()); aotService.UnRegisterThermalMgrListener(); + EXPECT_FALSE(aotService.IsThermalLevelEventSubscribered()); aotService.UnRegisterThermalMgrListener(); - EXPECT_TRUE(viewData1); - EXPECT_EQ(viewData2, 101010); - EXPECT_STREQ(viewData3.c_str(), "101010"); + EXPECT_FALSE(aotService.IsThermalLevelEventSubscribered()); } /** -- Gitee