From 8a7cccd7801f3bc707a8bd9872a86ae2b656e224 Mon Sep 17 00:00:00 2001 From: handyohos Date: Wed, 16 Feb 2022 22:04:37 +0800 Subject: [PATCH] bugfix: fix compiling error for qemu-arm-linux-min system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1)isSystemAppCalling接口导致过多外部依赖,最小系统先隔离该调用;后续需通过access_token的API来访问。 2)devicemanagerservice过多外部依赖,最小系统暂不编译。 3)其它napi模块在最小系统中通过support_jsapi进行隔离。 Signed-off-by: handyohos Change-Id: Ib96a3fb3468104a8873ade4698da140a373c7ced --- bundle.json | 7 +++--- ext/BUILD.gn | 24 +++++++++++++++++++ interfaces/inner_kits/native_cpp/BUILD.gn | 16 ++++++++----- .../native_cpp/src/device_manager_impl.cpp | 9 +++++++ .../src/notify/device_manager_notify.cpp | 1 - interfaces/kits/BUILD.gn | 21 ++++++++++++++++ interfaces/kits/js/BUILD.gn | 4 ---- services/devicemanagerservice/BUILD.gn | 4 ++++ test/BUILD.gn | 5 +++- 9 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 ext/BUILD.gn create mode 100644 interfaces/kits/BUILD.gn diff --git a/bundle.json b/bundle.json index 4f20bcf82..7ba25a8a4 100644 --- a/bundle.json +++ b/bundle.json @@ -45,11 +45,10 @@ "sub_component": [ "//foundation/distributedhardware/devicemanager/utils:devicemanagerutils", "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager_native_js", + "//foundation/distributedhardware/devicemanager/interfaces/kits:devicemanager_native_js", "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "//foundation/distributedhardware/devicemanager/sa_profile:dm_sa_profile", - "//foundation/distributedhardware/devicemanager/ext/pin_auth:devicemanagerext_pin_auth", - "//foundation/distributedhardware/devicemanager/ext/profile:devicemanagerext_profile" + "//foundation/distributedhardware/devicemanager/ext:ext_modules" ], "inner_kits": [ { @@ -71,4 +70,4 @@ ] } } -} \ No newline at end of file +} diff --git a/ext/BUILD.gn b/ext/BUILD.gn new file mode 100644 index 000000000..df1b58535 --- /dev/null +++ b/ext/BUILD.gn @@ -0,0 +1,24 @@ +# 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") + +group("ext_modules") { + deps = [] + if (support_jsapi) { + deps += [ + "./pin_auth:devicemanagerext_pin_auth", + "./profile:devicemanagerext_profile", + ] + } +} diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 68c8c569c..99011143a 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -54,20 +54,24 @@ if (defined(ohos_lite)) { "LOG_DOMAIN=0xD004100", ] - deps = [ - "${utils_path}:devicemanagerutils", - "//foundation/aafwk/standard/interfaces/innerkits/want:want", - ] + deps = [ "${utils_path}:devicemanagerutils" ] external_deps = [ - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", "utils_base:utils", ] + if (support_jsapi) { + deps += [ "//foundation/aafwk/standard/interfaces/innerkits/want:want" ] + external_deps += [ + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + ] + defines += [ "SUPPORT_CALLING_ABILITY" ] + } + subsystem_name = "distributedhardware" part_name = "device_manager_base" diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 900305b1e..811a6d7f4 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -15,10 +15,12 @@ #include "device_manager_impl.h" +#ifdef SUPPORT_CALLING_ABILITY #include "bundle_constants.h" #include "bundle_info.h" #include "bundle_mgr_client.h" #include "bundle_mgr_interface.h" +#endif #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -43,13 +45,16 @@ #include "ipc_verify_authenticate_req.h" #include "securec.h" +#ifdef SUPPORT_CALLING_ABILITY using namespace OHOS::AppExecFwk; using namespace OHOS::AppExecFwk::Constants; +#endif namespace OHOS { namespace DistributedHardware { bool DeviceManagerImpl::isSystemAppCalling(void) { +#ifdef SUPPORT_CALLING_ABILITY int32_t uid = IPCSkeleton::GetCallingUid(); if (uid < 0) { LOGI("app caller uid is: %d,", uid); @@ -76,6 +81,10 @@ bool DeviceManagerImpl::isSystemAppCalling(void) } return iBundleMgr->CheckIsSystemAppByUid(uid); +#else + // Minimum system only native services will call + return true; +#endif } DeviceManagerImpl &DeviceManagerImpl::GetInstance() diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index f1c36875e..987ca17c5 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -18,7 +18,6 @@ #include "device_manager.h" #include "dm_constants.h" #include "dm_log.h" -#include "nlohmann/json.hpp" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/kits/BUILD.gn b/interfaces/kits/BUILD.gn new file mode 100644 index 000000000..725c517af --- /dev/null +++ b/interfaces/kits/BUILD.gn @@ -0,0 +1,21 @@ +# 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") + +group("devicemanager_native_js") { + deps = [] + if (support_jsapi) { + deps += [ "./js:devicemanager" ] + } +} diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 5704e27a4..c1b70a129 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -61,7 +61,3 @@ ohos_shared_library("devicemanager") { relative_install_dir = "module/distributedhardware" part_name = "device_manager_base" } - -group("devicemanager_native_js") { - deps = [ ":devicemanager" ] -} diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 5c0c2ae96..c41e20600 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -23,6 +23,10 @@ if (defined(ohos_lite)) { executable("devicemanagerservice") { sources = [ "src/ipc/lite/ipc_server_main.cpp" ] } +} else if (!support_jsapi) { + group("devicemanagerservice") { + deps = [] + } } else { config("devicemanagerservice_config") { include_dirs = [ diff --git a/test/BUILD.gn b/test/BUILD.gn index d29faeb19..e9d4fadb9 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -14,5 +14,8 @@ group("test") { testonly = true - deps = [ "unittest:unittest" ] + deps = [] + if (support_jsapi) { + deps += [ "unittest:unittest" ] + } } -- Gitee