1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-27 02:09:41 +00:00

Revert "Enable connectivity monitor on Android 6 or later only"

This reverts commit 83ac6b7996.
This commit is contained in:
M66B 2017-11-11 10:36:02 +01:00
parent 83ac6b7996
commit d2a6042a6a

View file

@ -2025,7 +2025,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
}
};
@TargetApi(Build.VERSION_CODES.M)
ConnectivityManager.NetworkCallback networkMonitorCallback = new ConnectivityManager.NetworkCallback() {
private String TAG = "NetGuard.Monitor";
@ -2101,9 +2100,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
synchronized (validated) {
validated.put(network, new Date().getTime());
}
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.reportNetworkConnectivity(network, true);
Log.i(TAG, "Reported " + network + " " + ni);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.reportNetworkConnectivity(network, true);
Log.i(TAG, "Reported " + network + " " + ni);
}
} catch (IOException ex) {
Log.e(TAG, ex.toString());
Log.i(TAG, "No connectivity " + network + " " + ni);
@ -2373,13 +2374,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
listenConnectivityChanges();
// Monitor networks
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.registerNetworkCallback(
new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
networkMonitorCallback);
}
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.registerNetworkCallback(
new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
networkMonitorCallback);
// Setup house holding
Intent alarmIntent = new Intent(this, ServiceSinkhole.class);
@ -2626,10 +2625,8 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
registeredConnectivityChanged = false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.unregisterNetworkCallback(networkMonitorCallback);
}
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cm.unregisterNetworkCallback(networkMonitorCallback);
if (phone_state) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);