refine per-app VPN

This commit is contained in:
Max Lv
2014-10-19 18:33:04 +08:00
parent 5f95cccce4
commit 558a39ec14
@@ -132,25 +132,25 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
builder.allowFamily(AF_INET6)
if (config.isBypassApps) {
builder.addDisallowedApplication(this.getPackageName)
}
if (!config.isGlobalProxy) {
val apps = AppManager.getProxiedApps(this, config.proxiedAppString)
val uidSet: mutable.HashSet[String] = new mutable.HashSet[String]
val pkgSet: mutable.HashSet[String] = new mutable.HashSet[String]
for (app <- apps) {
if (app.proxied) {
uidSet.add(app.name)
pkgSet.add(app.name)
}
}
for (uid <- uidSet) {
for (pkg <- pkgSet) {
if (!config.isBypassApps) {
builder.addAllowedApplication(uid)
builder.addAllowedApplication(pkg)
} else {
builder.addDisallowedApplication(uid)
builder.addDisallowedApplication(pkg)
}
}
if (!config.isBypassApps) {
builder.addAllowedApplication(this.getPackageName)
}
}
}