diff --git a/services/abilitymgr/etc/appfwk.para b/services/abilitymgr/etc/appfwk.para index 42537ce0ed3d454ed92a254d517d46f1a25e50f2..bb4a3cdc804c3e342e2f6c9bd687e15414a52c26 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 2b2f3b6b1bea32cc8723919ef5bbf175bd19e832..a17aaf0bfea47367be33296ab2c35d99bd618330 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 1f5591c49773ad99f6766de4b121ea97eabeef0d..8d322618bc9cbc1269dd88757bac5c99d0d03c7b 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 f1517c42ba47932e4e687b164f3bc8809567805d..7308e7d383ff90e9972300db3ee10b347c59605c 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 a2e1673c3655f02472f18d93a910d8a1c9431df0..02b031a3b4f5f8b5afa82e56e35a624d58b90f03 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