Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android USB reverse tethering: How to fool the apps

Tags:

android

USB reverse tethering = Cellphone gets network connection from PC via USB.

I know how to do USB reverse tethering except for one problem: Many Android apps will check network connection using the code below before doing any useful work:

ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); 

The problem is that, when using USB reverse tethering, the above code will report no network connection. However, there IS a network connection (which is the USB reverse tethering itself), and ping, wget and all programs not doing this stupid check work well.

So the question is: How can I hack the system to let this network connection check return success (so that I can fool these apps)?

BTW. I use Cyanogenmod 7. And any solution specific to this MOD is also welcome.

like image 801
Cyker Avatar asked Oct 02 '11 13:10

Cyker


1 Answers

If you are doing this much hacking I am assuming that you will probably have your device rooted. If so program a shell interface to send commands to the device shell with JNI and receive STDOUT. Use this interface to run a netcfg command that can be parsed into an array - this will give you all the details the API hides. It also allows you to override Androids device settings using the ipconfig command.

As far as using this to send and receive from your device - in my experience - you will have to probably compile a device specif module that can be loaded into the kernel at run time. Or just download the kernel from the manufacturer and compile the module into the kernel and then flash the phone with the new custom kernel.

Hope this helps.

like image 103
jjNford Avatar answered Oct 23 '22 16:10

jjNford