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)
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()
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <unistd.h>
#include <libsyscommon/dbus-systemd.h>
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;
}
--- /dev/null
+[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
--- /dev/null
+[Unit]
+Description=MTP dummy responder functionfs socket
+
+[Socket]
+ListenUSBFunction=/dev/usb-funcs/mtp/default
+TriggerLimitIntervalSec=0
%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