增加 CanPromote函数判断wptr是否可以提升为sptr

Signed-off-by: dengliang <15934868816@139.com>
This commit is contained in:
dengliang 2024-10-31 21:46:11 +08:00
parent 7df5805842
commit 6440600112
7 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,9 @@ SUBSYSTEM_DIR = "//foundation/communication/ipc"
config("ipc_all_deps_config") {
include_dirs = [ "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include" ]
if (is_emulator) {
defines = [ "EMULATOR_PLATFORM" ]
}
}
ohos_prebuilt_shared_library("ipc_core") {

View File

@ -242,6 +242,10 @@ public:
void SetObjectDied(bool isDied);
#ifndef EMULATOR_PLATFORM
bool CanPromote() override;
#endif
private:
int SendLocalRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &optionoption);
int SendRequestInner(bool isLocal, uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);

View File

@ -68,8 +68,10 @@
"virtual thunk to OHOS::IRemoteObject::IsObjectDead() const";
"OHOS::IRemoteObject::IsObjectDead() const";
"OHOS::IPCObjectProxy::IsObjectDead()";
"OHOS::IPCObjectProxy::CanPromote()";
"OHOS::IPCObjectStub::IsObjectDead()";
"virtual thunk to OHOS::IRemoteObject::GetInterfaceDescriptor()";
"virtual thunk to OHOS::IPCObjectProxy::CanPromote()";
"OHOS::IRemoteObject::GetInterfaceDescriptor()";
"OHOS::IPCObjectProxy::GetInterfaceDescriptor()";
"OHOS::IPCObjectStub::GetInterfaceDescriptor()";

View File

@ -23,6 +23,9 @@ config("libipc_single_private_config") {
config("ipc_all_deps_config") {
include_dirs = [ "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include" ]
if (is_emulator) {
defines = [ "EMULATOR_PLATFORM" ]
}
}
ohos_shared_library("ipc_single") {

View File

@ -68,8 +68,10 @@
"virtual thunk to OHOS::IRemoteObject::IsObjectDead() const";
"OHOS::IRemoteObject::IsObjectDead() const";
"OHOS::IPCObjectProxy::IsObjectDead()";
"OHOS::IPCObjectProxy::CanPromote()";
"OHOS::IPCObjectStub::IsObjectDead()";
"virtual thunk to OHOS::IRemoteObject::GetInterfaceDescriptor()";
"virtual thunk to OHOS::IPCObjectProxy::CanPromote()";
"OHOS::IRemoteObject::GetInterfaceDescriptor()";
"OHOS::IPCObjectProxy::GetInterfaceDescriptor()";
"OHOS::IPCObjectStub::GetInterfaceDescriptor()";

View File

@ -616,6 +616,13 @@ uint32_t IPCObjectProxy::GetStrongRefCountForStub()
return invoker->GetStrongRefCountForStub(handle_);
}
#ifndef EMULATOR_PLATFORM
bool IPCObjectProxy::CanPromote()
{
return (GetSptrRefCount() > 0);
}
#endif
#ifndef CONFIG_IPC_SINGLE
int IPCObjectProxy::UpdateProto()
{

View File

@ -38,6 +38,9 @@ public:
MockIPCObjectProxy() : IPCObjectProxy(1, u"mockProxyService") {};
~MockIPCObjectProxy() {};
#ifndef EMULATOR_PLATFORM
MOCK_METHOD0(CanPromote, bool());
#endif
MOCK_METHOD0(GetObjectRefCount, int32_t());
MOCK_METHOD0(GetSessionName, std::string());
MOCK_METHOD0(GetInterfaceDescriptor, std::u16string());