luftreich / android-wired-tether

Automatically exported from code.google.com/p/android-wired-tether
11 stars 3 forks source link

HTC Evo 4G workaround: Two commands, can they be added to the program? #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using the latest version of android-wired-tether on my Evo 4G.  I finally 
have it all working, and my question is why can't these commands be included as 
part of the program?  

To get my phone prepped to tether, I installed GScript Lite so that I can 
create a button to enter these commands. You need root so you can run these 
commands as SU.  You don't need to worry about USB Debugging settings at all, 
this works either way.  This is the script you need to run before starting 
Wired Tether:

echo 4 > /sys/devices/platform/msm_hsusb/usb_function_switch

That script turns will turn on the fourth switch in usb_function_switch and 
disable the other.  The switches will look like this:

usb_mass_storage:disable
adb:disable
diag:disable
serial:disable
ether:enable
modem:disable
nmea:disable

You want to verify the switches settings, you can create a new script with this 
command in it:
cat /sys/devices/platform/msm_hsusb/usb_function_switch

This command to turn on ethernet won't start tethering immediately all by 
itself. It only will allow Wired Tether to do its job.  You can open it up, 
press "Press to start tethering" and it will enable tethering, show PC 
information in the notification bar, and monitor the data transferred.  It will 
even turn off tethering when you press stop.  When you turn it off it creates 
another problem: usb_mass_storage and adb stay disabled.  That means even if 
you hit Disk Drive in the notification bar, your SD card won't mount over USB.  

To fix usb_mass_storage, you can enter this command:

echo 1 > /sys/devices/platform/msm_hsusb/usb_function_switch

That will get your switches back to this:
usb_mass_storage:enable
adb:disable
diag:disable
serial:disable
ether:disable
modem:disable
nmea:disable

I thought I could also turn ADB (USB Debugging) back on by sending "echo 2" to 
toggle the second switch.  When I do that, adb is enabled, but usb_mass_storage 
is disabled.  The workaround is to go into Settings > Applications > 
Development and then uncheck and recheck USB Debugging.  

Voila, USB Tethering with a beautiful interface that works on the HTC Evo 4G.  

Lastly, if this is old news I'm sorry.  I've seen other people mention 
disabling usb_mass_storage and adb before, but I never saw any mention of how 
to do so.  I'm new to Android, so it was a mystery for me.  I figured it out 
based on a common USB tethering command (/system/bin/netsharing net on && echo 
4 > /sys/devices/platform/msm_hsusb/usb_function_switch). I figure there must 
be other people out there who also don't know these commands, so this post is 
for them.

Original issue reported on code.google.com by mai...@gmail.com on 27 Jun 2010 at 9:22

GoogleCodeExporter commented 9 years ago
I figured it out, finally. There are thirty individual echo presets for 
different combinations of switches. It repeats after that. 

The correct command to bring back mass storage and adb is

echo 3 > /sys/devices/platform/msm_hsusb/usb_function_switch

Original comment by mai...@gmail.com on 28 Jun 2010 at 12:52

GoogleCodeExporter commented 9 years ago
And I have one more addition.  The code to allow Wired Tether to work can just 
be: 
echo 0 > /sys/devices/platform/msm_hsusb/usb_function_switch

You don't need to turn on the ether switch for Wired Tether to work, you only 
need to turn of adb and usb_mass_storage.  Echo 0 just disables all switches. 

Original comment by mai...@gmail.com on 28 Jun 2010 at 4:32

GoogleCodeExporter commented 9 years ago
I already posted on the other issue, but I wanted to say thanks again.  Took 
the echo 0 into account, that makes your fix even better.  I sure wish there 
was an option built into the app to do this automatically for you.  Something 
like "HTC Compatibility" toggle... that would be great.

Original comment by cool...@gmail.com on 28 Jun 2010 at 4:38

GoogleCodeExporter commented 9 years ago
I've compiled a version using this very method you described above.

It sets adb mode once you stop tethering (because that's what I use) and should 
rather restore the last state, but apart from that it does what it's supposed 
to do: work on HTC phones (without HTC framework).

Attachment to the first post here: 
http://forum.xda-developers.com/showthread.php?t=706602

Original comment by alex.c.h...@gmail.com on 28 Jun 2010 at 7:39

GoogleCodeExporter commented 9 years ago
With "It sets adb mode" I meant adb and UMS, not adb alone.

Original comment by alex.c.h...@gmail.com on 28 Jun 2010 at 7:51

GoogleCodeExporter commented 9 years ago
Alex, it works like a charm on my Evo.  Thanks for sharing.

Original comment by john.laf...@gmail.com on 28 Jun 2010 at 8:05

GoogleCodeExporter commented 9 years ago
Thank you alex!  This is fantastic!  If you can, would you share the source and 
point out your changes?  I'm completely new to programming for android and am 
kind of curious to learn how you got these changes in.

Original comment by mai...@gmail.com on 28 Jun 2010 at 10:11

GoogleCodeExporter commented 9 years ago
It's working here too... I am a little curious of the changes as well, but I 
downloaded the source earlier into eclipse and it's probably over my head 
without spending a lot more time looking into it.

Original comment by cool...@gmail.com on 29 Jun 2010 at 12:58

GoogleCodeExporter commented 9 years ago
Took me about ten seconds to add that patch. It as easy as reading and 
understanding code that was not written by yourself.

TetherApplication.java:

in
'public int startTether() {}'
add
'this.coretask.runRootCommand("echo 0 > 
/sys/devices/platform/msm_hsusb/usb_function_switch")'
before "// Starting service"

and in
'public boolean stopTether() {}'
add
'this.coretask.runRootCommand("echo 3 > 
/sys/devices/platform/msm_hsusb/usb_function_switch")'
after "tether stop".

Of course you should do error checking as well, but that's basically 
everything. No need to share any source for that :-).

Original comment by alex.c.h...@gmail.com on 2 Jul 2010 at 9:08

GoogleCodeExporter commented 9 years ago
thanks alex. donated for this =D

Original comment by usctru...@gmail.com on 10 Jul 2010 at 9:10

GoogleCodeExporter commented 9 years ago
Thank you! Glad I could help.

Original comment by alex.c.h...@gmail.com on 10 Jul 2010 at 9:15

GoogleCodeExporter commented 9 years ago
I wonder if anyone will actually integrate them into the project?  It hasn't 
been updated in a while, I wonder if it's dead

Original comment by cool...@gmail.com on 10 Jul 2010 at 11:53

GoogleCodeExporter commented 9 years ago
It's not easy to integrate these small patches because they only apply to a few 
HTC devices.

I could rewrite them to be suitable for integration into the project. Let's see 
what the project owner has to say.

Original comment by alex.c.h...@gmail.com on 11 Jul 2010 at 12:53

GoogleCodeExporter commented 9 years ago
Are we sure that your fix breaks compatibility with other phones?

Original comment by mai...@gmail.com on 11 Jul 2010 at 4:52

GoogleCodeExporter commented 9 years ago
This appears to be an issue with the Droid Eris and the Sprint Hero as well. 
All three affected phones are CDMA with Sense UI.

Original comment by var...@gmail.com on 13 Jul 2010 at 6:00

GoogleCodeExporter commented 9 years ago
Additionally, there _is_ a need to share source of any changes if you are 
distributing them, being that this project is GPL-licensed. If the original 
project creators had done the same thing, you wouldn't have been able to patch 
and fix this app.

Just food for thought. Good work, either way.

Original comment by var...@gmail.com on 13 Jul 2010 at 6:04

GoogleCodeExporter commented 9 years ago
@vardyr:
I've been a Linux user and contributor for several years now. I know the GPL.

No, I'm not going to fork the repository just to publish a patch that changes 
exactly two lines. I did point out the changes I made (as pseudo-patch) and 
everyone willing to do so is able to incorporate them into the svn repository 
of wired-tether. Apparently no one is at the moment.

Additionally I decided providing the binary above just for the convenience of 
most users who don't know how to compile the code-base on their own.

Again there's no need for something. This time it's "being pedantic".

Original comment by alex.c.h...@gmail.com on 13 Jul 2010 at 10:18

GoogleCodeExporter commented 9 years ago
I just did this on my rooted HTC Incredible, default firmware, and this allows 
usb tethering to work.  THANKS! 

Original comment by brhellman@gmail.com on 23 Jul 2010 at 7:46

GoogleCodeExporter commented 9 years ago
The link seems to have been taken down?

Original comment by pkmn...@gmail.com on 19 Nov 2010 at 3:02