Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
9cb8c97b
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,发现更多精彩内容 >>
提交
9cb8c97b
编写于
9月 13, 2021
作者:
L
liangshenglin1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MakeRemoteBinder with sa id
Signed-off-by:
N
liangshenglin1
<
liangshenglin1@huawei.com
>
上级
fc8fa9f1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
11 deletion
+19
-11
interfaces/innerkits/libdbinder/include/dbinder_service.h
interfaces/innerkits/libdbinder/include/dbinder_service.h
+5
-2
services/dbinder/dbinder_service/src/dbinder_service.cpp
services/dbinder/dbinder_service/src/dbinder_service.cpp
+14
-9
未找到文件。
interfaces/innerkits/libdbinder/include/dbinder_service.h
浏览文件 @
9cb8c97b
...
...
@@ -105,7 +105,6 @@ public:
const
std
::
string
&
deviceID
,
binder_uintptr_t
binderObject
,
uint64_t
pid
=
0
);
bool
RegisterRemoteProxy
(
std
::
u16string
serviceName
,
sptr
<
IRemoteObject
>
binderObject
);
bool
RegisterRemoteProxy
(
std
::
u16string
serviceName
,
int32_t
systemAbilityId
);
bool
RegisterRemoteProxyInner
(
std
::
u16string
serviceName
,
binder_uintptr_t
binder
);
bool
OnRemoteMessageTask
(
const
struct
DHandleEntryTxRx
*
message
);
std
::
shared_ptr
<
struct
SessionInfo
>
QuerySessionObject
(
binder_uintptr_t
stub
);
bool
DetachDeathRecipient
(
sptr
<
IRemoteObject
>
object
);
...
...
@@ -137,7 +136,7 @@ private:
sptr
<
IRemoteObject
>
QueryProxyObject
(
binder_uintptr_t
binderObject
);
bool
DetachSessionObject
(
binder_uintptr_t
stub
);
bool
AttachSessionObject
(
std
::
shared_ptr
<
struct
SessionInfo
>
object
,
binder_uintptr_t
stub
);
sptr
<
IRemoteObject
>
FindOrNewProxy
(
binder_uintptr_t
binderObject
);
sptr
<
IRemoteObject
>
FindOrNewProxy
(
binder_uintptr_t
binderObject
,
int32_t
systemAbilityId
);
bool
SendEntryToRemote
(
const
sptr
<
DBinderServiceStub
>
stub
,
uint32_t
seqNumber
);
uint16_t
AllocFreeSocketPort
();
std
::
string
GetLocalDeviceID
();
...
...
@@ -161,6 +160,8 @@ private:
std
::
string
QueryBusNameObject
(
IPCObjectProxy
*
proxy
);
std
::
string
GetDatabusNameByProxy
(
IPCObjectProxy
*
proxy
);
uint32_t
GetSeqNumber
();
bool
RegisterRemoteProxyInner
(
std
::
u16string
serviceName
,
binder_uintptr_t
binder
);
bool
CheckSystemAbilityId
(
int32_t
systemAbilityId
);
private:
DISALLOW_COPY_AND_MOVE
(
DBinderService
);
...
...
@@ -191,6 +192,8 @@ private:
std
::
map
<
sptr
<
IRemoteObject
>
,
DBinderServiceStub
*>
noticeProxy_
;
std
::
map
<
sptr
<
IRemoteObject
>
,
sptr
<
IRemoteObject
::
DeathRecipient
>>
deathRecipients_
;
std
::
map
<
IPCObjectProxy
*
,
std
::
string
>
busNameObject_
;
static
constexpr
int32_t
FIRST_SYS_ABILITY_ID
=
0x00000001
;
static
constexpr
int32_t
LAST_SYS_ABILITY_ID
=
0x00ffffff
;
};
}
// namespace OHOS
#endif // OHOS_IPC_SERVICES_DBINDER_DBINDER_SERVICE_H
services/dbinder/dbinder_service/src/dbinder_service.cpp
浏览文件 @
9cb8c97b
...
...
@@ -244,7 +244,7 @@ sptr<DBinderServiceStub> DBinderService::FindOrNewDBinderStub(const std::u16stri
sptr
<
DBinderServiceStub
>
DBinderService
::
MakeRemoteBinder
(
const
std
::
u16string
&
serviceName
,
const
std
::
string
&
deviceID
,
binder_uintptr_t
binderObject
,
uint64_t
pid
)
{
if
(
IsDeviceIdIllegal
(
deviceID
)
||
serviceName
.
length
()
==
0
||
binderObject
==
0
)
{
if
(
IsDeviceIdIllegal
(
deviceID
)
||
serviceName
.
length
()
==
0
)
{
DBINDER_LOGE
(
"para is wrong device id length = %zu, service name length = %zu"
,
deviceID
.
length
(),
serviceName
.
length
());
return
nullptr
;
...
...
@@ -295,7 +295,7 @@ bool DBinderService::SendEntryToRemote(const sptr<DBinderServiceStub> stub, uint
message
->
transType
=
GetRemoteTransType
();
message
->
fromPort
=
0
;
message
->
toPort
=
0
;
message
->
stubIndex
=
0
;
message
->
stubIndex
=
static_cast
<
uint64_t
>
(
std
::
atoi
(
stub
->
GetServiceName
().
c_str
()))
;
message
->
seqNumber
=
seqNumber
;
message
->
binderObject
=
stub
->
GetBinderObject
();
message
->
stub
=
reinterpret_cast
<
binder_uintptr_t
>
(
stub
.
GetRefPtr
());
...
...
@@ -360,7 +360,12 @@ bool DBinderService::InvokerRemoteDBinder(const sptr<DBinderServiceStub> stub, u
return
true
;
}
sptr
<
IRemoteObject
>
DBinderService
::
FindOrNewProxy
(
binder_uintptr_t
binderObject
)
bool
DBinderService
::
CheckSystemAbilityId
(
int32_t
systemAbilityId
)
{
return
systemAbilityId
>=
FIRST_SYS_ABILITY_ID
&&
systemAbilityId
<=
LAST_SYS_ABILITY_ID
;
}
sptr
<
IRemoteObject
>
DBinderService
::
FindOrNewProxy
(
binder_uintptr_t
binderObject
,
int32_t
systemAbilityId
)
{
sptr
<
IRemoteObject
>
proxy
=
QueryProxyObject
(
binderObject
);
if
(
proxy
!=
nullptr
)
{
...
...
@@ -369,20 +374,18 @@ sptr<IRemoteObject> DBinderService::FindOrNewProxy(binder_uintptr_t binderObject
}
/* proxy is null, attempt to get a new proxy */
std
::
u16string
serviceName
=
GetRegisterService
(
binderObject
);
if
(
serviceName
.
empty
())
{
DBINDER_LOGE
(
"service is not registered in this device
"
);
if
(
serviceName
.
empty
()
&&
!
CheckSystemAbilityId
(
systemAbilityId
)
)
{
DBINDER_LOGE
(
"service is not registered in this device
, saId:%{public}d"
,
systemAbilityId
);
return
nullptr
;
}
DBINDER_LOGI
(
"new proxy serviceName = %s"
,
Str16ToStr8
(
serviceName
).
c_str
());
auto
manager
=
SystemAbilityManagerClient
::
GetInstance
().
GetSystemAbilityManager
();
if
(
manager
==
nullptr
)
{
DBINDER_LOGE
(
"when new proxy, find samgr fail!"
);
return
nullptr
;
}
int
digitalName
=
std
::
atoi
(
Str16ToStr8
(
serviceName
).
c_str
())
;
int
digitalName
=
!
serviceName
.
empty
()
?
std
::
atoi
(
Str16ToStr8
(
serviceName
).
c_str
())
:
systemAbilityId
;
proxy
=
manager
->
GetSystemAbility
(
digitalName
);
if
(
proxy
!=
nullptr
)
{
/* When the stub object dies, you need to delete the corresponding busName information */
...
...
@@ -397,6 +400,8 @@ sptr<IRemoteObject> DBinderService::FindOrNewProxy(binder_uintptr_t binderObject
DBINDER_LOGE
(
"attach proxy object fail"
);
return
nullptr
;
}
}
else
{
DBINDER_LOGW
(
"GetSystemAbility from samgr error, saId:%{public}d"
,
digitalName
);
}
return
proxy
;
}
...
...
@@ -408,7 +413,7 @@ uint16_t DBinderService::AllocFreeSocketPort()
bool
DBinderService
::
OnRemoteInvokerMessage
(
const
struct
DHandleEntryTxRx
*
message
)
{
sptr
<
IRemoteObject
>
proxy
=
FindOrNewProxy
(
message
->
binderObject
);
sptr
<
IRemoteObject
>
proxy
=
FindOrNewProxy
(
message
->
binderObject
,
static_cast
<
int32_t
>
(
message
->
stubIndex
)
);
if
(
proxy
==
nullptr
)
{
DBINDER_LOGE
(
"find and new proxy fail"
);
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录