I am building an android-app where two users are connected through WiFi-Hotspot. I create the connection programmatically. Lets say User A creates WiFi-Hotspot and User B connects to this hotspot. Now I make them chat with each other using socket. But if User A has data connection ON then User B can use this data through other apps and this can cause A to suffer. So, I want a way by which I can disable User B from using User A's internet i.e. connecting them via hotspot but without sharing internet.
I have looked into the hidden methods getTetherableIfaces and untether in Connection Manager but somehow it doesn't work. Here is how I use them:
ConnectivityManager cman = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
Method[] methods = cman.getClass().getMethods();
for (Method method : methods) {
if (method.getName().equals("getTetherableIfaces")) {
try {
interfaces = (String[]) method.invoke(cman);
}catch (Exception e) {
e.printStackTrace();
}
}
}
for (Method method : methods) {
if (method.getName().equals("untether")) {
try {
for(int i=0;i<interfaces.length;i++)
{
method.invoke(cman,interfaces[i]);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
PS: I have looked into Android-firewall apps but some using rooting and other use VPN which is not possible in my case.