diff --git a/android/app/src/main/kotlin/com/hiddify/hiddify/bg/VPNService.kt b/android/app/src/main/kotlin/com/hiddify/hiddify/bg/VPNService.kt index 7830c1e2..2b0dc04a 100644 --- a/android/app/src/main/kotlin/com/hiddify/hiddify/bg/VPNService.kt +++ b/android/app/src/main/kotlin/com/hiddify/hiddify/bg/VPNService.kt @@ -129,11 +129,13 @@ class VPNService : VpnService(), PlatformInterfaceWrapper { if (Settings.perAppProxyMode == PerAppProxyMode.INCLUDE) { appList.forEach { try { - builder.addAllowedApplication(it) + if (it != packageName) + builder.addAllowedApplication(it) } catch (_: NameNotFoundException) { } } - builder.addAllowedApplication(packageName) + + } else { appList.forEach { try { @@ -141,26 +143,38 @@ class VPNService : VpnService(), PlatformInterfaceWrapper { } catch (_: NameNotFoundException) { } } + try { + builder.addDisallowedApplication(packageName) + } catch (_: NameNotFoundException) { + } + } } else { val includePackage = options.includePackage if (includePackage.hasNext()) { while (includePackage.hasNext()) { try { - builder.addAllowedApplication(includePackage.next()) + val it = includePackage.next() + if (it != packageName) + builder.addAllowedApplication(it) } catch (_: NameNotFoundException) { } } - } + } else { - val excludePackage = options.excludePackage - if (excludePackage.hasNext()) { - while (excludePackage.hasNext()) { - try { - builder.addDisallowedApplication(excludePackage.next()) - } catch (_: NameNotFoundException) { + val excludePackage = options.excludePackage + if (excludePackage.hasNext()) { + while (excludePackage.hasNext()) { + try { + builder.addDisallowedApplication(excludePackage.next()) + } catch (_: NameNotFoundException) { + } } } + try { + builder.addDisallowedApplication(packageName) + } catch (_: NameNotFoundException) { + } } } }