Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[diag] update diag mode to newer android standard. Fixes: JB#31988
Diag mode has become a bit more complicated, so adding support
for the new interfaces.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Oct 5, 2015
1 parent 33aea13 commit 035e3d4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/dyn-modes/diag_mode.ini
Expand Up @@ -7,7 +7,7 @@ network_interface = rndis0

[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = rndis,adb,diag,serial
sysfs_value = diag,serial,rmnet,qdss,adb,rndis
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
Expand All @@ -16,4 +16,8 @@ android_extra_sysfs_path = /sys/class/android_usb/android0/f_diag/clients
android_extra_sysfs_value = diag
android_extra_sysfs_path2 = /sys/class/android_usb/android0/f_serial/transports
android_extra_sysfs_value2 = smd
android_extra_sysfs_path3 = /sys/class/android_usb/android0/f_rmnet/transports
android_extra_sysfs_value3 = qti,bam
android_extra_sysfs_path4 = /sys/class/android_usb/android0/f_qdss/transports
android_extra_sysfs_value4 = qti,bam_dmux
idProduct = 0A04
19 changes: 19 additions & 0 deletions config/dyn-modes/diag_mode_old.ini
@@ -0,0 +1,19 @@
[mode]
name = diag_mode
module = none
appsync = 1
network = 1
network_interface = rndis0

[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = rndis,adb,diag,serial
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnect_disconnect = 0
android_extra_sysfs_path = /sys/class/android_usb/android0/f_diag/clients
android_extra_sysfs_value = diag
android_extra_sysfs_path2 = /sys/class/android_usb/android0/f_serial/transports
android_extra_sysfs_value2 = smd
idProduct = 0A04
1 change: 1 addition & 0 deletions config/run/adb-diag.ini
Expand Up @@ -2,3 +2,4 @@
name = adbd.service
mode = diag_mode
systemd = 1
post = 1
4 changes: 4 additions & 0 deletions config/run/diag-adb-prepare.ini
@@ -0,0 +1,4 @@
[info]
name = adbd-prepare.service
mode = diag_mode
systemd = 1
20 changes: 20 additions & 0 deletions rpm/usb-moded.spec
Expand Up @@ -117,6 +117,20 @@ system bus.
This package contains the diag config for use with the android
gadget driver.

%package diag-mode-androidv5+qcom
Summary: USB mode controller - android v5 or newer diag mode config for qcom
Group: Config

%description diag-mode-androidv5+qcom
Usb_moded is a daemon to control the USB states. For this
it loads unloads the relevant usb gadget modules, keeps track
of the filesystem(s) and notifies about changes on the DBUS
system bus.

This package contains the diag config for use with the android
gadget driver.


%package acm-mode-android
Summary: USB mode controller - android acm mode config
Group: Config
Expand Down Expand Up @@ -384,8 +398,14 @@ systemctl daemon-reload || :

%files diag-mode-android
%defattr(-,root,root,-)
%{_sysconfdir}/usb-moded/dyn-modes/diag_mode_old.ini
%{_sysconfdir}/usb-moded/run/adb-diag.ini

%files diag-mode-androidv5+qcom
%defattr(-,root,root,-)
%{_sysconfdir}/usb-moded/dyn-modes/diag_mode.ini
%{_sysconfdir}/usb-moded/run/adb-diag.ini
%{_sysconfdir}/usb-moded/run/diag-adb-prepare.ini

%files acm-mode-android
%defattr(-,root,root,-)
Expand Down
8 changes: 8 additions & 0 deletions src/usb_moded-dyn-config.c
Expand Up @@ -50,6 +50,10 @@ void list_item_free(mode_list_elem *list_item)
free(list_item->android_extra_sysfs_value);
free(list_item->android_extra_sysfs_path2);
free(list_item->android_extra_sysfs_value2);
free(list_item->android_extra_sysfs_path3);
free(list_item->android_extra_sysfs_value3);
free(list_item->android_extra_sysfs_path4);
free(list_item->android_extra_sysfs_value4);
free(list_item->idProduct);
#ifdef CONNMAN
free(list_item->connman_tethering);
Expand Down Expand Up @@ -142,9 +146,13 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->softconnect_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_PATH, NULL);
list_item->android_extra_sysfs_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH, NULL);
list_item->android_extra_sysfs_path2 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH2, NULL);
list_item->android_extra_sysfs_path3 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH3, NULL);
list_item->android_extra_sysfs_path4 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH4, NULL);
//log_debug("Android extra mode sysfs path2 = %s\n", list_item->android_extra_sysfs_path2);
list_item->android_extra_sysfs_value = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE, NULL);
list_item->android_extra_sysfs_value2 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE2, NULL);
list_item->android_extra_sysfs_value3 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE3, NULL);
list_item->android_extra_sysfs_value4 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE4, NULL);
//log_debug("Android extra value2 = %s\n", list_item->android_extra_sysfs_value2);
list_item->idProduct = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_IDPRODUCT, NULL);
list_item->nat = g_key_file_get_integer(settingsfile, MODE_OPTIONS_ENTRY, MODE_HAS_NAT, NULL);
Expand Down
8 changes: 8 additions & 0 deletions src/usb_moded-dyn-config.h
Expand Up @@ -47,6 +47,10 @@ android engineers prefered to have sysfs entries... go figure... */
/* in combined android gadgets we sometime need more than one extra sysfs path or value */
#define MODE_ANDROID_EXTRA_SYSFS_PATH2 "android_extra_sysfs_path2"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE2 "android_extra_sysfs_value2"
#define MODE_ANDROID_EXTRA_SYSFS_PATH3 "android_extra_sysfs_path3"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE3 "android_extra_sysfs_value3"
#define MODE_ANDROID_EXTRA_SYSFS_PATH4 "android_extra_sysfs_path4"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE4 "android_extra_sysfs_value4"
/* For windows different modes/usb profiles need their own idProduct */
#define MODE_IDPRODUCT "idProduct"
#define MODE_HAS_NAT "nat"
Expand Down Expand Up @@ -77,6 +81,10 @@ typedef struct mode_list_elem
char *android_extra_sysfs_value; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path2; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value2; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path3; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value3; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path4; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value4; /* static value that never changes that needs to be set by sysfs :( */
char *idProduct; /* product id to assign to a specific profile */
int nat; /* If NAT should be set up in this mode or not */
int dhcp_server; /* if a DHCP server needs to be configured and started or not */
Expand Down

0 comments on commit 035e3d4

Please sign in to comment.