mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
fix: open Flatpak apps in renamed app variants (#1192)
Flatpak starts bwrap with an empty environment, so the bwrap shim lost DROIDDECK_BWRAP_SOCKET and dialled the default package's socket. The session now writes the socket name to /etc/droiddeck/bwrap-socket and the shim reads it when the variable is missing. Fixes #1092
This commit is contained in:
1 parent
99ab6dd64e
commit
31a6c3d033
4 files changed
+61
-1
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import runpy
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
BWRAP = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-bwrap"
|
||||
|
||||
|
||||
class BwrapSocketTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.shim = runpy.run_path(str(BWRAP))
|
||||
self.shim["socket_name"].__globals__["SOCKET_FILE"] = str(self.dir / "bwrap-socket")
|
||||
|
||||
def name(self, env):
|
||||
with mock.patch.dict(os.environ, env, clear=True):
|
||||
return self.shim["socket_name"]()
|
||||
|
||||
def test_flatpak_empty_environment_reaches_a_renamed_package(self):
|
||||
(self.dir / "bwrap-socket").write_text("com.antutu.benchmark.full.bwrap\n")
|
||||
self.assertEqual("\0com.antutu.benchmark.full.bwrap", self.name({}))
|
||||
|
||||
def test_the_environment_still_wins(self):
|
||||
(self.dir / "bwrap-socket").write_text("com.antutu.benchmark.full.bwrap\n")
|
||||
self.assertEqual("\0com.tencent.ig.bwrap", self.name({"DROIDDECK_BWRAP_SOCKET": "com.tencent.ig.bwrap"}))
|
||||
|
||||
def test_without_either_the_standard_package_is_asked(self):
|
||||
self.assertEqual("\0com.droiddeck.launcher.bwrap", self.name({}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user