diff --git a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h index 65ff6baa05751f1504223f27254f05bfd8dd266a..81c3e08af97ece5c028725aaad042a43349e2145 100644 --- a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h +++ b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h @@ -68,6 +68,9 @@ public: // notify process died virtual void NotifyProcessDied(int32_t pid) = 0; + + // notify process registered + virtual void AddSecurityComponentProcess(int32_t pid) = 0; }; // for client @@ -105,6 +108,8 @@ public: static void RegisterScIdEnhance(int32_t scId); static void UnregisterScIdEnhance(int32_t scId); + static void AddSecurityComponentProcess(int32_t pid); + static SecCompInputEnhanceInterface* inputHandler; static bool isEnhanceInputHandlerInit; diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 8478062bdcef3ea705ae41fde95caec73640fa56..5dfa2e9e910517cec5e27204e5a92b9aa2ad65ee 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -105,6 +105,16 @@ int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& clickInfo return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE; } +void SecCompEnhanceAdapter::AddSecurityComponentProcess(int32_t pid) +{ + if (!isEnhanceSrvHandlerInit) { + InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); + } + if (srvHandler != nullptr) { + srvHandler->AddSecurityComponentProcess(pid); + } +} + bool SecCompEnhanceAdapter::EnhanceDataPreprocess(std::string& componentInfo) { if (!isEnhanceClientHandlerInit) { diff --git a/interfaces/inner_api/security_component/include/i_sec_comp_service.h b/interfaces/inner_api/security_component/include/i_sec_comp_service.h index 8df9269e9c09bbad526817c5238e7719da7fe8d4..cd76c2e7aade5c3fe45c89d48888180d50d631f9 100644 --- a/interfaces/inner_api/security_component/include/i_sec_comp_service.h +++ b/interfaces/inner_api/security_component/include/i_sec_comp_service.h @@ -38,6 +38,7 @@ public: const SecCompClickEvent& clickInfo, sptr callerToken) = 0; virtual bool VerifySavePermission(AccessToken::AccessTokenID tokenId) = 0; virtual sptr GetEnhanceRemoteObject() = 0; + virtual int32_t PreRegisterSecCompProcess() = 0; }; } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/include/sec_comp_client.h b/interfaces/inner_api/security_component/include/sec_comp_client.h index 719489f71cef6ac8a276cb36af8de827d6670ee9..fca78d5f19d7cb1a76685082a34f9eb193a57961 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_client.h +++ b/interfaces/inner_api/security_component/include/sec_comp_client.h @@ -37,6 +37,7 @@ public: const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken); bool VerifySavePermission(AccessToken::AccessTokenID tokenId); sptr GetEnhanceRemoteObject(bool doLoadSa); + int32_t PreRegisterSecCompProcess(); void FinishStartSASuccess(const sptr& remoteObject); void FinishStartSAFail(); diff --git a/interfaces/inner_api/security_component/include/sec_comp_kit.h b/interfaces/inner_api/security_component/include/sec_comp_kit.h index 0f0ee946efd5b15a644845d67ca1ab49ce2deb35..93c7e531c08d711b562178dce43bbb7b26ac0484 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_kit.h +++ b/interfaces/inner_api/security_component/include/sec_comp_kit.h @@ -33,6 +33,7 @@ public: std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken = nullptr); static bool VerifySavePermission(AccessToken::AccessTokenID tokenId); static sptr GetEnhanceRemoteObject(bool isLoad); + static int32_t PreRegisterSecCompProcess(); }; } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/include/sec_comp_proxy.h b/interfaces/inner_api/security_component/include/sec_comp_proxy.h index 9b5b4e213cdd6c25da866290fd7a67929ecff4d5..f63496527e122afc07812dc82ff10d68142d67c6 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_proxy.h +++ b/interfaces/inner_api/security_component/include/sec_comp_proxy.h @@ -33,6 +33,7 @@ public: const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; + int32_t PreRegisterSecCompProcess() override; private: static inline BrokerDelegator delegator_; diff --git a/interfaces/inner_api/security_component/include/security_component_service_ipc_interface_code.h b/interfaces/inner_api/security_component/include/security_component_service_ipc_interface_code.h index 968ad969b21152ca7d7887c3eba2b5d833adc4cc..f87389d69364c8f057a61828ab053fc5c9376655 100644 --- a/interfaces/inner_api/security_component/include/security_component_service_ipc_interface_code.h +++ b/interfaces/inner_api/security_component/include/security_component_service_ipc_interface_code.h @@ -27,6 +27,7 @@ enum SecurityComponentServiceInterfaceCode { REPORT_SECURITY_COMPONENT_CLICK_EVENT = 3, GET_SECURITY_COMPONENT_ENHANCE_OBJECT = 4, VERIFY_TEMP_SAVE_PERMISSION = 5, + PRE_REGISTER_PROCESS = 6, }; enum EnhanceInterfaceCode { @@ -41,4 +42,3 @@ enum EnhanceCallbackCheckCode { } // namespace Security } // namespace OHOS #endif // SECURITY_COMPONENT_IPC_INTERFACE_CODE_H - diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/interfaces/inner_api/security_component/src/sec_comp_client.cpp index 27545fa62817064ee75dbfdb0bdb85eb0717aafa..7ce91dc5df616938da8c1ff2b0b0fcb38db67209 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_client.cpp @@ -113,6 +113,17 @@ sptr SecCompClient::GetEnhanceRemoteObject(bool doLoadSa) return proxy->GetEnhanceRemoteObject(); } +int32_t SecCompClient::PreRegisterSecCompProcess() +{ + auto proxy = GetProxy(true); + if (proxy == nullptr) { + SC_LOG_ERROR(LABEL, "Proxy is null"); + return SC_SERVICE_ERROR_VALUE_INVALID; + } + + return proxy->PreRegisterSecCompProcess(); +} + bool SecCompClient::StartLoadSecCompSa() { { diff --git a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp index 04562ca83b0b3ba8dac313eddc20b70e00e1fe5e..a8314fb6208d32422b3f8f6707ae60cdc1f74c64 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp @@ -133,6 +133,11 @@ sptr SecCompKit::GetEnhanceRemoteObject(bool isLoad) { return SecCompClient::GetInstance().GetEnhanceRemoteObject(isLoad); } + +int32_t SecCompKit::PreRegisterSecCompProcess() +{ + return SecCompClient::GetInstance().PreRegisterSecCompProcess(); +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp index 3b567699306305f6c512537844a6f1118edbc262..6182d7a7e49474ff142c42d44425deaa108f1314 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp @@ -269,6 +269,36 @@ sptr SecCompProxy::GetEnhanceRemoteObject() } return callback; } + +int32_t SecCompProxy::PreRegisterSecCompProcess() +{ + MessageParcel data; + if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { + SC_LOG_ERROR(LABEL, "PreRegister write descriptor fail"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + SC_LOG_ERROR(LABEL, "PreRegister remote service is null"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + int32_t requestResult = remote->SendRequest( + static_cast(SecurityComponentServiceInterfaceCode::PRE_REGISTER_PROCESS), + data, reply, option); + if (requestResult != SC_OK) { + SC_LOG_ERROR(LABEL, "PreRegister request fail, result: %{public}d", requestResult); + return requestResult; + } + int32_t res; + if (!reply.ReadInt32(res)) { + SC_LOG_ERROR(LABEL, "PreRegister read int32 fail"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + return res; +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index f4bd825387476f25964c1c26634db2e2e2c0abb3..5dde35d05bfef6b75559573ce271c3f602644dec 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -155,7 +155,7 @@ SecCompEntity* SecCompManager::GetSecurityComponentFromList(int32_t pid, int32_t bool SecCompManager::IsForegroundCompExist() { return std::any_of(componentMap_.begin(), componentMap_.end(), [](const auto & iter) { - return (iter.second.isForeground) && (iter.second.compList.size() > 0); + return iter.second.isForeground; }); } @@ -285,6 +285,29 @@ void SecCompManager::SendCheckInfoEnhanceSysEvent(int32_t scId, } } +int32_t SecCompManager::AddSecurityComponentProcess(const SecCompCallerInfo& caller) +{ + DelayExitTask::GetInstance().Stop(); + { + OHOS::Utils::UniqueWriteGuard lk(this->componentInfoLock_); + if (isSaExit_) { + SC_LOG_ERROR(LABEL, "SA is exiting, retry..."); + return SC_SERVICE_ERROR_SERVICE_NOT_EXIST; + } + + auto iter = componentMap_.find(caller.pid); + if (iter != componentMap_.end()) { + ProcessCompInfos newProcess; + newProcess.isForeground = true; + newProcess.tokenId = caller.tokenId; + componentMap_[caller.pid] = newProcess; + } + SecCompEnhanceAdapter::EnableInputEnhance(); + } + SecCompEnhanceAdapter::AddSecurityComponentProcess(caller.pid); + return SC_OK; +} + int32_t SecCompManager::RegisterSecurityComponent(SecCompType type, const nlohmann::json& jsonComponent, const SecCompCallerInfo& caller, int32_t& scId) { diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.h b/services/security_component_service/sa/sa_main/sec_comp_manager.h index d6a79fa37ccd5af56de1c75cd4e56391ac03c31e..92e0faa8db722f510b8d333e4df3e9bd403885a9 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.h +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.h @@ -65,6 +65,7 @@ public: bool Initialize(); void ExitSaProcess(); void ExitWhenAppMgrDied(); + int32_t AddSecurityComponentProcess(const SecCompCallerInfo& caller); private: SecCompManager(); diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.cpp b/services/security_component_service/sa/sa_main/sec_comp_service.cpp index 19451bd5171ad277a927cf138f125cd579e9bd67..7dec7649275ad7efc5f848732bb34f324724c218 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_service.cpp @@ -84,8 +84,6 @@ void SecCompService::OnStop() SC_LOG_INFO(LABEL, "Stop service"); state_ = ServiceRunningState::STATE_NOT_START; UnregisterAppStateObserver(); - iAppMgr_ = nullptr; - appStateObserver_ = nullptr; } bool SecCompService::RegisterAppStateObserver() @@ -236,6 +234,16 @@ int32_t SecCompService::ReportSecurityComponentClickEvent(int32_t scId, return res; } +int32_t SecCompService::PreRegisterSecCompProcess() +{ + SecCompCallerInfo caller; + if (!GetCallerInfo(caller)) { + SC_LOG_ERROR(LABEL, "Check caller failed"); + return SC_SERVICE_ERROR_VALUE_INVALID; + } + return SecCompManager::GetInstance().AddSecurityComponentProcess(caller); +} + bool SecCompService::VerifySavePermission(AccessToken::AccessTokenID tokenId) { return SecCompPermManager::GetInstance().VerifySavePermission(tokenId); diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.h b/services/security_component_service/sa/sa_main/sec_comp_service.h index f9b43de3771938159d1c114e4319f2c5af15dccb..0ac59c79f93e9fa82753c1a9d6b6ead5161f7686 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.h +++ b/services/security_component_service/sa/sa_main/sec_comp_service.h @@ -47,6 +47,7 @@ public: const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; + int32_t PreRegisterSecCompProcess() override; int Dump(int fd, const std::vector& args) override; diff --git a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp index 85a36b49108efcd700eb57c49ad3e103b41d0007..417e512199979f6403408d53c7ef0352b87e117e 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp @@ -205,6 +205,16 @@ int32_t SecCompStub::GetEnhanceRemoteObjectInner(MessageParcel& data, MessagePar return SC_OK; } +int32_t SecCompStub::PreRegisterSecCompProcessInner(MessageParcel& data, MessageParcel& reply) +{ + int32_t res = this->PreRegisterSecCompProcess(); + if (!reply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "preRegister write result fail"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + return SC_OK; +} + bool SecCompStub::IsMediaLibraryCalling() { int32_t uid = IPCSkeleton::GetCallingUid(); @@ -236,6 +246,9 @@ SecCompStub::SecCompStub() requestFuncMap_[static_cast( SecurityComponentServiceInterfaceCode::GET_SECURITY_COMPONENT_ENHANCE_OBJECT)] = &SecCompStub::GetEnhanceRemoteObjectInner; + requestFuncMap_[static_cast( + SecurityComponentServiceInterfaceCode::PRE_REGISTER_PROCESS)] = + &SecCompStub::PreRegisterSecCompProcessInner; } SecCompStub::~SecCompStub() diff --git a/services/security_component_service/sa/sa_main/sec_comp_stub.h b/services/security_component_service/sa/sa_main/sec_comp_stub.h index 8b4262d9b994278072a41d68faf57a64d773bfba..57ce8b47fd3a86ac2de173b4645525dfd4796491 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_stub.h +++ b/services/security_component_service/sa/sa_main/sec_comp_stub.h @@ -37,6 +37,7 @@ private: int32_t ReportSecurityComponentClickEventInner(MessageParcel& data, MessageParcel& reply); int32_t VerifySavePermissionInner(MessageParcel& data, MessageParcel& reply); int32_t GetEnhanceRemoteObjectInner(MessageParcel& data, MessageParcel& reply); + int32_t PreRegisterSecCompProcessInner(MessageParcel& data, MessageParcel& reply); bool IsMediaLibraryCalling(); using RequestFuncType = int32_t (SecCompStub::*)(MessageParcel& data, MessageParcel& reply); diff --git a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp index d6259e3c60a1aa944f0fc59a320bbec6d1574d2f..594d42a8953650b57a2e6566d2eea4095b2626ff 100644 --- a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp +++ b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp @@ -105,6 +105,11 @@ sptr SecCompEnhanceAdapter::GetEnhanceRemoteObject() SC_LOG_DEBUG(LABEL, "GetEnhanceRemoteObject success"); return nullptr; } + +void SecCompEnhanceAdapter::AddSecurityComponentProcess(int32_t pid) +{ + SC_LOG_DEBUG(LABEL, "AddSecurityComponentProcess success"); +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp index 8207e3678d278b10daf0334719f74ea7d75098cc..ce721b3846876924c490542698741744f0293f0a 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp @@ -570,14 +570,14 @@ HWTEST_F(SecCompManagerTest, ExitSaProcess001, TestSize.Level1) std::shared_ptr saClient = std::make_shared(); ASSERT_NE(nullptr, saClient); SystemAbilityManagerClient::clientInstance = saClient.get(); - SystemAbilityManagerProxy proxy(nullptr); - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); + sptr proxy = new SystemAbilityManagerProxy(nullptr); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); instance->ExitSaProcess(); EXPECT_TRUE(instance->isSaExit_); instance->isSaExit_ = false; - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); - EXPECT_CALL(proxy, UnloadSystemAbility(testing::_)).WillOnce(testing::Return(-1)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); + EXPECT_CALL(*proxy, UnloadSystemAbility(testing::_)).WillOnce(testing::Return(-1)); instance->ExitSaProcess(); EXPECT_TRUE(instance->isSaExit_); } @@ -608,17 +608,17 @@ HWTEST_F(SecCompManagerTest, ExitWhenAppMgrDied001, TestSize.Level1) instance->ExitWhenAppMgrDied(); EXPECT_TRUE(instance->isSaExit_); - SystemAbilityManagerProxy proxy(nullptr); - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); + sptr proxy = new SystemAbilityManagerProxy(nullptr); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); instance->ExitWhenAppMgrDied(); EXPECT_TRUE(instance->isSaExit_); - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); instance->ExitWhenAppMgrDied(); EXPECT_TRUE(instance->isSaExit_); - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); - EXPECT_CALL(proxy, UnloadSystemAbility(testing::_)).WillOnce(testing::Return(-1)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); + EXPECT_CALL(*proxy, UnloadSystemAbility(testing::_)).WillOnce(testing::Return(-1)); instance->ExitWhenAppMgrDied(); EXPECT_TRUE(instance->isSaExit_); } diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp index 8f3bc96f7d5373a280303abe850cf0aa68a00004..8c724c5d99b9f3fbf600db4e1eed396f166d3bed 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp @@ -114,15 +114,15 @@ HWTEST_F(SecCompServiceTest, RegisterAppStateObserver001, TestSize.Level1) // GetSystemAbility get app mgr failed secCompService_->appStateObserver_ = nullptr; - SystemAbilityManagerProxy proxy(nullptr); - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); + sptr proxy = new SystemAbilityManagerProxy(nullptr); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); EXPECT_FALSE(secCompService_->RegisterAppStateObserver()); // RegisterApplicationStateObserver failed secCompService_->appStateObserver_ = nullptr; - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); - MockIRemoteObject object; - EXPECT_CALL(proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(&object)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); + sptr object = new MockIRemoteObject(); + EXPECT_CALL(*proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(object)); sptr appProxy = new (std::nothrow) MockAppMgrProxy(nullptr); MockAppMgrProxy::g_MockAppMgrProxy = appProxy; EXPECT_CALL(*MockAppMgrProxy::g_MockAppMgrProxy, @@ -131,8 +131,8 @@ HWTEST_F(SecCompServiceTest, RegisterAppStateObserver001, TestSize.Level1) // GetForegroundApplications failed secCompService_->appStateObserver_ = nullptr; - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); - EXPECT_CALL(proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(&object)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); + EXPECT_CALL(*proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(object)); EXPECT_CALL(*MockAppMgrProxy::g_MockAppMgrProxy, RegisterApplicationStateObserver(testing::_, testing::_)).WillOnce(testing::Return(0)); EXPECT_CALL(*MockAppMgrProxy::g_MockAppMgrProxy, @@ -142,8 +142,8 @@ HWTEST_F(SecCompServiceTest, RegisterAppStateObserver001, TestSize.Level1) // get one foreground app secCompService_->appStateObserver_ = nullptr; - EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(&proxy)); - EXPECT_CALL(proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(&object)); + EXPECT_CALL(*saClient, GetSystemAbilityManager()).WillOnce(testing::Return(proxy)); + EXPECT_CALL(*proxy, GetSystemAbility(testing::_)).WillOnce(testing::Return(object)); EXPECT_CALL(*MockAppMgrProxy::g_MockAppMgrProxy, RegisterApplicationStateObserver(testing::_, testing::_)).WillOnce(testing::Return(0)); EXPECT_CALL(*MockAppMgrProxy::g_MockAppMgrProxy, GetForegroundApplications(testing::_)) diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h index 27d6f0ee6babb9dc8d740f7b0345b5188b2c70c1..438c1f56d72b1fdbe6e811641eddc92d58733c19 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h @@ -52,12 +52,17 @@ public: bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override { return true; - } + }; sptr GetEnhanceRemoteObject() override { return nullptr; - } + }; + + int32_t PreRegisterSecCompProcess() override + { + return 0; + }; }; class SecCompStubTest : public testing::Test {