diff --git a/0014-open-udp-stream-switch-dsoftbus.patch b/0014-open-udp-stream-switch-dsoftbus.patch new file mode 100644 index 0000000000000000000000000000000000000000..d4af9aa4973670b1cfdebdc8b3df40d8716a224a --- /dev/null +++ b/0014-open-udp-stream-switch-dsoftbus.patch @@ -0,0 +1,60 @@ +From 1473de8149a7e3b9921f8bb0b5067fc3f6128ba7 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Mon, 4 Sep 2023 11:16:32 +0800 +Subject: [PATCH] open udp stream switch + +--- + adapter/default_config/feature_config/standard/config.gni | 2 +- + .../trans_channel/tcp_direct/src/trans_tcp_direct_manager.c | 2 +- + .../trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/adapter/default_config/feature_config/standard/config.gni b/adapter/default_config/feature_config/standard/config.gni +index 6602d7ed7..c9bb34f20 100644 +--- a/adapter/default_config/feature_config/standard/config.gni ++++ b/adapter/default_config/feature_config/standard/config.gni +@@ -23,7 +23,7 @@ declare_args() { + dsoftbus_feature_protocol_newip = false + + dsoftbus_feature_trans_udp = true +- dsoftbus_feature_trans_udp_stream = false ++ dsoftbus_feature_trans_udp_stream = true + dsoftbus_feature_trans_udp_file = true + + dsoftbus_feature_ip_auth = true +diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_manager.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_manager.c +index 9b73c13ae..5a9ba5e60 100644 +--- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_manager.c ++++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_manager.c +@@ -248,7 +248,7 @@ static int32_t TransUpdAppInfo(AppInfo *appInfo, const ConnectOption *connInfo) + + int32_t TransOpenDirectChannel(const AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId) + { +- SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "TransOpenDirectChannel"); ++ SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "TransOpenDirectChannel"); + if (appInfo == NULL || connInfo == NULL || channelId == NULL) { + return SOFTBUS_INVALID_PARAM; + } +diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c +index 868dfc503..89d0db256 100644 +--- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c ++++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c +@@ -28,7 +28,7 @@ + + int32_t OpenTcpDirectChannel(const AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId) + { +- SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OpenTcpDirectChannel"); ++ SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "OpenTcpDirectChannel"); + if (appInfo == NULL || connInfo == NULL || channelId == NULL) { + return SOFTBUS_INVALID_PARAM; + } +@@ -78,4 +78,4 @@ int32_t OpenTcpDirectChannel(const AppInfo *appInfo, const ConnectOption *connIn + *channelId = newchannelId; + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "OpenTcpDirectChannel end: channelId=%d", newchannelId); + return SOFTBUS_OK; +-} +\ No newline at end of file ++} +-- +2.33.0 + diff --git a/device_manager.xml b/device_manager.xml new file mode 100755 index 0000000000000000000000000000000000000000..e6506fcbd9b73db4fdffec739807466352f20d03 --- /dev/null +++ b/device_manager.xml @@ -0,0 +1,14 @@ + + + device_manager + + libdevicemanagerservice.z.so + + + 4802 + libdevicemanagerservice.z.so + true + false + 1 + + diff --git a/distributed-utils.spec b/distributed-utils.spec index 81073fc490aa297727e28b5b2054fd279b18fb9f..9e88b5bdc1b9b1615cd2f30e5896c84dd6afd838 100644 --- a/distributed-utils.spec +++ b/distributed-utils.spec @@ -23,7 +23,7 @@ Name: distributed-utils Version: 1.0.0 -Release: 4 +Release: 5 Summary: Distributed middleware used components. License: Apache-2.0 and MIT Url: https://gitee.com/openharmony/ @@ -44,6 +44,13 @@ Source13: https://gitee.com/openharmony/distributedhardware_device_manager/repos Source14: https://gitee.com/openharmony/third_party_json/repository/archive/openHarmony-v3.2-Release.tar.gz #/third_party_json-OpenHarmony-v3.2-Release.tar.gz Source15: https://gitee.com/openharmony/security_dataclassification/repository/archive/openHarmony-v3.2-Release.tar.gz #/security_dataclassification-OpenHarmony-v3.2-Release.tar.gz Source16: https://gitee.com/openharmony/security_device_security_level/repository/archive/openHarmony-v3.2-Release.tar.gz #/security_device_security_level-OpenHarmony-v3.2-Release.tar.gz +Source17: start_services.sh +Source18: stop_services.sh +Source19: huks_service.xml +Source20: softbus_server.xml +Source21: device_manager.xml +Source22: distributedfiledaemon.xml +Source23: distributeddata.xml Patch0: 0000-adapt-for-build-c_utils.patch Patch1: 0001-remove-dependency-and-adpat-for-build-config_policy.patch @@ -59,6 +66,7 @@ Patch10: 0010-adapt-for-build-mbedtls.patch Patch11: 0011-remove-dependency-and-adapt-for-build-device_manager.patch Patch12: 0012-remove-dependency-and-adapt-for-build-device_security_level.patch Patch13: 0013-increase-the-pthread-stack-size-of-x86-and-other-env-dsoftbus.patch +Patch14: 0014-open-udp-stream-switch-dsoftbus.patch BuildRequires: python3-jinja2 python3-pyyaml cjson cjson-devel BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel @@ -115,6 +123,7 @@ rm -rf %{_builddir}/third_party/mbedtls/* %patch11 -p1 -d %{device_manager_dir} %patch12 -p1 -d %{device_security_level_dir} %patch13 -p1 -d %{dsoftbus_dir} +%patch14 -p1 -d %{dsoftbus_dir} # build all components with build.sh %build @@ -132,6 +141,7 @@ rm -rf %{_builddir}/out %install install -d -m 0755 %{buildroot}/system/lib64 install -d -m 0755 %{buildroot}/system/bin +install -d -m 0755 %{buildroot}/system/profile install -d -m 0755 %{buildroot}/usr/lib64 install -d -m 0755 %{buildroot}/usr/bin install -d -m 0755 %{buildroot}%{_includedir}/c_utils @@ -205,14 +215,30 @@ cd %{json_dir} cp -rvf include/nlohmann %{buildroot}/%{_includedir}/nlohmann_json cp -rvf single_include/nlohmann %{buildroot}/%{_includedir}/nlohmann_json/single_include +# copy shell scripts to /system/bin +cp %{SOURCE17} %{buildroot}/system/bin/ +cp %{SOURCE18} %{buildroot}/system/bin/ + +# copy profile for sa_main to /system/profile +cp %{SOURCE19} %{buildroot}/system/profile/ +cp %{SOURCE20} %{buildroot}/system/profile/ +cp %{SOURCE21} %{buildroot}/system/profile/ +cp %{SOURCE22} %{buildroot}/system/profile/ +cp %{SOURCE23} %{buildroot}/system/profile/ + %files /system/lib64/* /system/bin/* +/system/profile/* /%{_includedir}/* /usr/lib64/* /usr/bin/* %changelog +* Fri Oct 27 2023 Peng He - 1.0.0-5 +- dsoftbus support send stream. +- add profile file and shell scripts for services start/stop. + * Wed Jul 26 2023 Ge Wang - 1.0.0-4 - add deficient component. diff --git a/distributeddata.xml b/distributeddata.xml new file mode 100755 index 0000000000000000000000000000000000000000..2077993127a235166eb8cb0984fbff6f891119a6 --- /dev/null +++ b/distributeddata.xml @@ -0,0 +1,14 @@ + + + distributeddata + + libdistributeddataservice.z.so + + + 1301 + libdistributeddataservice.z.so + true + false + 1 + + \ No newline at end of file diff --git a/distributedfiledaemon.xml b/distributedfiledaemon.xml new file mode 100755 index 0000000000000000000000000000000000000000..129746eeaeceac3eaa6d966f99b8f30b510868a9 --- /dev/null +++ b/distributedfiledaemon.xml @@ -0,0 +1,16 @@ + + + distributedfiledaemon + + libdistributedfiledaemon.z.so + + + 5201 + libdistributedfiledaemon.z.so + 4802;4700 + 60000 + true + false + 1 + + diff --git a/huks_service.xml b/huks_service.xml new file mode 100755 index 0000000000000000000000000000000000000000..d6321a77d9df778d2302e8e9c7d30329b2414f4c --- /dev/null +++ b/huks_service.xml @@ -0,0 +1,14 @@ + + + huks_service + + libhuks_service.z.so + + + 3510 + libhuks_service.z.so + true + false + 1 + + diff --git a/softbus_server.xml b/softbus_server.xml new file mode 100755 index 0000000000000000000000000000000000000000..e935f1b072bd0c5b10c61bc0a3957b619ed9cc0c --- /dev/null +++ b/softbus_server.xml @@ -0,0 +1,14 @@ + + + softbus_server + + libsoftbus_server.z.so + + + 4700 + libsoftbus_server.z.so + true + false + 1 + + diff --git a/start_services.sh b/start_services.sh new file mode 100755 index 0000000000000000000000000000000000000000..87a4cff1a83176d459fbeb07d30a69e8912087cd --- /dev/null +++ b/start_services.sh @@ -0,0 +1,178 @@ +#!/bin/bash + +# 此脚本用于拉起分布式各个服务 +# 使用方法: +# 1. 启动所有服务: ./start_services.sh all +# 2. 启动某个服务: ./start_services.sh [samgr|huks|deviceauth|softbus|dm|dfs|datamgr] + +BIN_PATH="/system/bin" + +# 定义map,保存参数和对应执行的shell命令 +# 如果需要增加服务启动,直接往此map中增加字段即可 +declare -A COMMAND_MAP=( + ["samgr"]="./samgr > /system/log/samgr.log 2>&1 &" + ["huks"]="./sa_main /system/profile/huks_service.xml > /system/log/huks_service.log 2>&1 &" + ["deviceauth"]="./deviceauth_service > /system/log/device_auth.log 2>&1 &" + ["softbus"]="./sa_main /system/profile/softbus_server.xml > /system/log/softbus_server.log 2>&1 &" + ["dm"]="./sa_main /system/profile/device_manager.xml > /system/log/device_manager.log 2>&1 &" + ["dfs"]="./sa_main /system/profile/distributedfiledaemon.xml > /system/log/distributedfiledaemon.log 2>&1 &" + ["datamgr"]="./sa_main /system/profile/distributeddata.xml > /system/log/datamgr.log 2>&1 &" +) + +# 不同服务的前驱依赖关系 +declare -A CMD_REQUIRES=( + ["samgr"]="" + ["huks"]="samgr" + ["deviceauth"]="samgr huks" + ["softbus"]="samgr huks deviceauth" + ["dm"]="samgr huks deviceauth softbus" + ["dfs"]="samgr huks deviceauth softbus dm" + ["datamgr"]="samgr huks deviceauth softbus dm" +) + +start_order=("samgr" "huks" "deviceauth" "softbus" "dm" "dfs" "datamgr") + +# 日志打印函数 +log() { + case $1 in + error) + echo "[ERROR] $2" + ;; + info) + echo "[INFO] $2" + ;; + debug) + if [ "$DEBUG_MODE" == "true" ]; then + echo "[DEBUG] $2" + fi + ;; + *) + echo "Invalid log level: $1" + ;; + esac +} + +check_process_running() { + if pgrep -x "$1" > /dev/null; then + return 0 + else + return 1 + fi +} + +start_process() { + process_name=$1 + deps="${CMD_REQUIRES[$process_name]}" + + for dep in $deps; do + if check_process_running "$dep"; then + log info "Process '$dep' is already running" + continue + fi + if [ "${COMMAND_MAP[$dep]+isset}" ]; then + log info "Starting process '$dep'..." + eval ${COMMAND_MAP[$dep]} + sleep 1 + else + log error "Invalid dependency: $dep" + exit 1 + fi + done + + if check_process_running "$process_name"; then + log info "Process '$process_name' is already running" + else + log info "Starting ddd process '$process_name'..." + if [ "${COMMAND_MAP[$process_name]+isset}" ]; then + eval ${COMMAND_MAP[$process_name]} + else + log error "Invalid process: $process_name" + exit 1 + fi + fi +} + +# 如果有进程还在,暂停服务防止双进程存在 +if pgrep -x "samgr" > /dev/null; then + log info "service is running, stop it" + /system/bin/stop_services.sh all + sleep 2 +fi + +# 软链接动态库 +if [ ! -e "/usr/lib64/libsec_shared.z.so" ]; then + log info "libsec_shared.z.so not exist, create it" + ln -s /usr/lib64/libboundscheck.so /usr/lib64/libsec_shared.z.so +fi + +# 新建日志目录 +if [ ! -d "/system/log" ]; then + log info "/system/log directory not exist, create it" + sudo mkdir -p /system/log +fi + +# 以IP地址生成SN号 +if [ ! -e "/etc/SN" ]; then + log info "SN file not exist, add content to it." + ipv4_address=$(ip -4 addr show scope global | grep inet | awk '{print $2}' | cut -d '/' -f 1) + echo "$ipv4_address" | sudo tee /etc/SN > /dev/null +fi + +# 判断参数是否为空 +if [ -z "$1" ]; then + log error "Usage: $0 [all|samgr|huks|deviceauth|softbus|device_manager|dfs|datamgr]" + exit 1 +fi + +# 检查 $LD_LIBRARY_PATH 是否包含 "/system/lib64",如果不包含则加入 +if [[ ":$LD_LIBRARY_PATH:" != *":/system/lib64:"* ]]; then + log info "/system/lib64 not in LD_LIBRARY_PATH, add it." + export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" +fi + +# 检查是否关闭selinux,如果未关闭则关闭 +selinux_status=$(getenforce) +if [ "$selinux_status" = "Enforcing" ]; then + echo "SELinux set to Permissive..." + sudo setenforce 0 +fi + +# 如果未开启binder,开启binder +if [ ! -e "/dev/binder" ]; then + log info "Starting insert binder" + # 如果当前内核已经自带了binder,则直接进行binder的挂载 + if grep -q '^CONFIG_ANDROID_BINDER_IPC=y$' /boot/config-$(uname -r); then + mkdir /dev/binderfs + sudo mount -t binder binder /dev/binderfs + sudo ln -s /dev/binderfs/binder /dev/binder + else # 内核没有开启binder,插入相关binder的ko + if [ ! -f "/lib/modules/$(uname -r)/binder/binder_linux.ko" ]; then + log error "no binder ko find, please install binder." + exit 1 + fi + insmod /lib/modules/$(uname -r)/binder/binder_linux.ko + fi +fi + +cd ${BIN_PATH} || exit +# 验证参数并执行相应命令 +if [ "$1" == "all" ]; then + log info "Starting all services..." + for key in "${start_order[@]}"; do + log info "Starting $key service..." + # 执行命令 + eval ${COMMAND_MAP[$key]} + sleep 1 + done +else + if [ "${COMMAND_MAP[$1]+isset}" ]; then + log info "Starting $1 service..." + # 执行命令 + start_process "$1" + else + log error "Invalid parameter: $1" + exit 1 + fi +fi + +log info "Done." diff --git a/stop_services.sh b/stop_services.sh new file mode 100755 index 0000000000000000000000000000000000000000..86c0a1632c4c05f9651501f1d128010f2ee1fa38 --- /dev/null +++ b/stop_services.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# 停止所有启动的分布式服务 +# 使用方法: +# 1. 暂停所有服务:./stop_services.sh all +# 2. 暂替某个服务:./stop_services.sh [samgr|huks|deviceauth|softbus|dm|dfs|datamgr] + +# 定义map,保存参数和对应执行的shell命令 +declare -A COMMAND_MAP=( + ["dfs"]="pkill -f distributedfile" + ["dm"]="pkill -f device_manager" + ["softbus"]="pkill -f softbus_server" + ["deviceauth"]="pkill -f deviceauth_service" + ["huks"]="pkill -f huks_service" + ["samgr"]="pkill -f samgr" + ["datamgr"]="pkill -f distributeddata"\ +) + +# 日志打印函数 +log() { + case $1 in + error) + echo "[ERROR] $2" + ;; + info) + echo "[INFO] $2" + ;; + debug) + if [ "$DEBUG_MODE" == "true" ]; then + echo "[DEBUG] $2" + fi + ;; + *) + echo "Invalid log level: $1" + ;; + esac +} + +# 判断参数是否为空 +if [ -z "$1" ]; then + log error "Usage: $0 [all|samgr|huks|deviceauth|softbus|dm|dfs|datamgr]" + exit 1 +fi + +# 验证参数并执行相应命令 +if [ "$1" == "all" ]; then + log info "Stop all services..." + for key in "${!COMMAND_MAP[@]}"; do + log info "Stop $key service..." + # 执行命令 + eval ${COMMAND_MAP[$key]} + done +else + if [ "${COMMAND_MAP[$1]+isset}" ]; then + log info "Stop $1 service..." + # 执行命令 + eval ${COMMAND_MAP[$1]} + else + log error "Invalid parameter: $1" + exit 1 + fi +fi + +log info "Done."