1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-22 15:58:25 +00:00

Set metered connection status on Android 10

"VPN apps targeting Build.VERSION_CODES.Q or above will be considered
metered by default."  As a result, the metered status must be
explicitly set when creating the VpnService.Builder.
This commit is contained in:
Ryan Hayle 2020-03-22 13:27:29 -05:00
parent 1fa5bad1e7
commit 22434c6056
No known key found for this signature in database
GPG key ID: 09609EBB067F9235

View file

@ -1250,6 +1250,10 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
Builder builder = new Builder(); Builder builder = new Builder();
builder.setSession(getString(R.string.app_name)); builder.setSession(getString(R.string.app_name));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
builder.setMetered(Util.isMeteredNetwork(this));
}
// VPN address // VPN address
String vpn4 = prefs.getString("vpn4", "10.1.10.1"); String vpn4 = prefs.getString("vpn4", "10.1.10.1");
Log.i(TAG, "Using VPN4=" + vpn4); Log.i(TAG, "Using VPN4=" + vpn4);