(This is an edited version of my post on StackOverflow)

My Android TV box switches Ethernet off as soon as I connect WiFi. This is a feature in Android, which has a notion of "preferred net". Of course it is not a problem for an underlying Linux Kernel. One solution is to recompile AOSP matching the device and exchange system/framework/services.jar.

There is a simpler way, which doesn't require you to build AOSP matching your device. You can simply modify smali-decompiled code and recompile it. Use ConnectivityService.java on github for comparizon.
Something along this lines:

adb pull /system/framework/services.jar
cp services.jar services.jar.bak
unzip services.jar classes.dex
java -jar baksmali.jar classes.dex

Edit out/com/android/server/ConnectivityService.smali in handleConnect(), so that this will be the result:

// if this is a default net and other default is running
// kill the one not preferred
if (false && mNetConfigs[newNetType].isDefault()) {
  if (mActiveDefaultNetwork != -1 && mActiveDefaultNetwork != newNetType) { ...

I made the following change:

aget-object v5, v5, v1

invoke-virtual {v5}, Landroid/net/NetworkConfig;->isDefault()Z

move-result v5

#if-eqz v5, :cond_a6 # changed to unconditional jump
goto :cond_a6

Recompile, repack, push. Then reboot and test.

java -jar smali.jar -o classes.dex out
zip services.jar classes.dex
adb push services.jar /system/framework/services.jar

Unfortunately most apps look into WiFi status to know if they are online, so WiFi has to be connected anyhow.

Add a comment

Next Post Previous Post