Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
4dcd372e
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4dcd372e
编写于
5月 31, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 31, 2022
浏览文件
操作
浏览文件
下载
差异文件
!271 Rpc remove dynamic permission bugfix
Merge pull request !271 from pilipala195/grant_permission
上级
9ce9c3be
3a85f3dc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
3 deletion
+52
-3
services/dbinder/dbinder_service/src/dbinder_death_recipient.cpp
...s/dbinder/dbinder_service/src/dbinder_death_recipient.cpp
+16
-0
services/dbinder/dbinder_service/src/dbinder_sa_death_recipient.cpp
...binder/dbinder_service/src/dbinder_sa_death_recipient.cpp
+4
-3
services/dbinder/test/moduletest/include/rpc_test.h
services/dbinder/test/moduletest/include/rpc_test.h
+8
-0
services/dbinder/test/moduletest/src/rpc_client_test.cpp
services/dbinder/test/moduletest/src/rpc_client_test.cpp
+11
-0
services/dbinder/test/moduletest/src/rpc_test.cpp
services/dbinder/test/moduletest/src/rpc_test.cpp
+13
-0
未找到文件。
services/dbinder/dbinder_service/src/dbinder_death_recipient.cpp
浏览文件 @
4dcd372e
...
...
@@ -16,9 +16,12 @@
#include "dbinder_death_recipient.h"
#include "dbinder_service.h"
#include "dbinder_log.h"
#include "ISessionService.h"
#include "log_tags.h"
namespace
OHOS
{
using
Communication
::
SoftBus
::
ISessionService
;
#ifndef TITLE
#define TITLE __PRETTY_FUNCTION__
#endif
...
...
@@ -31,6 +34,7 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_RPC,
void
DbinderDeathRecipient
::
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
DBINDER_LOGE
(
"DbinderDeathRecipient OnRemoteDied"
);
if
(
remote
==
nullptr
)
{
DBINDER_LOGE
(
"remote object is null"
);
return
;
...
...
@@ -45,6 +49,18 @@ void DbinderDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
return
;
}
std
::
shared_ptr
<
ISessionService
>
softbusManager
=
ISessionService
::
GetInstance
();
if
(
softbusManager
==
nullptr
)
{
DBINDER_LOGE
(
"fail to get softbus service"
);
return
;
}
std
::
string
sessionName
=
dBinderService
->
QueryBusNameObject
(
callbackProxy
);
if
(
sessionName
.
empty
())
{
DBINDER_LOGE
(
"proxy sessionName not found"
);
return
;
}
softbusManager
->
RemovePermission
(
sessionName
);
sptr
<
IRemoteObject
::
DeathRecipient
>
death
=
dBinderService
->
QueryDeathRecipient
(
object
);
if
(
death
!=
nullptr
)
{
// Continue to clear subsequent data
...
...
services/dbinder/dbinder_service/src/dbinder_sa_death_recipient.cpp
浏览文件 @
4dcd372e
...
...
@@ -38,6 +38,7 @@ DbinderSaDeathRecipient::DbinderSaDeathRecipient(binder_uintptr_t binderObject)
void
DbinderSaDeathRecipient
::
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
DBINDER_LOGE
(
"DbinderSaDeathRecipient OnRemoteDied"
);
if
(
remote
==
nullptr
)
{
DBINDER_LOGE
(
"remote object is null"
);
return
;
...
...
@@ -52,9 +53,6 @@ void DbinderSaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
return
;
}
(
void
)
dBinderService
->
DetachBusNameObject
(
proxy
);
(
void
)
dBinderService
->
DetachProxyObject
(
binderObject_
);
std
::
shared_ptr
<
ISessionService
>
softbusManager
=
ISessionService
::
GetInstance
();
if
(
softbusManager
==
nullptr
)
{
DBINDER_LOGE
(
"fail to get softbus service"
);
...
...
@@ -66,5 +64,8 @@ void DbinderSaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
return
;
}
softbusManager
->
RemovePermission
(
sessionName
);
(
void
)
dBinderService
->
DetachBusNameObject
(
proxy
);
(
void
)
dBinderService
->
DetachProxyObject
(
binderObject_
);
}
}
// namespace OHOS
services/dbinder/test/moduletest/include/rpc_test.h
浏览文件 @
4dcd372e
...
...
@@ -17,6 +17,7 @@
#define OHOS_RPC_FOO_TEST_H
#include "iremote_broker.h"
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "iremote_stub.h"
#include "message_parcel.h"
...
...
@@ -66,6 +67,13 @@ public:
private:
static
inline
BrokerDelegator
<
RpcFooProxy
>
delegator_
;
};
class
RpcDeathRecipient
:
public
IRemoteObject
::
DeathRecipient
{
public:
virtual
void
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
);
RpcDeathRecipient
();
virtual
~
RpcDeathRecipient
();
};
}
// namespace OHOS
#endif // OHOS_RPC_FOO_TEST_H
services/dbinder/test/moduletest/src/rpc_client_test.cpp
浏览文件 @
4dcd372e
...
...
@@ -31,6 +31,7 @@ using namespace OHOS;
static
std
::
string
g_deviceId
;
static
sptr
<
IRpcFooTest
>
g_rpcTestProxy
;
static
sptr
<
IRpcFooTest
>
g_ipcTestProxy
;
static
IPCObjectProxy
*
g_proxy
;
class
RpcClientTest
:
public
testing
::
Test
{
public:
static
constexpr
char
DBINDER_PKG_NAME
[]
=
"DBinderService"
;
...
...
@@ -62,6 +63,9 @@ HWTEST_F(RpcClientTest, function_test_001, TestSize.Level1)
g_rpcTestProxy
=
iface_cast
<
IRpcFooTest
>
(
object
);
ASSERT_TRUE
(
g_rpcTestProxy
!=
nullptr
);
g_proxy
=
reinterpret_cast
<
IPCObjectProxy
*>
(
object
.
GetRefPtr
());
ASSERT_EQ
(
g_proxy
->
GetProto
(),
IRemoteObject
::
IF_PROT_DATABUS
);
}
HWTEST_F
(
RpcClientTest
,
function_test_002
,
TestSize
.
Level1
)
...
...
@@ -127,4 +131,11 @@ HWTEST_F(RpcClientTest, function_test_005, TestSize.Level1)
err
=
replyParcel
.
ReadInt32
();
ASSERT_EQ
(
err
,
ERR_NONE
);
}
HWTEST_F
(
RpcClientTest
,
function_test_006
,
TestSize
.
Level1
)
{
sptr
<
IRemoteObject
::
DeathRecipient
>
death
(
new
RpcDeathRecipient
());
ASSERT_EQ
(
g_proxy
->
GetProto
(),
IRemoteObject
::
IF_PROT_DATABUS
);
g_proxy
->
AddDeathRecipient
(
death
.
GetRefPtr
());
}
}
\ No newline at end of file
services/dbinder/test/moduletest/src/rpc_test.cpp
浏览文件 @
4dcd372e
...
...
@@ -134,4 +134,17 @@ int32_t RpcFooProxy::TestAdd(MessageParcel &data, MessageParcel &reply)
}
return
reply
.
ReadInt32
()
==
(
a
+
b
)
?
ERR_NONE
:
ERR_INVALID_DATA
;
}
RpcDeathRecipient
::
RpcDeathRecipient
()
{
}
RpcDeathRecipient
::~
RpcDeathRecipient
()
{
}
void
RpcDeathRecipient
::
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
return
;
}
}
// namespace OHOS
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录