forked from core/mobile_nebula
Disallow some problematic app from the VPN (#126)
This commit is contained in:
parent
f7a7093879
commit
cfca253ec1
|
@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.net.*
|
import android.net.*
|
||||||
import android.os.*
|
import android.os.*
|
||||||
import android.system.OsConstants
|
import android.system.OsConstants
|
||||||
|
@ -115,6 +116,15 @@ class NebulaVpnService : VpnService() {
|
||||||
builder.setMetered(false)
|
builder.setMetered(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disallow some common, known-problematic apps
|
||||||
|
// TODO Make this user configurable
|
||||||
|
// Android Auto Wireless (https://github.com/DefinedNet/mobile_nebula/issues/102)
|
||||||
|
disallowApp(builder, "com.google.android.projection.gearhead")
|
||||||
|
// Chromecast (https://github.com/DefinedNet/mobile_nebula/issues/102)
|
||||||
|
disallowApp(builder, "com.google.android.apps.chromecast.app")
|
||||||
|
// RCS / Jibe
|
||||||
|
disallowApp(builder, "com.google.android.apps.messaging")
|
||||||
|
|
||||||
// Add our unsafe routes
|
// Add our unsafe routes
|
||||||
site!!.unsafeRoutes.forEach { unsafeRoute ->
|
site!!.unsafeRoutes.forEach { unsafeRoute ->
|
||||||
val unsafeIPNet = mobileNebula.MobileNebula.parseCIDR(unsafeRoute.route)
|
val unsafeIPNet = mobileNebula.MobileNebula.parseCIDR(unsafeRoute.route)
|
||||||
|
@ -142,6 +152,15 @@ class NebulaVpnService : VpnService() {
|
||||||
sendSimple(MSG_IS_RUNNING, 1)
|
sendSimple(MSG_IS_RUNNING, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disallowApp(builder: Builder, name: String) {
|
||||||
|
try {
|
||||||
|
builder.addDisallowedApplication(name)
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Used to detect network changes (wifi -> cell or vice versa) and rebinds the udp socket/updates LH
|
// Used to detect network changes (wifi -> cell or vice versa) and rebinds the udp socket/updates LH
|
||||||
private fun registerNetworkCallback() {
|
private fun registerNetworkCallback() {
|
||||||
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
Loading…
Reference in New Issue