mirror of https://github.com/M66B/NetGuard.git
Merge branch 'master' into usage
Conflicts: app/src/main/java/eu/faircode/netguard/SinkholeService.java
This commit is contained in:
commit
6ea46b47c1
|
@ -80,6 +80,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
private static final int MIN_SDK = Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
|
||||
public static final String ACTION_RULES_CHANGED = "eu.faircode.netguard.ACTION_RULES_CHANGED";
|
||||
public static final String EXTRA_REFRESH = "Refresh";
|
||||
public static final String EXTRA_SEARCH = "Search";
|
||||
public static final String EXTRA_APPROVE = "Approve";
|
||||
public static final String EXTRA_LOGCAT = "Logcat";
|
||||
|
@ -296,7 +297,10 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
super.onNewIntent(intent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= MIN_SDK) {
|
||||
if (intent.hasExtra(EXTRA_REFRESH))
|
||||
updateApplicationList(intent.getStringExtra(EXTRA_SEARCH));
|
||||
else
|
||||
updateSearch(intent.getStringExtra(EXTRA_SEARCH));
|
||||
checkExtras(intent);
|
||||
}
|
||||
}
|
||||
|
@ -511,15 +515,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
if (running) {
|
||||
if (adapter != null) {
|
||||
adapter.set(result);
|
||||
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
||||
if (search == null) {
|
||||
if (menuSearch != null && menuSearch.isActionViewExpanded())
|
||||
adapter.getFilter().filter(searchView.getQuery().toString());
|
||||
} else {
|
||||
MenuItemCompat.expandActionView(menuSearch);
|
||||
searchView.setQuery(search, true);
|
||||
}
|
||||
updateSearch(search);
|
||||
}
|
||||
|
||||
if (swipeRefresh != null) {
|
||||
|
@ -531,6 +527,19 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}.execute();
|
||||
}
|
||||
|
||||
private void updateSearch(String search) {
|
||||
if (menuSearch != null) {
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
||||
if (search == null) {
|
||||
if (menuSearch.isActionViewExpanded())
|
||||
adapter.getFilter().filter(searchView.getQuery().toString());
|
||||
} else {
|
||||
MenuItemCompat.expandActionView(menuSearch);
|
||||
searchView.setQuery(search, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (Build.VERSION.SDK_INT < MIN_SDK)
|
||||
|
|
|
@ -116,6 +116,7 @@ public class Receiver extends BroadcastReceiver {
|
|||
|
||||
// Build notification
|
||||
Intent main = new Intent(context, ActivityMain.class);
|
||||
main.putExtra(ActivityMain.EXTRA_REFRESH, true);
|
||||
main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid));
|
||||
PendingIntent pi = PendingIntent.getActivity(context, uid, main, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
|
|
|
@ -371,17 +371,32 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
List<Rule> listRule = Rule.getRules(true, SinkholeService.this);
|
||||
List<Rule> listAllowed = getAllowedRules(listRule);
|
||||
|
||||
// Attempt seamless handover
|
||||
ParcelFileDescriptor prev = vpn;
|
||||
vpn = startVPN(listAllowed);
|
||||
if (prev != null && vpn == null) {
|
||||
Log.w(TAG, "Handover failed");
|
||||
stopVPN(prev);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
if (vpn != null) {
|
||||
stopNative(vpn, false);
|
||||
stopVPN(vpn);
|
||||
vpn = null;
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
vpn = startVPN(listAllowed);
|
||||
|
||||
} else {
|
||||
// Attempt seamless handover
|
||||
ParcelFileDescriptor prev = vpn;
|
||||
vpn = startVPN(listAllowed);
|
||||
|
||||
if (prev != null && vpn == null) {
|
||||
Log.w(TAG, "Handover failed");
|
||||
stopNative(prev, false);
|
||||
stopVPN(prev);
|
||||
prev = null;
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
vpn = startVPN(listAllowed);
|
||||
if (vpn == null)
|
||||
throw new IllegalStateException("Handover failed");
|
||||
|
@ -391,6 +406,8 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
stopNative(prev, false);
|
||||
stopVPN(prev);
|
||||
}
|
||||
}
|
||||
|
||||
if (vpn == null)
|
||||
throw new IllegalStateException("VPN start failed");
|
||||
|
||||
|
|
Loading…
Reference in New Issue