mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix: keep PRoot out of the APK, VPN DNS first, bridge failure exits, HUD polling stays on
This commit is contained in:
1 parent
f05e0df39e
commit
34a1cbbead
11 files changed
+27
-44
No files matched your search
@@ -252,7 +252,10 @@ class LinuxNetworkLinkComponent(
|
||||
}
|
||||
|
||||
private fun localDnsServers(): List<String> {
|
||||
val active = connectivity.activeNetwork?.let { connectivity.getNetworkCapabilities(it) }
|
||||
if (active?.hasTransport(NetworkCapabilities.TRANSPORT_VPN) == true) return emptyList()
|
||||
val servers = LinkedHashSet<String>()
|
||||
val gateways = LinkedHashSet<String>()
|
||||
for (network in connectivity.allNetworks) {
|
||||
val capabilities = connectivity.getNetworkCapabilities(network) ?: continue
|
||||
if (!capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) continue
|
||||
@@ -265,14 +268,12 @@ class LinuxNetworkLinkComponent(
|
||||
}
|
||||
link.routes.firstOrNull { it.isDefaultRoute }?.gateway?.let { gateway ->
|
||||
if (gateway is Inet4Address && !gateway.isLoopbackAddress && !gateway.isAnyLocalAddress) {
|
||||
gateway.hostAddress?.substringBefore('%')?.let { servers.add(it) }
|
||||
gateway.hostAddress?.substringBefore('%')?.let { gateways.add(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
return servers.sortedWith(compareBy<String>(
|
||||
{ if (it.startsWith("192.168.") || it.startsWith("10.")) 0 else 1 },
|
||||
{ if (it.contains(':')) 1 else 0 },
|
||||
)).take(6)
|
||||
val order = compareBy<String>({ if (it.contains(':')) 1 else 0 })
|
||||
return servers.sortedWith(order) + gateways.sortedWith(order)
|
||||
}
|
||||
|
||||
private fun writeResolver(properties: LinkProperties?) {
|
||||
@@ -280,7 +281,7 @@ class LinuxNetworkLinkComponent(
|
||||
.filter { !it.isLinkLocalAddress && !it.isLoopbackAddress && !it.isAnyLocalAddress }
|
||||
.sortedBy { if (it is Inet4Address) 0 else 1 }
|
||||
.mapNotNull { it.hostAddress?.substringBefore('%') }
|
||||
val servers = (localDnsServers() + own + listOf("8.8.8.8", "1.1.1.1", "2001:4860:4860::8888")).distinct().take(6)
|
||||
val servers = (own + localDnsServers() + listOf("8.8.8.8", "1.1.1.1", "2001:4860:4860::8888")).distinct().take(6)
|
||||
val text = buildString {
|
||||
append("# Written by the app from the device's active network; edits are overwritten.\n")
|
||||
for (server in servers) append("nameserver $server\n")
|
||||
|
||||
@@ -63,8 +63,6 @@ public final class LinuxRuntime {
|
||||
|
||||
private static final String HOST_DIR = "opt/android-host";
|
||||
public static final String PROOT_PACK = "add-on pack";
|
||||
public static final String PROOT_PACKAGED = "packaged";
|
||||
/** Termux's unpatched proot inside the rootfs. Developer switch only. */
|
||||
public static final String PROOT_ROOTFS = "rootfs fallback";
|
||||
public static final String PROOT_MISSING = "missing";
|
||||
|
||||
@@ -80,31 +78,17 @@ public final class LinuxRuntime {
|
||||
return rootfsProot(context).isFile() && rootfsLoader(context).isFile();
|
||||
}
|
||||
|
||||
private static File packagedProot(Context context) {
|
||||
return new File(context.getApplicationInfo().nativeLibraryDir, "libproot.so");
|
||||
}
|
||||
|
||||
private static File packagedLoader(Context context) {
|
||||
return new File(context.getApplicationInfo().nativeLibraryDir, "libproot-loader.so");
|
||||
}
|
||||
|
||||
private static boolean packagedProotReady(Context context) {
|
||||
return packagedProot(context).isFile() && packagedLoader(context).isFile();
|
||||
}
|
||||
|
||||
public static boolean patchedProot(Context context) {
|
||||
return packagedProotReady(context) || AddonPack.PROOT.installed(context);
|
||||
return AddonPack.PROOT.installed(context);
|
||||
}
|
||||
|
||||
public static File prootBinary(Context context) {
|
||||
if (packagedProotReady(context)) return packagedProot(context);
|
||||
if (AddonPack.PROOT.installed(context)) return AddonPack.PROOT.file(context, "libproot.so");
|
||||
if (SessionPrefs.allowStockProot(context)) return rootfsProot(context);
|
||||
return AddonPack.PROOT.file(context, "libproot.so");
|
||||
}
|
||||
|
||||
public static File prootLoader(Context context) {
|
||||
if (packagedProotReady(context)) return packagedLoader(context);
|
||||
if (AddonPack.PROOT.installed(context)) return AddonPack.PROOT.file(context, "libproot-loader.so");
|
||||
if (SessionPrefs.allowStockProot(context)) return rootfsLoader(context);
|
||||
return AddonPack.PROOT.file(context, "libproot-loader.so");
|
||||
@@ -113,8 +97,6 @@ public final class LinuxRuntime {
|
||||
public static String prootSource(Context context) {
|
||||
File bin = prootBinary(context);
|
||||
if (!bin.isFile()) return PROOT_MISSING;
|
||||
if (packagedProotReady(context)
|
||||
&& bin.getPath().equals(packagedProot(context).getPath())) return PROOT_PACKAGED;
|
||||
if (AddonPack.PROOT.installed(context)
|
||||
&& bin.getPath().equals(AddonPack.PROOT.file(context, "libproot.so").getPath())) return PROOT_PACK;
|
||||
return PROOT_ROOTFS;
|
||||
@@ -126,7 +108,7 @@ public final class LinuxRuntime {
|
||||
}
|
||||
|
||||
public static boolean isInstalled(Context context) {
|
||||
return hasRootfs(context) && (packagedProotReady(context) || patchedProot(context) || rootfsProotReady(context));
|
||||
return hasRootfs(context) && (patchedProot(context) || rootfsProotReady(context));
|
||||
}
|
||||
|
||||
public static boolean hasRootfs(Context context) {
|
||||
|
||||
Reference in new issue
Block a user