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

Merge pull request !1496 from dengliang/master
This commit is contained in:
openharmony_ci 2024-11-01 06:11:33 +00:00 committed by Gitee
commit dc8fe18aaf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 22 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

@ -70,6 +70,7 @@
"OHOS::IPCObjectProxy::IsObjectDead()";
"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

@ -70,6 +70,7 @@
"OHOS::IPCObjectProxy::IsObjectDead()";
"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());