diff --git a/README.md b/README.md index c8793fe6dc..5ead273034 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,5 @@ XR glasses support builds on WinNative's VITURE glasses work. VITURE protocol de Joy-Con VR controllers port the arm model of Google's [Google VR SDK for Unity](https://github.com/googlevr/gvr-unity-sdk) (Apache-2.0), adapt the hand skeleton of Valve's [OpenVR](https://github.com/ValveSoftware/openvr) `handskeletonsimulation` sample (BSD-3-Clause), which follows Moshi Turner's hand simulation in [Monado](https://gitlab.freedesktop.org/monado/monado), and use the Index controller offsets from Monado's `vive_poses.c` (BSL-1.0). Joy-Con behaviour was researched in Linux's [hid-nintendo](https://github.com/torvalds/linux/blob/master/drivers/hid/hid-nintendo.c) driver by Daniel J. Ogorchock, [@dekuNukem](https://github.com/dekuNukem)'s [Nintendo_Switch_Reverse_Engineering](https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering), [SDL](https://github.com/libsdl-org/SDL) and the Android Open Source Project, and checked against [ALVR](https://github.com/alvr-org/ALVR), [OpenComposite](https://gitlab.com/znixian/OpenOVR), [PSMoveSteamVRBridge](https://github.com/HipsterSloth/PSMoveSteamVRBridge), [@F8LEFT](https://github.com/F8LEFT)'s [JoyConVr](https://github.com/F8LEFT/JoyConVr), [@krnelpan1c](https://github.com/krnelpan1c)'s [Daydream-Controller-SteamVR](https://github.com/krnelpan1c/Daydream-Controller-SteamVR), [@yoyobuae](https://github.com/yoyobuae)'s [joyconvr](https://github.com/yoyobuae/joyconvr), [Moonlight](https://github.com/moonlight-stream/moonlight-android) and [Dolphin](https://github.com/dolphin-emu/dolphin); see [docs/third-party/joycon](docs/third-party/joycon/README.md). Nintendo Switch and Joy-Con are trademarks of Nintendo; this project is not affiliated with Nintendo. Camera hand tracking runs Google's [MediaPipe](https://github.com/google-ai-edge/mediapipe) Tasks Vision library with its Pose Landmarker (Lite) model, BlazePose GHUM 3D, and its Hand Landmarker model (all Apache-2.0), on frames from AndroidX [CameraX](https://developer.android.com/jetpack/androidx/releases/camera) (Apache-2.0); MediaPipe's usage reports are switched off. The design was checked against [@F8LEFT](https://github.com/F8LEFT)'s [JoyConVr](https://github.com/F8LEFT/JoyConVr) camera app (MIT), and the short Joy-Con movements follow the accelerometer mode of the [Google VR SDK for Unity](https://github.com/googlevr/gvr-unity-sdk)'s arm model, Eric Foxlin's zero-velocity updates and Frosio, Pedersini and Borghese's accelerometer autocalibration, and the camera and Joy-Con are joined by a Kalman filter (R. E. Kalman, 1960). Bare camera hands take their gestures after [ALVR](https://github.com/alvr-org/ALVR)'s `hand_gestures.rs` (MIT) and Meta Quest's menu pinch, with distances checked on photos from the [HaGRID](https://github.com/hukenovs/hagrid) gesture set (CC BY-SA 4.0, not included), fit the palm with Horn's quaternion method (1987) and smooth it with the 1€ filter (Casiez, Roussel and Vogel, 2012); the white glove model follows Valve's OpenVR render model reference and Index controller poses, is meshed with surface nets (Gibson, 1998; Mikola Lysenko) and blends and shades it with Inigo Quilez's smooth minimum and distance-field ambient occlusion, porting his polygon distance (MIT); see [docs/third-party/handtracking](docs/third-party/handtracking/README.md). + +The Store installs and runs apps with [Flatpak](https://github.com/flatpak/flatpak) (LGPL-2.1). Its sandbox goes through DroidDeck's own bubblewrap shim, which follows how Flatpak hands bwrap its environment. diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index 3b0af016dc..506d5b7720 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -5,6 +5,7 @@ import android.os.Environment import android.util.Log import com.droiddeck.launcher.R import com.droiddeck.launcher.core.FileUtils +import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.DesktopCatalog import com.droiddeck.launcher.runtime.LegacyNames import com.droiddeck.launcher.runtime.LinuxRuntime @@ -208,6 +209,13 @@ object SessionFiles { if (!FileUtils.writeString(File(etc, "steam-compatibility-label"), context.getString(R.string.steam_compat_label))) { Log.e(TAG, "could not write steam-compatibility-label") } + val droiddeckEtc = File(etc, "droiddeck").apply { mkdirs() } + val stagedSocket = File(droiddeckEtc, "bwrap-socket.staged") + if (!FileUtils.writeString(stagedSocket, BwrapSpawner.socket(context) + "\n") + || !stagedSocket.renameTo(File(droiddeckEtc, "bwrap-socket"))) { + stagedSocket.delete() + Log.e(TAG, "could not write bwrap-socket") + } BootMovie.syncFromSteam(context) val startupMovie = BootMovie.prepare(context) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-bwrap b/tools/linuxfs/overlay/usr/local/bin/droiddeck-bwrap index 909056fcd5..2e84a695c2 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-bwrap +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-bwrap @@ -7,7 +7,21 @@ import socket import struct import sys -SOCKET = "\0" + os.environ.get("DROIDDECK_BWRAP_SOCKET", "com.droiddeck.launcher.bwrap") +SOCKET_FILE = "/etc/droiddeck/bwrap-socket" + + +def socket_name(): + name = os.environ.get("DROIDDECK_BWRAP_SOCKET", "") + if not name: + try: + with open(SOCKET_FILE, encoding="utf-8") as f: + name = f.read().strip() + except OSError: + pass + return "\0" + (name or "com.droiddeck.launcher.bwrap") + + +SOCKET = socket_name() VERSION = "bubblewrap 0.11.0 (droiddeck)" NO_ARG = { diff --git a/tools/tests/test_bwrap_socket.py b/tools/tests/test_bwrap_socket.py new file mode 100644 index 0000000000..7fa782c8ad --- /dev/null +++ b/tools/tests/test_bwrap_socket.py @@ -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()