!8 将master分支内容同步至24.03分支

From: @yukaii 
Reviewed-by: @bugflyfly 
Signed-off-by: @bugflyfly
This commit is contained in:
openeuler-ci-bot 2024-04-27 08:46:29 +00:00 committed by Gitee
commit 3eb7974cfd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 492 additions and 0 deletions

View File

@ -0,0 +1,234 @@
From b7886752ac7f5a18057a8b43acc7aaf259dc7c57 Mon Sep 17 00:00:00 2001
From: heppen <hepeng68@huawei.com>
Date: Sun, 8 Oct 2023 15:27:16 +0800
Subject: [PATCH] adapt compilation for samgr
---
interfaces/innerkits/common/BUILD.gn | 4 +-
services/common/src/parse_util.cpp | 7 ++--
services/dfx/source/hisysevent_adapter.cpp | 42 ++++++++++---------
services/samgr/native/BUILD.gn | 6 +--
.../native/source/system_ability_manager.cpp | 2 +-
.../source/system_ability_manager_stub.cpp | 27 ++++++------
6 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/interfaces/innerkits/common/BUILD.gn b/interfaces/innerkits/common/BUILD.gn
index ffbf5a9..368eece 100644
--- a/interfaces/innerkits/common/BUILD.gn
+++ b/interfaces/innerkits/common/BUILD.gn
@@ -49,8 +49,8 @@ ohos_shared_library("samgr_common") {
if (is_standard_system) {
external_deps = [
"c_utils:utils",
- "hisysevent_native:libhisysevent",
- "hitrace_native:hitrace_meter",
+ # "hisysevent_native:libhisysevent",
+ # "hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
]
part_name = "samgr"
diff --git a/services/common/src/parse_util.cpp b/services/common/src/parse_util.cpp
index af7aecc..66ad8e6 100644
--- a/services/common/src/parse_util.cpp
+++ b/services/common/src/parse_util.cpp
@@ -21,10 +21,11 @@
#include <memory>
#include <sstream>
#include <vector>
+#include <algorithm>
#include "datetime_ex.h"
#include "hisysevent_adapter.h"
-#include "hitrace_meter.h"
+// #include "hitrace_meter.h"
#include "libxml/globals.h"
#include "libxml/tree.h"
#include "libxml/xmlstring.h"
@@ -105,7 +106,7 @@ void ParseUtil::OpenSo(SaProfile& saProfile)
{
if (saProfile.handle == nullptr) {
std::string dlopenTag = ToString(saProfile.saId) + "_DLOPEN";
- HITRACE_METER_NAME(HITRACE_TAG_SAMGR, dlopenTag);
+ // HITRACE_METER_NAME(HITRACE_TAG_SAMGR, dlopenTag);
int64_t begin = GetTickCount();
DlHandle handle = dlopen(Str16ToStr8(saProfile.libPath).c_str(), RTLD_NOW);
HILOGI("[PerformanceTest] SA:%{public}d OpenSo spend %{public}" PRId64 " ms",
@@ -117,7 +118,7 @@ void ParseUtil::OpenSo(SaProfile& saProfile)
if ((libPathVec.size() > 0)) {
fileName = libPathVec[libPathVec.size() - 1];
}
- ReportAddSystemAbilityFailed(saProfile.saId, fileName);
+ // ReportAddSystemAbilityFailed(saProfile.saId, fileName);
HILOGE("dlopen %{public}s failed with errno:%s!", fileName.c_str(), dlerror());
return;
}
diff --git a/services/dfx/source/hisysevent_adapter.cpp b/services/dfx/source/hisysevent_adapter.cpp
index 5e97a95..4f1cc88 100644
--- a/services/dfx/source/hisysevent_adapter.cpp
+++ b/services/dfx/source/hisysevent_adapter.cpp
@@ -16,14 +16,14 @@
#include <string>
-#include "def.h"
-#include "hisysevent.h"
+// #include "def.h"
+// #include "hisysevent.h"
#include "sam_log.h"
namespace OHOS {
using namespace OHOS::HiviewDFX;
namespace {
-const std::string DOMAIN_NAME = std::string(HiSysEvent::Domain::SAMGR);
+// const std::string DOMAIN_NAME = std::string(HiSysEvent::Domain::SAMGR);
const std::string ADD_SYSTEMABILITY_FAIL = "SAMGR_ADD_SYSTEMABILITY_FAIL";
const std::string CALLER_PID = "CALLER_PID";
const std::string SAID = "SAID";
@@ -34,26 +34,28 @@ const std::string GETSA__TAG = "SAMGR_GETSA_FREQUENCY";
void ReportAddSystemAbilityFailed(int32_t said, const std::string& filaName)
{
- int ret = HiSysEvent::Write(DOMAIN_NAME,
- ADD_SYSTEMABILITY_FAIL,
- HiSysEvent::EventType::FAULT,
- SAID, said,
- FILE_NAME, filaName);
- if (ret != 0) {
- HILOGE("hisysevent report add system ability event failed! ret %{public}d.", ret);
- }
+ HILOGE("Skip this method");
+ // int ret = HiSysEvent::Write(DOMAIN_NAME,
+ // ADD_SYSTEMABILITY_FAIL,
+ // HiSysEvent::EventType::FAULT,
+ // SAID, said,
+ // FILE_NAME, filaName);
+ // if (ret != 0) {
+ // HILOGE("hisysevent report add system ability event failed! ret %{public}d.", ret);
+ // }
}
void ReportGetSAFrequency(uint32_t callerPid, uint32_t said, int32_t count)
{
- int ret = HiSysEvent::Write(DOMAIN_NAME,
- GETSA__TAG,
- HiSysEvent::EventType::STATISTIC,
- CALLER_PID, callerPid,
- SAID, said,
- COUNT, count);
- if (ret != 0) {
- HILOGE("hisysevent report get sa frequency failed! ret %{public}d.", ret);
- }
+ HILOGE("Skip this method");
+ // int ret = HiSysEvent::Write(DOMAIN_NAME,
+ // GETSA__TAG,
+ // HiSysEvent::EventType::STATISTIC,
+ // CALLER_PID, callerPid,
+ // SAID, said,
+ // COUNT, count);
+ // if (ret != 0) {
+ // HILOGE("hisysevent report get sa frequency failed! ret %{public}d.", ret);
+ // }
}
} // OHOS
diff --git a/services/samgr/native/BUILD.gn b/services/samgr/native/BUILD.gn
index 8ec85e5..2e99473 100644
--- a/services/samgr/native/BUILD.gn
+++ b/services/samgr/native/BUILD.gn
@@ -59,11 +59,11 @@ ohos_executable("samgr") {
if (is_standard_system) {
external_deps = [
- "access_token:libaccesstoken_sdk",
+ # "access_token:libaccesstoken_sdk",
"c_utils:utils",
"eventhandler:libeventhandler",
- "hisysevent_native:libhisysevent",
- "hitrace_native:hitrace_meter",
+ # "hisysevent_native:libhisysevent",
+ # "hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
"init:libbeget_proxy",
"init:libbegetutil",
diff --git a/services/samgr/native/source/system_ability_manager.cpp b/services/samgr/native/source/system_ability_manager.cpp
index e43c103..95c894e 100644
--- a/services/samgr/native/source/system_ability_manager.cpp
+++ b/services/samgr/native/source/system_ability_manager.cpp
@@ -23,7 +23,7 @@
#include "directory_ex.h"
#include "errors.h"
#include "hisysevent_adapter.h"
-#include "hitrace_meter.h"
+// #include "hitrace_meter.h"
#include "if_local_ability_manager.h"
#include "ipc_skeleton.h"
#include "local_ability_manager_proxy.h"
diff --git a/services/samgr/native/source/system_ability_manager_stub.cpp b/services/samgr/native/source/system_ability_manager_stub.cpp
index 5b168dc..89fe52d 100644
--- a/services/samgr/native/source/system_ability_manager_stub.cpp
+++ b/services/samgr/native/source/system_ability_manager_stub.cpp
@@ -18,10 +18,10 @@
#include <unistd.h>
#include <cinttypes>
-#include "accesstoken_kit.h"
+// #include "accesstoken_kit.h"
#include "datetime_ex.h"
#include "errors.h"
-#include "hitrace_meter.h"
+// #include "hitrace_meter.h"
#include "ipc_skeleton.h"
#include "ipc_types.h"
#include "sam_log.h"
@@ -97,7 +97,7 @@ namespace {
}
}
-using namespace OHOS::Security;
+// using namespace OHOS::Security;
namespace OHOS {
SystemAbilityManagerStub::SystemAbilityManagerStub()
{
@@ -489,10 +489,10 @@ int32_t SystemAbilityManagerStub::RemoveSystemAbilityInner(MessageParcel& data,
int32_t SystemAbilityManagerStub::AddSystemProcessInner(MessageParcel& data, MessageParcel& reply)
{
- if (!CanRequest()) {
- HILOGE("AddSystemProcessInner PERMISSION DENIED!");
- return ERR_PERMISSION_DENIED;
- }
+ // if (!CanRequest()) {
+ // HILOGE("AddSystemProcessInner PERMISSION DENIED!");
+ // return ERR_PERMISSION_DENIED;
+ // }
std::u16string procName = data.ReadString16();
if (procName.empty()) {
HILOGW("SystemAbilityManagerStub::AddSystemProcessInner read process name failed!");
@@ -518,7 +518,7 @@ int32_t SystemAbilityManagerStub::LoadSystemAbilityInner(MessageParcel& data, Me
{
int32_t systemAbilityId = data.ReadInt32();
std::string loadSystemAbilityTag = ToString(systemAbilityId) + "_LoadSystemAbility";
- HITRACE_METER_NAME(HITRACE_TAG_SAMGR, loadSystemAbilityTag);
+ // HITRACE_METER_NAME(HITRACE_TAG_SAMGR, loadSystemAbilityTag);
if (!CheckInputSysAbilityId(systemAbilityId)) {
HILOGW("SystemAbilityManagerStub::LoadSystemAbilityInner read systemAbilityId failed!");
return ERR_INVALID_VALUE;
@@ -589,10 +589,11 @@ int32_t SystemAbilityManagerStub::LoadRemoteSystemAbilityInner(MessageParcel& da
bool SystemAbilityManagerStub::CanRequest()
{
- auto accessTokenId = IPCSkeleton::GetCallingTokenID();
- AccessToken::ATokenTypeEnum tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessTokenId);
- HILOGD("SystemAbilityManagerStub::CanRequest tokenId:%{private}u, tokenType:%{public}d",
- accessTokenId, tokenType);
- return (tokenType == AccessToken::ATokenTypeEnum::TOKEN_NATIVE);
+ return true;
+ // auto accessTokenId = IPCSkeleton::GetCallingTokenID();
+ // AccessToken::ATokenTypeEnum tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(accessTokenId);
+ // HILOGD("SystemAbilityManagerStub::CanRequest tokenId:%{private}u, tokenType:%{public}d",
+ // accessTokenId, tokenType);
+ // return (tokenType == AccessToken::ATokenTypeEnum::TOKEN_NATIVE);
}
} // namespace OHOS
--
2.33.0

75
bundle.json Normal file
View File

@ -0,0 +1,75 @@
{
"name": "@ohos/systemabilitymgr_samgr",
"description": "system ability manager",
"homePage": "https://gitee.com/openharmony",
"version": "3.1",
"license": "Apache License 2.0",
"repository": "https://gitee.com/openharmony/systemabilitymgr_samgr",
"publishAs": "code-segment",
"segment": {
"destPath": "foundation/systemabilitymgr/samgr"
},
"dirs": {},
"scripts": {},
"component": {
"name": "samgr",
"subsystem": "systemabilitymgr",
"features": [ "samgr_feature_coverage = false" ],
"adapted_system_type": [
"standard"
],
"rom": "300KB",
"ram": "7130KB",
"deps": {
"components": [
"access_token",
"c_utils",
"eventhandler",
"hisysevent_native",
"hitrace_native",
"hiviewdfx_hilog_native",
"init",
"ipc",
"samgr",
"selinux",
"startup_l2"
],
"third_party": [ "libxml2" ]
},
"build": {
"group_type": {
"base_group": [],
"fwk_group": []
},
"inner_kits": [
{
"header": {
"header_base": "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/",
"header_files": [
"if_system_ability_manager.h",
"iservice_registry.h",
"isystem_ability_load_callback.h",
"isystem_ability_status_change.h",
"system_ability_definition.h",
"system_ability_manager_proxy.h",
"system_ability_load_callback_stub.h",
"system_ability_status_change_stub.h",
"sam_log.h"
]
},
"name": "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy"
},
{
"header": {
"header_base": "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common/include/",
"header_files": [
"sa_profiles.h",
"parse_util.h"
]
},
"name": "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common:samgr_common"
}
]
}
}
}

116
samgr.spec Normal file
View File

@ -0,0 +1,116 @@
%define debug_package %{nil}
%global openHarmony_source_release OpenHarmony-v3.2-Release
%global samgr_dir %{_builddir}/foundation/systemabilitymgr
%global build_opt /opt/distributed-middleware-build
%global samgr_path /openeuler/compiler_gn/foundation/systemabilitymgr/samgr
Name: systemabilitymgr_samgr
Version: 1.0.0
Release: 2
Summary: System ability manager
License: Apache License 2.0
Url: https://gitee.com/openharmony/systemabilitymgr_samgr
Source1: https://gitee.com/openharmony/systemabilitymgr_samgr/repository/archive/%{openHarmony_source_release}.tar.gz #/systemabilitymgr_samgr-%{openHarmony_source_release}.tar.gz
Source2: bundle.json
Source3: samgr_common.gn
Source4: samgr_proxy.gn
Patch1: 0001-adapt-compilation-for-samgr.patch
BuildRequires: gcc, make, hilog, kernel-devel, libboundscheck
BuildRequires: libatomic,libicu-devel, libxml2-devel, cjson-devel
BuildRequires: distributed-build, distributed-beget
BuildRequires: commonlibrary_c_utils
BuildRequires: notification_eventhandler
BuildRequires: communication_ipc
Requires: commonlibrary_c_utils
Requires: distributed-beget
Requires: notification_eventhandler
Requires: communication_ipc
%description
OpenEuler supports samgr for distributed softbus capability
%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不用autosetupdistributed-build除外
mkdir -p %{samgr_dir}
%setup -q -D -T -a 1 -c -n %{samgr_dir}
mv systemabilitymgr_samgr-%{openHarmony_source_release} %{samgr_dir}/samgr
# patch命令统一使用-P来指定第几个patch
%patch -P1 -p1 -d %{samgr_dir}/samgr
%build
rm -rf %{_builddir}/out
%ifarch x86_64
bash %{_builddir}/build.sh --product-name openeuler --target-cpu x86_64
%endif
%ifarch aarch64
bash %{_builddir}/build.sh --product-name openeuler --target-cpu arm64
%endif
%install
install -d -m 0755 %{buildroot}/%{_includedir}/samgr
install -d -m 0755 %{buildroot}/%{_libdir}
install -d -m 0755 %{buildroot}/usr/bin/
install -d -m 0755 %{buildroot}/system/bin/
install -d -m 0755 %{buildroot}/system/lib64/
install -d -m 0755 %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/common/
install -d -m 0755 %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/samgr_proxy/
install -d -m 0755 %{buildroot}/%{build_opt}%{samgr_path}/services/lsamgr/
%ifarch aarch64
%define module_out_path out/openeuler/linux_clang_arm64
%endif
%ifarch x86_64
%define module_out_path out/openeuler/linux_clang_x86_64
%endif
# copy executable file.
install -m 755 %{_builddir}/out/openeuler/packages/phone/system/bin/samgr %{buildroot}/system/bin/
install -m 755 %{_builddir}/out/openeuler/packages/phone/system/bin/samgr %{buildroot}/usr/bin/
# prepare so
install -m 0755 %{_builddir}/%{module_out_path}/systemabilitymgr/samgr/libsamgr*.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{module_out_path}/systemabilitymgr/samgr/libsamgr*.so %{buildroot}/system/lib64/
# prepare head files
# TODO: 头文件范围和bundle.json声明的不一致
install -m 554 %{samgr_dir}/samgr/services/lsamgr/include/*.h %{buildroot}/%{_includedir}/samgr
install -m 554 %{samgr_dir}/samgr/interfaces/innerkits/common/include/*.h %{buildroot}/%{_includedir}/samgr
install -m 554 %{samgr_dir}/samgr/interfaces/innerkits/samgr_proxy/include/*.h %{buildroot}/%{_includedir}/samgr
# install bundle.json and BUILD.gn which is used by other components.
install -m 554 %{SOURCE2} %{buildroot}/%{build_opt}%{samgr_path}/bundle.json
install -m 554 %{SOURCE3} %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/common/BUILD.gn
install -m 554 %{SOURCE4} %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/samgr_proxy/BUILD.gn
# gernerate soft link to samgr header path
ln -s /usr/include/samgr %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/samgr_proxy/include
ln -s /usr/include/samgr %{buildroot}/%{build_opt}%{samgr_path}/interfaces/innerkits/common/include
ln -s /usr/include/samgr %{buildroot}/%{build_opt}%{samgr_path}/services/lsamgr/include
%files
%{_includedir}/samgr/*
%{_libdir}/*.so
/system/*
/usr/bin/*
%{build_opt}%{samgr_path}
%changelog
* Mon Apr 1 2024 s_c_c <shichuchao@huawei.com> - 1.0.0-2
- Fix samgr include_dirs for embedded
* Wed Jun 28 2023 tianhang <tian_hang@hoperun.com> - 1.0.0-1
- Init and adapt to openeuler

37
samgr_common.gn Normal file
View File

@ -0,0 +1,37 @@
# Copyright (c) 2022 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/config/sysroot.gni")
config("all_config_samgr_common") {
include_dirs = [
"${sysroot}/usr/include/samgr",
]
libs = ["samgr_common.z",]
}
config("config_samgr_common") {
include_dirs = [
"${sysroot}/usr/include/samgr",
]
libs = ["samgr_common.z",]
}
group("samgr_common") {
public_configs = [ ":config_samgr_common" ]
all_dependent_configs = [ ":all_config_samgr_common" ]
}

30
samgr_proxy.gn Normal file
View File

@ -0,0 +1,30 @@
# Copyright (c) 2021-2022 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")
import("//build/config/sysroot.gni")
config("samgr_proxy_config") {
include_dirs = [
"${sysroot}/usr/include/samgr",
"${sysroot}/usr/include/libxml2",
]
libs = ["samgr_proxy.z",]
}
group("samgr_proxy"){
public_configs = [ ":samgr_proxy_config" ]
all_dependent_configs = [ ":samgr_proxy_config" ]
}

Binary file not shown.