add ipc.bundle.json ipc_core.BUILD.gn ipc_single.BUILD.gn mbedtls.BUILD.gn and create soft link to /usr/include/ipc /usr/include/nlohmann_json and /usr/include/nlohmann_json/single_include

This commit is contained in:
zxstty 2023-11-10 11:46:38 +08:00 committed by muyuying1
parent 886ffc5b89
commit 037a5ecbf0
22 changed files with 2787 additions and 0 deletions

View File

@ -0,0 +1,618 @@
From 93f0cdc41e63859c3e67d460028a892298cb94e5 Mon Sep 17 00:00:00 2001
From: heppen <hepeng68@huawei.com>
Date: Sat, 23 Sep 2023 16:56:54 +0800
Subject: [PATCH 1/2] Remove dependence on access token and hitrace
---
interfaces/innerkits/ipc_core/BUILD.gn | 4 +-
interfaces/innerkits/ipc_single/BUILD.gn | 2 +-
.../access_token/src/access_token_adapter.c | 2 +-
.../src/core/source/ipc_object_stub.cpp | 76 ++++---
.../src/mock/include/dbinder_base_invoker.h | 12 +-
ipc/native/src/mock/include/hitrace_invoker.h | 18 +-
ipc/native/src/mock/source/binder_invoker.cpp | 12 +-
.../src/mock/source/hitrace_invoker.cpp | 212 +++++++++---------
.../src/mock/source/invoker_factory.cpp | 2 +-
.../src/napi/src/napi_remote_object.cpp | 2 +-
ipc/native/src/napi/src/napi_remote_proxy.cpp | 2 +-
.../unittest/common/ipc_hitrace_unittest.cpp | 2 +-
.../include/dbinder_test_service_skeleton.h | 2 +-
13 files changed, 175 insertions(+), 173 deletions(-)
diff --git a/interfaces/innerkits/ipc_core/BUILD.gn b/interfaces/innerkits/ipc_core/BUILD.gn
index cb35083..3c4d57b 100644
--- a/interfaces/innerkits/ipc_core/BUILD.gn
+++ b/interfaces/innerkits/ipc_core/BUILD.gn
@@ -71,10 +71,10 @@ ohos_shared_library("ipc_core") {
all_dependent_configs = [ ":ipc_all_deps_config" ]
external_deps = [
- "access_token:libaccesstoken_sdk",
+ # "access_token:libaccesstoken_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
- "hitrace_native:libhitracechain",
+ # "hitrace_native:libhitracechain",
"hiviewdfx_hilog_native:libhilog",
]
diff --git a/interfaces/innerkits/ipc_single/BUILD.gn b/interfaces/innerkits/ipc_single/BUILD.gn
index de33cdb..f61f26c 100644
--- a/interfaces/innerkits/ipc_single/BUILD.gn
+++ b/interfaces/innerkits/ipc_single/BUILD.gn
@@ -59,7 +59,7 @@ ohos_shared_library("ipc_single") {
external_deps = [
"c_utils:utils",
- "hitrace_native:libhitracechain",
+ # "hitrace_native:libhitracechain",
"hiviewdfx_hilog_native:libhilog",
]
diff --git a/ipc/native/c/adapter/access_token/src/access_token_adapter.c b/ipc/native/c/adapter/access_token/src/access_token_adapter.c
index aece213..890ba82 100644
--- a/ipc/native/c/adapter/access_token/src/access_token_adapter.c
+++ b/ipc/native/c/adapter/access_token/src/access_token_adapter.c
@@ -19,7 +19,7 @@
#include <sys/ioctl.h>
#include <unistd.h>
-#include "bits/ioctl.h"
+// #include "bits/ioctl.h"
#define ACCESS_TOKEN_ID_IOCTL_BASE 'A'
diff --git a/ipc/native/src/core/source/ipc_object_stub.cpp b/ipc/native/src/core/source/ipc_object_stub.cpp
index 28df2cd..781d600 100644
--- a/ipc/native/src/core/source/ipc_object_stub.cpp
+++ b/ipc/native/src/core/source/ipc_object_stub.cpp
@@ -39,8 +39,8 @@
#include "vector"
#ifndef CONFIG_IPC_SINGLE
-#include "accesstoken_kit.h"
-#include "access_token_adapter.h"
+// #include "accesstoken_kit.h"
+// #include "access_token_adapter.h"
#include "dbinder_databus_invoker.h"
#include "dbinder_error_code.h"
#include "rpc_feature_set.h"
@@ -56,10 +56,10 @@ static constexpr int HIDUMPER_SERVICE_UID = 1212;
using namespace OHOS::HiviewDFX;
static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjectStub" };
#ifndef CONFIG_IPC_SINGLE
-using namespace OHOS::Security;
+// using namespace OHOS::Security;
// Authentication information can be added only for processes with system permission.
static constexpr pid_t ALLOWED_UID = 10000;
-static constexpr int APL_BASIC = 2;
+// static constexpr int APL_BASIC = 2;
// Only the samgr can obtain the UID and PID.
static const std::string SAMGR_PROCESS_NAME = "samgr";
#endif
@@ -259,7 +259,7 @@ int IPCObjectStub::SendRequest(uint32_t code, MessageParcel &data, MessageParcel
break;
}
case GRANT_DATABUS_NAME: {
- if (!IPCSkeleton::IsLocalCalling() || !IsSamgrCall((uint32_t)RpcGetSelfTokenID())) {
+ if (!IPCSkeleton::IsLocalCalling() || !IsSamgrCall((uint32_t)0)) {
ZLOGE(LABEL, "GRANT_DATABUS_NAME message is excluded in sa manager");
result = IPC_STUB_INVALID_DATA_ERR;
break;
@@ -268,7 +268,7 @@ int IPCObjectStub::SendRequest(uint32_t code, MessageParcel &data, MessageParcel
break;
}
case TRANS_DATABUS_NAME: {
- if (!IPCSkeleton::IsLocalCalling() || !IsSamgrCall((uint32_t)RpcGetSelfTokenID())) {
+ if (!IPCSkeleton::IsLocalCalling() || !IsSamgrCall((uint32_t)0)) {
ZLOGE(LABEL, "TRANS_DATABUS_NAME message is excluded in sa manager");
result = IPC_STUB_INVALID_DATA_ERR;
break;
@@ -611,41 +611,43 @@ std::string IPCObjectStub::CreateDatabusName(int uid, int pid, int systemAbility
bool IPCObjectStub::IsSamgrCall(uint32_t accessToken)
{
- auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessToken);
- if (tokenType != AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
- ZLOGE(LABEL, "not native call");
- return false;
- }
- AccessToken::NativeTokenInfo nativeTokenInfo;
- int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
- if (result == ERR_NONE && nativeTokenInfo.processName == SAMGR_PROCESS_NAME) {
- return true;
- }
- ZLOGE(LABEL, "not samgr called, processName:%{private}s", nativeTokenInfo.processName.c_str());
- return false;
+ // auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessToken);
+ // if (tokenType != AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
+ // ZLOGE(LABEL, "not native call");
+ // return false;
+ // }
+ // AccessToken::NativeTokenInfo nativeTokenInfo;
+ // int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
+ // if (result == ERR_NONE && nativeTokenInfo.processName == SAMGR_PROCESS_NAME) {
+ // return true;
+ // }
+ // ZLOGE(LABEL, "not samgr called, processName:%{private}s", nativeTokenInfo.processName.c_str());
+ // return false;
+ return true;
}
bool IPCObjectStub::HasDumpPermission(uint32_t accessToken) const
{
- int res = AccessToken::AccessTokenKit::VerifyAccessToken(accessToken, "ohos.permission.DUMP");
- if (res == AccessToken::PermissionState::PERMISSION_GRANTED) {
- return true;
- }
- bool ret = false;
- auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessToken);
- if (tokenType == AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
- AccessToken::NativeTokenInfo nativeTokenInfo;
- int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
- ret = (result == ERR_NONE && nativeTokenInfo.apl >= APL_BASIC);
- } else if (tokenType == AccessToken::ATokenTypeEnum::TOKEN_HAP) {
- AccessToken::HapTokenInfo hapTokenInfo;
- int32_t result = AccessToken::AccessTokenKit::GetHapTokenInfo(accessToken, hapTokenInfo);
- ret = (result == ERR_NONE && hapTokenInfo.apl >= APL_BASIC);
- }
- if (!ret) {
- ZLOGD(LABEL, "No dump permission, please check!");
- }
- return ret;
+ // int res = AccessToken::AccessTokenKit::VerifyAccessToken(accessToken, "ohos.permission.DUMP");
+ // if (res == AccessToken::PermissionState::PERMISSION_GRANTED) {
+ // return true;
+ // }
+ // bool ret = false;
+ // auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessToken);
+ // if (tokenType == AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
+ // AccessToken::NativeTokenInfo nativeTokenInfo;
+ // int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
+ // ret = (result == ERR_NONE && nativeTokenInfo.apl >= APL_BASIC);
+ // } else if (tokenType == AccessToken::ATokenTypeEnum::TOKEN_HAP) {
+ // AccessToken::HapTokenInfo hapTokenInfo;
+ // int32_t result = AccessToken::AccessTokenKit::GetHapTokenInfo(accessToken, hapTokenInfo);
+ // ret = (result == ERR_NONE && hapTokenInfo.apl >= APL_BASIC);
+ // }
+ // if (!ret) {
+ // ZLOGD(LABEL, "No dump permission, please check!");
+ // }
+ // return ret;
+ return true;
}
#endif
} // namespace OHOS
diff --git a/ipc/native/src/mock/include/dbinder_base_invoker.h b/ipc/native/src/mock/include/dbinder_base_invoker.h
index ca7fd8e..7d40e7d 100644
--- a/ipc/native/src/mock/include/dbinder_base_invoker.h
+++ b/ipc/native/src/mock/include/dbinder_base_invoker.h
@@ -701,9 +701,9 @@ int DBinderBaseInvoker<T>::SendRequest(int32_t handle, uint32_t code, MessagePar
int userWaitTime = option.GetWaitTime();
MessageParcel &newData = const_cast<MessageParcel &>(data);
size_t oldWritePosition = newData.GetWritePosition();
- HiTraceId traceId = HiTraceChain::GetId();
+ // HiTraceId traceId = HiTraceChain::GetId();
// set client send trace point if trace is enabled
- HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
+ // HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
std::shared_ptr<T> session = WriteTransaction(BC_TRANSACTION, flags, handle, 0, code, data, seqNumber, 0);
if (session == nullptr) {
newData.RewindWrite(oldWritePosition);
@@ -720,7 +720,7 @@ int DBinderBaseInvoker<T>::SendRequest(int32_t handle, uint32_t code, MessagePar
} else {
ret = SendOrWaitForCompletion(userWaitTime, seqNumber, session, &reply);
}
- HitraceInvoker::TraceClientReceieve(handle, code, flags, traceId, childId);
+ // HitraceInvoker::TraceClientReceieve(handle, code, flags, traceId, childId);
// restore Parcel data
newData.RewindWrite(oldWritePosition);
return ret;
@@ -865,8 +865,8 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
data.InjectOffsets(reinterpret_cast<binder_uintptr_t>(reinterpret_cast<char *>(tr->buffer) + tr->offsets),
tr->offsets_size / sizeof(binder_size_t));
}
- uint32_t &newflags = const_cast<uint32_t &>(tr->flags);
- int isServerTraced = HitraceInvoker::TraceServerReceieve(tr->cookie, tr->code, data, newflags);
+ // uint32_t &newflags = const_cast<uint32_t &>(tr->flags);
+ // int isServerTraced = HitraceInvoker::TraceServerReceieve(tr->cookie, tr->code, data, newflags);
const pid_t oldPid = GetCallerPid();
const auto oldUid = static_cast<const uid_t>(GetCallerUid());
@@ -918,7 +918,7 @@ template <class T> void DBinderBaseInvoker<T>::ProcessTransaction(dbinder_transa
ZLOGE(LOG_LABEL, "delete raw data in process skeleton");
current->DetachRawData(listenFd);
}
- HitraceInvoker::TraceServerSend(tr->cookie, tr->code, isServerTraced, newflags);
+ // HitraceInvoker::TraceServerSend(tr->cookie, tr->code, isServerTraced, newflags);
if (!(flags & MessageOption::TF_ASYNC)) {
SetClientFd(listenFd);
SetSeqNum(senderSeqNumber);
diff --git a/ipc/native/src/mock/include/hitrace_invoker.h b/ipc/native/src/mock/include/hitrace_invoker.h
index 7da8029..785a1d2 100644
--- a/ipc/native/src/mock/include/hitrace_invoker.h
+++ b/ipc/native/src/mock/include/hitrace_invoker.h
@@ -16,24 +16,24 @@
#ifndef OHOS_IPC_HITRACE_INVOKER_H
#define OHOS_IPC_HITRACE_INVOKER_H
-#include "hitrace/trace.h"
+// #include "hitrace/trace.h"
#include "iremote_object.h"
namespace OHOS {
class HitraceInvoker {
public:
- static bool IsClientTraced(int32_t handle, uint32_t flags, const HiviewDFX::HiTraceId &traceId);
+ // static bool IsClientTraced(int32_t handle, uint32_t flags, const HiviewDFX::HiTraceId &traceId);
- static HiviewDFX::HiTraceId TraceClientSend(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags,
- const HiviewDFX::HiTraceId &traceId);
+ // static HiviewDFX::HiTraceId TraceClientSend(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags,
+ // const HiviewDFX::HiTraceId &traceId);
- static void TraceClientReceieve(int32_t handle, uint32_t code, uint32_t flags, const HiviewDFX::HiTraceId &traceId,
- const HiviewDFX::HiTraceId &childId);
+ // static void TraceClientReceieve(int32_t handle, uint32_t code, uint32_t flags, const HiviewDFX::HiTraceId &traceId,
+ // const HiviewDFX::HiTraceId &childId);
- static void RecoveryDataAndFlag(Parcel &data, uint32_t &flags, size_t oldReadPosition, uint8_t idLen);
+ // static void RecoveryDataAndFlag(Parcel &data, uint32_t &flags, size_t oldReadPosition, uint8_t idLen);
- static bool TraceServerReceieve(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags);
+ // static bool TraceServerReceieve(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags);
- static void TraceServerSend(int32_t handle, uint32_t code, bool isServerTraced, uint32_t flags);
+ // static void TraceServerSend(int32_t handle, uint32_t code, bool isServerTraced, uint32_t flags);
private:
static const int PADDED_SIZE_OF_PARCEL = 4;
diff --git a/ipc/native/src/mock/source/binder_invoker.cpp b/ipc/native/src/mock/source/binder_invoker.cpp
index 9ce6b59..946940c 100644
--- a/ipc/native/src/mock/source/binder_invoker.cpp
+++ b/ipc/native/src/mock/source/binder_invoker.cpp
@@ -96,9 +96,9 @@ int BinderInvoker::SendRequest(int handle, uint32_t code, MessageParcel &data, M
uint32_t flags = (uint32_t)option.GetFlags();
MessageParcel &newData = const_cast<MessageParcel &>(data);
size_t oldWritePosition = newData.GetWritePosition();
- HiTraceId traceId = HiTraceChain::GetId();
+ // HiTraceId traceId = HiTraceChain::GetId();
// set client send trace point if trace is enabled
- HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
+ // HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
if (!WriteTransaction(BC_TRANSACTION, flags, handle, code, data, nullptr)) {
newData.RewindWrite(oldWritePosition);
ZLOGE(LABEL, "WriteTransaction ERROR");
@@ -114,7 +114,7 @@ int BinderInvoker::SendRequest(int handle, uint32_t code, MessageParcel &data, M
} else {
error = WaitForCompletion(&reply);
}
- HitraceInvoker::TraceClientReceieve(handle, code, flags, traceId, childId);
+ // HitraceInvoker::TraceClientReceieve(handle, code, flags, traceId, childId);
// restore Parcel data
newData.RewindWrite(oldWritePosition);
if (error != ERR_NONE) {
@@ -413,8 +413,8 @@ void BinderInvoker::OnTransaction(const uint8_t *buffer)
if (tr->offsets_size > 0) {
data->InjectOffsets(tr->data.ptr.offsets, tr->offsets_size / sizeof(binder_size_t));
}
- uint32_t &newflags = const_cast<uint32_t &>(tr->flags);
- int isServerTraced = HitraceInvoker::TraceServerReceieve(tr->target.handle, tr->code, *data, newflags);
+ // uint32_t &newflags = const_cast<uint32_t &>(tr->flags);
+ // int isServerTraced = HitraceInvoker::TraceServerReceieve(tr->target.handle, tr->code, *data, newflags);
const pid_t oldPid = callerPid_;
const auto oldUid = static_cast<const uid_t>(callerUid_);
const uint32_t oldToken = callerTokenID_;
@@ -469,7 +469,7 @@ void BinderInvoker::OnTransaction(const uint8_t *buffer)
Str16ToStr8(targetObject->descriptor_).c_str(), tr->code, duration);
}
}
- HitraceInvoker::TraceServerSend(tr->target.handle, tr->code, isServerTraced, newflags);
+ // HitraceInvoker::TraceServerSend(tr->target.handle, tr->code, isServerTraced, newflags);
if (!(flagValue & TF_ONE_WAY)) {
SendReply(reply, 0, error);
}
diff --git a/ipc/native/src/mock/source/hitrace_invoker.cpp b/ipc/native/src/mock/source/hitrace_invoker.cpp
index 4f7f7c3..bc55772 100644
--- a/ipc/native/src/mock/source/hitrace_invoker.cpp
+++ b/ipc/native/src/mock/source/hitrace_invoker.cpp
@@ -20,7 +20,7 @@
#include "hilog/log_c.h"
#include "hilog/log_cpp.h"
-#include "hitrace/trace.h"
+// #include "hitrace/trace.h"
#include "ipc_debug.h"
#include "log_tags.h"
#include "parcel.h"
@@ -29,118 +29,118 @@
namespace OHOS {
// the value should be equal to the set of parcel
using namespace OHOS::HiviewDFX;
-static const HiLogLabel TRACE_LABEL = { LOG_CORE, LOG_ID_IPC, "BinderHiTrace" };
+// static const HiLogLabel TRACE_LABEL = { LOG_CORE, LOG_ID_IPC, "BinderHiTrace" };
-bool HitraceInvoker::IsClientTraced(int32_t handle, uint32_t flags, const HiTraceId &traceId)
-{
- return (traceId.IsValid() && (handle != 0) &&
- ((flags & TF_ONE_WAY) ? traceId.IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC) : true));
-}
+// bool HitraceInvoker::IsClientTraced(int32_t handle, uint32_t flags, const HiTraceId &traceId)
+// {
+// return (traceId.IsValid() && (handle != 0) &&
+// ((flags & TF_ONE_WAY) ? traceId.IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC) : true));
+// }
-HiTraceId HitraceInvoker::TraceClientSend(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags,
- const HiTraceId &traceId)
-{
- HiTraceId childId = traceId;
- bool isClientTraced = IsClientTraced(handle, flags, traceId);
- if (isClientTraced) {
- childId = HiTraceChain::CreateSpan();
- // add childid to parcel data
- uint8_t idBytes[HITRACE_ID_LEN];
- size_t idLen = (size_t)(childId.ToBytes(idBytes, HITRACE_ID_LEN));
- if (idLen != HITRACE_ID_LEN) {
- ZLOGE(TRACE_LABEL, "%{public}s:idLen not correct", __func__);
- return childId;
- }
+// HiTraceId HitraceInvoker::TraceClientSend(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags,
+// const HiTraceId &traceId)
+// {
+// HiTraceId childId = traceId;
+// bool isClientTraced = IsClientTraced(handle, flags, traceId);
+// if (isClientTraced) {
+// childId = HiTraceChain::CreateSpan();
+// // add childid to parcel data
+// uint8_t idBytes[HITRACE_ID_LEN];
+// size_t idLen = (size_t)(childId.ToBytes(idBytes, HITRACE_ID_LEN));
+// if (idLen != HITRACE_ID_LEN) {
+// ZLOGE(TRACE_LABEL, "%{public}s:idLen not correct", __func__);
+// return childId;
+// }
- size_t oldWritePosition = data.GetWritePosition();
- if (!data.WriteBuffer(idBytes, idLen)) {
- ZLOGE(TRACE_LABEL, "%{public}s:Write idBytes fail", __func__);
- // restore Parcel data
- data.RewindWrite(oldWritePosition);
- return childId;
- }
+// size_t oldWritePosition = data.GetWritePosition();
+// if (!data.WriteBuffer(idBytes, idLen)) {
+// ZLOGE(TRACE_LABEL, "%{public}s:Write idBytes fail", __func__);
+// // restore Parcel data
+// data.RewindWrite(oldWritePosition);
+// return childId;
+// }
- // padded size of traceid
- if (!data.WriteUint8(data.GetWritePosition() - oldWritePosition)) {
- ZLOGE(TRACE_LABEL, "%{public}s:Write idLen fail", __func__);
- // restore Parcel data
- data.RewindWrite(oldWritePosition);
- return childId;
- }
- // tracepoint: CS(Client Send)
- HiTraceChain::Tracepoint(HITRACE_TP_CS, childId, "%s handle=%d,code=%u",
- (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
- handle, code);
- flags |= TF_HITRACE;
- }
- return childId;
-}
+// // padded size of traceid
+// if (!data.WriteUint8(data.GetWritePosition() - oldWritePosition)) {
+// ZLOGE(TRACE_LABEL, "%{public}s:Write idLen fail", __func__);
+// // restore Parcel data
+// data.RewindWrite(oldWritePosition);
+// return childId;
+// }
+// // tracepoint: CS(Client Send)
+// HiTraceChain::Tracepoint(HITRACE_TP_CS, childId, "%s handle=%d,code=%u",
+// (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
+// handle, code);
+// flags |= TF_HITRACE;
+// }
+// return childId;
+// }
-void HitraceInvoker::TraceClientReceieve(int32_t handle, uint32_t code, uint32_t flags, const HiTraceId &traceId,
- const HiTraceId &childId)
-{
- if (!(flags & TF_HITRACE)) {
- return;
- }
- bool isClientTraced = IsClientTraced(handle, flags, traceId);
- if (isClientTraced) {
- if (!(flags & TF_ONE_WAY)) {
- // restore thread trace id
- HiTraceChain::SetId(traceId);
- // tracepoint: CR(Client Receive)
- HiTraceChain::Tracepoint(HITRACE_TP_CR, childId, "%s handle=%d,code=%u", "SYNC", handle, code);
- }
- }
-}
+// void HitraceInvoker::TraceClientReceieve(int32_t handle, uint32_t code, uint32_t flags, const HiTraceId &traceId,
+// const HiTraceId &childId)
+// {
+// if (!(flags & TF_HITRACE)) {
+// return;
+// }
+// bool isClientTraced = IsClientTraced(handle, flags, traceId);
+// if (isClientTraced) {
+// if (!(flags & TF_ONE_WAY)) {
+// // restore thread trace id
+// HiTraceChain::SetId(traceId);
+// // tracepoint: CR(Client Receive)
+// HiTraceChain::Tracepoint(HITRACE_TP_CR, childId, "%s handle=%d,code=%u", "SYNC", handle, code);
+// }
+// }
+// }
-void HitraceInvoker::RecoveryDataAndFlag(Parcel &data, uint32_t &flags, size_t oldReadPosition, uint8_t idLen)
-{
- // restore data
- data.RewindRead(oldReadPosition);
- // padded size(4 bytes) of uint8_t
- data.SetDataSize(data.GetDataSize() - PADDED_SIZE_OF_PARCEL - idLen);
- flags &= ~(uint32_t)TF_HITRACE;
-}
+// void HitraceInvoker::RecoveryDataAndFlag(Parcel &data, uint32_t &flags, size_t oldReadPosition, uint8_t idLen)
+// {
+// // restore data
+// data.RewindRead(oldReadPosition);
+// // padded size(4 bytes) of uint8_t
+// data.SetDataSize(data.GetDataSize() - PADDED_SIZE_OF_PARCEL - idLen);
+// flags &= ~(uint32_t)TF_HITRACE;
+// }
-bool HitraceInvoker::TraceServerReceieve(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags)
-{
- bool isServerTraced = (flags & TF_HITRACE) != 0;
- if (isServerTraced) {
- size_t oldReadPosition = data.GetReadPosition();
- // padded size(4 bytes) of uint8_t
- data.RewindRead(data.GetDataSize() - PADDED_SIZE_OF_PARCEL);
- // the padded size of traceid
- uint8_t idLen = data.ReadUint8();
- if (idLen >= sizeof(HiTraceIdStruct)) {
- // padded size(4 bytes) of uint8_t
- data.RewindRead(data.GetDataSize() - PADDED_SIZE_OF_PARCEL - idLen);
- const uint8_t *idBytes = data.ReadUnpadBuffer(sizeof(HiTraceIdStruct));
- if (idBytes == nullptr) {
- ZLOGE(TRACE_LABEL, "%{public}s:idBytes is null", __func__);
- isServerTraced = 0;
- RecoveryDataAndFlag(data, flags, oldReadPosition, idLen);
- return isServerTraced;
- }
- HiTraceId traceId(idBytes, sizeof(HiTraceIdStruct));
- HiTraceChain::SetId(traceId);
- // tracepoint: SR(Server Receive)
- HiTraceChain::Tracepoint(HITRACE_TP_SR, traceId,
- "%s handle=%d,code=%u", (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
- handle, code);
- }
+// bool HitraceInvoker::TraceServerReceieve(int32_t handle, uint32_t code, Parcel &data, uint32_t &flags)
+// {
+// bool isServerTraced = (flags & TF_HITRACE) != 0;
+// if (isServerTraced) {
+// size_t oldReadPosition = data.GetReadPosition();
+// // padded size(4 bytes) of uint8_t
+// data.RewindRead(data.GetDataSize() - PADDED_SIZE_OF_PARCEL);
+// // the padded size of traceid
+// uint8_t idLen = data.ReadUint8();
+// if (idLen >= sizeof(HiTraceIdStruct)) {
+// // padded size(4 bytes) of uint8_t
+// data.RewindRead(data.GetDataSize() - PADDED_SIZE_OF_PARCEL - idLen);
+// const uint8_t *idBytes = data.ReadUnpadBuffer(sizeof(HiTraceIdStruct));
+// if (idBytes == nullptr) {
+// ZLOGE(TRACE_LABEL, "%{public}s:idBytes is null", __func__);
+// isServerTraced = 0;
+// RecoveryDataAndFlag(data, flags, oldReadPosition, idLen);
+// return isServerTraced;
+// }
+// HiTraceId traceId(idBytes, sizeof(HiTraceIdStruct));
+// HiTraceChain::SetId(traceId);
+// // tracepoint: SR(Server Receive)
+// HiTraceChain::Tracepoint(HITRACE_TP_SR, traceId,
+// "%s handle=%d,code=%u", (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
+// handle, code);
+// }
- RecoveryDataAndFlag(data, flags, oldReadPosition, idLen);
- }
- return isServerTraced;
-}
+// RecoveryDataAndFlag(data, flags, oldReadPosition, idLen);
+// }
+// return isServerTraced;
+// }
-void HitraceInvoker::TraceServerSend(int32_t handle, uint32_t code, bool isServerTraced, uint32_t flags)
-{
- if (isServerTraced) {
- // tracepoint: SS(Server Send)
- HiTraceChain::Tracepoint(HITRACE_TP_SS, HiTraceChain::GetId(), "%s handle=%d,code=%u",
- (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC", handle, code);
- }
- HiTraceChain::ClearId();
-}
+// void HitraceInvoker::TraceServerSend(int32_t handle, uint32_t code, bool isServerTraced, uint32_t flags)
+// {
+// if (isServerTraced) {
+// // tracepoint: SS(Server Send)
+// HiTraceChain::Tracepoint(HITRACE_TP_SS, HiTraceChain::GetId(), "%s handle=%d,code=%u",
+// (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC", handle, code);
+// }
+// HiTraceChain::ClearId();
+// }
} // namespace OHOS
diff --git a/ipc/native/src/mock/source/invoker_factory.cpp b/ipc/native/src/mock/source/invoker_factory.cpp
index 5b2946b..e539639 100644
--- a/ipc/native/src/mock/source/invoker_factory.cpp
+++ b/ipc/native/src/mock/source/invoker_factory.cpp
@@ -18,7 +18,7 @@
#include <memory>
#include <utility>
-#include "__mutex_base"
+// #include "__mutex_base"
#include "functional"
#include "iremote_invoker.h"
#include "unordered_map"
diff --git a/ipc/native/src/napi/src/napi_remote_object.cpp b/ipc/native/src/napi/src/napi_remote_object.cpp
index 1275bb3..4ff5260 100644
--- a/ipc/native/src/napi/src/napi_remote_object.cpp
+++ b/ipc/native/src/napi/src/napi_remote_object.cpp
@@ -22,7 +22,7 @@
#include <uv.h>
#include "access_token_adapter.h"
#include "hilog/log.h"
-#include "hitrace_meter.h"
+// #include "hitrace_meter.h"
#include "ipc_object_proxy.h"
#include "ipc_object_stub.h"
#include "ipc_skeleton.h"
diff --git a/ipc/native/src/napi/src/napi_remote_proxy.cpp b/ipc/native/src/napi/src/napi_remote_proxy.cpp
index 0239944..9b4c6d9 100644
--- a/ipc/native/src/napi/src/napi_remote_proxy.cpp
+++ b/ipc/native/src/napi/src/napi_remote_proxy.cpp
@@ -21,7 +21,7 @@
#include <uv.h>
#include "access_token_adapter.h"
#include "hilog/log.h"
-#include "hitrace_meter.h"
+// #include "hitrace_meter.h"
#include "ipc_object_proxy.h"
#include "ipc_object_stub.h"
#include "ipc_skeleton.h"
diff --git a/ipc/native/test/unittest/common/ipc_hitrace_unittest.cpp b/ipc/native/test/unittest/common/ipc_hitrace_unittest.cpp
index 8b008f5..77649f0 100644
--- a/ipc/native/test/unittest/common/ipc_hitrace_unittest.cpp
+++ b/ipc/native/test/unittest/common/ipc_hitrace_unittest.cpp
@@ -23,7 +23,7 @@
#include <securec.h>
#include <gtest/gtest.h>
#include "ipc_debug.h"
-#include "hitrace/trace.h"
+// #include "hitrace/trace.h"
#include "ipc_skeleton.h"
#include "ipc_object_proxy.h"
#include "test_service_skeleton.h"
diff --git a/services/dbinder/test/distributedtest/include/dbinder_test_service_skeleton.h b/services/dbinder/test/distributedtest/include/dbinder_test_service_skeleton.h
index 41fe229..40d5177 100644
--- a/services/dbinder/test/distributedtest/include/dbinder_test_service_skeleton.h
+++ b/services/dbinder/test/distributedtest/include/dbinder_test_service_skeleton.h
@@ -23,7 +23,7 @@
#include "iremote_proxy.h"
#include "hilog/log.h"
#include "log_tags.h"
-#include "hitrace/trace.h"
+// #include "hitrace/trace.h"
namespace OHOS {
class IDBinderTestService : public IRemoteBroker {
--
2.33.0

View File

@ -0,0 +1,93 @@
From c4435b4448b3d8e95334528bbf0f2bdcf9ac5fa4 Mon Sep 17 00:00:00 2001
From: heppen <hepeng68@huawei.com>
Date: Sat, 23 Sep 2023 16:59:33 +0800
Subject: [PATCH 2/2] adaption for build: remove useless headers, add some
headers
---
interfaces/innerkits/ipc_core/include/iremote_broker.h | 1 +
interfaces/innerkits/ipc_core/include/message_parcel.h | 1 +
ipc/native/src/core/source/ipc_object_proxy.cpp | 2 +-
ipc/native/src/core/source/iremote_broker.cpp | 2 +-
ipc/native/src/mock/include/invoker_factory.h | 1 +
ipc/native/src/mock/source/binder_connector.cpp | 2 +-
6 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/interfaces/innerkits/ipc_core/include/iremote_broker.h b/interfaces/innerkits/ipc_core/include/iremote_broker.h
index ed2045c..7105ff7 100644
--- a/interfaces/innerkits/ipc_core/include/iremote_broker.h
+++ b/interfaces/innerkits/ipc_core/include/iremote_broker.h
@@ -18,6 +18,7 @@
#include <unordered_map>
#include <functional>
+#include <mutex>
#include "iremote_object.h"
#include "refbase.h"
diff --git a/interfaces/innerkits/ipc_core/include/message_parcel.h b/interfaces/innerkits/ipc_core/include/message_parcel.h
index 0f3302e..efa57ab 100644
--- a/interfaces/innerkits/ipc_core/include/message_parcel.h
+++ b/interfaces/innerkits/ipc_core/include/message_parcel.h
@@ -20,6 +20,7 @@
#include "parcel.h"
#include "refbase.h"
#include <string>
+#include <memory>
namespace OHOS {
class IRemoteObject;
diff --git a/ipc/native/src/core/source/ipc_object_proxy.cpp b/ipc/native/src/core/source/ipc_object_proxy.cpp
index 559c276..23f56a8 100644
--- a/ipc/native/src/core/source/ipc_object_proxy.cpp
+++ b/ipc/native/src/core/source/ipc_object_proxy.cpp
@@ -17,7 +17,7 @@
#include <cstdint>
-#include "__mutex_base"
+// #include "__mutex_base"
#include "algorithm"
#include "errors.h"
#include "hilog/log_c.h"
diff --git a/ipc/native/src/core/source/iremote_broker.cpp b/ipc/native/src/core/source/iremote_broker.cpp
index dcbb59c..12f498e 100644
--- a/ipc/native/src/core/source/iremote_broker.cpp
+++ b/ipc/native/src/core/source/iremote_broker.cpp
@@ -17,7 +17,7 @@
#include <utility>
-#include "__mutex_base"
+// #include "__mutex_base"
#include "functional"
#include "hilog/log_c.h"
#include "hilog/log_cpp.h"
diff --git a/ipc/native/src/mock/include/invoker_factory.h b/ipc/native/src/mock/include/invoker_factory.h
index 14bd25f..83086c5 100644
--- a/ipc/native/src/mock/include/invoker_factory.h
+++ b/ipc/native/src/mock/include/invoker_factory.h
@@ -17,6 +17,7 @@
#define OHOS_IPC_INVOKER_FACTORY_H
#include <functional>
+#include <mutex>
#include <unordered_map>
#include "iremote_invoker.h"
diff --git a/ipc/native/src/mock/source/binder_connector.cpp b/ipc/native/src/mock/source/binder_connector.cpp
index a262de6..733769d 100644
--- a/ipc/native/src/mock/source/binder_connector.cpp
+++ b/ipc/native/src/mock/source/binder_connector.cpp
@@ -21,7 +21,7 @@
#include <sys/mman.h>
#include <unistd.h>
-#include "__mutex_base"
+// #include "__mutex_base"
#include "cerrno"
#include "hilog/log_c.h"
#include "hilog/log_cpp.h"
--
2.33.0

View File

@ -0,0 +1,197 @@
From 94b7c10aba2a0c79b88a2b37598adefd206f3e5b Mon Sep 17 00:00:00 2001
From: heppen <hepeng68@huawei.com>
Date: Mon, 26 Jun 2023 17:11:55 +0800
Subject: [PATCH] Adapt binder as a kernel module
---
Makefile | 21 ++++++++---
binder.c | 26 +++++++++++--
binder_alloc.c | 2 +-
external_symbols.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 131 insertions(+), 9 deletions(-)
create mode 100644 external_symbols.c
diff --git a/Makefile b/Makefile
index c9d3d0c..5d07f84 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,17 @@
-# SPDX-License-Identifier: GPL-2.0-only
-ccflags-y += -I$(src) # needed for trace events
+CONFIG_MODULE_SIG=n
+ccflags-y += -I$(src) -Wno-int-conversion -Wno-implicit-function-declaration -DCONFIG_ANDROID_BINDER_DEVICES=\"binder\"
-obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o
-obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o
-obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o
+# only support openEuler-22.03-LTS-SP2 kernel.
+ifneq ($(KERNELRELEASE),)
+obj-m := binder_linux.o
+binder_linux-y := external_symbols.o binder.o binder_alloc.o
+else
+KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
+
+
+all:
+ $(MAKE) -C $(KERNEL_SRC) V=0 M=$$PWD
+
+clean:
+ $(MAKE) -C $(KERNEL_SRC) M=$$PWD clean
+endif
diff --git a/binder.c b/binder.c
index b403c7f..35384d8 100644
--- a/binder.c
+++ b/binder.c
@@ -2039,8 +2039,8 @@ static size_t binder_get_object(struct binder_proc *proc,
return 0;
} else {
if (binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
- offset, read_size))
- return 0;
+ offset, read_size))
+ return 0;
}
/* Ok, now see if we read a complete object. */
@@ -6531,7 +6531,27 @@ err_alloc_device_names_failed:
return ret;
}
-device_initcall(binder_init);
+static void __exit binder_exit(void)
+{
+ struct hlist_node *tmp;
+ struct binder_device *device;
+
+ debugfs_remove_recursive(binder_debugfs_dir_entry_root);
+
+ if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
+ strcmp(binder_devices_param, "") != 0) {
+ hlist_for_each_entry_safe (device, tmp, &binder_devices,hlist) {
+ misc_deregister(&device->miscdev);
+ hlist_del(&device->hlist);
+ kfree(device);
+ }
+ }
+
+ pr_info("unloaded\n");
+}
+
+module_init(binder_init);
+module_exit(binder_exit);
#define CREATE_TRACE_POINTS
#include "binder_trace.h"
diff --git a/binder_alloc.c b/binder_alloc.c
index a77ed66..1f5446c 100644
--- a/binder_alloc.c
+++ b/binder_alloc.c
@@ -38,7 +38,7 @@ enum {
};
static uint32_t binder_alloc_debug_mask = BINDER_DEBUG_USER_ERROR;
-module_param_named(debug_mask, binder_alloc_debug_mask,
+module_param_named(alloc_debug_mask, binder_alloc_debug_mask,
uint, 0644);
#define binder_alloc_debug(mask, x...) \
diff --git a/external_symbols.c b/external_symbols.c
new file mode 100644
index 0000000..4ee95e7
--- /dev/null
+++ b/external_symbols.c
@@ -0,0 +1,91 @@
+#include <linux/sched.h>
+#include <linux/file.h>
+#include <linux/fdtable.h>
+#include <linux/atomic.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/kprobes.h>
+
+static struct kprobe kp = {
+ .symbol_name = "kallsyms_lookup_name"
+};
+typedef unsigned long (*kallsyms_lookup_name_t)(const char *name);
+
+static kallsyms_lookup_name_t kallsyms_lookup_name_ptr = NULL;
+
+kallsyms_lookup_name_t static get_lookup(void) {
+ if (kallsyms_lookup_name_ptr == NULL) {
+ register_kprobe(&kp);
+ kallsyms_lookup_name_ptr = (kallsyms_lookup_name_t) kp.addr;
+ unregister_kprobe(&kp);
+ }
+ return kallsyms_lookup_name_ptr;
+}
+
+static void (*zap_page_range_ptr)(struct vm_area_struct *, unsigned long, unsigned long) = NULL;
+static int (*can_nice_ptr)(const struct task_struct *, const int) = NULL;
+static int (*security_binder_set_context_mgr_ptr)(struct task_struct *mgr) = NULL;
+static int (*security_binder_transaction_ptr)(struct task_struct *from, struct task_struct *to) = NULL;
+static int (*security_binder_transfer_binder_ptr)(struct task_struct *from, struct task_struct *to) = NULL;
+static int (*security_binder_transfer_file_ptr)(struct task_struct *from, struct task_struct *to, struct file *file) = NULL;
+static int (*task_work_add_ptr)(struct task_struct *task, struct callback_head *twork,
+ enum task_work_notify_mode mode) = NULL;
+static void (*__wake_up_pollfree_ptr)(wait_queue_head_t *wq_head) = NULL;
+
+static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res) = NULL;
+
+void zap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size)
+{
+ zap_page_range_ptr = get_lookup()("zap_page_range");
+ zap_page_range_ptr(vma, address, size);
+}
+
+int can_nice(const struct task_struct *p, const int nice)
+{
+ can_nice_ptr = get_lookup()("can_nice");
+ return can_nice_ptr(p, nice);
+}
+
+int security_binder_set_context_mgr(struct task_struct *mgr)
+{
+ security_binder_set_context_mgr_ptr = get_lookup()("security_binder_set_context_mgr");
+ return security_binder_set_context_mgr_ptr(mgr);
+}
+
+int security_binder_transaction(struct task_struct *from, struct task_struct *to)
+{
+ security_binder_transaction_ptr = get_lookup()("security_binder_transaction");
+ return security_binder_transaction_ptr(from, to);
+}
+
+int security_binder_transfer_binder(struct task_struct *from, struct task_struct *to)
+{
+ security_binder_transfer_binder_ptr = get_lookup()("security_binder_transfer_binder");
+ return security_binder_transfer_binder_ptr(from, to);
+}
+
+int security_binder_transfer_file(struct task_struct *from, struct task_struct *to, struct file *file)
+{
+ security_binder_transfer_file_ptr = get_lookup()("security_binder_transfer_file");
+ return security_binder_transfer_file_ptr(from, to, file);
+}
+
+int task_work_add(struct task_struct *task, struct callback_head *twork,
+ enum task_work_notify_mode mode)
+{
+ task_work_add_ptr = get_lookup()("task_work_add");
+ return task_work_add_ptr(task, twork, mode);
+}
+
+int close_fd_get_file(unsigned int fd, struct file **res)
+{
+ close_fd_get_file_ptr = get_lookup()("close_fd_get_file");
+ return close_fd_get_file_ptr(fd, res);
+}
+
+void __wake_up_pollfree(wait_queue_head_t *wq_head)
+{
+ __wake_up_pollfree_ptr = get_lookup()("__wake_up_pollfree");
+ return __wake_up_pollfree_ptr(wq_head);
+}
--
2.33.0

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

26
binder.BUILD.gn Normal file
View File

@ -0,0 +1,26 @@
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
config("libdbinder_config") {
include_dirs = [
" /usr/include/c_utils",
"/usr/include/ipc",
]
libs = [ "dbinder.z" ]
}
group("libdbinder") {
public_configs = [ ":libdbinder_config" ]
}

BIN
binder.pp Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

211
communication_ipc.spec Normal file
View File

@ -0,0 +1,211 @@
%define debug_package %{nil}
%global build_opt /opt/distributed-middleware-build
%global oh_version OpenHarmony-v3.2-Release
%global oe_version openEuler-22.03-LTS-SP2
%global communication_path %{_builddir}/foundation/communication
%global third_party_path %{_builddir}/third_party
%global binder_dest_path /usr/lib/modules/%(uname -r)/binder
%global ashmem_dest_path /usr/lib/modules/%(uname -r)/ashmem
Name: communication_ipc
Version: 1.0.0
Release: 1%{?dist}
Summary: Inter-process communication (IPC) and Remote Procedure Call (RPC)
License: Apache-2.0 and GPL-2.0
URL: https://gitee.com/openharmony/communication_ipc
Source1: https://gitee.com/openharmony/communication_ipc/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/communication_ipc-OpenHarmony-v3.2-Release.tar.gz
Source2: https://gitee.com/openharmony/communication_dsoftbus/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/communication_dsoftbus-OpenHarmony-v3.2-Release.tar.gz
Source3: https://gitee.com/openharmony/third_party_sqlite/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_sqlite-OpenHarmony-v3.2-Release.tar.gz
Source4: https://gitee.com/openharmony/third_party_libcoap/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_libcoap-OpenHarmony-v3.2-Release.tar.gz
Source5: https://gitee.com/openharmony/third_party_mbedtls/repository/archive/OpenHarmony-v3.2-Release.tar.gz #/third_party_mbedtls-OpenHarmony-v3.2-Release.tar.gz
Source6: https://gitee.com/openeuler/kernel/binder-%{oe_version}.tar.gz
Source7: ipc.bundle.json
Source8: ipc.BUILD.gn
Source9: ipc_core.BUILD.gn
Source10: ipc_single.BUILD.gn
Source11: binder.BUILD.gn
Source12: mbedtls.BUILD.gn
Source13: dsoftbus.bundle.json
Source14: dsoftbus.BUILD.gn
Source15: sdk.BUILD.gn
Source16: https://gitee.com/openeuler/kernel/ashmem-%{oe_version}.tar.gz
Source17: binder.pp
Patch1: 0001-remove-dependence-on-access-token-and-hitrace.patch
Patch2: 0002-fix-build-error-from-header-include.patch
Patch3: 0003-adapt-binder-as-a-kernel-module.patch
Patch4: 0004-adapt-compilation-for-softbus_client.patch
BuildRequires: gcc, make, hilog, kernel-devel, uname-build-checks
BuildRequires: commonlibrary_c_utils
BuildRequires: distributed-build, distributed-beget
BuildRequires: notification_eventhandler
BuildRequires: cjson-devel, openssl-devel
Requires: commonlibrary_c_utils
Requires: distributed-beget
Requires: notification_eventhandler
Requires: cjson-devel, openssl-devel
%description
The inter-process communication (IPC) and remote procedure call (RPC) mechanisms are used to implement cross-process communication.
# Decompress source code package, make patches to the source code.
%prep
rm -rf %{_builddir}/*
cp -rf %{build_opt} %{_builddir}/build
[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh
[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn
[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py
cp -rf %{_builddir}/build/openeuler/vendor %{_builddir}/
cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}
%setup -q -D -T -a 1 -c -n %{communication_path}
mv %{communication_path}/%{name} %{communication_path}/ipc
%patch -P1 -p1 -d %{communication_path}/ipc
%patch -P2 -p1 -d %{communication_path}/ipc
%setup -q -D -T -a 2 -c -n %{communication_path}
mv %{communication_path}/communication_dsoftbus-%{oh_version} %{communication_path}/dsoftbus
%patch -P4 -p1 -d %{communication_path}/dsoftbus
%setup -q -D -T -a 3 -c -n %{third_party_path}
mv %{third_party_path}/third_party_sqlite-%{oh_version} %{third_party_path}/sqlite
%setup -q -D -T -a 4 -c -n %{third_party_path}
mv %{third_party_path}/third_party_libcoap-%{oh_version} %{third_party_path}/libcoap
%setup -q -D -T -a 5 -c -n %{third_party_path}
mv %{third_party_path}/third_party_mbedtls-%{oh_version} %{third_party_path}/mbedtls
%setup -q -D -T -a 6 -c -n %{_builddir}
%patch -P3 -p1 -d %{_builddir}/binder
%build
%ifarch x86_64
%{_builddir}/build.sh --product-name openeuler --target-cpu x86_64
%endif
%ifarch aarch64
%{_builddir}/build.sh --product-name openeuler --target-cpu arm64
%endif
# build binder
cd %{_builddir}/binder
make %{?_smp_mflags}
cd %{_builddir}/ashmem/src
make %{?_smp_mflags}
%install
install -d -m 0755 %{buildroot}/%{_includedir}/ipc
install -d -m 0755 %{buildroot}/%{_includedir}/mbedtls
install -d -m 0755 %{buildroot}/%{_includedir}/dsoftbus
install -d -m 0755 %{buildroot}/%{_libdir}
install -d -m 0755 %{buildroot}/system/lib64
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/ipc_core
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/ipc_single
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/libdbinder
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/json
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/mbedtls/
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/sdk/
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/inner_kits
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/bus_center
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/common
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/discovery
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/transport
%ifarch aarch64
%define header_out_path out/openeuler/innerkits/linux-arm64/ipc
%define module_out_path out/openeuler/linux_clang_arm64
%define dsoftbus_header_out_path out/openeuler/innerkits/linux-arm64/dsoftbus
%endif
%ifarch x86_64
%define header_out_path out/openeuler/innerkits/linux-x86_64/ipc
%define module_out_path out/openeuler/linux_clang_x86_64
%define dsoftbus_header_out_path out/openeuler/innerkits/linux-x86_64/dsoftbus
%endif
# install libs and headers from ipc
install -m 0755 %{_builddir}/%{module_out_path}/communication/ipc/*.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{module_out_path}/communication/ipc/*.so %{buildroot}/system/lib64
find %{_builddir}/%{header_out_path} -name *.h -print0 | xargs -0 -i cp -rf {} %{buildroot}%{_includedir}/ipc/
# install libs and headers from dsoftbus
%define dsoftbus_module_path %{module_out_path}/communication/dsoftbus
rm -f %{_builddir}/%{dsoftbus_module_path}/libsoftbus_server.z.so
install -m 0755 %{_builddir}/%{dsoftbus_module_path}/*.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{dsoftbus_module_path}/*.so %{buildroot}/system/lib64
# install libs and headers from third party components
%define third_party_module_path %{module_out_path}/common/common
install -m 0755 %{_builddir}/%{third_party_module_path}/*.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{third_party_module_path}/*.so %{buildroot}/system/lib64
install -m 0755 %{_builddir}/%{module_out_path}/common/dsoftbus/*.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{module_out_path}/common/dsoftbus/*.so %{buildroot}/system/lib64
install -m 0755 %{_builddir}/third_party/mbedtls/include/mbedtls/*.h %{buildroot}/%{_includedir}/mbedtls/
install -m 0755 %{_builddir}/foundation/communication/ipc/interfaces/innerkits/libdbinder/include/rpc_system_ability_callback.h %{buildroot}/%{_includedir}/ipc/
install -m 0755 %{_builddir}/foundation/communication/dsoftbus/interfaces/kits/common/softbus_error_code.h %{buildroot}/%{_includedir}/dsoftbus/
install -m 0755 %{_builddir}/foundation/communication/dsoftbus/interfaces/inner_kits/transport/inner_session.h %{buildroot}/%{_includedir}/dsoftbus/
install -m 0755 %{communication_path}/ipc/interfaces/innerkits/libdbinder/include/* %{buildroot}/%{_includedir}/ipc/
install -m 0755 %{communication_path}/dsoftbus/sdk/transmission/session/cpp/include/* %{buildroot}/%{_includedir}/ipc/
find %{_builddir}/%{header_out_path} -name *.h -print0 | xargs -0 -i cp -rf {} %{buildroot}/%{_includedir}/ipc/
find %{_builddir}/%{dsoftbus_header_out_path} -name *.h -print0 | xargs -0 -i cp -rvf {} %{buildroot}/%{_includedir}/dsoftbus/
#copy bundle.json
install -m 0755 %{SOURCE13} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/bundle.json
#copy BUILD.gn
install -m 0755 %{SOURCE7} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/bundle.json
install -m 0755 %{SOURCE8} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/BUILD.gn
install -m 0755 %{SOURCE9} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/ipc_core/BUILD.gn
install -m 0755 %{SOURCE10} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/ipc_single/BUILD.gn
install -m 0755 %{SOURCE11} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/libdbinder/BUILD.gn
install -m 0755 %{SOURCE12} %{buildroot}/%{build_opt}/openeuler/compiler_gn/third_party/mbedtls/BUILD.gn
install -m 0755 %{SOURCE14} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/BUILD.gn
install -m 0755 %{SOURCE15} %{buildroot}/%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/sdk/BUILD.gn
# install ko file of binder
install -d %{buildroot}/%{binder_dest_path}/
install -d %{buildroot}/%{ashmem_dest_path}/
install -m 0755 %{_builddir}/binder/binder_linux.ko %{buildroot}/%{binder_dest_path}/
install -m 0755 %{_builddir}/ashmem/src/ashmem_linux.ko %{buildroot}/%{ashmem_dest_path}/
mkdir -p %{buildroot}/usr/share/pp
cp -pdf %{_builddir}/binder.pp %{buildroot}/usr/share/pp
#create soft link
ln -s /usr/mbedtls/include %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/mbedtls/include
ln -s /usr/include/ipc %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/ipc_core/include
ln -s /usr/include/ipc %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/ipc/interfaces/innerkits/libdbinder/include
ln -s /usr/include/nlohmann_json %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/json/include
ln -s /usr/include/nlohmann_json/single_include %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/json/single_include
ln -s /usr/include/dsoftbus %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/inner_kits/transport
ln -s /usr/include/dsoftbus %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/bus_center/include
ln -s /usr/include/dsoftbus %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/common/include
ln -s /usr/include/dsoftbus %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/discovery/include
ln -s /usr/include/dsoftbus %{buildroot}%{build_opt}/openeuler/compiler_gn/foundation/communication/dsoftbus/interfaces/kits/transport/include
%files
%{_libdir}/*.so
%{_includedir}/ipc/*
%{_includedir}/mbedtls/*
%{_includedir}/dsoftbus/*
/system/*
/%{binder_dest_path}/*.ko
/%{ashmem_dest_path}/*.ko
%{build_opt}/*
/usr/share/pp
%post
semodule -X 300 -i /usr/share/pp/binder.pp
%changelog
* Sun Oct 08 2023 Peng He <hepeng68@huawei.com> - 1.0.0-1
* Thu Nov 22 2023 JiaQi Zhao <zhaojiaqi18@huawei.com> - 1.0.0-1
- Init package

20
dsoftbus.BUILD.gn Normal file
View File

@ -0,0 +1,20 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//foundation/communication/dsoftbus/dsoftbus.gni")
lite_component("dsoftbus") {
features = [
"sdk:softbus_client",
]
}

86
dsoftbus.bundle.json Normal file
View File

@ -0,0 +1,86 @@
{
"name": "@openharmony/dsoftbus",
"version": "3.1.0",
"description": "dsoftbus",
"publishAs": "code-segment",
"scripts": {
"install": "DEST_PATH=${DEP_BUNDLE_BASE}/foundation/communication/dsoftbus && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
},
"author": {},
"repository": "",
"license": "Apache License 2.0",
"segment": {
"destPath": "foundation/communication/dsoftbus"
},
"component": {
"name": "dsoftbus",
"subsystem": "communication",
"adapted_system_type": [
"mini",
"small",
"standard"
],
"syscap":[ "SystemCapability.Communication.SoftBus.Core" ],
"features": [
"dsoftbus_feature_conn_p2p",
"dsoftbus_feature_disc_ble",
"dsoftbus_feature_conn_br",
"dsoftbus_feature_conn_ble",
"dsoftbus_feature_lnn_net",
"dsoftbus_feature_trans_udp_stream",
"dsoftbus_feature_trans_udp_file",
"dsoftbus_get_devicename",
"dsoftbus_feature_product_config_path",
"dsoftbus_feature_ifname_prefix",
"dsoftbus_feature_lnn_wifiservice_dependence",
"dsoftbus_standard_feature_dfinder_support_multi_nif",
"dsoftbus_feature_protocol_newip"
],
"rom": "967KB",
"ram": "28MB",
"deps": {
"components": [
"ability_base",
"ability_runtime",
"bluetooth",
"drivers_interface_wlan",
"hiviewdfx_hilog_native",
"ipc",
"os_account",
"relational_store",
"c_utils",
"wifi"
],
"third_party": [
"bounds_checking_function",
"cJSON",
"libcoap",
"thirdparty_mbedtls"
]
},
"build": {
"group_type":{
"base_group":[],
"fwk_group":[
"//foundation/communication/dsoftbus/sdk:softbus_client"
],
"service_group":[
]
},
"inner_kits": [
{
"name": "//foundation/communication/dsoftbus/sdk:softbus_client",
"header": {
"header_files": [
"bus_center/softbus_bus_center.h",
"common/softbus_common.h",
"discovery/discovery_service.h",
"transport/session.h"
],
"header_base": "//foundation/communication/dsoftbus/interfaces/kits"
}
}
]
}
}
}

29
ipc.BUILD.gn Normal file
View File

@ -0,0 +1,29 @@
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
import("//build/ohos_var.gni")
SUBSYSTEM_DIR = "//foundation/communication/ipc"
IPC_CORE_ROOT = "$SUBSYSTEM_DIR/ipc/native"
config("ipc_util_config") {
# header file path
include_dirs = [
"$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include",
"$IPC_CORE_ROOT/src/core/include",
"$IPC_CORE_ROOT/src/mock/include",
"//commonlibrary/c_utils/base/include",
]
}

103
ipc.bundle.json Normal file
View File

@ -0,0 +1,103 @@
{
"name": "@openharmony/ipc",
"version": "3.1.0",
"description": "ipc",
"publishAs": "code-segment",
"scripts": {
"install": "DEST_PATH=${DEP_BUNDLE_BASE}/foundation/communication/ipc && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
},
"author": {},
"repository": "",
"license": "Apache License 2.0",
"segment": {
"destPath": "foundation/communication/ipc"
},
"component": {
"name": "ipc",
"subsystem": "communication",
"adapted_system_type": [
"standard",
"small",
"mini"
],
"features": [
"ipc_feature_rpc_enabled"
],
"syscap":[
"SystemCapability.Communication.IPC.Core"
],
"rom": "500KB",
"ram": "100KB",
"deps": {
"components": [
"samgr",
"hitrace_native",
"hiviewdfx_hilog_native",
"c_utils",
"access_token",
"dsoftbus"
],
"third_party": [
"bounds_checking_function"
]
},
"build": {
"sub_component": [
],
"inner_kits": [
{
"name": "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
"header": {
"header_files": [
"ipc_types.h",
"ipc_skeleton.h",
"iremote_object.h",
"iremote_proxy.h",
"iremote_stub.h",
"message_parcel.h",
"message_option.h",
"iremote_broker.h",
"ipc_object_proxy.h",
"ipc_object_stub.h",
"peer_holder.h",
"ipc_file_descriptor.h",
"jni_help.h"
],
"header_base": "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include"
}
},
{
"name": "//foundation/communication/ipc/interfaces/innerkits/ipc_single:ipc_single",
"header": {
"header_files": [
"ipc_types.h",
"ipc_skeleton.h",
"iremote_object.h",
"iremote_proxy.h",
"iremote_stub.h",
"message_parcel.h",
"message_option.h",
"iremote_broker.h",
"ipc_object_proxy.h",
"ipc_object_stub.h",
"peer_holder.h",
"ipc_file_descriptor.h",
"jni_help.h"
],
"header_base": "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include"
}
},
{
"name": "//foundation/communication/ipc/interfaces/innerkits/libdbinder:libdbinder",
"header": {
"header_files": [
"dbinder_service.h",
"dbinder_service_stub.h"
],
"header_base": "//foundation/communication/ipc/interfaces/innerkits/libdbinder/include"
}
}
]
}
}
}

30
ipc_core.BUILD.gn Normal file
View File

@ -0,0 +1,30 @@
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
SUBSYSTEM_DIR = "//foundation/communication/ipc"
config("ipc_all_deps_config") {
include_dirs = [ "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include" ]
libs = [ "ipc_core.z" ]
}
group("ipc_core") {
public_configs = [
"$SUBSYSTEM_DIR:ipc_util_config",
":ipc_all_deps_config"
]
all_dependent_configs = [ ":ipc_all_deps_config" ]
}

27
ipc_single.BUILD.gn Normal file
View File

@ -0,0 +1,27 @@
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
SUBSYSTEM_DIR = "//foundation/communication/ipc"
config("libipc_single_config") {
libs = [ "ipc_single.z" ]
}
group("ipc_single") {
public_configs = [
"$SUBSYSTEM_DIR:ipc_util_config",
":libipc_single_config"
]
}

18
mbedtls.BUILD.gn Normal file
View File

@ -0,0 +1,18 @@
import("//build/ohos.gni")
config("mbedtls_config") {
include_dirs = [
"include",
]
libs = [
"mbedtls.z",
]
}
ohos_shared_library("mbedtls_shared") {
public_configs = [ ":mbedtls_config" ]
}
group("mbedtls") {
public_deps = [ ":mbedtls_shared" ]
}

36
sdk.BUILD.gn Normal file
View File

@ -0,0 +1,36 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
import("//build/ohos_var.gni")
dsoftbus_root_path = "//foundation/communication/dsoftbus"
config("dsoftbus_sdk_interface") {
include_dirs = [
"$dsoftbus_root_path/interfaces/kits",
"$dsoftbus_root_path/interfaces/kits/bus_center",
"$dsoftbus_root_path/interfaces/kits/common",
"$dsoftbus_root_path/interfaces/kits/discovery",
"$dsoftbus_root_path/interfaces/kits/transport",
"$dsoftbus_root_path/sdk/transmission/session/cpp/include",
"$dsoftbus_root_path/interfaces/inner_kits/transport",
"$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
]
libs = [ "softbus_client.z" ]
}
group("softbus_client") {
public_configs = [ ":dsoftbus_sdk_interface" ]
all_dependent_configs = [ ":dsoftbus_sdk_interface" ]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.