From: INSUN PYO Date: Tue, 18 Feb 2020 04:41:52 +0000 (+0900) Subject: Use mtp-responder-dummy.socket when there is no mtp-responser.socket X-Git-Tag: submit/tizen_5.5/20200218.230832^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b54461f39296454dd32075e8ed84983199ce8d88;p=platform%2Fcore%2Fsystem%2Flibdevice-node.git Use mtp-responder-dummy.socket when there is no mtp-responser.socket The mtp-responder.socket is special in the configfs environment. If mtp-responder.socket is missing, gadget configuration will fail. As a result, all usb operations do not work properly. So in environments that mtp doesn't support, use dummy mtp. Applied target : XU3, Artik headless, RPI4 Change-Id: I34bee7c1837ada478959407cd7c6500e219f28bc (cherry picked from commit 0202291b7c1b3be3db32bba3001d51d7efe6a362) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 452fae7..4646bb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,12 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hw/ DESTINATION include/hw CONFIGURE_FILE(hwcommon.pc.in hwcommon.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hwcommon.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +# dummy mtp responder +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/strs DESTINATION /etc/mtp-responder-dummy) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/descs DESTINATION /etc/mtp-responder-dummy) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/mtp-responder-dummy.socket DESTINATION /usr/lib/systemd/system) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mtp-responder-dummy/mtp-responder-dummy.service DESTINATION /usr/lib/systemd/system) + IF(BUILD_GTESTS STREQUAL on) ADD_SUBDIRECTORY(unittest) ENDIF() diff --git a/hw/usb_gadget_common.c b/hw/usb_gadget_common.c index 2ecef99..fb6a986 100644 --- a/hw/usb_gadget_common.c +++ b/hw/usb_gadget_common.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -522,6 +523,17 @@ int simple_translator_open(struct hw_info *info, simple_translator->id_to_gadget = simple_id_to_gadget; simple_translator->cleanup_gadget = simple_cleanup_gadget; + /* Use mtp-responder-dummy.socket when there is no mtp-responser.socket. + * + * The mtp-responder.socket is special in the configfs environment. + * If mtp-responder.socket is missing, gadget configuration will fail. + * As a result, all usb operations do not work properly. + * So in environments that mtp doesn't support, use dummy mtp. + */ + if (access("/usr/lib/systemd/system/mtp-responder.socket", F_OK)) { + _available_funcs[USB_FUNCTION_IDX_MTP]->ffs_service = "mtp-responder-dummy"; + } + *common = &simple_translator->common; return 0; } diff --git a/mtp-responder-dummy/descs b/mtp-responder-dummy/descs new file mode 100644 index 0000000..0bffd51 Binary files /dev/null and b/mtp-responder-dummy/descs differ diff --git a/mtp-responder-dummy/mtp-responder-dummy.service b/mtp-responder-dummy/mtp-responder-dummy.service new file mode 100644 index 0000000..04e7258 --- /dev/null +++ b/mtp-responder-dummy/mtp-responder-dummy.service @@ -0,0 +1,12 @@ +[Unit] +Description=MTP dummy responder +StartLimitIntervalSec=0 + +[Service] +User=network_fw +Group=network_fw +RemainAfterExit=yes +ExecStart=/usr/bin/true +SmackProcessLabel=System +USBFunctionDescriptors=/etc/mtp-responder-dummy/descs +USBFunctionStrings=/etc/mtp-responder-dummy/strs diff --git a/mtp-responder-dummy/mtp-responder-dummy.socket b/mtp-responder-dummy/mtp-responder-dummy.socket new file mode 100644 index 0000000..3f84ab7 --- /dev/null +++ b/mtp-responder-dummy/mtp-responder-dummy.socket @@ -0,0 +1,6 @@ +[Unit] +Description=MTP dummy responder functionfs socket + +[Socket] +ListenUSBFunction=/dev/usb-funcs/mtp/default +TriggerLimitIntervalSec=0 diff --git a/mtp-responder-dummy/strs b/mtp-responder-dummy/strs new file mode 100644 index 0000000..b0bd4ab Binary files /dev/null and b/mtp-responder-dummy/strs differ diff --git a/packaging/libdevice-node.spec b/packaging/libdevice-node.spec index 2f9b9f0..809904f 100644 --- a/packaging/libdevice-node.spec +++ b/packaging/libdevice-node.spec @@ -54,6 +54,10 @@ make %{?jobs:-j%jobs} %manifest %{name}.manifest %license LICENSE.Apache-2.0 %{_libdir}/*.so.* +%{_unitdir}/mtp-responder-dummy.socket +%{_unitdir}/mtp-responder-dummy.service +/etc/mtp-responder-dummy/strs +/etc/mtp-responder-dummy/descs %files devel %manifest %{name}.manifest