Compare commits

...
Author SHA1 Message Date
The412Banner 77fbc3abb4 fix(diagnostics): the session report names the firmware build date 2026-11-30 20:03:52 +00:00
MaxsTechReview 5f129fb4db fix(native): allocated getcwd and realpath results name the guest mount (#3481)
getcwd(NULL, ...) and realpath(path, NULL) returned the host path of a
session mount whenever its guest path was longer than the host path,
because the translation had to fit the buffer the C library allocated.
Shells export that host path as PWD, and Wine prefers a valid PWD, so a
program started from an added game folder on a removable card got a
working directory it could not open and started in the Windows folder.
Grow the allocated result to fit the guest path.
2026-11-30 14:24:10 -05:00
MaxsTechReview 7404fba5a3 fix(battlenet): an install folder chosen in Battle.net on the library's drive is kept (#3479)
* fix(battlenet): an install folder chosen in Battle.net on the library's drive is kept

Every open set Battle.net's default install folder back to the library folder whenever the two differed, so a folder the user picked in Battle.net on the same drive was replaced on the next open. The folder is now only moved to the library when it is unset, missing, or on another drive.

* fix(battlenet): check the trimmed folder against the rootfs drives
2026-11-30 14:24:05 -05:00
7 changed files with 108 additions and 5 deletions

No files matched your search

@@ -27,6 +27,7 @@ import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.TimeZone
object DeviceReport {
private const val TAG = "DeviceReport"
@@ -36,6 +37,10 @@ object DeviceReport {
.map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") }
.filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" }
internal fun buildDate(millis: Long): String? = millis.takeIf { it > 0 }?.let {
SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }.format(Date(it))
}
fun write(context: Context, target: File, mode: String) {
try {
target.writeText(build(context, mode))
@@ -129,6 +134,7 @@ object DeviceReport {
k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
k("Security patch", Build.VERSION.SECURITY_PATCH)
k("Build", Build.DISPLAY)
k("Build date", buildDate(Build.TIME))
k("Fingerprint", Build.FINGERPRINT)
k("Kernel", System.getProperty("os.version"))
k("ABIs", Build.SUPPORTED_ABIS.joinToString(", "))
@@ -0,0 +1,16 @@
package com.droiddeck.launcher.core
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class DeviceReportBuildDateTest {
@Test fun theFirmwareBuildTimeIsShownInUtc() {
assertEquals("2024-11-08 17:47 UTC", DeviceReport.buildDate(1_731_088_027_000L))
}
@Test fun anUnsetBuildTimeIsUnknown() {
assertNull(DeviceReport.buildDate(0L))
assertNull(DeviceReport.buildDate(-1L))
}
}
@@ -350,6 +350,17 @@ def keeps_open(root):
return isinstance(client, dict) and LAUNCH_BEHAVIOR[0] in client and client[LAUNCH_BEHAVIOR[0]] != LAUNCH_BEHAVIOR[1]
def chosen_folder(root, current, library):
current = current.strip()
folder = windows_path(root, current) if current else None
if not folder or rootfs_drive(root, current) or not os.path.isdir(folder):
return False
try:
return volume_root(os.path.realpath(folder)) == volume_root(os.path.realpath(library))
except OSError:
return False
def write_config(root, library=None):
path = os.path.join(drive_c(root), *CONFIG)
key, value = LAUNCH_BEHAVIOR
@@ -374,6 +385,7 @@ def write_config(root, library=None):
client["HardwareAcceleration"] = "false"
changes.append("acceleration")
if library and isinstance(client.setdefault("Install", {}), dict) \
and not chosen_folder(root, str(client["Install"].get("DefaultInstallPath", "")), library) \
and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(root, library).rstrip("\\"):
client["Install"]["DefaultInstallPath"] = install_path(root, library)
changes.append("library")
+4 -5
View File
@@ -739,10 +739,8 @@ char *getcwd(char *buf, size_t size) {
static char *(*orig_getcwd)(char *, size_t) = NULL;
if (!orig_getcwd) orig_getcwd = (char *(*)(char *, size_t))dlsym(RTLD_NEXT, "getcwd");
char *res = orig_getcwd ? orig_getcwd(buf, size) : NULL;
if (res) {
size_t len = strlen(res);
guest_path_of_mount_source(res, len, buf ? size : len + 1, NULL);
}
if (res && !buf) return guest_path_of_allocated_mount_source(res);
if (res) guest_path_of_mount_source(res, strlen(res), size, NULL);
return res;
}
@@ -790,7 +788,8 @@ char *realpath(const char *path, char *resolved_path) {
}
}
}
if (res) guest_path_of_mount_source(res, strlen(res), resolved_path ? PATH_MAX : strlen(res) + 1, NULL);
if (res && !resolved_path) return guest_path_of_allocated_mount_source(res);
if (res) guest_path_of_mount_source(res, strlen(res), PATH_MAX, NULL);
return res;
}
+14
View File
@@ -975,6 +975,20 @@ static size_t guest_path_of_mount_source(char *buf, size_t len, size_t cap, int
return best->dst_len + rest;
}
static char *guest_path_of_allocated_mount_source(char *res) {
size_t len = strlen(res);
char tmp[PATH_MAX];
if (len >= sizeof(tmp)) return res;
memcpy(tmp, res, len + 1);
int converted = 0;
size_t n = guest_path_of_mount_source(tmp, len, sizeof(tmp), &converted);
if (!converted) return res;
char *grown = realloc(res, n + 1);
if (!grown) return res;
memcpy(grown, tmp, n + 1);
return grown;
}
static ssize_t postprocess_readlink(const char *linkpath, char *buf, ssize_t ret, size_t bufsiz) {
if (ret <= 0) return ret;
if ((size_t)ret < bufsiz) {
+31
View File
@@ -295,6 +295,37 @@ class DriveTest(Temp):
self.assertEqual(BNET["install_path"](self.root, str(self.card)), "D:\\")
self.assertEqual(sorted(os.listdir(self.devices)), ["d:"])
def test_a_folder_chosen_in_battlenet_on_the_library_drive_is_kept(self):
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
BNET["write_config"](self.root)
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
(self.card / "Battle.net").mkdir()
config = json.loads(path.read_text())
config["Client"]["Install"]["DefaultInstallPath"] = "D:\\Battle.net"
path.write_text(json.dumps(config))
self.assertIsNone(BNET["write_config"](self.root, str(self.library)))
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Battle.net")
def test_a_chosen_folder_inside_the_native_rootfs_is_not_kept_whatever_its_spacing(self):
BNET["write_config"](self.root, str(self.library))
rootfs = self.card / "files/linuxfs"
(rootfs / "Games").mkdir(parents=True)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
for current in ("D:\\files\\linuxfs\\Games", " D:\\files\\linuxfs\\Games"):
self.assertFalse(BNET["chosen_folder"](self.root, current, str(self.library)))
def test_a_folder_on_another_drive_or_missing_moves_to_the_library(self):
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
BNET["write_config"](self.root, str(self.library))
internal = self.tmp / "root/Games/Stores/Battle.net"
internal.mkdir(parents=True)
for current in ("Z:" + str(internal), "D:\\Gone"):
config = json.loads(path.read_text())
config["Client"]["Install"]["DefaultInstallPath"] = current
path.write_text(json.dumps(config))
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Games\\Battle.net")
def test_drives_in_use_and_the_ones_proton_owns_are_left_alone(self):
self.devices.mkdir(parents=True)
os.symlink("/somewhere/else", self.devices / "d:")
+25
View File
@@ -88,6 +88,18 @@ int main(int argc, char **argv) {
printf("%s\t%s\n", argv[i], ok ? cwd : "-");
continue;
}
if (strncmp(argv[i], "cdnull:", 7) == 0) {
char *got = chdir(argv[i] + 7) == 0 ? getcwd(NULL, 0) : NULL;
printf("%s\t%s\n", argv[i], got ? got : "-");
free(got);
continue;
}
if (strncmp(argv[i], "realnull:", 9) == 0) {
char *got = realpath(argv[i] + 9, NULL);
printf("%s\t%s\n", argv[i], got ? got : "-");
free(got);
continue;
}
if (strncmp(argv[i], "lstat:", 6) == 0) {
int ok = lstat(argv[i] + 6, &st) == 0;
printf("%s\t%d\t%d\n", argv[i], ok, ok && S_ISLNK(st.st_mode));
@@ -324,6 +336,19 @@ class NativeHookMountTest(unittest.TestCase):
arg = f"cd:/pfx/native/dosdevices/z:{GAME}/"
self.assertEqual(self.run_probe(arg)[arg], [GAME])
def test_allocated_working_directory_and_real_path_name_a_longer_guest_mount(self):
guest = "/root/Games/" + "g" * len(str(self.library))
binds = f"{self.library}:{guest}"
args = [f"cd:{guest}/Some Game", f"cdnull:{guest}/Some Game", f"realnull:{guest}/Some Game/game.txt"]
result = self.run_probe(*args, binds=binds)
self.assertEqual(result[args[0]], [f"{guest}/Some Game"])
self.assertEqual(result[args[1]], [f"{guest}/Some Game"])
self.assertEqual(result[args[2]], [f"{guest}/Some Game/game.txt"])
def test_allocated_working_directory_names_a_shorter_guest_mount(self):
arg = f"cdnull:{GAME}"
self.assertEqual(self.run_probe(arg)[arg], [GAME])
def test_rootfs_path_under_a_mount_point_reaches_the_mount(self):
path = f"{self.root}{GAME}/game.txt"
self.assertEqual(self.run_probe(path)[path], ["1", "library"])