I want to know if there is a way to fake network connection as disconnected or disabled on selected apps. As there are Xposed modules like "Fake Wifi Connection" is working, I believe this should be possible.
Thank you.
I want to know if there is a way to fake network connection as disconnected or disabled on selected apps. As there are Xposed modules like "Fake Wifi Connection" is working, I believe this should be possible.
Thank you.
Usually we check network is connected or not by using something like this
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
isConnected = activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();
So you can hook method isConnectedOrConnectiong() of NetworkInfo class using Xposed and return true from it.
XposedHelpers.findAndHookMethod(NetworkInfo.class, loadPackageParam.classLoader, "isConnectedOrConnecting", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
param.setResult(false);
}
});
param.setResult(false) skips the call to the original method and returns false as a result of the call ( which is never made )
I hope this helps.
Edit: from the android docs
getActiveNetworkInfo Added in API level 1
NetworkInfo getActiveNetworkInfo ()
Returns details about the currently active default data network. When connected, this network is the default route for outgoing connections. You should always check isConnected() before initiating network traffic. This may return null when there is no default network.
So the call may return null when there is no default network. This will not work in that case.