mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +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
@@ -13,7 +13,6 @@ import android.widget.FrameLayout
|
||||
import com.droiddeck.launcher.gpu.FrameGen
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.SessionDisplay
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
@@ -179,9 +178,10 @@ class DroidDeckHudHost(context: Context) {
|
||||
|
||||
private fun applyShown() {
|
||||
if (!running) return
|
||||
val show = !hidden && !backgrounded && SessionState.mode != SessionService.MODE_DESKTOP
|
||||
view?.visibility = if (show) View.VISIBLE else View.GONE
|
||||
showing = show
|
||||
val show = !hidden && !backgrounded
|
||||
val visible = show && SessionState.mode != SessionService.MODE_DESKTOP
|
||||
view?.visibility = if (visible) View.VISIBLE else View.GONE
|
||||
showing = visible
|
||||
if (show != polling) {
|
||||
polling = show
|
||||
if (show) Choreographer.getInstance().postFrameCallback(frameCallback)
|
||||
@@ -215,9 +215,7 @@ class DroidDeckHudHost(context: Context) {
|
||||
}.getOrNull()
|
||||
|
||||
private fun sessionResolution(): String {
|
||||
val panel = SessionDisplay.panelSize(context)
|
||||
val choice = SessionPrefs.resolutionChoice(context, SessionState.mode, panel)
|
||||
val (width, height) = SessionDisplay.resolveChoice(panel, choice)
|
||||
val (width, height) = SessionState.outputSize
|
||||
return "${width}x${height}"
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ internal class MangoReadings(private val sessionDir: File, private val rootDir:
|
||||
private fun externalCpuTemp(): Int? {
|
||||
val file = File(Environment.getExternalStorageDirectory(), "DroidDeck/cpu-temp")
|
||||
if (!file.isFile || System.currentTimeMillis() - file.lastModified() > CPU_TEMP_FRESH_MS) return null
|
||||
return readFloat(file)?.roundToInt()?.takeIf { it in -20..150 }
|
||||
return readFloat(file)?.takeIf { it.isFinite() && it in -20f..150f }?.roundToInt()
|
||||
}
|
||||
|
||||
fun gpuPercent(): Int? {
|
||||
|
||||
@@ -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