Commit e96b23cb authored by Florent Revest's avatar Florent Revest

usb-moded: Renew config files with fixes for adb (no more rndis while using...

usb-moded: Renew config files with fixes for adb (no more rndis while using adbd, it didn't work anyway), sdk(udhcpd.service has been renamed to udhcp-daemon.service to workaround a DBus method call timeout to StartUnit and StopUnit, thanks to this udhcpd's status stays synced between systemd and usb-moded) and mtp modes(enabling the ffs usb mode was required for buteo-mtp to be able to write in /dev/mtp/ep0 and start buteo-session.service which starts buteo-mtp.service as ceres).
parent 6ba94c90
From 7fb45319984663efd4412eb6df6dc0c3925b8844 Mon Sep 17 00:00:00 2001
From: Florent Revest <revestflo@gmail.com>
Date: Wed, 17 May 2017 12:39:51 +0200
Subject: [PATCH] [systemd] Use a default timeout of 2sec for StopUnit
On my devices, I noticed that adding udhcpd-developer-mode.ini to
/etc/usb-moded/run/ would totally prevent USB from working. It turned
out that usb-moded was trying to call StopUnit on udhcpd.service and
the blocking call would never stop. I had to introduce this timeout to
make sure usb-moded would start properly.
---
src/usb_moded-appsync.c | 6 +++---
src/usb_moded-systemd.c | 4 ++--
src/usb_moded-systemd.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/usb_moded-appsync.c b/src/usb_moded-appsync.c
index bfb10b9..9ca6550 100644
--- a/src/usb_moded-appsync.c
+++ b/src/usb_moded-appsync.c
@@ -258,7 +258,7 @@ int activate_sync(const char *mode)
log_debug("launching pre-enum-app %s\n", data->name);
if(data->systemd)
{
- if(!systemd_control_service(data->name, SYSTEMD_START))
+ if(!systemd_control_service(data->name, SYSTEMD_START, -1))
mark_active(data->name, 0);
else
goto error;
@@ -320,7 +320,7 @@ int activate_sync_post(const char *mode)
log_debug("launching post-enum-app %s\n", data->name);
if(data->systemd)
{
- if(systemd_control_service(data->name, SYSTEMD_START))
+ if(systemd_control_service(data->name, SYSTEMD_START, -1))
goto error;
mark_active(data->name, 1);
}
@@ -442,7 +442,7 @@ static void appsync_stop_apps(int post)
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{
log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name);
- if(systemd_control_service(data->name, SYSTEMD_STOP))
+ if(systemd_control_service(data->name, SYSTEMD_STOP, 2000))
log_debug("Failed to stop %s\n", data->name);
data->state = APP_STATE_DONTCARE;
}
diff --git a/src/usb_moded-systemd.c b/src/usb_moded-systemd.c
index 4a27cfb..9c1ee29 100644
--- a/src/usb_moded-systemd.c
+++ b/src/usb_moded-systemd.c
@@ -57,7 +57,7 @@ static DBusConnection * get_systemd_dbus_connection(void)
// mode = replace
// method = StartUnit or StopUnit
-int systemd_control_service(const char *name, const char *method)
+int systemd_control_service(const char *name, const char *method, int timeout)
{
DBusConnection *bus;
@@ -84,7 +84,7 @@ int systemd_control_service(const char *name, const char *method)
dbus_message_unref(msg);
goto quit;
}
- reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &error);
+ reply = dbus_connection_send_with_reply_and_block(bus, msg, timeout, &error);
if(reply)
{
dbus_message_unref(reply);
diff --git a/src/usb_moded-systemd.h b/src/usb_moded-systemd.h
index 495d3bd..3343c37 100644
--- a/src/usb_moded-systemd.h
+++ b/src/usb_moded-systemd.h
@@ -22,4 +22,4 @@
#define SYSTEMD_STOP "StopUnit"
#define SYSTEMD_START "StartUnit"
-int systemd_control_service(const char *name, const char *method);
+int systemd_control_service(const char *name, const char *method, int timeout);
--
2.11.0
[Unit]
Description=Starts the buteo-session.service as ceres
DefaultDependencies=no
After=local-fs.target
Conflicts=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/bin/buteo-mtp start
ExecStop=/usr/bin/buteo-mtp stop
[mountpoints]
mount=/dev/sdcard
[altmount]
mount=/run/user/1000/media/sdcard
[usbmode]
mode=developer_mode
[mode]
name = adb_mode
module = none
appsync = 1
[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = adb
android_extra_sysfs_path = /sys/class/android_usb/android0/f_ffs/aliases
android_extra_sysfs_value = adb
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnect_disconnect = 0
idProduct = 0A03
[mode]
name = developer_mode
module = none
network = 1
network_interface = rndis0
appsync = 1
[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = rndis
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnect_disconnect = 0
idProduct = 0A02
dhcp_server = 1
[mode]
name = mtp_mode
module = none
appsync = 1
[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = ffs,mtp
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnect_disconnect = 0
[info]
name = adbd-prepare.service
mode = adb_mode
systemd = 1
[info]
name = android-tools-adbd.service
mode = adb_mode
systemd = 1
post = 1
[info]
name = buteo-session.service
mode = mtp_mode
systemd = 1
[info]
name = udhcp-daemon.service
mode = developer_mode
systemd = 1
post = 1
...@@ -5,10 +5,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5f30f0716dfdd0d91eb439ebec522ec2" ...@@ -5,10 +5,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5f30f0716dfdd0d91eb439ebec522ec2"
SRC_URI = "git://github.com/philippedeswert/usb-moded.git;protocol=https \ SRC_URI = "git://github.com/philippedeswert/usb-moded.git;protocol=https \
file://usb-moded.service \ file://usb-moded.service \
file://usb-moded.ini \
file://com.meego.usb_moded.service \ file://com.meego.usb_moded.service \
file://udhcpd.service \ file://udhcp-daemon.service \
file://0001-systemd-Use-a-default-timeout-of-2sec-for-StopUnit.patch \ file://buteo-session.service \
file://usb-moded \
file://init_ffs" file://init_ffs"
SRCREV = "b2bcc5ba8d1bf3179c73a916f01ab4e0cf0a3526" SRCREV = "b2bcc5ba8d1bf3179c73a916f01ab4e0cf0a3526"
PR = "r1" PR = "r1"
...@@ -25,7 +25,7 @@ RDEPENDS_${PN} += "buteo-mtp" ...@@ -25,7 +25,7 @@ RDEPENDS_${PN} += "buteo-mtp"
do_configure_prepend() { do_configure_prepend() {
sed -i "s@systemd-daemon@systemd@" configure.ac sed -i "s@systemd-daemon@systemd@" configure.ac
sed -i "s@shell@ceres@g" systemd/adbd-functionfs.sh sed -i "s@shell@ceres@g" systemd/adbd-functionfs.sh
sed -i "s@ adbd.service@ android-tools-adbd.service@" ${S}/config/run-diag/qa-diagnostic.ini ${S}/config/run/adb-diag.ini ${S}/config/run/adb-startserver.ini ${S}/systemd/adbd-prepare.service sed -i "s@ adbd.service@ android-tools-adbd.service@" ${S}/systemd/adbd-prepare.service
sed -i "s@umount adb@umount /dev/usb-ffs/adb@" ${S}/systemd/adbd-prepare.service sed -i "s@umount adb@umount /dev/usb-ffs/adb@" ${S}/systemd/adbd-prepare.service
} }
...@@ -41,14 +41,10 @@ do_install_append() { ...@@ -41,14 +41,10 @@ do_install_append() {
echo "options g_file_storage stall=0 removable=1" > ${D}/etc/modprobe.d/usb_moded.conf echo "options g_file_storage stall=0 removable=1" > ${D}/etc/modprobe.d/usb_moded.conf
install -d ${D}/etc/usb-moded install -d ${D}/etc/usb-moded
install -d ${D}/etc/usb-moded/run install -d ${D}/etc/usb-moded/run
install -d ${D}/etc/usb-moded/run-diag
install -d ${D}/etc/usb-moded/dyn-modes install -d ${D}/etc/usb-moded/dyn-modes
install -d ${D}/etc/usb-moded/diag install -m 644 -D ../usb-moded/usb-moded.ini ${D}/etc/usb-moded/usb-moded.ini
install -m 644 -D config/dyn-modes/* ${D}/etc/usb-moded/dyn-modes/ install -m 644 -D ../usb-moded/run/* ${D}/etc/usb-moded/run/
install -m 644 -D config/diag/* ${D}/etc/usb-moded/diag/ install -m 644 -D ../usb-moded/dyn-modes/* ${D}/etc/usb-moded/dyn-modes/
install -m 644 -D config/run/* ${D}/etc/usb-moded/run/
install -m 644 -D config/run-diag/* ${D}/etc/usb-moded/run-diag/
install -m 644 -D config/mass-storage-jolla.ini ${D}/etc/usb-moded/
touch ${D}/etc/modprobe.d/g_ether.conf touch ${D}/etc/modprobe.d/g_ether.conf
touch ${D}/etc/udhcpd.conf touch ${D}/etc/udhcpd.conf
...@@ -56,23 +52,17 @@ do_install_append() { ...@@ -56,23 +52,17 @@ do_install_append() {
install -d ${D}/lib/systemd/system/multi-user.target.wants/ install -d ${D}/lib/systemd/system/multi-user.target.wants/
install -m 644 -D ../usb-moded.service ${D}/lib/systemd/system/usb-moded.service install -m 644 -D ../usb-moded.service ${D}/lib/systemd/system/usb-moded.service
ln -s ../usb-moded.service ${D}/lib/systemd/system/multi-user.target.wants/usb-moded.service ln -s ../usb-moded.service ${D}/lib/systemd/system/multi-user.target.wants/usb-moded.service
install -m 644 -D ../udhcpd.service ${D}/lib/systemd/system/udhcpd.service install -m 644 -D ../udhcp-daemon.service ${D}/lib/systemd/system/udhcp-daemon.service
install -m 644 -D ../buteo-session.service ${D}/lib/systemd/system/buteo-session.service
install -d ${D}/usr/share/dbus-1/services/ install -d ${D}/usr/share/dbus-1/services/
install -m 644 -D ../com.meego.usb_moded.service ${D}/usr/share/dbus-1/services/com.meego.usb_moded.service install -m 644 -D ../com.meego.usb_moded.service ${D}/usr/share/dbus-1/services/com.meego.usb_moded.service
# install -m 644 -D systemd/usb-moded-args.conf ${D}/var/lib/environment/usb-moded/usb-moded-args.conf
install -m 644 -D systemd/usb-moded.conf ${D}/etc/tmpfiles.d/usb-moded.conf install -m 644 -D systemd/usb-moded.conf ${D}/etc/tmpfiles.d/usb-moded.conf
install -m 755 -D systemd/adbd-functionfs.sh ${D}/usr/sbin/adbd-functionfs.sh install -m 755 -D systemd/adbd-functionfs.sh ${D}/usr/sbin/adbd-functionfs.sh
install -m 644 -D systemd/adbd-prepare.service ${D}/lib/systemd/system/adbd-prepare.service install -m 644 -D systemd/adbd-prepare.service ${D}/lib/systemd/system/adbd-prepare.service
install -m 644 ${WORKDIR}/usb-moded.ini ${D}/etc/usb-moded/usb-moded.ini
# Remove problematic ini files
rm ${D}/etc/usb-moded/run/udhcpd-connection-sharing.ini ${D}/etc/usb-moded/run/vfat.ini ${D}/etc/usb-moded/run/mtp.ini
rm ${D}/etc/usb-moded/dyn-modes/connection_sharing.ini ${D}/etc/usb-moded/dyn-modes/developer_mode.ini ${D}/etc/usb-moded/dyn-modes/diag_mode_old.ini ${D}/etc/usb-moded/dyn-modes/mass-storage.ini ${D}/etc/usb-moded/dyn-modes/mtp_mode.ini
install -d ${D}/usr/bin/ install -d ${D}/usr/bin/
cp ../init_ffs ${D}/usr/bin/init_ffs cp ../init_ffs ${D}/usr/bin/init_ffs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment