Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIPdroid fails to detect the network when reverse tethering over USB; app refuses to connect #1054

Open
bruceleerabbit opened this issue Mar 27, 2024 · 1 comment

Comments

@bruceleerabbit
Copy link

When the gnirehtet app is used to reverse tether over USB, it simulates use of the VPN mechanism. Other apps on the phone have no network issue, such as browsers. But SIPdroid 4.4 beta fails to detect the network. In the profile for a SIP account there is an option to connect over VPN. After enabling that it still fails to connect.

FWIW, the LinPhone project had the same problem 5 years ago:

BelledonneCommunications/linphone-android#709

@hosseinalizare
Copy link

hosseinalizare commented Dec 3, 2024

It seems that by default, USB communication is not anticipated. I had the same issue and implemented the following solution:

As a quick fix, I added the following code to the Receiver class, and I was able to establish the call without any issues. First, I added the following function:

public static String getIPAddress(boolean useIPv4) {
    try {
        List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface intf : interfaces) {
            List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
            for (InetAddress addr : addrs) {
                if (!addr.isLoopbackAddress()) {
                    String sAddr = addr.getHostAddress();
                    boolean isIPv4 = sAddr.indexOf(':') < 0;
                    if (useIPv4) {
                        if (isIPv4)
                            return sAddr;
                    } else {
                        if (!isIPv4) {
                            int delim = sAddr.indexOf('%'); // drop ip6 zone suffix
                            return delim < 0 ? sAddr.toUpperCase() : sAddr.substring(0, delim).toUpperCase();
                        }
                    }
                }
            }
        }
    } catch (Exception ignored) { } // for now eat exceptions
    return "";
}

This function checks for a local network connection and returns the IP address. Then, I added the following code to the end of the isFastGSM function:

if (nt == TelephonyManager.NETWORK_TYPE_EDGE) 
    return PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(org.sipdroid.sipua.ui.Settings.PREF_EDGE + (i != 0 ? i : ""), org.sipdroid.sipua.ui.Settings.DEFAULT_EDGE);

// This condition was added by me
if (getIPAddress(true) != "") {
    Log.i("ZARE:", "NET ZARE 7 " + true);
    on_wlan = true;
    return true;
}
return false;

Please note that I checked this condition as the last priority; you may need to adjust its position based on your requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants