From 51217176c62d5e2c778ceb32249f71ff5217847d Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 7 Apr 2022 21:54:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=BC=BAreportevent=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- services/common/src/bundle_active_service.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp index a7e36b0..7e7ea2e 100644 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -31,6 +31,7 @@ static const int PERIOD_YEARLY_JS = 4; static const int PERIOD_BEST_SERVICE = 4; static const int DELAY_TIME = 2000; static const std::string PERMITTED_PROCESS_NAME = "foundation"; +const int SYSTEM_UID = 1000; REGISTER_SYSTEM_ABILITY_BY_ID(BundleActiveService, DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID, true); const std::string NEEDED_PERMISSION = "ohos.permission.BUNDLE_ACTIVE_INFO"; @@ -208,8 +209,10 @@ int BundleActiveService::ReportEvent(BundleActiveEvent& event, const int userId) if ((AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId) == AccessToken::TypeATokenTypeEnum::TOKEN_NATIVE)) { AccessToken::NativeTokenInfo callingTokenInfo; AccessToken::AccessTokenKit::GetNativeTokenInfo(tokenId, callingTokenInfo); - BUNDLE_ACTIVE_LOGI("calling process name is %{public}s", callingTokenInfo.processName.c_str()); - if (callingTokenInfo.processName == PERMITTED_PROCESS_NAME) { + int callingUid = OHOS::IPCSkeleton::GetCallingUid(); + BUNDLE_ACTIVE_LOGI("calling process name is %{public}s, uid is %{public}d", + callingTokenInfo.processName.c_str(), callingUid); + if (callingTokenInfo.processName == PERMITTED_PROCESS_NAME && callingUid == SYSTEM_UID) { BundleActiveReportHandlerObject tmpHandlerObject(userId, ""); tmpHandlerObject.event_ = event; sptr timer = MiscServices::TimeServiceClient::GetInstance(); -- Gitee