mirror of
https://github.com/openharmony/security_security_component_manager.git
synced 2026-08-24 22:51:27 -04:00
-3
@@ -522,9 +522,6 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L
|
||||
auto token = proxy->AsObject();
|
||||
EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID,
|
||||
SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, token));
|
||||
setuid(100);
|
||||
EXPECT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, SecCompKit::UnregisterSecurityComponent(scId));
|
||||
setuid(g_selfUid);
|
||||
EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId));
|
||||
system("param set sec.comp.enhance 0");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace SecurityComponent {
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "DelayExitTask"};
|
||||
static const std::string DELAY_EXIT_TASK = "DelayExitTask";
|
||||
static const int32_t DELAY_EXIT_MILLISECONDS = 30 * 1000; // 30s
|
||||
static const int32_t DELAY_EXIT_MILLISECONDS = 10 * 60 * 1000; // 10m
|
||||
}
|
||||
|
||||
DelayExitTask::DelayExitTask()
|
||||
@@ -69,4 +69,3 @@ void DelayExitTask::Stop()
|
||||
} // namespace SecurityComponent
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ int32_t SecCompManager::DeleteSecurityComponentFromList(int32_t pid, int32_t scI
|
||||
if (!IsForegroundCompExist()) {
|
||||
SecCompEnhanceAdapter::DisableInputEnhance();
|
||||
}
|
||||
DelayExitTask::GetInstance().Start();
|
||||
return SC_OK;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +156,14 @@ 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;
|
||||
return (iter.second.isForeground) && (iter.second.compList.size() > 0);
|
||||
});
|
||||
}
|
||||
|
||||
bool SecCompManager::IsCompExist()
|
||||
{
|
||||
return std::any_of(componentMap_.begin(), componentMap_.end(), [](const auto & iter) {
|
||||
return (iter.second.compList.size() > 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -218,7 +226,7 @@ void SecCompManager::NotifyProcessDied(int32_t pid)
|
||||
void SecCompManager::ExitSaProcess()
|
||||
{
|
||||
OHOS::Utils::UniqueReadGuard<OHOS::Utils::RWLock> lk(this->componentInfoLock_);
|
||||
if (!componentMap_.empty() || !malicious_.IsMaliciousAppListEmpty()) {
|
||||
if (IsCompExist()) {
|
||||
SC_LOG_INFO(LABEL, "Apps using security component still exist, no exit sa");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
private:
|
||||
SecCompManager();
|
||||
bool IsForegroundCompExist();
|
||||
bool IsCompExist();
|
||||
int32_t AddSecurityComponentToList(int32_t pid,
|
||||
AccessToken::AccessTokenID tokenId, const SecCompEntity& newEntity);
|
||||
int32_t DeleteSecurityComponentFromList(int32_t pid, int32_t scId);
|
||||
|
||||
@@ -210,10 +210,9 @@ int32_t SecCompService::UpdateSecurityComponent(int32_t scId, const std::string&
|
||||
int32_t SecCompService::UnregisterSecurityComponent(int32_t scId)
|
||||
{
|
||||
SecCompCallerInfo caller;
|
||||
if (!GetCallerInfo(caller)) {
|
||||
SC_LOG_ERROR(LABEL, "Check caller failed");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
caller.tokenId = IPCSkeleton::GetCallingTokenID();
|
||||
caller.pid = IPCSkeleton::GetCallingPid();
|
||||
caller.uid = IPCSkeleton::GetCallingUid();
|
||||
|
||||
return SecCompManager::GetInstance().UnregisterSecurityComponent(scId, caller);
|
||||
}
|
||||
|
||||
@@ -544,12 +544,6 @@ HWTEST_F(SecCompManagerTest, UpdateSecurityComponent002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(SecCompManagerTest, ExitSaProcess001, TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<SecCompManager> instance = std::make_shared<SecCompManager>();
|
||||
instance->malicious_.AddAppToMaliciousAppList(ServiceTestCommon::TEST_SC_ID_1);
|
||||
instance->ExitSaProcess();
|
||||
EXPECT_FALSE(instance->isSaExit_);
|
||||
|
||||
instance->malicious_.maliciousAppList_.clear();
|
||||
std::shared_ptr<LocationButton> compPtr = std::make_shared<LocationButton>();
|
||||
ASSERT_NE(nullptr, compPtr);
|
||||
compPtr->rect_.x_ = ServiceTestCommon::TEST_COORDINATE;
|
||||
@@ -557,6 +551,7 @@ HWTEST_F(SecCompManagerTest, ExitSaProcess001, TestSize.Level1)
|
||||
compPtr->rect_.width_ = ServiceTestCommon::TEST_COORDINATE;
|
||||
compPtr->rect_.height_ = ServiceTestCommon::TEST_COORDINATE;
|
||||
SecCompEntity entity(compPtr, ServiceTestCommon::TEST_TOKEN_ID, ServiceTestCommon::TEST_SC_ID_1);
|
||||
std::shared_ptr<SecCompManager> instance = std::make_shared<SecCompManager>();
|
||||
ASSERT_EQ(SC_OK,
|
||||
instance->AddSecurityComponentToList(ServiceTestCommon::TEST_PID_1, 0, entity));
|
||||
instance->ExitSaProcess();
|
||||
|
||||
Reference in New Issue
Block a user