diff --git a/compiler_service/include/aot_compiler_impl.h b/compiler_service/include/aot_compiler_impl.h index 46e4eadb6b53fdf947c1596e169fcc68d58cce9f..2b1f85988dafb36aefac5c43c5cd8a0799332637 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 92060e56ccf63811129e9f650a9b6e8b012b56cd..8e239ff7d3c3bdb4b1d8c454676591081e947b8f 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 d79b7230c689edf6c880dc0d9c1e435335e81f41..6fc85de2d9700f13335ef98c9a70c6263401d940 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 d379d69e0bde24cdc4c3600653c85f5543843152..b9195793bee2135a479448274310eb5765cf7487 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 7411c4dbc65732272b3dd7500826cda0065b5fb6..337268319452799399ebe709f807a4c133fa48a9 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 280f83ad6eb8b3db7ba6ca14888d1faf55054473..2adcee95da28e6ac6070cb6657461608b22d6d78 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()); } /**