mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-24 15:21:19 +00:00
0.52 beta
This commit is contained in:
parent
cfd56e2e03
commit
61d930eb04
2 changed files with 23 additions and 14 deletions
|
@ -9,8 +9,8 @@ model {
|
|||
applicationId = "eu.faircode.netguard"
|
||||
minSdkVersion.apiLevel = 21
|
||||
targetSdkVersion.apiLevel = 23
|
||||
versionCode = 2015120701
|
||||
versionName = "0.51"
|
||||
versionCode = 2015120702
|
||||
versionName = "0.52"
|
||||
archivesBaseName = "NetGuard-v$versionName-$versionCode"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class SinkholeService extends VpnService {
|
|||
private boolean last_connected = false;
|
||||
private boolean last_metered = true;
|
||||
private boolean phone_state = false;
|
||||
private boolean subscription_state = false;
|
||||
private ParcelFileDescriptor vpn = null;
|
||||
private boolean debug = false;
|
||||
private Thread debugThread = null;
|
||||
|
@ -122,14 +123,25 @@ public class SinkholeService extends VpnService {
|
|||
String reason = intent.getStringExtra(EXTRA_REASON);
|
||||
Log.i(TAG, "Executing intent=" + intent + " command=" + cmd + " reason=" + reason + " vpn=" + (vpn != null));
|
||||
|
||||
// Check phone state listener
|
||||
// Listen for phone state changes
|
||||
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (!phone_state && Util.hasPhoneStatePermission(SinkholeService.this)) {
|
||||
if (!phone_state &&
|
||||
Util.hasPhoneStatePermission(SinkholeService.this)) {
|
||||
tm.listen(phoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||
phone_state = true;
|
||||
Log.i(TAG, "Listening to service state changes");
|
||||
}
|
||||
|
||||
// Listen for data SIM changes
|
||||
if (!subscription_state &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 &&
|
||||
Util.hasPhoneStatePermission(SinkholeService.this)) {
|
||||
SubscriptionManager sm = SubscriptionManager.from(SinkholeService.this);
|
||||
sm.addOnSubscriptionsChangedListener(subscriptionsChangedListener);
|
||||
subscription_state = true;
|
||||
Log.i(TAG, "Listening to subscription changes");
|
||||
}
|
||||
|
||||
try {
|
||||
switch (cmd) {
|
||||
case start:
|
||||
|
@ -500,12 +512,6 @@ public class SinkholeService extends VpnService {
|
|||
ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
registerReceiver(connectivityChangedReceiver, ifConnectivity);
|
||||
|
||||
// Listen for data SIM changes
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
SubscriptionManager sm = SubscriptionManager.from(this);
|
||||
sm.addOnSubscriptionsChangedListener(subscriptionsChangedListener);
|
||||
}
|
||||
|
||||
// Listen for added applications
|
||||
IntentFilter ifPackage = new IntentFilter();
|
||||
ifPackage.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
|
@ -570,15 +576,18 @@ public class SinkholeService extends VpnService {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
unregisterReceiver(idleStateReceiver);
|
||||
unregisterReceiver(connectivityChangedReceiver);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
SubscriptionManager sm = SubscriptionManager.from(this);
|
||||
sm.removeOnSubscriptionsChangedListener(subscriptionsChangedListener);
|
||||
}
|
||||
unregisterReceiver(packageAddedReceiver);
|
||||
|
||||
if (phone_state) {
|
||||
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||
phone_state = false;
|
||||
}
|
||||
|
||||
if (subscription_state) {
|
||||
SubscriptionManager sm = SubscriptionManager.from(this);
|
||||
sm.removeOnSubscriptionsChangedListener(subscriptionsChangedListener);
|
||||
subscription_state = false;
|
||||
}
|
||||
|
||||
if (vpn != null) {
|
||||
|
|
Loading…
Reference in a new issue