From d8546587fe15886a3fe9967a9313be2b3ebc5240 Mon Sep 17 00:00:00 2001 From: wangzhen Date: Thu, 28 Aug 2025 21:12:37 +0800 Subject: [PATCH] Add allowDebug parameter Signed-off-by: wangzhen Change-Id: I549881d9e5df1fb1d7f40b273f482c8ab13da906 --- services/abilitymgr/etc/appfwk.para | 1 + services/abilitymgr/etc/appfwk.para.dac | 1 + services/common/include/app_utils.h | 2 ++ services/common/src/app_utils.cpp | 11 ++++++++ .../app_utils_test/app_utils_test.cpp | 28 +++++++++++++++++++ 5 files changed, 43 insertions(+) diff --git a/services/abilitymgr/etc/appfwk.para b/services/abilitymgr/etc/appfwk.para index 42537ce0ed3..bb4a3cdc804 100644 --- a/services/abilitymgr/etc/appfwk.para +++ b/services/abilitymgr/etc/appfwk.para @@ -35,6 +35,7 @@ persist.sys.abilityms.move_ui_ability_to_background_api_enable = true persist.sys.abilityms.prevent_startability = true persist.sys.abilityms.forbid_start = false persist.sys.abilityms.restart_app_with_window = false +persist.sys.abilityms.allow_debug_permission = false const.abilityms.launch_embeded_ui_ability = false const.sys.abilityms.limit_maximum_extensions_of_per_process = 10 const.sys.abilityms.limit_maximum_extensions_of_per_device = 100 diff --git a/services/abilitymgr/etc/appfwk.para.dac b/services/abilitymgr/etc/appfwk.para.dac index 2b2f3b6b1be..a17aaf0bfea 100644 --- a/services/abilitymgr/etc/appfwk.para.dac +++ b/services/abilitymgr/etc/appfwk.para.dac @@ -36,6 +36,7 @@ persist.sys.abilityms.prevent_startability = foundation:foundation:0755 persist.sys.abilityms.cache_ability_enable = foundation:foundation:0755 persist.sys.abilityms.forbid_start = foundation:foundation:0755 persist.sys.abilityms.restart_app_with_window = foundation:foundation:0755 +persist.sys.abilityms.allow_debug_permission = foundation:foundation:0755 const.abilityms.launch_embeded_ui_ability = foundation:foundation:0755 const.sys.abilityms.limit_maximum_extensions_of_per_process = foundation:foundation:0755 const.sys.abilityms.limit_maximum_extensions_of_per_device = foundation:foundation:0755 diff --git a/services/common/include/app_utils.h b/services/common/include/app_utils.h index 1f5591c4977..8d322618bc9 100644 --- a/services/common/include/app_utils.h +++ b/services/common/include/app_utils.h @@ -357,6 +357,7 @@ public: bool IsSupportRestartAppWithWindow(); + bool IsSupportAllowDebugPermission(); private: /** * LoadResidentProcessInExtremeMemory, load resident process in extreme low memory. @@ -443,6 +444,7 @@ private: volatile DeviceConfiguration isPreloadApplicationEnabled_ = {false, false}; volatile DeviceConfiguration isForbidStart_ = {true, false}; volatile DeviceConfiguration isSupportRestartAppWithWindow_ = {false, false}; + volatile DeviceConfiguration isSupportAllowDebugPermission_ = {false, false}; DeviceConfiguration>> residentProcessInExtremeMemory_ = {false, {}}; std::mutex residentProcessInExtremeMemoryMutex_; diff --git a/services/common/src/app_utils.cpp b/services/common/src/app_utils.cpp index f1517c42ba4..7308e7d383f 100644 --- a/services/common/src/app_utils.cpp +++ b/services/common/src/app_utils.cpp @@ -84,6 +84,7 @@ constexpr const char* SUPPORT_APP_SERVICE_EXTENSION = "const.abilityms.support_a constexpr const char* PRODUCT_PRELOAD_APPLICATION_SETTING_ENABLED = "const.product.preload_application.setting.enabled"; constexpr const char* FORBID_START = "persist.sys.abilityms.forbid_start"; constexpr const char* RESTART_APP_WITH_WINDOW = "persist.sys.abilityms.restart_app_with_window"; +constexpr const char* ALLOW_DEBUG_PERMISSION = "persist.sys.abilityms.allow_debug_permission"; // Support prepare terminate constexpr int32_t PREPARE_TERMINATE_ENABLE_SIZE = 6; constexpr const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate"; @@ -856,5 +857,15 @@ bool AppUtils::IsSupportRestartAppWithWindow() TAG_LOGD(AAFwkTag::DEFAULT, "restartApp: %{public}d", isSupportRestartAppWithWindow_.value); return isSupportRestartAppWithWindow_.value; } + +bool AppUtils::IsSupportAllowDebugPermission() +{ + if (!isSupportAllowDebugPermission_.isLoaded) { + isSupportAllowDebugPermission_.value = system::GetBoolParameter(ALLOW_DEBUG_PERMISSION, false); + isSupportAllowDebugPermission_.isLoaded = true; + } + TAG_LOGD(AAFwkTag::DEFAULT, "restartApp: %{public}d", isSupportAllowDebugPermission_.value); + return isSupportAllowDebugPermission_.value; +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/app_utils_test/app_utils_test.cpp b/test/unittest/app_utils_test/app_utils_test.cpp index a2e1673c365..02b031a3b4f 100644 --- a/test/unittest/app_utils_test/app_utils_test.cpp +++ b/test/unittest/app_utils_test/app_utils_test.cpp @@ -1038,5 +1038,33 @@ HWTEST_F(AppUtilsTest, IsSupportRestartAppWithWindow_0200, TestSize.Level2) appUtils.isSupportRestartAppWithWindow_.value = true; EXPECT_TRUE(appUtils.IsSupportRestartAppWithWindow()); } + +/** + * @tc.number: IsSupportAllowDebugPermission_0100 + * @tc.desc: Test IsSupportAllowDebugPermission works + * @tc.type: FUNC + */ +HWTEST_F(AppUtilsTest, IsSupportAllowDebugPermission_0100, TestSize.Level2) +{ + TAG_LOGI(AAFwkTag::TEST, "IsSupportAllowDebugPermission_0100 called."); + auto &appUtils = AAFwk::AppUtils::GetInstance(); + appUtils.isSupportAllowDebugPermission_.isLoaded = false; + EXPECT_FALSE(appUtils.IsSupportAllowDebugPermission()); + EXPECT_TRUE(appUtils.isSupportAllowDebugPermission_.isLoaded); +} + +/** + * @tc.number: IsSupportAllowDebugPermission_0200 + * @tc.desc: Test IsSupportAllowDebugPermission works + * @tc.type: FUNC + */ +HWTEST_F(AppUtilsTest, IsSupportAllowDebugPermission_0200, TestSize.Level2) +{ + TAG_LOGI(AAFwkTag::TEST, "IsSupportAllowDebugPermission_0200 called."); + auto &appUtils = AAFwk::AppUtils::GetInstance(); + appUtils.isSupportAllowDebugPermission_.isLoaded = true; + appUtils.isSupportAllowDebugPermission_.value = true; + EXPECT_TRUE(appUtils.IsSupportAllowDebugPermission()); +} } // namespace AbilityRuntime } // namespace OHOS -- Gitee