From d1926e4e953f0af195cecf29360fdb0ff31c8bd4 Mon Sep 17 00:00:00 2001 From: z00797421 Date: Tue, 14 Jul 2026 00:46:16 +0800 Subject: [PATCH] modify review suggestion Change-Id: I65968877cad11544bd71b46a41ea1c63b758657b Signed-off-by: z00797421 --- .../ability_manager/include/ability_manager_errors.h | 5 +++++ services/abilitymgr/src/sa_interceptor_manager.cpp | 2 +- .../sa_interceptor_manager_test.cpp | 12 +++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index deda9965c6..ab7f8f4416 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -938,6 +938,11 @@ enum { */ ERR_PRELOAD_NOT_ENTRY_MODULE = 2097368, + /** + * Result (2097369) for sa interceptor not found when unregister. + */ + ERR_SA_INTERCEPTOR_NOT_EXIST = 2097369, + /** * Result (2097370-2097379) for StartUIAbilities Error. */ diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index f7a775660e..90ca4c27f5 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -87,7 +87,7 @@ int32_t SAInterceptorManager::RemoveSAInterceptor(sptr intercepto } } TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor not found"); - return ERR_OK; + return AAFwk::ERR_SA_INTERCEPTOR_NOT_EXIST; } bool SAInterceptorManager::SAInterceptorListIsEmpty() diff --git a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp index a829a49d7c..f6c3d0db8e 100644 --- a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp +++ b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp @@ -87,22 +87,16 @@ HWTEST_F(SAInterceptorManagerTest, AddSAInterceptor_0100, TestSize.Level1) /* * @tc.number: RemoveSAInterceptor_0100 * @tc.name: RemoveSAInterceptor - * @tc.desc: Verify RemoveSAInterceptor with null interceptor and non-exist interceptor + * @tc.desc: Verify RemoveSAInterceptor with null interceptor */ HWTEST_F(SAInterceptorManagerTest, RemoveSAInterceptor_0100, TestSize.Level1) { SAInterceptorManager::GetInstance().saInterceptors_.clear(); int32_t result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(nullptr); EXPECT_EQ(result, ERR_NULL_SA_INTERCEPTOR_EXECUTER); - sptr interceptor = new MockSAInterceptor(); - result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); + sptr remoteObj = new MockIRemoteObject(); + result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(remoteObj); EXPECT_EQ(result, ERR_SA_INTERCEPTOR_NOT_EXIST); - result = SAInterceptorManager::GetInstance().AddSAInterceptor(interceptor); - EXPECT_EQ(result, ERR_OK); - EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 1); - result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); - EXPECT_EQ(result, ERR_OK); - EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 0); } /*