Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
4da97c1e
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4da97c1e
编写于
10月 19, 2022
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
name different for same value
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
0752e93b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
4 deletion
+15
-4
services/param/watcher/agent/watcher_manager_kits.cpp
services/param/watcher/agent/watcher_manager_kits.cpp
+1
-1
services/param/watcher/agent/watcher_manager_kits.h
services/param/watcher/agent/watcher_manager_kits.h
+4
-2
test/unittest/param/watcher_agent_unittest.cpp
test/unittest/param/watcher_agent_unittest.cpp
+10
-1
未找到文件。
services/param/watcher/agent/watcher_manager_kits.cpp
浏览文件 @
4da97c1e
...
@@ -297,7 +297,7 @@ void WatcherManagerKits::ParamWatcher::OnParameterChange(const std::string &name
...
@@ -297,7 +297,7 @@ void WatcherManagerKits::ParamWatcher::OnParameterChange(const std::string &name
uint32_t
index
=
0
;
uint32_t
index
=
0
;
ParameterChangeListener
*
listener
=
GetParameterListener
(
&
index
);
ParameterChangeListener
*
listener
=
GetParameterListener
(
&
index
);
while
(
listener
!=
nullptr
)
{
while
(
listener
!=
nullptr
)
{
if
(
!
listener
->
CheckValueChange
(
value
))
{
if
(
!
listener
->
CheckValueChange
(
name
,
value
))
{
listener
->
OnParameterChange
(
name
,
value
);
listener
->
OnParameterChange
(
name
,
value
);
}
}
index
++
;
index
++
;
...
...
services/param/watcher/agent/watcher_manager_kits.h
浏览文件 @
4da97c1e
...
@@ -53,14 +53,16 @@ private:
...
@@ -53,14 +53,16 @@ private:
return
(
callback
==
callback_
&&
context
==
context_
);
return
(
callback
==
callback_
&&
context
==
context_
);
}
}
void
OnParameterChange
(
const
std
::
string
&
name
,
const
std
::
string
&
value
);
void
OnParameterChange
(
const
std
::
string
&
name
,
const
std
::
string
&
value
);
bool
CheckValueChange
(
const
std
::
string
&
value
)
bool
CheckValueChange
(
const
std
::
string
&
name
,
const
std
::
string
&
value
)
{
{
bool
ret
=
(
value_
==
value
);
bool
ret
=
(
value_
==
value
&&
name_
==
name
);
value_
=
value
;
value_
=
value
;
name_
=
name
;
return
ret
;
return
ret
;
}
}
private:
private:
std
::
string
value_
{};
std
::
string
value_
{};
std
::
string
name_
{};
ParameterChangePtr
callback_
{
nullptr
};
ParameterChangePtr
callback_
{
nullptr
};
void
*
context_
{
nullptr
};
void
*
context_
{
nullptr
};
};
};
...
...
test/unittest/param/watcher_agent_unittest.cpp
浏览文件 @
4da97c1e
...
@@ -34,9 +34,11 @@ using namespace std;
...
@@ -34,9 +34,11 @@ using namespace std;
using
namespace
OHOS
;
using
namespace
OHOS
;
using
namespace
OHOS
::
init_param
;
using
namespace
OHOS
::
init_param
;
int
g_callbackCount
=
0
;
static
void
TestParameterChange
(
const
char
*
key
,
const
char
*
value
,
void
*
context
)
static
void
TestParameterChange
(
const
char
*
key
,
const
char
*
value
,
void
*
context
)
{
{
printf
(
"TestParameterChange key:%s %s"
,
key
,
value
);
printf
(
"TestParameterChange key:%s %s
\n
"
,
key
,
value
);
g_callbackCount
++
;
}
}
static
void
TestWatcherCallBack
(
const
char
*
key
,
ServiceStatus
status
)
static
void
TestWatcherCallBack
(
const
char
*
key
,
ServiceStatus
status
)
...
@@ -140,6 +142,7 @@ public:
...
@@ -140,6 +142,7 @@ public:
data
.
WriteString
(
name
);
data
.
WriteString
(
name
);
data
.
WriteString
(
name
);
data
.
WriteString
(
name
);
data
.
WriteString
(
"watcherId"
);
data
.
WriteString
(
"watcherId"
);
g_callbackCount
=
0
;
int
ret
=
SystemWatchParameter
(
name
.
c_str
(),
TestParameterChange
,
nullptr
);
int
ret
=
SystemWatchParameter
(
name
.
c_str
(),
TestParameterChange
,
nullptr
);
EXPECT_EQ
(
ret
,
0
);
EXPECT_EQ
(
ret
,
0
);
WatcherManagerKits
&
instance
=
OHOS
::
init_param
::
WatcherManagerKits
::
GetInstance
();
WatcherManagerKits
&
instance
=
OHOS
::
init_param
::
WatcherManagerKits
::
GetInstance
();
...
@@ -147,7 +150,13 @@ public:
...
@@ -147,7 +150,13 @@ public:
instance
.
remoteWatcher_
->
OnRemoteRequest
(
IWatcher
::
PARAM_CHANGE
,
data
,
reply
,
option
);
instance
.
remoteWatcher_
->
OnRemoteRequest
(
IWatcher
::
PARAM_CHANGE
,
data
,
reply
,
option
);
instance
.
remoteWatcher_
->
OnRemoteRequest
(
IWatcher
::
PARAM_CHANGE
+
1
,
data
,
reply
,
option
);
instance
.
remoteWatcher_
->
OnRemoteRequest
(
IWatcher
::
PARAM_CHANGE
+
1
,
data
,
reply
,
option
);
instance
.
remoteWatcher_
->
OnParameterChange
(
name
.
c_str
(),
"testname"
,
"testvalue"
);
instance
.
remoteWatcher_
->
OnParameterChange
(
name
.
c_str
(),
"testname"
,
"testvalue"
);
EXPECT_EQ
(
g_callbackCount
,
2
);
instance
.
remoteWatcher_
->
OnParameterChange
(
name
.
c_str
(),
"testname.2"
,
"testvalue"
);
EXPECT_EQ
(
g_callbackCount
,
3
);
instance
.
remoteWatcher_
->
OnParameterChange
(
name
.
c_str
(),
"testname.2"
,
"testvalue"
);
EXPECT_EQ
(
g_callbackCount
,
3
);
}
}
EXPECT_EQ
(
g_callbackCount
,
3
);
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录