diff --git a/adapter/BUILD.gn b/adapter/BUILD.gn index 47922a7c0ac39253c9ca6380a391788461e1508a..56677c9dcb6efbbb12559c1c4ce832d0a4d8aca8 100644 --- a/adapter/BUILD.gn +++ b/adapter/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -32,7 +32,7 @@ if (defined(ohos_lite)) { } else { group("uhdf_entry") { hdf_framework_path = "./../framework" - hdf_peripheral_path = "./../../peripheral" + hdf_peripheral_path = "./uhdf2/host/peripheral" deps = [ "$hdf_adapter_path/uhdf2/hdi:libhdi", "$hdf_adapter_path/uhdf2/host:hdf_devhost", @@ -47,7 +47,7 @@ if (defined(ohos_lite)) { "$hdf_adapter_path/uhdf2/pub_utils:libpub_utils", "$hdf_adapter_path/uhdf2/utils:libhdf_utils", "$hdf_framework_path/tools/hdf_dbg:hdf_dbg", - "$hdf_peripheral_path/base:hdf_peripheral.cfg", + "$hdf_peripheral_path:hdf_peripheral.cfg", ] } group("uhdf_test_entry") { diff --git a/adapter/uhdf2/hdi.gni b/adapter/uhdf2/hdi.gni index 5977158375e3455d5525f4481a8b8655649fcd30..ab1906ce3c9d673b78e1816715ec85865ec5b37a 100644 --- a/adapter/uhdf2/hdi.gni +++ b/adapter/uhdf2/hdi.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -102,16 +102,7 @@ template("hdi") { idl_headers_config = "$target_name" + "_idl_headers_config" config("$idl_headers_config") { - include_dirs = [ - "$hdf_uhdf_path/include/hdi", - "$hdf_uhdf_path/osal/include", - "$hdf_uhdf_path/ipc/include", - "$hdf_framework_path/include/utils", - "//drivers/hdf_core/interfaces/inner_api/utils", - "//drivers/hdf_core/interfaces/inner_api/osal/uhdf", - "//drivers/hdf_core/interfaces/inner_api/hdi", - ] - include_dirs += hdi_build_info.include_dirs + include_dirs = hdi_build_info.include_dirs } action("hdi_gen") { @@ -164,6 +155,7 @@ template("hdi") { external_deps = [ "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", @@ -180,6 +172,11 @@ template("hdi") { external_deps = [ "hilog:libhilog" ] } + public_external_deps = [ + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdf_utils", + ] + if (defined(invoker.innerapi_tags)) { innerapi_tags = invoker.innerapi_tags } @@ -234,6 +231,7 @@ template("hdi") { external_deps = [ "c_utils:utils", + "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdi", "hilog:libhilog", ] @@ -252,6 +250,11 @@ template("hdi") { external_deps = [ "hilog:libhilog" ] } + public_external_deps = [ + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdf_utils", + ] + shlib_type = "hdi_stub" install_images = [ chipset_base_dir ] subsystem_name = invoker.subsystem_name @@ -290,6 +293,10 @@ template("hdi") { group("$target_name" + "_idl_headers") { public_configs = [ ":$idl_headers_config" ] deps = [ ":hdi_gen" ] + public_external_deps = [ + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdf_utils", + ] } # only generate code and provide header file path @@ -299,5 +306,9 @@ template("hdi") { public_configs = [ ":$idl_headers_config" ] deps = [ ":hdi_gen" ] public_deps = hdi_build_info.header_deps + public_external_deps = [ + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdf_utils", + ] } } diff --git a/adapter/uhdf2/host/peripheral/BUILD.gn b/adapter/uhdf2/host/peripheral/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..69cdd389b69e7cec8c5e3161ee6f19ec79ea8a15 --- /dev/null +++ b/adapter/uhdf2/host/peripheral/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021-2024 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") + +ohos_prebuilt_etc("hdf_peripheral.cfg") { + source = "hdf_peripheral.cfg" + relative_install_dir = "init" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "hdf_core" +} diff --git a/adapter/uhdf2/host/peripheral/hdf_peripheral.cfg b/adapter/uhdf2/host/peripheral/hdf_peripheral.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a49c066d23690eae25e6c74d9b8e2febdda725e6 --- /dev/null +++ b/adapter/uhdf2/host/peripheral/hdf_peripheral.cfg @@ -0,0 +1,74 @@ +{ + "jobs" : [{ + "name" : "pre-init", + "cmds" : [ + "chown input_user_host input_user_host /dev/hdf_input_host", + "chown input_user_host input_user_host /dev/hdf_input_event1", + "chown input_user_host input_user_host /dev/hdf_input_event2", + "chown input_user_host input_user_host /dev/hdf_input_event3", + "chown input_user_host input_user_host /dev/hdf_input_event4", + "chown input_user_host input_user_host /dev/hdf_input_event5", + "chown input_user_host input_user_host /dev/hdf_input_event6", + "chown hdf_devmgr uhdf_driver /dev/dev_mgr", + "chown hdf_devmgr uhdf_driver /dev/hdf_kevent", + "chown audio_host audio_host /dev/hdf_audio_render", + "chown audio_host audio_host /dev/hdf_audio_capture", + "chown audio_host audio_host /dev/hdf_audio_control", + "chown sensor_host sensor_host /dev/hdf_sensor_manager_ap", + "chown sensor_host sensor_host /dev/sensorhub", + "chown sensor_host sensor_host /sys/class/sensors/libsensor_ver", + "chown sensor_host sensor_host /dev/ar", + "chown sensor_host sensor_host /dev/motionhub", + "chown vibrator_host vibrator_host /dev/hdf_misc_vibrator", + "chown vibrator_host vibrator_host /dev/haptics", + "chown light_host light_host /dev/hdf_light", + "chown light_host light_host /sys/class/leds/blue/brightness", + "chown light_host light_host /sys/class/leds/blue/delay_on", + "chown light_host light_host /sys/class/leds/blue/delay_off", + "chown light_host light_host /sys/class/leds/red/brightness", + "chown light_host light_host /sys/class/leds/red/delay_on", + "chown light_host light_host /sys/class/leds/red/delay_off", + "chown light_host light_host /sys/class/leds/green/brightness", + "chown light_host light_host /sys/class/leds/green/delay_on", + "chown light_host light_host /sys/class/leds/green/delay_off", + "chown vendor_mpp_driver vendor_mpp_driver /dev/mpp_service", + "chown system vendor_mpp_driver /dev/rga", + "chown camera_host camera_host /dev/video0", + "chown camera_host camera_host /dev/video1", + "chown camera_host camera_host /dev/video2", + "chown camera_host camera_host /dev/video3", + "chown camera_host camera_host /dev/video4", + "chown camera_host camera_host /dev/video5", + "chown camera_host camera_host /dev/video6", + "chown camera_host camera_host /dev/video7", + "chown camera_host camera_host /dev/video8", + "chown wifi wifi_group /dev/hdfwifi" + ] + }, { + "name" : "post-fs-data", + "cmds" : [ + "chown system system /dev/hdf_disp", + "chown system system /dev/hdf_dsoftbus", + "chown composer_host composer_host /sys/class/backlight/backlight/brightness", + "mkdir /data/service/el0/battery 0751 power_host power_host", + "mkdir /data/service/el0/display 0711 power_host power_host", + "mkdir /data/service/el0/thermal 0755 thermal thermal", + "mkdir /data/service/el0/thermal/sensor 0755 power_host power_host", + "mkdir /data/service/el0/thermal/cooling 0755 power_host power_host", + "mkdir /data/service/el1/public/pinauth/ 0700 pin_auth_host pin_auth_host", + "mkdir /data/service/el1/public/userauth/ 0700 user_auth_host user_auth_host", + "chown power_host system /sys/power/wake_lock", + "chown power_host system /sys/power/wake_unlock", + "mkdir /data/service/el1/public/usb 0770 usb_host usb_host", + "write /data/service/el1/public/usb/mode device" + ] + }, { + "name" : "param:vendor.hifi.watchdog.come=true", + "condition" : "vendor.hifi.watchdog.come=true", + "cmds" : [ + "reset audio_host", + "setparam vendor.hifi.watchdog.come false" + ] + } + ] +} diff --git a/bundle.json b/bundle.json index 8c9c7494f81ecaff8abbf190ed6e17d771e4344f..23e5c54e37e2426aaaf74167edb3e851af2ffb9c 100644 --- a/bundle.json +++ b/bundle.json @@ -58,6 +58,7 @@ "ipc/hdf_dump_reg.h", "ipc/hdf_remote_service.h", "ipc/hdf_sbuf_ipc.h", + "ipc/iproxy_broker.h", "core/hdf_object.h" ], "header_base": "//drivers/hdf_core/interfaces/inner_api" @@ -156,4 +157,4 @@ ] } } -} \ No newline at end of file +} diff --git a/interfaces/inner_api/ipc/iproxy_broker.h b/interfaces/inner_api/ipc/iproxy_broker.h new file mode 100644 index 0000000000000000000000000000000000000000..d723669a6d1f1a0a98efb58f57077350ba6193e5 --- /dev/null +++ b/interfaces/inner_api/ipc/iproxy_broker.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022-2024 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 HDI_PROXY_BROKER_H +#define HDI_PROXY_BROKER_H + +#include +#include +#include + +namespace OHOS { +namespace HDI { +template +class IProxyBroker : public OHOS::PeerHolder, public OHOS::IRemoteBroker, public INTERFACE { +public: + explicit IProxyBroker(const sptr &object); + virtual ~IProxyBroker() = default; + virtual sptr AsInterface(); + sptr AsObject() override; +}; + +template +IProxyBroker::IProxyBroker(const sptr &object) : PeerHolder(object) +{ +} + +template +sptr IProxyBroker::AsInterface() +{ + return this; +} + +template +sptr IProxyBroker::AsObject() +{ + return Remote(); +} + +template +inline sptr hdi_facecast(const sptr &object) +{ + const std::u16string descriptor = INTERFACE::GetDescriptor(); + BrokerRegistration ®istration = BrokerRegistration::Get(); + sptr broker = registration.NewInstance(descriptor, object); + INTERFACE *proxyBroker = static_cast *>(broker.GetRefPtr()); + return static_cast(proxyBroker); +} + +template +inline sptr hdi_objcast(const sptr &iface) +{ + IProxyBroker *brokerObject = static_cast *>(iface.GetRefPtr()); + return brokerObject->AsObject(); +} +} // namespace HDI +} // namespace OHOS + +#endif // HDI_PROXY_BROKER_H