mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-10-08 09:14:30 +00:00
IssueNo:#I581UL
Description:Support pointer device configuration. Sig:SIG_ApplicationFramework Feature or BugFix: Feature Binary Source: No Signed-off-by: zhangyafei.echo <zhangyafei12@huawei.com> Change-Id: Id2f0978dd6694fc0d2916468a7e95b28bea4dfc2
This commit is contained in:
parent
7edcb8ed4d
commit
40c642c90e
@ -64,6 +64,10 @@ napi_value WrapConfiguration(napi_env env, const AppExecFwk::Configuration &conf
|
||||
jsValue = WrapInt32ToJS(env, displayId);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "displayId", jsValue);
|
||||
|
||||
std::string hasPointerDevice = configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
jsValue = WrapBoolToJS(env, hasPointerDevice == "true" ? true : false);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "hasPointerDevice", jsValue);
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
|
@ -679,16 +679,20 @@ void Ability::OnConfigurationUpdatedNotify(const Configuration &changeConfigurat
|
||||
|
||||
std::string language;
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
if (setting_) {
|
||||
auto displayId = std::atoi(setting_->GetProperty(AbilityStartSetting::WINDOW_DISPLAY_ID_KEY).c_str());
|
||||
language = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
HILOG_INFO("displayId: [%{public}d], language: [%{public}s], colormode: [%{public}s]",
|
||||
displayId, language.c_str(), colormode.c_str());
|
||||
hasPointerDevice = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
HILOG_INFO("displayId: [%{public}d], language: [%{public}s], colormode: [%{public}s], "
|
||||
"hasPointerDevice: [%{public}s]", displayId, language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
} else {
|
||||
language = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
HILOG_INFO("language: [%{public}s], colormode: [%{public}s]", language.c_str(), colormode.c_str());
|
||||
hasPointerDevice = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
HILOG_INFO("language: [%{public}s], colormode: [%{public}s], hasPointerDevice: [%{public}s]",
|
||||
language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
}
|
||||
|
||||
// Notify ResourceManager
|
||||
@ -710,9 +714,15 @@ void Ability::OnConfigurationUpdatedNotify(const Configuration &changeConfigurat
|
||||
}
|
||||
}
|
||||
#endif
|
||||
resConfig->SetColorMode(ConvertColorMode(colormode));
|
||||
if (!colormode.empty()) {
|
||||
resConfig->SetColorMode(ConvertColorMode(colormode));
|
||||
}
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(ConvertHasPointerDevice(hasPointerDevice));
|
||||
}
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
HILOG_INFO("Notify ResourceManager, colorMode: %{public}d.", resConfig->GetColorMode());
|
||||
HILOG_INFO("Notify ResourceManager, current colorMode: %{public}d, hasPointerDevice: %{publis}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
@ -774,6 +774,10 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
|
||||
std::string colormode = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
HILOG_INFO("colormode is %{public}s.", colormode.c_str());
|
||||
resConfig->SetColorMode(ConvertColorMode(colormode));
|
||||
|
||||
std::string hasPointerDevice = config.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
HILOG_INFO("hasPointerDevice is %{public}s.", hasPointerDevice.c_str());
|
||||
resConfig->SetInputDevice(ConvertHasPointerDevice(hasPointerDevice));
|
||||
#endif
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
return true;
|
||||
|
@ -214,6 +214,9 @@ NativeValue* CreateJsConfiguration(NativeEngine& engine, const AppExecFwk::Confi
|
||||
|
||||
object->SetProperty("displayId", CreateJsValue(engine, displayId));
|
||||
|
||||
std::string hasPointerDevice = configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
object->SetProperty("hasPointerDevice", CreateJsValue(engine, hasPointerDevice == "true" ? true : false));
|
||||
|
||||
return objValue;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -86,6 +86,7 @@ ohos_shared_library("libappms") {
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"startup_l2:syspara_watchagent",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
|
@ -707,6 +707,10 @@ private:
|
||||
|
||||
void OnRenderRemoteDied(const wptr<IRemoteObject> &remote);
|
||||
|
||||
void AddWatchParameter();
|
||||
|
||||
static void PointerDeviceEventCallback(const char *key, const char *value, void *context);
|
||||
|
||||
private:
|
||||
/**
|
||||
* ClearUpApplicationData, clear the application data.
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "itest_observer.h"
|
||||
#include "parameter.h"
|
||||
#include "parameters.h"
|
||||
#include "permission_constants.h"
|
||||
#include "permission_verification.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -115,6 +116,7 @@ AppMgrServiceInner::AppMgrServiceInner()
|
||||
void AppMgrServiceInner::Init()
|
||||
{
|
||||
GetGlobalConfiguration();
|
||||
AddWatchParameter();
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->Init();
|
||||
}
|
||||
|
||||
@ -244,7 +246,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
bundleMgrResult = (IN_PROCESS_CALL(bundleMgr_->GetSandboxBundleInfo(appInfo->bundleName,
|
||||
appIndex, userId, bundleInfo)) == 0);
|
||||
}
|
||||
|
||||
|
||||
if (!bundleMgrResult) {
|
||||
HILOG_ERROR("GetBundleInfo is fail");
|
||||
return false;
|
||||
@ -1218,7 +1220,7 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
bundleIndex, userId, bundleInfo)) == 0);
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
}
|
||||
|
||||
|
||||
if (!bundleMgrResult) {
|
||||
HILOG_ERROR("GetBundleInfo is fail");
|
||||
return;
|
||||
@ -2151,6 +2153,11 @@ void AppMgrServiceInner::GetGlobalConfiguration()
|
||||
// Assign to default colormode "light"
|
||||
HILOG_INFO("current global colormode is : %{public}s", ConfigurationInner::COLOR_MODE_LIGHT.c_str());
|
||||
configuration_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, ConfigurationInner::COLOR_MODE_LIGHT);
|
||||
|
||||
// Get input pointer device
|
||||
std::string hasPointerDevice = system::GetParameter(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, "false");
|
||||
HILOG_INFO("current hasPointerDevice is %{public}s", hasPointerDevice.c_str());
|
||||
configuration_->AddItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, hasPointerDevice);
|
||||
}
|
||||
|
||||
std::shared_ptr<AppExecFwk::Configuration> AppMgrServiceInner::GetConfiguration()
|
||||
@ -2506,5 +2513,54 @@ uint32_t AppMgrServiceInner::BuildStartFlags(const AAFwk::Want &want, const Abil
|
||||
}
|
||||
return startFlags;
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::AddWatchParameter()
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int ret;
|
||||
|
||||
auto context = new std::weak_ptr<AppMgrServiceInner>(shared_from_this());
|
||||
ret = WatchParameter(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE.c_str(), PointerDeviceEventCallback,
|
||||
context);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("watch parameter %{public}s failed with %{public}d.",
|
||||
AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE.c_str(), ret);
|
||||
}
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::PointerDeviceEventCallback(const char *key, const char *value, void *context)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
auto weak = static_cast<std::weak_ptr<AppMgrServiceInner>*>(context);
|
||||
if (weak == nullptr) {
|
||||
HILOG_ERROR("context is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto appMgrServiceInner = weak->lock();
|
||||
if (appMgrServiceInner == nullptr) {
|
||||
HILOG_ERROR("app manager service inner is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((strcmp(key, AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE.c_str()) != 0) ||
|
||||
((strcmp(value, "true") != 0) && (strcmp(value, "false") != 0))) {
|
||||
HILOG_ERROR("key %{public}s or value %{public}s mismatch.", key, value);
|
||||
return;
|
||||
}
|
||||
|
||||
Configuration changeConfig;
|
||||
if (!changeConfig.AddItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, value)) {
|
||||
HILOG_ERROR("add %{public}s item to configuration failed.", key);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("update config %{public}s to %{public}s", key, value);
|
||||
auto result = appMgrServiceInner->UpdateConfiguration(changeConfig);
|
||||
if (result != 0) {
|
||||
HILOG_ERROR("update config failed with %{public}d, key: %{public}s, value: %{public}s.", result, key, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -89,6 +89,7 @@ ohos_source_set("appmgr_mst_source") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
|
@ -274,6 +274,7 @@ group("unittest") {
|
||||
"app_mgr_proxy_test:unittest",
|
||||
"app_mgr_service_dump_test:unittest",
|
||||
"app_mgr_service_event_handler_test:unittest",
|
||||
"app_mgr_service_inner_test:unittest",
|
||||
"app_mgr_stub_test:unittest",
|
||||
"app_running_processes_info_test:unittest",
|
||||
"app_scheduler_test:unittest",
|
||||
|
@ -63,6 +63,7 @@ ohos_unittest("AmsAbilityRunningRecordTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ ohos_unittest("AppDeathRecipientTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ ohos_unittest("AmsAppLifeCycleTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ ohos_unittest("AmsAppRunningRecordTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ ohos_unittest("AmsWorkFlowTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,7 @@ ohos_unittest("AmsRecentAppListTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ ohos_unittest("AmsServiceAppSpawnClientTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
|
@ -70,6 +70,7 @@ ohos_unittest("AmsServiceEventDriveTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ ohos_unittest("AmsServiceStartupTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ ohos_unittest("AMSEventHandlerTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
52
test/unittest/app_mgr_service_inner_test/BUILD.gn
Normal file
52
test/unittest/app_mgr_service_inner_test/BUILD.gn
Normal file
@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
module_output_path = "ability_runtime/appmgrservice"
|
||||
|
||||
ohos_unittest("AppMgrServiceInnerTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [ "app_mgr_service_inner_test.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/appmgr:appmgr_config" ]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_services_path}/appmgr:libappms",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"startup_l2:syspara",
|
||||
"startup_l2:syspara_watchagent",
|
||||
"utils_base:utils",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":AppMgrServiceInnerTest" ]
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "app_mgr_service_inner.h"
|
||||
#undef private
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AppMgrServiceInnerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void AppMgrServiceInnerTest::SetUpTestCase(void)
|
||||
{}
|
||||
|
||||
void AppMgrServiceInnerTest::TearDownTestCase(void)
|
||||
{}
|
||||
|
||||
void AppMgrServiceInnerTest::SetUp()
|
||||
{}
|
||||
|
||||
void AppMgrServiceInnerTest::TearDown()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.name: PointerDeviceCallback_0100
|
||||
* @tc.desc: set parameter, expect config update
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I581UL
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, PointerDeviceCallback_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("PointerDeviceCallback_0100 start");
|
||||
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
|
||||
auto context = new std::weak_ptr<AppMgrServiceInner>(appMgrServiceInner);
|
||||
std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
|
||||
std::string value;
|
||||
|
||||
// invalid parameter value
|
||||
appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "false", nullptr);
|
||||
appMgrServiceInner->PointerDeviceEventCallback("invalid_key", "false", context);
|
||||
appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "invalid", context);
|
||||
|
||||
// set "input.pointer.device" to false
|
||||
appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "false", context);
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "false");
|
||||
|
||||
// set "input.pointer.device" to true
|
||||
appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "true", context);
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "true");
|
||||
|
||||
HILOG_INFO("PointerDeviceCallback_0100 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PointerDeviceWatchParameter_0100
|
||||
* @tc.desc: set parameter, expect config update
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I581UL
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, PointerDeviceWatchParameter_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("PointerDeviceWatchParameter_0100 start");
|
||||
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
|
||||
std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
|
||||
std::string value;
|
||||
|
||||
appMgrServiceInner->AddWatchParameter();
|
||||
|
||||
// invalid parameter value
|
||||
system::SetParameter(key.c_str(), "invalid");
|
||||
|
||||
// set "input.pointer.device" to false
|
||||
system::SetParameter(key.c_str(), "false");
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "false");
|
||||
|
||||
// set "input.pointer.device" to true
|
||||
system::SetParameter(key.c_str(), "true");
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "true");
|
||||
|
||||
HILOG_INFO("PointerDeviceWatchParameter_0100 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PointerDeviceUpdateConfig_0100
|
||||
* @tc.desc: set parameter, expect config update
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I581UL
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, PointerDeviceUpdateConfig_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("PointerDeviceUpdateConfig_0100 start");
|
||||
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::shared_ptr<AppExecFwk::Configuration> config;
|
||||
std::string value;
|
||||
int32_t result;
|
||||
|
||||
appMgrServiceInner->GetGlobalConfiguration();
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "true");
|
||||
|
||||
result = appMgrServiceInner->UpdateConfiguration(*config);
|
||||
EXPECT_EQ(result, 0);
|
||||
|
||||
Configuration changeConfig;
|
||||
changeConfig.AddItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, "true");
|
||||
result = appMgrServiceInner->UpdateConfiguration(changeConfig);
|
||||
EXPECT_EQ(result, 0);
|
||||
config = appMgrServiceInner->GetConfiguration();
|
||||
EXPECT_NE(config, nullptr);
|
||||
value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
EXPECT_EQ(value, "true");
|
||||
|
||||
HILOG_INFO("PointerDeviceUpdateConfig_0100 end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -66,6 +66,7 @@ ohos_unittest("AppRunningProcessesInfoTest") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user