From 9b8ecba042eaa4a194f5f742db9d7e99d19683e2 Mon Sep 17 00:00:00 2001 From: guowen666 Date: Tue, 31 Oct 2023 22:33:08 +0800 Subject: [PATCH] Add Disc Extend Frame Signed-off-by: guowen666 --- core/bus_center/bus_center_server.gni | 13 +++++++ .../extend/include/bus_center_ex_obj.h | 30 ++++++++++++++++ .../extend/include/bus_center_ex_obj_proxy.h | 34 +++++++++++++++++++ .../extend/include/bus_center_ex_obj_stub.h | 29 ++++++++++++++++ .../extend/include/if_bus_center_ex_obj.h | 28 +++++++++++++++ .../extend/src/bus_center_ex_obj_proxy.cpp | 23 +++++++++++++ .../extend/src/bus_center_ex_obj_stub.cpp | 24 +++++++++++++ .../softbus_server_ipc_interface_code.h | 1 + .../standard/init/include/if_softbus_server.h | 1 + .../standard/init/include/softbus_server.h | 1 + .../init/include/softbus_server_stub.h | 1 + .../standard/init/src/if_softbus_server.cpp | 6 ++++ .../standard/init/src/softbus_server.cpp | 12 +++++++ .../standard/init/src/softbus_server_stub.cpp | 18 ++++++++++ sdk/BUILD.gn | 5 +++ sdk/bus_center/bus_center_sdk.gni | 12 +++++++ .../bus_center_server_proxy_standard.h | 1 + .../src/bus_center_server_proxy_standard.cpp | 29 ++++++++++++++++ sdk/libsoftbus_client_map | 2 ++ 19 files changed, 270 insertions(+) create mode 100644 core/bus_center/extend/include/bus_center_ex_obj.h create mode 100644 core/bus_center/extend/include/bus_center_ex_obj_proxy.h create mode 100644 core/bus_center/extend/include/bus_center_ex_obj_stub.h create mode 100644 core/bus_center/extend/include/if_bus_center_ex_obj.h create mode 100644 core/bus_center/extend/src/bus_center_ex_obj_proxy.cpp create mode 100644 core/bus_center/extend/src/bus_center_ex_obj_stub.cpp diff --git a/core/bus_center/bus_center_server.gni b/core/bus_center/bus_center_server.gni index 85ba030f89..a0942785e3 100644 --- a/core/bus_center/bus_center_server.gni +++ b/core/bus_center/bus_center_server.gni @@ -95,6 +95,19 @@ if (defined(ohos_lite)) { "$dsoftbus_root_path/sdk/frame/$os_type/include", "//utils/system/safwk/native/include", ] + + if (dsoftbus_feature_ex_kits) { + import( + "$dsoftbus_root_path/dsoftbus_enhance/core/bus_center/extend/bus_center_ex.gni") + + bus_center_server_inc += bus_center_ex_inc + bus_center_server_src += bus_center_ex_src + } else { + bus_center_server_inc += + [ "$dsoftbus_root_path/core/bus_center/extend/include" ] + bus_center_server_src += [ "$dsoftbus_root_path/core/bus_center/extend/src/bus_center_ex_obj_stub.cpp" ] + } + bus_center_server_external_deps += bus_center_adapter_external_deps + bus_center_ledger_external_deps + bus_center_core_adapter_external_deps + adapter_wifi_external_deps + diff --git a/core/bus_center/extend/include/bus_center_ex_obj.h b/core/bus_center/extend/include/bus_center_ex_obj.h new file mode 100644 index 0000000000..496439ded5 --- /dev/null +++ b/core/bus_center/extend/include/bus_center_ex_obj.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef BUS_CENTER_EX_OBJ_H +#define BUS_CENTER_EX_OBJ_H + +#include "bus_center_ex_obj_stub.h" + +namespace OHOS { +class BusCenterExObj : public BusCenterExObjStub { +public: + BusCenterExObj() = default; + + ~BusCenterExObj() override = default; +}; +} // namespace OHOS + +#endif // BUS_CENTER_EX_OBJ_H \ No newline at end of file diff --git a/core/bus_center/extend/include/bus_center_ex_obj_proxy.h b/core/bus_center/extend/include/bus_center_ex_obj_proxy.h new file mode 100644 index 0000000000..3d96361fd0 --- /dev/null +++ b/core/bus_center/extend/include/bus_center_ex_obj_proxy.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef BUS_CENTER_EX_OBJ_PROXY_H +#define BUS_CENTER_EX_OBJ_PROXY_H + +#include "if_bus_center_ex_obj.h" +#include "iremote_proxy.h" + +namespace OHOS { +class BusCenterExObjProxy : public IRemoteProxy { +public: + explicit BusCenterExObjProxy(const sptr &impl); + + ~BusCenterExObjProxy() = default; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace OHOS + +#endif // BUS_CENTER_EX_OBJ_PROXY_H \ No newline at end of file diff --git a/core/bus_center/extend/include/bus_center_ex_obj_stub.h b/core/bus_center/extend/include/bus_center_ex_obj_stub.h new file mode 100644 index 0000000000..6a93f23f02 --- /dev/null +++ b/core/bus_center/extend/include/bus_center_ex_obj_stub.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef BUS_CENTER_EX_OBJ_STUB_H +#define BUS_CENTER_EX_OBJ_STUB_H + +#include "if_bus_center_ex_obj.h" +#include "iremote_stub.h" + +namespace OHOS { +class BusCenterExObjStub : public IRemoteStub { +public: + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; +}; +} // namespace OHOS + +#endif // BUS_CENTER_EX_OBJ_STUB_H \ No newline at end of file diff --git a/core/bus_center/extend/include/if_bus_center_ex_obj.h b/core/bus_center/extend/include/if_bus_center_ex_obj.h new file mode 100644 index 0000000000..c5e8b35ae7 --- /dev/null +++ b/core/bus_center/extend/include/if_bus_center_ex_obj.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef IF_BUS_CENTER_EX_OBJ_H +#define IF_BUS_CENTER_EX_OBJ_H + +#include "iremote_broker.h" + +namespace OHOS { +class IBusCenterExObj : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IBusCenter.Ex.virtual"); +}; +} // namespace OHOS + +#endif // IF_BUS_CENTER_EX_OBJ_H \ No newline at end of file diff --git a/core/bus_center/extend/src/bus_center_ex_obj_proxy.cpp b/core/bus_center/extend/src/bus_center_ex_obj_proxy.cpp new file mode 100644 index 0000000000..a47de5c357 --- /dev/null +++ b/core/bus_center/extend/src/bus_center_ex_obj_proxy.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "bus_center_ex_obj_proxy.h" + +namespace OHOS { +BusCenterExObjProxy::BusCenterExObjProxy(const sptr &impl) + :IRemoteProxy(impl) +{ +} +} // namespace OHOS \ No newline at end of file diff --git a/core/bus_center/extend/src/bus_center_ex_obj_stub.cpp b/core/bus_center/extend/src/bus_center_ex_obj_stub.cpp new file mode 100644 index 0000000000..9bb61d470d --- /dev/null +++ b/core/bus_center/extend/src/bus_center_ex_obj_stub.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "bus_center_ex_obj_stub.h" + +namespace OHOS { +int32_t BusCenterExObjStub::OnRemoteRequest(uint32_t code, + MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +} +} // namespace OHOS \ No newline at end of file diff --git a/core/common/include/softbus_server_ipc_interface_code.h b/core/common/include/softbus_server_ipc_interface_code.h index e4b35124e3..2c8b9050d2 100644 --- a/core/common/include/softbus_server_ipc_interface_code.h +++ b/core/common/include/softbus_server_ipc_interface_code.h @@ -78,6 +78,7 @@ enum SoftBusFuncId { SERVER_GET_ALL_META_NODE_INFO, SERVER_SHIFT_LNN_GEAR, SERVER_RIPPLE_STATS, + SERVER_GET_BUS_CENTER_EX_OBJ, CLIENT_ON_CHANNEL_OPENED = 256, CLIENT_ON_CHANNEL_OPENFAILED, diff --git a/core/frame/standard/init/include/if_softbus_server.h b/core/frame/standard/init/include/if_softbus_server.h index a71f733b44..9a0e7bcb6a 100644 --- a/core/frame/standard/init/include/if_softbus_server.h +++ b/core/frame/standard/init/include/if_softbus_server.h @@ -70,6 +70,7 @@ public: virtual int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode); virtual int32_t GetSoftbusSpecObject(sptr &object); + virtual int32_t GetBusCenterExObj(sptr &object); public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISoftBusServer"); diff --git a/core/frame/standard/init/include/softbus_server.h b/core/frame/standard/init/include/softbus_server.h index 07406dd553..0cb9aa6e10 100644 --- a/core/frame/standard/init/include/softbus_server.h +++ b/core/frame/standard/init/include/softbus_server.h @@ -69,6 +69,7 @@ public: int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode) override; int Dump(int fd, const std::vector &args) override; + int32_t GetBusCenterExObj(sptr &object) override; protected: void OnStart() override; diff --git a/core/frame/standard/init/include/softbus_server_stub.h b/core/frame/standard/init/include/softbus_server_stub.h index f733190593..0fad138ef7 100644 --- a/core/frame/standard/init/include/softbus_server_stub.h +++ b/core/frame/standard/init/include/softbus_server_stub.h @@ -71,6 +71,7 @@ private: int32_t GetAllMetaNodeInfoInner(MessageParcel &data, MessageParcel &reply); int32_t ShiftLNNGearInner(MessageParcel &data, MessageParcel &reply); int32_t GetSoftbusSpecObjectInner(MessageParcel &data, MessageParcel &reply); + int32_t GetBusCenterExObjInner(MessageParcel &data, MessageParcel &reply); void InitMemberFuncMap(); void InitMemberPermissionMap(); diff --git a/core/frame/standard/init/src/if_softbus_server.cpp b/core/frame/standard/init/src/if_softbus_server.cpp index 94c0d0808c..27e767f6c8 100644 --- a/core/frame/standard/init/src/if_softbus_server.cpp +++ b/core/frame/standard/init/src/if_softbus_server.cpp @@ -106,4 +106,10 @@ int32_t ISoftBusServer::GetSoftbusSpecObject(sptr &object) SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "GetSoftbusSpecObject ipc default impl"); return SOFTBUS_ERR; } + +int32_t ISoftBusServer::GetBusCenterExObj(sptr &object) +{ + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "GetBusCenterExObj ipc default impl"); + return SOFTBUS_ERR; +} } // namespace OHOS \ No newline at end of file diff --git a/core/frame/standard/init/src/softbus_server.cpp b/core/frame/standard/init/src/softbus_server.cpp index 5bbb666626..c07a384207 100644 --- a/core/frame/standard/init/src/softbus_server.cpp +++ b/core/frame/standard/init/src/softbus_server.cpp @@ -15,6 +15,7 @@ #include "softbus_server.h" +#include "bus_center_ex_obj.h" #include "ipc_skeleton.h" #include "ipc_types.h" #include "lnn_bus_center_ipc.h" @@ -341,4 +342,15 @@ int32_t SoftBusServer::GetSoftbusSpecObject(sptr &object) object = result; return SOFTBUS_OK; } + +int32_t SoftBusServer::GetBusCenterExObj(sptr &object) +{ + sptr result = new(std::nothrow) BusCenterExObj(); + if (result == nullptr) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftBusServer GetBusCenterExObj failed!"); + return SOFTBUS_MEM_ERR; + } + object = result; + return SOFTBUS_OK; +} } // namespace OHOS diff --git a/core/frame/standard/init/src/softbus_server_stub.cpp b/core/frame/standard/init/src/softbus_server_stub.cpp index 001c318bca..7cb81618fc 100644 --- a/core/frame/standard/init/src/softbus_server_stub.cpp +++ b/core/frame/standard/init/src/softbus_server_stub.cpp @@ -157,6 +157,7 @@ void SoftBusServerStub::InitMemberFuncMap() memberFuncMap_[SERVER_SHIFT_LNN_GEAR] = &SoftBusServerStub::ShiftLNNGearInner; memberFuncMap_[SERVER_RIPPLE_STATS] = &SoftBusServerStub::RippleStatsInner; memberFuncMap_[SERVER_GET_SOFTBUS_SPEC_OBJECT] = &SoftBusServerStub::GetSoftbusSpecObjectInner; + memberFuncMap_[SERVER_GET_BUS_CENTER_EX_OBJ] = &SoftBusServerStub::GetBusCenterExObjInner; } void SoftBusServerStub::InitMemberPermissionMap() @@ -1375,4 +1376,21 @@ int32_t SoftBusServerStub::GetSoftbusSpecObjectInner(MessageParcel &data, Messag } return SOFTBUS_OK; } + +int32_t SoftBusServerStub::GetBusCenterExObjInner(MessageParcel &data, MessageParcel &reply) +{ + sptr object; + int32_t ret = GetBusCenterExObj(object); + if (!reply.WriteInt32(ret)) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "GetBusCenterExObjInner write reply failed!"); + return SOFTBUS_ERR; + } + if (ret == SOFTBUS_OK) { + if (!reply.WriteRemoteObject(object)) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "GetBusCenterExObjInner write object failed!"); + return SOFTBUS_ERR; + } + } + return SOFTBUS_OK; +} } // namespace OHOS diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index e48630c01c..fc7736bd6e 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -69,6 +69,11 @@ config("dsoftbus_sdk_interface") { include_dirs += [ "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/broadcast" ] } + + if (dsoftbus_feature_ex_kits) { + include_dirs += + [ "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/bus_center" ] + } } target(build_type, "softbus_client") { diff --git a/sdk/bus_center/bus_center_sdk.gni b/sdk/bus_center/bus_center_sdk.gni index c9bd27e1b8..e976be4083 100644 --- a/sdk/bus_center/bus_center_sdk.gni +++ b/sdk/bus_center/bus_center_sdk.gni @@ -66,6 +66,18 @@ if (defined(ohos_lite)) { "$dsoftbus_root_path/sdk/bus_center/ipc/$os_type/src/bus_center_server_proxy_standard.cpp", "$dsoftbus_root_path/sdk/bus_center/manager/src/client_bus_center_manager.c", ] + + if (dsoftbus_feature_ex_kits) { + import( + "$dsoftbus_root_path/dsoftbus_enhance/sdk/bus_center/extend/bus_center_ex_sdk.gni") + + bus_center_manager_sdk_inc += bus_center_ex_sdk_inc + bus_center_manager_sdk_src += bus_center_ex_sdk_src + } else { + bus_center_manager_sdk_inc += + [ "$dsoftbus_root_path/core/bus_center/extend/include" ] + bus_center_manager_sdk_src += [ "$dsoftbus_root_path/core/bus_center/extend/src/bus_center_ex_obj_proxy.cpp" ] + } } bus_center_sdk_src = bus_center_service_sdk_src + bus_center_manager_sdk_src diff --git a/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h b/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h index c40c27bf3c..1cbf2522bd 100644 --- a/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h +++ b/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h @@ -65,6 +65,7 @@ public: int32_t GetAllMetaNodeInfo(MetaNodeInfo *infos, int32_t *infoNum) override; int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode) override; + int32_t GetBusCenterExObj(sptr &object) override; private: static inline BrokerDelegator delegator_; diff --git a/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp b/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp index 4d755e26e1..f561d4d3d5 100644 --- a/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp +++ b/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp @@ -921,4 +921,33 @@ int32_t BusCenterServerProxy::ShiftLNNGear(const char *pkgName, const char *call } return serverRet; } + +int32_t BusCenterServerProxy::GetBusCenterExObj(sptr &object) +{ + sptr remote = GetSystemAbility(); + if (remote == nullptr) { + LLOGE("remote is null"); + return SOFTBUS_ERR; + } + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + LLOGE("GetBusCenterExObj write InterfaceToken failed!"); + return SOFTBUS_ERR; + } + MessageParcel reply; + MessageOption option; + int32_t ret = remote->SendRequest(SERVER_GET_BUS_CENTER_EX_OBJ, data, reply, option); + if (ret != ERR_NONE) { + LLOGE("GetBusCenterExObj send request failed, ret=%d", ret); + return SOFTBUS_ERR; + } + if (!reply.ReadInt32(ret)) { + LLOGE("GetBusCenterExObj send ret failed"); + return SOFTBUS_ERR; + } + if (ret == SOFTBUS_OK) { + object = reply.ReadRemoteObject(); + } + return ret; +} } // namespace OHOS \ No newline at end of file diff --git a/sdk/libsoftbus_client_map b/sdk/libsoftbus_client_map index 36a33f4ed1..fb0dab4053 100644 --- a/sdk/libsoftbus_client_map +++ b/sdk/libsoftbus_client_map @@ -355,6 +355,8 @@ "ClientDeleteEventListener"; "TransProxyPackAndSendData"; "ClientTransProxyGetInfoByChannelId"; + "EnableDiscoveryPolicy"; + "SetDiscoveryPolicy"; extern "C++" { OHOS::StreamAdaptor*; Communication::SoftBus*; -- Gitee