You need to sign in or sign up before continuing.
提交 0a21090f 编写于 作者: L liubb_0516

Remove dbinder's dependency on samgr

Signed-off-by: Nliubb_0516 <liubeibei8@huawei.com>
上级 6da1cf47
......@@ -24,10 +24,10 @@
#include <list>
#include <thread>
#include "if_dbinder_service.h"
#include "dbinder_service_stub.h"
#include "ipc_object_proxy.h"
#include "ipc_object_stub.h"
#include "dbinder_service_stub.h"
#include "rpc_system_ability_callback.h"
namespace OHOS {
class DBinderRemoteListener;
......@@ -101,8 +101,7 @@ public:
virtual ~DBinderService();
public:
static sptr<DBinderService> GetInstance();
bool StartDBinderService();
bool StartDBinderService(std::shared_ptr<IDBinderService> &callbackImpl);
bool StartDBinderService(std::shared_ptr<RpcSystemAbilityCallback> &callbackImpl);
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);
......@@ -197,7 +196,7 @@ private:
static constexpr int32_t FIRST_SYS_ABILITY_ID = 0x00000001;
static constexpr int32_t LAST_SYS_ABILITY_ID = 0x00ffffff;
std::shared_ptr<IDBinderService> dbinderCallback_;
std::shared_ptr<RpcSystemAbilityCallback> dbinderCallback_;
};
} // namespace OHOS
#endif // OHOS_IPC_SERVICES_DBINDER_DBINDER_SERVICE_H
......@@ -13,17 +13,17 @@
* limitations under the License.
*/
#ifndef INTERFACES_RPC_SERVICES_DBINDER_H
#define INTERFACES_RPC_SERVICES_DBINDER_H
#ifndef INTERFACES_RPC_SERVICES_CALLBACK_H
#define INTERFACES_RPC_SERVICES_CALLBACK_H
#include "iremote_object.h"
namespace OHOS {
class IDBinderService {
class RpcSystemAbilityCallback {
public:
virtual sptr<IRemoteObject> GetSystemAbilityFromRemote(int32_t systemAbilityId) = 0;
IDBinderService() = default;
virtual ~IDBinderService() = default;
RpcSystemAbilityCallback() = default;
virtual ~RpcSystemAbilityCallback() = default;
};
} // namespace OHOS
#endif // INTERFACES_RPC_SERVICES_DBINDER_H
\ No newline at end of file
#endif // INTERFACES_RPC_SERVICES_CALLBACK_H
\ No newline at end of file
......@@ -73,22 +73,7 @@ std::string DBinderService::GetLocalDeviceID()
return networkId;
}
bool DBinderService::StartDBinderService()
{
if (mainThreadCreated_) {
return true;
}
bool result = StartRemoteListener();
if (!result) {
return false;
}
mainThreadCreated_ = true;
return true;
}
bool DBinderService::StartDBinderService(std::shared_ptr<IDBinderService> &callbackImpl)
bool DBinderService::StartDBinderService(std::shared_ptr<RpcSystemAbilityCallback> &callbackImpl)
{
if (mainThreadCreated_) {
return true;
......@@ -387,6 +372,10 @@ sptr<IRemoteObject> DBinderService::FindOrNewProxy(binder_uintptr_t binderObject
DBINDER_LOGI("already have proxy");
return proxy;
}
if (dbinderCallback_ == nullptr) {
DBINDER_LOGE("samgr not initialized get remote sa callback");
return nullptr;
}
/* proxy is null, attempt to get a new proxy */
std::u16string serviceName = GetRegisterService(binderObject);
if (serviceName.empty() && !CheckSystemAbilityId(systemAbilityId)) {
......@@ -394,9 +383,7 @@ sptr<IRemoteObject> DBinderService::FindOrNewProxy(binder_uintptr_t binderObject
return nullptr;
}
int32_t digitalName = !serviceName.empty() ? std::atoi(Str16ToStr8(serviceName).c_str()) : systemAbilityId;
if (dbinderCallback_ != nullptr) {
proxy = dbinderCallback_->GetSystemAbilityFromRemote(digitalName);
}
proxy = dbinderCallback_->GetSystemAbilityFromRemote(digitalName);
if (proxy != nullptr) {
/* When the stub object dies, you need to delete the corresponding busName information */
IPCObjectProxy *saProxy = reinterpret_cast<IPCObjectProxy *>(proxy.GetRefPtr());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册