From 57fe16ad48d6ee673295cd370b77bdf52287edc6 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 24 Mar 2022 12:05:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9innerkit=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- BUILD.gn | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 6fb466c..87a5834 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -19,20 +19,24 @@ ohos_sa_profile("device_usage_statistics_sa_profile") { part_name = "${device_usage_statistics_part_name}" } -ohos_shared_library("usagestatsinner") { - sources = [ - "interfaces/innerkits/src/bundle_active_client.cpp", - "interfaces/innerkits/src/bundle_active_proxy.cpp", - "services/packageusage/src/bundle_active_event.cpp", - "services/packageusage/src/bundle_active_package_stats.cpp", - ] +config("usagestatsinner_public_config") { include_dirs = [ "services/common/include", "services/packageusage/include", "services/packagegroup/include", "interfaces/innerkits/include", ] +} +ohos_shared_library("usagestatsinner") { + sources = [ + "interfaces/innerkits/src/bundle_active_client.cpp", + "interfaces/innerkits/src/bundle_active_proxy.cpp", + "services/packageusage/src/bundle_active_event.cpp", + "services/packageusage/src/bundle_active_package_stats.cpp", + ] + public_configs = [ ":usagestatsinner_public_config" ] + public_deps = [ ":usagestatservice" ] external_deps = [ "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -41,8 +45,6 @@ ohos_shared_library("usagestatsinner") { "utils_base:utils", ] - deps = [ ":usagestatservice" ] - part_name = "${device_usage_statistics_part_name}" subsystem_name = "resourceschedule" } -- Gitee From e8f9ec5bb99cdadb5c1cdfd6806f75eddfebeb20 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 24 Mar 2022 18:36:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C=E6=96=B9=E5=BC=8F?= 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp index f9170fa..2cf7017 100644 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -25,13 +25,12 @@ namespace OHOS { namespace DeviceUsageStats { +using namespace OHOS::Security; static const int PERIOD_BEST_JS = 0; static const int PERIOD_YEARLY_JS = 4; static const int PERIOD_BEST_SERVICE = 4; static const int DELAY_TIME = 2000; REGISTER_SYSTEM_ABILITY_BY_ID(BundleActiveService, DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID, true); -using namespace OHOS::Security::AccessToken; -using AccessTokenKit = OHOS::Security::AccessToken::AccessTokenKit; const std::string NEEDED_PERMISSION = "ohos.permission.BUNDLE_ACTIVE_INFO"; void BundleActiveService::OnStart() @@ -413,8 +412,9 @@ bool BundleActiveService::CheckBundleIsSystemAppAndHasPermission(const int uid, } std::string bundleName = ""; sptrBundleMgr_->GetBundleNameForUid(uid, bundleName); - bool bundleIsSystemApp = sptrBundleMgr_->CheckIsSystemAppByUid(uid); - int bundleHasPermission = sptrBundleMgr_->CheckPermissionByUid(bundleName, NEEDED_PERMISSION, userId); + AccessToken::AccessTokenID tokenId = AccessToken::AccessTokenKit::GetHapTokenID(userId, + bundleName, 0); + int bundleHasPermission = AccessToken::AccessTokenKit::VerifyAccessToken(tokenId, NEEDED_PERMISSION); if (!bundleIsSystemApp) { errCode = BUNDLE_ACTIVE_FAIL; BUNDLE_ACTIVE_LOGE("%{public}s is not system app", bundleName.c_str()); -- Gitee From 48799e076ef2badcefde3618eeeb8a6b31b06e80 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 24 Mar 2022 19:50:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C=E6=96=B9=E5=BC=8F?= 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp index 2cf7017..8b73dc0 100644 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -412,6 +412,7 @@ bool BundleActiveService::CheckBundleIsSystemAppAndHasPermission(const int uid, } std::string bundleName = ""; sptrBundleMgr_->GetBundleNameForUid(uid, bundleName); + bool bundleIsSystemApp = sptrBundleMgr_->CheckIsSystemAppByUid(uid); AccessToken::AccessTokenID tokenId = AccessToken::AccessTokenKit::GetHapTokenID(userId, bundleName, 0); int bundleHasPermission = AccessToken::AccessTokenKit::VerifyAccessToken(tokenId, NEEDED_PERMISSION); -- Gitee