Merge pull request !4 from ql/sa
This commit is contained in:
openharmony_ci 2021-07-05 14:41:57 +00:00 committed by Gitee
commit 79160d3456
2 changed files with 19 additions and 1 deletions

View File

@ -104,6 +104,8 @@ public:
sptr<DBinderServiceStub> MakeRemoteBinder(const std::u16string &serviceName,
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);

View File

@ -555,9 +555,25 @@ bool DBinderService::RegisterRemoteProxy(std::u16string serviceName, sptr<IRemot
binder_uintptr_t binder = (binder_uintptr_t)binderObject.GetRefPtr();
DBINDER_LOGI("register remote proxy");
return RegisterRemoteProxyInner(serviceName, binder);
}
bool DBinderService::RegisterRemoteProxy(std::u16string serviceName, int32_t systemAbilityId)
{
DBINDER_LOGI("register remote proxy, service name = %{public}s", Str16ToStr8(serviceName).c_str());
if (serviceName.length() == 0 || systemAbilityId <= 0) {
DBINDER_LOGE("serviceName.length() = %zu", serviceName.length());
return false;
}
binder_uintptr_t binder = (binder_uintptr_t)systemAbilityId;
return RegisterRemoteProxyInner(serviceName, binder);
}
bool DBinderService::RegisterRemoteProxyInner(std::u16string serviceName, binder_uintptr_t binder)
{
std::unique_lock<std::shared_mutex> lockGuard(remoteBinderMutex_);
// clear historical remnants, Don't care if it succeeds
(void)mapRemoteBinderObjects_.erase(serviceName);
auto result = mapRemoteBinderObjects_.insert(std::pair<std::u16string, binder_uintptr_t>(serviceName, binder));