diff --git a/.github/workflows/authorship.yml b/.github/workflows/authorship.yml
index 97c6637a8f..ebbcae644f 100644
--- a/.github/workflows/authorship.yml
+++ b/.github/workflows/authorship.yml
@@ -23,7 +23,7 @@ permissions:
jobs:
validate:
- name: Build APK
+ name: Validate source and build result
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0c81773ed9..a8ffbac79f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,26 +16,29 @@ on:
- 'LICENSE'
- '.gitignore'
workflow_dispatch:
+ inputs:
+ rebuild_preloads:
+ description: Rebuild preloads instead of reusing the approved binary snapshot
+ type: boolean
+ default: false
permissions:
contents: read
+ actions: read
pull-requests: write
concurrency:
group: build-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
-env:
- PRELOAD_CACHE_VERSION: v6
-
jobs:
- xbox:
- name: Xbox ARM64 backend
+ source:
+ name: Pin source tree
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
- runs-on: ubuntu-24.04-arm
- timeout-minutes: 30
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
outputs:
- base-sha: ${{ steps.merge.outputs.base-sha }}
+ base-sha: ${{ steps.merge.outputs.base-sha || steps.trusted.outputs.base-sha }}
tree-sha: ${{ steps.source.outputs.tree-sha }}
steps:
- uses: actions/checkout@v4
@@ -53,9 +56,46 @@ jobs:
git config user.name "ci"
git config user.email "ci@users.noreply.github.com"
git merge --no-ff --no-edit origin/main
- - name: Record backend source tree
+ - name: Resolve trusted manifest base
+ id: trusted
+ if: github.event_name != 'pull_request'
+ run: |
+ set -euo pipefail
+ git fetch --no-tags origin main
+ echo "base-sha=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT"
+ - name: Record pinned source tree
id: source
run: echo "tree-sha=$(git rev-parse 'HEAD^{tree}')" >> "$GITHUB_OUTPUT"
+
+ xbox:
+ name: Xbox ARM64 backend
+ needs: source
+ if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
+ runs-on: ubuntu-24.04-arm
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Merge the pinned APK base
+ if: github.event_name == 'pull_request'
+ env:
+ BUILD_BASE_SHA: ${{ needs.source.outputs.base-sha }}
+ run: |
+ set -euo pipefail
+ git fetch --no-tags origin "$BUILD_BASE_SHA"
+ git config user.name "ci"
+ git config user.email "ci@users.noreply.github.com"
+ git merge --no-ff --no-edit FETCH_HEAD
+ - name: Verify pinned source tree
+ env:
+ SOURCE_TREE: ${{ needs.source.outputs.tree-sha }}
+ run: test "$(git rev-parse 'HEAD^{tree}')" = "$SOURCE_TREE"
+ - name: Plan component identities
+ id: plan
+ run: python3 tools/components/prepare.py plan
- uses: actions/cache@v4
id: xbox-cache
with:
@@ -63,14 +103,10 @@ jobs:
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
app/build/xbox/xodus-droiddeck-source.tar.xz
app/build/xbox/runtime/*-source.tar.xz
- key: xbox-arm64-${{ hashFiles('tools/xbox/**') }}
+ key: xbox-v2-${{ steps.plan.outputs.xbox }}
- name: Build Xbox backend
if: steps.xbox-cache.outputs.cache-hit != 'true'
- run: |
- rustup toolchain install 1.99.0 --profile minimal
- sudo apt-get update -qq
- sudo apt-get install -y build-essential pkg-config libssl-dev protobuf-compiler cmake xz-utils
- bash tools/xbox/build.sh
+ run: python3 tools/components/prepare.py xbox
- uses: actions/upload-artifact@v4
with:
name: xbox-arm64
@@ -85,9 +121,173 @@ jobs:
if-no-files-found: error
retention-days: 14
+ components:
+ name: Prepare verified components
+ needs: source
+ if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 40
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
+ fetch-depth: 0
+ submodules: true
+ persist-credentials: false
+ - name: Merge the pinned APK base
+ if: github.event_name == 'pull_request'
+ env:
+ BUILD_BASE_SHA: ${{ needs.source.outputs.base-sha }}
+ run: |
+ set -euo pipefail
+ git fetch --no-tags origin "$BUILD_BASE_SHA"
+ git config user.name "ci"
+ git config user.email "ci@users.noreply.github.com"
+ git merge --no-ff --no-edit FETCH_HEAD
+ - name: Verify pinned source tree
+ env:
+ SOURCE_TREE: ${{ needs.source.outputs.tree-sha }}
+ run: test "$(git rev-parse 'HEAD^{tree}')" = "$SOURCE_TREE"
+ - name: Resolve the pinned Android NDK
+ run: bash tools/ci/resolve-ndk.sh
+
+ - name: Plan component identities
+ id: plan
+ run: python3 tools/components/prepare.py plan
+ - name: Cache remaining Linux runtime assets
+ id: preloads
+ uses: actions/cache@v4
+ with:
+ path: |
+ app/src/main/assets/linuxfs
+ !app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet
+ !app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
+ !app/src/main/assets/linuxfs/i386/libblsession.so
+ !app/src/main/assets/linuxfs/i386/libfakeinput.so
+ !app/src/main/assets/linuxfs/i386/libfaultreport.so
+ !app/src/main/assets/linuxfs/libblaudit.so
+ !app/src/main/assets/linuxfs/libblfastpath.so
+ !app/src/main/assets/linuxfs/libblsession.so
+ !app/src/main/assets/linuxfs/libfakeinput.so
+ !app/src/main/assets/linuxfs/libssbs.so
+ !app/src/main/assets/linuxfs/usr/local/bin/droiddeck-clipboard
+ !app/src/main/assets/linuxfs/x86_64/libblsession.so
+ !app/src/main/assets/linuxfs/x86_64/libfakeinput.so
+ !app/src/main/assets/linuxfs/x86_64/libfaultreport.so
+ !app/src/main/assets/linuxfs/x86_64/libvulkan-thunk.so
+ !app/src/main/assets/linuxfs/x86_64/libwebkitinput.so
+ key: runtime-v9-${{ steps.plan.outputs.runtime }}
+
+ - name: Cache PulseAudio 13.0 source
+ id: pa-src
+ uses: actions/cache@v4
+ with:
+ path: pa13
+ key: pulseaudio-src-${{ steps.plan.outputs.pulseaudio-source }}
+ - name: Cache proot
+ id: proot
+ uses: actions/cache@v4
+ with:
+ path: |
+ app/src/main/jniLibs/arm64-v8a/libproot.so
+ app/src/main/jniLibs/arm64-v8a/libproot-loader.so
+ key: proot-v2-${{ steps.plan.outputs.proot }}
+ - name: Cache GOG Galaxy companion
+ id: comet
+ uses: actions/cache@v4
+ with:
+ path: app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet
+ key: comet-v2-${{ steps.plan.outputs.comet }}
+
+ - name: Restore verified preload snapshots
+ id: component-preloads
+ env:
+ GH_TOKEN: ${{ github.token }}
+ FORCE_PRELOAD_REBUILD: ${{ inputs.rebuild_preloads || 'false' }}
+ COMPONENT_TRUSTED_BASE: ${{ needs.source.outputs.base-sha }}
+ run: python3 tools/components/prepare.py preload-snapshot
+
+ - name: Prepare required Linux build tools once
+ env:
+ COMPONENTS_TO_BUILD: >-
+ ${{ steps.preloads.outputs.cache-hit != 'true' && 'runtime' || '' }}
+ ${{ steps.component-preloads.outputs.arm64 != 'true' && 'arm64-preloads' || '' }}
+ ${{ steps.comet.outputs.cache-hit != 'true' && 'comet' || '' }}
+ run: python3 tools/components/prepare.py tools
+
+ - name: Build changed ARM64 preloads
+ if: steps.component-preloads.outputs.arm64 != 'true'
+ run: python3 tools/components/prepare.py arm64-preloads
+
+ - name: Prepare remaining Linux runtime assets
+ if: steps.preloads.outputs.cache-hit != 'true'
+ run: python3 tools/components/prepare.py runtime
+
+ - name: Fetch the Debian image the preloads build in
+ if: steps.component-preloads.outputs.x86 != 'true'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: python3 tools/components/prepare.py debian-image
+
+ - name: Build the x86 preloads FEX guests load (glibc 2.31)
+ if: steps.component-preloads.outputs.x86 != 'true'
+ run: python3 tools/components/prepare.py x86-preloads
+
+ - name: Bundle the droiddeck-esync packs
+ run: python3 tools/components/prepare.py esync
+
+ - name: Fetch PulseAudio 13.0 source
+ if: steps.pa-src.outputs.cache-hit != 'true'
+ run: python3 tools/components/prepare.py pulseaudio-source
+
+ - name: Fetch DirectAudio (tools/directaudio/release.env)
+ run: python3 tools/components/prepare.py directaudio
+
+ - name: Build the AAudio sink into the audio bundle
+ run: python3 tools/components/prepare.py audio
+
+ - name: Build proot
+ if: steps.proot.outputs.cache-hit != 'true'
+ run: python3 tools/components/prepare.py proot
+
+ - name: Check the preloads
+ run: |
+ set -euo pipefail
+ bash tools/linuxfs/check-preloads.sh app/src/main/assets/linuxfs
+
+ - name: Build GOG Galaxy companion
+ if: steps.comet.outputs.cache-hit != 'true'
+ run: python3 tools/components/prepare.py comet
+
+ - name: Build the non-Adreno test additions (Mali bridge client, Venus GL probe, Xclipse layer)
+ run: |
+ set -euo pipefail
+ bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libvulkan-dev
+ D=app/src/main/assets/linuxfs
+ mkdir -p "$D/usr/local/bin" "$D/usr/local/lib/droiddeck-xclipse"
+ aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -pthread \
+ -o "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so" tools/linuxfs/xclipse-layer/xclipse_layer.c -ldl
+ aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so"
+ install -m644 tools/linuxfs/xclipse-layer/VkLayer_droiddeck_xclipse.json "$D/usr/local/lib/droiddeck-xclipse/"
+ external/MaliBridge/scripts/build-client-linux.sh "$D" aarch64-linux-gnu-gcc
+ aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
+ aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe"
+
+ - name: Prepare graphics driver variants
+ run: python3 tools/quest/build-driver.py "$ANDROID_HOME/ndk/$NDK_VERSION"
+ - name: Record and pack prepared components
+ run: python3 tools/components/prepare.py pack
+ - uses: actions/upload-artifact@v4
+ with:
+ name: prepared-components
+ path: app/build/prepared-components.tar.gz
+ if-no-files-found: error
+ compression-level: 0
+ retention-days: 14
+
build:
- needs: xbox
- name: Compile and test APK
+ needs: [source, components, xbox]
+ name: Compile APK and Android tests
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
runs-on: ubuntu-24.04
timeout-minutes: 45
@@ -151,7 +351,7 @@ jobs:
- name: Merge onto main, or say what conflicts
if: github.event_name == 'pull_request'
env:
- BUILD_BASE_SHA: ${{ needs.xbox.outputs.base-sha }}
+ BUILD_BASE_SHA: ${{ needs.source.outputs.base-sha }}
run: |
set -uo pipefail
git config user.name "ci"
@@ -209,7 +409,7 @@ jobs:
- name: Verify backend and APK source match
env:
- XBOX_SOURCE_TREE: ${{ needs.xbox.outputs.tree-sha }}
+ XBOX_SOURCE_TREE: ${{ needs.source.outputs.tree-sha }}
run: test "$(git rev-parse 'HEAD^{tree}')" = "$XBOX_SOURCE_TREE"
- uses: actions/setup-java@v4
@@ -219,13 +419,11 @@ jobs:
- uses: gradle/actions/setup-gradle@v4
with:
+ cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
cache-cleanup: on-success
- - name: Resolve the runner's NDK
- run: |
- NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
- VERSION=$(sed -n 's/^Pkg.Revision *= *//p' "$NDK/source.properties")
- echo "NDK_VERSION=$VERSION" >> "$GITHUB_ENV"
+ - name: Resolve the pinned Android NDK
+ run: bash tools/ci/resolve-ndk.sh
- name: Set the APK build label
id: build-label
@@ -251,299 +449,6 @@ jobs:
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
- - name: Cache the preloads
- id: preloads
- uses: actions/cache@v4
- with:
- path: app/src/main/assets/linuxfs
- key: preloads-${{ env.PRELOAD_CACHE_VERSION }}-${{ hashFiles('app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/cpp/adrenotools/src/hook/kgsl.h', 'tools/quest/*', 'tools/linuxfs/preload/*.c', 'tools/linuxfs/build-x86-preloads.sh', 'tools/linuxfs/fex/*', 'tools/linuxfs/clipboard/*.c', 'tools/linuxfs/ssbs/*.c', 'tools/linuxfs/xclipse-layer/*', 'tools/proot/fastpath/*.c', 'tools/linuxfs/overlay/usr/local/bin/*', 'tools/linuxfs/overlay/usr/bin/**', 'tools/linuxfs/desktop/*', 'tools/gamescope/release.env', 'tools/wlroots/release.env', 'tools/linuxfs/uruntime.env', 'tools/linuxfs/licenses/*', 'tools/mangoapp/*', 'tools/msitools/**', 'tools/comet/**', 'tools/xbox/**', 'external/MaliBridge/client/**', 'external/MaliBridge/common/**', 'external/MaliBridge/tests/**', 'external/MaliBridge/scripts/build-client-linux.sh', 'tools/venus/glprobe.c', 'tools/linuxfs/debian-image.env', 'tools/vr/**') }}
-
- - name: Build libfakeinput.so and libblsession.so (glibc aarch64)
- if: steps.preloads.outputs.cache-hit != 'true'
- run: |
- set -euo pipefail
- sudo apt-get -o Dir::Etc::sourcelist=sources.list.d/ubuntu.sources \
- -o Dir::Etc::sourceparts=- -o Acquire::Retries=3 update -qq
- sudo apt-get install -y -qq gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libvulkan-dev libvulkan1 mesa-vulkan-drivers >/dev/null
- D=app/src/main/assets/linuxfs
- mkdir -p "$D"
- aarch64-linux-gnu-g++ -shared -fPIC -O2 -Wall -Wno-attributes -Wno-nonnull-compare \
- -pthread -std=c++17 -static-libstdc++ -static-libgcc -Wl,--exclude-libs,ALL \
- -o "$D/libfakeinput.so" app/src/main/cpp/fakeinput_steam.cpp -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/libfakeinput.so"
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
- -o "$D/libblsession.so" tools/linuxfs/preload/*.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/libblsession.so"
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
- -o "$D/libblfastpath.so" tools/proot/fastpath/fastpath.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/libblfastpath.so"
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -nostdlib -ffreestanding -fno-stack-protector \
- -fno-tree-loop-distribute-patterns -Wl,-z,defs -o "$D/libblaudit.so" tools/proot/fastpath/audit.c
- aarch64-linux-gnu-strip --strip-unneeded "$D/libblaudit.so"
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
- -o "$D/libssbs.so" tools/linuxfs/ssbs/ssbs_adapter.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/libssbs.so"
- # Samsung Xclipse driver workarounds, a Vulkan layer the system-driver path enables there.
- mkdir -p "$D/usr/local/lib/droiddeck-xclipse"
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -pthread \
- -o "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so" tools/linuxfs/xclipse-layer/xclipse_layer.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so"
- install -m644 tools/linuxfs/xclipse-layer/VkLayer_droiddeck_xclipse.json "$D/usr/local/lib/droiddeck-xclipse/"
- mkdir -p "$D/usr/local/bin"
- # The Mali bridge's Linux side: ICD, manifest and self-test (external/MaliBridge).
- external/MaliBridge/scripts/build-client-linux.sh "$D" aarch64-linux-gnu-gcc
- # GLX start-up probe for the Mali Venus route.
- aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe"
- aarch64-linux-gnu-gcc -O2 -Wall -Wextra -o "$D/usr/local/bin/droiddeck-clipboard" tools/linuxfs/clipboard/clipboard.c -ldl
- aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-clipboard"
- VK_INCLUDE=$(ls -d "${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1) \
- tools/vr/build.sh --native "$D/usr/local/lib/droiddeck-vr"
- for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
- install -Dm644 "$script" "$D/usr/local/bin/$(basename "$script")"
- done
- for f in tools/linuxfs/overlay/usr/bin/* tools/linuxfs/overlay/usr/bin/steamos-polkit-helpers/*; do
- [ -f "$f" ] && install -Dm644 "$f" "$D/${f#tools/linuxfs/overlay/}"
- done
- if [ -f tools/gamescope/release.env ]; then
- . tools/gamescope/release.env
- curl -fsSL --retry 3 -o gamescope.tzst "https://github.com/${GAMESCOPE_REPO:-${GITHUB_REPOSITORY}}/releases/download/${GAMESCOPE_TAG}/gamescope.tzst"
- echo "${GAMESCOPE_SHA256} gamescope.tzst" | sha256sum -c -
- tar --use-compress-program=unzstd -xf gamescope.tzst -C "$D"
- test -f "$D/usr/local/bin/gamescope"
- rm gamescope.tzst
- fi
- . tools/linuxfs/uruntime.env
- curl -fsSL --retry 3 -o uruntime "https://github.com/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/${URUNTIME_ASSET}"
- echo "${URUNTIME_SHA256} uruntime" | sha256sum -c -
- install -Dm644 uruntime "$D/usr/local/lib/droiddeck/uruntime"
- install -Dm644 tools/linuxfs/licenses/uruntime-LICENSE "$D/usr/local/share/licenses/uruntime/LICENSE"
- rm uruntime
- M="$D/usr/local/lib/mangoapp"
- mkdir -p "$M" mango-pkgs
- grep -v '^#' tools/mangoapp/packages.txt | while read -r sum url; do
- [ -n "$url" ] || continue
- curl -fsSL --retry 3 -o mango-pkgs/pkg.tar.zst "$url"
- echo "$sum mango-pkgs/pkg.tar.zst" | sha256sum -c -
- tar --use-compress-program=unzstd -xf mango-pkgs/pkg.tar.zst -C mango-pkgs
- rm mango-pkgs/pkg.tar.zst
- done
- install -m644 mango-pkgs/usr/bin/mangoapp "$M/mangoapp"
- for so in libfmt.so.10 libspdlog.so.1.13 libglfw.so.3 libtraceevent.so.1; do
- cp -L "mango-pkgs/usr/lib/$so" "$M/$so"
- done
- aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wl,-soname,libtracefs.so.1 \
- -o "$M/libtracefs.so.1" tools/mangoapp/libtracefs-shim.c
- aarch64-linux-gnu-strip --strip-unneeded "$M/libtracefs.so.1"
- install -Dm644 tools/mangoapp/mangoapp "$D/usr/local/bin/mangoapp"
- rm -rf mango-pkgs
- ls -l "$M"
- mkdir -p pw-pkgs
- grep -v '^#' tools/pipewire/packages.txt | while read -r sum url; do
- [ -n "$url" ] || continue
- curl -fsSL --retry 3 -o pw-pkgs/pkg.tar.zst "$url"
- echo "$sum pw-pkgs/pkg.tar.zst" | sha256sum -c -
- tar --use-compress-program=unzstd -xf pw-pkgs/pkg.tar.zst -C pw-pkgs
- rm pw-pkgs/pkg.tar.zst
- done
- tools/pipewire/assemble.sh pw-pkgs "$D/usr/local/lib/droiddeck-pipewire.tzst"
- rm -rf pw-pkgs
- ls -l "$D/usr/local/lib/droiddeck-pipewire.tzst"
- T="$D/usr/local/lib/droiddeck-msitools"
- mkdir -p "$T" msi-pkgs
- grep -v '^#' tools/msitools/packages.txt | while read -r sum url; do
- [ -n "$url" ] || continue
- curl -fsSL --retry 3 -o msi-pkgs/pkg.tar.xz "$url"
- echo "$sum msi-pkgs/pkg.tar.xz" | sha256sum -c -
- tar -xJf msi-pkgs/pkg.tar.xz -C msi-pkgs
- rm msi-pkgs/pkg.tar.xz
- done
- install -m644 msi-pkgs/usr/bin/msiinfo "$T/msiinfo"
- install -m644 msi-pkgs/usr/bin/cabextract "$T/cabextract"
- install -m644 msi-pkgs/usr/lib/7zip/7z "$T/7z"
- install -m644 msi-pkgs/usr/lib/7zip/7z.so "$T/7z.so"
- for so in libmsi-1.0.so.0 libgsf-1.so.114 libgcab-1.0.so.0; do
- cp -L "msi-pkgs/usr/lib/$so" "$T/$so"
- done
- for f in NOTICE GPL-2 GPL-3 LGPL-2.1 7zip-License 7zip-unRarLicense; do
- install -Dm644 "tools/msitools/licenses/$f" "$D/usr/local/share/licenses/droiddeck-msitools/$f"
- done
- rm -rf msi-pkgs
- ls -l "$T"
- install -Dm644 tools/linuxfs/desktop/droiddeck-desktop "$D/usr/local/bin/droiddeck-desktop"
- install -Dm644 tools/linuxfs/desktop/droiddeck-gpu "$D/usr/local/bin/droiddeck-gpu"
- install -Dm644 tools/linuxfs/desktop/droiddeck-desktop-gpu "$D/usr/local/bin/droiddeck-desktop-gpu"
- install -Dm644 tools/linuxfs/desktop/kwin_wayland_wrapper "$D/usr/local/bin/kwin_wayland_wrapper"
- install -Dm644 tools/linuxfs/desktop/firefox-droiddeck.js "$D/usr/lib/firefox/defaults/pref/droiddeck.js"
- ls -lR "$D"
-
- - name: Fetch the Debian image the preloads build in
- if: steps.preloads.outputs.cache-hit != 'true'
- env:
- GH_TOKEN: ${{ github.token }}
- run: |
- set -euo pipefail
- . tools/linuxfs/debian-image.env
- image=public.ecr.aws/docker/library/debian:bullseye
- if gh release download "$DEBIAN_IMAGE_TAG" -R "$GITHUB_REPOSITORY" -p "$DEBIAN_IMAGE_ASSET" -O /tmp/debian-image.tar.zst \
- && { [ -z "$DEBIAN_IMAGE_SHA256" ] || echo "$DEBIAN_IMAGE_SHA256 /tmp/debian-image.tar.zst" | sha256sum -c -; }; then
- zstd -dc /tmp/debian-image.tar.zst | docker load
- rm -f /tmp/debian-image.tar.zst
- else
- echo "::warning::the hosted Debian image could not be fetched; pulling from the registry instead"
- for attempt in 1 2 3 4 5; do
- docker pull "$image" && break
- [ "$attempt" -lt 5 ] || { echo "::error::could not pull $image after $attempt attempts"; exit 1; }
- echo "pull attempt $attempt failed (registry busy?); retrying in $((attempt * 30)) s"
- sleep $((attempt * 30))
- done
- fi
- docker image ls "$image"
-
- - name: Build the x86 preloads FEX guests load (glibc 2.31)
- if: steps.preloads.outputs.cache-hit != 'true'
- run: |
- set -euo pipefail
- docker run --rm -v "$PWD:/src" -w /src public.ecr.aws/docker/library/debian:bullseye bash -c '
- set -euo pipefail
- install_compilers() {
- apt-get -o Acquire::Check-Valid-Until=false update -qq &&
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends gcc g++ gcc-multilib g++-multilib binutils >/dev/null
- }
- printf "deb http://deb.debian.org/debian bullseye main\ndeb http://security.debian.org/debian-security bullseye-security main\n" > /etc/apt/sources.list
- if ! install_compilers; then
- printf "deb http://archive.debian.org/debian bullseye main\ndeb http://archive.debian.org/debian-security bullseye-security main\n" > /etc/apt/sources.list
- install_compilers
- fi
- tools/linuxfs/build-x86-preloads.sh app/src/main/assets/linuxfs
- '
- sudo chown -R "$(id -u):$(id -g)" app/src/main/assets/linuxfs
- ls -l app/src/main/assets/linuxfs/x86_64 app/src/main/assets/linuxfs/i386
-
- - name: Bundle the droiddeck-esync packs
- run: |
- set -euo pipefail
- if [ -f tools/droiddeck-esync/release.env ]; then
- . tools/droiddeck-esync/release.env
- release_url="https://github.com/${SYNC_BUNDLE_REPO}/releases/download/${SYNC_BUNDLE_TAG}"
- curl -fsSL --retry 3 -o sync-bundle.tzst "$release_url/$SYNC_BUNDLE_ASSET"
- echo "$SYNC_BUNDLE_SHA256 sync-bundle.tzst" | sha256sum -c -
- mkdir -p app/src/main/assets/droiddeck-esync
- tar --use-compress-program=unzstd -xf sync-bundle.tzst -C app/src/main/assets/droiddeck-esync
- rm sync-bundle.tzst
- curl -fsSL --retry 3 -o sync-index.json "$release_url/index.json"
- revoked=$(python3 -c 'import json, sys; print(" ".join(p["id"] for p in json.load(open(sys.argv[1]))["packs"] if p.get("revoked") is True))' sync-index.json)
- for id in $revoked; do
- if [ -e "app/src/main/assets/droiddeck-esync/packs/$id.tzst" ]; then
- echo "::warning::$SYNC_BUNDLE_ASSET carries revoked pack $id; it is left out of the APK (point tools/droiddeck-esync/release.env at a newer bundle)"
- rm -f "app/src/main/assets/droiddeck-esync/packs/$id.tzst"
- fi
- done
- rm sync-index.json
- test -f app/src/main/assets/droiddeck-esync/index.json
- test -f app/src/main/assets/droiddeck-esync/index.json.sig
- ls -lR app/src/main/assets/droiddeck-esync
- fi
-
- - name: Cache PulseAudio 13.0 source
- id: pa-src
- uses: actions/cache@v4
- with:
- path: pa13
- key: pulseaudio-src-13.0
- - name: Fetch PulseAudio 13.0 source
- if: steps.pa-src.outputs.cache-hit != 'true'
- run: |
- set -euo pipefail
- curl -fsSL -o pa.tar.gz https://github.com/pulseaudio/pulseaudio/archive/refs/tags/v13.0.tar.gz
- mkdir -p pa13 && tar -xzf pa.tar.gz -C pa13 --strip-components=1 && rm pa.tar.gz
- - name: Fetch DirectAudio (tools/directaudio/release.env)
- run: tools/directaudio/fetch.sh "$PWD" "$PWD/sink-out"
- - name: Build the AAudio sink into the audio bundle
- run: |
- set -euo pipefail
- export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
- tools/aaudio-sink/build.sh "$PWD/pa13" "$PWD/sink-out"
- rm -rf pa-bundle && mkdir -p pa-bundle
- tar --use-compress-program=unzstd -xf app/src/main/assets/pulseaudio.tzst -C pa-bundle
- test ! -f pa-bundle/modules/arm64/module-aaudio-sink.so
- install -m755 sink-out/module-aaudio-sink.so pa-bundle/modules/arm64/module-aaudio-sink.so
- install -m755 sink-out/module-directaudio-native-sink.so pa-bundle/modules/arm64/module-directaudio-native-sink.so
- (cd pa-bundle && tar --use-compress-program='zstd -19' -cf ../pulseaudio.tzst .)
- mkdir -p app/build/prepared-assets
- mv pulseaudio.tzst app/build/prepared-assets/pulseaudio.tzst
- tar --use-compress-program=unzstd -tf app/build/prepared-assets/pulseaudio.tzst | grep -c '\.so$'
- rm -rf pa-bundle sink-out
- - name: Cache proot
- id: proot
- uses: actions/cache@v4
- with:
- path: |
- app/src/main/jniLibs/arm64-v8a/libproot.so
- app/src/main/jniLibs/arm64-v8a/libproot-loader.so
- key: proot-${{ env.NDK_VERSION }}-${{ hashFiles('tools/proot/**') }}
- - name: Build proot
- if: steps.proot.outputs.cache-hit != 'true'
- run: |
- set -euo pipefail
- export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
- tools/proot/build.sh app/src/main/jniLibs/arm64-v8a
-
- - name: Check the preloads
- run: |
- set -euo pipefail
- bash tools/linuxfs/check-preloads.sh app/src/main/assets/linuxfs
- D=app/src/main/assets/linuxfs
- syms() { readelf -Ws "$1" | awk '$4 == "FUNC" && $5 == "GLOBAL" {sub(/@.*/, "", $8); print $8}'; }
- # The bridge ICD: libc only, and nothing exported but the loader's three entry points.
- VKB="$D/usr/local/lib/vkbridge/libvulkan_droidbridge.so"
- test -f "$VKB" && test -f "$D/usr/local/share/vkbridge/droidbridge_icd.json" && test -f "$D/usr/local/bin/droiddeck-vkbridge-smoke"
- VKB_NEED=$(readelf -d "$VKB" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p' | grep -vx 'libc.so.6' | grep -vx 'ld-linux-aarch64.so.1' || true)
- [ -z "$VKB_NEED" ] || { echo "::error::the bridge ICD needs $VKB_NEED"; exit 1; }
- [ "$(syms "$VKB" | grep -c '^vk_icd')" = 3 ] || { echo "::error::the bridge ICD does not export the loader interface"; exit 1; }
-
- # Mali (Venus), David Cimo's route: the vtest server (jniLibs), the Venus ICD (assets/venus)
- # and the Mali compatibility layer (assets/linuxfs), built by build-venus.yml and fetched by
- # tag + sha256 like gamescope. The app uses it only on a GPU that is not an Adreno.
- - name: Fetch the Mali (Venus) component (tools/venus/release.env)
- env:
- GH_TOKEN: ${{ github.token }}
- run: |
- set -euo pipefail
- . tools/venus/release.env
- gh release download "${VENUS_TAG}" -R "${VENUS_REPO}" -p venus.tzst -O venus.tzst
- echo "${VENUS_SHA256} venus.tzst" | sha256sum -c -
- tar --use-compress-program=unzstd -xf venus.tzst -C app/src/main
- test -f app/src/main/jniLibs/arm64-v8a/libvirgl_test_server.so
- test -f app/src/main/assets/venus/libvulkan_virtio.so
- rm venus.tzst
-
- - name: Check Quest tracking IPC
- run: |
- set -euo pipefail
- NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
- VK_INCLUDE=$(ls -d "$NDK"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1)
- mkdir -p build/vr/include
- cp -R "$VK_INCLUDE/vulkan" build/vr/include/
- if [ -d "$VK_INCLUDE/vk_video" ]; then cp -R "$VK_INCLUDE/vk_video" build/vr/include/; fi
- g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_tracking.cpp -o /tmp/test-xr-tracking
- /tmp/test-xr-tracking
- g++ -std=c++17 -Wall -Wextra -Werror tools/vr/tests/test_xr_touch.cpp -o /tmp/test-xr-touch
- /tmp/test-xr-touch
- g++ -std=c++17 -Wall -Wextra -Werror tools/vr/tests/test_pad_controller_config.cpp -o /tmp/test-pad-controller-config
- /tmp/test-pad-controller-config
- g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_vsync.cpp -o /tmp/test-xr-vsync
- /tmp/test-xr-vsync
- g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_frames.cpp -o /tmp/test-xr-frames
- /tmp/test-xr-frames
- cc -Itools/vr/third_party/wayland -c tools/vr/src/wayland_client_stub.c -o /tmp/test-wayland-stub.o
- cc -Itools/vr/third_party/wayland -c app/src/main/cpp/waylandcomp/generated/xdg-shell-protocol.c -o /tmp/test-xdg-shell.o
- g++ -std=c++17 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -pthread -Ibuild/vr/include \
- -Itools/vr/third_party/wayland -Iapp/src/main/cpp/waylandcomp/generated \
- tools/vr/tests/test_presenter_shutdown.cpp tools/vr/src/presenter.cpp /tmp/test-wayland-stub.o /tmp/test-xdg-shell.o \
- -ldl -o /tmp/test-presenter-shutdown
- timeout 10 /tmp/test-presenter-shutdown
-
- name: Rust toolchain for the store engines (aarch64-linux-android)
id: rust
run: |
@@ -561,9 +466,10 @@ jobs:
~/.cargo/git/db
~/.cargo/bin/cargo-ndk
app/src/main/rust/stores/target
- key: stores-${{ steps.rust.outputs.rustc }}-${{ hashFiles('app/src/main/rust/stores/Cargo.lock') }}
+ key: stores-v2-${{ runner.os }}-${{ runner.arch }}-${{ env.NDK_VERSION }}-${{ steps.rust.outputs.rustc }}-${{ hashFiles('app/src/main/rust/stores/Cargo.lock') }}-${{ hashFiles('app/src/main/rust/stores/src/**', 'app/src/main/rust/stores/Cargo.toml', 'app/src/main/rust/stores/build.rs', 'app/src/main/rust/stores/.cargo/**', 'app/build.gradle') }}
restore-keys: |
- stores-${{ steps.rust.outputs.rustc }}-
+ stores-v2-${{ runner.os }}-${{ runner.arch }}-${{ env.NDK_VERSION }}-${{ steps.rust.outputs.rustc }}-${{ hashFiles('app/src/main/rust/stores/Cargo.lock') }}-
+ stores-v2-${{ runner.os }}-${{ runner.arch }}-${{ env.NDK_VERSION }}-${{ steps.rust.outputs.rustc }}-
- name: cargo-ndk
run: |
@@ -581,18 +487,26 @@ jobs:
restore-keys: |
cxx-${{ env.NDK_VERSION }}-
+ - uses: actions/download-artifact@v4
+ with:
+ name: prepared-components
+ path: app/build
+ - name: Verify and unpack prepared components
+ env:
+ SOURCE_TREE: ${{ needs.source.outputs.tree-sha }}
+ run: python3 tools/components/prepare.py unpack --tree "$SOURCE_TREE"
+
- uses: actions/download-artifact@v4
with:
name: xbox-arm64
path: app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
- - name: Build GOG Galaxy companion
- if: steps.preloads.outputs.cache-hit != 'true'
- run: |
- rustup toolchain install 1.90.0 --profile minimal
- rustup target add --toolchain 1.90.0 aarch64-unknown-linux-gnu
- RUSTUP_TOOLCHAIN=1.90.0 bash tools/comet/build.sh
-
+ - name: Cache checksum-pinned pack inputs
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/droiddeck-pack-inputs
+ key: pack-inputs-v1-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env') }}
+ restore-keys: pack-inputs-v1-
- name: Build the add-on packs
run: bash tools/packs/build.sh app/build/packs
@@ -603,7 +517,6 @@ jobs:
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
run: |
set -o pipefail
- python3 tools/quest/build-driver.py "$ANDROID_HOME/ndk/$NDK_VERSION"
python3 tools/powervr/fetch.py
python3 tools/release/runtime_inputs.py record
./gradlew assembleRelease --console=plain -PndkVersion="$NDK_VERSION" 2>&1 | tee /tmp/build.log
@@ -635,19 +548,11 @@ jobs:
path: app/src/main/rust/stores/Cargo.lock
if-no-files-found: ignore
- - name: Install Python test dependencies
- run: |
- sudo apt-get update -qq
- sudo apt-get install -y -qq python3-yaml
-
- - name: Steam import and game environment tests
- run: |
- # The Xclipse layer regression test compiles the layer against the distribution's headers.
- sudo apt-get update -qq && sudo apt-get install -y -qq libvulkan-dev >/dev/null
- python3 -m unittest discover -s tools/tests -p 'test_*.py'
-
- name: Unit tests
id: unit-tests
+ env:
+ DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
+ SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
run: |
set -o pipefail
mkdir -p app/build
@@ -723,86 +628,84 @@ jobs:
TEST_DIAGNOSTICS_URL: ${{ steps.unit-test-diagnostics.outputs.artifact-url }}
APK_OUTCOME: ${{ steps.apk-upload.outcome }}
SAME_REPO: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
+ run: bash tools/release/report-build.sh
+
+ python-tests:
+ name: Python and native regression tests
+ needs: source
+ if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Merge the pinned APK base
+ if: github.event_name == 'pull_request'
+ env:
+ BUILD_BASE_SHA: ${{ needs.source.outputs.base-sha }}
run: |
- set -uo pipefail
- MARK=""
- {
- echo "$MARK"
- echo "## Build of this pull request"
- echo
- [ -f /tmp/pr-merge.md ] && cat /tmp/pr-merge.md
- echo
- case "$BUILD_OUTCOME:$UNIT_TEST_OUTCOME:$APK_OUTCOME" in
- success:success:success)
- echo "### Build passed"
- echo
- echo "The \`droiddeck-apk\` artifact is [on this run]($RUN_URL), signed with the public test key."
- echo
- if [ "$SAME_REPO" = true ]; then
- echo "A release-signed tester build that installs over Stable or Preview is being published now and will appear in DroidDeck's **Test builds** list. Label the PR \`no-test-build\` to skip that."
- else
- echo "**Maintainer:** add the \`publish-test\` label to publish a release-signed tester build that installs over Stable or Preview and appears in DroidDeck's **Test builds** list. The label is removed automatically after publishing."
- fi
- echo
- echo "Fallback: [open **PR Release Publish**]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/workflows/pr-release-publish.yml) on \`main\` and enter PR \`$PR\`."
- ;;
- success:success:*)
- echo "### APK publication incomplete"
- echo
- echo "Compilation and unit tests passed, but APK publication did not complete. See [the run]($RUN_URL)."
- ;;
- success:failure:*)
- echo "### ERROR: Unit tests failed"
- echo
- echo "The APK compiled, but unit tests failed. No installable artifact was published."
- echo
- if [ -n "$TEST_DIAGNOSTICS_URL" ]; then
- echo "The [unit-test-results]($TEST_DIAGNOSTICS_URL) artifact contains the test log and any generated reports."
- else
- echo "The test diagnostics upload did not complete. See [the test log]($RUN_URL)."
- fi
- ;;
- success:*)
- echo "### Build incomplete"
- echo
- echo "The APK compiled, but unit tests did not complete successfully. See [the run]($RUN_URL)."
- ;;
- failure:*)
- echo "### ERROR: Build failed"
- echo
- echo "The compiler's errors ([full log]($RUN_URL)):"
- echo
- echo '```'
- { grep -E '^e: |^w: .*error|error:|CMake Error|fatal error|ninja: error|FAILED|What went wrong|Execution failed for task|Unresolved reference|Type mismatch|Unresolved' /tmp/build.log 2>/dev/null \
- | sed -e 's#file:///home/runner/work/[^/]*/[^/]*/##' -e 's#/home/runner/work/[^/]*/[^/]*/##' \
- | grep -v '^w: ' | awk '!seen[$0]++' | head -80; } || true
- echo '```'
- echo
- echo "What went wrong (Gradle)
"
- echo
- echo '```'
- awk '/^\* What went wrong/{p=1} /^\* Try:/{p=0} p{print}' /tmp/build.log 2>/dev/null | head -60
- echo '```'
- echo " "
- ;;
- skipped:*|cancelled:*)
- echo "### Not built"
- echo
- echo "The build did not run (see above, or [the run]($RUN_URL))."
- ;;
- esac
- echo
- } > /tmp/pr-report.md
- cat /tmp/pr-report.md >> "$GITHUB_STEP_SUMMARY"
- ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" --paginate --jq ".[] | select(.body | startswith(\"$MARK\")) | .id" | head -1 || true)
- if [ -n "$ID" ]; then
- gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${ID}" -F body=@/tmp/pr-report.md >/dev/null
- else
- gh api -X POST "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" -F body=@/tmp/pr-report.md >/dev/null
- fi
+ set -euo pipefail
+ git fetch --no-tags origin "$BUILD_BASE_SHA"
+ git config user.name "ci"
+ git config user.email "ci@users.noreply.github.com"
+ git merge --no-ff --no-edit FETCH_HEAD
+ - name: Verify backend and test source match
+ env:
+ XBOX_SOURCE_TREE: ${{ needs.source.outputs.tree-sha }}
+ run: test "$(git rev-parse 'HEAD^{tree}')" = "$XBOX_SOURCE_TREE"
+ - name: Install Python test dependencies
+ timeout-minutes: 7
+ run: bash tools/ci/install-ubuntu-packages.sh python3-yaml gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user libvulkan-dev mesa-vulkan-drivers
+ - name: Resolve the pinned Android NDK
+ run: bash tools/ci/resolve-ndk.sh
+
+ - name: Check Quest tracking IPC
+ run: |
+ set -euo pipefail
+ NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
+ VK_INCLUDE=$(ls -d "$NDK"/toolchains/llvm/prebuilt/*/sysroot/usr/include | head -1)
+ mkdir -p build/vr/include
+ cp -R "$VK_INCLUDE/vulkan" build/vr/include/
+ if [ -d "$VK_INCLUDE/vk_video" ]; then cp -R "$VK_INCLUDE/vk_video" build/vr/include/; fi
+ g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_tracking.cpp -o /tmp/test-xr-tracking
+ /tmp/test-xr-tracking
+ g++ -std=c++17 -Wall -Wextra -Werror tools/vr/tests/test_xr_touch.cpp -o /tmp/test-xr-touch
+ /tmp/test-xr-touch
+ g++ -std=c++17 -Wall -Wextra -Werror tools/vr/tests/test_pad_controller_config.cpp -o /tmp/test-pad-controller-config
+ /tmp/test-pad-controller-config
+ g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_vsync.cpp -o /tmp/test-xr-vsync
+ /tmp/test-xr-vsync
+ g++ -std=c++17 -Wall -Wextra -Werror -pthread tools/vr/tests/test_xr_frames.cpp -o /tmp/test-xr-frames
+ /tmp/test-xr-frames
+ cc -Itools/vr/third_party/wayland -c tools/vr/src/wayland_client_stub.c -o /tmp/test-wayland-stub.o
+ cc -Itools/vr/third_party/wayland -c app/src/main/cpp/waylandcomp/generated/xdg-shell-protocol.c -o /tmp/test-xdg-shell.o
+ g++ -std=c++17 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -pthread -Ibuild/vr/include \
+ -Itools/vr/third_party/wayland -Iapp/src/main/cpp/waylandcomp/generated \
+ tools/vr/tests/test_presenter_shutdown.cpp tools/vr/src/presenter.cpp /tmp/test-wayland-stub.o /tmp/test-xdg-shell.o \
+ -ldl -o /tmp/test-presenter-shutdown
+ timeout 10 /tmp/test-presenter-shutdown
+
+ - name: Steam import and game environment tests
+ run: python3 -m unittest discover -s tools/tests -p 'test_*.py'
+
+ checks:
+ name: Compile and test APK
+ needs: [build, python-tests]
+ if: ${{ always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ steps:
+ - name: Require compilation and every test job
+ env:
+ BUILD_RESULT: ${{ needs.build.result }}
+ PYTHON_RESULT: ${{ needs.python-tests.result }}
+ run: test "$BUILD_RESULT" = success && test "$PYTHON_RESULT" = success
sign:
- needs: build
+ needs: [build, checks]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
permissions:
contents: read
@@ -814,7 +717,7 @@ jobs:
secrets: inherit
packs:
- needs: build
+ needs: [build, checks]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
permissions:
contents: read
@@ -834,6 +737,10 @@ jobs:
CI_REPO: Droid-Deck/DroidDeck-CI
KEEP: 10
steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
- uses: actions/download-artifact@v4
with:
pattern: droiddeck-signed-*
@@ -851,72 +758,13 @@ jobs:
- name: Describe the change
env:
GH_TOKEN: ${{ github.token }}
- run: |
- set -euo pipefail
- pr=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" \
- --jq '[.[] | select(.merged_at != null and .base.ref == "main")] | first // empty')
- if [ -n "$pr" ]; then
- number=$(jq -r .number <<<"$pr")
- title=$(jq -r .title <<<"$pr")
- merged=$(jq -r '.merged_at[:10]' <<<"$pr")
- summary=$(jq -r '.body // ""' <<<"$pr" | tr -d '\r' | { grep -v '^🤖' || true; } |
- awk '!p && /^#/ { next } NF { p = 1; print; next } p { exit }' | head -n 6 | cut -c1-400)
- {
- echo "**Merged to main** - [PR #$number]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$number): $title (merged $merged)"
- if [ -n "$summary" ]; then
- echo
- echo "$summary"
- fi
- } > notes-head.md
- else
- subject=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA" --jq '.commit.message | split("\n")[0]')
- echo "**Pushed to main** without a PR - $subject" > notes-head.md
- fi
- cat notes-head.md
+ run: bash tools/release/describe-build.sh
- name: Publish to DroidDeck-CI
id: publish
env:
GH_TOKEN: ${{ steps.ci-token.outputs.token }}
- run: |
- set -euo pipefail
- tag=main-${GITHUB_SHA::7}
- cat signed/SHA256SUMS-*.txt > signed/SHA256SUMS.txt
- rm signed/SHA256SUMS-*.txt
- notes="$(cat notes-head.md)
-
- Signed build of $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA - in main, not yet in a DroidDeck release; for testing.
- Commit: $GITHUB_SHA
- VersionCode: $(sed -n 's/^ *versionCode \([0-9][0-9]*\)$/\1/p' app/build.gradle)
- Each apk installs over a DroidDeck release and keeps its data. \`standard\` is the normal app; the others are the same app under another package name, installed beside it.
-
- SHA-256:
- \`\`\`
- $(cat signed/SHA256SUMS.txt)
- \`\`\`"
- gh release delete "$tag" -R "$CI_REPO" --yes --cleanup-tag 2>/dev/null || true
- gh release create "$tag" -R "$CI_REPO" --target main --prerelease \
- --title "main ${GITHUB_SHA::7}" --notes "$notes" signed/*
- gh release list -R "$CI_REPO" -L 200 --json tagName,publishedAt \
- --jq '[.[] | select(.tagName | startswith("main-"))] | sort_by(.publishedAt) | reverse | .['"$KEEP"':][] | .tagName' |
- while IFS= read -r old; do
- if [ "$old" = "$tag" ]; then
- continue
- fi
- if ! gh release delete "$old" -R "$CI_REPO" --yes --cleanup-tag 2>/dev/null; then
- if gh release view "$old" -R "$CI_REPO" >/dev/null 2>&1; then
- echo "::error::Could not delete old release $old"
- exit 1
- fi
- fi
- done
- published=$(gh release view "$tag" -R "$CI_REPO" --json tagName,assets)
- jq -e --arg tag "$tag" '.tagName == $tag and (.assets | length) > 0' <<< "$published" >/dev/null
- url="$GITHUB_SERVER_URL/$CI_REPO/releases/tag/$tag"
- apk=$(cd signed && ls DroidDeck-*.apk | awk 'length(a) == 0 || length($0) < length(a) { a = $0 } END { print a }')
- echo "release=$url" >> "$GITHUB_OUTPUT"
- echo "apk=$GITHUB_SERVER_URL/$CI_REPO/releases/download/$tag/$apk" >> "$GITHUB_OUTPUT"
- echo "Published $url"
+ run: bash tools/release/publish-ci.sh
- name: Post the Preview build to Discord
env:
@@ -924,26 +772,8 @@ jobs:
GH_TOKEN: ${{ github.token }}
RELEASE: ${{ steps.publish.outputs.release }}
APK: ${{ steps.publish.outputs.apk }}
- run: |
- set -euo pipefail
- if [ -z "$WEBHOOK" ]; then
- echo "::notice::No DISCORD_BUILDS_WEBHOOK secret; nothing posted"
- exit 0
- fi
- commit=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA")
- subject=$(jq -r '.commit.message | split("\n")[0]' <<<"$commit")
- title=$(jq -r '.commit.message | split("\n") | map(select(length > 0)) | .[1] // ""' <<<"$commit")
- pr=$(sed -n 's/^Merge pull request #\([0-9]*\).*/\1/p' <<<"$subject")
- if [ -n "$pr" ]; then
- what="[#$pr]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$pr): ${title:-$subject}"
- else
- what="[\`${GITHUB_SHA::7}\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA): $subject"
- fi
- get=$(printf 'Download: [standard APK](<%s>) · [all variants](<%s>)' "$APK" "$RELEASE")
- content=$(printf '**New signed Preview build** `main-%s`\n%s\nIn the app: **Updates → Preview**\n%s' "${GITHUB_SHA::7}" "$what" "$get")
- jq -n --arg content "$content" '{content: $content, allowed_mentions: {parse: []}}' |
- curl -fsS -H 'Content-Type: application/json' -d @- "$WEBHOOK" -o /dev/null
- echo "Posted: $content"
+ run: bash tools/release/announce-preview.sh
+
catalog:
needs: announce
diff --git a/README.md b/README.md
index 0a67b26744..dde1ce3a25 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,16 @@ DroidDeck brings the SteamOS experience to Android: Valve's Steam client in Big

+
+
+
+
+
+
+
+
+
+

> Note: DroidDeck does not have a stand-alone website. Do not click on any download links from websites claiming to be the DroidDeck team.
@@ -47,7 +57,7 @@ Compatibility and performance vary by device; hardware validation is limited. De
## Credits and licence
-GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve.
+GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. The proot fast path picks the guest name of a host file bound under several names in the order [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later) sorts its bindings, so links and `/proc/self/fd` read back as they do through proot. The session's [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) opens its sockets with the per-socket access settings documented in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions through its `access.rules`. Wine write watches use the userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later): libblsession gives it the arm64 syscall number and answers its `PAGEMAP_SCAN` from `/proc/self/pagemap` where Android refuses the ioctl. Wine on arm64 sets a thread's full context by raising `SIGUSR2` from `syscall_dispatcher_return_slowpath` in [Wine](https://gitlab.winehq.org/wine/wine)'s `dlls/ntdll/unix/signal_arm64.c` (LGPL-2.1-or-later); libblsession runs that handler in place on a frame laid out as the [Linux](https://github.com/torvalds/linux) kernel's `arch/arm64/kernel/signal.c` builds it and returns through `rt_sigreturn`, so proot does not stop the thread for it. Wine's process list reads each process's memory counters from `/proc//status` in `fill_vm_counters` ([Wine](https://gitlab.winehq.org/wine/wine) `dlls/ntdll/unix/process.c`, LGPL-2.1-or-later), so libblsession gives those reads the kernel's file instead of a copy with `TracerPid` cleared. droiddeck-ntsync is checked against the object, wait and error semantics documented for the [Linux](https://github.com/torvalds/linux) ntsync driver in `Documentation/userspace-api/ntsync.rst` (GPL-2.0). Xbox games load the Windows modules of [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) runtime (LGPL-2.1-or-later), including its `wintypes.dll`, whose `ApiInformation` answer Minecraft for Windows needs to start; how Minecraft installs GameInput under Wine was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT). See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve.
XR glasses support builds on WinNative's VITURE glasses work. VITURE protocol details were checked against [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) by [@wheaney](https://github.com/wheaney), including the VITURE protocol header it ships, [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) by [@badicsalex](https://github.com/badicsalex) and the [go-macos/iokit VITURE package](https://pkg.go.dev/github.com/go-macos/iokit/viture); the optional VITURE SDK belongs to VITURE and is not included. RayNeo support adapts [@informalTechCode](https://github.com/informalTechCode)'s [RayNeo-Air-Series-3DoF-Scaffold](https://github.com/informalTechCode/RayNeo-Air-Series-3DoF-Scaffold) (Apache-2.0) and references [@verncat](https://github.com/verncat)'s [RayNeo-Air-3S-Pro-OpenVR](https://github.com/verncat/RayNeo-Air-3S-Pro-OpenVR) (MIT) and [Monado](https://gitlab.freedesktop.org/monado/monado) (BSL-1.0); see [docs/third-party/rayneo](docs/third-party/rayneo/README.md). XREAL 1S support references [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) and [xrealOneDeviceKit](https://github.com/wheaney/xrealOneDeviceKit) by @wheaney, [xreal_one_driver](https://github.com/rohitsangwan01/xreal_one_driver) by [@rohitsangwan01](https://github.com/rohitsangwan01) (MIT) and [xr-tools](https://github.com/0xcaff/xr-tools) by [@0xcaff](https://github.com/0xcaff). Rokid support follows the Rokid protocol notes in [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) and @badicsalex's [Void Computing write-ups](https://voidcomputing.hu/blog/worse-better-prettier/), and [Monado](https://gitlab.freedesktop.org/monado/monado)'s Rokid driver. The REDMAGIC glasses-display findings draw on [@mekhontsev](https://github.com/mekhontsev)'s [MagicDesk investigation](https://github.com/mekhontsev/magicdesk/blob/main/docs/xr-resolution-fix.md) and [@Coding-BR](https://github.com/Coding-BR)'s [decompiled Nubia kernel](https://github.com/Coding-BR/android_kernel_nubia_sm8850_qwjujube). VITURE, RayNeo, XREAL, Rokid and REDMAGIC are trademarks of their owners; this project is not affiliated with them.
@@ -56,3 +66,5 @@ Joy-Con VR controllers port the arm model of Google's [Google VR SDK for Unity](
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. Chromium and Electron apps from Flathub start their browser processes through [zypak](https://github.com/refi64/zypak) by [@refi64](https://github.com/refi64) (BSD-3-Clause); its source was read to see that it always spawns them through Flatpak's spawn portal, which is why DroidDeck starts them directly without Chromium's sandbox instead.
+
+Steam's Browse buttons open a GTK 3 file chooser through PyGObject (LGPL-2.1-or-later). It runs under Steam's own `reaper` with Steam's app ID, which [gamescope](https://github.com/ValveSoftware/gamescope) (BSD-2-Clause) reads from the process tree (`GetAppIdFromReaper` in `src/Utils/Process.cpp`) to show it over Steam.
diff --git a/app/build.gradle b/app/build.gradle
index f5daf81823..22fe1f953a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -80,7 +80,7 @@ def sourceCommit = providers.environmentVariable('DROIDDECK_SOURCE_COMMIT').getO
def prNumber = (providers.environmentVariable('DROIDDECK_PR_NUMBER').getOrNull() ?: '0').with { it.isInteger() ? it : '0' }
def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true'
def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim()
-def commitTime = (gitValue(['show', '-s', '--format=%ct', 'HEAD']) ?: '0').with { it.isLong() ? it : '0' }
+def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' }
def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines()
.findAll { it.contains('=') && !it.startsWith('#') }
.collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] }
@@ -122,8 +122,8 @@ android {
applicationId "com.droiddeck.launcher"
minSdkVersion 26
targetSdkVersion 28
- versionCode 14
- versionName "0.5.0"
+ versionCode 15
+ versionName "0.6.0"
buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\""
buildConfigField "String", "SOURCE_COMMIT", "\"${sourceCommit}\""
buildConfigField "int", "PR_NUMBER", "${prNumber}"
@@ -223,6 +223,10 @@ android {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
unitTests.all {
+ if (ciBuild) {
+ outputs.upToDateWhen { false }
+ outputs.doNotCacheIf('CI executes the test suite on every run') { true }
+ }
// Robolectric keeps a sandbox per SDK level the tests ask for; seven no longer fit in Gradle's default 512 MB.
maxHeapSize = '2g'
def logTarget = providers.systemProperty('robolectric.logging').orNull
@@ -367,6 +371,8 @@ dependencies {
implementation 'androidx.camera:camera-camera2:1.4.2'
implementation 'androidx.camera:camera-lifecycle:1.4.2'
implementation 'androidx.webkit:webkit:1.12.1'
+ // Google's WebRTC (BSD) for the native Xbox Cloud Gaming player (XboxNativePlayerActivity).
+ implementation 'io.github.webrtc-sdk:android:125.6422.07'
implementation("com.google.mediapipe:tasks-vision:${trackingPack.MEDIAPIPE_VERSION}") {
exclude group: 'com.google.auto.value', module: 'auto-value'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5439940930..29718e0879 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -34,6 +34,7 @@
android:localeConfig="@xml/locales_config"
android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="false"
+ android:allowAudioPlaybackCapture="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
@@ -61,7 +62,7 @@
@@ -84,8 +85,8 @@
@@ -97,7 +98,7 @@
@@ -151,6 +152,27 @@
android:process=":xboxlogin" android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density"
android:theme="@style/AppTheme" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/assets/xcloud/player.js b/app/src/main/assets/xcloud/player.js
new file mode 100644
index 0000000000..3d3762149d
--- /dev/null
+++ b/app/src/main/assets/xcloud/player.js
@@ -0,0 +1,187 @@
+/* DroidDeck Xbox Cloud Gaming player. Includes Greenlight's player (c) UnknownSKL (Jim Kroon), MIT. */
+(()=>{var _=class{_player;_dataChannel;constructor(e){this._player=e,this._dataChannel=this._player._peerConnection.createDataChannel(this.getChannelName(),this.getChannelConfig()),this._dataChannel.onopen=this.onOpen.bind(this),this._dataChannel.onmessage=this.onMessage.bind(this),this._dataChannel.onclosing=this.onClosing.bind(this),this._dataChannel.onclose=this.onClose.bind(this),this._dataChannel.onerror=this.onError.bind(this)}getChannelName(){return"channel"}getChannelConfig(){return{}}onOpen(e){console.log(this.getChannelName(),"Opening channel:",e)}onMessage(e){console.log(this.getChannelName(),"Message channel:",e)}onClosing(e){console.log(this.getChannelName(),"Closing channel:",e)}onClose(e){console.log(this.getChannelName(),"Closed channel:",e)}onError(e){console.log(this.getChannelName(),"Error channel:",e)}send(e){if(this._dataChannel.readyState!=="open"){console.log("["+this.getChannelName()+"] Tried to send data while channel is not open. readyState is:",this._dataChannel.readyState);return}return typeof e=="string"&&(e=new TextEncoder().encode(e)),this._dataChannel.send(e)}getPlayer(){return this._player}destroy(){}};var S=class extends _{_micPermissions="prompt";_micStream;constructor(e){super(e),navigator.permissions.query({name:"microphone"}).then(t=>{this._micPermissions=t.state,t.onchange=()=>{this._micPermissions=t.state}})}getChannelName(){return"chat"}getChannelConfig(){return{ordered:!0,protocol:"chatV1"}}destroy(){}};var v=class r{_player;_index;_physicalGamepadId=-1;_rumbleInterval;_isFocused=!0;_gamepadOverride={buttons:{}};_options={enable_keyboard:!1,enable_gamepad:!0,enable_vibration:!0,keyboard_mapping:{A:"Enter",B:"Backspace",X:"x",Y:"y",DPadUp:"ArrowUp",DPadDown:"ArrowDown",DPadLeft:"ArrowLeft",DPadRight:"ArrowRight",LeftShoulder:"[",RightShoulder:"]",LeftThumb:"l",RightThumb:"r",LeftTrigger:"-",RightTrigger:"=",Menu:"m",View:"v",Nexus:"n"},gamepad_mapping:{A:"0",B:"1",X:"2",Y:"3",DPadUp:"12",DPadDown:"13",DPadLeft:"14",DPadRight:"15",LeftShoulder:"4",RightShoulder:"5",LeftThumb:"10",RightThumb:"11",LeftTrigger:"6",RightTrigger:"7",Menu:"9",View:"8",Nexus:"16"},gamepad_axes_mapping:{LeftThumbXAxis:"0",LeftThumbYAxis:"1",RightThumbXAxis:"2",RightThumbYAxis:"3"},gamepad_deadzone:.08,gamepad_force_capture:!1};_listener={keyDown:this.onKeyDown.bind(this),keyUp:this.onKeyUp.bind(this),gamepadConnected:this.onGamepadConnected.bind(this),gamepadDisconnected:this.onGamepadDisconnected.bind(this),windowFocus:this.onWindowFocus.bind(this),windowBlur:this.onWindowBlur.bind(this)};constructor(e,t={}){this._index=e,this._options={...this._options,...t}}attach(e){this._player=e,this._player._channels.control.sendGamepadState(this._index,!0,this),this._options.enable_keyboard===!0&&(window.addEventListener("keydown",this._listener.keyDown),window.addEventListener("keyup",this._listener.keyUp)),this._options.enable_gamepad===!0&&(window.addEventListener("gamepadconnected",this._listener.gamepadConnected),window.addEventListener("gamepaddisconnected",this._listener.gamepadDisconnected)),this._options.enable_gamepad===!0&&this._options.gamepad_force_capture===!1&&(window.addEventListener("blur",this._listener.windowBlur),window.addEventListener("focus",this._listener.windowFocus)),this.detectActiveGamepad()}detach(){if(this._player===void 0){console.log("[Gamepad] Player is not attached. this._player is:",this._player);return}this._player._channels.control.sendGamepadState(this._index,!1),this._physicalGamepadId=-1,this._rumbleInterval!==void 0&&clearInterval(this._rumbleInterval),this._options.enable_keyboard===!0&&(window.removeEventListener("keydown",this._listener.keyDown),window.removeEventListener("keyup",this._listener.keyUp)),this._options.enable_gamepad===!0&&(window.removeEventListener("gamepadconnected",this._listener.gamepadConnected),window.removeEventListener("gamepaddisconnected",this._listener.gamepadDisconnected)),this._options.enable_gamepad===!0&&this._options.gamepad_force_capture===!1&&(window.removeEventListener("blur",this._listener.windowBlur),window.removeEventListener("focus",this._listener.windowFocus))}sendButtonState(e,t){if(this._player===void 0){console.log("[Gamepad] Player is not attached. this._player is:",this._player);return}if(!(e in this.getDefaultFamepadFrame())){console.log("[Gamepad] Invalid button:",e);return}let n=this.getDefaultFamepadFrame();n.GamepadIndex=this._index,this._gamepadOverride.buttons[e]=t}onKeyDown(e){if(this._isFocused!==!1)for(let t in this._options.keyboard_mapping)this._options.keyboard_mapping[t]===e.key&&(this._gamepadOverride.buttons[t]=1,e.preventDefault())}onKeyUp(e){if(this._isFocused!==!1)for(let t in this._options.keyboard_mapping)this._options.keyboard_mapping[t]===e.key&&(this._gamepadOverride.buttons[t]=0,e.preventDefault())}onWindowFocus(){this._isFocused=!0}onWindowBlur(){}getDefaultFamepadFrame(){return{GamepadIndex:0,Nexus:0,Menu:0,View:0,A:0,B:0,X:0,Y:0,DPadUp:0,DPadDown:0,DPadLeft:0,DPadRight:0,LeftShoulder:0,RightShoulder:0,LeftThumb:0,RightThumb:0,LeftThumbXAxis:0,LeftThumbYAxis:0,RightThumbXAxis:0,RightThumbYAxis:0,LeftTrigger:0,RightTrigger:0}}detectActiveGamepad(){if(this._physicalGamepadId<0)for(let e in navigator.getGamepads()){let t=navigator.getGamepads()[e]?.index;if(t===void 0)continue;let n=!1;for(let i in this._player?._channels.control.getGamepadHandlers())if(this._player?._channels.control.getGamepadHandlers()[i]instanceof r&&(this._player?._channels.control.getGamepadHandlers()[i])._physicalGamepadId===navigator.getGamepads()[e]?.index){console.log("[Gamepad] Active gamepad already detected:",t,(this._player?._channels.control.getGamepadHandlers()[i])._physicalGamepadId),n=!0;continue}n===!1&&(this._physicalGamepadId=t,console.log("[Gamepad] Active gamepad detected:",this._physicalGamepadId))}else console.log("[Gamepad] Physical gamepad already detected:",this._physicalGamepadId)}onGamepadConnected(e){if(this._physicalGamepadId<0){for(let t in this._player?._channels.control.getGamepadHandlers())if(this._player?._channels.control.getGamepadHandlers()[t]instanceof r&&(this._player?._channels.control.getGamepadHandlers()[t])._physicalGamepadId===e.gamepad.index)return;this._physicalGamepadId=e.gamepad.index}}onGamepadDisconnected(e){e.gamepad.index===this._physicalGamepadId&&(this._physicalGamepadId=-1)}hasOverrideButtons(){return Object.keys(this._gamepadOverride.buttons).length>0}getGamepadState(){let e=this.getGamepad(this._physicalGamepadId);if((this._physicalGamepadId<0||e===void 0||this._isFocused===!1)&&this.hasOverrideButtons()===!1)return;let t=this.getDefaultFamepadFrame();if(t.GamepadIndex=this._index,e!==void 0){for(let i in this._options.gamepad_mapping)t[i]=e.buttons[this._options.gamepad_mapping[i]]?.value??0;for(let i in this._options.gamepad_axes_mapping)t[i]=this.normaliseAxis(e.axes[this._options.gamepad_axes_mapping[i]]??0)}for(let i in this._gamepadOverride.buttons)t[i]=this._gamepadOverride.buttons[i];let n=[];for(let i in this._gamepadOverride.buttons)this._gamepadOverride.buttons[i]===0&&n.push(i);for(let i of n)delete this._gamepadOverride.buttons[i];return t.View>0&&t.Menu>0&&(t.View=0,t.Menu=0,t.Nexus=1),t}getGamepad(e=-1){let t=navigator.getGamepads()[e];if(t!==null)return t}getPhysicalGamepadId(){return this._physicalGamepadId}handleVibration(e){if(this._physicalGamepadId<0){console.log("[Gamepad] Received a vibration report but no physical gamepad is connected");return}let t=this.getGamepad(this._physicalGamepadId);if(t===void 0){console.log("[Gamepad] Received a vibration report but no physical gamepad is connected");return}if(this._options.enable_vibration===!1)return;let n={startDelay:0,duration:e.durationMs,weakMagnitude:e.rightMotorPercent*(window.__ddRumble??1),strongMagnitude:e.leftMotorPercent*(window.__ddRumble??1),leftTrigger:e.leftTriggerMotorPercent,rightTrigger:e.rightTriggerMotorPercent};if(t.vibrationActuator?.type==="dual-rumble"){let i=e.rightMotorPercent<.6?(.6-e.rightMotorPercent)/2:0,a=(e.leftTriggerMotorPercent+e.rightTriggerMotorPercent)/4,s=Math.min(i,a);if(n.weakMagnitude=Math.min(1,(e.rightMotorPercent+s)*(window.__ddRumble??1)),n.leftTrigger=0,n.rightTrigger=0,t.vibrationActuator?.playEffect("dual-rumble",n),clearInterval(this._rumbleInterval),e.repeat>0){let o=e.repeat;this._rumbleInterval=setInterval(()=>{o<=0&&clearInterval(this._rumbleInterval),t.vibrationActuator!==void 0&&t.vibrationActuator?.playEffect("dual-rumble",n),o--},e.delayMs+e.durationMs)}}else console.log("[Gamepad] Unknown vibration type:",t.vibrationActuator.type)}normaliseAxis(e){return Math.abs(e)0&&(this._reportType|=1,s=s+this._calculateMetadataSize(e),this._metadataFrames=e),t.length>0&&(this._reportType|=2,s=s+this._calculateGamepadSize(t),this._gamepadFrames=t),n.length>0&&(this._reportType|=4,s=s+this._calculatePointerSize(n),this._pointerFrames=n),i.length>0&&(this._reportType|=32,s=s+this._calculateMouseSize(i),this._mouseFrames=i),a.length>0&&(this._reportType|=64,s=s+this._calculateKeyboardSize(a),this._keyboardFrames=a),this._totalSize=s}_calculateMetadataSize(e){return 1+7*4*e.length}_calculateGamepadSize(e){return 1+23*e.length}_calculatePointerSize(e){let t=1;for(let n in e)t=t+1+e[n].events.length*20;return t}_calculateMouseSize(e){return 1+18*e.length}_calculateKeyboardSize(e){return 1+3*e.length}_writeMetadataData(e,t,n){e.setUint8(t,n.length),t++,n.length>=30&&console.warn("metadataQueue is bigger then 30. This might impact reliability!");for(let i=0;i=30&&console.warn("gamepadQueue is bigger then 30. This might impact reliability!");for(let i=0;i0&&(s|=2),a.Menu>0&&(s|=4),a.View>0&&(s|=8),a.A>0&&(s|=16),a.B>0&&(s|=32),a.X>0&&(s|=64),a.Y>0&&(s|=128),a.DPadUp>0&&(s|=256),a.DPadDown>0&&(s|=512),a.DPadLeft>0&&(s|=1024),a.DPadRight>0&&(s|=2048),a.LeftShoulder>0&&(s|=4096),a.RightShoulder>0&&(s|=8192),a.LeftThumb>0&&(s|=16384),a.RightThumb>0&&(s|=32768),e.setUint16(t,s,!0),e.setInt16(t+2,this._normalizeAxisValue(a.LeftThumbXAxis),!0),e.setInt16(t+4,this._normalizeAxisValue(-a.LeftThumbYAxis),!0),e.setInt16(t+6,this._normalizeAxisValue(a.RightThumbXAxis),!0),e.setInt16(t+8,this._normalizeAxisValue(-a.RightThumbYAxis),!0),e.setUint16(t+10,this._normalizeTriggerValue(a.LeftTrigger),!0),e.setUint16(t+12,this._normalizeTriggerValue(a.RightTrigger),!0),e.setUint32(t+14,1,!0),e.setUint32(t+18,1,!1),t+=22}return t}_writePointerData(e,t,n){e.setUint8(t,1),t++,n.length>=2&&console.warn("pointerQueue is bigger then 1. Only one event will be sent.");let i=n[0];if(i!==void 0){e.setUint8(t,i.events.length),t++;let a=this._serverVideoWidth,s=this._serverVideoHeight;for(let o=0;o=30&&console.warn("mouseQueue is bigger then 30. This might impact reliability!");for(let i=0;i=30&&console.warn("keyboardQueue is bigger then 30. This might impact reliability!");for(let i=0;i0&&(n=this._writeMetadataData(t,n,this._metadataFrames)),this._gamepadFrames.length>0&&(n=this._writeGamepadData(t,n,this._gamepadFrames)),this._pointerFrames.length>0&&(n=this._writePointerData(t,n,this._pointerFrames)),this._mouseFrames.length>0&&(n=this._writeMouseData(t,n,this._mouseFrames)),this._keyboardFrames.length>0&&(n=this._writeKeyboardData(t,n,this._keyboardFrames)),this._reportType===8&&(t.setUint8(n,this._maxTouchpoints),n++),n!==n)throw new Error("Packet length mismatch. Something is wrong!");return t}_normalizeTriggerValue(e){return e<=0||Number.isNaN(e)?0:e>=1?65535:e*65535|0}_normalizeAxisValue(e){let i=Math.round(e*32767);return i>32767?32767:i<-32767?-32767:i}};var F=class{_player;_inputSequenceNum=0;_metadataQueue=[];_gamepadQueue=[];_pointerQueue=[];_mouseQueue=[];_keyboardQueue=[];_gamepadHeartbeatTimers=new Map;_lastGamepadState=new Map;_axisChangeThreshold=.08;constructor(e){this._player=e}_hasQueuedData(){return this._metadataQueue.length>0||this._gamepadQueue.length>0||this._pointerQueue.length>0||this._mouseQueue.length>0||this._keyboardQueue.length>0}_upsertGamepadFrame(e){for(let t=0;tthis._axisChangeThreshold||o>.15)return!0}for(let a of i)if(Math.abs(e[a]-t[a])>.01)return!0;return!1}_isHeartbeatDue(e){let t=this._gamepadHeartbeatTimers.get(e)??0;return performance.now()-t>33}queueMetadataFrame(e){this._metadataQueue.push(e),this.checkQueueAndSend()}queueGamepadFrame(e){let t=this._lastGamepadState.get(e.GamepadIndex),n=this._hasSignificantAxisChange(e,t),i=this._isHeartbeatDue(e.GamepadIndex);(n||i)&&(this._upsertGamepadFrame(e),this._lastGamepadState.set(e.GamepadIndex,e),this._gamepadHeartbeatTimers.set(e.GamepadIndex,performance.now()),this.checkQueueAndSend())}queueGamepadFrames(e,t=!1){for(let n of e)this._upsertGamepadFrame(n);this.checkQueueAndSend(t)}queueMouseFrame(e){this._mouseQueue.push(e),this.checkQueueAndSend()}queueKeyboardFrame(e){this._keyboardQueue.push(e),this.checkQueueAndSend()}queuePointerFrame(e){this._pointerQueue.length>0?this._pointerQueue[0].events=this._pointerQueue[0].events.concat(e.events):this._pointerQueue.push(e),this.checkQueueAndSend()}checkQueueAndSend(e=!1){if(e===!0){this._hasQueuedData()&&this.sendQueue();return}if(this._gamepadQueue.length>0){this.sendQueue();return}if(this._mouseQueue.length>0||this._keyboardQueue.length>0||this._pointerQueue.length>0){this.sendQueue();return}this._metadataQueue.length>5&&this.sendQueue()}sendQueue(){let e=new y(this.getSequenceNum());this._pointerQueue.length>0&&e.setStreamConfig({width:this._player._channels.input.getServerVideoWidth(),height:this._player._channels.input.getServerVideoHeight()}),e.setData(this._metadataQueue,this._gamepadQueue,this._pointerQueue,this._mouseQueue,this._keyboardQueue),this._player._channels.input.send(e.toBuffer()),this.clearQueues()}clearQueues(){this._metadataQueue=[],this._gamepadQueue=[],this._pointerQueue=[],this._mouseQueue=[],this._keyboardQueue=[]}getSequenceNum(){return this._inputSequenceNum++,this._inputSequenceNum}};var A=class extends _{_serverVideoWidth=0;_serverVideoHeight=0;_inputQueue=new F(this.getPlayer());getChannelName(){return"input"}getChannelConfig(){return{ordered:!0,protocol:"1.0"}}getServerVideoWidth(){return this._serverVideoWidth}getServerVideoHeight(){return this._serverVideoHeight}start(){let e=new y(0);e.setMetadata(navigator.maxTouchPoints>1?navigator.maxTouchPoints:1),this.send(e.toBuffer()),console.log("[InputChannel] Sent metadata:",e,e.toBuffer()),setTimeout(this.gamepadStateLoop.bind(this),16)}onMessage(e){let t=new DataView(e.data),n=t.getUint8(0);if(console.log("[InputChannel] received:",t),n===128){console.log("Received a vibration report"),t.getUint8(2);let i=t.getUint8(3),a=this.getPlayer()._channels.control.getGamepadHandler(i);if(a!==void 0){let s=t.getUint8(4)/100,o=t.getUint8(5)/100,d=t.getUint8(6)/100,u=t.getUint8(7)/100,h=t.getUint16(8,!0),g=t.getUint16(10,!0),p=t.getUint8(12),c={gamepadIndex:i,leftMotorPercent:s,rightMotorPercent:o,leftTriggerMotorPercent:d,rightTriggerMotorPercent:u,durationMs:h,delayMs:g,repeat:p};a.handleVibration(c)}else console.log("[InputChannel] Received a vibration report but no gamepad handler is available")}else n===16&&(console.log("[InputChannel] Received server video dimensions:",t.getUint32(2,!0),t.getUint32(6,!0)),this._serverVideoHeight=t.getUint32(2,!0),this._serverVideoWidth=t.getUint32(6,!0))}gamepadStateLoop(){let e=this.getPlayer()._channels.control.getGamepadHandlers(),t=[];for(let n in e)if(e[n]instanceof v){let i=e[n].getGamepadState();i!==void 0&&t.push(i)}t.length>0&&this.queueGamepadFrames(t),setTimeout(this.gamepadStateLoop.bind(this),16)}queueMetadataFrame(e){return this._inputQueue.queueMetadataFrame(e)}queueGamepadFrames(e,t=!1){this._inputQueue.queueGamepadFrames(e,t)}queueMouseFrame(e){this._inputQueue.queueMouseFrame(e)}queueKeyboardFrame(e){this._inputQueue.queueKeyboardFrame(e)}queuePointerFrame(e){this._inputQueue.queuePointerFrame(e)}destroy(){}};function Q(){return crypto.randomUUID()}var D=class{_channel;_data;constructor(e,t){this._channel=e,this._data=t,this.handle(this._data)}handle(e){switch(console.log("[MessageHandler] Handling:",e),e.target){case"/streaming/sessionLifetimeManagement/serverInitiatedDisconnect":this.completeTransaction(e.id,""),this._channel.getPlayer().destroy();break;case"/streaming/properties/titleinfo":console.log("Title update:",e);break;case"/streaming/touchcontrols/showlayoutv2":break;case"/streaming/systemUi/messages/ShowMessageDialog":this.handleMessage(e);break;default:console.log("[MessageChannel] Unhandled transaction:",e)}}completeTransaction(e,t){let n=JSON.stringify({type:"TransactionComplete",content:JSON.stringify(t),id:e,cv:""});this._channel.send(n)}cancelTransaction(e,t){let n=JSON.stringify({type:"ReceiverCancel",content:JSON.stringify(t),id:e,cv:""});this._channel.send(n)}handleMessage(e){let t=JSON.parse(e.content);console.log(t),confirm(t.TitleText+`
+
+`+t.ContentText)?this.completeTransaction(e.id,{Result:0}):this.completeTransaction(e.id,{Result:1})}};var M=class extends _{_handshakeCompleted=!1;getChannelName(){return"message"}getChannelConfig(){return{protocol:"messageV1",ordered:!0}}onOpen(){console.log("[MessageChannel] Sending handshake...");let e=JSON.stringify({type:"Handshake",version:"messageV1",id:"be0bfc6d-1e83-4c8a-90ed-fa8601c5a179",cv:"0"});this.send(e)}onMessage(e){let t=JSON.parse(e.data);switch(t.type){case"HandshakeAck":console.log("[MessageChannel] Handshake completed"),this._handshakeCompleted=!0,this.getPlayer()._channels.control.sendAuthorization(),this.getPlayer()._channels.input.start(),this.sendConfig();break;case"TransactionStart":case"Message":new D(this,t);break;default:console.log("[MessageChannel] Unhandled message type:",t.type,t)}}sendConfig(){let e=[],t=[0,2,0],n=JSON.stringify(this.generateMessage("/streaming/systemUi/configuration",{version:t,systemUis:e}));this.send(n);let i=JSON.stringify(this.generateMessage("/streaming/properties/clientappinstallidchanged",{clientAppInstallId:"c97d7ee0-73b2-4239-bf1d-9d805a338429"}));this.send(i);let a=JSON.stringify(this.generateMessage("/streaming/characteristics/orientationchanged",{orientation:0}));this.send(a);let s=JSON.stringify(this.generateMessage("/streaming/characteristics/touchinputenabledchanged",{touchInputEnabled:!1}));this.send(s);let o=JSON.stringify(this.generateMessage("/streaming/characteristics/clientdevicecapabilities",{}));this.send(o);let d=JSON.stringify(this.generateMessage("/streaming/characteristics/dimensionschanged",{horizontal:1920,vertical:1080,preferredWidth:1920,preferredHeight:1080,safeAreaLeft:0,safeAreaTop:0,safeAreaRight:1920,safeAreaBottom:1080,supportsCustomResolution:!0}));this.send(d)}generateMessage(e,t){return{type:"Message",content:JSON.stringify(t),id:Q(),target:e,cv:""}}destroy(){}};var E=class{_address;_ipv4Address;_ipv4Port;constructor(e){this._address=e;let t=this._address.split(":"),n=t[6]+t[7],i=t[5],a=~parseInt(n.substring(0,2),16)&255,s=~parseInt(n.substring(2,4),16)&255,o=~parseInt(n.substring(4,6),16)&255,d=~parseInt(n.substring(6,8),16)&255,u=~parseInt(i.substring(0,4),16)&65535;this._ipv4Address=a+"."+s+"."+o+"."+d,this._ipv4Port=u}getIpv4Address(){return this._ipv4Address}getIpv4Port(){return this._ipv4Port}};var R=class{_peerConnection;_iceCandidates=[];constructor(e){this._peerConnection=e._peerConnection,this._peerConnection.addEventListener("icecandidate",t=>{t.candidate&&this._iceCandidates.push(t.candidate)})}getCandidates(){return this._iceCandidates}setRemoteCandidates(e){e.length===0&&console.warn("Error: No candidates received!");for(let t in e){if(e[t].candidate==="a=end-of-candidates")continue;let n=e[t].candidate.split(" ");if(n.length>4&&n[4].substr(0,4)==="2001"){let i=new E(n[4]);this._peerConnection.addIceCandidate({candidate:"a=candidate:10 1 UDP 1 "+i.getIpv4Address()+" 9002 typ host ",sdpMLineIndex:e[t].sdpMLineIndex,sdpMid:e[t].sdpMid}),this._peerConnection.addIceCandidate({candidate:"a=candidate:11 1 UDP 1 "+i.getIpv4Address()+" "+i.getIpv4Port()+" typ host ",sdpMLineIndex:e[t].sdpMLineIndex,sdpMid:e[t].sdpMid})}this._peerConnection.addIceCandidate({candidate:e[t].candidate,sdpMid:e[t].sdpMid,sdpMLineIndex:e[t].sdpMLineIndex})}}};var I=class{_player;_peerConnection;constructor(e){this._player=e,this._peerConnection=e._peerConnection}getAvailableCodecs(){let e=RTCRtpReceiver.getCapabilities("video")?.codecs;if(e===void 0)return[];let t=[];for(let n in e)t.includes(e[n].mimeType)||t.push(e[n].mimeType);return t}setLocalSDP(e){return console.log("[SDP] setLocalSDP() Setting local SDP:",e),e.sdp=e.sdp?.replace("useinbandfec=1","useinbandfec=1; stereo=1"),e}setRemoteSDP(e){return console.log("[SDP] setRemoteSDP() Setting remote SDP:",e),e}getDefaultCodecPreferences(){let e=RTCRtpReceiver.getCapabilities("video")?.codecs;if(e===void 0)return[];let t=[],n=[],i=[],a=[];for(let o in e)e[o].mimeType.includes("H264")?e[o].sdpFmtpLine?.includes("profile-level-id=4d")?t.push(e[o]):e[o].sdpFmtpLine?.includes("profile-level-id=42e")?n.push(e[o]):e[o].sdpFmtpLine?.includes("profile-level-id=420")&&i.push(e[o]):(e[o].mimeType.includes("ulpfec")||e[o].mimeType.includes("flexfec")||e[o].mimeType.includes("VP9")||e[o].mimeType.includes("VP8"))&&a.push(e[o]);return[...t,...n,...i,...a]}_setBitrate(e,t,n){let i=e.split(`
+`),a=-1;for(let o=0;o{e.forEach(t=>{t.type==="inbound-rtp"?this.readInboundRtp(t):t.type==="candidate-pair"&&t.packetsReceived!==void 0&&t.packetsReceived>0?this.readCandidatePair(t):t.type==="remote-candidate"&&this.readRemoteCandidate(t)})})}readInboundRtp(e){e.kind==="video"&&e.codecId&&e.packetsReceived!==void 0&&e.packetsReceived>0?(e.codecId.includes("profile-level-id=4d")?this._videoCodec="H264 (High)":e.codecId.includes("profile-level-id=42e")?this._videoCodec="H264 (Normal)":e.codecId.includes("profile-level-id=420")?this._videoCodec="H264 (Low)":this._videoCodec="Other ("+e.codecId+")",e.frameWidth&&(this._videoWidth=e.frameWidth),e.frameHeight&&(this._videoHeight=e.frameHeight),e.framesPerSecond&&(this._videoFps=e.framesPerSecond)):e.kind==="audio"&&e.codecId&&e.packetsReceived!==void 0&&e.packetsReceived>0&&(this._audioCodec=e.codecId)}readCandidatePair(e){this._activeRemoteCandidate=e.remoteCandidateId,this._rtt=e.currentRoundTripTime}readRemoteCandidate(e){e.id===this._activeRemoteCandidate&&(this.isPrivateIP(e.address)?this._remoteIsLocal=!0:this._remoteIsLocal=!1,this.isIpv6(e.address)?this._remoteIsIpv6=!0:this._remoteIsIpv6=!1,this._remoteHost=e.address,this._remotePort=e.port)}isPrivateIP(e){let t=e.split(".");return t[0]==="10"||t[0]==="172"&&parseInt(t[1],10)>=16&&parseInt(t[1],10)<=31||t[0]==="192"&&t[1]==="168"}isIpv6(e){return e.split(":").length>3}};var G=class{_player;_videoComponent;_overlays={debug:void 0};constructor(e,t){this._videoComponent=e,this._player=t}toggleDebug(){this._overlays.debug===void 0?this.createDebugOverlay():this.destroy()}createDebugOverlay(){this._overlays.debug=document.createElement("div"),this._overlays.debug.id="playerDebugOverlay",this._overlays.debug.style.position="absolute",this._overlays.debug.style.top="0",this._overlays.debug.style.left="0",this._overlays.debug.style.width=this._videoComponent.getElement()?.style.width||"100%",this._overlays.debug.style.height=this._videoComponent.getElement()?.style.height||"auto",this._overlays.debug.style.background="linear-gradient(0deg, rgba(0,0,0, 0) 0%, rgba(0,0,0, 0) 75%, rgba(0,0,0, 0.5) 100%)",this._overlays.debug.style.padding="10px",this._overlays.debug.style.pointerEvents="none",document.getElementById(this._player.getElementId())?.appendChild(this._overlays.debug),setTimeout(()=>{this.refreshDebugOverlay()},500),this.refreshDebugOverlay()}destroy(){this._overlays.debug?.remove(),this._overlays.debug=void 0}refreshDebugOverlay(){if(this._overlays.debug!==void 0){this._overlays.debug.innerHTML="",this._overlays.debug.appendChild(this.createLabel("Local Play",this._player.getStats()._remoteIsLocal?"Local":"Remote","ok")),this._overlays.debug.appendChild(this.createLabel("Resolution",this._player.getStats()._videoWidth+"x"+this._player.getStats()._videoHeight,"ok")),this._overlays.debug.appendChild(this.createLabel("Stream FPS",this._player.getStats()._videoFps.toString(),this._player.getStats()._videoFps>=58?"ok":"warning"));let e=this._videoComponent.getFrameStats?.();e&&(this._overlays.debug.appendChild(this.createLabel("Render FPS",e.renderingFps.toString(),e.renderingFps>=58?"ok":"warning")),this._overlays.debug.appendChild(this.createLabel("Render Delay",e.renderDelayMs.toString()+" ms",e.renderDelayMs<16?"ok":e.renderDelayMs<33?"warning":"error")),this._overlays.debug.appendChild(this.createLabel("Dropped Frames",e.droppedFrames.toString(),e.droppedFrames===0?"ok":e.droppedFrames<30?"warning":"error"))),this._overlays.debug.appendChild(this.createLabel("Connection",this._player.getStats()._remoteIsIpv6?"IPv6":"IPv4","ok")),this._overlays.debug.appendChild(this.createLabel("Video",this._player.getStats()._videoCodec,"ok"));let t=this._player.getStats()._rtt*1e3>75?"error":this._player.getStats()._rtt*1e3>40?"warning":"ok";this._overlays.debug.appendChild(this.createLabel("RTT",(this._player.getStats()._rtt*1e3).toString()+" ms",t)),setTimeout(()=>{this.refreshDebugOverlay()},500)}}createLabel(e,t="",n=""){let i={borderRadius:"5px",background:"linear-gradient(0deg, rgba(28,26,26,1) 0%, rgba(47,45,45,1) 100%)",padding:"10px",fontSize:"12px",marginTop:"3px",marginRight:"10px",marginBottom:"2px",textTransform:"uppercase",color:"white",display:"inline-block"},a=document.createElement("span"),s={error:"rgb(220, 53, 69)",warning:"rgb(255, 193, 7)",ok:"rgb(25, 135, 84)"};t!==""?a.innerHTML=`${e}: ${t}`:a.innerText=e;for(let o in i)a.style[o]=i[o];return a}};var L=class{_player;_element;_overlay;constructor(e){this._player=e,this._overlay=new G(this,this._player)}create(e){let t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.muted=!0,t.playsInline=!0,t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.style.backgroundColor="black",t.style.touchAction="none",t.poster="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";let n=document.getElementById(this._player.getElementId());if(n===null)return;this._element=t,n.appendChild(this._element),getComputedStyle(n).position==="static"===!0&&(n.style.position="relative"),this._element.requestVideoFrameCallback(this.processVideoMetadata.bind(this))}processVideoMetadata(e,t){this._element!==void 0&&(this._element.requestVideoFrameCallback(this.processVideoMetadata.bind(this)),this._player._channels.input.queueMetadataFrame({serverDataKey:t.rtpTimestamp,firstFramePacketArrivalTimeMs:t.receiveTime,frameSubmittedTimeMs:t.receiveTime,frameDecodedTimeMs:t.expectedDisplayTime,frameRenderedTimeMs:t.expectedDisplayTime}))}getElement(){return this._element}toggleDebugOverlay(){this._overlay.toggleDebug()}destroy(){let t=document.getElementById(this._player.getElementId())?.querySelector("video");this._overlay!==void 0&&this._overlay.destroy(),t&&t.remove()}};var N=class{_player;_element;constructor(e){this._player=e}create(e){let t=document.createElement("audio");t.srcObject=e,t.autoplay=!0,t.muted=!1,this._element=t;let n=document.getElementById(this._player.getElementId());n!==null&&n.appendChild(this._element)}getElement(){return this._element}destroy(){let t=document.getElementById(this._player.getElementId())?.querySelector("audio");t&&t.remove()}};var U=class{_peerConnection=new RTCPeerConnection({});_channels={chat:new S(this),control:new w(this),input:new A(this),message:new M(this)};_elementId;_isDestoyed=!1;_iceHelper=new R(this);_sdpHelper=new I(this);_statsHelper=new P(this);_videoComponent;_audioComponent;constructor(e){console.log("xCloudPlayer constructing..."),this._elementId=e,this._peerConnection.addTransceiver("audio",{direction:"sendrecv"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}).setCodecPreferences(this._sdpHelper.getDefaultCodecPreferences()),this._peerConnection.ontrack=n=>{n.track.kind==="video"?(this._videoComponent=new L(this),this._videoComponent.create(n.streams[0])):n.track.kind==="audio"?(this._audioComponent=new N(this),this._audioComponent.create(n.streams[0])):console.log("[xPlayer] Detected an unknown stream type: ",n.track.kind)},console.log("xCloudPlayer constructed.")}init(){console.log("xCloudPlayer init called.")}getElementId(){return this._elementId}async createOffer(){let e=await this._peerConnection.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),t=this._sdpHelper.setLocalSDP(e);return this._peerConnection.setLocalDescription(t),t}async setRemoteSDP(e){let t=this._sdpHelper.setRemoteSDP(e);return await this._peerConnection.setRemoteDescription({type:"answer",sdp:t})}async getICECandidates(){return this._iceHelper.getCandidates()}async setRemoteIceCandidates(e){this._iceHelper.setRemoteCandidates(e)}getVideoElement(){if(this._videoComponent)return this._videoComponent.getElement()}getAudioElement(){if(this._audioComponent)return this._audioComponent.getElement()}toggleDebugOverlay(){this._videoComponent&&this._videoComponent.toggleDebugOverlay()}getStats(){return this._statsHelper}destroy(){if(this._isDestoyed===!1){this._peerConnection.close(),this._peerConnection.onconnectionstatechange&&this._peerConnection.onconnectionstatechange(new Event("connectionstatechanged"));for(let e in this._channels)this._channels[e].destroy();this._videoComponent&&this._videoComponent.destroy(),this._audioComponent&&this._audioComponent.destroy(),this._isDestoyed=!0}else console.log("Cannot destroy because the player is already destroyed.")}};function X(r){return r.brightness!==0||r.contrast!==0||Math.abs(r.gamma-1)>.001||r.saturation!==100||r.sharpen>0||r.deband>0||r.fxaa||r.toon||r.crt||r.ntsc||r.maxFps>0}var J=`#version 300 es
+in vec2 position;
+out vec2 vUV;
+void main() { vUV = position * 0.5 + 0.5; gl_Position = vec4(position, 0.0, 1.0); }`,j=`attribute vec2 position;
+varying vec2 vUV;
+void main() { vUV = position * 0.5 + 0.5; gl_Position = vec4(position, 0.0, 1.0); }`,Z=`#version 300 es
+precision mediump float;
+uniform sampler2D screenTexture;
+uniform vec2 resolution;
+uniform int filterId;
+uniform float sharpenFactor;
+uniform float brightness;
+uniform float contrast;
+uniform float gamma;
+uniform float saturation;
+uniform float deband;
+out vec4 fragColor;
+const float CAS_CONTRAST_PEAK = 0.8 * -3.0 + 8.0;
+
+vec3 sharpen(vec2 coord, vec3 e) {
+ vec2 px = 1.0 / resolution;
+ vec3 b = texture(screenTexture, coord + px * vec2(0, 1)).rgb;
+ vec3 d = texture(screenTexture, coord + px * vec2(-1, 0)).rgb;
+ vec3 f = texture(screenTexture, coord + px * vec2(1, 0)).rgb;
+ vec3 h = texture(screenTexture, coord + px * vec2(0, -1)).rgb;
+ vec3 a = texture(screenTexture, coord + px * vec2(-1, 1)).rgb;
+ vec3 c = texture(screenTexture, coord + px * vec2(1, 1)).rgb;
+ vec3 g = texture(screenTexture, coord + px * vec2(-1, -1)).rgb;
+ vec3 i = texture(screenTexture, coord + px * vec2(1, -1)).rgb;
+ if (filterId == 1) {
+ vec3 blur = ((a + c + g + i) + (b + d + f + h) * 2.0 + e * 4.0) / 16.0;
+ return e + (e - blur) * sharpenFactor / 3.0;
+ }
+ vec3 minRgb = min(min(min(d, e), min(f, b)), h) + min(min(a, c), min(g, i));
+ vec3 maxRgb = max(max(max(d, e), max(f, b)), h) + max(max(a, c), max(g, i));
+ vec3 amplify = inversesqrt(clamp(min(minRgb, 2.0 - maxRgb) / maxRgb, 0.0, 1.0));
+ vec3 weight = -(1.0 / (amplify * CAS_CONTRAST_PEAK));
+ vec3 outColor = clamp(((b + d + f + h) * weight + e) / (4.0 * weight + 1.0), 0.0, 1.0);
+ return mix(e, outColor, sharpenFactor / 2.0);
+}
+
+float ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }
+
+void main() {
+ vec2 uv = gl_FragCoord.xy / resolution;
+ vec3 color = texture(screenTexture, uv).rgb;
+ if (sharpenFactor > 0.0) color = sharpen(uv, color);
+ color = clamp(color + brightness, 0.0, 1.0);
+ color = (color - 0.5) * clamp(contrast + 1.0, 0.5, 2.0) + 0.5;
+ color = mix(vec3(dot(color, vec3(0.2126, 0.7152, 0.0722))), color, saturation);
+ color = pow(max(color, 0.0), vec3(1.0 / gamma));
+ if (deband > 0.0) color += vec3(((ign(gl_FragCoord.xy) + ign(gl_FragCoord.xy + vec2(11.0, 17.0))) - 1.0) * (deband / 255.0));
+ fragColor = vec4(color, 1.0);
+}`,ee=`precision highp float;
+#define FXAA_MIN_REDUCE (1.0 / 128.0)
+#define FXAA_MUL_REDUCE (1.0 / 8.0)
+#define MAX_SPAN 8.0
+uniform sampler2D screenTexture;
+uniform vec2 resolution;
+const vec3 luma = vec3(0.299, 0.587, 0.114);
+void main() {
+ vec2 invResolution = 1.0 / resolution;
+ vec3 rgbNW = texture2D(screenTexture, (gl_FragCoord.xy + vec2(-1.0, -1.0)) * invResolution).rgb;
+ vec3 rgbNE = texture2D(screenTexture, (gl_FragCoord.xy + vec2( 1.0, -1.0)) * invResolution).rgb;
+ vec3 rgbSW = texture2D(screenTexture, (gl_FragCoord.xy + vec2(-1.0, 1.0)) * invResolution).rgb;
+ vec3 rgbSE = texture2D(screenTexture, (gl_FragCoord.xy + vec2( 1.0, 1.0)) * invResolution).rgb;
+ vec3 rgbM = texture2D(screenTexture, gl_FragCoord.xy * invResolution).rgb;
+ float lumaNW = dot(rgbNW, luma);
+ float lumaNE = dot(rgbNE, luma);
+ float lumaSW = dot(rgbSW, luma);
+ float lumaSE = dot(rgbSE, luma);
+ float lumaM = dot(rgbM, luma);
+ float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
+ float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
+ vec2 dir;
+ dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
+ dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
+ float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * FXAA_MUL_REDUCE, FXAA_MIN_REDUCE);
+ float minDirFactor = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
+ dir = clamp(dir * minDirFactor, vec2(-MAX_SPAN), vec2(MAX_SPAN)) * invResolution;
+ vec4 rgbA = 0.5 * (
+ texture2D(screenTexture, gl_FragCoord.xy * invResolution + dir * (1.0 / 3.0 - 0.5)) +
+ texture2D(screenTexture, gl_FragCoord.xy * invResolution + dir * (2.0 / 3.0 - 0.5)));
+ vec4 rgbB = rgbA * 0.5 + 0.25 * (
+ texture2D(screenTexture, gl_FragCoord.xy * invResolution + dir * -0.5) +
+ texture2D(screenTexture, gl_FragCoord.xy * invResolution + dir * 0.5));
+ float lumaB = dot(rgbB, vec4(luma, 0.0));
+ gl_FragColor = lumaB < lumaMin || lumaB > lumaMax ? rgbA : rgbB;
+}`,te=`precision highp float;
+uniform sampler2D screenTexture;
+uniform vec2 resolution;
+void main() {
+ vec2 uv = gl_FragCoord.xy / resolution;
+ float edgeThreshold = 0.2;
+ vec2 offset = vec2(1.0) / resolution;
+ vec3 colorCenter = texture2D(screenTexture, uv).rgb;
+ vec3 colorLeft = texture2D(screenTexture, uv - vec2(offset.x, 0.0)).rgb;
+ vec3 colorRight = texture2D(screenTexture, uv + vec2(offset.x, 0.0)).rgb;
+ vec3 colorUp = texture2D(screenTexture, uv - vec2(0.0, offset.y)).rgb;
+ vec3 colorDown = texture2D(screenTexture, uv + vec2(0.0, offset.y)).rgb;
+ float diffHorizontal = length(colorRight - colorLeft);
+ float diffVertical = length(colorUp - colorDown);
+ float edgeFactor = step(edgeThreshold, diffHorizontal + diffVertical);
+ vec3 outlineColor = mix(colorCenter, vec3(0.0), edgeFactor);
+ gl_FragColor = vec4(outlineColor, 1.0);
+}`,ne=`precision highp float;
+#define CA_AMOUNT 1.0025
+#define SCANLINE_INTENSITY_X 0.125
+#define SCANLINE_INTENSITY_Y 0.375
+#define SCANLINE_SIZE 1024.0
+uniform sampler2D screenTexture;
+varying vec2 vUV;
+void main() {
+ vec4 finalColor = texture2D(screenTexture, vUV);
+ finalColor.rgb = vec3(
+ texture2D(screenTexture, (vUV - 0.5) * CA_AMOUNT + 0.5).r,
+ finalColor.g,
+ texture2D(screenTexture, (vUV - 0.5) / CA_AMOUNT + 0.5).b
+ );
+ float scanlineX = abs(sin(vUV.x * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_X);
+ float scanlineY = abs(sin(vUV.y * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_Y);
+ gl_FragColor = vec4(mix(finalColor.rgb, vec3(0.0), scanlineX + scanlineY), finalColor.a);
+}`,ie=`precision highp float;
+#define PI 3.14159265
+#define SCANLINE_INTENSITY 0.35
+#define CHROMA_OFFSET 0.005
+#define BLUR_RADIUS 0.002
+#define WARP_AMOUNT 0.01
+#define SCANLINE_DARKEN 0.5
+uniform sampler2D screenTexture;
+uniform int FrameCount;
+uniform vec2 TextureSize;
+uniform vec2 resolution;
+varying vec2 vUV;
+const mat3 yiq_mat = mat3(
+ 0.299, 0.587, 0.114,
+ 0.596, -0.275, -0.321,
+ 0.212, -0.523, 0.311
+);
+const mat3 yiq2rgb_mat = mat3(
+ 1.0, 0.956, 0.621,
+ 1.0, -0.272, -0.647,
+ 1.0, -1.106, 1.705
+);
+vec3 applyNTSC(vec2 uv) {
+ vec3 col = texture2D(screenTexture, uv).rgb;
+ vec3 yiq = col * yiq_mat;
+ float chromaPhase = PI * (mod(uv.y * TextureSize.y, 2.0) + float(FrameCount));
+ yiq.y *= cos(chromaPhase * 0.5);
+ yiq.z *= sin(chromaPhase * 0.5);
+ vec3 rgb = yiq * yiq2rgb_mat;
+ vec3 finalColor;
+ finalColor.r = texture2D(screenTexture, uv + vec2(CHROMA_OFFSET, 0.0)).r;
+ finalColor.g = texture2D(screenTexture, uv + vec2(0.0, BLUR_RADIUS)).g;
+ finalColor.b = texture2D(screenTexture, uv - vec2(CHROMA_OFFSET, 0.0)).b;
+ return finalColor;
+}
+vec3 applyScanlines(vec2 uv) {
+ vec3 col = texture2D(screenTexture, uv).rgb;
+ float scanline = abs(sin(uv.y * resolution.y * 2.0)) * SCANLINE_INTENSITY;
+ col *= 1.0 - (scanline * SCANLINE_DARKEN);
+ return col;
+}
+vec2 applyWarp(vec2 uv) {
+ uv = uv * 2.0 - 1.0;
+ float r = sqrt(uv.x * uv.x + uv.y * uv.y);
+ uv += uv * (r * r) * WARP_AMOUNT;
+ return uv * 0.5 + 0.5;
+}
+void main() {
+ vec2 warpedUV = applyWarp(vUV);
+ vec3 ntscColor = applyNTSC(warpedUV);
+ vec3 scanlineColor = applyScanlines(warpedUV);
+ vec3 finalColor = mix(ntscColor, scanlineColor, 0.7);
+ gl_FragColor = vec4(finalColor, 1.0);
+}`,H=class{constructor(e,t){this.video=e;this.effects=t;this.canvas=document.createElement("canvas"),Object.assign(this.canvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"contain",zIndex:"1"}),e.parentElement?.appendChild(this.canvas);let n=this.canvas.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,desynchronized:!0,powerPreference:"high-performance"});if(n===null)throw new Error("WebGL2 unavailable");this.gl=n;let i=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),n.STATIC_DRAW),this.passes.set("base",this.compile(J,Z,["screenTexture","resolution","filterId","sharpenFactor","brightness","contrast","gamma","saturation","deband"])),this.videoTexture=this.texture(),this.schedule()}canvas;gl;passes=new Map;videoTexture;targets=[];width=0;height=0;frame=0;lastDraw=0;stopped=!1;idle=!1;pending=!1;update(e){this.effects=e}pause(){this.idle||this.stopped||(this.idle=!0,this.canvas.style.display="none")}resume(e){this.effects=e,!(!this.idle||this.stopped)&&(this.idle=!1,this.canvas.style.display="",this.schedule())}schedule(){this.pending||(this.pending=!0,this.video.requestVideoFrameCallback(this.onFrame))}compile(e,t,n){let i=this.gl,a=(o,d)=>{let u=i.createShader(o);if(i.shaderSource(u,d),i.compileShader(u),!i.getShaderParameter(u,i.COMPILE_STATUS))throw new Error(`shader: ${i.getShaderInfoLog(u)}`);return u},s=i.createProgram();if(i.attachShader(s,a(i.VERTEX_SHADER,e)),i.attachShader(s,a(i.FRAGMENT_SHADER,t)),i.bindAttribLocation(s,0,"position"),i.linkProgram(s),!i.getProgramParameter(s,i.LINK_STATUS))throw new Error(`program: ${i.getProgramInfoLog(s)}`);return{program:s,uniforms:new Map(n.map(o=>[o,i.getUniformLocation(s,o)]))}}extra(e){let t=this.passes.get(e);if(t===void 0){let n={fxaa:ee,toon:te,crt:ne,ntsc:ie}[e];t=this.compile(j,n,["screenTexture","resolution","TextureSize","FrameCount"]),this.passes.set(e,t)}return t}texture(){let e=this.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}resize(e,t){let n=this.gl;this.width=e,this.height=t,this.canvas.width=e,this.canvas.height=t;for(let i of this.targets)n.deleteFramebuffer(i.framebuffer),n.deleteTexture(i.texture);this.targets=[0,1].map(()=>{let i=this.texture();n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e,t,0,n.RGBA,n.UNSIGNED_BYTE,null);let a=n.createFramebuffer();return n.bindFramebuffer(n.FRAMEBUFFER,a),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,i,0),{framebuffer:a,texture:i}}),n.bindFramebuffer(n.FRAMEBUFFER,null)}onFrame=e=>{if(this.pending=!1,this.stopped||this.idle)return;this.schedule();let t=this.effects.maxFps;if(!(t>0&&e-this.lastDraw<1e3/t-2)){this.lastDraw=e;try{this.draw()}catch(n){window.DDCloud?.log(`effects: ${String(n).slice(0,200)}`),this.destroy()}}};draw(){let e=this.gl,t=this.effects,n=this.video.videoWidth,i=this.video.videoHeight;if(n===0||i===0)return;(n!==this.width||i!==this.height)&&this.resize(n,i),this.frame++,e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.videoTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.video);let a=["fxaa","toon","crt","ntsc"].filter(d=>t[d]);e.viewport(0,0,n,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);let s=this.passes.get("base");e.bindFramebuffer(e.FRAMEBUFFER,a.length>0?this.targets[0].framebuffer:null),e.useProgram(s.program);let o=s.uniforms;e.uniform1i(o.get("screenTexture"),0),e.uniform2f(o.get("resolution"),n,i),e.uniform1i(o.get("filterId"),t.sharpenMode==="usm"?1:2),e.uniform1f(o.get("sharpenFactor"),t.sharpen),e.uniform1f(o.get("brightness"),t.brightness/100),e.uniform1f(o.get("contrast"),t.contrast/100),e.uniform1f(o.get("gamma"),Math.min(5,Math.max(.1,t.gamma))),e.uniform1f(o.get("saturation"),t.saturation/100),e.uniform1f(o.get("deband"),t.deband),e.drawArrays(e.TRIANGLES,0,3),a.forEach((d,u)=>{let h=this.extra(d),g=this.targets[u%2],p=u===a.length-1;e.bindFramebuffer(e.FRAMEBUFFER,p?null:this.targets[(u+1)%2].framebuffer),e.useProgram(h.program),e.bindTexture(e.TEXTURE_2D,g.texture);let c=h.uniforms;e.uniform1i(c.get("screenTexture")??null,0),e.uniform2f(c.get("resolution")??null,n,i),e.uniform2f(c.get("TextureSize")??null,n,i),e.uniform1i(c.get("FrameCount")??null,this.frame),e.drawArrays(e.TRIANGLES,0,3)})}destroy(){this.stopped=!0,this.canvas.remove(),this.gl.getExtension("WEBGL_lose_context")?.loseContext()}};var V=class{constructor(e){this.pc=e;this.element=document.createElement("div"),Object.assign(this.element.style,{position:"absolute",top:"8px",right:"8px",zIndex:"3",padding:"4px 8px",borderRadius:"6px",background:"rgba(0,0,0,0.55)",color:"#e8e8e8",font:"12px monospace",lineHeight:"16px",pointerEvents:"none",display:"none",whiteSpace:"pre",textAlign:"right"}),document.body.appendChild(this.element)}element;timer;level=0;vertical=!1;left=!1;server="";last={bytes:0,time:0,decode:0,frames:0,lost:0,received:0};show(e,t,n,i=!1){this.level=e,this.vertical=t,this.server=n,this.left=i,Object.assign(this.element.style,i?{left:"8px",right:"",textAlign:"left"}:{left:"",right:"8px",textAlign:"right"}),this.element.style.display=e>0?"block":"none",e>0&&this.timer===void 0&&(this.timer=setInterval(()=>this.update(),1e3),this.update()),e===0&&this.timer!==void 0&&(clearInterval(this.timer),this.timer=void 0)}async update(){let e=await this.pc.getStats(),t,n,i=new Map;if(e.forEach(c=>{c.type==="inbound-rtp"&&c.kind==="video"?t=c:c.type==="candidate-pair"&&c.state==="succeeded"&&c.nominated?n=c:c.type==="codec"&&i.set(c.id,c)}),t===void 0)return;let a=this.last.time>0?(t.timestamp-this.last.time)/1e3:0,s=a>0?(t.bytesReceived-this.last.bytes)*8/a/1e6:0,o=(t.framesDecoded??0)-this.last.frames,d=o>0?((t.totalDecodeTime??0)-this.last.decode)*1e3/o:0,u=(t.packetsLost??0)-this.last.lost,h=(t.packetsReceived??0)-this.last.received,g=u+h>0?u*100/(u+h):0;this.last={bytes:t.bytesReceived,time:t.timestamp,decode:t.totalDecodeTime??0,frames:t.framesDecoded??0,lost:t.packetsLost??0,received:t.packetsReceived??0};let p=["web",`${Math.round(t.framesPerSecond??0)} fps`];if(this.level>=2&&(n?.currentRoundTripTime!==void 0&&p.push(`ping ${Math.round(n.currentRoundTripTime*1e3)} ms`),p.push(`${t.frameWidth??"?"}x${t.frameHeight??"?"}`)),this.level>=3&&p.push(`${s.toFixed(1)} Mb/s`,`decode ${d.toFixed(1)} ms`,`loss ${g.toFixed(1)}%`),this.level>=4){let c=i.get(t.codecId);c&&p.push(String(c.mimeType??"").replace("video/","")),p.push(`jitter ${Math.round((t.jitter??0)*1e3)} ms`,`dropped ${t.framesDropped??0}`),this.server&&p.push(this.server)}this.element.textContent=p.join(this.vertical?`
+`:" \xB7 ")}destroy(){this.show(0,this.vertical,this.server,this.left),this.element.remove()}};function z(r,e){let t=e==="high"?"4d":e==="low"?"420":"42e",n=[];for(let d of r.matchAll(/a=fmtp:(\d+).*profile-level-id=([0-9a-f]{6})/g))d[2].startsWith(t)&&n.push(d[1]);if(n.length===0)return r;let i=r.split(`\r
+`),a=i.findIndex(d=>d.startsWith("m=video"));if(a<0)return r;let s=i[a].trim().split(" "),o=s.slice(3).filter(d=>!n.includes(d));return i[a]=s.slice(0,3).concat(n,o).join(" "),i.join(`\r
+`)}function K(r,e){let t=r.split(`\r
+`),n=t.findIndex(a=>a.startsWith("m=video"));if(n<0)return r;let i=`b=AS:${e}`;for(let a=n+1;a<=t.length;a++){let s=t[a];if(s===void 0||s.startsWith("m=")){t.splice(a,0,i);break}if(!(s.startsWith("i=")||s.startsWith("c="))){if(s.startsWith("b=AS:")){t[a]=i;break}t.splice(a,0,i);break}}return t.join(`\r
+`)}var m=JSON.parse(DDCloud.settings()),ae=RTCPeerConnection.prototype.setLocalDescription;RTCPeerConnection.prototype.setLocalDescription=function(r){return r?.sdp&&((m.codec==="high"||m.codec==="normal"||m.codec==="low")&&(r.sdp=z(r.sdp,m.codec)),m.bitrateMbps>0&&(r.sdp=K(r.sdp,m.bitrateMbps*1e3))),ae.call(this,r)};window.__ddRumble=m.rumble/100;window.addEventListener("error",r=>DDCloud.log(`error: ${r.message} @${r.lineno}`));window.addEventListener("unhandledrejection",r=>DDCloud.log(`rejection: ${String(r.reason).slice(0,200)}`));window.addEventListener("gamepadconnected",r=>DDCloud.log(`controller: ${r.gamepad.id.slice(0,60)} mapping=${r.gamepad.mapping||"none"} buttons=${r.gamepad.buttons.length} axes=${r.gamepad.axes.length}`));var W=new Map,re=1;window.__ddResolve=(r,e,t)=>{let n=W.get(r);W.delete(r),n&&n({status:e,body:t})};function C(r,e=""){return new Promise(t=>{let n=re++;W.set(n,t),DDCloud.call(n,r,typeof e=="string"?e:JSON.stringify(e))})}var B=r=>new Promise(e=>setTimeout(e,r)),se=r=>r.status>=200&&r.status<300;function x(r){let e=document.getElementById("status");e&&(e.textContent=r),DDCloud.status(r)}var T=class extends Error{constructor(t,n){super(t);this.stage=t;this.detail=n}};function k(r,e){if(!se(e))throw new T(r,`${e.status} ${e.body.slice(0,300)}`);return e}function oe(r,e){return new Promise(t=>{if(r.iceGatheringState==="complete")return t();let n=setTimeout(t,e);r.addEventListener("icegatheringstatechange",()=>{r.iceGatheringState==="complete"&&(clearTimeout(n),t())})})}async function de(){x("Starting the game on Xbox Cloud Gaming\u2026"),k("start",await C("start"));let r=!1,e=0;for(;;){let l=k("state",await C("state")),f=JSON.parse(l.body||"{}");if(f.state==="Provisioned")break;if(f.state==="Failed")throw new T("provision",JSON.stringify(f.errorDetails??{}).slice(0,300));f.state==="ReadyToConnect"&&!r?(r=!0,x("Signing in to the cloud console\u2026"),k("connect",await C("connect"))):f.state==="WaitingForResources"?x(`In the queue for a cloud console\u2026 ${Math.round(e/1e3)} s`):x(`Getting a cloud console ready\u2026 ${Math.round(e/1e3)} s`),await B(1e3),e+=1e3}x("Connecting\u2026");let t=new U("player");t.init();let n=t._peerConnection,i=t._channels.input,a=i.queueMetadataFrame.bind(i);i.queueMetadataFrame=l=>{if(m.preventDrops){let f=l.frameRenderedTimeMs-l.frameDecodedTimeMs;l.frameDecodedTimeMs=l.frameSubmittedTimeMs+10,l.frameRenderedTimeMs=l.frameDecodedTimeMs+f}a(l)};let s,o,d=()=>{if(!(o===void 0||s===void 0&&m.volume===100)){if(s===void 0){let l=new AudioContext;s=l.createGain(),l.createMediaStreamSource(o).connect(s).connect(l.destination);let f=document.querySelector("#player audio");f&&(f.muted=!0)}s.gain.value=m.volume/100}};n.addEventListener("track",l=>{l.track.kind==="audio"&&(o=l.streams[0],d())});let u=new V(n),h,g=()=>{let l=t.getVideoElement();if(l!==void 0){if(!X(m)){h?.pause();return}if(h===void 0)try{h=new H(l,m)}catch(f){DDCloud.log(`effects unavailable: ${String(f).slice(0,200)}`)}else h.resume(m)}};window.__ddApply=l=>{m=JSON.parse(l),window.__ddRumble=m.rumble/100,u.show(m.statsLevel,m.statsLayout==="vertical",m.server,m.statsCorner==="left"),d(),g()},n.addEventListener("connectionstatechange",()=>{n.connectionState==="connected"?(x(""),DDCloud.playing(),u.show(m.statsLevel,m.statsLayout==="vertical",m.server,m.statsCorner==="left"),setTimeout(g,500)):n.connectionState==="failed"?DDCloud.failed("webrtc","connection failed"):n.connectionState==="disconnected"&&x("Connection lost\u2026")});let p=await t.createOffer(),c=k("sdp",await C("sdp",p.sdp??"")),O=JSON.parse(JSON.parse(c.body).exchangeResponse);if(O.status&&O.status!=="success")throw new T("sdp-answer",JSON.stringify(O).slice(0,300));await t.setRemoteSDP(O.sdp),await oe(n,3e3);let Y=(await t.getICECandidates()).map(l=>JSON.stringify({candidate:l.candidate,sdpMid:l.sdpMid,sdpMLineIndex:l.sdpMLineIndex,usernameFragment:l.usernameFragment})),$=k("ice",await C("ice",Y));t.setRemoteIceCandidates(JSON.parse(JSON.parse($.body).exchangeResponse));let q=Date.now();for(;!t._channels.message._handshakeCompleted&&Date.now()-q<2e4;)await B(100);DDCloud.log(`handshake ${t._channels.message._handshakeCompleted?"done":"missing"} after ${Date.now()-q} ms`),await B(300);let b=new v(0,{enable_keyboard:!1});b.attach(t),DDCloud.log(`controllers at attach: ${Array.from(navigator.getGamepads()).filter(Boolean).length}`),window.__ddNexus=()=>{b.sendButtonState("Nexus",1),setTimeout(()=>b.sendButtonState("Nexus",0),200)},window.__ddButton=(l,f)=>b.sendButtonState(l,f),window.__ddInput=l=>{l?b.onWindowFocus():b.onWindowBlur()},setInterval(()=>{C("keepalive")},3e4),window.__ddStop=()=>{try{h?.destroy(),u.destroy(),b.detach(),t.destroy()}catch{}}}de().catch(r=>{r instanceof T?DDCloud.failed(r.stage,r.detail):DDCloud.failed("page",String(r).slice(0,300))});})();
diff --git a/app/src/main/cpp/waylandcomp/CMakeLists.txt b/app/src/main/cpp/waylandcomp/CMakeLists.txt
index 16c707d639..574182b7da 100644
--- a/app/src/main/cpp/waylandcomp/CMakeLists.txt
+++ b/app/src/main/cpp/waylandcomp/CMakeLists.txt
@@ -8,6 +8,7 @@ add_library(droiddeckwayland SHARED
src/sc_layer.c
src/ahb_swapchain.c
src/waylandcomp_jni.c
+ src/gpu_clock_pin.c
src/droiddeck_ext.c
src/wl_dmabuf.c
src/wl_android_buffer.c
@@ -96,4 +97,5 @@ target_link_libraries(droiddeckwayland
dl
log
android
+ nativewindow
)
diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c
index 4a281e1854..06c6a236d4 100644
--- a/app/src/main/cpp/waylandcomp/src/compositor.c
+++ b/app/src/main/cpp/waylandcomp/src/compositor.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#include "xdg-shell-server-protocol.h"
@@ -888,10 +889,14 @@ static uint32_t nominal_refresh_ns(void) {
}
static int64_t presented_ns(int64_t render_ns) {
- if (!g_tick_vsync_ns || render_ns - g_last_vsync_ns > (int64_t)nominal_refresh_ns() ||
- render_ns < g_tick_vsync_ns)
+ int64_t tick = g_tick_vsync_ns;
+ int64_t refresh = (int64_t)nominal_refresh_ns();
+ if (!tick || render_ns - g_last_vsync_ns > refresh)
return render_ns;
- return g_tick_vsync_ns;
+ int64_t delta = render_ns - tick;
+ if (delta > refresh || -delta > refresh)
+ return render_ns;
+ return tick;
}
static void feedback_present_all(struct wl_list *list, int64_t t) {
@@ -1922,7 +1927,121 @@ static void hdr_count_copied(const struct draw_list *dl, const char *reason) {
}
}
+/*
+ * Stream mode (the Xbox Cloud Gaming native player, in its own process): no Wayland clients, the scene is one
+ * picture handed over as AHardwareBuffers (ImageReader images of the decoded video). Each buffer is imported once
+ * and kept while the reader cycles through its few buffers; the newest frame is the scene, so the screen effects
+ * and frame generation apply to it as to a game.
+ */
+#define STREAM_SLOTS 6
+static pthread_mutex_t g_stream_lock = PTHREAD_MUTEX_INITIALIZER;
+static atomic_int g_stream_on;
+static AHardwareBuffer *g_stream_pending;
+static struct { AHardwareBuffer *ahb; struct vkp_image *img; uint64_t used; } g_stream_slots[STREAM_SLOTS];
+static struct vkp_image *g_stream_img;
+static uint64_t g_stream_seq;
+static atomic_uint g_stream_frames;
+
+static void stream_forget_all(void) {
+ vkp_wait_idle();
+ for (int i = 0; i < STREAM_SLOTS; i++) {
+ if (g_stream_slots[i].img) vkp_image_destroy(g_stream_slots[i].img);
+ if (g_stream_slots[i].ahb) AHardwareBuffer_release(g_stream_slots[i].ahb);
+ g_stream_slots[i].img = NULL; g_stream_slots[i].ahb = NULL; g_stream_slots[i].used = 0;
+ }
+ g_stream_img = NULL;
+}
+
+/* Compositor thread: the newest handed-over buffer becomes the scene picture. */
+static void stream_take(void) {
+ pthread_mutex_lock(&g_stream_lock);
+ AHardwareBuffer *ahb = g_stream_pending;
+ g_stream_pending = NULL;
+ pthread_mutex_unlock(&g_stream_lock);
+ if (!ahb) return;
+ if (!atomic_load(&g_stream_on)) { AHardwareBuffer_release(ahb); return; }
+ int slot = -1, oldest = 0;
+ for (int i = 0; i < STREAM_SLOTS; i++) {
+ if (g_stream_slots[i].ahb == ahb) { slot = i; break; }
+ if (g_stream_slots[i].used < g_stream_slots[oldest].used) oldest = i;
+ }
+ if (slot >= 0) {
+ AHardwareBuffer_release(ahb); /* the slot keeps its own reference */
+ } else {
+ struct vkp_image *img = vkp_image_from_ahb(ahb);
+ if (!img) {
+ static int said;
+ if (!said) { said = 1; droiddeck_log("stream", "a decoded frame could not be imported: nothing to show"); }
+ AHardwareBuffer_release(ahb);
+ return;
+ }
+ droiddeck_log("stream", "decoded frame buffer imported (%dx%d)", vkp_image_width(img), vkp_image_height(img));
+ slot = oldest;
+ if (g_stream_slots[slot].img) {
+ vkp_wait_idle(); /* the GPU may still read the picture being replaced */
+ if (g_stream_img == g_stream_slots[slot].img) g_stream_img = NULL;
+ vkp_image_destroy(g_stream_slots[slot].img);
+ }
+ if (g_stream_slots[slot].ahb) AHardwareBuffer_release(g_stream_slots[slot].ahb);
+ g_stream_slots[slot].ahb = ahb;
+ g_stream_slots[slot].img = img;
+ }
+ g_stream_slots[slot].used = ++g_stream_seq;
+ g_stream_img = g_stream_slots[slot].img;
+ atomic_fetch_add(&g_stream_frames, 1);
+ schedule_render();
+}
+
+static void render_stream(void) {
+ g_dirty = 0;
+ struct vkp_image *img = g_stream_img;
+ if (!img) return;
+ int w = vkp_image_width(img), h = vkp_image_height(img);
+ if (w != g_scene_w || h != g_scene_h) {
+ droiddeck_log("stream", "picture %dx%d", w, h);
+ g_scene_w = w;
+ g_scene_h = h;
+ }
+ struct vkp_draw d = {.img = img, .sx = 0, .sy = 0, .sw = (float)w, .sh = (float)h, .dx = 0, .dy = 0, .dw = w, .dh = h, .blend = 0};
+ vkp_apply_window_request();
+ sc_layer_hide();
+ int r = vkp_render(w, h, &d, 1);
+ if (r == 0) {
+ g_stat_frames++;
+ static int first;
+ if (!first) { first = 1; droiddeck_log("stream", "first stream frame presented"); }
+ } else {
+ static int failed;
+ if (failed++ % 600 == 0) droiddeck_log("stream", "presenting a stream frame failed (%d, %d times)", r, failed);
+ }
+}
+
+void droiddeck_stream_set(int on) {
+ atomic_store(&g_stream_on, on ? 1 : 0);
+ if (g_input_pipe[1] < 0) return;
+ struct input_msg m = { 21, on ? 1 : 0, 0, 0, 0 };
+ ssize_t n = write(g_input_pipe[1], &m, sizeof(m));
+ (void)n;
+}
+
+/* Any thread: hands over one decoded frame (acquires its own reference). */
+void droiddeck_stream_frame(AHardwareBuffer *ahb) {
+ if (!ahb || !atomic_load(&g_stream_on) || g_input_pipe[1] < 0) return;
+ AHardwareBuffer_acquire(ahb);
+ pthread_mutex_lock(&g_stream_lock);
+ AHardwareBuffer *dropped = g_stream_pending;
+ g_stream_pending = ahb;
+ pthread_mutex_unlock(&g_stream_lock);
+ if (dropped) { AHardwareBuffer_release(dropped); return; } /* a wake-up is already queued */
+ struct input_msg m = { 20, 0, 0, 0, 0 };
+ ssize_t n = write(g_input_pipe[1], &m, sizeof(m));
+ (void)n;
+}
+
+unsigned droiddeck_stream_frames(void) { return atomic_load(&g_stream_frames); }
+
static void render_scene(void) {
+ if (atomic_load(&g_stream_on)) { render_stream(); return; }
struct draw_list dl = {0};
struct surface *s;
int w, h;
@@ -3082,6 +3201,8 @@ static int on_input_readable(int fd, uint32_t mask, void *data) {
break;
case 10: break;
case 11: axis_event(m.p1, m.p2); break;
+ case 20: stream_take(); break;
+ case 21: if (!m.p1) stream_forget_all(); schedule_render(); break;
default: deliver_pointer(&m); break;
}
}
diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
index 94bb581a02..9de2824d78 100644
--- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
+++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
@@ -238,7 +238,7 @@ static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) {
}
g_ring_w = w; g_ring_h = h; g_ring_fmt = fmt;
LOGD("framegen: generation ring %ux%u x%u", w, h, n);
- return 1;
+ return 2;
}
@@ -350,6 +350,7 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
fge_configure((uint32_t)mult, (uint32_t)atomic_load(&g_target), flow, hz,
atomic_load(&g_model), atomic_load(&g_preset));
}
+ const int size_changed = g_built_w != (uint32_t)w || g_built_h != (uint32_t)h || g_built_fmt != fmt;
if (!fge_prepare((uint32_t)w, (uint32_t)h, fmt)) {
if (fmt != VK_FORMAT_R8G8B8A8_UNORM && fge_unavailable()) {
refuse_format(fmt, kind, w, h, "build its chain");
@@ -361,17 +362,25 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
}
return 0;
}
- if (g_built_w != (uint32_t)w || g_built_h != (uint32_t)h || g_built_fmt != fmt) {
+ if (size_changed) {
g_built_w = (uint32_t)w; g_built_h = (uint32_t)h; g_built_fmt = fmt;
g_generating_logged = 0;
}
uint32_t want = (uint32_t)(mult - 1);
- if (!ensure_ring((uint32_t)w, (uint32_t)h, fmt, want)) {
+ const int ring = ensure_ring((uint32_t)w, (uint32_t)h, fmt, want);
+ if (!ring) {
if (fmt != VK_FORMAT_R8G8B8A8_UNORM) { refuse_format(fmt, kind, w, h, "make its generation ring"); return 0; }
FGLOG("no memory for the generation ring (%dx%d x%u); frame generation stays off", w, h, want);
mark_failed(kind);
return 0;
}
+ /* The ring and the engine's images are new on this frame. Dispatching into them now
+ * null-dereferenced Turnip (vkp_framegen_run, first Steam frame, 2560x1440 to the panel).
+ * Show this frame as it is; generation starts once the size has settled. */
+ if (size_changed || ring == 2) {
+ FGLOG("frame generation catches up at %dx%d; this frame is shown as it is", w, h);
+ return 0;
+ }
/* The pacer's source rate must be the game's, not this loop's: a loop slowed by its own
* generations would otherwise read as a slower game and justify even more generations. */
diff --git a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c
new file mode 100644
index 0000000000..0f8e1f61bf
--- /dev/null
+++ b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c
@@ -0,0 +1,170 @@
+#include "gpu_clock_pin.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../adrenotools/src/hook/kgsl.h"
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_t worker;
+static bool joinable;
+static atomic_bool running;
+
+struct pin {
+ int fd;
+ unsigned int context;
+ unsigned int memory;
+ unsigned int timestamp;
+ unsigned long gpuaddr;
+ uint32_t nop;
+ void *commands;
+ size_t size;
+};
+
+static struct pin pin = { .fd = -1 };
+
+static void release_pin(void) {
+ if (pin.context) {
+ struct kgsl_drawctxt_destroy destroy = { .drawctxt_id = pin.context };
+ ioctl(pin.fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &destroy);
+ }
+ if (pin.commands) munmap(pin.commands, pin.size);
+ if (pin.memory) {
+ struct kgsl_gpumem_free_id free_memory = { .id = pin.memory };
+ ioctl(pin.fd, IOCTL_KGSL_GPUMEM_FREE_ID, &free_memory);
+ }
+ if (pin.fd >= 0) close(pin.fd);
+ pin = (struct pin) { .fd = -1 };
+}
+
+static bool submit_pin(void) {
+ struct kgsl_command_object object = {
+ .gpuaddr = pin.gpuaddr,
+ .size = 2 * sizeof(uint32_t),
+ .flags = KGSL_CMDLIST_IB,
+ .id = pin.memory,
+ };
+ struct kgsl_gpu_command command = {
+ .flags = KGSL_CMDBATCH_PWR_CONSTRAINT,
+ .cmdlist = (uintptr_t)&object,
+ .cmdsize = sizeof(object),
+ .numcmds = 1,
+ .context_id = pin.context,
+ };
+ if (ioctl(pin.fd, IOCTL_KGSL_GPU_COMMAND, &command) < 0) return false;
+ pin.timestamp = command.timestamp;
+ return true;
+}
+
+static bool prepare_pin(void) {
+ pin.fd = open("/dev/kgsl-3d0", O_RDWR | O_CLOEXEC);
+ if (pin.fd < 0) return false;
+ struct kgsl_devinfo info = {0};
+ struct kgsl_device_getproperty device_info = {
+ .type = KGSL_PROP_DEVICE_INFO, .value = &info, .sizebytes = sizeof(info),
+ };
+ if (ioctl(pin.fd, IOCTL_KGSL_DEVICE_GETPROPERTY, &device_info) < 0) return false;
+ unsigned int core = info.chip_id >> 24;
+ if (!core) core = info.gpu_id / 100;
+ if (core < 3) { errno = ENODEV; return false; }
+ pin.nop = core >= 5 ? 0x70100001 : 0xc0001000;
+ struct kgsl_drawctxt_create context = {
+ .flags = KGSL_CONTEXT_NO_GMEM_ALLOC | KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_PWR_CONSTRAINT,
+ };
+ if (ioctl(pin.fd, IOCTL_KGSL_DRAWCTXT_CREATE, &context) < 0) return false;
+ pin.context = context.drawctxt_id;
+ struct kgsl_device_constraint_pwrlevel level = { .level = KGSL_CONSTRAINT_PWR_MAX };
+ struct kgsl_device_constraint constraint = {
+ .type = KGSL_CONSTRAINT_PWRLEVEL,
+ .context_id = pin.context,
+ .data = &level,
+ .size = sizeof(level),
+ };
+ struct kgsl_device_getproperty property = {
+ .type = KGSL_PROP_PWR_CONSTRAINT,
+ .value = &constraint,
+ .sizebytes = sizeof(constraint),
+ };
+ if (ioctl(pin.fd, IOCTL_KGSL_SETPROPERTY, &property) < 0) return false;
+ struct kgsl_gpumem_alloc_id memory = { .size = 4096 };
+ if (ioctl(pin.fd, IOCTL_KGSL_GPUMEM_ALLOC_ID, &memory) < 0) return false;
+ pin.memory = memory.id;
+ pin.gpuaddr = memory.gpuaddr;
+ pin.size = memory.mmapsize;
+ void *commands = mmap(NULL, pin.size, PROT_READ | PROT_WRITE, MAP_SHARED, pin.fd,
+ (off_t)pin.memory << 12);
+ if (commands == MAP_FAILED) return false;
+ pin.commands = commands;
+ // A3xx/A4xx use type-3 CP_NOP; newer cores use type-7 with zero odd-parity bits.
+ uint32_t *words = commands;
+ words[0] = pin.nop;
+ words[1] = 0;
+ struct kgsl_gpumem_sync_cache sync = { .id = pin.memory, .op = KGSL_GPUMEM_CACHE_CLEAN };
+ if (ioctl(pin.fd, IOCTL_KGSL_GPUMEM_SYNC_CACHE, &sync) < 0) return false;
+ return submit_pin();
+}
+
+static void *hold_pin(void *unused) {
+ (void)unused;
+ while (atomic_load(&running)) {
+ struct kgsl_device_waittimestamp_ctxtid wait = {
+ .context_id = pin.context,
+ .timestamp = pin.timestamp,
+ .timeout = 100,
+ };
+ if (ioctl(pin.fd, IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, &wait) < 0) {
+ if (errno == EINTR || errno == ETIMEDOUT) continue;
+ break;
+ }
+ // Constraints expire after idle_timer (normally 80 ms); renew with a NOP, keeping devfreq alive.
+ usleep(25000);
+ if (atomic_load(&running) && !submit_pin()) break;
+ }
+ if (atomic_exchange(&running, false))
+ __android_log_print(ANDROID_LOG_WARN, "GpuClockPin", "constraint stopped: %s", strerror(errno));
+ release_pin();
+ return NULL;
+}
+
+bool gpu_clock_pin_set(bool on) {
+ pthread_mutex_lock(&lock);
+ if (joinable) {
+ if (on && atomic_load(&running)) {
+ pthread_mutex_unlock(&lock);
+ return true;
+ }
+ atomic_store(&running, false);
+ pthread_join(worker, NULL);
+ joinable = false;
+ }
+ bool ok = true;
+ if (on) {
+ ok = prepare_pin();
+ if (ok) {
+ atomic_store(&running, true);
+ int error = pthread_create(&worker, NULL, hold_pin, NULL);
+ if (error) {
+ atomic_store(&running, false);
+ errno = error;
+ ok = false;
+ } else {
+ joinable = true;
+ }
+ }
+ if (!ok) {
+ int error = errno;
+ release_pin();
+ errno = error;
+ }
+ }
+ pthread_mutex_unlock(&lock);
+ return ok;
+}
diff --git a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h
new file mode 100644
index 0000000000..5fe17d102e
--- /dev/null
+++ b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include
+
+bool gpu_clock_pin_set(bool on);
diff --git a/app/src/main/cpp/waylandcomp/src/vk_loader.h b/app/src/main/cpp/waylandcomp/src/vk_loader.h
index 0e507f633a..2f5701dd6b 100644
--- a/app/src/main/cpp/waylandcomp/src/vk_loader.h
+++ b/app/src/main/cpp/waylandcomp/src/vk_loader.h
@@ -21,7 +21,7 @@
X(BindImageMemory) X(DestroyImage) X(FreeMemory) X(AcquireNextImageKHR) \
X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
- X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) \
+ X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) X(GetAndroidHardwareBufferPropertiesANDROID) \
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) \
\
X(CreateShaderModule) X(DestroyShaderModule) X(CreatePipelineLayout) X(DestroyPipelineLayout) \
diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.c b/app/src/main/cpp/waylandcomp/src/vk_present.c
index f171b3b930..388508ef19 100644
--- a/app/src/main/cpp/waylandcomp/src/vk_present.c
+++ b/app/src/main/cpp/waylandcomp/src/vk_present.c
@@ -21,6 +21,7 @@
#include
#include
#include
+#include
#define TAG "DroidDeckWayland"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
@@ -42,6 +43,7 @@ struct vkp_image {
};
static ANativeWindow *g_window;
+static int g_ahb_import;
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
static int g_dev_state;
static void device_lost(const char *where);
@@ -564,11 +566,10 @@ static int dev_init(void) {
}
g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops);
- static const char *const wanted_exts[5] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME, "VK_KHR_external_memory_fd",
- "VK_EXT_external_memory_dma_buf", "VK_EXT_image_drm_format_modifier",
- "VK_KHR_image_format_list"};
- const char *dev_exts[9] = {0};
- uint32_t n_dev_exts = 0;
+ static const char *const import_exts[4] = {"VK_KHR_external_memory_fd", "VK_EXT_external_memory_dma_buf",
+ "VK_EXT_image_drm_format_modifier", "VK_KHR_image_format_list"};
+ const char *dev_exts[9] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
+ uint32_t n_dev_exts = 1;
uint32_t ne = 0;
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, NULL);
VkExtensionProperties *exts = calloc(ne ? ne : 1, sizeof(*exts));
@@ -588,11 +589,10 @@ static int dev_init(void) {
}
if (len) droiddeck_log("gpu", " %s", names);
}
- for (unsigned i = 0; i < 5; i++) {
- if (has_ext(exts, ne, wanted_exts[i]))
- dev_exts[n_dev_exts++] = wanted_exts[i];
- else
- LOGE("present: driver MISSING %s (dmabuf import will fail)", wanted_exts[i]);
+ /* Only what the driver has: the system driver lacks the dma-buf ones, which the cloud player never needs. */
+ for (unsigned i = 0; i < 4; i++) {
+ if (has_ext(exts, ne, import_exts[i])) dev_exts[n_dev_exts++] = import_exts[i];
+ else LOGE("present: driver MISSING %s (dmabuf import will fail)", import_exts[i]);
}
int want_hdr_md = 0;
if (droiddeck_color_requested()) {
@@ -601,10 +601,12 @@ static int dev_init(void) {
}
const int want_sem_fd = has_ext(exts, ne, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME);
if (want_sem_fd) dev_exts[n_dev_exts++] = VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME;
- const int want_ahb = !g_library_name &&
- has_ext(exts, ne, VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME) &&
- has_ext(exts, ne, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
- if (want_ahb) {
+ /* The cloud player's decoded frames arrive as AHardwareBuffers (vkp_image_from_ahb). */
+ g_ahb_import = has_ext(exts, ne, VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME) &&
+ has_ext(exts, ne, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
+ /* The present path's own AHB import (#561) stays on the phone's own driver. */
+ const int want_ahb = !g_library_name && g_ahb_import;
+ if (g_ahb_import) {
dev_exts[n_dev_exts++] = VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME;
dev_exts[n_dev_exts++] = VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME;
}
@@ -1244,6 +1246,60 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
return img;
}
+void vkp_wait_idle(void) {
+ if (g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev);
+}
+
+struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) {
+ if (!ahb || dev_init() != 0) return NULL;
+ if (!g_ahb_import || !g_vk.GetAndroidHardwareBufferPropertiesANDROID) {
+ static int said;
+ if (!said) { said = 1; LOGE("ahb: the driver cannot import AHardwareBuffers (VK_ANDROID_external_memory_android_hardware_buffer)"); }
+ return NULL;
+ }
+ AHardwareBuffer_Desc desc;
+ AHardwareBuffer_describe(ahb, &desc);
+ VkAndroidHardwareBufferFormatPropertiesANDROID fp = {
+ .sType = VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID};
+ VkAndroidHardwareBufferPropertiesANDROID props = {
+ .sType = VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID, .pNext = &fp};
+ VkResult pr = g_vk.GetAndroidHardwareBufferPropertiesANDROID(g_dev, ahb, &props);
+ if (pr != VK_SUCCESS || fp.format == VK_FORMAT_UNDEFINED) {
+ LOGE("ahb: %ux%u format %u: properties %s, Vulkan format %d", desc.width, desc.height, desc.format,
+ vk_result_name(pr), (int)fp.format);
+ return NULL;
+ }
+ struct vkp_image *img = calloc(1, sizeof(*img));
+ if (!img) return NULL;
+ img->w = (int)desc.width; img->h = (int)desc.height; img->dmabuf = 1; img->fmt = fp.format; img->sampled = 1;
+ VkExternalMemoryImageCreateInfo ext = {
+ .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
+ .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID};
+ VkImageCreateInfo ici = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .pNext = &ext,
+ .imageType = VK_IMAGE_TYPE_2D, .format = fp.format, .extent = {desc.width, desc.height, 1},
+ .mipLevels = 1, .arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
+ .usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
+ .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
+ VkResult cr = g_vk.CreateImage(g_dev, &ici, NULL, &img->image);
+ if (cr != VK_SUCCESS) { LOGE("ahb: vkCreateImage %ux%u -> %s", desc.width, desc.height, vk_result_name(cr)); free(img); return NULL; }
+ int idx = -1;
+ for (int i = 0; i < 32; i++) if (props.memoryTypeBits & (1u << i)) { idx = i; break; }
+ VkImportAndroidHardwareBufferInfoANDROID imp = {
+ .sType = VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID, .buffer = ahb};
+ VkMemoryDedicatedAllocateInfo ded = {.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
+ .pNext = &imp, .image = img->image};
+ VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &ded,
+ .allocationSize = props.allocationSize, .memoryTypeIndex = (uint32_t)(idx < 0 ? 0 : idx)};
+ VkResult mr = idx < 0 ? VK_ERROR_FEATURE_NOT_PRESENT : g_vk.AllocateMemory(g_dev, &mai, NULL, &img->mem);
+ if (mr != VK_SUCCESS || g_vk.BindImageMemory(g_dev, img->image, img->mem, 0) != VK_SUCCESS) {
+ LOGE("ahb: importing %ux%u -> %s", desc.width, desc.height, vk_result_name(mr));
+ if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
+ g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL;
+ }
+ return img;
+}
+
static int shm_sampled(void) {
static int known;
if (!known) {
@@ -1891,6 +1947,10 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
VkImageLayout result_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
if (fx) {
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
+ /* Frame generation samples every output pixel. Upscaling first made it interpolate
+ * the whole panel (3200x1440 on a 1440p phone) and rebuild on Steam's first frame.
+ * Grade at the game's size instead; the screen blit still scales to the panel. */
+ if (fg) { mapped_w = scene_w; mapped_h = scene_h; }
vkp_effects_set_formats(scene_fmt, scene_fmt);
result = vkp_effects_run(cmd, scene_img, scene_w, scene_h, mapped_w, mapped_h, &rw, &rh);
result_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.h b/app/src/main/cpp/waylandcomp/src/vk_present.h
index 1a5f6a244b..bcbf36c508 100644
--- a/app/src/main/cpp/waylandcomp/src/vk_present.h
+++ b/app/src/main/cpp/waylandcomp/src/vk_present.h
@@ -39,6 +39,9 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
int vkp_image_is_dmabuf(const struct vkp_image *img);
struct vkp_image *vkp_image_create_shm(int w, int h);
+struct AHardwareBuffer;
+struct vkp_image *vkp_image_from_ahb(struct AHardwareBuffer *ahb);
+void vkp_wait_idle(void);
void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride);
int vkp_image_width(const struct vkp_image *img);
diff --git a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
index d30b46173f..572b6dd74f 100644
--- a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
+++ b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include "vk_present.h"
#include "droiddeck_ext.h"
#include "ahb_swapchain.h"
@@ -16,6 +17,7 @@
#include "effects_chain.h"
#include "cardboard.h"
#include "droiddeck_color.h"
+#include "gpu_clock_pin.h"
extern int droiddeck_wayland_run(void);
extern void droiddeck_wayland_set_scale_mode(int mode, int alignment);
@@ -26,6 +28,9 @@ extern int droiddeck_cursor_serial(void);
extern void droiddeck_wayland_send_key(int evdev, int state);
extern void droiddeck_wayland_send_scene_input(int type, int a, int b);
extern void droiddeck_wayland_vsync(int64_t frame_time_ns);
+extern void droiddeck_stream_set(int on);
+extern void droiddeck_stream_frame(AHardwareBuffer *ahb);
+extern unsigned droiddeck_stream_frames(void);
extern void droiddeck_wayland_output_resized(void);
extern void droiddeck_wayland_set_output_refresh_rate(int mhz);
extern volatile int g_fps_limit;
@@ -652,8 +657,14 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputDelete(JNIE
extern void adrenotools_set_turbo(bool turbo);
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) {
- (void)env; (void)clazz;
- adrenotools_set_turbo(on == JNI_TRUE);
+ (void)clazz;
+ if (!gpu_clock_pin_set(on == JNI_TRUE)) {
+ int saved_errno = errno;
+ jclass error = (*env)->FindClass(env, "java/lang/IllegalStateException");
+ if (error) (*env)->ThrowNew(env, error, strerror(saved_errno));
+ }
+ // Clear a legacy global pin when recovering its marker after an app upgrade or crash.
+ if (on != JNI_TRUE) adrenotools_set_turbo(false);
}
JNIEXPORT jint JNICALL
@@ -678,3 +689,21 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetCardboardSpatialP
(*env)->GetFloatArrayRegion(env, pos, 0, 3, p);
vkp_cardboard_set_spatial_pose(m, p, live ? 1 : 0);
}
+
+/* The Xbox Cloud Gaming native player: its decoded frames are the whole scene (no Wayland clients). */
+JNIEXPORT void JNICALL
+Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamMode(JNIEnv *env, jclass clazz, jboolean on) {
+ droiddeck_stream_set(on ? 1 : 0);
+}
+
+JNIEXPORT void JNICALL
+Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamFrame(JNIEnv *env, jclass clazz, jobject hardwareBuffer) {
+ if (!hardwareBuffer) return;
+ AHardwareBuffer *ahb = AHardwareBuffer_fromHardwareBuffer(env, hardwareBuffer);
+ if (ahb) droiddeck_stream_frame(ahb);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamFrames(JNIEnv *env, jclass clazz) {
+ return (jint)droiddeck_stream_frames();
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/App.kt b/app/src/main/java/com/droiddeck/launcher/App.kt
index 3fc4383772..928d7caa8c 100644
--- a/app/src/main/java/com/droiddeck/launcher/App.kt
+++ b/app/src/main/java/com/droiddeck/launcher/App.kt
@@ -25,9 +25,19 @@ class App : Application() {
if (android.os.Build.VERSION.SDK_INT >= 28) android.webkit.WebView.setDataDirectorySuffix("xbox")
return
}
+ if (process == "$packageName:xboxcloud") {
+ if (android.os.Build.VERSION.SDK_INT >= 28) android.webkit.WebView.setDataDirectorySuffix("xboxcloud")
+ return
+ }
+ if (process == "$packageName:xcloudnative") {
+ // The native cloud player: the stores log and nothing that touches the Linux session.
+ com.droiddeck.launcher.stores.StoresState.init(this)
+ return
+ }
if (process == "$packageName:vr_recovery" || process == "$packageName:rgb_diagnostic") return
CrashHandler.install(this)
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
+ com.droiddeck.launcher.session.SessionPrefs.applyNtsyncDefault(this)
com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this)
com.droiddeck.launcher.update.AppUpdates.init(this)
com.droiddeck.launcher.core.DownloadSource.init(this)
diff --git a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt
index b609379e31..bd9ef5f118 100644
--- a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt
+++ b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt
@@ -58,6 +58,8 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
private set
private var runtimePending by mutableStateOf(false)
private var sessionRunning by mutableStateOf(false)
+ var tpUbwcMode: String by mutableStateOf(SessionPrefs.TP_UBWC_AUTO)
+ private set
val uiMode: String get() = when (mode) {
SessionPrefs.GPU_DRIVERS_AUTO -> GPU_MODE_AUTO
@@ -77,8 +79,16 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
mode = uiMode, display = displaySlot(), runtime = runtimeSlot(),
canRestart = !sessionRunning,
checkedAt = TurnipReleases.cached(activity)?.checkedAt ?: 0L,
+ tpUbwcMode = tpUbwcMode.takeIf { gpu.model == 740 },
+ tpUbwcRestartRequired = com.droiddeck.launcher.gpu.TpUbwcHint.restartRequired(activity),
)
+ fun chooseTpUbwcMode(mode: String) {
+ if (gpu.model != 740) return
+ SessionPrefs.setTpUbwcMode(activity, mode)
+ tpUbwcMode = mode
+ }
+
private fun slotSource(chosenDefault: Boolean, defaultLabel: Int): String = activity.getString(when {
uiMode == GPU_MODE_AUTO -> R.string.gpu_src_auto
uiMode == GPU_MODE_PAIR && pairRows.any { it.active } -> R.string.gpu_src_pair
@@ -128,6 +138,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
var androidSelected by mutableStateOf("")
fun refreshDrivers() {
+ tpUbwcMode = SessionPrefs.tpUbwcMode(activity)
val lm = LinuxVulkanDriverManager(activity)
fun origin(id: String) = if (TurnipReleases.isDownloaded(activity, id)) DriverRow.DOWNLOADED else DriverRow.IMPORTED
val bundles = DriverBundle.all(activity)
diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
similarity index 97%
rename from app/src/main/java/com/droiddeck/launcher/MainActivity.kt
rename to app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
index 946507d834..60641dc0db 100644
--- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
@@ -80,7 +80,7 @@ import com.droiddeck.launcher.session.GameStorage
import com.droiddeck.launcher.input.SecondScreenDisplay
import com.droiddeck.launcher.input.SecondScreenDisplays
-class MainActivity : ComponentActivity() {
+class FrontEndActivity : ComponentActivity() {
override fun attachBaseContext(newBase: android.content.Context) {
super.attachBaseContext(newBase)
com.droiddeck.launcher.core.AppLanguage.applyTo(this, newBase)
@@ -91,7 +91,7 @@ class MainActivity : ComponentActivity() {
private val components = ComponentsMenu(this, ui)
private val decky = DeckyMenu(this, ui)
private val updates = UpdatesMenu(this, ui)
- private val protons = ProtonMenu(this, ui)
+ private val protons = ProtonMenu(this, ui) { !busy && flood == null && pkgStage == null && components.compBusy == null }
private var installed by mutableStateOf(null)
private var flood by mutableStateOf(null)
@@ -120,6 +120,7 @@ class MainActivity : ComponentActivity() {
private var glThread by mutableStateOf(true)
private var noGlError by mutableStateOf(true)
private var returnAfterGame by mutableStateOf(true)
+ private var shaderPrecache by mutableStateOf(null)
private var steamRepairQueued by mutableStateOf(false)
private var mangoapp by mutableStateOf(true)
private var steamController by mutableStateOf(SessionPrefs.CONTROLLER_DECK)
@@ -159,6 +160,7 @@ class MainActivity : ComponentActivity() {
private var gpuClockPin by mutableStateOf(false)
private var prootNoSeccomp by mutableStateOf(false)
private var prootFastPath by mutableStateOf(true)
+ private var cursorComposite by mutableStateOf(false)
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
private var phantomWarning by mutableStateOf(null)
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
@@ -166,7 +168,7 @@ class MainActivity : ComponentActivity() {
private var directAudio by mutableStateOf(false)
private var picturePosition by mutableStateOf("center")
private var stretch16x9 by mutableStateOf(false)
- private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+ private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
private var launcherFullscreen by mutableStateOf(true)
private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO)
private var downloadMirror by mutableStateOf("")
@@ -397,8 +399,6 @@ class MainActivity : ComponentActivity() {
private var touchMode by mutableStateOf(SessionPrefs.TOUCH_AUTO)
private var suspendPolicy by mutableStateOf(SessionPrefs.SUSPEND_MANUAL)
private var steamDownloadsInBackground by mutableStateOf(false)
- private var zramCompression by mutableStateOf(false)
- private var zramSupported by mutableStateOf(null)
private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO)
private var backActionsInverted by mutableStateOf(false)
private var gameStorage by mutableStateOf("")
@@ -469,7 +469,13 @@ class MainActivity : ComponentActivity() {
}
private fun launchFlooded(f: PendingFlood) {
- if (busy || LinuxRuntimeInstaller.isBusy()) { flood = null; floodProgress = 0f; return }
+ if (busy || LinuxRuntimeInstaller.isBusy() || protons.protonBusyId != null ||
+ ProtonExtras.installInProgress || pkgStage != null) {
+ flood = null
+ floodProgress = 0f
+ com.droiddeck.launcher.ui.LaunchOrigin.flooding = null
+ return
+ }
val signal = com.droiddeck.launcher.ui.Themes.byId(theme).signal
super.startActivity(f.intent.putExtra(com.droiddeck.launcher.ui.EXTRA_FLOOD, signal.toArgb()))
overridePendingTransition(0, 0)
@@ -553,12 +559,12 @@ class MainActivity : ComponentActivity() {
}
startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME)
.putExtra(SessionActivity.EXTRA_STEAMVR, steamVr)
- .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
+ .returnTo(returnHome)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
return true
}
return startSession(Intent(this, SessionActivity::class.java)
- .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
+ .returnTo(returnHome)
.apply {
if (game.gameIdString == com.droiddeck.launcher.gpu.SteamVr.APP_ID) {
putExtra(SessionActivity.EXTRA_STEAMVR, true)
@@ -569,6 +575,12 @@ class MainActivity : ComponentActivity() {
}, steamSession = true)
}
+ private fun Intent.returnTo(returnHome: Boolean): Intent {
+ val task = taskId
+ return putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
+ .apply { if (returnHome) putExtra(SessionActivity.EXTRA_LINK_TASK, task) }
+ }
+
private fun launchWithoutSteam(game: Library.SteamGame, returnHome: Boolean): Boolean {
val app = applicationContext
Thread({
@@ -582,7 +594,7 @@ class MainActivity : ComponentActivity() {
}
com.droiddeck.launcher.session.NoSteamLaunch.remember(command)
val next = Intent(this, SessionActivity::class.java)
- .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
+ .returnTo(returnHome)
.putExtra(SessionService.EXTRA_MODE, SessionService.MODE_RUN)
.putExtra(SessionService.EXTRA_PROGRAM, command.program)
.putExtra(SessionService.EXTRA_PROGRAM_ARGS, command.args.toTypedArray())
@@ -591,7 +603,7 @@ class MainActivity : ComponentActivity() {
SessionState.stopRequested -> android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
SessionState.mode == SessionService.MODE_RUN && SessionState.program == command.program && SessionState.programArgs == command.args ->
startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME)
- .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
+ .returnTo(returnHome)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
else -> pendingSwitch = next
}
@@ -708,7 +720,7 @@ class MainActivity : ComponentActivity() {
else {
switchPoll = null
switchingTo = null
- android.widget.Toast.makeText(this@MainActivity, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
+ android.widget.Toast.makeText(this@FrontEndActivity, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
}
return
}
@@ -766,6 +778,7 @@ class MainActivity : ComponentActivity() {
downloadPrefix = DownloadSource.custom(this)
DownloadSource.probe()
animationsEnabled = SessionPrefs.animationsEnabled(this)
+ LauncherIcon.repair(this, intent?.component)
launcherIcon = LauncherIcon.current(this)
gameStoresEnabled = SessionPrefs.gameStoresEnabled(this)
gameStoresSpeedTier = SessionPrefs.gameStoresSpeedTier(this)
@@ -1067,7 +1080,7 @@ class MainActivity : ComponentActivity() {
onWirelessAdbPair = { host, port, code, complete ->
Thread({
val result = runCatching {
- kotlinx.coroutines.runBlocking { WirelessAdbFix.pair(this@MainActivity, host, port, code) }
+ kotlinx.coroutines.runBlocking { WirelessAdbFix.pair(this@FrontEndActivity, host, port, code) }
}
val error = result.exceptionOrNull()?.let { it.localizedMessage ?: getString(R.string.main_wadb_pair_failed) }
ui.post { complete(error) }
@@ -1075,13 +1088,13 @@ class MainActivity : ComponentActivity() {
},
onFindWirelessAdbPort = { host, complete ->
Thread({
- val port = WirelessAdbFix.findConnectPort(this@MainActivity, host)
+ val port = WirelessAdbFix.findConnectPort(this@FrontEndActivity, host)
ui.post { complete(port) }
}, "wireless-adb-discovery").start()
},
onWirelessAdbApply = { host, port, enabled, complete ->
Thread({
- val result = runCatching { WirelessAdbFix.setChildProcessLimit(this@MainActivity, host, port, enabled) }
+ val result = runCatching { WirelessAdbFix.setChildProcessLimit(this@FrontEndActivity, host, port, enabled) }
val error = result.exceptionOrNull()?.let { it.localizedMessage ?: getString(R.string.main_wadb_command_failed) }
ui.post {
if (error == null) refreshPhantomStatus()
@@ -1091,7 +1104,7 @@ class MainActivity : ComponentActivity() {
},
onSetPhantomProcessLimit = { enabled, complete ->
Thread({
- val result = runCatching { WirelessAdbFix.setUsingSavedPairing(this@MainActivity, enabled) }
+ val result = runCatching { WirelessAdbFix.setUsingSavedPairing(this@FrontEndActivity, enabled) }
val error = result.exceptionOrNull()?.let { it.localizedMessage ?: getString(R.string.main_wadb_unavailable) }
ui.post {
if (error == null) refreshPhantomStatus()
@@ -1147,7 +1160,7 @@ class MainActivity : ComponentActivity() {
showNonAdreno?.let { release ->
ConfirmDialog(
title = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_title),
- text = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_text, com.droiddeck.launcher.core.DeviceSupport.gpuName(this@MainActivity), release.size / 1e6),
+ text = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_text, com.droiddeck.launcher.core.DeviceSupport.gpuName(this@FrontEndActivity), release.size / 1e6),
confirm = androidx.compose.ui.res.stringResource(R.string.main_install_anyway),
onConfirm = { showNonAdreno = null; install(release) },
onDismiss = { showNonAdreno = null },
@@ -1544,6 +1557,7 @@ class MainActivity : ComponentActivity() {
onRestoreBundled = { TurnipDriver(this).restoreBundled(); drivers.refreshDrivers() },
onMode = { m -> drivers.chooseMode(m) },
onRestart = { drivers.restartApp() },
+ onTpUbwcMode = { drivers.chooseTpUbwcMode(it) },
),
protons = com.droiddeck.launcher.ui.ProtonsState(
rows = protons.protonRows, busyId = protons.protonBusyId, stage = protons.protonStage, percent = protons.protonPercent,
@@ -1650,8 +1664,6 @@ class MainActivity : ComponentActivity() {
touchMode = touchMode,
suspendPolicy = suspendPolicy,
steamDownloadsInBackground = steamDownloadsInBackground,
- zramCompression = if (mode == SessionService.MODE_STEAM) zramCompression else null,
- zramSupported = zramSupported,
pipSupported = com.droiddeck.launcher.session.SessionPipController.supported(this),
pipAutoEnter = pipAutoEnter,
unfoldedControls = if (mode == SessionService.MODE_STEAM &&
@@ -1671,6 +1683,7 @@ class MainActivity : ComponentActivity() {
syncBackend = if (mode == SessionService.MODE_STEAM) SessionPrefs.syncBackendOf(fastSync, fsyncFirst, syncFallback) else null,
steamClientArch = if (mode == SessionService.MODE_STEAM) steamClientArch else null,
returnAfterGame = if (mode == SessionService.MODE_STEAM) returnAfterGame else null,
+ shaderPrecache = if (mode == SessionService.MODE_STEAM) shaderPrecache else null,
steamRepairQueued = steamRepairQueued,
mangoapp = mangoapp,
steamController = if (mode == SessionService.MODE_STEAM) steamController else null,
@@ -1720,7 +1733,6 @@ class MainActivity : ComponentActivity() {
SessionPrefs.setSteamDownloadsInBackground(this, enabled)
steamDownloadsInBackground = enabled
},
- onZramCompression = { on -> SessionPrefs.setZramCompression(this, on); zramCompression = on },
onPipAutoEnter = { on -> SessionPrefs.setPipAutoEnter(this, on); pipAutoEnter = on },
onUnfoldedControls = { on -> SessionPrefs.setUnfoldedControls(this, on); unfoldedControls = on },
onUnfoldedControlsWithController = { on ->
@@ -1758,9 +1770,15 @@ class MainActivity : ComponentActivity() {
syncFallback = SessionPrefs.syncFallback(this)
},
onSteamRepair = { steamRepairQueued = SteamRepair.queue(this) },
- onSteamClientArch = { id -> SessionPrefs.setSteamClientArch(this, id); steamClientArch = id; refresh() },
+ onSteamClientArch = { id ->
+ SessionPrefs.setSteamClientArch(this, id)
+ steamClientArch = id
+ loadShaderPrecache(mode)
+ refresh()
+ },
onMangoapp = { on -> SessionPrefs.setMangoapp(this, on); mangoapp = on },
onReturnAfterGame = { on -> SessionPrefs.setReturnAfterGame(this, on); returnAfterGame = on },
+ onShaderPrecache = { on -> SessionPrefs.setShaderPrecache(this, on); shaderPrecache = on },
onSteamController = { id -> SessionPrefs.setSteamController(this, id); steamController = id },
onRunSteamAtStartup = { on ->
SessionPrefs.setRunSteamAtStartup(this, on)
@@ -1801,7 +1819,8 @@ class MainActivity : ComponentActivity() {
fsyncFirst = fsyncFirst,
gamescopeRealtime = gamescopeRealtime,
gpuClockPin = gpuClockPin,
- prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, guestHostname = guestHostname, phantomWarning = phantomWarning,
+ prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, cursorComposite = cursorComposite,
+ guestHostname = guestHostname, phantomWarning = phantomWarning,
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on },
onZinkLazy = { on -> SessionPrefs.setZinkLazy(this, on); zinkLazy = on },
@@ -1815,6 +1834,7 @@ class MainActivity : ComponentActivity() {
onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on },
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
+ onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) },
onClientCore = { core, on ->
clientCores = if (on) clientCores + core else clientCores - core
@@ -1915,6 +1935,19 @@ class MainActivity : ComponentActivity() {
private var pipAutoEnter by mutableStateOf(false)
private var unfoldedControls by mutableStateOf(false)
private var unfoldedControlsWithController by mutableStateOf(false)
+ private var shaderPrecacheGeneration = 0
+
+ private fun loadShaderPrecache(mode: String) {
+ val generation = ++shaderPrecacheGeneration
+ shaderPrecache = null
+ if (mode != SessionService.MODE_STEAM) return
+ Thread({
+ val precache = SessionPrefs.shaderPrecache(this)
+ ui.post {
+ if (!isDestroyed && generation == shaderPrecacheGeneration) shaderPrecache = precache
+ }
+ }, "shader-precache").start()
+ }
private fun loadModeSettings(mode: String) {
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
@@ -1930,6 +1963,7 @@ class MainActivity : ComponentActivity() {
steamRepairQueued = SteamRepair.queued(this)
mangoapp = SessionPrefs.mangoapp(this)
returnAfterGame = SessionPrefs.returnAfterGame(this)
+ loadShaderPrecache(mode)
steamController = SessionPrefs.steamController(this)
runSteamAtStartup = SessionPrefs.runSteamAtStartup(this)
loadBootMovie()
@@ -1952,9 +1986,6 @@ class MainActivity : ComponentActivity() {
storageDiagnostics = SessionPrefs.storageDiagnosticsEnabled(this)
settingsMode = mode
Thread({
- val zram = com.droiddeck.launcher.core.ZramSupport.supported()
- val zramOn = SessionPrefs.zramCompression(this)
- ui.post { zramSupported = zram; zramCompression = zramOn }
drivers.refreshDrivers()
val storage = GameStorage.options(this)
val deckyInstalled = if (mode == SessionService.MODE_STEAM) DeckyManager.installed(this) else null
@@ -2003,6 +2034,7 @@ class MainActivity : ComponentActivity() {
gpuClockPin = SessionPrefs.gpuClockPin(this)
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
prootFastPath = SessionPrefs.prootFastPath(this)
+ cursorComposite = SessionPrefs.cursorComposite(this)
guestHostname = SessionPrefs.guestHostname(this)
refreshPhantomStatus()
}
@@ -2083,7 +2115,7 @@ class MainActivity : ComponentActivity() {
steamGamesX64 = scannedX64
steamGames = all.map { g ->
val newer = current[g.appId]
- if (newer != null && g.library != Library.ADDED && steamArtRefreshes[g.appId] != artRefreshesAtStart[g.appId]) g.withArt(newer.art, newer.hero, newer.icon) else g
+ if (newer != null && g.library != Library.ADDED && steamArtRefreshes[g.appId] != artRefreshesAtStart[g.appId]) g.withArt(newer.art, newer.hero, newer.icon, newer.logo) else g
}
shortcutLibraryScanning = false
handleGameLink(all)
diff --git a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
index 54526834b5..71304e8837 100644
--- a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
@@ -23,7 +23,7 @@ class HomeActivity : Activity() {
.setAction(SessionService.ACTION_HOME_GUIDE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
} else {
- Intent(this, MainActivity::class.java)
+ Intent(this, FrontEndActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
}
startActivity(destination)
diff --git a/app/src/main/java/com/droiddeck/launcher/LauncherIcon.kt b/app/src/main/java/com/droiddeck/launcher/LauncherIcon.kt
index 9183df76e8..89c33523ac 100644
--- a/app/src/main/java/com/droiddeck/launcher/LauncherIcon.kt
+++ b/app/src/main/java/com/droiddeck/launcher/LauncherIcon.kt
@@ -8,7 +8,7 @@ object LauncherIcon {
const val DARK = "dark"
const val LIGHT = "light"
- private val aliases = linkedMapOf(DARK to "com.droiddeck.launcher.LauncherDark", LIGHT to "com.droiddeck.launcher.LauncherLight")
+ private val aliases = linkedMapOf(DARK to "com.droiddeck.launcher.MainActivity", LIGHT to "com.droiddeck.launcher.LauncherLight")
val options: List> = listOf(
DARK to R.string.setup_launcher_icon_dark,
@@ -29,6 +29,12 @@ object LauncherIcon {
fun activity(context: Context): ComponentName = component(context, current(context))
+ fun repair(context: Context, launchedFrom: ComponentName?) {
+ if (!enabled(context, DARK) || !enabled(context, LIGHT) || launchedFrom == component(context, DARK)) return
+ context.packageManager.setComponentEnabledSetting(component(context, DARK),
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
+ }
+
fun set(context: Context, style: String) {
if (style !in aliases || style == current(context)) return
val pm = context.packageManager
diff --git a/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt b/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt
index 5bd651cf5f..5e49b5cf5d 100644
--- a/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt
@@ -1,6 +1,8 @@
package com.droiddeck.launcher
import android.os.Handler
+import android.util.Log
+import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
@@ -8,31 +10,47 @@ import androidx.compose.runtime.setValue
import com.droiddeck.launcher.session.ProtonExtras
import com.droiddeck.launcher.ui.ProtonRow
import com.droiddeck.launcher.session.SessionState
+import com.droiddeck.launcher.session.SessionPhase
+import com.droiddeck.launcher.frontend.AutoComponents
+import com.droiddeck.launcher.runtime.LinuxRuntime
+import com.droiddeck.launcher.runtime.LinuxRuntimeInstaller
-internal class ProtonMenu(private val activity: android.app.Activity, private val ui: android.os.Handler) {
+internal class ProtonMenu(
+ private val activity: android.app.Activity,
+ private val ui: Handler,
+ private val idle: () -> Boolean = { true },
+) {
var protonRows by mutableStateOf>(emptyList())
var protonBusyId by mutableStateOf(null)
var protonStage by mutableStateOf(null)
var protonPercent by mutableIntStateOf(-1)
private val checking = java.util.concurrent.atomic.AtomicBoolean(false)
+ @VisibleForTesting internal var installer: (ProtonExtras.Tool, (String, Int) -> Unit) -> String? =
+ { tool, progress -> ProtonExtras.install(activity, tool, progress) }
- fun installProton(id: String) {
+ fun installProton(id: String, automatic: Boolean = false) {
val tool = ProtonExtras.tools.firstOrNull { it.id == id } ?: return
- if (protonBusyId != null || SessionState.running) return
+ if (protonBusyId != null || ProtonExtras.installInProgress || SessionState.running) return
ProtonExtras.unqueue(activity, tool)
protonBusyId = id
protonStage = activity.getString(R.string.store_starting)
protonPercent = -1
Thread({
- val problem = ProtonExtras.install(activity, tool) { label, value ->
- ui.post { protonStage = label; protonPercent = value }
- }
+ val problem = runCatching {
+ installer(tool) { label, value ->
+ ui.post { protonStage = label; protonPercent = value }
+ }
+ }.getOrElse { it.message ?: it.javaClass.simpleName }
ui.post {
protonBusyId = null
protonStage = null
protonPercent = -1
refreshProtons()
- if (problem != null) android.widget.Toast.makeText(activity, problem, android.widget.Toast.LENGTH_LONG).show()
+ if (problem != null) {
+ if (automatic) Log.w("ProtonMenu", "auto-update ${tool.id}: $problem")
+ else android.widget.Toast.makeText(activity, problem, android.widget.Toast.LENGTH_LONG).show()
+ }
+ if (automatic) ensureAutoUpdates()
}
}, "install-proton-$id").start()
}
@@ -64,7 +82,25 @@ internal class ProtonMenu(private val activity: android.app.Activity, private va
if (!checking.compareAndSet(false, true)) return
Thread({
val asked = try { ProtonExtras.checkLatest(activity, force) } catch (_: Throwable) { false } finally { checking.set(false) }
- if (asked) ui.post { refreshProtons() }
+ ui.post {
+ if (asked) refreshProtons()
+ ensureAutoUpdates()
+ }
}, "proton-updates").start()
}
+
+ internal fun ensureAutoUpdates(now: Long = System.currentTimeMillis()) {
+ if (activity.isFinishing || activity.isDestroyed || !idle() || protonBusyId != null ||
+ ProtonExtras.installInProgress || SessionState.running || LinuxRuntimeInstaller.isBusy() ||
+ SessionState.phase !in setOf(SessionPhase.IDLE, SessionPhase.FAILED) ||
+ !LinuxRuntime.isInstalled(activity) || !AutoComponents.online(activity) || AutoComponents.unfavourable(activity)) return
+ val attempts = activity.getSharedPreferences("proton-auto-updates", android.content.Context.MODE_PRIVATE)
+ val (tool, update) = ProtonExtras.tools.firstNotNullOfOrNull { tool ->
+ val update = ProtonExtras.update(activity, tool) ?: return@firstNotNullOfOrNull null
+ val previous = attempts.getLong("${tool.id}.at", 0L)
+ if (attempts.getString("${tool.id}.tag", null) != update || now - previous !in 0 until 15L * 60 * 1000) tool to update else null
+ } ?: return
+ attempts.edit().putString("${tool.id}.tag", update).putLong("${tool.id}.at", now).apply()
+ installProton(tool.id, automatic = true)
+ }
}
diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt
index baaa8a6ea2..714a916ee0 100644
--- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt
@@ -329,6 +329,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private var glassesSettings by mutableStateOf(Glasses.settings.value)
private var glassesScreen: GlassesScreen? = null
private var glassesOutputActive by mutableStateOf(false)
+ private var pausedFrame by mutableStateOf(null)
+ private var pausedFrameWanted = false
private var trackingRecovery by mutableStateOf(null)
private var glasses3dForVr = false
private var ended = false
@@ -1015,9 +1017,20 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
SessionAchievements(inFront.game, inFront.title, onClose = ::closeAchievements)
}
com.droiddeck.launcher.ui.AchievementNotificationOverlay()
- if (SessionState.suspended) SessionPausedOverlay(
+ // Auto and Native resume on their own as the session comes back; only a failed resume needs the button.
+ val autoResume = suspendPolicy == SessionPrefs.SUSPEND_AUTO || suspendPolicy == SessionPrefs.SUSPEND_NATIVE
+ SessionPausedOverlay(
+ suspended = SessionState.suspended && (!autoResume || SessionState.resumeFailed),
+ engaged = SessionState.resumeRequested || SessionState.resuming,
+ failures = SessionState.resumeFailures,
+ frame = pausedFrame,
title = pausedTitle(),
onResume = { SessionService.resume(this@SessionActivity) },
+ onFrameNeeded = ::requestPausedFrame,
+ onHidden = {
+ pausedFrame = null
+ pausedFrameWanted = false
+ },
)
if (leaving) com.droiddeck.launcher.ui.FloodSpread(
com.droiddeck.launcher.ui.LocalPalette.current.signal,
@@ -1695,7 +1708,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "compositor.start driver=$driverId")
CompositorHost.startOrAttach(
- holder.surface, runtimeDir.path,
+ this, holder.surface, runtimeDir.path,
driverId?.let { turnip.driverPath(it) }, driverId?.let { turnip.libraryName(it) },
applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(), outputFpsLimit(),
)
@@ -1882,7 +1895,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
override fun run() {
if (!watching) return
if (::pip.isInitialized) pip.refresh()
- if (SessionState.stopRequested && !SessionState.running && !installingRuntime) {
+ if (SessionState.stopRequested && !SessionState.running && !installingRuntime &&
+ SessionState.phase != SessionPhase.STOPPING) {
SessionState.stopRequested = false
SessionEvents.transition(SessionPhase.IDLE, "session.cancelled")
collectStartArtifacts("session start cancelled")
@@ -1915,6 +1929,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
SessionState.relaunch?.let { next ->
SessionState.relaunch = null
next.putExtra(EXTRA_RETURN_HOME, intent.getBooleanExtra(EXTRA_RETURN_HOME, false))
+ next.putExtra(EXTRA_LINK_TASK, intent.getIntExtra(EXTRA_LINK_TASK, -1))
setIntent(next)
recreate()
return@runOnUiThread
@@ -2885,6 +2900,50 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
if (down || code !in gestureKeysDown) WaylandCompositor.nativeSendKey(code, if (down) 1 else 0)
}
+ // The frozen game cannot draw again, so the paused overlay shows a copy taken while the surface still holds its frame.
+ private fun capturePausedFrame() {
+ if (!SessionState.running || pipUi || isInPictureInPictureMode || glassesOutputActive) return
+ if (SessionState.suspended && pausedFrame != null) return
+ if (suspendPolicy == SessionPrefs.SUSPEND_NEVER || !::surfaceView.isInitialized) return
+ if (surfaceView.holder.surface?.isValid != true) return
+ val width = surfaceView.width
+ val height = surfaceView.height
+ if (width <= 0 || height <= 0) return
+ val scale = minOf(1f, PAUSED_FRAME_MAX_EDGE / maxOf(width, height).toFloat())
+ val bitmap = try {
+ android.graphics.Bitmap.createBitmap(
+ maxOf(1, (width * scale).toInt()), maxOf(1, (height * scale).toInt()), android.graphics.Bitmap.Config.ARGB_8888,
+ )
+ } catch (_: OutOfMemoryError) {
+ return
+ }
+ val surfaceAt = IntArray(2).also { surfaceView.getLocationInWindow(it) }
+ val overlayAt = IntArray(2).also { sessionOverlay.getLocationInWindow(it) }
+ val left = surfaceAt[0] - overlayAt[0]
+ val top = surfaceAt[1] - overlayAt[1]
+ val bounds = android.graphics.Rect(left, top, left + width, top + height)
+ try {
+ android.view.PixelCopy.request(surfaceView, bitmap, { result ->
+ if (result == android.view.PixelCopy.SUCCESS && !isDestroyed) {
+ pausedFrame = com.droiddeck.launcher.ui.PausedFrame(bitmap.asImageBitmap(), bounds)
+ pausedFrameWanted = false
+ } else {
+ bitmap.recycle()
+ }
+ }, uiHandler)
+ } catch (_: IllegalArgumentException) {
+ bitmap.recycle()
+ }
+ }
+
+ // Sessions that froze from picture-in-picture, or before onPause could copy a frame, have none; the
+ // compositor shows the frozen frame again once its output is back, so copy it from there.
+ private fun requestPausedFrame() {
+ if (pausedFrame != null) return
+ pausedFrameWanted = true
+ if (resumed && surfaceW > 0) capturePausedFrame()
+ }
+
private fun pipBounds(): android.graphics.Rect {
val rect = android.graphics.Rect()
if (!::surfaceView.isInitialized || !surfaceView.getGlobalVisibleRect(rect)) return rect
@@ -2995,6 +3054,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
return
}
if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true)
+ if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1))
setIntent(intent)
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
SessionState.steamVr = true
@@ -3015,6 +3075,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
applyFollowOrientation(resources.configuration)
if (runtimeRemovalBlocked) return
+ if (!SessionState.suspended) pausedFrame = null
com.droiddeck.launcher.ui.Motion.refresh(this)
refreshHomeApp()
if (intent?.action == SessionService.ACTION_RESUME) {
@@ -3040,6 +3101,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
override fun onPause() {
if (runtimeRemovalBlocked) { super.onPause(); return }
+ capturePausedFrame()
sessionClipboard.stop()
if (::touchscreenGestures.isInitialized) touchscreenGestures.cancel()
if (::touchpad.isInitialized) touchpad.cancel()
@@ -3278,6 +3340,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
surfaceView.visibility = if (glassesOutputActive) View.INVISIBLE else View.VISIBLE
Log.i(TAG, "compositor output attached: " +
if (glassesOutputActive) "glasses display ${glassesScreen?.display?.displayId}" else "phone")
+ if (pausedFrameWanted) uiHandler.postDelayed({
+ if (pausedFrameWanted && pausedFrame == null && resumed) capturePausedFrame()
+ }, PAUSED_FRAME_REDRAW_MS)
}
private fun restorePhoneOutput(screen: GlassesScreen) {
@@ -3512,17 +3577,33 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
return
}
- super.finish()
if (!closeAtOnce && intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) {
com.droiddeck.launcher.ui.QuitFlood.take()
com.droiddeck.launcher.ui.LaunchOrigin.flooding = null
- startActivity(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
- }
+ closeLinkTasks()
+ if (!isTaskRoot) moveTaskToBack(true)
+ super.finishAndRemoveTask()
+ } else super.finish()
if (quitFlooded) overridePendingTransition(0, 0)
else overridePendingTransition(R.anim.session_hold, R.anim.session_sink)
}
+ private fun closeLinkTasks() {
+ val linkTask = intent.getIntExtra(EXTRA_LINK_TASK, -1)
+ if (linkTask == -1) return
+ val tasks = runCatching { getSystemService(android.app.ActivityManager::class.java)?.appTasks }.getOrNull().orEmpty()
+ for (task in tasks) {
+ runCatching {
+ val info = task.taskInfo
+ @Suppress("DEPRECATION")
+ val id = if (android.os.Build.VERSION.SDK_INT >= 29) info.taskId else info.persistentId
+ val base = info.baseIntent
+ if (id == linkTask && base.component?.className == FrontEndActivity::class.java.name &&
+ com.droiddeck.launcher.frontend.GameLaunchIntent.accepts(base.action)) task.finishAndRemoveTask()
+ }
+ }
+ }
+
private fun completeLeave() {
if (isFinishing) return
val signal = com.droiddeck.launcher.ui.Themes.current(this).signal
@@ -3534,9 +3615,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
companion object {
const val EXTRA_RETURN_HOME = "returnHome"
+ const val EXTRA_LINK_TASK = "linkTask"
const val EXTRA_STEAMVR = "steamVr"
const val EXTRA_REPAIR_RUNTIME = "repairRuntime"
private const val LEAVE_TIMEOUT_MS = 1_500L
+ private const val PAUSED_FRAME_MAX_EDGE = 1920f
+ private const val PAUSED_FRAME_REDRAW_MS = 150L
private const val TAG = "SessionActivity"
private var startedScreens = 0
private const val FEX_MISSING = "droiddeck-fex: x86 Linux programs need"
diff --git a/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java b/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java
index 15ffd7bdb0..f1fa534927 100644
--- a/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java
+++ b/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java
@@ -17,6 +17,8 @@ public class DirectAudioRelayComponent extends SessionPart {
private File logFile;
private final File micFifoPath;
private volatile int pid = -1;
+ private final Object micLock = new Object();
+ private boolean micHot;
public DirectAudioRelayComponent(File socketPath, File micFifoPath) {
this.socketPath = socketPath;
@@ -30,6 +32,9 @@ public class DirectAudioRelayComponent extends SessionPart {
@Override
public void start() {
stop();
+ synchronized (micLock) {
+ micHot = false;
+ }
File binary = new File(app().getApplicationInfo().nativeLibraryDir, BINARY);
if (!binary.isFile()) {
Log.w(TAG, "helper missing at " + binary + "; DirectAudio will report itself unavailable");
@@ -79,12 +84,40 @@ public class DirectAudioRelayComponent extends SessionPart {
app().getFilesDir(), null,
line -> {
Log.i(TAG, line);
+ trackMic(line);
if (log != null) synchronized (log) { log.println(line); log.flush(); }
});
Log.i(TAG, "started pid=" + pid + " socket=" + socketPath
+ (micFifoPath != null ? " mic=" + micFifoPath : " (no microphone)"));
}
+ private void trackMic(String line) {
+ boolean start = line.startsWith("DA-Relay: mic start ");
+ if (!start && !line.startsWith("DA-Relay: mic stop ")) return;
+ synchronized (micLock) {
+ micHot = start;
+ micLock.notifyAll();
+ }
+ }
+
+ // Android keeps the input stream's wake lock while a frozen helper still has it started.
+ public boolean awaitMicReleased(long timeoutMs) {
+ long deadline = System.currentTimeMillis() + timeoutMs;
+ synchronized (micLock) {
+ while (micHot) {
+ long left = deadline - System.currentTimeMillis();
+ if (left <= 0) return false;
+ try {
+ micLock.wait(left);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
@Override
public void stop() {
if (pid != -1) {
diff --git a/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java b/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java
index c7c04035ef..f4ac02cd67 100644
--- a/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java
+++ b/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java
@@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit;
public class PulseAudioComponent extends SessionPart {
private static final String TAG = "PulseAudio";
public static final String SOCKET_NAME = "PS0";
+ private static final String MIC_SOURCE = "DirectAudioMic";
private static final String BUNDLE_STAMP = "2026-10-08-pa13-directaudio-native";
@@ -97,9 +98,9 @@ public class PulseAudioComponent extends SessionPart {
config.add("set-default-sink DirectAudio");
config.add(".fail");
if (micFifoPath != null && !micFifoPath.isEmpty()) {
- config.add("load-module module-pipe-source source_name=DirectAudioMic file=\""
+ config.add("load-module module-pipe-source source_name=" + MIC_SOURCE + " file=\""
+ micFifoPath + "\" format=s16le rate=48000 channels=1");
- config.add("set-default-source DirectAudioMic");
+ config.add("set-default-source " + MIC_SOURCE);
}
FileUtils.writeString(new File(workingDir, "default.pa"), String.join("\n", config));
@@ -234,16 +235,24 @@ public class PulseAudioComponent extends SessionPart {
}
public boolean setSinkSuspended(boolean suspended) {
+ return suspend("sink", "@DEFAULT_SINK@", suspended);
+ }
+
+ public boolean setMicSuspended(boolean suspended) {
+ return micFifoPath == null || micFifoPath.isEmpty() || suspend("source", MIC_SOURCE, suspended);
+ }
+
+ private boolean suspend(String kind, String name, boolean suspended) {
File pactl = new File(workingDir, "pactl");
if (!pactl.isFile() || pid <= 1) {
- Log.w(TAG, "cannot change sink state: PulseAudio control client or server unavailable");
+ Log.w(TAG, "cannot change " + kind + " state: PulseAudio control client or server unavailable");
return false;
}
java.lang.Process process = null;
try {
File modules = new File(workingDir, "modules/arm64");
ProcessBuilder builder = new ProcessBuilder(
- pactl.getAbsolutePath(), "suspend-sink", "@DEFAULT_SINK@", Boolean.toString(suspended));
+ pactl.getAbsolutePath(), "suspend-" + kind, name, Boolean.toString(suspended));
builder.directory(workingDir);
builder.redirectErrorStream(true);
builder.redirectOutput(new File("/dev/null"));
@@ -254,18 +263,18 @@ public class PulseAudioComponent extends SessionPart {
process = builder.start();
if (!process.waitFor(5, TimeUnit.SECONDS)) {
process.destroyForcibly();
- Log.w(TAG, "timed out changing sink state to suspended=" + suspended);
+ Log.w(TAG, "timed out changing " + kind + " state to suspended=" + suspended);
return false;
}
int status = process.exitValue();
- if (status != 0) Log.w(TAG, "sink state change failed with exit " + status);
+ if (status != 0) Log.w(TAG, kind + " state change failed with exit " + status);
return status == 0;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- Log.w(TAG, "interrupted changing sink state", e);
+ Log.w(TAG, "interrupted changing " + kind + " state", e);
return false;
} catch (Exception e) {
- Log.w(TAG, "could not change sink state", e);
+ Log.w(TAG, "could not change " + kind + " state", e);
return false;
} finally {
if (process != null && process.isAlive()) process.destroyForcibly();
diff --git a/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt b/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt
deleted file mode 100644
index adaa106a02..0000000000
--- a/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.droiddeck.launcher.core
-
-import com.droiddeck.launcher.gpu.GpuInfo
-import com.droiddeck.launcher.gpu.SocNames
-
-object CpuAllocationDefaults {
- data class Allocation(val client: String, val game: String)
-
- val device: Allocation? by lazy {
- forDevice(SocNames.model(), GpuInfo.systemProperty("ro.board.platform"),
- CpuCores.all.associateWith(CpuCores::maxGhz))
- }
-
- fun forDevice(model: String, platform: String, frequencies: Map): Allocation? {
- val chip = model.trim().uppercase().substringBefore('-')
- val gen2 = chip in setOf("SM8550", "QCS8550") ||
- (chip.isEmpty() && platform.trim().equals("kalama", ignoreCase = true))
- if (!gen2 || frequencies.size != 8 || frequencies.keys.any { it < 0 } ||
- frequencies.values.any { it == null || !it.isFinite() || it <= 0.0 }) return null
- val clusters = frequencies.entries.groupBy { it.value }.toSortedMap(compareBy { it ?: 0.0 }).values.toList()
- if (clusters.map { it.size } != listOf(3, 4, 1)) return null
- return Allocation(
- client = CpuCores.format(clusters[2].map { it.key }.toSet()),
- game = CpuCores.format(clusters[1].map { it.key }.toSet()),
- )
- }
-}
diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt
index a0f37a0713..57aefe2711 100644
--- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt
+++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt
@@ -155,13 +155,17 @@ object DeviceReport {
k("RAM total", FileUtils.sizeToString(mi.totalMem))
k("RAM available", FileUtils.sizeToString(mi.availMem))
}
- runCatching {
- val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) k("Thermal status", thermalStatusName(pm.currentThermalStatus))
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- k("Thermal headroom (10 s)", pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) })
+ val pm = runCatching { context.getSystemService(Context.POWER_SERVICE) as? PowerManager }.getOrNull()
+ if (pm != null) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ k("Thermal status", runCatching { thermalStatusName(pm.currentThermalStatus) }.getOrNull())
}
- k("Power saver", pm.isPowerSaveMode)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ k("Thermal headroom (10 s)", runCatching {
+ pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) }
+ }.getOrNull())
+ }
+ k("Power saver", runCatching { pm.isPowerSaveMode }.getOrNull())
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val rate = runCatching { context.getSystemService(PerformanceHintManager::class.java)?.preferredUpdateRateNanos }.getOrNull()
@@ -207,7 +211,12 @@ object DeviceReport {
h("Drivers")
val gpu = com.droiddeck.launcher.gpu.GpuInfo.detect()
k("GPU", "${gpu.name} · ${gpu.family.label(gpu.name)} · ${gpu.supportText}" + if (gpu.oneUi8Gen2) " · One UI 8 Gen 2" else "")
- if (gpu.model == 740) k("TP UBWC hint", com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice() ?: "driver default")
+ if (gpu.model == 740) {
+ val hint = com.droiddeck.launcher.gpu.TpUbwcHint
+ k("TP UBWC hint", hint.forThisDevice(context) ?: "driver default")
+ k("TP UBWC mode", hint.activeMode ?: SessionPrefs.TP_UBWC_AUTO)
+ if (hint.restartRequired(context)) k("TP UBWC pending", "${SessionPrefs.tpUbwcMode(context)} (restart required)")
+ }
k("Driver mode", SessionPrefs.gpuDriverMode(context) +
(com.droiddeck.launcher.gpu.DriverPairs.recommendedKey(gpu, com.droiddeck.launcher.gpu.DriverPairs.from(
com.droiddeck.launcher.gpu.TurnipReleases.cached(context)), com.droiddeck.launcher.gpu.TurnipReleases.autoPicks(context),
diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt
index f8806c7c03..c924f85329 100644
--- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt
+++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt
@@ -14,7 +14,7 @@ import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.os.Looper
-import com.droiddeck.launcher.MainActivity
+import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -185,7 +185,7 @@ class WirelessAdbPairingService : Service() {
enableVibration(false)
})
val open = PendingIntent.getActivity(this, 0,
- Intent(this, MainActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
+ Intent(this, FrontEndActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
PendingIntent.FLAG_IMMUTABLE)
val cancel = PendingIntent.getService(this, 1,
Intent(this, WirelessAdbPairingService::class.java).setAction(ACTION_CANCEL), PendingIntent.FLAG_IMMUTABLE)
diff --git a/app/src/main/java/com/droiddeck/launcher/core/ZramSupport.kt b/app/src/main/java/com/droiddeck/launcher/core/ZramSupport.kt
index 51c3b24948..3befaac385 100644
--- a/app/src/main/java/com/droiddeck/launcher/core/ZramSupport.kt
+++ b/app/src/main/java/com/droiddeck/launcher/core/ZramSupport.kt
@@ -1,26 +1,10 @@
package com.droiddeck.launcher.core
-import android.app.ActivityManager
-import android.content.Context
-import android.os.Build
import java.io.File
object ZramSupport {
- private const val GIB = 1L shl 30
-
fun supported(): Boolean = kernelAtLeast(System.getProperty("os.version").orEmpty(), 5, 4) && swapTotalKb() > 0
- fun recommended(context: Context): Boolean {
- if (!supported()) return false
- val memory = ActivityManager.MemoryInfo()
- context.getSystemService(ActivityManager::class.java).getMemoryInfo(memory)
- val advertised = if (Build.VERSION.SDK_INT >= 34) memory.advertisedMem else 0L
- return belowTwelveGb(advertised, memory.totalMem)
- }
-
- fun belowTwelveGb(advertisedBytes: Long, totalBytes: Long): Boolean =
- if (advertisedBytes > 0) advertisedBytes < 11 * GIB else totalBytes < 10 * GIB
-
fun kernelAtLeast(release: String, major: Int, minor: Int): Boolean {
val parts = Regex("^(\\d+)\\.(\\d+)").find(release)?.groupValues ?: return false
val ma = parts[1].toInt()
diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerActivity.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerActivity.kt
index 27cb9dbcea..1425a78e7e 100644
--- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerActivity.kt
@@ -29,7 +29,7 @@ class FileManagerActivity : ComponentActivity() {
setContent {
DroidDeckTheme(appScale = com.droiddeck.launcher.core.AppUiPrefs.scale(this)) {
Surface(modifier = Modifier.fillMaxSize().systemBarsPadding(), color = MaterialTheme.colorScheme.background) {
- FileManagerScreen(initialDir = initialDir)
+ FileManagerScreen(initialDir = initialDir, onExit = { finish() })
}
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt
index 0843057f75..627761c2da 100644
--- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt
+++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt
@@ -28,6 +28,8 @@ import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.filled.ExitToApp
+import androidx.compose.material.icons.automirrored.filled.KeyboardReturn
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ContentPaste
import androidx.compose.material.icons.filled.CreateNewFolder
@@ -90,12 +92,18 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.session.SessionPrefs
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.util.Date
+private enum class FileManagerNavigation { EXIT, RETURN_TO_START, BACK }
+
+internal fun canNavigateUp(currentDir: File, currentRoot: File): Boolean =
+ currentDir != currentRoot && currentDir.parentFile?.exists() == true
+
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FileManagerScreen(
@@ -105,6 +113,7 @@ fun FileManagerScreen(
initialDir: File? = null,
pickerTitle: String? = null,
onPick: ((File) -> Unit)? = null,
+ onExit: (() -> Unit)? = null,
) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
@@ -118,12 +127,14 @@ fun FileManagerScreen(
val pickPrefs = remember { context.getSharedPreferences("file_manager", android.content.Context.MODE_PRIVATE) }
val browsePrefs = pickPrefs
- val rootDir = remember {
+ val rootDir = remember(initialDir) {
initialDir?.takeIf { it.isDirectory } ?: File("/storage/emulated/0")
}
-
+ val launchDir = remember(initialDir, pickMode) {
+ initialDir?.takeIf { !pickMode }
+ }
var currentDir by remember { mutableStateOf(rootDir) }
- var currentRoot by remember {
+ val initialRoot = remember(rootDir) {
val abs = rootDir.absolutePath
val internal = "/storage/emulated/0"
val vol = when {
@@ -139,8 +150,9 @@ fun FileManagerScreen(
?: rootDir
}
}
- mutableStateOf(vol)
+ vol
}
+ var currentRoot by remember { mutableStateOf(initialRoot) }
var entries by remember { mutableStateOf(listOf()) }
var selectedEntry by remember { mutableStateOf(null) }
var showMenuFor by remember { mutableStateOf(null) }
@@ -151,8 +163,10 @@ fun FileManagerScreen(
var pendingConflict by remember { mutableStateOf(null) }
var conflictChoice by remember { mutableStateOf(null) }
var conflictApplyToAll by remember { mutableStateOf(false) }
- var operationJob by remember { mutableStateOf(null) }
- var cancelledJob by remember { mutableStateOf(null) }
+ var operationJob by remember { mutableStateOf(null) }
+ var cancelledJob by remember { mutableStateOf(null) }
+ var pendingNavigation by remember { mutableStateOf(null) }
+ var cancellingNavigation by remember { mutableStateOf(false) }
var pendingBulkDelete by remember { mutableStateOf>(emptyList()) }
var searchQuery by remember { mutableStateOf("") }
val visibleEntries = if (searchQuery.isBlank()) entries
@@ -178,9 +192,10 @@ fun FileManagerScreen(
var showFavorites by remember { mutableStateOf(false) }
var favTick by remember { mutableIntStateOf(0) }
- var listingJob by remember { mutableStateOf(null) }
+ var listingJob by remember { mutableStateOf(null) }
fun loadDirectory(dir: File, resetScroll: Boolean = true) {
+ if (cancellingNavigation) return
currentDir = dir
if (pickMode) pickPrefs.edit().putString("lastFilePickerDir", dir.absolutePath).apply()
listingJob?.cancel()
@@ -205,25 +220,90 @@ fun FileManagerScreen(
}
fun openDrive(dir: File) {
+ if (cancellingNavigation) return
currentRoot = dir
loadDirectory(dir)
}
+ fun returnToStart() {
+ if (cancellingNavigation) return
+ val dir = launchDir ?: return
+ if (!dir.isDirectory) {
+ Toast.makeText(context, R.string.fm_start_unavailable, Toast.LENGTH_SHORT).show()
+ return
+ }
+ showFavorites = false
+ showSearch = false
+ searchQuery = ""
+ currentRoot = initialRoot
+ loadDirectory(dir)
+ }
+
LaunchedEffect(Unit) { loadDirectory(rootDir) }
- BackHandler(enabled = showFavorites || currentDir != currentRoot) {
- if (showFavorites) {
- showFavorites = false
- return@BackHandler
+ val canGoUp = currentDir != currentRoot && currentDir.parentFile?.exists() == true
+ fun isOperationActive() = isOperationRunning || operationJob?.isCompleted == false || cancelledJob?.isCompleted == false
+ val operationActive = isOperationActive()
+
+ fun navigate(action: FileManagerNavigation) {
+ if (cancellingNavigation) return
+ when (action) {
+ FileManagerNavigation.EXIT -> onExit?.invoke()
+ FileManagerNavigation.RETURN_TO_START -> returnToStart()
+ FileManagerNavigation.BACK -> {
+ if (showFavorites) showFavorites = false
+ else if (canNavigateUp(currentDir, currentRoot)) currentDir.parentFile?.let { loadDirectory(it) }
+ else onExit?.invoke()
+ }
}
- val parent = currentDir.parentFile
- if (parent != null && parent.exists()) loadDirectory(parent)
}
- val canGoUp = currentDir != currentRoot && currentDir.parentFile?.exists() == true
- fun goUp() {
- val parent = currentDir.parentFile
- if (currentDir != currentRoot && parent != null && parent.exists()) loadDirectory(parent)
+ fun requestNavigation(action: FileManagerNavigation) {
+ if (cancellingNavigation) return
+ if (isOperationActive()) pendingNavigation = action else navigate(action)
+ }
+
+ BackHandler(enabled = operationActive || cancellingNavigation || showFavorites || currentDir != currentRoot) {
+ requestNavigation(FileManagerNavigation.BACK)
+ }
+
+ if (pendingNavigation != null) {
+ OutlinedAlertDialog(
+ onDismissRequest = { pendingNavigation = null },
+ title = { Text(stringResource(R.string.fm_cancel_operation_title)) },
+ text = { Text(stringResource(R.string.fm_cancel_operation_confirmation)) },
+ confirmButton = {
+ TextButton(onClick = {
+ val action = pendingNavigation ?: return@TextButton
+ pendingNavigation = null
+ val job = operationJob?.takeUnless(Job::isCompleted)
+ ?: cancelledJob?.takeUnless(Job::isCompleted)
+ if (job == null) {
+ navigate(action)
+ } else {
+ cancellingNavigation = true
+ cancelledJob = job
+ job.cancel()
+ scope.launch {
+ job.join()
+ if (operationJob === job) operationJob = null
+ if (cancelledJob === job) cancelledJob = null
+ pendingConflict = null
+ isOperationRunning = false
+ operationDeterminate = false
+ cancellingNavigation = false
+ if (action != FileManagerNavigation.EXIT) loadDirectory(currentDir, resetScroll = false)
+ navigate(action)
+ }
+ }
+ }) { Text(stringResource(R.string.fm_accept)) }
+ },
+ dismissButton = {
+ TextButton(onClick = { pendingNavigation = null }) {
+ Text(stringResource(R.string.fm_decline))
+ }
+ },
+ )
}
fun uniqueDestination(dir: File, name: String): File {
@@ -241,11 +321,14 @@ fun FileManagerScreen(
}
fun performDelete(file: File) {
- scope.launch {
+ if (isOperationActive()) return
+ operationJob = scope.launch {
isOperationRunning = true
operationLabel = context.getString(R.string.fm_op_deleting)
- val ok = withContext(Dispatchers.IO) { FileOps.delete(file) }
+ val job = coroutineContext[Job]
+ val ok = withContext(Dispatchers.IO) { FileOps.delete(file) { job?.isActive == false } }
isOperationRunning = false
+ if (operationJob === job) operationJob = null
loadDirectory(currentDir, resetScroll = false)
if (!ok) Toast.makeText(context, R.string.fm_delete_failed, Toast.LENGTH_SHORT).show()
}
@@ -260,7 +343,7 @@ fun FileManagerScreen(
fun performPaste() {
val sources = clipboardFiles
- if (sources.isEmpty() || isOperationRunning || operationJob?.isActive == true || cancelledJob?.isCompleted == false) return
+ if (sources.isEmpty() || isOperationActive()) return
val dstDir = currentDir
val cut = isCutOperation
@@ -269,7 +352,7 @@ fun FileManagerScreen(
operationDeterminate = true
operationLabel = context.getString(if (cut) R.string.fm_op_moving else R.string.fm_op_copying)
isOperationRunning = true
- val job = coroutineContext[kotlinx.coroutines.Job]
+ val job = coroutineContext[Job]
var applyToAll: ConflictChoice? = null
var failed = 0
@@ -322,7 +405,7 @@ fun FileManagerScreen(
isOperationRunning = false
operationDeterminate = false
- operationJob = null
+ if (operationJob === job) operationJob = null
clipboardFiles = emptyList()
isCutOperation = false
selectionMode = false
@@ -340,32 +423,38 @@ fun FileManagerScreen(
}
fun performRename(file: File, newName: String) {
+ if (isOperationActive()) return
val target = File(file.parentFile, newName)
if (target.exists()) {
Toast.makeText(context, context.getString(R.string.fm_already_exists, newName), Toast.LENGTH_SHORT).show()
return
}
- scope.launch {
+ operationJob = scope.launch {
+ val job = coroutineContext[Job]
isOperationRunning = true
operationLabel = context.getString(R.string.fm_op_renaming)
val ok = withContext(Dispatchers.IO) { file.renameTo(target) }
isOperationRunning = false
+ if (operationJob === job) operationJob = null
loadDirectory(currentDir, resetScroll = false)
if (!ok) Toast.makeText(context, R.string.fm_rename_failed, Toast.LENGTH_SHORT).show()
}
}
fun createFolder(parent: File, name: String) {
+ if (isOperationActive()) return
val target = File(parent, name)
if (target.exists()) {
Toast.makeText(context, context.getString(R.string.fm_already_exists, name), Toast.LENGTH_SHORT).show()
return
}
- scope.launch {
+ operationJob = scope.launch {
+ val job = coroutineContext[Job]
isOperationRunning = true
operationLabel = context.getString(R.string.fm_op_creating_folder)
val ok = withContext(Dispatchers.IO) { target.mkdirs() }
isOperationRunning = false
+ if (operationJob === job) operationJob = null
loadDirectory(currentDir, resetScroll = false)
if (!ok) Toast.makeText(context, R.string.fm_create_folder_failed, Toast.LENGTH_SHORT).show()
}
@@ -481,18 +570,20 @@ fun FileManagerScreen(
},
confirmButton = {
TextButton(onClick = {
+ if (isOperationActive()) return@TextButton
pendingBulkDelete = emptyList()
selectionMode = false
selectedPaths = emptySet()
operationJob = scope.launch {
isOperationRunning = true
+ val job = coroutineContext[Job]
var failed = 0
victims.forEachIndexed { i, f ->
operationLabel = context.getString(R.string.fm_op_deleting_batch, i + 1, victims.size, f.name)
- if (!withContext(Dispatchers.IO) { FileOps.delete(f) }) failed++
+ if (!withContext(Dispatchers.IO) { FileOps.delete(f) { job?.isActive == false } }) failed++
}
isOperationRunning = false
- operationJob = null
+ if (operationJob === job) operationJob = null
loadDirectory(currentDir, resetScroll = false)
if (failed > 0) {
Toast.makeText(context, context.resources.getQuantityString(R.plurals.fm_delete_some_failed, failed, failed), Toast.LENGTH_SHORT).show()
@@ -582,7 +673,7 @@ fun FileManagerScreen(
.background(MaterialTheme.colorScheme.surfaceContainer)
.padding(horizontal = 8.dp, vertical = 6.dp),
) {
- IconButton(onClick = { goUp() }, enabled = canGoUp) {
+ IconButton(onClick = { requestNavigation(FileManagerNavigation.BACK) }, enabled = canGoUp && !cancellingNavigation) {
Icon(Icons.Filled.ArrowBack, stringResource(R.string.fm_back), tint = MaterialTheme.colorScheme.primary)
}
@@ -672,6 +763,13 @@ fun FileManagerScreen(
)
}
+ if (launchDir != null) {
+ IconButton(onClick = { requestNavigation(FileManagerNavigation.RETURN_TO_START) }, enabled = !cancellingNavigation) {
+ Icon(Icons.AutoMirrored.Filled.KeyboardReturn, stringResource(R.string.fm_return_to_start), tint = MaterialTheme.colorScheme.primary)
+ }
+ if (LocalConfiguration.current.screenWidthDp >= 700) Spacer(Modifier.width(56.dp))
+ }
+
if (!showFavorites) {
if (!pickMode) {
OutlinedButton(
@@ -747,6 +845,11 @@ fun FileManagerScreen(
Icon(Icons.Filled.StarBorder, stringResource(R.string.fm_show_favorites), tint = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
+ if (!pickMode && onExit != null) {
+ IconButton(onClick = { requestNavigation(FileManagerNavigation.EXIT) }, enabled = !cancellingNavigation) {
+ Icon(Icons.AutoMirrored.Filled.ExitToApp, stringResource(R.string.fm_exit), tint = MaterialTheme.colorScheme.onSurfaceVariant)
+ }
+ }
}
if (showSearch && !showFavorites) {
@@ -986,7 +1089,7 @@ fun FileManagerScreen(
contentPadding = PaddingValues(8.dp),
) {
if (canGoUp) item(key = "..", span = { GridItemSpan(maxLineSpan) }) {
- ParentFolderRow(compact = compactRows, onTap = { goUp() })
+ ParentFolderRow(compact = compactRows, onTap = { requestNavigation(FileManagerNavigation.BACK) })
}
items(shownEntries, key = { it.absolutePath }) { file ->
val isFav = remember(file.absolutePath, favTick) {
@@ -1052,7 +1155,7 @@ fun FileManagerScreen(
} else
LazyColumn(state = listState, modifier = Modifier.fillMaxSize()) {
if (canGoUp) item(key = "..") {
- ParentFolderRow(compact = compactRows, onTap = { goUp() })
+ ParentFolderRow(compact = compactRows, onTap = { requestNavigation(FileManagerNavigation.BACK) })
}
if (entries.isEmpty()) {
item {
diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt b/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt
index 29df5ff6d6..05d467ef51 100644
--- a/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt
+++ b/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt
@@ -9,6 +9,7 @@ import java.io.FileOutputStream
import java.io.IOException
import java.nio.file.Files
import java.util.Locale
+import java.util.concurrent.CancellationException
object FileOps {
private const val TAG = "FileOps"
@@ -24,24 +25,27 @@ object FileOps {
fun isSymlink(file: File): Boolean = try { Files.isSymbolicLink(file.toPath()) } catch (e: Exception) { false }
- fun delete(target: File?): Boolean {
+ fun delete(target: File?, isCancelled: () -> Boolean = { false }): Boolean {
+ if (isCancelled()) throw CancellationException("Delete cancelled: $target")
if (target == null) return false
if (target.isDirectory && !isSymlink(target)) {
- if (!clear(target)) return false
+ if (!clear(target, isCancelled)) return false
}
+ if (isCancelled()) throw CancellationException("Delete cancelled: $target")
return target.delete()
}
- fun clear(dir: File): Boolean {
+ fun clear(dir: File, isCancelled: () -> Boolean = { false }): Boolean {
val children = dir.listFiles() ?: return true
var ok = true
- for (child in children) if (!delete(child)) ok = false
+ for (child in children) if (!delete(child, isCancelled)) ok = false
return ok
}
- fun totalSize(f: File?): Long {
+ fun totalSize(f: File?, isCancelled: () -> Boolean = { false }): Long {
+ if (isCancelled()) throw CancellationException("Size scan cancelled: $f")
if (f == null || !f.exists() || isSymlink(f)) return 0
- if (f.isDirectory) return f.listFiles()?.sumOf { totalSize(it) } ?: 0
+ if (f.isDirectory) return f.listFiles()?.sumOf { totalSize(it, isCancelled) } ?: 0
return f.length()
}
@@ -53,12 +57,12 @@ object FileOps {
return true
}
if (!copyWithProgress(src, dst, progress, isCancelled)) return false
- if (isCancelled()) return false
+ // Once the destination is committed, finish deleting the source.
return delete(src)
}
fun copyWithProgress(src: File, dst: File, progress: ProgressCallback?, isCancelled: () -> Boolean = { false }): Boolean {
- val total = maxOf(totalSize(src), 1L)
+ val total = maxOf(totalSize(src, isCancelled), 1L)
return copyWithProgress(src, dst, longArrayOf(0), total, progress, isCancelled)
}
@@ -71,15 +75,23 @@ object FileOps {
return false
}
if (src.isDirectory) {
- if (!dst.exists() && !dst.mkdirs()) return false
- var allOk = true
- src.list()?.forEach { name ->
- if (!copyWithProgress(File(src, name), File(dst, name), done, total, progress, isCancelled)) {
- Log.e(TAG, "Failed to copy: ${File(src, name)}")
- allOk = false
+ val created = if (dst.exists()) false else {
+ if (!dst.mkdirs()) return false
+ true
+ }
+ try {
+ var allOk = true
+ src.list()?.forEach { name ->
+ if (!copyWithProgress(File(src, name), File(dst, name), done, total, progress, isCancelled)) {
+ Log.e(TAG, "Failed to copy: ${File(src, name)}")
+ allOk = false
+ }
}
+ return allOk
+ } catch (e: CancellationException) {
+ if (created) delete(dst)
+ throw e
}
- return allOk
}
val parent = dst.parentFile
if (!src.exists() || (parent != null && !parent.exists() && !parent.mkdirs())) return false
@@ -118,6 +130,7 @@ object FileOps {
val size = input.size()
var position = 0L
while (position < size) {
+ if (isCancelled()) throw CancellationException("Copy cancelled: $src")
val transferred = input.transferTo(position, minOf(chunk, size - position), channel)
if (transferred <= 0) break
position += transferred
@@ -125,12 +138,19 @@ object FileOps {
progress?.onProgress(done[0], total)
}
if (position < size) throw IOException("Incomplete copy: $position/$size bytes")
+ if (size > 0 && isCancelled()) throw CancellationException("Copy cancelled: $src")
}
}
staging?.let { directory ->
val copied = File(directory, "file").toPath()
- if (permissions != null && Files.getPosixFilePermissions(copied) != permissions) {
- Files.setPosixFilePermissions(copied, permissions)
+ if (permissions != null) {
+ try {
+ if (Files.getPosixFilePermissions(copied) != permissions) {
+ Files.setPosixFilePermissions(copied, permissions)
+ }
+ } catch (e: Exception) {
+ Log.w(TAG, "Failed to restore destination permissions: $target", e)
+ }
}
if (isCancelled()) throw java.util.concurrent.CancellationException("Copy cancelled: $src")
Files.move(copied, target.toPath(), java.nio.file.StandardCopyOption.ATOMIC_MOVE)
diff --git a/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt b/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt
index 6fd89fa99f..498ec504e8 100644
--- a/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt
@@ -50,6 +50,7 @@ class FilePickerActivity : ComponentActivity() {
setResult(Activity.RESULT_OK, Intent().putExtra(EXTRA_SELECTED_FILE, file.absolutePath))
finish()
},
+ onExit = { finish() },
)
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt
index 62d04d2477..8315c22e9e 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt
@@ -5,6 +5,8 @@ import android.graphics.Bitmap
import android.util.Log
import com.droiddeck.launcher.files.PeIconExtractor
import com.droiddeck.launcher.session.SessionPrefs
+import com.droiddeck.launcher.stores.StoreArt
+import com.droiddeck.launcher.stores.StoreGameSidecar
import org.json.JSONObject
import java.io.File
import java.net.HttpURLConnection
@@ -228,41 +230,93 @@ object AddedGameArt {
return if (tmp.renameTo(png)) png else null
}
- fun fetchMissing(context: Context, games: List): Boolean {
+ internal class Sources(
+ val storeLogo: (AddedGames.Game) -> Boolean,
+ val steamSearch: (String) -> Int?,
+ val steam: (String, File, Set) -> Boolean,
+ val sgdbGame: (String, Int?, String) -> Int?,
+ val sgdb: (String, Int, File, Set) -> Boolean,
+ )
+
+ private val network = Sources(
+ storeLogo = ::storeLogo,
+ steamSearch = { name -> search(name)?.toIntOrNull() },
+ steam = ::download,
+ sgdbGame = SteamGridDb::gameId,
+ sgdb = SteamGridDb::download,
+ )
+
+ private val EXTRAS = setOf(Slot.LOGO, Slot.ICON)
+ private val STEAM_SLOTS = setOf(Slot.COVER, Slot.WIDE, Slot.BACKGROUND, Slot.LOGO)
+ internal const val EXTRAS_TRIED = "extras-tried"
+
+ internal fun missing(context: Context, game: AddedGames.Game): Set {
+ val own = local(game)
+ val cache = cacheDir(context, game)
+ fun has(slot: Slot, mine: File?, cached: String) = chosen(cache, slot) != null || mine != null || File(cache, cached).isFile
+ return Slot.values().filterNot { slot ->
+ when (slot) {
+ Slot.COVER -> has(slot, own.portrait, "p.jpg")
+ Slot.WIDE -> has(slot, own.header, "header.jpg")
+ Slot.BACKGROUND -> has(slot, own.hero, "hero.jpg")
+ Slot.LOGO -> has(slot, own.logo, "logo.png")
+ Slot.ICON -> has(slot, own.icon, "icon-sgdb.png")
+ }
+ }.toSet()
+ }
+
+ private fun storeLogo(game: AddedGames.Game): Boolean {
+ val url = StoreGameSidecar.read(game.folder)?.logo ?: return false
+ return StoreArt.fetchLogo(game.folder, url)
+ }
+
+ fun fetchMissing(context: Context, games: List): Boolean =
+ fetchMissing(context, games, SteamGridDb.key(context), network)
+
+ internal fun fetchMissing(context: Context, games: List, sgdbKey: String, sources: Sources): Boolean {
if (!SessionPrefs.addedGamesArt(context)) return false
- val sgdbKey = SteamGridDb.key(context)
val keyChangedAt = SteamGridDb.keyChangedAt(context)
var sgdbDown = false
var changed = false
for (game in games) {
- if (local(game).portrait != null) continue
+ val start = missing(context, game)
+ val full = Slot.COVER in start
+ val allowed = if (full) Slot.values().toSet() else EXTRAS
+ var need = start intersect allowed
+ if (need.isEmpty() || (need == setOf(Slot.ICON) && sgdbKey.isEmpty())) continue
val cache = cacheDir(context, game)
- if (File(cache, "p.jpg").isFile) continue
+ val tried = File(cache, EXTRAS_TRIED)
+ if (!full && tried.isFile && tried.lastModified() >= keyChangedAt && System.currentTimeMillis() - tried.lastModified() < RETRY_AFTER_MS) continue
cache.mkdirs()
- val match = steamMatch(context, game) { name ->
- runCatching { search(name) }.onFailure { Log.w(TAG, "${game.name}: store search failed (${it.message})") }.getOrNull()?.toIntOrNull()
+ if (Slot.LOGO in need && game.source != Library.ADDED && runCatching { sources.storeLogo(game) }.getOrDefault(false)) {
+ changed = true
+ need = need - Slot.LOGO
}
- val appId = match.appId?.takeIf { match.certainty == SteamMatch.Certainty.FILES }
- val id = match.appId?.toString()
- if (id != null && download(id, cache)) changed = true
- if (File(cache, "p.jpg").isFile || sgdbKey.isEmpty() || sgdbDown) continue
- val stored: String? = try {
- remembered(File(cache, "sgdb-id"), keyChangedAt) {
- SteamGridDb.gameId(sgdbKey, appId ?: id?.toIntOrNull(), game.name)?.toString()
+ val match by lazy {
+ steamMatch(context, game) { name ->
+ runCatching { sources.steamSearch(name) }.onFailure { Log.w(TAG, "${game.name}: store search failed (${it.message})") }.getOrNull()
}
- } catch (e: Exception) {
- Log.w(TAG, "${game.name}: SteamGridDB lookup failed (${e.javaClass.simpleName}); not asking again this pass")
- sgdbDown = true
- null
}
- val gridId = stored?.toIntOrNull() ?: continue
- val grabbed = try {
- SteamGridDb.download(sgdbKey, gridId, cache)
- } catch (e: Exception) {
- sgdbDown = true
- false
+ val steamWant = need intersect STEAM_SLOTS
+ if (steamWant.isNotEmpty()) {
+ val id = match.appId?.toString()
+ if (id != null && sources.steam(id, cache, steamWant)) changed = true
+ need = missing(context, game) intersect allowed
}
- if (grabbed) changed = true
+ var asked = true
+ if (need.isNotEmpty() && sgdbKey.isNotEmpty()) {
+ if (sgdbDown) asked = false else try {
+ val gridId = remembered(File(cache, "sgdb-id"), keyChangedAt) {
+ sources.sgdbGame(sgdbKey, match.appId, game.name)?.toString()
+ }?.toIntOrNull()
+ if (gridId != null && sources.sgdb(sgdbKey, gridId, cache, need)) changed = true
+ } catch (e: Exception) {
+ Log.w(TAG, "${game.name}: SteamGridDB failed (${e.javaClass.simpleName}); not asking again this pass")
+ sgdbDown = true
+ asked = false
+ }
+ }
+ if ((missing(context, game) intersect EXTRAS).isEmpty()) tried.delete() else if (asked) tried.writeText("")
}
return changed
}
@@ -314,11 +368,13 @@ object AddedGameArt {
return pickStoreResult(name, (0 until items.length()).map { items.getJSONObject(it) }.map { it.optString("id") to it.optString("name") })
}
- private fun download(id: String, cache: File): Boolean {
+ private fun download(id: String, cache: File, slots: Set): Boolean {
var got = false
- for ((remote, localName) in listOf(
- "library_600x900.jpg" to "p.jpg", "header.jpg" to "header.jpg", "library_hero.jpg" to "hero.jpg", "logo.png" to "logo.png",
+ for ((slot, remote, localName) in listOf(
+ Triple(Slot.COVER, "library_600x900.jpg", "p.jpg"), Triple(Slot.WIDE, "header.jpg", "header.jpg"),
+ Triple(Slot.BACKGROUND, "library_hero.jpg", "hero.jpg"), Triple(Slot.LOGO, "logo.png", "logo.png"),
)) {
+ if (slot !in slots) continue
val dst = File(cache, localName)
if (dst.isFile) continue
val bytes = get("$CDN$id/$remote") ?: steamAssetUrl(id, remote)?.let { get(it) } ?: continue
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt
index 5de835f6e1..340bc83ce0 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt
@@ -274,7 +274,7 @@ object AddedGames {
class FolderResult(val added: List, val already: Int)
- fun addFolder(context: Context, dir: File, onGame: (Game) -> Unit = {}, onChecking: (String?) -> Unit = {}): FolderResult {
+ fun addFolder(context: Context, dir: File, onGame: (Game) -> Unit = {}, onChecking: (String?) -> Unit = {}, showHidden: Boolean = false): FolderResult {
val app = context.applicationContext
// Binds are mounted at session start, so a new one reaches the session from the next start.
if (guestPath(app, dir) == null) bindFolder(app, dir)
@@ -283,7 +283,7 @@ object AddedGames {
var already = 0
val fresh = ArrayList()
val added = ArrayList()
- for (sub in dir.listFiles { f -> f.isDirectory && !f.name.startsWith(".") }?.sortedBy { it.name.lowercase() }.orEmpty()) {
+ for (sub in dir.listFiles { f -> f.isDirectory && (showHidden || !f.name.startsWith(".")) }?.sortedBy { it.name.lowercase() }.orEmpty()) {
val path = canonical(sub)
if (listed.any { it == path || inside(path, it) || inside(it, path) }) { already++; continue }
onChecking(sub.name)
@@ -387,11 +387,17 @@ object AddedGames {
}
}
+ private class LoginUser(val id: String, val mostRecent: Boolean, val autoLogin: Boolean, val timestamp: Long)
+
internal fun accountConfig(root: File): File? {
val users = runCatching { File(root, "config/loginusers.vdf").readText() }.getOrDefault("")
- val recent = Regex(""""(\d{5,})"\s*\{([^}]*)\}""").findAll(users)
- .lastOrNull { Regex(""""MostRecent"\s*"1"""").containsMatchIn(it.groupValues[2]) }
- val account = recent?.groupValues?.get(1)?.toLongOrNull()?.let { (it - 76561197960265728L).toString() }
+ val recent = Regex(""""(\d{5,})"\s*\{([^}]*)\}""").findAll(users).map {
+ val body = it.groupValues[2]
+ LoginUser(it.groupValues[1], Regex(""""MostRecent"\s*"1"""").containsMatchIn(body), Regex(""""AutoLogin"\s*"1"""").containsMatchIn(body),
+ Regex(""""timestamp"\s*"(\d+)"""").find(body)?.groupValues?.get(1)?.toLongOrNull() ?: 0L)
+ }.filter { it.mostRecent || it.autoLogin || it.timestamp > 0 }.toList().asReversed()
+ .maxWithOrNull(compareBy({ it.mostRecent }, { it.autoLogin }, { it.timestamp }))
+ val account = recent?.id?.toLongOrNull()?.let { (it - 76561197960265728L).toString() }
?: File(root, "userdata").list()?.filter { it.isNotEmpty() && it.all(Char::isDigit) && it != "0" }?.singleOrNull()
return account?.let { File(root, "userdata/$it/config") }
}
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameShortcuts.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameShortcuts.kt
index 80cdd93c1b..45b2452694 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/GameShortcuts.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameShortcuts.kt
@@ -11,13 +11,13 @@ import android.graphics.drawable.Icon
import android.net.Uri
import android.widget.Toast
import com.droiddeck.launcher.LauncherIcon
-import com.droiddeck.launcher.MainActivity
+import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
import java.io.File
object GameShortcuts {
fun launchIntent(context: Context, gameId: String) = Intent(Intent.ACTION_VIEW,
- Uri.parse(GameLaunchLink.uri(gameId)), context, MainActivity::class.java)
+ Uri.parse(GameLaunchLink.uri(gameId)), context, FrontEndActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
private fun info(context: Context, game: Library.SteamGame): ShortcutInfo {
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt
index 1242d9add1..05f3f98691 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt
@@ -16,9 +16,10 @@ object Library {
val icon: File? = null,
val source: String = SOURCE_STEAM,
val storeId: String? = null,
+ val logo: File? = null,
) {
- fun withArt(art: File?, hero: File?, icon: File?) =
- SteamGame(appId, name, art, library, gameId, hero, lastPlayed, gameFiles, protonPrefix, icon, source, storeId)
+ fun withArt(art: File?, hero: File?, icon: File?, logo: File? = this.logo) =
+ SteamGame(appId, name, art, library, gameId, hero, lastPlayed, gameFiles, protonPrefix, icon, source, storeId, logo)
val gameIdString: String get() = java.lang.Long.toUnsignedString(gameId)
val profileKey: String get() = if (library == ADDED) java.lang.Integer.toUnsignedString(appId) else appId.toString()
@@ -26,6 +27,7 @@ object Library {
const val ADDED = "added"
const val EPIC_LAUNCHER = "epic-launcher"
const val EPIC_LAUNCHER_NAME = "Epic Games Launcher"
+ const val XBOX_CLOUD = "xbox-cloud"
const val SOURCE_STEAM = "steam"
class Rom(val name: String, val hostPath: File, val guestPath: String, val emulatorId: String, val art: File? = null)
@@ -45,12 +47,14 @@ object Library {
1054830,
1070560,
1113280,
+ 1161040,
1245040,
1391110,
1420170,
1493710,
1580130,
1628350,
+ 1826330,
1887720,
2180100,
228980,
@@ -68,6 +72,7 @@ object Library {
)
private val STEAM_CAPSULES = listOf("library_capsule.jpg", "library_600x900.jpg")
private val STEAM_HEROES = listOf("library_hero.jpg")
+ internal val STEAM_LOGOS = listOf("logo.png")
private val STEAM_ICON = Regex("[a-fA-F0-9]{40}\\.(jpg|png)")
private val NAME = Regex("^\\s*\"name\"\\s*\"([^\"]*)\"", RegexOption.MULTILINE)
private val STATE = Regex("^\\s*\"StateFlags\"\\s*\"(\\d+)\"", RegexOption.MULTILINE)
@@ -102,7 +107,10 @@ object Library {
.firstOrNull { it.isDirectory }
}
- fun steamGames(context: Context, strictRead: Boolean = false, arch: String = SessionPrefs.activeSteamClientArch(context)): List {
+ fun steamGames(
+ context: Context, strictRead: Boolean = false, arch: String = SessionPrefs.activeSteamClientArch(context),
+ withShared: Boolean = true,
+ ): List {
val root = SessionPrefs.steamRoot(context, arch)
val cache = File(root, "appcache/librarycache")
val libraries = steamLibraries(context, arch)
@@ -119,8 +127,9 @@ object Library {
val name = NAME.find(text)?.groupValues?.get(1)?.trim().orEmpty()
val flags = STATE.find(text)?.groupValues?.get(1)?.toIntOrNull() ?: 0
if (name.isEmpty() || flags and 4 == 0) return@forEach
- val art = steamCacheImage(cache, appId, STEAM_CAPSULES)
- val hero = steamCacheImage(cache, appId, STEAM_HEROES)
+ val images = SteamCacheImages(File(cache, appId.toString()))
+ val art = images.find(STEAM_CAPSULES)
+ val hero = images.find(STEAM_HEROES)
val lastPlayed = LAST_PLAYED.find(text)?.groupValues?.get(1)?.toLongOrNull() ?: 0L
val installDir = INSTALL_DIR.find(text)?.groupValues?.get(1)?.trim()
?.takeIf { it.isNotEmpty() && it != "." && it != ".." && '/' !in it && '\\' !in it }
@@ -129,14 +138,25 @@ object Library {
appId, name, art, label, hero = hero, lastPlayed = lastPlayed,
gameFiles = gameFiles,
protonPrefix = protonPrefix(context, appId.toLong(), library, roots),
- icon = steamCacheImage(cache, appId, listOf("icon.jpg", "icon.png"))
- ?: File(cache, appId.toString()).listFiles()?.firstOrNull { it.isFile && STEAM_ICON.matches(it.name) },
+ icon = images.icon(),
+ logo = images.find(STEAM_LOGOS),
))
}
}
+ if (withShared) {
+ val other = if (arch == "x86_64") "arm64" else "x86_64"
+ val shared = sharedApps(context, arch) - out.keys
+ if (shared.isNotEmpty()) runCatching { steamGames(context, arch = other, withShared = false) }.getOrDefault(emptyList())
+ .filter { it.appId in shared }.forEach { out[it.appId] = it }
+ }
return out.values.toList()
}
+ internal fun sharedApps(context: Context, arch: String): Set {
+ val view = File(LinuxRuntime.rootDir(context), "root/.droiddeck-x64/shared/${if (arch == "x86_64") "arm64" else "x86-64"}/steamapps")
+ return view.list().orEmpty().mapNotNull { Regex("appmanifest_(\\d+)\\.acf").matchEntire(it)?.groupValues?.get(1)?.toIntOrNull() }.toSet()
+ }
+
fun steamLibraryArt(context: Context): List> {
val root = SessionPrefs.activeSteamRoot(context)
val cache = File(root, "appcache/librarycache")
@@ -203,16 +223,23 @@ object Library {
protonPrefix = protonPrefix(context, g.steamAppId?.toLong() ?: g.appId, libraries = roots),
icon = art.icon?.takeIf { it.extension.lowercase() != "ico" },
source = g.source, storeId = g.storeId,
+ logo = art.logo,
)
}
- internal fun steamCacheImage(cache: File, appId: Int, names: List): File? {
- val appDir = File(cache, appId.toString())
- val dirs = listOf(appDir) + appDir.listFiles()
- .orEmpty().filter { it.isDirectory }.sortedBy { it.name }
- return names.asSequence()
+ internal fun steamCacheImage(cache: File, appId: Int, names: List): File? =
+ SteamCacheImages(File(cache, appId.toString())).find(names)
+
+ internal class SteamCacheImages(appDir: File) {
+ private val entries = appDir.listFiles().orEmpty()
+ private val dirs = listOf(appDir) + entries.filter { it.isDirectory }.sortedBy { it.name }
+
+ fun find(names: List): File? = names.asSequence()
.flatMap { name -> dirs.asSequence().map { File(it, name) } }
.firstOrNull { it.isFile && it.length() > 0L }
+
+ fun icon(): File? = find(listOf("icon.jpg", "icon.png"))
+ ?: entries.firstOrNull { it.isFile && STEAM_ICON.matches(it.name) }
}
private class Spec(val id: String, val name: String, val system: String, val program: String, val folders: List, val exts: Set, val atPanel: Boolean = false)
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/LibraryCache.kt b/app/src/main/java/com/droiddeck/launcher/frontend/LibraryCache.kt
index 3d03b23073..cd30e400cf 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/LibraryCache.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/LibraryCache.kt
@@ -27,6 +27,7 @@ object LibraryCache {
icon = o.file("icon"),
source = o.optString("source").ifEmpty { if (o.getString("library") == Library.ADDED) Library.ADDED else Library.SOURCE_STEAM },
storeId = o.optString("storeId").ifEmpty { null },
+ logo = o.file("logo"),
)
} to x64
}.getOrElse { e -> Log.w(TAG, "unreadable, ignored: ${e.message}"); Pair(emptyList(), false) }
@@ -44,7 +45,7 @@ object LibraryCache {
for (g in games) array.put(
JSONObject().put("appId", g.appId).put("name", g.name).put("library", g.library).put("gameId", g.gameId)
.put("lastPlayed", g.lastPlayed).putFile("art", g.art).putFile("hero", g.hero)
- .putFile("gameFiles", g.gameFiles).putFile("protonPrefix", g.protonPrefix).putFile("icon", g.icon)
+ .putFile("gameFiles", g.gameFiles).putFile("protonPrefix", g.protonPrefix).putFile("icon", g.icon).putFile("logo", g.logo)
.put("source", g.source).apply { g.storeId?.let { put("storeId", it) } },
)
val f = file(context)
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/SteamGameArt.kt b/app/src/main/java/com/droiddeck/launcher/frontend/SteamGameArt.kt
index cb4f49f0fd..25a3cb8fb5 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/SteamGameArt.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/SteamGameArt.kt
@@ -22,10 +22,12 @@ object SteamGameArt {
val cover = chosenFile(context, game.appId, AddedGameArt.Slot.COVER)
val hero = chosenFile(context, game.appId, AddedGameArt.Slot.BACKGROUND)
val icon = chosenFile(context, game.appId, AddedGameArt.Slot.ICON)
- if (cover == null && hero == null && icon == null) return game
+ val logo = chosenFile(context, game.appId, AddedGameArt.Slot.LOGO)
+ if (cover == null && hero == null && icon == null && logo == null) return game
return Library.SteamGame(
game.appId, game.name, cover ?: game.art, game.library, game.gameId,
hero ?: game.hero, game.lastPlayed, game.gameFiles, game.protonPrefix, icon ?: game.icon, game.source, game.storeId,
+ logo ?: game.logo,
)
}
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/SteamGridDb.kt b/app/src/main/java/com/droiddeck/launcher/frontend/SteamGridDb.kt
index dec6c24cfb..2eaa89410d 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/SteamGridDb.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/SteamGridDb.kt
@@ -84,18 +84,23 @@ object SteamGridDb {
.filter { it.second > 0 && it.first > 0 }
.maxByOrNull { it.second }?.first
- fun download(key: String, id: Int, cache: File): Boolean {
+ internal fun cacheName(slot: AddedGameArt.Slot): String =
+ when (slot) {
+ AddedGameArt.Slot.COVER -> "p.jpg"
+ AddedGameArt.Slot.WIDE -> "header.jpg"
+ AddedGameArt.Slot.BACKGROUND -> "hero.jpg"
+ AddedGameArt.Slot.LOGO -> "logo.png"
+ AddedGameArt.Slot.ICON -> "icon-sgdb.png"
+ }
+
+ fun download(key: String, id: Int, cache: File, slots: Set = AddedGameArt.Slot.values().toSet()): Boolean {
var got = false
- for ((path, local) in listOf(
- "grids/game/$id?dimensions=600x900&$QUERY" to "p.jpg",
- "grids/game/$id?dimensions=460x215,920x430&$QUERY" to "header.jpg",
- "heroes/game/$id?$QUERY" to "hero.jpg",
- "logos/game/$id?$QUERY" to "logo.png",
- "icons/game/$id?$QUERY" to "icon-sgdb.png",
- )) {
+ for (slot in AddedGameArt.Slot.values()) {
+ if (slot !in slots) continue
+ val local = cacheName(slot)
val dst = File(cache, local)
if (dst.isFile) continue
- val items = json(key, "$API/$path")?.optJSONArray("data") ?: continue
+ val items = json(key, "$API/${path(id, slot)}")?.optJSONArray("data") ?: continue
val url = best(items, local.endsWith(".png")) ?: continue
val bytes = AddedGameArt.get(url) ?: continue
val tmp = File(cache, "$local.tmp")
diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/WinCompSources.kt b/app/src/main/java/com/droiddeck/launcher/frontend/WinCompSources.kt
index 7562cc1ee0..63e8627790 100644
--- a/app/src/main/java/com/droiddeck/launcher/frontend/WinCompSources.kt
+++ b/app/src/main/java/com/droiddeck/launcher/frontend/WinCompSources.kt
@@ -3,12 +3,13 @@ package com.droiddeck.launcher.frontend
import android.content.Context
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreGameSidecar
+import com.droiddeck.launcher.session.WinComponents
import org.json.JSONObject
import java.io.File
import java.util.Locale
object WinCompSources {
- enum class Origin { STEAM, GOG, EPIC, AMAZON, STEAM_NAME, FOLDER }
+ enum class Origin { STEAM, GOG, EPIC, AMAZON, STEAM_NAME, FOLDER, XBOX }
data class Finding(val component: String?, val original: String, val origin: Origin, val auto: Boolean, val args: List = emptyList())
@@ -49,6 +50,17 @@ object WinCompSources {
fun installer(path: String): List = if (UE_PREREQ.containsMatchIn(path)) listOf("vcredist2022", "d3dx9") else DependencyDetector.componentsFor(path)
+ private val XBOX_KNOWN = Regex("""> {
+ val config = folder?.listFiles().orEmpty().firstOrNull { it.isFile && it.name.equals("MicrosoftGame.config", ignoreCase = true) && it.length() < 1L shl 20 }
+ val declared = config?.let { file -> runCatching { XBOX_KNOWN.findAll(file.readText()).map { it.groupValues[1] }.toList() }.getOrNull() }.orEmpty()
+ return (listOf("VC14") + declared).flatMap { name -> XBOX_COMPONENTS[name].orEmpty().map { it to name } }.distinctBy { it.first }
+ }
+
fun steamDepots(ids: List): List> = ids.mapNotNull { SteamRedists.DEPOTS[it] }.distinctBy { it.first }
@@ -94,6 +106,7 @@ object WinCompSources {
parts.forEach { out += Finding(it, original, Origin.EPIC, true) }
}
}
+ store == Store.XBOX -> xbox(folder).forEach { (component, original) -> out += Finding(component, original, Origin.XBOX, true) }
store == Store.AMAZON -> folder?.let { amazonPostInstall(it) }?.forEach { command ->
val parts = installer(command)
val original = command.replace('\\', '/').substringAfterLast('/')
diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt
index 4282ecf6f3..3d493c6063 100644
--- a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt
+++ b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt
@@ -50,8 +50,10 @@ object FrameGen {
else -> context.getString(R.string.frame_gen_off)
}
- fun apply(context: Context, refreshHz: Float): String? {
- val mode = mode(context)
+ fun apply(context: Context, refreshHz: Float): String? = apply(context, mode(context), refreshHz)
+
+ /** Arms [mode] in this process's compositor; the cloud player passes its own mode and frame-rate cap. */
+ fun apply(context: Context, mode: Mode, refreshHz: Float): String? {
when (mode.engine) {
ENGINE_LSFG -> {
val status = Lossless.sync(context)
diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/TpUbwcHint.kt b/app/src/main/java/com/droiddeck/launcher/gpu/TpUbwcHint.kt
index 1ccee78e24..893d569a60 100644
--- a/app/src/main/java/com/droiddeck/launcher/gpu/TpUbwcHint.kt
+++ b/app/src/main/java/com/droiddeck/launcher/gpu/TpUbwcHint.kt
@@ -1,6 +1,8 @@
package com.droiddeck.launcher.gpu
+import android.content.Context
import android.util.Log
+import com.droiddeck.launcher.session.SessionPrefs
object TpUbwcHint {
const val ENV = "FD_DEV_FEATURES"
@@ -8,31 +10,43 @@ object TpUbwcHint {
@Volatile private var resolved = false
@Volatile private var cached: String? = null
+ @Volatile var activeMode: String? = null
+ private set
// On Adreno 740, TPL1_DBG_ECO_CNTL1.TP_UBWC_FLAG_HINT is shared by every driver on the GPU and must
- // match the system driver: blob v6xx leaves it off, newer blobs set it. A mismatch corrupts Android UI.
+ // match the system driver. A mismatch corrupts Android UI.
// Samsung's One UI firmware sets it whatever blob version it reports.
- internal fun features(model: Int, systemDriverVersion: String?, samsung: Boolean = false): String? {
+ internal fun features(model: Int, systemDriverVersion: String?, samsung: Boolean = false,
+ mode: String = SessionPrefs.TP_UBWC_AUTO): String? {
if (model != 740) return null
+ if (mode == SessionPrefs.TP_UBWC_ON) return "enable_tp_ubwc_flag_hint=1"
+ if (mode == SessionPrefs.TP_UBWC_OFF) return "enable_tp_ubwc_flag_hint=0"
if (samsung) return "enable_tp_ubwc_flag_hint=1"
- val blob = systemDriverVersion?.split('.')?.getOrNull(1)?.toIntOrNull() ?: return null
- return "enable_tp_ubwc_flag_hint=" + if (blob >= 700) "1" else "0"
+ val parts = systemDriverVersion?.split('.') ?: return null
+ val blob = parts.getOrNull(1)?.toIntOrNull() ?: return null
+ val patch = parts.getOrNull(2)?.toIntOrNull() ?: 0
+ val on = blob >= 700 || (blob == 676 && patch >= 76)
+ return "enable_tp_ubwc_flag_hint=" + if (on) "1" else "0"
}
@Synchronized
- fun forThisDevice(): String? {
+ fun forThisDevice(context: Context): String? {
if (resolved) return cached
+ val mode = SessionPrefs.tpUbwcMode(context)
val gpu = GpuInfo.detect()
val model = gpu.model
val version = if (model == 740) VulkanInfo.query()["driver_version"] else null
- cached = features(model, version, gpu.oneUi8Gen2)
+ cached = features(model, version, gpu.oneUi8Gen2, mode)
+ activeMode = mode
resolved = true
- Log.i(TAG, "Adreno $model${if (gpu.oneUi8Gen2) " (One UI)" else ""}, system driver ${version ?: "n/a"}: ${cached ?: "driver default"}")
+ Log.i(TAG, "Adreno $model${if (gpu.oneUi8Gen2) " (One UI)" else ""}, system driver ${version ?: "n/a"}, mode $mode: ${cached ?: "driver default"}")
return cached
}
- fun applyToProcess() {
- val value = forThisDevice() ?: return
+ fun restartRequired(context: Context): Boolean = resolved && activeMode != SessionPrefs.tpUbwcMode(context)
+
+ fun applyToProcess(context: Context) {
+ val value = forThisDevice(context) ?: return
runCatching { android.system.Os.setenv(ENV, value, true) }
.onFailure { Log.w(TAG, "setenv $ENV failed: ${it.javaClass.simpleName}") }
}
diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt
index ac87bd0aa5..45f07471bc 100644
--- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt
+++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt
@@ -301,15 +301,18 @@ class LinuxNetworkLinkComponent(
}
}
- private fun seededMac(): String {
- val id = Settings.Secure.getString(appContext.contentResolver, Settings.Secure.ANDROID_ID) ?: "bannerlator"
- val bytes = java.security.MessageDigest.getInstance("SHA-1").digest(id.toByteArray())
- val b0 = (bytes[0].toInt() and 0xfc) or 0x02
- return listOf(b0, bytes[1].toInt(), bytes[2].toInt(), bytes[3].toInt(), bytes[4].toInt(), bytes[5].toInt())
- .joinToString(":") { "%02x".format(it and 0xff) }
- }
+ private fun seededMac(): String =
+ seededMac { Settings.Secure.getString(appContext.contentResolver, Settings.Secure.ANDROID_ID) }
companion object {
+ internal fun seededMac(readId: () -> String?): String {
+ val id = runCatching(readId).getOrNull() ?: "bannerlator"
+ val bytes = java.security.MessageDigest.getInstance("SHA-1").digest(id.toByteArray())
+ val b0 = (bytes[0].toInt() and 0xfc) or 0x02
+ return listOf(b0, bytes[1].toInt(), bytes[2].toInt(), bytes[3].toInt(), bytes[4].toInt(), bytes[5].toInt())
+ .joinToString(":") { "%02x".format(it and 0xff) }
+ }
+
private const val TAG = "LinuxNetworkLink"
private const val LINK_FILE = "etc/droiddeck-net"
private const val LINK_INDEX = 2
diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java
index 65cca5919a..6772d4203f 100644
--- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java
+++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java
@@ -111,6 +111,11 @@ public final class LinuxRuntime {
File root = rootDir(context);
List binds = binds(context, sessionRoot, runtimeDir, externalStorage, extraBinds);
if (sessionRoot != null) lastBinds = binds;
+ return commandWithBinds(context, root, binds, guestCommand);
+ }
+
+ public static List commandWithBinds(Context context, File root, List binds,
+ List guestCommand) {
List cmd = prootPrefix(context, root, "/root");
for (String spec : binds) bind(cmd, spec);
cmd.addAll(guestCommand);
diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/RuntimeInstallService.kt b/app/src/main/java/com/droiddeck/launcher/runtime/RuntimeInstallService.kt
index d2cee04350..aa53092fe2 100644
--- a/app/src/main/java/com/droiddeck/launcher/runtime/RuntimeInstallService.kt
+++ b/app/src/main/java/com/droiddeck/launcher/runtime/RuntimeInstallService.kt
@@ -9,7 +9,7 @@ import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.IBinder
-import com.droiddeck.launcher.MainActivity
+import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
class RuntimeInstallService : Service() {
@@ -75,7 +75,7 @@ class RuntimeInstallService : Service() {
enableVibration(false)
})
val open = PendingIntent.getActivity(this, 0,
- Intent(this, MainActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
+ Intent(this, FrontEndActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
PendingIntent.FLAG_IMMUTABLE)
return Notification.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_stat_session)
diff --git a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt
index 8267edd57a..953196900c 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt
@@ -51,7 +51,7 @@ object BootMovie {
SessionPrefs.setBootMovieApplyNext(context, true)
BootMovieReport.note(context, "picked $id here; Steam names ${SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context))}")
// Whatever Steam names right now is about to be replaced, so it is not a pick to adopt later.
- SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context))?.let { SessionPrefs.setBootMovieSteamSeen(context, it) }
+ SessionFiles.startupMovieLocalPath(BootMovieLibrary.steamConfig(context))?.let { SessionPrefs.setBootMovieSteamSeen(context, it) }
}
fun customName(context: Context): String? =
@@ -167,10 +167,12 @@ object BootMovie {
* that movie becomes the choice here. Steam already plays it, so nothing is staged over it. True when the choice changed.
*/
fun syncFromSteam(context: Context): Boolean {
- val path = SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context)) ?: return false
- if (path == SessionPrefs.bootMovieSteamSeen(context)) return false
- SessionPrefs.setBootMovieSteamSeen(context, path)
- if (path == SessionFiles.BOOT_MOVIE_PATH) return false
+ val named = SessionFiles.startupMovieLocalPath(BootMovieLibrary.steamConfig(context)) ?: return false
+ val seen = SessionPrefs.bootMovieSteamSeen(context)
+ if (named == seen) return false
+ SessionPrefs.setBootMovieSteamSeen(context, named)
+ if (named == SessionFiles.BOOT_MOVIE_PATH || (named.isEmpty() && seen == null)) return false
+ val path = named.ifEmpty { "/movies/steam_os_startup.webm" }
val prefix = "/uioverrides/movies/"
// The list names a bought movie from the Steam folder (/config/communityitemscache/...), Steam's config from its config folder.
val id = if (path.startsWith(prefix)) BootMovieLibrary.idOf(path.removePrefix(prefix)) else {
diff --git a/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt b/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt
index 7c125e8196..0dd7a0fadf 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt
@@ -79,8 +79,9 @@ object BootMovieLibrary {
return customMovieDirs(context).map { File(it, name) }.firstOrNull { it.isFile && it.length() > 0L }
}
- private fun isMovie(file: File) = file.isFile && file.length() > 0L && file.name.endsWith(".webm", ignoreCase = true) &&
- file.name !in STAGED && !file.name.startsWith(".")
+ private fun isMovie(file: File) = isWebm(file) && file.name !in STAGED
+
+ private fun isWebm(file: File) = file.isFile && file.length() > 0L && file.name.endsWith(".webm", ignoreCase = true) && !file.name.startsWith(".")
private fun readMeta(context: Context): JSONObject =
runCatching { JSONObject(metaFile(context).readText()) }.getOrDefault(JSONObject())
@@ -136,7 +137,7 @@ object BootMovieLibrary {
}
val bought = HashMap()
for (root in steamRoots(context)) {
- File(root, "steamui/movies").listFiles { f -> isMovie(f) && f.nameWithoutExtension.lowercase() in NATIVE }.orEmpty()
+ File(root, "steamui/movies").listFiles { f -> isWebm(f) && f.nameWithoutExtension.lowercase() in NATIVE }.orEmpty()
.sortedBy { it.name.lowercase() }.forEach { steam.putIfAbsent(STEAM_PREFIX + "/movies/" + it.name, it) }
val scan = pointShopMovies(root)
bought.putAll(scan.titles)
@@ -144,8 +145,8 @@ object BootMovieLibrary {
}
val seen = HashSet()
for ((id, file) in steam) {
- if (file.name in STAGED || !seen.add(file.canonicalPath)) continue
val native = file.nameWithoutExtension.lowercase() in NATIVE
+ if ((file.name in STAGED && !native) || !seen.add(file.canonicalPath)) continue
// Steam names a bought movie by an item number and a hash; the points shop's own title is shown when Steam has it.
val title = if (native) NATIVE[file.nameWithoutExtension.lowercase()] ?: file.nameWithoutExtension else bought[file.path] ?: boughtId(file)?.let { "#$it" } ?: file.nameWithoutExtension
out.add(Entry(id, title, if (native) SOURCE_STEAM else SOURCE_POINTSHOP, file, removable = false))
@@ -153,8 +154,11 @@ object BootMovieLibrary {
return out
}
- /** The three startup movies Steam ships with; Steam's movies folder holds many more videos that are not startup movies. */
- private val NATIVE = mapOf("deck_startup" to "Deck startup", "oled_startup" to "Oled startup", "startup_machine" to "Machine startup")
+ /** The four startup movies Steam ships with; Steam's movies folder holds many more videos that are not startup movies. */
+ private val NATIVE = mapOf(
+ "deck_startup" to "Deck startup", "oled_startup" to "Oled startup", "startup_machine" to "Machine startup",
+ "steam_os_startup" to "SteamOS startup",
+ )
private val skippedFolders = setOf("uioverrides", "steamapps", "librarycache", "httpcache", "logs", "compatdata", "shadercache")
diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt
index 40a0f18c8e..8ebcdcfcca 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt
@@ -741,13 +741,19 @@ object ComponentsManager {
class StoredOriginal(val protonId: String, val protonName: String?, val comp: String, val protonVersion: String, val size: Long, val kept: Boolean)
class Stored(val packages: List, val originals: List)
- private fun packagesInUse(state: JSONObject): Set {
+ internal fun liveSelection(key: String, entry: JSONObject, proton: Proton?): Boolean =
+ proton != null && (key == "queued" || entry.optString("protonVersion") == proton.version)
+
+ private fun packagesInUse(state: JSONObject, installed: Map): Set {
val names = HashSet()
for (key in listOf("active", "queued")) {
val byProton = state.optJSONObject(key) ?: continue
for (pid in byProton.keys()) {
val comps = byProton.optJSONObject(pid) ?: continue
- for (comp in comps.keys()) comps.optJSONObject(comp)?.optString("file")?.takeIf { it.isNotEmpty() }?.let(names::add)
+ for (comp in comps.keys()) {
+ val entry = comps.optJSONObject(comp) ?: continue
+ if (liveSelection(key, entry, installed[pid])) entry.optString("file").takeIf { it.isNotEmpty() }?.let(names::add)
+ }
}
}
val profiles = state.optJSONObject("profiles")
@@ -767,8 +773,8 @@ object ComponentsManager {
fun stored(context: Context): Stored = synchronized(lock) {
val state = loadState(context)
- val used = packagesInUse(state)
- val installed = protons(context).associateBy { it.id }
+ val installed = protons(context).distinctBy { it.id }.associateBy { it.id }
+ val used = packagesInUse(state, installed)
val originals = originalsDir(context).listFiles()?.filter { it.isDirectory }?.flatMap { proton ->
proton.listFiles()?.filter { it.isDirectory }?.flatMap { version ->
COMPONENTS.mapNotNull { comp ->
@@ -794,27 +800,50 @@ object ComponentsManager {
true
}
+ fun forgetProton(context: Context, dirName: String) {
+ synchronized(lock) {
+ val id = safeName(dirName)
+ if (protons(context).any { it.id == id }) return
+ val state = loadState(context)
+ val selected = listOf("active", "queued").map { state.sub(it).remove(id) != null }.any { it }
+ if (selected && runCatching { saveState(context, state) }.onFailure { Log.w(TAG, "forget $id", it) }.isFailure) return
+ File(originalsDir(context), id).deleteRecursively()
+ }
+ }
+
fun deletePackage(context: Context, file: String): String = synchronized(lock) {
val name = safeName(file)
val state = loadState(context)
- val queued = state.sub("queued")
- for (pid in queued.keys()) {
- val comps = queued.optJSONObject(pid) ?: continue
- for (comp in comps.keys()) check(comps.optJSONObject(comp)?.optString("file") != name) { context.getString(R.string.cmgr_package_in_use, name, pid) }
- }
- val active = state.sub("active")
- for (pid in active.keys()) {
- val comps = active.optJSONObject(pid) ?: continue
- for (comp in comps.keys()) check(comps.optJSONObject(comp)?.optString("file") != name) { context.getString(R.string.cmgr_package_in_use, name, pid) }
- }
- val profiles = state.sub("profiles")
- for (scope in profiles.keys()) {
- val profile = profiles.optJSONObject(scope) ?: continue
- check(COMPONENTS.none { profile.optString(it) == name }) { context.getString(R.string.cmgr_package_in_use, name, scope) }
+ val installed = protons(context).distinctBy { it.id }.associateBy { it.id }
+ var changed = false
+ for (key in listOf("queued", "active")) {
+ val byProton = state.sub(key)
+ for (pid in byProton.keys().asSequence().toList()) {
+ val comps = byProton.optJSONObject(pid) ?: continue
+ for (comp in comps.keys().asSequence().toList()) {
+ val entry = comps.optJSONObject(comp) ?: continue
+ if (entry.optString("file") != name) continue
+ check(!liveSelection(key, entry, installed[pid])) { context.getString(R.string.cmgr_package_in_use, name, installed[pid]?.name ?: pid) }
+ comps.remove(comp)
+ changed = true
+ }
+ if (comps.length() == 0) byProton.remove(pid)
+ }
}
val f = File(packagesDir(context), name)
check(f.isFile) { context.getString(R.string.cmgr_package_not_stored, name) }
- f.delete()
+ val profiles = state.sub("profiles")
+ for (scope in profiles.keys().asSequence().toList()) {
+ val profile = profiles.optJSONObject(scope) ?: continue
+ for (comp in COMPONENTS.filter { profile.optString(it) == name }) {
+ rememberProfiledComponent(state, comp)
+ profile.remove(comp)
+ changed = true
+ }
+ if (profile.length() == 0) profiles.remove(scope)
+ }
+ check(f.delete()) { name }
+ if (changed) saveState(context, state)
context.getString(R.string.cmgr_deleted, name)
}
diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt
index 7855c49590..40135f08de 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt
@@ -26,6 +26,7 @@ object GpuClockPin {
pinned = true
"gpu clock: held at its top"
} catch (t: Throwable) {
+ File(context.filesDir, MARKER).delete()
Log.w(TAG, "pin", t)
"gpu clock: pin failed"
}
diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt
index fb6efe09f3..0063509167 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt
@@ -1,5 +1,6 @@
package com.droiddeck.launcher.session
+import android.os.SystemClock
import android.util.Log
import com.droiddeck.launcher.core.SessionPart
import com.droiddeck.launcher.runtime.LinuxRuntime
@@ -23,11 +24,16 @@ class GpuStatsComponent(val dir: File) : SessionPart() {
}
fun prepare(): Boolean {
- if (!File(KGSL).exists() || MANGOHUD_FILES.none { File(KGSL, it).let { f -> f.exists() && !f.canRead() } }) return false
+ if (!File(KGSL).exists()) return false
+ val unreadable = MANGOHUD_FILES.any { File(KGSL, it).let { f -> f.exists() && !f.canRead() } }
+ if (!unreadable && !File(GPUBUSY).canRead()) return false
return try {
dir.mkdirs()
dir.listFiles()?.forEach { java.nio.file.Files.deleteIfExists(it.toPath()) }
feeds.clear()
+ PASSTHROUGH_FILES.forEach { name ->
+ runCatching { File(dir, name).writeText(File(KGSL, name).readText()) }
+ }
loadFeed()?.let { load ->
feeds.add(load)
feeds.add(Feed(File(dir, "perf_now"), load.source, load.read, "%-6s\n", percent = true))
@@ -37,7 +43,7 @@ class GpuStatsComponent(val dir: File) : SessionPart() {
feeds.add(Feed(File(dir, "cur_freq"), clock.source, { clock.read()?.times(1_000_000) }, "%-10d\n"))
}
pick("temp", tempSources(), "%6d\n") { milliCelsius(it) }?.let { feeds.add(it) }
- feeds.forEach { feed -> feed.read()?.let { write(feed, it) } }
+ refresh()
Log.i(TAG, "hud: kgsl stats from the session's own: " + MANGOHUD_FILES.joinToString { name ->
"$name " + (feeds.firstOrNull { it.file.name == name }?.source ?: "none")
})
@@ -55,11 +61,20 @@ class GpuStatsComponent(val dir: File) : SessionPart() {
while (running) {
try { Thread.sleep(PERIOD_MS) } catch (e: InterruptedException) { break }
if (!running) break
- for (feed in feeds) feed.read()?.let { write(feed, it) }
+ refresh()
}
}, "gpu-stats").apply { isDaemon = true; start() }
}
+ // kgsl's gpubusy can read 0 0 straight after a read, so feeds that share a reader share one read.
+ private fun refresh() {
+ val values = HashMap<() -> Long?, Long?>()
+ for (feed in feeds) {
+ if (feed.read !in values) values[feed.read] = feed.read()
+ values[feed.read]?.let { write(feed, it) }
+ }
+ }
+
override fun stop() {
running = false
thread?.interrupt()
@@ -67,16 +82,30 @@ class GpuStatsComponent(val dir: File) : SessionPart() {
}
private fun loadFeed(): Feed? {
- pick("gpu_busy_percentage", LOAD_SOURCES, "%3d %%\n") { it.coerceIn(0, 100) }?.let { return it }
- val gpubusy = "$KGSL/gpubusy"
- val read = {
- runCatching {
- val parts = File(gpubusy).readText().trim().split(Regex("\\s+"))
- val total = parts[1].toLong()
- if (total > 0) (parts[0].toLong() * 100 / total).coerceIn(0, 100) else 0L
+ latchedBusyFeed()?.let { return it }
+ return pick("gpu_busy_percentage", LOAD_SOURCES, "%3d %%\n") { it.coerceIn(0, 100) }
+ }
+
+ // kgsl publishes busy/total once per ~1 s of GPU-on time and zeroes it on any read while the GPU is
+ // power-collapsed, so direct pollers mostly see 0; latch each published window instead.
+ private fun latchedBusyFeed(): Feed? {
+ var load = 0L
+ var windowAt = 0L
+ val read = read@{
+ val parts = runCatching {
+ File(GPUBUSY).readText().trim().split(Regex("\\s+")).map { it.toLong() }
}.getOrNull()
+ if (parts == null || parts.size < 2) return@read null
+ val now = SystemClock.elapsedRealtime()
+ if (parts[1] > 0) {
+ load = (parts[0] * 100 / parts[1]).coerceIn(0, 100)
+ windowAt = now
+ } else if (now - windowAt > LOAD_HOLD_MS) {
+ load = 0
+ }
+ load
}
- return if (read() != null) Feed(File(dir, "gpu_busy_percentage"), gpubusy, read, "%3d %%\n") else null
+ return if (read() != null) Feed(File(dir, "gpu_busy_percentage"), GPUBUSY, read, "%3d %%\n") else null
}
private fun pick(name: String, sources: List, format: String, unit: (Long) -> Long?): Feed? {
@@ -100,8 +129,11 @@ class GpuStatsComponent(val dir: File) : SessionPart() {
const val KGSL = "/sys/class/kgsl/kgsl-3d0"
const val MSM_LOAD = "/sys/kernel/debug/dri/0/perf_now"
const val MSM_CLOCK = "/sys/devices/platform/soc@0/3d00000.gpu/devfreq/3d00000.gpu/cur_freq"
+ private const val GPUBUSY = "$KGSL/gpubusy"
private const val PERIOD_MS = 500L
+ private const val LOAD_HOLD_MS = 5_000L
private val MANGOHUD_FILES = listOf("gpu_busy_percentage", "clock_mhz", "temp")
+ private val PASSTHROUGH_FILES = listOf("gpu_model", "gpu_chipid")
private const val QCOM_GPU = "/sys/kernel/gpu"
private val LOAD_SOURCES = listOf(
"$KGSL/gpu_busy_percentage", "$KGSL/devfreq/gpu_load", "$KGSL/gpuload", "$QCOM_GPU/gpu_busy",
diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt
index a23f23bebf..f69983f0db 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt
@@ -87,11 +87,10 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
if (line.startsWith("== STEP ")) {
stepAt = at
stepText = line.substringAfter("== STEP ").substringAfter(' ')
- val m = INSTALL_COUNT.find(line)
- if (m != null) {
+ clientDownload(line)?.let { (what, percent) ->
clientDownloadAt = at
- clientDownload = m.groupValues[1]
- clientPercent = m.groupValues[2].toInt() * 100 / maxOf(1, m.groupValues[3].toInt())
+ clientDownload = what
+ clientPercent = percent
}
} else {
val m = UPDATE_PROGRESS.find(line)
@@ -132,6 +131,19 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
}
}
+ internal fun clientDownload(line: String): Pair? {
+ val count = INSTALL_COUNT.find(line) ?: return null
+ val mb = INSTALL_MEGABYTES.find(line.substring(count.range.last + 1))
+ val done = mb?.groupValues?.get(1)?.toLongOrNull()
+ val total = mb?.groupValues?.get(2)?.toLongOrNull()
+ if (done != null && total != null && total > 0) {
+ return "$done / $total MB" to (done * 100 / total).toInt().coerceIn(0, 100)
+ }
+ val part = count.groupValues[2].toIntOrNull() ?: return null
+ val all = count.groupValues[3].toIntOrNull() ?: return null
+ return count.groupValues[1] to (part.toLong() * 100 / maxOf(1, all)).coerceIn(0L, 100L).toInt()
+ }
+
internal fun readableScriptStep(scriptStep: String): Boolean {
val t = scriptStep.lowercase()
return t.startsWith("download") || t.startsWith("checking the linux") || t.startsWith("unpacking") || t.startsWith("installing")
@@ -140,5 +152,6 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
private const val TAIL_BYTES = 48L * 1024
private val UPDATE_PROGRESS = Regex("""Downloading update \((\d+) of (\d+) KB\)""")
private val INSTALL_COUNT = Regex("""downloading Steam: (\S+) \((\d+)/(\d+)\)""")
+ private val INSTALL_MEGABYTES = Regex("""^, (\d+) of (\d+) MB""")
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt b/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt
index 42c0deeb6f..20714ba95a 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt
@@ -136,11 +136,13 @@ object ProtonExtras {
fun remove(context: Context, tool: Tool, dir: String? = null) {
val name = if (dir != null) dir.takeIf { it in installedAll(context, tool) } ?: return else installed(context, tool) ?: return
- File(toolsDir(context), name).deleteRecursively()
+ if (File(toolsDir(context), name).deleteRecursively()) ComponentsManager.forgetProton(context, name)
}
fun removeOlder(context: Context, tool: Tool) {
- installedAll(context, tool).dropLast(1).forEach { File(toolsDir(context), it).deleteRecursively() }
+ installedAll(context, tool).dropLast(1).forEach {
+ if (File(toolsDir(context), it).deleteRecursively()) ComponentsManager.forgetProton(context, it)
+ }
}
@Synchronized
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt
index 5a661df23f..2416d39275 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt
@@ -200,22 +200,86 @@ object SessionArtifacts {
internal fun recordedClient(dir: File): String? =
runCatching { File(dir, CLIENT_FILE).readText().trim() }.getOrNull()?.takeIf { it == "arm64" || it == "x86_64" }
+ private const val LOG_MARKS = "steam-log-marks.txt"
+ private const val MAX_STEAM_LOG = 8L * 1024 * 1024
+ private const val HEAD = 4096L
+
+ private class Mark(val size: Long, val head: String)
+
+ fun markSteamLogs(dir: File, logs: File) {
+ val lines = logs.listFiles { f -> f.isFile }?.mapNotNull { f ->
+ val size = f.length()
+ head(f, size)?.let { "$size\t$it\t${f.name}" }
+ } ?: return
+ runCatching { File(dir, LOG_MARKS).writeText(lines.joinToString("") { "$it\n" }) }
+ }
+
+ private fun head(f: File, length: Long): String? = runCatching {
+ val buf = ByteArray(minOf(length, HEAD).toInt())
+ f.inputStream().use { input ->
+ var off = 0
+ while (off < buf.size) {
+ val n = input.read(buf, off, buf.size - off)
+ if (n < 0) return@runCatching null
+ off += n
+ }
+ }
+ java.security.MessageDigest.getInstance("SHA-1").digest(buf).joinToString("") { "%02x".format(it) }
+ }.getOrNull()
+
+ private fun steamLogMarks(dir: File): List? = runCatching {
+ File(dir, LOG_MARKS).readLines().mapNotNull { line ->
+ val parts = line.split('\t', limit = 3)
+ parts.getOrNull(0)?.toLongOrNull()?.let { size -> parts.getOrNull(1)?.let { Mark(size, it) } }
+ }
+ }.getOrNull()
+
+ private fun startOf(src: File, size: Long, marks: List): Long {
+ val heads = HashMap()
+ return marks.filter { it.size <= size }.sortedByDescending { it.size }
+ .firstOrNull { m -> heads.getOrPut(minOf(m.size, HEAD)) { head(src, m.size) } == m.head }?.size ?: 0L
+ }
+
private fun copySteamLogs(context: Context, dir: File, record: Record, steamArch: String? = null) {
val logs = File(steamArch?.let { SessionPrefs.steamRoot(context, it) } ?: SessionPrefs.activeSteamRoot(context), "logs")
if (!logs.isDirectory) return
val out = File(dir, "steam").apply { mkdirs() }
- logs.listFiles { f -> f.isFile && f.length() < 8L * 1024 * 1024 }?.forEach { src ->
+ copySessionLogs(logs, dir, out).forEach { dst -> record.files[dst] = Scrubbed(dst.length(), dst.lastModified()) }
+ Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
+ }
+
+ internal fun copySessionLogs(logs: File, dir: File, out: File): List {
+ val marks = steamLogMarks(dir)
+ val copied = ArrayList()
+ logs.listFiles { f -> f.isFile }?.forEach { src ->
+ val size = src.length()
+ val from = marks?.let { startOf(src, size, it) } ?: 0L
+ if (marks != null && from == size || size - from >= MAX_STEAM_LOG) return@forEach
try {
val dst = File(out, src.name)
- dst.bufferedWriter().use { w ->
- src.forEachLine { line -> w.write(LogRedactor.redact(line)); w.newLine() }
+ src.inputStream().buffered().use { input ->
+ var left = if (from > 0) from - 1 else 0L
+ while (left > 0) {
+ val skipped = input.skip(left)
+ if (skipped <= 0) break
+ left -= skipped
+ }
+ if (from > 0 && input.read() != '\n'.code) {
+ while (true) {
+ val c = input.read()
+ if (c < 0 || c == '\n'.code) break
+ }
+ }
+ dst.bufferedWriter().use { w ->
+ input.bufferedReader().forEachLine { line -> w.write(LogRedactor.redact(line)); w.newLine() }
+ }
}
- record.files[dst] = Scrubbed(dst.length(), dst.lastModified())
+ copied.add(dst)
} catch (e: Exception) {
Log.w(TAG, "could not scrub ${src.name}", e)
}
}
- Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
+ return copied
}
/**
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 163baccf51..61a32a1b83 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt
@@ -59,8 +59,10 @@ object SessionFiles {
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
"usr/local/bin/droiddeck-steam-ui-scale" to "usr/local/bin/droiddeck-steam-ui-scale",
"usr/local/bin/droiddeck-steam-language" to "usr/local/bin/droiddeck-steam-language",
+ "usr/local/bin/droiddeck-steam-shaders" to "usr/local/bin/droiddeck-steam-shaders",
"usr/local/bin/droiddeck-steam-desktop-ui" to "usr/local/bin/droiddeck-steam-desktop-ui",
"usr/local/bin/droiddeck-steam-library" to "usr/local/bin/droiddeck-steam-library",
+ "usr/local/bin/droiddeck-steam-share" to "usr/local/bin/droiddeck-steam-share",
"usr/local/bin/droiddeck-seed-redists" to "usr/local/bin/droiddeck-seed-redists",
"usr/local/bin/droiddeck-launcher-cores" to "usr/local/bin/droiddeck-launcher-cores",
"usr/local/bin/droiddeck-proton-extra" to "usr/local/bin/droiddeck-proton-extra",
@@ -79,6 +81,7 @@ object SessionFiles {
"usr/local/bin/droiddeck-steam-games" to "usr/local/bin/droiddeck-steam-games",
"usr/local/bin/droiddeck-pad-defaults" to "usr/local/bin/droiddeck-pad-defaults",
"usr/local/bin/droiddeck-steam-x64" to "usr/local/bin/droiddeck-steam-x64",
+ "usr/local/bin/droiddeck-steamrt-shim" to "usr/local/bin/droiddeck-steamrt-shim",
"usr/local/bin/droiddeck-x64-arm-proton" to "usr/local/bin/droiddeck-x64-arm-proton",
"usr/local/bin/droiddeck-x64-arm-webhelper" to "usr/local/bin/droiddeck-x64-arm-webhelper",
"usr/local/bin/droiddeck-x64-webhelper" to "usr/local/bin/droiddeck-x64-webhelper",
@@ -403,10 +406,12 @@ object SessionFiles {
private fun activeStartupMovie(text: String): VdfBlock? = customizationMovie(text) ?: olderMovie(text)
/** The movie Steam's config selects, as a path like `/uioverrides/movies/x.webm`; null when none is named. */
- internal fun startupMoviePath(config: File): String? {
+ internal fun startupMoviePath(config: File): String? = startupMovieLocalPath(config)?.takeIf { it.isNotEmpty() }
+
+ internal fun startupMovieLocalPath(config: File): String? {
val text = runCatching { config.readText() }.getOrNull() ?: return null
val movie = activeStartupMovie(text) ?: return null
- return scalar(text.substring(movie.keyStart, movie.close + 1), "LocalPath")?.takeIf { it.isNotEmpty() }
+ return scalar(text.substring(movie.keyStart, movie.close + 1), "LocalPath")
}
/** Both `StartupMovie` sections of Steam's config as written there, for the report; null when there is none. */
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt
index 6cbb89c580..f15265cca4 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt
@@ -4,10 +4,8 @@ import android.content.Context
import android.content.pm.ActivityInfo
import androidx.annotation.StringRes
import com.droiddeck.launcher.R
-import com.droiddeck.launcher.core.CpuAllocationDefaults
import com.droiddeck.launcher.core.GameEnvironment
import com.droiddeck.launcher.core.TextureFiltering
-import com.droiddeck.launcher.core.ZramSupport
import com.droiddeck.launcher.gpu.Cardboard
import com.droiddeck.launcher.gpu.ScreenEffects
import com.droiddeck.launcher.gpu.SystemVulkanDriver
@@ -53,9 +51,9 @@ object SessionPrefs {
)
fun orientation(context: Context): Int =
- prefs(context).getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+ prefs(context).getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
.takeIf { value -> orientationOptions.any { it.first == value } }
- ?: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+ ?: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
fun setOrientation(context: Context, orientation: Int) {
require(orientationOptions.any { it.first == orientation })
@@ -266,6 +264,19 @@ object SessionPrefs {
const val GPU_DRIVERS_MANUAL = "manual"
const val GPU_DRIVERS_MIX = "mix"
+ const val TP_UBWC_AUTO = "auto"
+ const val TP_UBWC_ON = "on"
+ const val TP_UBWC_OFF = "off"
+
+ fun tpUbwcMode(context: Context): String =
+ prefs(context).getString("tpUbwcMode", TP_UBWC_AUTO)
+ ?.takeIf { it in setOf(TP_UBWC_AUTO, TP_UBWC_ON, TP_UBWC_OFF) } ?: TP_UBWC_AUTO
+
+ fun setTpUbwcMode(context: Context, mode: String) {
+ require(mode in setOf(TP_UBWC_AUTO, TP_UBWC_ON, TP_UBWC_OFF))
+ prefs(context).edit().putString("tpUbwcMode", mode).commit()
+ }
+
fun gpuDriverMode(context: Context): String =
prefs(context).getString("gpuDriverMode", GPU_DRIVERS_AUTO) ?: GPU_DRIVERS_AUTO
@@ -318,6 +329,34 @@ object SessionPrefs {
prefs(context).edit().putBoolean("returnAfterGame", on).apply()
}
+ private fun shaderPrecacheApplied(context: Context) =
+ java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.bl-shader-precache-applied")
+
+ /**
+ * Shader pre-caching as the launcher last set it, until a session reports it written into the
+ * client's config.vdf; after that the client's own toggle is the user's again.
+ */
+ fun pendingShaderPrecache(context: Context): Boolean? {
+ val prefs = prefs(context)
+ if (!prefs.contains("shaderPrecache")) return null
+ val on = prefs.getBoolean("shaderPrecache", true)
+ val applied = shaderPrecacheApplied(context)
+ val written = runCatching { applied.readText().trim() }.getOrNull() ?: return on
+ applied.delete()
+ if (written != if (on) "1" else "0") return on
+ prefs.edit().remove("shaderPrecache").apply()
+ return null
+ }
+
+ fun setShaderPrecache(context: Context, on: Boolean) {
+ shaderPrecacheApplied(context).delete()
+ prefs(context).edit().putBoolean("shaderPrecache", on).apply()
+ }
+
+ fun shaderPrecache(context: Context): Boolean = pendingShaderPrecache(context)
+ ?: runCatching { com.droiddeck.launcher.storage.SteamStorage.shaderPrecache(
+ java.io.File(steamRoot(context, steamClientArch(context)), "config/config.vdf").readText()) }.getOrDefault(true)
+
fun stretch16x9(context: Context): Boolean = prefs(context).getBoolean("stretch16x9", false)
fun setStretch16x9(context: Context, on: Boolean) {
@@ -355,30 +394,19 @@ object SessionPrefs {
prefs(context).edit().putBoolean("wifiDiscoveryAsked", true).apply()
}
- internal data class CoreAllocation(val clientOverride: Boolean, val clientCpus: String, val gameCpus: String)
-
- internal fun coreAllocation(context: Context, defaults: CpuAllocationDefaults.Allocation? = CpuAllocationDefaults.device): CoreAllocation {
- val saved = prefs(context)
- return CoreAllocation(
- saved.getBoolean("clientCpusOverride", defaults != null && !saved.contains("clientCpus")),
- saved.getString("clientCpus", defaults?.client.orEmpty()).orEmpty(),
- saved.getString("gameCpus", defaults?.game.orEmpty()).orEmpty(),
- )
- }
-
- fun clientCpusOverride(context: Context): Boolean = coreAllocation(context).clientOverride
+ fun clientCpusOverride(context: Context): Boolean = prefs(context).getBoolean("clientCpusOverride", false)
fun setClientCpusOverride(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("clientCpusOverride", on).apply()
}
- fun clientCpus(context: Context): String = coreAllocation(context).clientCpus
+ fun clientCpus(context: Context): String = prefs(context).getString("clientCpus", "").orEmpty()
fun setClientCpus(context: Context, list: String) {
prefs(context).edit().putString("clientCpus", list).apply()
}
- fun gameCpus(context: Context): String = coreAllocation(context).gameCpus
+ fun gameCpus(context: Context): String = prefs(context).getString("gameCpus", "").orEmpty()
fun setGameCpus(context: Context, list: String) {
prefs(context).edit().putString("gameCpus", list).apply()
@@ -390,7 +418,7 @@ object SessionPrefs {
prefs(context).edit().putBoolean("noXalia", on).apply()
}
- fun fastSync(context: Context): Boolean = prefs(context).getBoolean("fastSync", false)
+ fun fastSync(context: Context): Boolean = prefs(context).getBoolean("fastSync", true)
fun setFastSync(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("fastSync", on).apply()
@@ -425,6 +453,17 @@ object SessionPrefs {
.apply()
}
+ fun applyNtsyncDefault(context: Context) {
+ val prefs = prefs(context)
+ if (prefs.getBoolean("ntsyncDefaultV1", false)) return
+ prefs.edit()
+ .putBoolean("fastSync", true)
+ .putBoolean("fsyncFirst", false)
+ .putBoolean("syncFallback", true)
+ .putBoolean("ntsyncDefaultV1", true)
+ .apply()
+ }
+
fun syncFallback(context: Context): Boolean = prefs(context).getBoolean("syncFallback", true)
fun setSyncFallback(context: Context, on: Boolean) {
@@ -458,6 +497,13 @@ object SessionPrefs {
prefs(context).edit().putBoolean("prootFastPath", on).apply()
}
+ /** gamescope draws the cursor itself. Off by default: on a phone that plane costs frames. */
+ fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", false)
+
+ fun setCursorComposite(context: Context, on: Boolean) {
+ prefs(context).edit().putBoolean("cursorComposite", on).apply()
+ }
+
const val DEFAULT_GUEST_HOSTNAME = "DroidDeck"
@JvmStatic
@@ -887,6 +933,14 @@ object SessionPrefs {
it.getInt("gradientSecondary", com.droiddeck.launcher.ui.Themes.DEFAULT_SECONDARY)
}
+ /** How fast the Inner Gamer theme cycles its colours, 1 to 10. */
+ fun rgbSpeed(context: Context): Int =
+ prefs(context).getInt("innerGamerSpeed", com.droiddeck.launcher.ui.Themes.DEFAULT_RGB_SPEED).coerceIn(1, com.droiddeck.launcher.ui.Themes.RGB_SPEEDS)
+
+ fun setRgbSpeed(context: Context, speed: Int) {
+ prefs(context).edit().putInt("innerGamerSpeed", speed.coerceIn(1, com.droiddeck.launcher.ui.Themes.RGB_SPEEDS)).apply()
+ }
+
fun setGradientColors(context: Context, primary: Int, secondary: Int) {
prefs(context).edit().putInt("gradientPrimary", primary).putInt("gradientSecondary", secondary).apply()
}
@@ -1173,15 +1227,6 @@ object SessionPrefs {
}.apply()
}
- fun zramCompression(context: Context): Boolean {
- val prefs = prefs(context)
- return if (prefs.contains("zramCompression")) prefs.getBoolean("zramCompression", false) else ZramSupport.recommended(context)
- }
-
- fun setZramCompression(context: Context, on: Boolean) {
- prefs(context).edit().putBoolean("zramCompression", on).apply()
- }
-
fun gameStorage(context: Context): String = prefs(context).getString("gameStorage", "") ?: ""
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
index 5ae9f753c4..ef3069acbe 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt
@@ -72,6 +72,7 @@ class SessionService : Service() {
private val steamDownloadMonitor = SteamDownloadMonitor()
private var downloadMonitorTask: Runnable? = null
private var downloadActive = false
+ private var clientInstallActive = false
@Volatile private var steamLibraryMounts = emptyMap()
private var suspendDownloadNow = false
private var suspendPolicy = SessionPrefs.SUSPEND_MANUAL
@@ -99,6 +100,8 @@ class SessionService : Service() {
private var suspendOperationPending = false
private var pipTask = false
private var suspendAttemptFailed = false
+ private var freezePending = false
+ private var freezeCancelled = false
private var pendingSteamGameId: String? = null
private var pendingSteamGameGeneration = -1
// Bumped to cancel a running game-exit watch (a new launch, or the session ending).
@@ -320,12 +323,17 @@ class SessionService : Service() {
suspendDownloadNow = false
steamDownloadMonitor.reset()
downloadActive = false
+ clientInstallActive = false
steamSleepToken = null
completeNativeSleep()
suspendOperationPending = false
+ freezePending = false
suspendAttemptFailed = false
suspendController = null
SessionState.suspended = false
+ SessionState.resumeRequested = false
+ SessionState.resuming = false
+ SessionState.resumeFailed = false
SessionState.pipActive = false
pipTask = false
SessionState.program = intent?.getStringExtra(EXTRA_PROGRAM)
@@ -396,15 +404,6 @@ class SessionService : Service() {
log.useLines { lines -> lines.any { it.contains("X11 I/O error") || it.contains("Xwayland", ignoreCase = true) } }
}.getOrDefault(false)
- private fun tuDebug(linuxDriverId: String): String? {
- // Turnip's switch; a non-Adreno GPU runs another driver (PanVK, RADV, the bridge).
- if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) return null
- val override = tuDebugOverride()
- if (!override.isNullOrEmpty()) return override
- if (SessionPrefs.tuSysmem(this) || sysmemDriver(linuxDriverId)) return "sysmem"
- return null
- }
-
private fun tuDebugOverride(): String? = File(Environment.getExternalStorageDirectory(), TU_DEBUG_SWITCH)
.takeIf { it.isFile }?.let { FileUtils.readString(it)?.trim() }?.takeIf { it.isNotEmpty() }
@@ -424,7 +423,7 @@ class SessionService : Service() {
}
}
SessionTerminal.clear()
- com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice()
+ com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)
try {
LinuxRuntime.writeAccounts(this)
} catch (e: Exception) {
@@ -663,13 +662,30 @@ class SessionService : Service() {
helperRoots = { components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } },
suspendAudio = {
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")
+ if (!pulse.setMicSuspended(true)) Log.w(TAG, "could not suspend microphone source")
+ val relay = components.firstNotNullOfOrNull { it as? DirectAudioRelayComponent }
+ if (relay != null && !relay.awaitMicReleased(MIC_RELEASE_TIMEOUT_MS)) {
+ Log.w(TAG, "microphone still open after ${MIC_RELEASE_TIMEOUT_MS} ms; suspending anyway")
+ }
},
resumeAudio = {
if (!pulse.setSinkSuspended(false)) Log.w(TAG, "could not resume audio sink")
+ if (!pulse.setMicSuspended(false)) Log.w(TAG, "could not resume microphone source")
+ },
+ zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-zram"),
+ pagedOut = { processes, unacknowledged, residentKb, swapKb, swapBeforeKb, millis ->
+ Log.i(TAG, "paged out $processes processes ($unacknowledged unacknowledged) in $millis ms: " +
+ "resident ${residentKb / 1024} MB, zram ${swapBeforeKb / 1024} -> ${swapKb / 1024} MB")
+ mainHandler.post {
+ SessionEvents.record("session.paged_out", mapOf(
+ "processes" to processes, "unacknowledged" to unacknowledged, "residentMb" to residentKb / 1024,
+ "swapMb" to swapKb / 1024, "swapBeforeMb" to swapBeforeKb / 1024, "ms" to millis,
+ ))
+ }
},
)
- mainHandler.post { updateSuspendPolicy() }
updateDownloadMonitoring()
+ mainHandler.post { updateSuspendPolicy() }
}
}
@@ -701,6 +717,7 @@ class SessionService : Service() {
com.droiddeck.launcher.core.AppLanguage.system(this).country,
))
guest.add("TZ=" + java.util.TimeZone.getDefault().id)
+ if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("BL_SHADER_PRECACHE=" + if (it) "1" else "0") }
guest.add("XDG_RUNTIME_DIR=" + LinuxRuntime.GUEST_RUNTIME_DIR)
guest.add("XDG_SESSION_TYPE=wayland")
guest.add("WAYLAND_DISPLAY=wayland-0")
@@ -755,8 +772,10 @@ class SessionService : Service() {
guest.add("BL_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("BL_DRM_STANDIN=$it") }
}
- if (!venus) tuDebug(linuxDriverId)?.let { guest.add("TU_DEBUG=$it") }
- com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice()?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") }
+ val tuOverride = tuDebugOverride()
+ val tuDriver = sysmemDriver(linuxDriverId)
+ // Turnip's switch; a non-Adreno GPU runs another driver (PanVK, RADV, the bridge, Venus).
+ if (!venus && com.droiddeck.launcher.core.DeviceSupport.adreno()) (tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
if (SessionPrefs.zinkLazy(this)) {
guest.add("ZINK_DESCRIPTORS=lazy")
guest.add("ZINK_DEBUG=compact")
@@ -769,7 +788,10 @@ class SessionService : Service() {
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
SessionState.steamClientArch?.let { arch ->
guest.add("BL_STEAM_CLIENT_ARCH=$arch")
- SessionPaths.current()?.let { SessionArtifacts.recordClient(it, arch) }
+ SessionPaths.current()?.let {
+ SessionArtifacts.recordClient(it, arch)
+ SessionArtifacts.markSteamLogs(it, File(SessionPrefs.steamRoot(this, arch), "logs"))
+ }
if (arch == "x86_64") FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) }
}
if (SessionState.mode == MODE_STEAM) {
@@ -780,12 +802,13 @@ class SessionService : Service() {
guest.add("BL_SYNC_FALLBACK=" + (if (SessionPrefs.syncFallback(this)) "1" else "0"))
guest.add("BL_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
- if (SessionState.mode == MODE_STEAM && SessionPrefs.zramCompression(this) &&
- com.droiddeck.launcher.core.ZramSupport.supported()) guest.add("BL_ZRAM=1")
+ if (SessionPrefs.cursorComposite(this)) guest.add("BL_CURSOR_COMPOSITE=1")
+ if (com.droiddeck.launcher.core.ZramSupport.supported()) guest.add("BL_ZRAM=1")
guest.add("BANNER_AUDIO_DIRECT_DECAY=0")
val extra = extraEnv() + com.droiddeck.launcher.agent.AgentEnv.beginSession(this)
if (extra.none { it.startsWith("TU_DEBUG=") }) guest.add("$GAME_TU_DEBUG=" + (tuOverride ?: if (tuDriver) "sysmem" else ""))
extra.forEach { guest.add(it) }
+ com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") }
val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this)
if (clientPinned) {
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
@@ -1301,6 +1324,7 @@ class SessionService : Service() {
}
private fun resumeSession(panelVisible: Boolean = true) {
+ if (SessionState.suspended) SessionState.resumeRequested = true
if (panelVisible) activityVisible = true
screenOn = readScreenOn()
manualPauseRequested = false
@@ -1498,10 +1522,12 @@ class SessionService : Service() {
private fun updateSuspendPolicy() {
if (!SessionState.running) return
val hidden = !hasVisibleSurface
- val downloadsBlockingSuspend = steamDownloadsInBackground && SessionState.mode == MODE_STEAM &&
- suspendPolicy != SessionPrefs.SUSPEND_NEVER && hidden && downloadActive && !suspendDownloadNow
+ val downloadsBlockingSuspend = downloadsKeepAwake() && hidden && !suspendDownloadNow
if (suspendPolicy == SessionPrefs.SUSPEND_MANUAL && hidden && !downloadsBlockingSuspend) {
manualPauseRequested = true
+ } else if (!hidden && !SessionState.suspended) {
+ // Coming back before the freeze finished keeps the game running instead of pausing it a moment later.
+ manualPauseRequested = false
}
val controller = suspendController ?: return
if (downloadsBlockingSuspend) acquireLocks()
@@ -1523,6 +1549,11 @@ class SessionService : Service() {
SessionPrefs.SUSPEND_MANUAL -> manualPauseRequested && prepared && !downloadsBlockingSuspend
else -> false
}
+ if (freezePending && !shouldSuspend && !freezeCancelled) {
+ freezeCancelled = true
+ controller.cancelFreeze()
+ }
+ if (shouldSuspend && SessionState.suspended && !suspendOperationPending) SessionState.resumeRequested = false
if (suspendOperationPending || suspendAttemptFailed || shouldSuspend == SessionState.suspended) return
val gen = sessionGen
suspendOperationPending = true
@@ -1533,36 +1564,54 @@ class SessionService : Service() {
"nativeSleep" to (nativeSleepToken != null),
))
if (shouldSuspend) {
- controller.freeze { success ->
+ freezePending = true
+ freezeCancelled = false
+ val freezeSteamToken = steamSleepToken
+ val freezeNativeToken = nativeSleepToken
+ controller.freeze(
+ pageOut = steamSleepToken != null || nativeSleepToken != null || !activityVisible || !screenOn,
+ ) { success ->
mainHandler.post {
if (gen != sessionGen || !SessionState.running) return@post
suspendOperationPending = false
+ freezePending = false
if (success) {
SessionState.suspended = true
+ SessionState.resumeFailed = false
SessionEvents.transition(SessionPhase.SUSPENDED, "session.suspended")
releaseLocks()
refreshNotification()
} else {
- completeNativeSleep()
- completeSteamSleep()
- suspendAttemptFailed = true
- Log.w(TAG, "could not confirm that the session stopped")
+ if (nativeSleepToken == freezeNativeToken) completeNativeSleep()
+ if (steamSleepToken == freezeSteamToken) completeSteamSleep()
+ if (freezeCancelled) {
+ SessionEvents.record("session.suspend_cancelled")
+ } else {
+ suspendAttemptFailed = true
+ Log.w(TAG, "could not confirm that the session stopped")
+ }
}
updateSuspendPolicy()
}
}
} else {
acquireLocks()
+ SessionState.resuming = true
controller.resume { success ->
mainHandler.post {
if (gen != sessionGen || !SessionState.running) return@post
suspendOperationPending = false
+ SessionState.resuming = false
+ SessionState.resumeRequested = false
if (success) {
SessionState.suspended = false
+ SessionState.resumeFailed = false
SessionEvents.transition(SessionEvents.resumePhase(), "session.resumed")
refreshNotification()
} else {
suspendAttemptFailed = true
+ SessionState.resumeFailures++
+ SessionState.resumeFailed = true
Log.w(TAG, "could not confirm that the session resumed")
}
updateSuspendPolicy()
@@ -1658,6 +1707,9 @@ class SessionService : Service() {
return@post
}
SessionState.suspended = false
+ SessionState.resumeRequested = false
+ SessionState.resuming = false
+ SessionState.resumeFailed = false
SessionState.pipActive = false
pipTask = false
SessionState.guestPid = -1
@@ -1709,6 +1761,8 @@ class SessionService : Service() {
completeNativeSleep()
val (ended, endedArch) = synchronized(stopLock) {
if (!SessionState.running) return
+ SessionEvents.record("guest.exited", mapOf("status" to status))
+ SessionEvents.transition(SessionPhase.STOPPING, "session.stopping", mapOf("status" to status))
SessionState.running = false
SessionPaths.take() to SessionState.steamClientArch
}
@@ -1718,11 +1772,10 @@ class SessionService : Service() {
val stoppedSession = SessionState.sessionId
val launcherEnded = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP || SessionState.program == NoSteamLaunch.EPIC
SessionState.stopRequested = false
- SessionEvents.record("guest.exited", mapOf("status" to status))
GpuClockPin.stop(this)
GameThreadHints.stop()
- SessionEvents.transition(SessionPhase.STOPPING, "session.stopping", mapOf("status" to status))
suspendOperationPending = false
+ freezePending = false
launchWatcher?.stopWatching()
launchWatcher = null
syncWatcher?.stopWatching()
@@ -1891,8 +1944,7 @@ class SessionService : Service() {
.setContentText(getString(
when {
SessionState.suspended -> R.string.session_notification_paused
- downloadActive && steamDownloadsInBackground &&
- suspendPolicy != SessionPrefs.SUSPEND_NEVER -> R.string.session_notification_downloads
+ downloadsKeepAwake() -> R.string.session_notification_downloads
else -> R.string.session_notification
}
))
@@ -1900,8 +1952,7 @@ class SessionService : Service() {
.apply {
if (SessionState.suspended) {
addAction(Notification.Action.Builder(null, getString(R.string.resume_session), resume).build())
- } else if (downloadActive && steamDownloadsInBackground &&
- suspendPolicy != SessionPrefs.SUSPEND_NEVER) {
+ } else if (downloadsKeepAwake()) {
val suspend = PendingIntent.getService(
this@SessionService, 3,
Intent(this@SessionService, SessionService::class.java).setAction(ACTION_SUSPEND_NOW),
@@ -1921,33 +1972,50 @@ class SessionService : Service() {
getSystemService(NotificationManager::class.java)?.notify(NOTIFICATION_ID, buildNotification())
}
+ private fun downloadsKeepAwake(): Boolean =
+ downloadActive && (steamDownloadsInBackground || clientInstallActive) &&
+ SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER
+
+ private fun downloadWatchWanted(): Boolean =
+ SessionState.running && SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER &&
+ (steamDownloadsInBackground || !SessionState.firstFrameSeen)
+
private fun updateDownloadMonitoring() {
- val enabled = SessionState.running && SessionState.mode == MODE_STEAM &&
- steamDownloadsInBackground && suspendPolicy != SessionPrefs.SUSPEND_NEVER
- if (!enabled) {
+ if (!downloadWatchWanted()) {
val wasActive = downloadActive
downloadMonitorTask?.let(mainHandler::removeCallbacks)
downloadMonitorTask = null
steamDownloadMonitor.reset()
downloadActive = false
+ if (clientInstallActive) SessionEvents.record("steam.client_download", mapOf("active" to false))
+ clientInstallActive = false
if (wasActive) refreshNotification()
return
}
if (downloadMonitorTask != null) return
val poll = object : Runnable {
override fun run() {
- if (downloadMonitorTask !== this || !SessionState.running ||
- SessionState.mode != MODE_STEAM || !steamDownloadsInBackground ||
- suspendPolicy == SessionPrefs.SUSPEND_NEVER) {
+ if (downloadMonitorTask !== this) return
+ if (!downloadWatchWanted()) {
+ downloadMonitorTask = null
+ updateDownloadMonitoring()
+ updateSuspendPolicy()
return
}
+ val root = LinuxRuntime.rootDir(this@SessionService)
val wasActive = downloadActive
- downloadActive = steamDownloadMonitor.poll(
- LinuxRuntime.rootDir(this@SessionService),
+ val wasInstalling = clientInstallActive
+ clientInstallActive = !SessionState.firstFrameSeen &&
+ (clientInstallActive || SteamDownloadMonitor.clientInstallPending(root))
+ downloadActive = clientInstallActive || steamDownloadsInBackground && steamDownloadMonitor.poll(
+ root,
receivedBytes = TrafficStats.getUidRxBytes(android.os.Process.myUid()),
client = SessionState.steamClientArch,
mounts = steamLibraryMounts,
)
+ if (wasInstalling != clientInstallActive) {
+ SessionEvents.record("steam.client_download", mapOf("active" to clientInstallActive))
+ }
if (wasActive != downloadActive) refreshNotification()
updateSuspendPolicy()
mainHandler.postDelayed(this, DOWNLOAD_POLL_MS)
@@ -1973,6 +2041,7 @@ class SessionService : Service() {
companion object {
private const val TAG = "SessionService"
private const val TRACER_NICE = -6
+ private const val MIC_RELEASE_TIMEOUT_MS = 5_000L
private const val TU_DEBUG_SWITCH = "Download/droiddeck-tu-debug"
private const val GAME_TU_DEBUG = "DROIDDECK_GAME_TU_DEBUG"
private const val LEGACY_ENV_SWITCH = "Download/droiddeck-env"
@@ -2104,6 +2173,7 @@ class SessionService : Service() {
fun resume(context: Context) {
if (!SessionState.running) return
+ if (SessionState.suspended) SessionState.resumeRequested = true
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_RESUME))
}
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt
index cebc33caa0..5ff739e478 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.session
import java.io.File
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -46,6 +47,10 @@ object SessionState {
@Volatile
var runtimeDriver: String? = null
var suspended by mutableStateOf(false)
+ var resumeRequested by mutableStateOf(false)
+ var resuming by mutableStateOf(false)
+ var resumeFailures by mutableIntStateOf(0)
+ var resumeFailed by mutableStateOf(false)
@Volatile var pipActive = false
@Volatile
var program: String? = null
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionSuspendController.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionSuspendController.kt
index d694d67862..5d0e32f990 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SessionSuspendController.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SessionSuspendController.kt
@@ -18,6 +18,9 @@ internal class SessionSuspendController(
private val sleep: (Long) -> Unit = Thread::sleep,
private val nowMillis: () -> Long = { System.nanoTime() / 1_000_000 },
private val executor: ExecutorService = Executors.newSingleThreadExecutor(),
+ private val zramControl: File? = null,
+ private val pagedOut: (processes: Int, unacknowledged: Int, residentKb: Long, swapKb: Long, swapBeforeKb: Long, millis: Long) -> Unit =
+ { _, _, _, _, _, _ -> },
) {
private enum class Role { SESSION_ROOT, SESSION_CHILD, HELPER_ROOT, HELPER_CHILD }
@@ -38,9 +41,11 @@ internal class SessionSuspendController(
private data class TaskIdentity(val process: ProcessRecord, val tid: Int, val started: Long)
@Volatile private var closing = false
+ @Volatile private var cancelled = false
private var frozen = emptyList()
- fun freeze(completion: (Boolean) -> Unit) {
+ fun freeze(pageOut: Boolean = false, completion: (Boolean) -> Unit) {
+ cancelled = false
submit({
val records = frozen.associateByTo(LinkedHashMap()) { it.pid to it.started }
var complete = false
@@ -59,17 +64,18 @@ internal class SessionSuspendController(
records[it.pid to it.started] = ProcessRecord(it.pid, it.started, Role.HELPER_ROOT)
}
}
+ if (pageOut) pageOut(records, root.pid, helpers)
val deadline = nowMillis() + FREEZE_TIMEOUT_MS
var previous: Map? = null
for (pass in 0 until FREEZE_MAX_PASSES) {
- if (closing || nowMillis() >= deadline) break
+ if (closing || cancelled || nowMillis() >= deadline) break
try {
if (readProcess(root.pid)?.started != root.started) break
addSnapshot(records, root.pid, helpers)
if (readProcess(root.pid)?.started != root.started) break
stop(records.values.toList())
sleep(if (pass == 0) 70L else 35L)
- if (closing || nowMillis() >= deadline) break
+ if (closing || cancelled || nowMillis() >= deadline) break
val current = stoppedSnapshot(records.values.toList(), root)
if (current != null && current == previous) {
complete = true
@@ -97,6 +103,11 @@ internal class SessionSuspendController(
}, { completion(false) })
}
+ // A freeze still queued or paging out stops before its next SIGSTOP pass and rolls back.
+ fun cancelFreeze() {
+ cancelled = true
+ }
+
fun resume(completion: (Boolean) -> Unit) {
submit({
val records = frozen
@@ -233,6 +244,65 @@ internal class SessionSuspendController(
return tasks.takeIf { stopped && it.isNotEmpty() }
}
+ // A stopped process cannot run libblsession's SIGURG handler, so the page-out has to finish
+ // before the stop. Android's low-memory killer otherwise finds the frozen game resident in RAM
+ // with most of zram still free.
+ private fun pageOut(records: MutableMap, ProcessRecord>, root: Int, helpers: List) {
+ val control = zramControl?.takeIf { it.isFile } ?: return
+ try {
+ addSnapshot(records, root, helpers)
+ control.writeText("1")
+ } catch (_: IOException) {
+ return
+ }
+ val targets = records.values.filter { record ->
+ try {
+ File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libblsession.so") } }
+ } catch (_: IOException) {
+ false
+ }
+ }
+ if (targets.isEmpty()) return
+ val acks = targets.associateWith { File(control.parentFile, "${control.name}.ack.${it.pid}") }
+ acks.values.forEach { it.delete() }
+ val start = nowMillis()
+ val before = memoryKb(targets)
+ for (record in targets) send(record, SIGURG)
+ // A program can replace libblsession's SIGURG handler (PyInstaller's bootloader, the Go runtime);
+ // such a process never creates its ack and is not waited for once the start window has passed.
+ val waiting = targets.toMutableList()
+ while (!closing && !cancelled && nowMillis() - start < PAGE_OUT_TIMEOUT_MS) {
+ val started = nowMillis() - start >= PAGE_OUT_START_MS
+ waiting.removeAll { val ack = acks.getValue(it); ack.length() > 0 || (started && !ack.exists()) || isGone(it) }
+ if (waiting.isEmpty()) break
+ sleep(PAGE_OUT_POLL_MS)
+ }
+ val unacknowledged = targets.count { acks.getValue(it).length() == 0L && !isGone(it) }
+ acks.values.forEach { it.delete() }
+ val after = memoryKb(targets)
+ pagedOut(targets.size, unacknowledged, after.first, after.second, before.second, nowMillis() - start)
+ }
+
+ private fun isGone(record: ProcessRecord): Boolean =
+ try { readProcess(record.pid)?.started != record.started } catch (_: Exception) { false }
+
+ private fun memoryKb(records: List): Pair {
+ var resident = 0L
+ var swap = 0L
+ for (record in records) {
+ try {
+ File(procRoot, "${record.pid}/status").useLines { lines ->
+ for (line in lines) {
+ val kb = line.substringAfter(':').trim().substringBefore(' ').toLongOrNull() ?: continue
+ if (line.startsWith("VmRSS:")) resident += kb else if (line.startsWith("VmSwap:")) swap += kb
+ }
+ }
+ } catch (_: IOException) {
+ }
+ }
+ return resident to swap
+ }
+
// PRoot traces every guest. A stop sent while it runs becomes a group stop that it restarts
// thread by thread; once it is stopped, each thread that takes a SIGSTOP stays parked in its
// signal-delivery stop. So the roots stop first and every guest thread gets its own SIGSTOP.
@@ -310,6 +380,10 @@ internal class SessionSuspendController(
private companion object {
const val SIGSTOP = 19
const val SIGCONT = 18
+ const val SIGURG = 23
+ const val PAGE_OUT_POLL_MS = 100L
+ const val PAGE_OUT_START_MS = 2_000L
+ const val PAGE_OUT_TIMEOUT_MS = 12_000L
const val RESTORE_CHECKS = 80
const val FREEZE_TIMEOUT_MS = 8_000L
const val FREEZE_MAX_PASSES = 256
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt
index 0c430c1c5e..27bc081b0d 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt
@@ -20,7 +20,7 @@ object SettingsReset {
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime",
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
- "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath",
+ "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "cursorComposite",
"guestHostname", "fexPreset", "forceSsbs", "logs", "storageDiagnostics",
"upscaler", "upscaleSharpness", "screenEffects", "textureAnisotropy", "textureLodBias",
"steamDownloadsInBackground", "steam_offline", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds",
diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt
index 37f7c1fb90..ff3602c1bd 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt
@@ -1,7 +1,7 @@
package com.droiddeck.launcher.session
import java.io.File
-import java.io.RandomAccessFile
+import java.io.FileInputStream
internal class SteamDownloadMonitor {
private data class ManifestState(
@@ -63,16 +63,17 @@ internal class SteamDownloadMonitor {
lastContentActivityAt = 0L
}
runCatching {
- RandomAccessFile(log, "r").use { input ->
- input.seek(contentLogOffset)
+ FileInputStream(log).use { input ->
+ input.channel.position(contentLogOffset)
+ val reader = input.bufferedReader(Charsets.ISO_8859_1)
while (true) {
- val line = input.readLine() ?: break
+ val line = reader.readLine() ?: break
when {
"Client version:" in line -> {
activeContentUpdates.clear()
lastContentActivityAt = 0L
}
- CONTENT_UPDATE.find(line)?.let { match ->
+ " update changed : " in line && CONTENT_UPDATE.find(line)?.let { match ->
val appId = match.groupValues[1]
val updateType = match.groupValues[2]
val state = match.groupValues[3]
@@ -85,14 +86,15 @@ internal class SteamDownloadMonitor {
}
true
} == true -> Unit
- CURRENT_RATE.find(line)?.groupValues?.get(1)?.toDoubleOrNull()?.let { it > 0.0 } == true ->
+ "Current download rate: " in line &&
+ CURRENT_RATE.find(line)?.groupValues?.get(1)?.toDoubleOrNull()?.let { it > 0.0 } == true ->
lastContentActivityAt = now
"Downloading " in line && " chunks for depot " in line ->
lastContentActivityAt = now
}
if (activeContentUpdates.isNotEmpty()) lastContentActivityAt = now
}
- contentLogOffset = input.filePointer
+ contentLogOffset = input.channel.position()
}
}
return activeContentUpdates.isNotEmpty() && lastContentActivityAt > 0L &&
@@ -138,13 +140,21 @@ internal class SteamDownloadMonitor {
private fun value(text: String, key: String): String? =
Regex("\"$key\"\\s+\"([^\"]*)\"").find(text)?.groupValues?.get(1)
- private companion object {
- const val MANIFEST_PROGRESS_GRACE_MS = 8_000L
- const val CONTENT_ACTIVITY_GRACE_MS = 90_000L
- const val MIN_RECEIVE_BYTES_PER_SEC = 64L * 1024L
- val PATH = Regex("\"path\"\\s+\"([^\"]+)\"")
- val STEAM_HOMES = listOf("root/.local/share/Steam", "root/.droiddeck-x64/.local/share/Steam")
- val CONTENT_UPDATE = Regex("""AppID (\d+) (App|Workshop|Shader) update changed : (.*)""")
- val CURRENT_RATE = Regex("""Current download rate: ([\d.]+) Mbps""")
+ companion object {
+ fun clientInstallPending(runtimeRoot: File): Boolean {
+ val home = File(runtimeRoot, "root")
+ val steam = File(home, ".local/share/Steam")
+ val stamped = File(steam, "package/droiddeck-installed").isFile ||
+ File(steam, "package/bannerlator-installed").isFile
+ return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".bl-steam-repair").exists()
+ }
+
+ private const val MANIFEST_PROGRESS_GRACE_MS = 8_000L
+ private const val CONTENT_ACTIVITY_GRACE_MS = 90_000L
+ private const val MIN_RECEIVE_BYTES_PER_SEC = 64L * 1024L
+ private val PATH = Regex("\"path\"\\s+\"([^\"]+)\"")
+ private val STEAM_HOMES = listOf("root/.local/share/Steam", "root/.droiddeck-x64/.local/share/Steam")
+ private val CONTENT_UPDATE = Regex("""AppID (\d+) (App|Workshop|Shader) update changed : (.*)""")
+ private val CURRENT_RATE = Regex("""Current download rate: ([\d.]+) Mbps""")
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt
index 2c5a1aa0d1..4b355caa40 100644
--- a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt
+++ b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt
@@ -101,10 +101,28 @@ object WinComponents {
fun cached(context: Context): List? =
runCatching { parse(File(context.filesDir, CATALOG_CACHE).readText()) }.getOrNull()
+ const val VCREDIST_ARM64 = "vcredist2022_arm64"
+
+ /**
+ * The ARM64 Visual C++ 2015-2022 runtime as registry values only (the version a 14.44.35211 installer writes, in both
+ * registry views). Xbox games' launchers running as ARM64EC check for it; Wine's own CRT does the work. Same approach as
+ * MGamer404's Bannerlator #627. Used until the catalog carries a component of this name.
+ */
+ internal fun builtInArm64Runtime(): Component {
+ fun value(view: String, name: String, type: String, data: String) = Step("set_register_key", JSONObject()
+ .put("action", "set_register_key").put("key", "HKLM\\Software\\${view}Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\arm64")
+ .put("value", name).put("type", type).put("data", data))
+ val steps = listOf("", "Wow6432Node\\").flatMap { view ->
+ listOf(value(view, "Installed", "REG_DWORD", "1"), value(view, "Major", "REG_DWORD", "14"), value(view, "Minor", "REG_DWORD", "44"),
+ value(view, "Bld", "REG_DWORD", "35211"), value(view, "Rbld", "REG_DWORD", "0"), value(view, "Version", "REG_SZ", "v14.44.35211.00"))
+ }
+ return Component(VCREDIST_ARM64, "Microsoft Visual C++ 2015-2022 ARM64 runtime 14.44.35211 (registry entries only)", "Microsoft", "ready", emptyList(), steps)
+ }
+
private fun parse(body: String): List? {
return try {
val arr = JSONObject(body).getJSONArray("components")
- (0 until arr.length()).mapNotNull { i ->
+ val listed = (0 until arr.length()).mapNotNull { i ->
val o = arr.getJSONObject(i)
val name = o.optString("name")
if (!validId(name)) return@mapNotNull null
@@ -117,6 +135,7 @@ object WinComponents {
o.optString("snapshot"),
)
}
+ if (listed.any { it.name == VCREDIST_ARM64 }) listed else listed + builtInArm64Runtime()
} catch (e: Exception) {
Log.w(TAG, "catalog: $e"); null
}
diff --git a/app/src/main/java/com/droiddeck/launcher/storage/SteamStorage.kt b/app/src/main/java/com/droiddeck/launcher/storage/SteamStorage.kt
index e707fd59fc..9697addd64 100644
--- a/app/src/main/java/com/droiddeck/launcher/storage/SteamStorage.kt
+++ b/app/src/main/java/com/droiddeck/launcher/storage/SteamStorage.kt
@@ -28,6 +28,8 @@ object SteamStorage {
private val LAST_PLAYED = Regex("^\\s*\"LastPlayed\"\\s*\"(\\d+)\"", RegexOption.MULTILINE)
private val MAPPING = Regex("\"(\\d+)\"\\s*\\{\\s*\"name\"\\s*\"([^\"]*)\"")
private val COMPAT_NAME = Regex("\"compat_tools\"\\s*\\{\\s*\"([^\"]+)\"")
+ private val VDF_TOKEN = Regex("\"((?:\\\\.|[^\"\\\\])*)\"|[{}]|//[^\n]*")
+ private val SHADER_CACHE_OFF = listOf("InstallConfigStore", "Software", "Valve", "Steam", "ShaderCacheManager", "DisableShaderCache")
data class Manifest(
val file: File, val appId: Int, val name: String, val installDir: String?,
@@ -118,6 +120,28 @@ object SteamStorage {
return MAPPING.findAll(configVdf.substring(open, end)).associate { it.groupValues[1] to it.groupValues[2] }
}
+ fun shaderPrecache(configVdf: String): Boolean = vdfValue(configVdf, SHADER_CACHE_OFF) != "1"
+
+ private fun vdfValue(text: String, path: List): String? {
+ val blocks = ArrayList()
+ var key: String? = null
+ for (token in VDF_TOKEN.findAll(text)) {
+ val name = key
+ when {
+ token.value.startsWith("//") -> {}
+ token.value == "{" -> { blocks.add(name.orEmpty()); key = null }
+ token.value == "}" -> { blocks.removeLastOrNull(); key = null }
+ name == null -> key = token.groupValues[1]
+ else -> {
+ val at = blocks + name
+ if (at.size == path.size && at.zip(path).all { (a, b) -> a.equals(b, ignoreCase = true) }) return token.groupValues[1]
+ key = null
+ }
+ }
+ }
+ return null
+ }
+
fun compatToolName(compatibilityToolVdf: String): String? = COMPAT_NAME.find(compatibilityToolVdf)?.groupValues?.get(1)
private val ARM_IN_NAME = Regex("arm64|aarch64")
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/CredentialCipher.kt b/app/src/main/java/com/droiddeck/launcher/stores/CredentialCipher.kt
index aa07484231..01c7eebcf4 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/CredentialCipher.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/CredentialCipher.kt
@@ -1,6 +1,5 @@
package com.droiddeck.launcher.stores
-import android.os.Build
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.util.Base64
@@ -13,6 +12,8 @@ import javax.crypto.spec.GCMParameterSpec
object CredentialCipher {
const val VERSION = 1
+ /** Sealed with the hardware-keystore (TEE) key; [VERSION] envelopes keep opening with the older, possibly StrongBox, key. */
+ const val VERSION_TEE = 2
const val ALG = "AES/GCM"
private const val TRANSFORMATION = "AES/GCM/NoPadding"
private const val TAG_BITS = 128
@@ -21,6 +22,11 @@ object CredentialCipher {
fun key(): SecretKey
fun existing(): SecretKey = key()
+
+ /** Key for [VERSION] envelopes written before [VERSION_TEE]. */
+ fun legacy(): SecretKey = existing()
+
+ val version: Int get() = VERSION
}
class KeyMissing : java.security.GeneralSecurityException("no key")
@@ -29,33 +35,33 @@ object CredentialCipher {
e is android.security.keystore.KeyPermanentlyInvalidatedException ||
e is KeyMissing || e is org.json.JSONException || e is IllegalArgumentException
+ // StrongBox took over 10 s per Xbox credential write on a tester's phone, past the backend's
+ // 10 s reply timeout, so new writes use a TEE key. The old alias stays readable.
object Keystore : KeyProvider {
- private const val ALIAS = "droiddeck-store-credentials"
+ private const val LEGACY_ALIAS = "droiddeck-store-credentials"
+ private const val ALIAS = "droiddeck-store-credentials-tee"
private const val PROVIDER = "AndroidKeyStore"
- @Synchronized
- override fun existing(): SecretKey {
- val ks = KeyStore.getInstance(PROVIDER).apply { load(null) }
- return ks.getKey(ALIAS, null) as? SecretKey ?: throw KeyMissing()
- }
+ override val version: Int get() = VERSION_TEE
@Synchronized
- override fun key(): SecretKey {
- val ks = KeyStore.getInstance(PROVIDER).apply { load(null) }
- (ks.getKey(ALIAS, null) as? SecretKey)?.let { return it }
- if (Build.VERSION.SDK_INT >= 28) {
- try { return generate(strongBox = true) } catch (e: Exception) { }
- }
- return generate(strongBox = false)
- }
+ override fun existing(): SecretKey = stored(ALIAS) ?: throw KeyMissing()
- private fun generate(strongBox: Boolean): SecretKey {
+ @Synchronized
+ override fun legacy(): SecretKey = stored(LEGACY_ALIAS) ?: throw KeyMissing()
+
+ @Synchronized
+ override fun key(): SecretKey = stored(ALIAS) ?: generate()
+
+ private fun stored(alias: String): SecretKey? =
+ KeyStore.getInstance(PROVIDER).apply { load(null) }.getKey(alias, null) as? SecretKey
+
+ private fun generate(): SecretKey {
val spec = KeyGenParameterSpec.Builder(ALIAS, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setKeySize(256)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.setUserAuthenticationRequired(false)
- .apply { if (strongBox && Build.VERSION.SDK_INT >= 28) setIsStrongBoxBacked(true) }
.build()
return KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, PROVIDER).run { init(spec); generateKey() }
}
@@ -64,15 +70,16 @@ object CredentialCipher {
fun seal(plain: String, keys: KeyProvider): JSONObject {
val cipher = Cipher.getInstance(TRANSFORMATION).apply { init(Cipher.ENCRYPT_MODE, keys.key()) }
val ct = cipher.doFinal(plain.toByteArray(Charsets.UTF_8))
- return JSONObject().put("v", VERSION).put("alg", ALG)
+ return JSONObject().put("v", keys.version).put("alg", ALG)
.put("iv", b64(cipher.iv)).put("ct", b64(ct))
}
fun open(envelope: JSONObject, keys: KeyProvider): String {
- require(envelope.optInt("v", -1) == VERSION && envelope.optString("alg") == ALG) { "unknown envelope" }
+ val version = envelope.optInt("v", -1)
+ require((version == VERSION || version == VERSION_TEE) && envelope.optString("alg") == ALG) { "unknown envelope" }
val iv = Base64.decode(envelope.getString("iv"), Base64.NO_WRAP)
val ct = Base64.decode(envelope.getString("ct"), Base64.NO_WRAP)
- val cipher = Cipher.getInstance(TRANSFORMATION).apply { init(Cipher.DECRYPT_MODE, keys.existing(), GCMParameterSpec(TAG_BITS, iv)) }
+ val cipher = Cipher.getInstance(TRANSFORMATION).apply { init(Cipher.DECRYPT_MODE, if (version == VERSION) keys.legacy() else keys.existing(), GCMParameterSpec(TAG_BITS, iv)) }
return String(cipher.doFinal(ct), Charsets.UTF_8)
}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt
index 27bf133f18..a740eb088e 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt
@@ -94,6 +94,20 @@ object StoreAccounts {
return json.optString("display_name", "").ifEmpty { json.optString("username", "") }.ifEmpty { store.label }
}
+ /** The name the Stores page shows. Xbox shows the gamertag, else the sign-in email with its name part masked. */
+ fun displayName(context: Context, store: Store): String? {
+ if (store != Store.XBOX) return signedInAs(context, store)
+ val json = read(context, store) ?: return if (isUnavailable(store)) store.label else null
+ val signedIn = json.optString("username").takeIf { it.isNotBlank() } ?: return null
+ json.optString("gamertag").takeIf { it.isNotBlank() }?.let { return it }
+ return maskEmail(signedIn)
+ }
+
+ internal fun maskEmail(name: String): String {
+ val at = name.indexOf('@')
+ return if (at <= 0) name.take(1) + "•••" else name.take(1) + "•••" + name.substring(at)
+ }
+
private fun seal(f: File, json: JSONObject, retry: Boolean = false): File? {
if (keystoreFailed && !retry) return null
val text = json.toString()
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt
index 4b2b0b8039..14415fd9c6 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt
@@ -14,13 +14,45 @@ object StoreArt {
fun fetchInto(folder: File, sidecar: StoreGameSidecar) {
sidecar.cover?.let { place(it, File(folder, "cover.jpg")) }
- val wide = sidecar.hero ?: return
- if (place(wide, File(folder, "hero.jpg"))) {
- val header = File(folder, "header.jpg")
- if (!header.isFile) runCatching { File(folder, "hero.jpg").copyTo(header, overwrite = true) }
+ sidecar.hero?.let { wide ->
+ if (place(wide, File(folder, "hero.jpg"))) {
+ val header = File(folder, "header.jpg")
+ if (!header.isFile) runCatching { File(folder, "hero.jpg").copyTo(header, overwrite = true) }
+ }
+ }
+ sidecar.logo?.let { fetchLogo(folder, it) }
+ }
+
+ fun fetchLogo(folder: File, url: String): Boolean {
+ val dst = File(folder, LOGO)
+ if (dst.isFile && dst.length() > 0) return true
+ return writeLogo(get(url) ?: return false, dst)
+ }
+
+ /** A logo is drawn over the hero, so it stays a PNG with its transparency instead of going through [place]. */
+ internal fun writeLogo(bytes: ByteArray, dst: File): Boolean {
+ if (dst.isFile && dst.length() > 0) return true
+ val bitmap = runCatching { BitmapFactory.decodeByteArray(bytes, 0, bytes.size) }.getOrNull() ?: return false
+ val tmp = File(dst.path + ".tmp")
+ return try {
+ if (bitmap.width <= 0 || bitmap.height <= 0) return false
+ if (isPng(bytes)) tmp.writeBytes(bytes) else tmp.outputStream().use { bitmap.compress(Bitmap.CompressFormat.PNG, 100, it) }
+ tmp.renameTo(dst)
+ } catch (e: Exception) {
+ Log.w(TAG, "${dst.name}: ${e.javaClass.simpleName}")
+ false
+ } finally {
+ tmp.delete()
+ bitmap.recycle()
}
}
+ private val PNG_MAGIC = byteArrayOf(0x89.toByte(), 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A)
+
+ private fun isPng(bytes: ByteArray): Boolean = bytes.size > PNG_MAGIC.size && PNG_MAGIC.indices.all { bytes[it] == PNG_MAGIC[it] }
+
+ const val LOGO = "logo.png"
+
private fun place(url: String, dst: File): Boolean {
if (dst.isFile && dst.length() > 0) return true
val bytes = get(url) ?: return false
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreCatalog.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreCatalog.kt
index debaf4ad04..cfb0ed53de 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreCatalog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreCatalog.kt
@@ -23,6 +23,7 @@ data class CatalogItem(
val mature: Boolean = false,
val subscription: Boolean = false,
val includedWith: String = "",
+ val logoUrl: String? = null,
) {
val accessible: Boolean get() = owned || subscription
/** Licensed now, or a supported package the account's subscription can install. */
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt
index 25850f7479..aa42aa75e8 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt
@@ -22,6 +22,7 @@ class StoreGameSidecar(
val epic: EpicOptions = EpicOptions(),
val cloud: Boolean = true,
val achievements: Boolean = true,
+ val logo: String? = null,
) {
val isInstalled: Boolean get() = state == STATE_INSTALLED
@@ -33,7 +34,8 @@ class StoreGameSidecar(
env: Map = this.env, installVersion: String = this.installVersion,
installedAt: Long = this.installedAt, cover: String? = this.cover, hero: String? = this.hero,
extra: Map = this.extra, state: String = this.state, epic: EpicOptions = this.epic, cloud: Boolean = this.cloud, achievements: Boolean = this.achievements,
- ) = StoreGameSidecar(store, id, title, exe, launcher, args, env, installVersion, installedAt, cover, hero, extra, state, epic, cloud, achievements)
+ logo: String? = this.logo,
+ ) = StoreGameSidecar(store, id, title, exe, launcher, args, env, installVersion, installedAt, cover, hero, extra, state, epic, cloud, achievements, logo)
fun toJson(): JSONObject = JSONObject().apply {
put("version", VERSION)
@@ -52,6 +54,7 @@ class StoreGameSidecar(
if (installedAt > 0L) put("installedAt", installedAt)
if (!cover.isNullOrEmpty()) put("cover", cover)
if (!hero.isNullOrEmpty()) put("hero", hero)
+ if (!logo.isNullOrEmpty()) put("logo", logo)
if (extra.isNotEmpty()) put("extra", JSONObject(extra as Map<*, *>))
}
@@ -129,6 +132,7 @@ class StoreGameSidecar(
epic = o.optJSONObject("epic")?.let { e -> EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false)) } ?: EpicOptions(),
cloud = o.optBoolean("cloud", true),
achievements = o.optBoolean("achievements", true),
+ logo = o.optString("logo", "").ifEmpty { null },
)
}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt
index 611b7f3dba..91a0f96f5b 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt
@@ -104,6 +104,29 @@ object StoreInstallRoot {
.map { it to guestFor(context, it) }
}
+ /** Xodus has its own PRoot mount table and cannot see the selected Steam library's SD bind. */
+ fun externalRootsForXodus(context: Context): List> {
+ val roots = externalRoots(context).toMutableList()
+ val selectedLibrary = GameStorage.effective(context)?.let { File(it.path, ON_VOLUME) }
+ ?.takeUnless { isInternal(context, it) }
+ if (selectedLibrary != null && roots.none { it.first.absolutePath == selectedLibrary.absolutePath }) {
+ roots += selectedLibrary to guestFor(context, selectedLibrary)
+ }
+ return roots
+ }
+
+ fun externalBindSpecs(context: Context): List = externalBindSpecs(externalRoots(context), LinuxRuntime.rootDir(context))
+
+ fun externalBindSpecsForXodus(context: Context): List =
+ externalBindSpecs(externalRootsForXodus(context), LinuxRuntime.rootDir(context))
+
+ internal fun externalBindSpecs(roots: List>, guestRoot: File): List =
+ roots.mapNotNull { (host, guest) ->
+ if (!host.isDirectory || !host.canRead()) return@mapNotNull null
+ val target = File(guestRoot, guest.removePrefix("/"))
+ if (target.isDirectory || target.mkdirs()) "${host.path}:$guest" else null
+ }
+
private fun guestFor(context: Context, root: File): String {
val sm = context.getSystemService(StorageManager::class.java)
val uuid = runCatching { sm?.getStorageVolume(root)?.uuid }.getOrNull()?.takeIf { it.isNotBlank() }?.replace(Regex("[^A-Za-z0-9-]"), "")
@@ -114,11 +137,21 @@ object StoreInstallRoot {
fun isInternal(context: Context, root: File): Boolean = root.absolutePath == internalRoot(context).absolutePath
fun externalGuestPath(context: Context, host: File): String? {
+ return externalGuestPath(host, externalRoots(context))
+ }
+
+ fun guestPath(context: Context, host: File): String = externalGuestPath(context, host) ?: host.path
+
+ fun guestPathForXodus(context: Context, host: File): String =
+ externalGuestPath(host, externalRootsForXodus(context)) ?: host.path
+
+ internal fun externalGuestPath(host: File, roots: List>): String? {
val path = host.absolutePath
- for ((root, guest) in externalRoots(context)) {
- val dir = root.absolutePath
+ for ((root, guest) in roots.sortedByDescending { it.first.absolutePath.length }) {
+ val dir = root.absolutePath.trimEnd(File.separatorChar)
if (path == dir) return guest
- if (path.startsWith("$dir/")) return guest + "/" + path.removePrefix("$dir/")
+ val prefix = dir + File.separator
+ if (path.startsWith(prefix)) return guest + "/" + path.removePrefix(prefix).replace(File.separatorChar, '/')
}
return null
}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt
index 9b3f7136d6..65fdf6e921 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt
@@ -40,7 +40,7 @@ object StoreInstalls {
val app = context.applicationContext
onStep?.invoke(0, STEPS)
val before = StoreGameSidecar.read(folder)
- val finished = StoreLaunch.writeLauncher(folder, sidecar.copy(state = StoreGameSidecar.STATE_INSTALLED, epic = before?.epic ?: sidecar.epic, cloud = before?.cloud ?: sidecar.cloud, achievements = before?.achievements ?: sidecar.achievements))
+ val finished = StoreLaunch.writeLauncher(folder, sidecar.copy(state = StoreGameSidecar.STATE_INSTALLED, epic = before?.epic ?: sidecar.epic, cloud = before?.cloud ?: sidecar.cloud, achievements = before?.achievements ?: sidecar.achievements, logo = sidecar.logo ?: before?.logo))
finished.write(folder)
if (StoreGameSidecar.read(folder)?.isInstalled != true) throw java.io.IOException("the install record could not be written in ${folder.name}")
onStep?.invoke(1, STEPS)
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLogFiles.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLogFiles.kt
index 0af6590120..bd94cfc3bc 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLogFiles.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLogFiles.kt
@@ -24,6 +24,11 @@ object StoreLogFiles {
Thread({ android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); r.run() }, "store-log-flush").apply { isDaemon = true }
}
+ private val CLOCK = SimpleDateFormat("HH:mm:ss.SSS", Locale.US)
+
+ /** Appends [text] with a time stamp. Works in any of the app's processes. */
+ fun stamped(context: Context, text: String) = append(context, "${synchronized(CLOCK) { CLOCK.format(Date()) }} $text")
+
fun append(context: Context, line: String) {
val app = context.applicationContext
pending.add(line)
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt
index e780733d97..cf7fc2dfa6 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt
@@ -10,9 +10,6 @@ import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.stores.download.DownloadEntry
-import java.text.SimpleDateFormat
-import java.util.Date
-import java.util.Locale
object StoresState {
private const val TAG = "Stores"
@@ -79,7 +76,7 @@ object StoresState {
val app = context.applicationContext
com.droiddeck.launcher.stores.download.SavedQueue.restore(app)
background("stores-refresh") {
- val found = Store.entries.mapNotNull { store -> StoreAccounts.signedInAs(app, store)?.let { store to it } }
+ val found = Store.entries.mapNotNull { store -> StoreAccounts.displayName(app, store)?.let { store to it } }
val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder ->
StoreGameSidecar.read(folder)?.takeIf { it.isInstalled }?.let { InstalledStoreGame(it, folder) }
}
@@ -129,7 +126,9 @@ object StoresState {
fun installedGame(store: Store, id: String): InstalledStoreGame? = installed.firstOrNull { it.sidecar.store == store && it.sidecar.id == id }
fun detailItem(store: Store, id: String): CatalogItem? = detailCatalogItem(
- store, id, library[store].orEmpty(), found[store].orEmpty(), shelves[store],
+ store, id, library[store].orEmpty(),
+ found[store].orEmpty() + if (store == Store.ITCH) com.droiddeck.launcher.stores.itch.ItchBrowseState.items else emptyList(),
+ shelves[store],
)
fun open(context: Context, store: Store, force: Boolean = false) {
@@ -185,6 +184,8 @@ object StoresState {
}
var openDownloads by mutableStateOf(false)
+ /** A "store:id" key another page asks the Stores page to open. */
+ var openGameRequest by mutableStateOf(null)
private fun askForNotifications(context: Context) {
val activity = context as? android.app.Activity ?: return
@@ -262,7 +263,7 @@ object StoresState {
val text = StoreLog.redactLine(raw)
Log.i(TAG, text)
val app = appContext ?: return
- StoreLogFiles.append(app, "${synchronized(CLOCK) { CLOCK.format(Date()) }} $text")
+ StoreLogFiles.stamped(app, text)
}
private var appContext: Context? = null
@@ -295,8 +296,6 @@ object StoresState {
}
}, name).start()
}
-
- private val CLOCK = SimpleDateFormat("HH:mm:ss.SSS", Locale.US)
}
interface StoreBackend {
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonInstaller.kt
index 7eff5fbbe9..401f621ede 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonInstaller.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonInstaller.kt
@@ -124,6 +124,7 @@ internal class AmazonInstaller(
installVersion = versionId, installedAt = System.currentTimeMillis(),
cover = cover, hero = item.imageUrl,
extra = mapOf("entitlementId" to entitlementId, "sku" to sku),
+ logo = item.logoUrl,
)
StoreInstalls.complete(app, folder, sidecar, onStep = { done, steps -> handle.stageProgress(done.toLong(), steps.toLong()) })
return folder.path
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonLibrary.kt
index 841fe9217a..41f049979b 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonLibrary.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonLibrary.kt
@@ -24,6 +24,7 @@ data class AmazonGame(
val publisher: String = "",
val productSku: String = "",
val versionId: String = "",
+ val logoUrl: String = "",
)
object AmazonLibrary {
@@ -42,7 +43,8 @@ object AmazonLibrary {
JSONObject()
.put("productId", g.productId).put("entitlementId", g.entitlementId).put("title", g.title)
.put("artUrl", g.artUrl).put("heroUrl", g.heroUrl).put("developer", g.developer)
- .put("publisher", g.publisher).put("productSku", g.productSku).put("versionId", g.versionId),
+ .put("publisher", g.publisher).put("productSku", g.productSku).put("versionId", g.versionId)
+ .apply { if (g.logoUrl.isNotEmpty()) put("logoUrl", g.logoUrl) },
)
}.toString()
@@ -60,6 +62,7 @@ object AmazonLibrary {
publisher = o.optString("publisher", ""),
productSku = o.optString("productSku", ""),
versionId = o.optString("versionId", ""),
+ logoUrl = o.optString("logoUrl", ""),
)
}
return tidy(games)
@@ -94,6 +97,7 @@ object AmazonLibrary {
sizeBytes = prefs.getLong("size_${game.productId}", 0L).takeIf { it > 0 } ?: 0L,
storeUrl = STORE_URL,
extra = mapOf("entitlementId" to game.entitlementId, "sku" to game.productSku, "version" to ""),
+ logoUrl = game.logoUrl.ifEmpty { null },
)
}
@@ -106,7 +110,7 @@ object AmazonLibrary {
}
}
- private fun gameFrom(o: JSONObject, before: AmazonGame?): AmazonGame = AmazonGame(
+ internal fun gameFrom(o: JSONObject, before: AmazonGame?): AmazonGame = AmazonGame(
productId = o.optString("productId"),
entitlementId = o.optString("entitlementId"),
title = o.optString("title"),
@@ -116,6 +120,7 @@ object AmazonLibrary {
publisher = o.optString("publisher"),
productSku = o.optString("sku"),
versionId = before?.versionId.orEmpty(),
+ logoUrl = o.optString("logo").ifEmpty { before?.logoUrl.orEmpty() },
)
private fun backfillPosters(app: Context, games: List) {
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/SavedQueue.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/SavedQueue.kt
index 5a5eae4fa0..a9a25759e1 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/download/SavedQueue.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/download/SavedQueue.kt
@@ -77,6 +77,7 @@ object SavedQueue {
private fun itemJson(i: CatalogItem) = JSONObject().apply {
put("store", i.store.id); put("id", i.id); put("title", i.title)
put("image", i.imageUrl ?: ""); put("tall", i.tallImageUrl ?: "")
+ i.logoUrl?.let { put("logo", it) }
put("tags", i.tags); put("developer", i.developer); put("description", i.description)
put("size", i.sizeBytes); put("owned", i.owned); put("subscription", i.subscription)
put("extra", JSONObject(i.extra))
@@ -91,6 +92,7 @@ object SavedQueue {
tags = o.optString("tags"), developer = o.optString("developer"), description = o.optString("description"),
owned = o.optBoolean("owned", true), subscription = o.optBoolean("subscription"), sizeBytes = o.optLong("size"),
extra = extra?.keys()?.asSequence()?.associateWith { extra.getString(it) } ?: emptyMap(),
+ logoUrl = o.optString("logo").ifEmpty { null },
)
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt
index a32bceeb69..1f80eecf55 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt
@@ -15,7 +15,7 @@ import android.os.IBinder
import android.os.Looper
import android.os.PowerManager
import android.util.Log
-import com.droiddeck.launcher.MainActivity
+import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
import com.droiddeck.launcher.core.DeviceSupport
import com.droiddeck.launcher.stores.StoresState
@@ -189,7 +189,7 @@ class StoreDownloadService : Service() {
}
private fun openPage(context: Context, nav: String, code: Int): PendingIntent =
- PendingIntent.getActivity(context, code, Intent(context, MainActivity::class.java).putExtra(EXTRA_NAV, nav)
+ PendingIntent.getActivity(context, code, Intent(context, FrontEndActivity::class.java).putExtra(EXTRA_NAV, nav)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP), PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
private fun openDownloads(context: Context, code: Int) = openPage(context, "stores:downloads", code)
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt
index 8521a90f5d..e5ea933d83 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt
@@ -251,7 +251,7 @@ internal object EpicClientLibrary {
SessionPrefs.addedGameStoredAppId(app, oldFolder.path)?.let { SteamLiveShortcuts.remove(app, it) }
changed = true
}
- val next = StoreGameSidecar(
+ val next = withLaunchArgs(StoreGameSidecar(
Store.EPIC, appName, item.optString("DisplayName").ifEmpty { appName }, exe,
installVersion = item.optString("AppVersionString"), installedAt = existing?.installedAt?.takeIf { it > 0 } ?: folder.lastModified(),
cover = existing?.cover, hero = existing?.hero,
@@ -260,7 +260,7 @@ internal object EpicClientLibrary {
epic = existing?.epic ?: com.droiddeck.launcher.stores.EpicOptions(),
cloud = existing?.cloud ?: true,
launcher = StoreLaunch.LAUNCHER,
- )
+ ), commandArgs(item.optString("LaunchCommand")))
val sidecarChanged = existing?.toJson()?.toString(2) != next.toJson().toString(2)
val launcher = File(folder, StoreLaunch.LAUNCHER)
if (sidecarChanged || runCatching { launcher.readText() }.getOrNull() != StoreLaunch.launcherText(next)) {
@@ -328,6 +328,7 @@ internal object EpicClientLibrary {
.put("CatalogItemId", record.optString("itemId"))
.put("InstallLocation", dir)
.put("LaunchExecutable", record.optString("launchExecutable"))
+ .put("LaunchCommand", record.optString("launchCommand"))
.put("AppVersionString", record.optString("version"))
.put("SidecarDeploymentId", record.optJSONObject("sidecar")?.optString("deploymentId").orEmpty())
.put("DisplayName", title?.takeIf(String::isNotBlank) ?: dir.substringAfterLast('/'))
@@ -358,7 +359,11 @@ internal object EpicClientLibrary {
write(File(manifests, "$guid.item"), item(install, tags, ownership == true).toString(2))
runCatching { egstore(install, guid) { token } }.onFailure { Log.w(TAG, "${install.appName}: .egstore not written (${it.javaClass.simpleName})") }
after.put(install.appName, JSONObject().put("guid", guid).put("signature", install.signature).apply { if (ownership != null) put("ownership", ownership) })
- StoreGameSidecar.read(install.folder)?.let { StoreLaunch.refreshLauncher(install.folder, it) }
+ StoreGameSidecar.read(install.folder)?.let { sidecar ->
+ val next = runCatching { manifestArgs(install, guid) }.getOrNull()?.let { withLaunchArgs(sidecar, it) } ?: sidecar
+ if (next !== sidecar) next.write(install.folder)
+ StoreLaunch.refreshLauncher(install.folder, next)
+ }
}
for (name in before.keys().asSequence().toList()) {
if (after.has(name)) continue
@@ -376,6 +381,33 @@ internal object EpicClientLibrary {
return changed
}
+ private const val LAUNCH_ARGS = "launchArgs"
+
+ private fun manifestArgs(install: Install, guid: String): List? {
+ val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null
+ val launch = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch")) ?: return null
+ val build = launch.optString("buildVersion")
+ if (install.version.isNotEmpty() && build != install.version) return null
+ val args = launch.optJSONArray("args") ?: return null
+ return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() }
+ }
+
+ private fun commandArgs(command: String): List {
+ if (command.isBlank()) return emptyList()
+ val args = EpicNative.call("launch.split", JSONObject().put("command", command))?.optJSONArray("args") ?: return emptyList()
+ return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() }
+ }
+
+ internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List): StoreGameSidecar {
+ val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty()
+ val kept = sidecar.args.filterNot { it in previous }
+ val added = args.filterNot { it in kept }
+ val next = kept + added
+ val extra = LinkedHashMap(sidecar.extra).apply { if (added.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, added.joinToString("\n")) }
+ if (next == sidecar.args && extra == sidecar.extra) return sidecar
+ return sidecar.copy(args = next, extra = extra)
+ }
+
private fun ownershipToken(token: String, install: Install): Boolean? =
runCatching { EpicApiClient.getCustomAttribute(token, install.namespace, install.catalogItemId, "OwnershipToken") }
.getOrNull()?.trim()?.lowercase()?.let { it == "true" }
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicInstaller.kt
index 8d40d002bf..3be966b968 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicInstaller.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicInstaller.kt
@@ -133,7 +133,7 @@ internal class EpicInstaller(
val sidecar = StoreGameSidecar(
Store.EPIC, item.id, item.title, exe = picked.ifEmpty { "game.exe" }, args = args,
installVersion = result.optString("buildVersion"), installedAt = System.currentTimeMillis(),
- cover = cover, hero = item.imageUrl, extra = extra,
+ cover = cover, hero = item.imageUrl, extra = extra, logo = item.logoUrl,
)
StoreInstalls.complete(app, folder, sidecar, onStep = { done, steps -> handle.stageProgress(done.toLong(), steps.toLong()) })
val disk = result.optLong("diskBytes", 0L)
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicLibrary.kt
index be665881b8..32a485bfba 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicLibrary.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicLibrary.kt
@@ -25,6 +25,7 @@ data class EpicGame(
val releaseDate: String = "",
val publisher: String = "",
val isDlc: Boolean = false,
+ val artLogo: String = "",
)
object EpicLibrary {
@@ -50,7 +51,8 @@ object EpicLibrary {
.put("title", g.title).put("artCover", g.artCover).put("artSquare", g.artSquare)
.put("developer", g.developer).put("description", g.description).put("version", g.version)
.put("installSize", g.installSize).put("canRunOffline", g.canRunOffline)
- .put("releaseDate", g.releaseDate).put("publisher", g.publisher),
+ .put("releaseDate", g.releaseDate).put("publisher", g.publisher)
+ .apply { if (g.artLogo.isNotEmpty()) put("artLogo", g.artLogo) },
)
}.toString()
@@ -73,6 +75,7 @@ object EpicLibrary {
canRunOffline = o.optBoolean("canRunOffline", true),
releaseDate = o.optString("releaseDate", ""),
publisher = o.optString("publisher", ""),
+ artLogo = o.optString("artLogo", ""),
)
}
return tidy(games)
@@ -106,6 +109,7 @@ object EpicLibrary {
sizeBytes = prefs.getLong("size_${game.appName}", 0L).takeIf { it > 0 } ?: game.installSize,
storeUrl = "https://store.epicgames.com/en-US/browse?q=" + URLEncoder.encode(title, "UTF-8"),
extra = mapOf("namespace" to game.namespace, "catalogItemId" to game.catalogItemId, "version" to game.version),
+ logoUrl = game.artLogo.ifEmpty { null },
)
}
@@ -128,6 +132,7 @@ object EpicLibrary {
releaseDate = pick("releaseDate", before?.releaseDate.orEmpty()),
publisher = pick("publisher", before?.publisher.orEmpty()),
isDlc = d.optBoolean("dlc", false),
+ artLogo = pick("logo", before?.artLogo.orEmpty()),
)
}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt
index 1ba78d7951..acb7333e82 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt
@@ -11,10 +11,12 @@ import com.droiddeck.launcher.stores.StoreInstallRoot
import com.droiddeck.launcher.stores.StoreInstalls
import com.droiddeck.launcher.stores.StoreLanguage
import com.droiddeck.launcher.stores.StoreLoginActivity
+import com.droiddeck.launcher.stores.StoreNet
import com.droiddeck.launcher.stores.StoresState
import com.droiddeck.launcher.stores.download.DownloadEntry
import com.droiddeck.launcher.stores.download.DownloadQueue
import com.droiddeck.launcher.stores.download.DownloadStage
+import org.json.JSONObject
import java.io.File
import java.util.concurrent.atomic.AtomicBoolean
@@ -85,6 +87,13 @@ object GogBackend : StoreBackend {
override fun uninstall(context: Context, game: InstalledStoreGame) {}
+ private fun fetchLogo(id: String): String? =
+ runCatching { StoreNet.get("https://api.gog.com/v2/games/$id?locale=en-US")?.let { logoOf(JSONObject(it)) } }.getOrNull()
+
+ /** `images.logo2x` from the products API is an opaque banner, not a logo; the v2 `logo` link is a transparent PNG. */
+ internal fun logoOf(v2: JSONObject): String? =
+ GogStoreCatalog.absolutize(v2.optJSONObject("_links")?.optJSONObject("logo")?.optString("href")).takeIf { it.startsWith("https://") }
+
private class InstallJob(val app: Context, val game: GogGame, val item: CatalogItem, val folder: File) : DownloadQueue.DownloadJob {
private val cancelled = AtomicBoolean(false)
@@ -118,6 +127,7 @@ object GogBackend : StoreBackend {
Store.GOG, game.gameId, game.title, exe = result.exeRelative.ifEmpty { "" },
installVersion = result.buildId, installedAt = System.currentTimeMillis(),
cover = item.tallImageUrl ?: item.imageUrl, hero = item.imageUrl,
+ logo = item.logoUrl ?: fetchLogo(game.gameId),
extra = mapOf(com.droiddeck.launcher.frontend.WinCompSources.GOG_DEPENDENCIES to result.dependencies.joinToString(","))
+ (if (result.dependenciesRead) mapOf(com.droiddeck.launcher.frontend.WinCompSources.LIST_READ to "1") else emptyMap())
+ mapOf(StoreLanguage.EXTRA to installedLanguage),
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBrowse.kt b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBrowse.kt
new file mode 100644
index 0000000000..d430d11434
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBrowse.kt
@@ -0,0 +1,176 @@
+package com.droiddeck.launcher.stores.itch
+
+import android.content.Context
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import com.droiddeck.launcher.stores.CatalogItem
+import com.droiddeck.launcher.stores.StoresState
+import org.json.JSONArray
+import java.io.File
+import java.security.MessageDigest
+
+internal data class BrowseQuery(
+ val sort: String = ItchBrowse.SORT_POPULAR,
+ val price: String = ItchBrowse.PRICE_ANY,
+ val platforms: Set = emptySet(),
+ val tags: List = emptyList(),
+) {
+ val isDefault: Boolean get() = this == BrowseQuery()
+}
+
+internal class BrowsePage(val items: List, val code: Int, val cached: Boolean)
+
+internal object ItchBrowse {
+ const val SORT_POPULAR = "popular"
+ const val SORT_NEW_POPULAR = "new-and-popular"
+ const val SORT_TOP_SELLERS = "top-sellers"
+ const val SORT_TOP_RATED = "top-rated"
+ const val SORT_NEWEST = "newest"
+ val sorts = listOf(SORT_POPULAR, SORT_NEW_POPULAR, SORT_TOP_SELLERS, SORT_TOP_RATED, SORT_NEWEST)
+
+ const val PRICE_ANY = "any"
+ const val PRICE_FREE = "free"
+ const val PRICE_SALE = "on-sale"
+ const val PRICE_PAID = "store"
+ const val PRICE_UNDER_5 = "5-dollars-or-less"
+ const val PRICE_UNDER_15 = "15-dollars-or-less"
+ val prices = listOf(PRICE_ANY, PRICE_FREE, PRICE_SALE, PRICE_PAID, PRICE_UNDER_5, PRICE_UNDER_15)
+
+ val platformNames = listOf("windows", "osx", "linux", "android", "ios", "web", "mobile-web")
+
+ private const val BASE = "https://itch.io/games"
+ private const val FRESH_MS = 3 * 60 * 60 * 1000L
+ private const val GAP_MS = 1_200L
+ private const val RETRY_MS = 8_000L
+ private const val FOLDER = "itch-browse"
+
+ @Volatile private var lastRequestAt = 0L
+ private val lock = Any()
+
+ private fun sortSegment(sort: String): String? = sort.takeIf { it != SORT_POPULAR && it in sorts }
+
+ private fun priceSegment(price: String): String? = price.takeIf { it != PRICE_ANY && it in prices }
+
+ fun path(query: BrowseQuery): String {
+ val segments = listOfNotNull(sortSegment(query.sort), priceSegment(query.price)) +
+ platformNames.filter { it in query.platforms }.map { "platform-$it" } +
+ query.tags.map { "tag-" + tagSlug(it) }
+ return if (segments.isEmpty()) BASE else BASE + "/" + segments.joinToString("/")
+ }
+
+ fun url(query: BrowseQuery, page: Int): String = path(query) + ".xml" + if (page > 1) "?page=$page" else ""
+
+ fun tagSlug(tag: String): String = tag.trim().lowercase().replace(Regex("[^a-z0-9]+"), "-").trim('-')
+
+ fun page(context: Context, query: BrowseQuery, page: Int, force: Boolean = false): BrowsePage {
+ val app = context.applicationContext
+ val url = url(query, page)
+ if (!force) read(app, url)?.let { return BrowsePage(it, 200, true) }
+ val (status, body) = fetch(url)
+ val items = if (status in 200..299 && body != null) ItchShelves.parse(body) else emptyList()
+ StoresState.logLine("itch.io browse: $url answered $status with ${items.size} games")
+ if (items.isNotEmpty()) write(app, url, items)
+ return BrowsePage(items, status, false)
+ }
+
+ private fun fetch(url: String): Pair {
+ synchronized(lock) {
+ pause()
+ var answer = ItchShelves.open(url)
+ if (answer.first == 429) {
+ StoresState.logLine("itch.io browse: 429, waiting before one more try")
+ Thread.sleep(RETRY_MS)
+ pause()
+ answer = ItchShelves.open(url)
+ }
+ lastRequestAt = System.currentTimeMillis()
+ return answer
+ }
+ }
+
+ private fun pause() {
+ val gap = GAP_MS - (System.currentTimeMillis() - lastRequestAt)
+ if (gap > 0) Thread.sleep(gap)
+ }
+
+ private fun file(context: Context, url: String): File {
+ val digest = MessageDigest.getInstance("SHA-1").digest(url.toByteArray()).joinToString("") { "%02x".format(it) }
+ return File(File(context.cacheDir, FOLDER), "$digest.json")
+ }
+
+ private fun read(context: Context, url: String): List? {
+ val file = file(context, url)
+ if (!file.isFile || System.currentTimeMillis() - file.lastModified() > FRESH_MS) return null
+ return runCatching { ItchCatalog.list(JSONArray(file.readText())) }.getOrNull()?.takeIf { it.isNotEmpty() }
+ }
+
+ private fun write(context: Context, url: String, items: List) {
+ val file = file(context, url)
+ runCatching {
+ file.parentFile?.mkdirs()
+ file.writeText(ItchCatalog.array(items).toString())
+ }
+ }
+}
+
+internal object ItchBrowseState {
+ var query by mutableStateOf(BrowseQuery())
+ private set
+ var items by mutableStateOf>(emptyList())
+ private set
+ var loading by mutableStateOf(false)
+ private set
+ var ended by mutableStateOf(false)
+ private set
+ var failed by mutableStateOf(false)
+ private set
+
+ private var next = 1
+ private var generation = 0
+
+ val active: Boolean get() = !query.isDefault
+
+ fun choose(context: Context, wanted: BrowseQuery) {
+ if (wanted == query) return
+ generation++
+ query = wanted
+ items = emptyList()
+ ended = false
+ failed = false
+ loading = false
+ next = 1
+ if (active) more(context)
+ }
+
+ fun more(context: Context, retry: Boolean = false) {
+ if (loading || ended || !active || (failed && !retry)) return
+ loading = true
+ failed = false
+ val app = context.applicationContext
+ val mine = generation
+ val asked = query
+ val page = next
+ Thread({
+ val answer = runCatching { ItchBrowse.page(app, asked, page) }.getOrNull()
+ StoresState.post {
+ if (mine != generation) return@post
+ loading = false
+ if (answer == null || answer.code !in 200..299) {
+ failed = true
+ return@post
+ }
+ if (answer.items.isEmpty()) {
+ ended = true
+ return@post
+ }
+ val known = items.mapTo(HashSet()) { it.id }
+ val fresh = answer.items.filter { known.add(it.id) }
+ if (fresh.isEmpty()) ended = true else {
+ items = items + fresh
+ next = page + 1
+ }
+ }
+ }, "itch-browse").start()
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchShelves.kt b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchShelves.kt
index 0fd783ed66..acf3324315 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchShelves.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchShelves.kt
@@ -108,7 +108,7 @@ internal object ItchShelves {
return shelves.takeUnless { it.isEmpty }
}
- private fun open(url: String): Pair {
+ internal fun open(url: String): Pair {
var conn: HttpURLConnection? = null
return try {
conn = (URL(url).openConnection() as HttpURLConnection).apply {
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt
index 24d7ff622b..a50b56612e 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt
@@ -26,6 +26,8 @@ object XboxBackend : StoreBackend {
access = emptyMap()
}
XboxLibraryCache.clear(context)
+ XboxCloudSession.clear()
+ XboxCloudActivity.clearWebSignIn(context)
XboxRuntime.stop()
}
StoresState.post { packageChoice = null; StoresState.shelves.remove(store); StoresState.found.remove(store) }
@@ -53,13 +55,17 @@ object XboxBackend : StoreBackend {
else StoresState.status.remove(store)
}
}
- if (cached != null && !cached.needsRefresh(force)) return@Thread
+ if (cached != null && !cached.needsRefresh(force)) { XboxGamertag.ensure(app); return@Thread }
val response = Xodus.run(app, listOf("library", "--json", "--market", market))
val licenses = XboxCatalog.access(response, account, market, report = { StoresState.logLine("Xbox: $it") })
val products = XboxCatalog.rawProducts(licenses.keys.toList(), market)
- val games = products.mapNotNull { XboxCatalog.product(it, licenses) }.sortedBy { it.title.lowercase() }
+ val cloud = runCatching { XboxCatalog.cloudCatalog(market) }
+ .onFailure { StoresState.logLine("Xbox: cloud lists unavailable (${it.javaClass.simpleName})") }.getOrNull()
+ val games = mergeEditions(products.mapNotNull { XboxCatalog.product(it, licenses, cloud) }).sortedBy { it.title.lowercase() }
StoresState.logLine("Xbox: library catalog requested=${licenses.size} returned=${products.size} supported=${games.size} " +
- "filtered=${products.size - games.size} backend-skipped=${response.optInt("skippedEntitlements")}")
+ "filtered=${products.size - games.size} backend-skipped=${response.optInt("skippedEntitlements")} " +
+ "pc=${games.count { it.xboxPc }} cloud=${games.count { it.xboxCloud }} cloud-only=${games.count { !it.xboxPc }} " +
+ "cloud-lists=${cloud?.gamePass?.size ?: -1}/${cloud?.all?.size ?: -1}")
synchronized(this) {
if (current != generation || StoreAccounts.signedInAs(app, store) != account) return@Thread
access = licenses
@@ -73,6 +79,7 @@ object XboxBackend : StoreBackend {
StoresState.problems.remove(store)
}
}
+ if (current == generation) XboxGamertag.ensure(app)
} catch (e: Exception) {
StoresState.post {
if (current == generation) {
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt
index 100371b06e..d4a16c4098 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt
@@ -10,7 +10,7 @@ import java.time.Instant
internal object XboxCatalog {
private val productId = Regex("[A-Z0-9]{12}")
private val plans = setOf("CFQ7TTC0KGQ8", "CFQ7TTC0KHS0", "CFQ7TTC0P85B", "CFQ7TTC0K5DJ", "CFQ7TTC0K6L8", "CFQ7TTC10QFD")
- /** Plans that include PC games; the retired console-only plan must not offer a Windows install. */
+ /** Plans whose store offers advertise PC games. Library entitlements under any active plan count, as the backend resolves a PC package for them. */
private val pcPlans = mapOf(
"CFQ7TTC0KGQ8" to "PC Game Pass",
"CFQ7TTC0KHS0" to "Game Pass Ultimate",
@@ -61,7 +61,7 @@ internal object XboxCatalog {
val parent = row.optString("satisfiedByProductId").takeUnless { it.isBlank() || it == "null" }
if (parent == null) return if (id in plans) null else "owned"
if (parent in blocked) return null
- if (parent in plans) return if (parent in pcPlans && activePlan(parent)) "gamepass" else null
+ if (parent in plans) return if (activePlan(parent)) "gamepass" else null
return kind(parent, visited + id)
}
val result = rows.keys.mapNotNull { id -> kind(id)?.let { id to it } }.toMap()
@@ -98,7 +98,7 @@ internal object XboxCatalog {
return products(objects(body.optJSONArray("productsList")).map { it.optString("productId") }.take(24), access)
}
- internal fun product(json: JSONObject, access: Map): CatalogItem? {
+ internal fun product(json: JSONObject, access: Map, cloud: XboxCloudCatalog? = null): CatalogItem? {
val id = json.optString("ProductId").uppercase()
if (!productId.matches(id) || json.optString("ProductType") != "Game") return null
val localized = objects(json.optJSONArray("LocalizedProperties")).firstOrNull() ?: return null
@@ -107,7 +107,9 @@ internal object XboxCatalog {
objects(it.optJSONObject("Sku")?.optJSONObject("Properties")?.optJSONArray("Packages"))
}
val pc = packages.filter { pkg -> objects(pkg.optJSONArray("PlatformDependencies")).any { it.optString("PlatformName") == "Windows.Desktop" } }
- if (pc.none { it.optString("PackageFormat").equals("MSIXVC", true) }) return null
+ val installable = pc.any { it.optString("PackageFormat").equals("MSIXVC", true) }
+ val streams = cloud?.streams(id, access[id].orEmpty()) == true
+ if (!installable && !streams) return null
val images = objects(localized.optJSONArray("Images"))
fun image(vararg kinds: String): String? = kinds.firstNotNullOfOrNull { purpose ->
images.firstOrNull { it.optString("ImagePurpose") == purpose }?.optString("Uri")?.let { raw ->
@@ -127,13 +129,57 @@ internal object XboxCatalog {
storeUrl = "https://www.xbox.com/games/store/$id",
publisher = localized.optString("PublisherName"), developer = localized.optString("DeveloperName"),
description = localized.optString("ProductDescription"),
- sizeBytes = pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L,
- extra = mapOf("market" to Xodus.market(), "access" to kind.orEmpty()),
+ sizeBytes = if (installable) pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L else 0L,
+ extra = mapOf("market" to Xodus.market(), "access" to kind.orEmpty(), "pc" to flag(installable), "cloud" to flag(streams)),
)
}
+ private const val CLOUD_GAME_PASS = "29a81209-df6f-41fd-a528-2ae6b91f719c"
+ private const val CLOUD_ALL = "ce573635-7c18-4d0c-9d68-90b932393470"
+
+ /** Microsoft's public cloud lists (catalog.gamepass.com "sigls"; ids as Better xCloud by redphx, MIT, uses them). */
+ fun cloudCatalog(market: String = Xodus.market()): XboxCloudCatalog =
+ XboxCloudCatalog(cloudList(CLOUD_GAME_PASS, market), cloudList(CLOUD_ALL, market))
+
+ private fun cloudList(id: String, market: String): Set {
+ val body = JSONArray(StoreNet.get("https://catalog.gamepass.com/sigls/v2?id=$id&language=en-us&market=$market") ?: error("Xbox cloud list unavailable"))
+ return (0 until body.length()).mapNotNull { body.optJSONObject(it)?.optString("id")?.uppercase()?.takeIf(productId::matches) }.toSet()
+ }
+
+ fun cloudUrl(id: String, title: String, cloudId: String = id): String =
+ "https://www.xbox.com/play/launch/${title.lowercase().replace(Regex("[^a-z0-9]+"), "-").trim('-').ifEmpty { "game" }}/$cloudId"
+
+ internal fun flag(value: Boolean) = if (value) "1" else "0"
+
fun objects(array: JSONArray?): List = if (array == null) emptyList() else
(0 until array.length()).mapNotNull { array.optJSONObject(it) }
private fun get(url: String): JSONObject = JSONObject(StoreNet.get(url) ?: error("Microsoft Store could not be reached. Try again."))
}
+
+internal data class XboxCloudCatalog(val gamePass: Set, val all: Set) {
+ fun streams(id: String, access: String): Boolean = when (access) {
+ "gamepass" -> id in gamePass
+ "owned" -> id in all || id in gamePass
+ else -> false
+ }
+}
+
+val CatalogItem.xboxPc: Boolean get() = extra["pc"] != "0"
+val CatalogItem.xboxCloud: Boolean get() = extra["cloud"] == "1"
+val CatalogItem.xboxCloudId: String get() = extra["cloudId"]?.takeIf { it.isNotEmpty() } ?: id
+
+/** Microsoft lists console and PC editions as separate products; a cloud-only one with a PC game's title folds into that card. */
+internal fun mergeEditions(games: List): List {
+ fun key(title: String) = title.lowercase().replace(Regex("[^a-z0-9]+"), "")
+ val cloudOnly = games.filter { !it.xboxPc && it.xboxCloud }.groupBy { key(it.title) }
+ val folded = HashSet()
+ val merged = games.map { game ->
+ if (!game.xboxPc || game.xboxCloud) game
+ else cloudOnly[key(game.title)]?.firstOrNull()?.let { console ->
+ folded.add(console.id)
+ game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to console.id))
+ } ?: game
+ }
+ return merged.filter { it.id !in folded }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudActivity.kt
new file mode 100644
index 0000000000..1fa7bdfe56
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudActivity.kt
@@ -0,0 +1,189 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.content.Intent
+import android.graphics.Color
+import android.os.Bundle
+import android.util.Log
+import android.view.InputDevice
+import android.view.KeyEvent
+import android.view.View
+import android.view.WindowManager
+import android.webkit.ConsoleMessage
+import android.webkit.CookieManager
+import android.webkit.PermissionRequest
+import android.webkit.WebChromeClient
+import android.webkit.WebResourceRequest
+import android.webkit.WebSettings
+import android.webkit.WebView
+import android.webkit.WebViewClient
+import android.widget.FrameLayout
+import androidx.activity.ComponentActivity
+import androidx.core.view.WindowCompat
+import androidx.core.view.WindowInsetsCompat
+import androidx.core.view.WindowInsetsControllerCompat
+import androidx.webkit.WebSettingsCompat
+import androidx.webkit.WebViewCompat
+import androidx.webkit.WebViewFeature
+
+/**
+ * Microsoft's web player (xbox.com/play) in its own process and WebView data directory: the store sign-in
+ * clears its own web data after each attempt, so the player keeps a separate Microsoft session. Signing out of
+ * the store clears it ([clearWebSignIn]).
+ */
+class XboxCloudActivity : ComponentActivity() {
+ private var web: WebView? = null
+ private var custom: View? = null
+ private var customCallback: WebChromeClient.CustomViewCallback? = null
+ private lateinit var root: FrameLayout
+
+ @SuppressLint("SetJavaScriptEnabled")
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ hideBars()
+ root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) }
+ setContentView(root)
+ Log.i(TAG, "WebView ${WebViewCompat.getCurrentWebViewPackage(this)?.versionName}")
+
+ val view = WebView(this)
+ web = view
+ view.settings.apply {
+ javaScriptEnabled = true
+ domStorageEnabled = true
+ databaseEnabled = true
+ mediaPlaybackRequiresUserGesture = false
+ allowFileAccess = false
+ allowContentAccess = false
+ mixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW
+ useWideViewPort = true
+ loadWithOverviewMode = true
+ userAgentString = chromeUserAgent(userAgentString)
+ }
+ // No "X-Requested-With: " header: it marks the page as embedded in an app.
+ if (WebViewFeature.isFeatureSupported(WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST))
+ WebSettingsCompat.setRequestedWithHeaderOriginAllowList(view.settings, emptySet())
+ Log.i(TAG, "UA ${view.settings.userAgentString}")
+ CookieManager.getInstance().setAcceptCookie(true)
+ CookieManager.getInstance().setAcceptThirdPartyCookies(view, true)
+ view.webViewClient = object : WebViewClient() {
+ override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean =
+ request.url.scheme != "https"
+ override fun onPageFinished(view: WebView, url: String) { Log.i(TAG, "page ${url.substringBefore('?')}") }
+ }
+ view.webChromeClient = object : WebChromeClient() {
+ override fun onConsoleMessage(message: ConsoleMessage): Boolean {
+ Log.d(TAG, "console ${message.messageLevel()}: ${message.message().take(300)}")
+ return true
+ }
+ override fun onPermissionRequest(request: PermissionRequest) {
+ Log.i(TAG, "permission request ${request.resources.joinToString()} denied")
+ request.deny()
+ }
+ override fun onShowCustomView(view: View, callback: CustomViewCallback) {
+ custom?.let { root.removeView(it) }
+ custom = view; customCallback = callback
+ root.addView(view, FrameLayout.LayoutParams(-1, -1))
+ hideBars()
+ }
+ override fun onHideCustomView() {
+ custom?.let { root.removeView(it) }
+ custom = null; customCallback = null
+ }
+ }
+ root.addView(view, FrameLayout.LayoutParams(-1, -1))
+ if (savedInstanceState != null) view.restoreState(savedInstanceState)
+ else view.loadUrl(startUrl(intent))
+ }
+
+ override fun onNewIntent(intent: Intent) {
+ super.onNewIntent(intent)
+ setIntent(intent)
+ web?.loadUrl(startUrl(intent))
+ }
+
+ private fun startUrl(intent: Intent): String =
+ intent.getStringExtra("url")?.takeIf { url -> runCatching { java.net.URI(url) }.getOrNull()?.let {
+ it.scheme == "https" && it.host == "www.xbox.com" && it.userInfo == null && it.port == -1 } == true } ?: START_URL
+
+ // Without the WebView markers the page treats this as Chrome for Android.
+ private fun chromeUserAgent(default: String): String =
+ default.replace("; wv)", ")").replace(Regex(" Version/\\d+(\\.\\d+)*"), "")
+
+ private fun hideBars() {
+ WindowCompat.setDecorFitsSystemWindows(window, false)
+ WindowInsetsControllerCompat(window, window.decorView).apply {
+ hide(WindowInsetsCompat.Type.systemBars())
+ systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
+ }
+ }
+
+ override fun onWindowFocusChanged(hasFocus: Boolean) {
+ super.onWindowFocusChanged(hasFocus)
+ if (hasFocus) hideBars()
+ }
+
+ // A controller's unused B arrives as BACK; ask before leaving so a stray press never ends a stream.
+ override fun dispatchKeyEvent(event: KeyEvent): Boolean {
+ if (event.keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
+ val fromController = event.source and InputDevice.SOURCE_GAMEPAD == InputDevice.SOURCE_GAMEPAD ||
+ event.source and InputDevice.SOURCE_JOYSTICK == InputDevice.SOURCE_JOYSTICK
+ when {
+ custom != null -> customCallback?.onCustomViewHidden()
+ fromController -> confirmLeave()
+ web?.canGoBack() == true -> web?.goBack()
+ else -> finish()
+ }
+ return true
+ }
+ if (event.keyCode == KeyEvent.KEYCODE_BACK) return true
+ return super.dispatchKeyEvent(event)
+ }
+
+ private var leaving: android.app.AlertDialog? = null
+
+ private fun confirmLeave() {
+ if (leaving?.isShowing == true) return
+ leaving = android.app.AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_Alert)
+ .setTitle("Leave Xbox Cloud Gaming?")
+ .setMessage("The stream ends when you leave.")
+ .setPositiveButton("Leave") { _, _ -> finish() }
+ .setNegativeButton("Stay", null)
+ .show()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ web?.saveState(outState)
+ }
+
+ override fun onPause() { super.onPause(); CookieManager.getInstance().flush() }
+
+ override fun onDestroy() {
+ web?.let { root.removeView(it); it.stopLoading(); it.destroy() }
+ web = null
+ super.onDestroy()
+ }
+
+ companion object {
+ private const val TAG = "XboxCloud"
+ const val START_URL = "https://www.xbox.com/play"
+
+ fun intent(context: Context, url: String? = null): Intent = Intent(context, XboxCloudActivity::class.java)
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ .apply { if (url != null) putExtra("url", url) }
+
+ const val PROCESS_SUFFIX = ":xboxcloud"
+ const val WEBVIEW_SUFFIX = "xboxcloud"
+
+ fun clearWebSignIn(context: Context) {
+ val am = context.getSystemService(Context.ACTIVITY_SERVICE) as android.app.ActivityManager
+ am.runningAppProcesses.orEmpty().filter { it.processName.endsWith(PROCESS_SUFFIX) }
+ .forEach { android.os.Process.killProcess(it.pid) }
+ val suffix = WEBVIEW_SUFFIX
+ listOf(java.io.File(context.applicationInfo.dataDir, "app_webview_$suffix"), java.io.File(context.cacheDir.parentFile, "cache/webview_$suffix"))
+ .forEach { runCatching { it.deleteRecursively() } }
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudGames.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudGames.kt
new file mode 100644
index 0000000000..10b034eaae
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudGames.kt
@@ -0,0 +1,135 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import android.content.Intent
+import androidx.compose.runtime.mutableStateListOf
+import com.droiddeck.launcher.frontend.Library
+import com.droiddeck.launcher.session.SessionState
+import com.droiddeck.launcher.stores.CatalogItem
+import com.droiddeck.launcher.stores.Store
+import com.droiddeck.launcher.stores.StoresState
+import org.json.JSONArray
+import org.json.JSONObject
+import java.io.File
+import java.net.HttpURLConnection
+import java.net.URL
+
+/** Xbox games added to the Games tab to stream before (or without) installing them. */
+object XboxCloudGames {
+ class Entry(val id: String, val title: String, val poster: String?, val hero: String?)
+
+ private const val PREFS = "xbox_cloud_games"
+ private val idPattern = Regex("[A-Z0-9]{12}")
+ val entries = mutableStateListOf()
+ @Volatile private var loaded = false
+
+ fun load(context: Context) {
+ if (loaded) return
+ loaded = true
+ val list = decode(context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString("games", null))
+ StoresState.post { entries.clear(); entries.addAll(list) }
+ }
+
+ fun isAdded(id: String) = entries.any { it.id == id }
+
+ fun add(context: Context, item: CatalogItem) {
+ val app = context.applicationContext
+ if (isAdded(item.id)) return
+ entries.add(Entry(item.id, item.title, item.tallImageUrl, item.imageUrl))
+ save(app)
+ Thread({
+ fetch(item.tallImageUrl, File(artDir(app, item.id), "poster"))
+ fetch(item.imageUrl, File(artDir(app, item.id), "hero"))
+ StoresState.post { StoresState.notifyLibraryChanged(app) }
+ }, "xbox-cloud-art").start()
+ }
+
+ fun remove(context: Context, id: String) {
+ val app = context.applicationContext
+ entries.removeAll { it.id == id }
+ save(app)
+ artDir(app, id).deleteRecursively()
+ }
+
+ private fun save(app: Context) {
+ app.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString("games", encode(entries.toList())).apply()
+ }
+
+ internal fun encode(list: List): String = JSONArray().apply {
+ list.forEach { put(JSONObject().put("id", it.id).put("title", it.title).put("poster", it.poster.orEmpty()).put("hero", it.hero.orEmpty())) }
+ }.toString()
+
+ internal fun decode(text: String?): List = runCatching {
+ val array = JSONArray(text ?: return emptyList())
+ (0 until minOf(array.length(), 2000)).mapNotNull { array.optJSONObject(it) }.mapNotNull { o ->
+ val id = o.optString("id")
+ val title = o.optString("title")
+ if (!idPattern.matches(id) || title.isBlank()) null
+ else Entry(id, title.take(200), o.optString("poster").takeIf { it.isNotEmpty() }, o.optString("hero").takeIf { it.isNotEmpty() })
+ }.distinctBy { it.id }
+ }.getOrDefault(emptyList())
+
+ /** Games-tab rows for the added games that are not installed (an installed copy has its own row). */
+ fun rows(context: Context, installedIds: Set): List = entries.filter { it.id !in installedIds }.map { e ->
+ val dir = artDir(context, e.id)
+ val appId = rowId(e.id)
+ Library.SteamGame(appId = appId, name = e.title, art = File(dir, "poster").takeIf { it.isFile }, library = Library.XBOX_CLOUD,
+ hero = File(dir, "hero").takeIf { it.isFile }, source = Store.XBOX.id, storeId = e.id)
+ }
+
+ internal fun rowId(id: String): Int = ("xbox-cloud:$id").hashCode() or Int.MIN_VALUE
+
+ private fun artDir(context: Context, id: String) = File(context.filesDir, "xbox-cloud-art/$id")
+
+ private fun fetch(url: String?, target: File) {
+ if (url == null) return
+ runCatching {
+ val parsed = URL(url)
+ require(parsed.protocol == "https" && parsed.host in setOf("store-images.s-microsoft.com", "store-images.microsoft.com"))
+ val connection = parsed.openConnection() as HttpURLConnection
+ try {
+ connection.connectTimeout = 15_000; connection.readTimeout = 30_000
+ check(connection.responseCode == 200)
+ val bytes = connection.inputStream.use { it.readBytes() }
+ require(bytes.size in 1..12_000_000)
+ target.parentFile?.mkdirs()
+ File(target.path + ".tmp").apply { writeBytes(bytes); check(renameTo(target)) }
+ } finally { connection.disconnect() }
+ }
+ }
+
+ private val prefetching = java.util.concurrent.atomic.AtomicBoolean(false)
+
+ /**
+ * Fetches the streaming tokens in the background while a cloud game is on screen (about 20 s), so Stream starts at
+ * once; both players take them from this process (the native one through XboxCloudTokenService).
+ */
+ fun prefetch(context: Context) {
+ val app = context.applicationContext
+ if (!prefetching.compareAndSet(false, true)) return
+ Thread({
+ try {
+ val account = com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, Store.XBOX) ?: return@Thread
+ runCatching { XboxCloudSession.get(app, account) }
+ .onFailure { StoresState.logLine("Xbox: cloud tokens not fetched ahead: ${it.message?.take(160)}") }
+ } finally { prefetching.set(false) }
+ }, "xcloud-prefetch").start()
+ }
+
+ /** Streaming runs outside the Linux session; the session owns the screen, audio and controllers while it runs. */
+ fun stream(context: Context, id: String, title: String) {
+ if (SessionState.running) {
+ android.widget.Toast.makeText(context, "Close the Steam session to stream Xbox games.", android.widget.Toast.LENGTH_LONG).show()
+ return
+ }
+ context.startActivity(XboxCloudPlayerActivity.playerIntent(context, id, title).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
+ }
+
+ /** Whether the signed-in library says this game streams (cached library; reads disk). */
+ fun streams(context: Context, id: String): Boolean = runCatching {
+ StoresState.library[Store.XBOX]?.firstOrNull { it.id == id }?.let { return it.xboxCloud }
+ val app = context.applicationContext
+ val account = com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, Store.XBOX) ?: return false
+ XboxLibraryCache.read(app, account, Xodus.market())?.games?.firstOrNull { it.id == id }?.xboxCloud == true
+ }.getOrDefault(false)
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt
new file mode 100644
index 0000000000..9b8d11c0d0
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt
@@ -0,0 +1,399 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.content.Intent
+import android.graphics.Color
+import android.os.Bundle
+import android.view.Gravity
+import android.view.KeyEvent
+import android.view.WindowManager
+import android.webkit.JavascriptInterface
+import android.webkit.WebResourceRequest
+import android.webkit.WebResourceResponse
+import android.webkit.WebView
+import android.webkit.WebViewClient
+import android.widget.Button
+import android.widget.FrameLayout
+import android.widget.LinearLayout
+import android.widget.TextView
+import androidx.activity.ComponentActivity
+import androidx.core.view.WindowCompat
+import androidx.core.view.WindowInsetsCompat
+import androidx.core.view.WindowInsetsControllerCompat
+import androidx.webkit.WebViewAssetLoader
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.input.key.key
+import androidx.compose.ui.input.key.onKeyEvent
+import androidx.compose.ui.input.key.type
+import androidx.compose.ui.unit.dp
+import com.droiddeck.launcher.stores.Store
+import com.droiddeck.launcher.stores.StoreAccounts
+import com.droiddeck.launcher.stores.StoresState
+import org.json.JSONObject
+import java.util.concurrent.Executors
+
+/** Runs the WebRTC client page (tools/xcloud-player); signalling and tokens stay on this side of the bridge. */
+class XboxCloudPlayerActivity : ComponentActivity() {
+ private lateinit var root: FrameLayout
+ private var web: WebView? = null
+ private var notice: LinearLayout? = null
+ private val worker = Executors.newSingleThreadExecutor()
+ private val signalling = Executors.newCachedThreadPool()
+ @Volatile private var session: XboxCloudSession.Session? = null
+ @Volatile private var sessionPath: String? = null
+ @Volatile private var titleId: String? = null
+ @Volatile private var closed = false
+ @Volatile private var webUrl: String? = null
+ @Volatile private var settings = XboxCloudSettings()
+ @Volatile private var sessionSignals: XboxCloudSignalling? = null
+ /** The settings this stream started with (stream-start settings changed since then need a restart). */
+ @Volatile private var startedWith: XboxCloudSettings? = null
+ private var menu: androidx.compose.ui.platform.ComposeView? = null
+
+ @SuppressLint("SetJavaScriptEnabled")
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ hideBars()
+ watchBars()
+ root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) }
+ setContentView(root)
+ val requested = intent.getStringExtra("product").orEmpty()
+ showNotice("Signing in to Xbox Cloud Gaming…", withButtons = false)
+ worker.execute {
+ val result = runCatching {
+ val account = StoreAccounts.signedInAs(applicationContext, Store.XBOX) ?: error("Sign in to the Xbox store first.")
+ val cached = XboxLibraryCache.read(applicationContext, account, Xodus.market())?.games?.firstOrNull { it.id == requested }
+ val product = cached?.extra?.get("cloudId")?.takeIf { it.isNotEmpty() } ?: requested
+ webUrl = XboxCatalog.cloudUrl(requested, cached?.title ?: intent.getStringExtra("title").orEmpty(), product)
+ val active = XboxCloudSession.get(applicationContext, account)
+ val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.")
+ settings = XboxCloudSettings.load(applicationContext)
+ startedWith = settings
+ session = active.forStream(settings.region, settings.osName); titleId = title
+ diag("cloud player: $product -> title $title, region ${java.net.URI(session!!.baseUri).host}, transfer=${active.userToken != null}")
+ }
+ runOnUiThread {
+ if (closed) return@runOnUiThread
+ result.onSuccess { openPlayer() }.onFailure {
+ diag("cloud player not started: ${it.javaClass.simpleName}: ${it.message?.take(160)}")
+ showNotice(it.message ?: "Xbox Cloud Gaming could not start.", withButtons = true)
+ }
+ }
+ }
+ }
+
+ @SuppressLint("SetJavaScriptEnabled")
+ private fun openPlayer() {
+ val loader = WebViewAssetLoader.Builder().addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(this)).build()
+ val view = WebView(this)
+ web = view
+ view.settings.apply {
+ javaScriptEnabled = true
+ mediaPlaybackRequiresUserGesture = false
+ allowFileAccess = false
+ allowContentAccess = false
+ }
+ view.setBackgroundColor(Color.BLACK)
+ // The Gamepad API only sees controllers while the WebView has input focus.
+ view.isFocusable = true
+ view.isFocusableInTouchMode = true
+ view.addJavascriptInterface(Bridge(), "DDCloud")
+ view.webViewClient = object : WebViewClient() {
+ override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? =
+ loader.shouldInterceptRequest(request.url)
+ override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean = true
+ }
+ view.webChromeClient = object : android.webkit.WebChromeClient() {
+ override fun onConsoleMessage(message: android.webkit.ConsoleMessage): Boolean {
+ android.util.Log.d("XboxCloudPlayer", "console ${message.messageLevel()}: ${message.message().take(300)}")
+ return true
+ }
+ }
+ root.addView(view, 0, FrameLayout.LayoutParams(-1, -1))
+ notice?.let { root.removeView(it) }
+ notice = null
+ view.requestFocus()
+ view.loadUrl("https://appassets.androidplatform.net/assets/xcloud/player.html")
+ }
+
+ private inner class Bridge {
+ @JavascriptInterface
+ fun call(id: Int, op: String, arg: String) {
+ signalling.execute {
+ val reply = runCatching { handle(op, arg) }.getOrElse { XboxCloudSession.Reply(0, it.javaClass.simpleName) }
+ if (reply.status !in 200..299) diag("cloud player $op: ${reply.status} ${reply.body.take(300)}")
+ else if (op != "state" && op != "keepalive") diag("cloud player $op: ${reply.status}")
+ runOnUiThread { web?.evaluateJavascript("window.__ddResolve($id, ${reply.status}, ${JSONObject.quote(reply.body)})", null) }
+ }
+ }
+
+ @JavascriptInterface
+ fun status(text: String) { android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") }
+
+ @JavascriptInterface
+ fun playing() {
+ diag("cloud player streaming")
+ runOnUiThread { web?.requestFocus() }
+ }
+
+ @JavascriptInterface
+ fun settings(): String = pageSettings(this@XboxCloudPlayerActivity.settings)
+
+ @JavascriptInterface
+ fun log(text: String) { diag("cloud player page: ${text.take(240)}") }
+
+ @JavascriptInterface
+ fun failed(stage: String, detail: String) {
+ diag("cloud player failed at ${stage.take(40)}: ${detail.take(300)}")
+ runOnUiThread { if (!closed) showNotice("The stream could not start ($stage).", withButtons = true) }
+ }
+ }
+
+ private fun handle(op: String, arg: String): XboxCloudSession.Reply {
+ val active = session ?: error("no session")
+ val signals = sessionSignals ?: XboxCloudSignalling(active, titleId ?: error("no title"), settings).also { sessionSignals = it }
+ return signals.op(op, arg).also { sessionPath = signals.path }
+ }
+
+ private fun showNotice(text: String, withButtons: Boolean) {
+ notice?.let { root.removeView(it) }
+ val box = LinearLayout(this).apply {
+ orientation = LinearLayout.VERTICAL
+ gravity = Gravity.CENTER
+ setBackgroundColor(if (withButtons) Color.argb(230, 0, 0, 0) else Color.TRANSPARENT)
+ }
+ box.addView(TextView(this).apply { setTextColor(Color.WHITE); textSize = 18f; gravity = Gravity.CENTER; this.text = text; setPadding(32, 16, 32, 16) })
+ if (withButtons) {
+ val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL; gravity = Gravity.CENTER }
+ (webUrl ?: intent.getStringExtra("webUrl"))?.let { url ->
+ row.addView(Button(this).apply { this.text = "Open in Microsoft's player"; setOnClickListener { startActivity(XboxCloudActivity.intent(this@XboxCloudPlayerActivity, url)); finish() } })
+ }
+ row.addView(Button(this).apply { this.text = "Close"; setOnClickListener { finish() } })
+ box.addView(row)
+ }
+ notice = box
+ root.addView(box, FrameLayout.LayoutParams(-1, -1))
+ }
+
+ private val rehideBars = Runnable { if (window.decorView.hasWindowFocus()) hideBars() }
+
+ private fun watchBars() {
+ androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
+ if (insets.isVisible(WindowInsetsCompat.Type.navigationBars()) || insets.isVisible(WindowInsetsCompat.Type.statusBars())) {
+ v.removeCallbacks(rehideBars)
+ v.postDelayed(rehideBars, 1500)
+ }
+ androidx.core.view.ViewCompat.onApplyWindowInsets(v, insets)
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ hideBars()
+ }
+
+ private fun hideBars() {
+ WindowCompat.setDecorFitsSystemWindows(window, false)
+ WindowInsetsControllerCompat(window, window.decorView).apply {
+ hide(WindowInsetsCompat.Type.systemBars())
+ systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
+ }
+ }
+
+ override fun onWindowFocusChanged(hasFocus: Boolean) {
+ super.onWindowFocusChanged(hasFocus)
+ if (hasFocus) hideBars()
+ }
+
+ private var guideDown = false
+ private var guideDownAt = 0L
+ private var lastGuideUp = 0L
+ private var pendingNexus: Runnable? = null
+ private var swallowGuideUp = false
+
+ private fun isGuideKey(event: KeyEvent): Boolean = event.keyCode == KeyEvent.KEYCODE_BUTTON_MODE
+
+ /** One press is the stream's Xbox button; two quick presses or a hold open the player menu. */
+ private fun guideKey(event: KeyEvent): Boolean {
+ if (!isGuideKey(event)) return false
+ if (event.action == KeyEvent.ACTION_DOWN) {
+ if (event.repeatCount == 0) {
+ guideDown = true; guideDownAt = event.eventTime
+ val pending = pendingNexus
+ if (pending != null && event.eventTime - lastGuideUp <= DOUBLE_PRESS_MS) {
+ root.removeCallbacks(pending); pendingNexus = null; guideDown = false
+ swallowGuideUp = true
+ openMenu()
+ }
+ } else if (guideDown && event.eventTime - guideDownAt >= 600) {
+ guideDown = false
+ swallowGuideUp = true
+ openMenu()
+ }
+ } else if (event.action == KeyEvent.ACTION_UP && guideDown) {
+ guideDown = false
+ lastGuideUp = event.eventTime
+ val tap = Runnable { pendingNexus = null; pressNexus(1); root.postDelayed({ pressNexus(0) }, 150) }
+ pendingNexus = tap
+ root.postDelayed(tap, DOUBLE_PRESS_MS)
+ }
+ return true
+ }
+
+ private fun pressNexus(value: Int) {
+ web?.evaluateJavascript("window.__ddButton && window.__ddButton('Nexus', $value)", null)
+ }
+
+ // Back opens the player menu so a stray press never ends a stream.
+ override fun dispatchKeyEvent(event: KeyEvent): Boolean {
+ if (menu != null) {
+ if (isGuideKey(event)) {
+ if (event.action == KeyEvent.ACTION_UP) { if (swallowGuideUp) swallowGuideUp = false else closeMenu() }
+ return true
+ }
+ if (event.keyCode == KeyEvent.KEYCODE_BACK) {
+ if (event.action == KeyEvent.ACTION_UP) { if (menuPage.isNotEmpty()) menuPage = "" else closeMenu() }
+ return true
+ }
+ return super.dispatchKeyEvent(event)
+ }
+ if (notice == null && guideKey(event)) return true
+ if (event.keyCode == KeyEvent.KEYCODE_BACK) {
+ if (event.action == KeyEvent.ACTION_UP) { if (notice == null) openMenu() else finish() }
+ return true
+ }
+ // Reporting controller buttons handled stops Android turning an unused one into a fallback key.
+ val handled = super.dispatchKeyEvent(event)
+ val fromController = event.source and android.view.InputDevice.SOURCE_GAMEPAD == android.view.InputDevice.SOURCE_GAMEPAD ||
+ event.source and android.view.InputDevice.SOURCE_JOYSTICK == android.view.InputDevice.SOURCE_JOYSTICK
+ return handled || (notice == null && web != null && fromController)
+ }
+
+ private var menuPage by androidx.compose.runtime.mutableStateOf("")
+
+ private fun openMenu() {
+ if (menu != null || web == null) return
+ web?.evaluateJavascript("window.__ddInput && window.__ddInput(false)", null)
+ menuPage = ""
+ val regions = session?.regionList?.map { it.name }.orEmpty()
+ val view = androidx.compose.ui.platform.ComposeView(this)
+ view.setContent {
+ com.droiddeck.launcher.ui.DroidDeckTheme {
+ var current by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(settings) }
+ val entries = androidx.compose.runtime.remember { List(6) { androidx.compose.ui.focus.FocusRequester() } }
+ androidx.compose.runtime.LaunchedEffect(menuPage) {
+ if (menuPage.isEmpty()) runCatching { entries[lastMainEntry.coerceIn(0, 5)].requestFocus() }
+ }
+ val cs = androidx.compose.material3.MaterialTheme.colorScheme
+ androidx.compose.foundation.layout.Box(androidx.compose.ui.Modifier.fillMaxSize()) {
+ androidx.compose.foundation.layout.Column(
+ androidx.compose.ui.Modifier.fillMaxHeight().width(400.dp).background(cs.surface.copy(alpha = 0.95f))
+ .verticalScroll(androidx.compose.foundation.rememberScrollState()).padding(vertical = 12.dp),
+ ) {
+ androidx.compose.material3.Text(intent.getStringExtra("title").orEmpty().ifEmpty { "Xbox Cloud Gaming" },
+ style = androidx.compose.material3.MaterialTheme.typography.titleMedium, color = cs.onSurface,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
+ if (menuPage.isEmpty()) {
+ MenuEntry("Resume", "Back to the game", entries[0], 0) { closeMenu() }
+ MenuEntry("Xbox menu", "The game's Xbox menu (also: Guide once, or View + Menu)", entries[1], 1) {
+ closeMenu(); web?.evaluateJavascript("window.__ddNexus && window.__ddNexus()", null)
+ }
+ MenuEntry("Screen effects", "Sharpen, colour, deband, FXAA, CRT, NTSC, Toon, fps cap", entries[2], 2) { menuPage = "picture" }
+ MenuEntry("Stream quality", "Resolution, region, language, codec, bitrate (next stream)", entries[3], 3) { menuPage = "stream" }
+ MenuEntry("Performance overlay and sound", "Overlay level and layout, volume, controller rumble", entries[4], 4) { menuPage = "overlay" }
+ MenuEntry("Leave", "End the stream", entries[5], 5) { finish() }
+ androidx.compose.material3.Text("Guide twice opens this menu; Back or Guide closes it.",
+ style = androidx.compose.material3.MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 8.dp))
+ } else {
+ MenuEntry("‹ Back", null) { menuPage = "" }
+ if (menuPage == "stream") MenuEntry("Restart the stream with these settings",
+ "Ends this cloud session and starts a new one; the game restarts, unsaved progress is lost.") { restartStream() }
+ val page = menuPage
+ XboxCloudSettingsPanel(current, regions, live = true, section = page, restoreRow = lastRow[page] ?: 0,
+ onRowFocused = { lastRow[page] = it }, startedWith = startedWith) { changed ->
+ current = changed
+ settings = changed
+ XboxCloudSettings.save(this@XboxCloudPlayerActivity, changed)
+ web?.evaluateJavascript("window.__ddApply && window.__ddApply(${JSONObject.quote(pageSettings(changed))})", null)
+ }
+ }
+ }
+ }
+ }
+ }
+ menu = view
+ root.addView(view, FrameLayout.LayoutParams(-1, -1))
+ view.requestFocus()
+ }
+
+ private fun pageSettings(s: XboxCloudSettings): String = JSONObject(s.toJson())
+ .put("server", session?.let { active -> active.regionList.firstOrNull { it.baseUri == active.baseUri }?.name } ?: "").toString()
+
+ private var lastMainEntry = 0
+ private val lastRow = mutableMapOf()
+
+ @androidx.compose.runtime.Composable
+ private fun MenuEntry(title: String, note: String?, focus: androidx.compose.ui.focus.FocusRequester? = null, index: Int = -1, onClick: () -> Unit) =
+ XboxMenuEntry(title, note, focus, { if (index >= 0) lastMainEntry = index }, onClick)
+
+ private fun restartStream() {
+ val active = session; val path = sessionPath
+ sessionPath = null
+ closeMenu()
+ showNotice("Restarting the stream…", withButtons = false)
+ Thread({
+ if (active != null && path != null) runCatching { XboxCloudSession.request(active, "DELETE", "/$path") }
+ .onSuccess { diag("cloud player restart: session closed ${it.status}") }
+ runOnUiThread { if (!isFinishing) { startActivity(playerIntent(this, intent.getStringExtra("product").orEmpty(), intent.getStringExtra("title").orEmpty())); finish() } }
+ }, "xcloud-restart").start()
+ }
+
+ private fun closeMenu() {
+ menu?.let { root.removeView(it) }
+ menu = null
+ web?.evaluateJavascript("window.__ddInput && window.__ddInput(true)", null)
+ web?.requestFocus()
+ }
+
+ override fun onDestroy() {
+ closed = true
+ web?.let { it.evaluateJavascript("window.__ddStop && window.__ddStop()", null); root.removeView(it); it.destroy() }
+ web = null
+ val active = session; val path = sessionPath
+ if (active != null && path != null) Thread({
+ runCatching { XboxCloudSession.request(active, "DELETE", "/$path") }
+ .onSuccess { diag("cloud player session closed: ${it.status}") }
+ }, "xcloud-stop").start()
+ worker.shutdownNow(); signalling.shutdownNow()
+ super.onDestroy()
+ }
+
+ private fun diag(text: String) = StoresState.logLine("Xbox: $text")
+
+ companion object {
+ private const val DOUBLE_PRESS_MS = 350L
+
+ fun intent(context: Context, productId: String, title: String): Intent = Intent(context, XboxCloudPlayerActivity::class.java)
+ .putExtra("product", productId.uppercase()).putExtra("title", title)
+
+ /** The player the settings pick: the native engine (frame generation) where it can run, else the web player. */
+ fun playerIntent(context: Context, productId: String, title: String): Intent {
+ val native = XboxNativePlayerActivity.supported() && XboxCloudSettings.load(context).playerEngine == "native"
+ return if (!native) intent(context, productId, title) else Intent(context, XboxNativePlayerActivity::class.java)
+ .putExtra("product", productId.uppercase()).putExtra("title", title)
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt
new file mode 100644
index 0000000000..ca21202781
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt
@@ -0,0 +1,120 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import org.json.JSONArray
+import org.json.JSONObject
+import java.net.HttpURLConnection
+import java.net.URL
+
+/** Streaming-service tokens stay in memory only. Request shapes follow Greenlight / xal-node by unknownskl (MIT). */
+internal object XboxCloudSession {
+ class Region(val name: String, val baseUri: String, val isDefault: Boolean)
+
+ class Session(val account: String, val token: String, val offering: String, val baseUri: String, val regionList: List,
+ val userToken: String?, internal val expiresAt: Long,
+ val osName: String = "windows") {
+ val fresh get() = System.currentTimeMillis() < expiresAt - 5 * 60_000L
+ val regions get() = regionList.size
+
+ fun forStream(regionName: String, os: String): Session = Session(account, token, offering,
+ regionList.firstOrNull { it.name == regionName }?.baseUri ?: baseUri, regionList, userToken, expiresAt, os)
+ }
+
+ @Volatile private var cached: Session? = null
+
+ /** One fetch at a time (about 20 s: two ticket exchanges); a second caller waits and gets the same tokens. */
+ @Synchronized
+ fun get(app: Context, account: String): Session {
+ cached?.takeIf { it.account == account && it.fresh }?.let { return it }
+ val json = Xodus.run(app, listOf("cloud-token"), timeout = 60)
+ require(json.getInt("schema") == 1 && json.getString("account") == account)
+ val array = json.getJSONArray("regions")
+ val regions = (0 until array.length()).map { array.getJSONObject(it) }
+ .map { Region(it.getString("name"), it.getString("baseUri"), it.optBoolean("isDefault")) }
+ val default = regions.firstOrNull { it.isDefault } ?: regions.firstOrNull() ?: error("No Xbox Cloud Gaming region")
+ val seconds = json.optLong("durationInSeconds").coerceIn(0, 24 * 3600)
+ return Session(account, json.getString("gsToken"), json.getString("offering"), default.baseUri, regions,
+ json.optString("userToken").takeIf { !json.isNull("userToken") && it.isNotEmpty() }, System.currentTimeMillis() + seconds * 1000).also { cached = it }
+ }
+
+ fun clear() { cached = null; titleIds = null }
+
+ /**
+ * For the native player's own process: the main process's tokens (it keeps them, and fetches them ahead while a
+ * cloud game's page is open), handed over in memory through XboxCloudTokenService; null if that is not reachable.
+ */
+ fun fromMainProcess(app: Context, account: String, timeoutSeconds: Long = 90): Session? {
+ cached?.takeIf { it.account == account && it.fresh }?.let { return it }
+ val reply = XboxCloudTokenService.request(app, account, timeoutSeconds) ?: return null
+ reply.getString("error")?.let { error(it) }
+ return fromBundle(reply).takeIf { it.account == account && it.fresh }?.also { cached = it }
+ }
+
+ internal fun toBundle(s: Session) = android.os.Bundle().apply {
+ putString("account", s.account); putString("token", s.token); putString("offering", s.offering)
+ putString("baseUri", s.baseUri); putString("userToken", s.userToken); putLong("expiresAt", s.expiresAt)
+ putStringArrayList("regionNames", ArrayList(s.regionList.map { it.name }))
+ putStringArrayList("regionUris", ArrayList(s.regionList.map { it.baseUri }))
+ putBooleanArray("regionDefaults", s.regionList.map { it.isDefault }.toBooleanArray())
+ }
+
+ internal fun fromBundle(b: android.os.Bundle): Session {
+ val names = b.getStringArrayList("regionNames").orEmpty()
+ val uris = b.getStringArrayList("regionUris").orEmpty()
+ val defaults = b.getBooleanArray("regionDefaults") ?: BooleanArray(0)
+ val regions = names.indices.map { Region(names[it], uris.getOrElse(it) { "" }, defaults.getOrElse(it) { false }) }
+ return Session(b.getString("account").orEmpty(), b.getString("token").orEmpty(), b.getString("offering").orEmpty(),
+ b.getString("baseUri").orEmpty(), regions, b.getString("userToken"), b.getLong("expiresAt"))
+ }
+
+ @Volatile private var titleIds: Pair>? = null
+
+ fun titles(session: Session): Map {
+ titleIds?.takeIf { it.first == session.account }?.let { return it.second }
+ val reply = request(session, "GET", "/v2/titles")
+ check(reply.status == 200) { "Xbox Cloud Gaming answered ${reply.status}" }
+ val results = JSONObject(reply.body).optJSONArray("results") ?: JSONArray()
+ val map = (0 until results.length()).mapNotNull { index ->
+ val row = results.optJSONObject(index) ?: return@mapNotNull null
+ val product = row.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty()
+ val title = row.optString("titleId")
+ if (product.matches(Regex("[A-Z0-9]{12}")) && title.isNotBlank() && title.length <= 64) product to title else null
+ }.toMap()
+ titleIds = session.account to map
+ return map
+ }
+
+ class Reply(val status: Int, val body: String)
+
+ fun request(session: Session, method: String, path: String, body: String? = null): Reply {
+ val connection = URL(session.baseUri + path).openConnection() as HttpURLConnection
+ try {
+ connection.connectTimeout = 15_000; connection.readTimeout = 30_000
+ connection.requestMethod = method
+ connection.setRequestProperty("Authorization", "Bearer ${session.token}")
+ connection.setRequestProperty("Accept", "application/json")
+ connection.setRequestProperty("Content-Type", "application/json")
+ connection.setRequestProperty("X-Gssv-Client", "XboxComBrowser")
+ connection.setRequestProperty("X-MS-Device-Info", deviceInfo(session.osName))
+ if (body != null) {
+ connection.doOutput = true
+ connection.outputStream.use { it.write(body.toByteArray(Charsets.UTF_8)) }
+ }
+ val status = connection.responseCode
+ val stream = if (status in 200..299) connection.inputStream else connection.errorStream
+ val text = stream?.use { it.readBytes() }?.also { require(it.size <= 16_000_000) } ?: ByteArray(0)
+ return Reply(status, String(text, Charsets.UTF_8))
+ } finally { connection.disconnect() }
+ }
+
+ private fun deviceInfo(os: String) = JSONObject()
+ .put("appInfo", JSONObject().put("env", JSONObject().put("clientAppId", "www.xbox.com").put("clientAppType", "browser")
+ .put("clientAppVersion", "21.1.98").put("clientSdkVersion", "8.5.3").put("httpEnvironment", "prod").put("sdkInstallId", "")))
+ .put("dev", JSONObject()
+ .put("hw", JSONObject().put("make", "Microsoft").put("model", "unknown").put("sdktype", "web"))
+ .put("os", JSONObject().put("name", os).put("ver", "22631.2715").put("platform", "desktop"))
+ .put("displayInfo", JSONObject().put("dimensions", JSONObject().put("widthInPixels", 1920).put("heightInPixels", 1080))
+ .put("pixelDensity", JSONObject().put("dpiX", 2).put("dpiY", 2)))
+ .put("browser", JSONObject().put("browserName", "chrome").put("browserVersion", "119.0")))
+ .toString()
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettings.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettings.kt
new file mode 100644
index 0000000000..7b8806a36e
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettings.kt
@@ -0,0 +1,108 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import org.json.JSONObject
+
+data class XboxCloudSettings(
+ val resolution: String = "1080p", // 720p | 1080p | 1080p_hq
+ val region: String = "", // "" = Microsoft's choice
+ val language: String = "", // "" = the device's language
+ val codec: String = "default", // default | high | normal | low
+ val bitrateMbps: Int = 0, // 0 = no cap
+ val preventDrops: Boolean = false,
+ val statsLevel: Int = 0, // 0 off, 1 fps, 2 basic, 3 detailed, 4 full
+ val statsLayout: String = "horizontal",
+ val statsCorner: String = "right", // right | left
+ val volume: Int = 100, // 100..300 %
+ val rumble: Int = 100, // 0..100 %
+ val maxFps: Int = 0,
+ val brightness: Int = 0,
+ val contrast: Int = 0,
+ val gamma: Float = 1f,
+ val saturation: Int = 100,
+ val sharpen: Int = 0,
+ val sharpenMode: String = "cas", // cas | usm
+ val deband: Int = 0,
+ val fxaa: Boolean = false,
+ val toon: Boolean = false,
+ val crt: Boolean = false,
+ val ntsc: Boolean = false,
+ val playerEngine: String = "web", // web | native (WebRTC library + DroidDeck's compositor, frame generation)
+ val frameGen: String = "ddfg", // native engine: off | ddfg (2x) | lsfg | lsfg3 | lsfg4 (needs Lossless.dll)
+ val fpsLimit: Int = 0, // native engine target: 0 = the screen's rate, else 30/45/60/120/144/165
+ val fpsCustomOn: Boolean = false, // use fpsCustom instead of the presets
+ val fpsCustom: Int = 60, // 10..165
+ val instantInput: Boolean = true, // native: send controller changes at once (else every 16 ms)
+ val smallBuffer: Boolean = false, // native: WebRTC shows frames as soon as decoded (no playout delay)
+ val fastDecoder: Boolean = true, // native: the hardware decoder's low-latency mode
+ val zeroCopy: Boolean = false, // native, frame generation off: decode straight onto the screen
+) {
+ /** The native engine's frame-rate target (0 = the screen's own rate). */
+ val fpsTarget get() = if (fpsCustomOn) fpsCustom else fpsLimit
+
+ /** The service picks the stream resolution from the reported OS (Better xCloud's mapping). */
+ val osName get() = when (resolution) { "720p" -> "android"; "1080p_hq" -> "tizen"; else -> "windows" }
+
+ fun toJson(): String = JSONObject()
+ .put("resolution", resolution).put("region", region).put("language", language).put("codec", codec)
+ .put("bitrateMbps", bitrateMbps).put("preventDrops", preventDrops).put("statsLevel", statsLevel).put("statsLayout", statsLayout).put("statsCorner", statsCorner)
+ .put("volume", volume).put("rumble", rumble).put("maxFps", maxFps).put("brightness", brightness).put("contrast", contrast)
+ .put("gamma", gamma.toDouble()).put("saturation", saturation).put("sharpen", sharpen).put("sharpenMode", sharpenMode)
+ .put("deband", deband).put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
+ .put("playerEngine", playerEngine).put("frameGen", frameGen)
+ .put("fpsLimit", fpsLimit).put("fpsCustomOn", fpsCustomOn).put("fpsCustom", fpsCustom)
+ .put("instantInput", instantInput).put("smallBuffer", smallBuffer).put("fastDecoder", fastDecoder).put("zeroCopy", zeroCopy)
+ .toString()
+
+ fun withoutEffects() = copy(brightness = 0, contrast = 0, gamma = 1f, saturation = 100, sharpen = 0, sharpenMode = "cas",
+ deband = 0, fxaa = false, toon = false, crt = false, ntsc = false)
+
+ companion object {
+ private const val PREFS = "xbox_cloud"
+ private const val KEY = "settings"
+
+ fun load(context: Context): XboxCloudSettings =
+ decode(context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY, null))
+
+ internal fun decode(text: String?): XboxCloudSettings = runCatching {
+ val json = JSONObject(text ?: return XboxCloudSettings())
+ val d = XboxCloudSettings()
+ XboxCloudSettings(
+ resolution = json.optString("resolution", d.resolution).takeIf { it in setOf("720p", "1080p", "1080p_hq") } ?: d.resolution,
+ region = json.optString("region", d.region).take(64), language = json.optString("language", d.language).take(16),
+ codec = json.optString("codec", d.codec).takeIf { it in setOf("default", "high", "normal", "low") } ?: d.codec,
+ bitrateMbps = json.optInt("bitrateMbps", d.bitrateMbps).coerceIn(0, 100),
+ preventDrops = json.optBoolean("preventDrops", d.preventDrops),
+ statsLevel = json.optInt("statsLevel", d.statsLevel).coerceIn(0, 4),
+ statsLayout = json.optString("statsLayout", d.statsLayout).takeIf { it == "vertical" } ?: "horizontal",
+ statsCorner = json.optString("statsCorner", d.statsCorner).takeIf { it == "left" } ?: "right",
+ volume = json.optInt("volume", d.volume).coerceIn(100, 300), rumble = json.optInt("rumble", d.rumble).coerceIn(0, 100),
+ maxFps = json.optInt("maxFps", d.maxFps).coerceIn(0, 120),
+ brightness = json.optInt("brightness", d.brightness).coerceIn(-50, 50), contrast = json.optInt("contrast", d.contrast).coerceIn(-100, 100),
+ gamma = json.optDouble("gamma", 1.0).toFloat().coerceIn(0.5f, 3f), saturation = json.optInt("saturation", d.saturation).coerceIn(0, 200),
+ sharpen = json.optInt("sharpen", d.sharpen).coerceIn(0, 10),
+ sharpenMode = json.optString("sharpenMode", d.sharpenMode).takeIf { it == "usm" } ?: "cas",
+ deband = json.optInt("deband", d.deband).coerceIn(0, 8),
+ fxaa = json.optBoolean("fxaa"), toon = json.optBoolean("toon"), crt = json.optBoolean("crt"), ntsc = json.optBoolean("ntsc"),
+ playerEngine = json.optString("playerEngine", d.playerEngine).takeIf { it == "native" } ?: "web",
+ frameGen = json.optString("frameGen", d.frameGen).let { if (it == "winfg") "ddfg" else it }
+ .takeIf { it in setOf("off", "ddfg", "lsfg", "lsfg3", "lsfg4") } ?: d.frameGen,
+ fpsLimit = json.optInt("fpsLimit", d.fpsLimit).takeIf { it in setOf(0, 30, 45, 60, 120, 144, 165) } ?: 0,
+ fpsCustomOn = json.optBoolean("fpsCustomOn", d.fpsCustomOn),
+ fpsCustom = json.optInt("fpsCustom", d.fpsCustom).coerceIn(10, 165),
+ instantInput = json.optBoolean("instantInput", d.instantInput), smallBuffer = json.optBoolean("smallBuffer", d.smallBuffer),
+ fastDecoder = json.optBoolean("fastDecoder", d.fastDecoder), zeroCopy = json.optBoolean("zeroCopy", d.zeroCopy),
+ )
+ }.getOrDefault(XboxCloudSettings())
+
+ fun save(context: Context, settings: XboxCloudSettings) {
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY, settings.toJson()).apply()
+ }
+
+ val LANGUAGES = listOf("" to "Device language", "en-US" to "English (US)", "en-GB" to "English (UK)", "de-DE" to "Deutsch",
+ "es-ES" to "Español (España)", "es-MX" to "Español (México)", "fr-FR" to "Français", "it-IT" to "Italiano",
+ "ja-JP" to "日本語", "ko-KR" to "한국어", "nl-NL" to "Nederlands", "pl-PL" to "Polski", "pt-BR" to "Português (Brasil)",
+ "pt-PT" to "Português (Portugal)", "ru-RU" to "Русский", "sv-SE" to "Svenska", "tr-TR" to "Türkçe", "zh-CN" to "中文 (简体)",
+ "zh-TW" to "中文 (繁體)")
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsActivity.kt
new file mode 100644
index 0000000000..bfe1e3908e
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsActivity.kt
@@ -0,0 +1,60 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedButton
+import androidx.compose.material3.Text
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import com.droiddeck.launcher.stores.Store
+import com.droiddeck.launcher.stores.StoreAccounts
+import com.droiddeck.launcher.ui.DroidDeckTheme
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+
+class XboxCloudSettingsActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ DroidDeckTheme {
+ var settings by remember { mutableStateOf(XboxCloudSettings.load(this)) }
+ var regions by remember { mutableStateOf(emptyList()) }
+ LaunchedEffect(Unit) {
+ regions = withContext(Dispatchers.IO) {
+ runCatching {
+ val account = StoreAccounts.signedInAs(applicationContext, Store.XBOX) ?: return@runCatching emptyList()
+ XboxCloudSession.get(applicationContext, account).regionList.map { it.name }
+ }.getOrDefault(emptyList())
+ }
+ }
+ Column(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background).verticalScroll(rememberScrollState())) {
+ Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
+ OutlinedButton(onClick = { finish() }) { Text("Back") }
+ Text("Xbox Cloud Gaming", style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold,
+ color = MaterialTheme.colorScheme.onBackground, modifier = Modifier.padding(horizontal = 16.dp))
+ }
+ XboxCloudSettingsPanel(settings, regions, live = false) { changed ->
+ settings = changed
+ XboxCloudSettings.save(this@XboxCloudSettingsActivity, changed)
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt
new file mode 100644
index 0000000000..0a09fd7890
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt
@@ -0,0 +1,313 @@
+package com.droiddeck.launcher.stores.xbox
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.widthIn
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedButton
+import androidx.compose.material3.Switch
+import androidx.compose.material3.Text
+import androidx.compose.foundation.border
+import androidx.compose.foundation.background
+import androidx.compose.foundation.focusable
+import androidx.compose.foundation.gestures.detectTapGestures
+import androidx.compose.runtime.rememberUpdatedState
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.foundation.layout.RowScope
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.compositionLocalOf
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusProperties
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.input.key.Key
+import androidx.compose.ui.input.key.KeyEventType
+import androidx.compose.ui.input.key.key
+import androidx.compose.ui.input.key.onKeyEvent
+import androidx.compose.ui.input.key.type
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+
+/** Shared by the Xbox cloud settings page and the in-player menu; [live] changes reach the running stream. */
+@Composable
+fun XboxCloudSettingsPanel(
+ settings: XboxCloudSettings,
+ regions: List,
+ live: Boolean,
+ /** "stream", "picture" or "overlay" shows that section only; null shows all. */
+ section: String? = null,
+ /** The row to select when the panel opens (the last one used), or null for no initial selection. */
+ restoreRow: Int? = null,
+ onRowFocused: (Int) -> Unit = {},
+ /** The settings the running stream started with; rows that differ say they need a restart (null: no stream). */
+ startedWith: XboxCloudSettings? = null,
+ onChange: (XboxCloudSettings) -> Unit,
+) {
+ val focus = remember(section) { PanelFocus() }
+ focus.next = 0
+ focus.onFocused = onRowFocused
+ CompositionLocalProvider(LocalPanelFocus provides focus) {
+ PanelContent(settings, regions, live, section, startedWith, onChange)
+ }
+ LaunchedEffect(section) {
+ if (restoreRow != null) runCatching { focus.requester(restoreRow.coerceIn(0, (focus.count - 1).coerceAtLeast(0))).requestFocus() }
+ }
+}
+
+/** Gives each settings row its place in the page, so the last-used row can be selected again. */
+private class PanelFocus {
+ var next = 0
+ var count = 0
+ var onFocused: (Int) -> Unit = {}
+ private val requesters = mutableMapOf()
+ fun requester(index: Int) = requesters.getOrPut(index) { FocusRequester() }
+ fun take(): Int = next++.also { count = maxOf(count, next) }
+}
+
+private val LocalPanelFocus = compositionLocalOf { null }
+
+@Composable
+private fun PanelContent(
+ settings: XboxCloudSettings,
+ regions: List,
+ live: Boolean,
+ section: String?,
+ startedWith: XboxCloudSettings?,
+ onChange: (XboxCloudSettings) -> Unit,
+) {
+ // Stream-start settings changed during a stream wait for a restart; back at the starting value, no note.
+ fun pending(differs: (XboxCloudSettings) -> Boolean) = startedWith != null && differs(startedWith)
+
+ if (section == null || section == "stream") Section("Stream", if (live) "Applies to the next stream." else "Applies when a stream starts.") {
+ if (XboxNativePlayerActivity.supported()) {
+ Choice("Player engine", listOf("web" to "Web", "native" to "Native (frame gen)"), settings.playerEngine,
+ pending { it.playerEngine != settings.playerEngine }) { onChange(settings.copy(playerEngine = it)) }
+ val ctx = androidx.compose.ui.platform.LocalContext.current
+ val lsfg = androidx.compose.runtime.remember { XboxNativeVideo.lsfgReady(ctx) }
+ Choice("Frame generation", XboxNativeVideo.modes(lsfg).map { it to XboxNativeVideo.modeName(it) }, settings.frameGen) {
+ onChange(settings.copy(frameGen = it))
+ }
+ Text("Native engine (experimental): Google's WebRTC and DroidDeck's own compositor, so DroidDeck frame generation " +
+ "(DDFG) or LSFG can add frames. LSFG uses the Lossless.dll DroidDeck already uses for games. Screen effects " +
+ "apply to the web engine.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(start = 8.dp, bottom = 6.dp))
+ }
+ // The service picks the size from the reported device profile (the PC profile can send 1440p).
+ Choice("Resolution", listOf("720p" to "720p (phone)", "1080p" to "Best (PC)", "1080p_hq" to "1080p HQ (TV)"),
+ settings.resolution, pending { it.resolution != settings.resolution }) { onChange(settings.copy(resolution = it)) }
+ Choice("Server region", listOf("" to "Automatic") + regions.map { it to it }, settings.region,
+ pending { it.region != settings.region }) { onChange(settings.copy(region = it)) }
+ Choice("Game language", XboxCloudSettings.LANGUAGES, settings.language,
+ pending { it.language != settings.language }) { onChange(settings.copy(language = it)) }
+ Choice("Video codec quality", listOf("default" to "Automatic", "high" to "High", "normal" to "Normal", "low" to "Low"), settings.codec,
+ pending { it.codec != settings.codec }) { onChange(settings.copy(codec = it)) }
+ Choice("Bitrate limit", listOf(0 to "No limit") + listOf(5, 8, 10, 12, 15, 20, 25, 30, 40, 50).map { it to "$it Mb/s" }, settings.bitrateMbps,
+ pending { it.bitrateMbps != settings.bitrateMbps }) { onChange(settings.copy(bitrateMbps = it)) }
+ Toggle("Stop quality drops", "Keeps the resolution up when this device decodes slowly.", settings.preventDrops) { onChange(settings.copy(preventDrops = it)) }
+ }
+
+ if (section == null || section == "picture") Section("Picture", "Shader effects on the stream.") {
+ Step("Brightness", "${settings.brightness}", { onChange(settings.copy(brightness = (settings.brightness - 5).coerceAtLeast(-50))) },
+ { onChange(settings.copy(brightness = (settings.brightness + 5).coerceAtMost(50))) })
+ Step("Contrast", "${settings.contrast}", { onChange(settings.copy(contrast = (settings.contrast - 10).coerceAtLeast(-100))) },
+ { onChange(settings.copy(contrast = (settings.contrast + 10).coerceAtMost(100))) })
+ Step("Gamma", String.format("%.1f", settings.gamma), { onChange(settings.copy(gamma = ((settings.gamma * 10).toInt() - 1).coerceAtLeast(5) / 10f)) },
+ { onChange(settings.copy(gamma = ((settings.gamma * 10).toInt() + 1).coerceAtMost(30) / 10f)) })
+ Step("Saturation", "${settings.saturation}%", { onChange(settings.copy(saturation = (settings.saturation - 10).coerceAtLeast(0))) },
+ { onChange(settings.copy(saturation = (settings.saturation + 10).coerceAtMost(200))) })
+ Step("Sharpen", if (settings.sharpen == 0) "Off" else "${settings.sharpen}", { onChange(settings.copy(sharpen = (settings.sharpen - 1).coerceAtLeast(0))) },
+ { onChange(settings.copy(sharpen = (settings.sharpen + 1).coerceAtMost(10))) })
+ Choice("Sharpen type", listOf("cas" to "Contrast-adaptive", "usm" to "Unsharp mask"), settings.sharpenMode) { onChange(settings.copy(sharpenMode = it)) }
+ Step("Deband", if (settings.deband == 0) "Off" else "${settings.deband}", { onChange(settings.copy(deband = (settings.deband - 1).coerceAtLeast(0))) },
+ { onChange(settings.copy(deband = (settings.deband + 1).coerceAtMost(8))) })
+ Toggle("FXAA", "Smooths jagged edges.", settings.fxaa) { onChange(settings.copy(fxaa = it)) }
+ Toggle("CRT", "Scanlines and colour fringes.", settings.crt) { onChange(settings.copy(crt = it)) }
+ Toggle("NTSC", "Old TV signal look.", settings.ntsc) { onChange(settings.copy(ntsc = it)) }
+ Toggle("Toon", "Cartoon outlines.", settings.toon) { onChange(settings.copy(toon = it)) }
+ Choice("Frame-rate cap", listOf(0 to "Off", 30 to "30 fps", 45 to "45 fps", 60 to "60 fps"), settings.maxFps) { onChange(settings.copy(maxFps = it)) }
+ Row(Modifier.fillMaxWidth().padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ OutlinedButton(onClick = { onChange(settings.withoutEffects()) }) { Text("Reset picture") }
+ }
+ Text("Effects cost a little GPU time; with none set the stream is shown directly.", style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(top = 4.dp))
+ }
+
+ if ((section == null && XboxNativePlayerActivity.supported()) || section == "framerate") Section("Frame rate (native engine)",
+ "With frame generation this is the rate shown; without it, only targets below the stream's 60 fps change anything.") {
+ Choice("Target", listOf(0 to "Screen's rate", 30 to "30 fps", 45 to "45 fps", 60 to "60 fps", 120 to "120 fps", 144 to "144 fps", 165 to "165 fps"),
+ settings.fpsLimit) { onChange(settings.copy(fpsLimit = it, fpsCustomOn = false)) }
+ Toggle("Custom frame rate", "Set any rate from 10 to 165 fps with the slider.", settings.fpsCustomOn) { onChange(settings.copy(fpsCustomOn = it)) }
+ if (settings.fpsCustomOn) SliderRow("Custom", settings.fpsCustom, 10, 165) { onChange(settings.copy(fpsCustom = it)) }
+ }
+
+ if ((section == null && XboxNativePlayerActivity.supported()) || section == "latency") Section("Low latency (native engine)", null) {
+ Toggle("Instant controller input", "Sends each press the moment it happens instead of every 16 ms.", settings.instantInput) {
+ onChange(settings.copy(instantInput = it))
+ }
+ Toggle("Small network buffer", "Shows frames as soon as they are decoded. Less delay; may stutter on weak Wi-Fi.",
+ settings.smallBuffer, pending { it.smallBuffer != settings.smallBuffer }) { onChange(settings.copy(smallBuffer = it)) }
+ Toggle("Fast decoder", "The video chip's low-latency mode.", settings.fastDecoder,
+ pending { it.fastDecoder != settings.fastDecoder }) { onChange(settings.copy(fastDecoder = it)) }
+ Toggle("Zero-copy picture", "Frames go straight from the video chip to the screen: the lowest delay. Used while frame generation is off and no target below 60 fps is set; switches live.",
+ settings.zeroCopy) { onChange(settings.copy(zeroCopy = it)) }
+ }
+
+ // "overlay-native": the native player's page (its sound has no volume boost).
+ if (section == null || section == "overlay" || section == "overlay-native") Section("Overlay and sound", null) {
+ Choice("Performance overlay", listOf(0 to "Off", 1 to "FPS only", 2 to "Basic", 3 to "Detailed", 4 to "Full"), settings.statsLevel) {
+ onChange(settings.copy(statsLevel = it))
+ }
+ Choice("Overlay layout", listOf("horizontal" to "Horizontal", "vertical" to "Vertical"), settings.statsLayout) { onChange(settings.copy(statsLayout = it)) }
+ Choice("Overlay position", listOf("right" to "Top right", "left" to "Top left"), settings.statsCorner) { onChange(settings.copy(statsCorner = it)) }
+ Text("Basic: fps, ping, resolution. Detailed: + bitrate, decode time, packet loss. Full: + codec, jitter, " +
+ "dropped frames, server.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ if (section != "overlay-native") Step("Volume", "${settings.volume}%", { onChange(settings.copy(volume = (settings.volume - 25).coerceAtLeast(100))) },
+ { onChange(settings.copy(volume = (settings.volume + 25).coerceAtMost(300))) })
+ Step("Controller rumble", if (settings.rumble == 0) "Off" else "${settings.rumble}%", { onChange(settings.copy(rumble = (settings.rumble - 25).coerceAtLeast(0))) },
+ { onChange(settings.copy(rumble = (settings.rumble + 25).coerceAtMost(100))) })
+ }
+}
+
+@Composable
+private fun Section(title: String, note: String?, content: @Composable ColumnScope.() -> Unit) {
+ Column(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp)) {
+ Text(title, style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.primary)
+ if (note != null) Text(note, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ Spacer(Modifier.height(4.dp))
+ content()
+ }
+}
+
+/**
+ * One settings row, driven by a controller: it takes focus as a whole (highlighted), Left / Right change its
+ * value, A / Enter selects; the − / + buttons and switches inside stay for touch only.
+ */
+@Composable
+private fun SettingRow(
+ onLeft: (() -> Unit)?,
+ onRight: (() -> Unit)?,
+ onSelect: (() -> Unit)?,
+ content: @Composable RowScope.() -> Unit,
+) {
+ val panel = LocalPanelFocus.current
+ val index = panel?.take() ?: -1
+ var focused by remember { mutableStateOf(false) }
+ val currentSelect by rememberUpdatedState(onSelect)
+ val cs = MaterialTheme.colorScheme
+ val shape = RoundedCornerShape(10.dp)
+ Row(
+ Modifier.fillMaxWidth().padding(vertical = 1.dp).clip(shape)
+ .background(if (focused) cs.primary.copy(alpha = 0.16f) else Color.Transparent)
+ .border(2.dp, if (focused) cs.primary else Color.Transparent, shape)
+ .let { if (panel != null && index >= 0) it.focusRequester(panel.requester(index)) else it }
+ .onFocusChanged { state -> focused = state.isFocused; if (state.isFocused && index >= 0) panel?.onFocused?.invoke(index) }
+ .onKeyEvent { event ->
+ if (event.type != KeyEventType.KeyDown) return@onKeyEvent false
+ val action = when (event.key) {
+ Key.DirectionLeft -> onLeft
+ Key.DirectionRight -> onRight
+ Key.Enter, Key.NumPadEnter, Key.DirectionCenter, Key.ButtonA -> onSelect
+ else -> null
+ }
+ if (action != null) { action(); true } else false
+ }
+ .focusable()
+ // A tap selects too, without a second focus stop (a clickable would be one).
+ .pointerInput(Unit) { detectTapGestures { currentSelect?.invoke() } }
+ .padding(horizontal = 8.dp, vertical = 4.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ content = content,
+ )
+}
+
+private val noFocus = Modifier.focusProperties { canFocus = false }
+
+@Composable
+private fun Step(label: String, value: String, onMinus: () -> Unit, onPlus: () -> Unit) {
+ SettingRow(onLeft = onMinus, onRight = onPlus, onSelect = onPlus) {
+ Text(label, Modifier.weight(1f), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface)
+ OutlinedButton(onClick = onMinus, modifier = noFocus.size(40.dp), contentPadding = PaddingValues(0.dp)) { Text("−") }
+ Text(value, Modifier.widthIn(min = 112.dp, max = 168.dp).padding(horizontal = 4.dp), textAlign = TextAlign.Center,
+ style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ OutlinedButton(onClick = onPlus, modifier = noFocus.size(40.dp), contentPadding = PaddingValues(0.dp)) { Text("+") }
+ }
+}
+
+/** A value slider (touch) that a controller moves with Left / Right in steps of 1 (hold to repeat). */
+@Composable
+private fun SliderRow(label: String, value: Int, min: Int, max: Int, onValue: (Int) -> Unit) {
+ SettingRow(onLeft = { onValue((value - 1).coerceAtLeast(min)) }, onRight = { onValue((value + 1).coerceAtMost(max)) }, onSelect = null) {
+ Text(label, Modifier.width(72.dp), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface)
+ androidx.compose.material3.Slider(value = value.toFloat(), onValueChange = { onValue(it.toInt().coerceIn(min, max)) },
+ valueRange = min.toFloat()..max.toFloat(), modifier = noFocus.weight(1f))
+ Text("$value fps", Modifier.width(72.dp), textAlign = TextAlign.End, style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurface)
+ }
+}
+
+@Composable
+private fun Choice(label: String, options: List>, selected: T, needsRestart: Boolean = false, onSelect: (T) -> Unit) {
+ val index = options.indexOfFirst { it.first == selected }.coerceAtLeast(0)
+ Step(label, options.getOrNull(index)?.second ?: "",
+ { if (options.isNotEmpty()) onSelect(options[(index - 1 + options.size) % options.size].first) },
+ { if (options.isNotEmpty()) onSelect(options[(index + 1) % options.size].first) })
+ if (needsRestart) Text("Takes effect when you restart the stream.", style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.tertiary, modifier = Modifier.padding(start = 8.dp, bottom = 4.dp))
+}
+
+@Composable
+private fun Toggle(label: String, note: String, checked: Boolean, needsRestart: Boolean = false, onToggle: (Boolean) -> Unit) {
+ SettingRow(onLeft = { onToggle(false) }, onRight = { onToggle(true) }, onSelect = { onToggle(!checked) }) {
+ Column(Modifier.weight(1f)) {
+ Text(label, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface)
+ Text(note, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ }
+ Spacer(Modifier.width(8.dp))
+ Switch(checked = checked, onCheckedChange = onToggle, modifier = noFocus)
+ }
+ if (needsRestart) Text("Takes effect when you restart the stream.", style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.tertiary, modifier = Modifier.padding(start = 8.dp, bottom = 4.dp))
+}
+
+/** One entry of the cloud players' menu list (highlighted when selected; A or a tap opens it). */
+@Composable
+internal fun XboxMenuEntry(title: String, note: String?, focus: FocusRequester? = null, onFocused: () -> Unit = {}, onClick: () -> Unit) {
+ val cs = MaterialTheme.colorScheme
+ var focused by remember { mutableStateOf(false) }
+ val shape = RoundedCornerShape(10.dp)
+ androidx.compose.material3.Surface(
+ onClick = onClick, color = if (focused) cs.primary.copy(alpha = 0.2f) else cs.surfaceContainerHigh, shape = shape,
+ border = if (focused) androidx.compose.foundation.BorderStroke(2.dp, cs.primary) else null,
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 3.dp)
+ .let { if (focus != null) it.focusRequester(focus) else it }
+ .onFocusChanged { state -> focused = state.isFocused; if (state.isFocused) onFocused() }
+ .onKeyEvent { event -> if (event.type == KeyEventType.KeyDown && event.key == Key.ButtonA) { onClick(); true } else false },
+ ) {
+ Column(Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) {
+ Text(title, style = MaterialTheme.typography.titleSmall, color = cs.onSurface)
+ if (note != null) Text(note, style = MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant)
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSignalling.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSignalling.kt
new file mode 100644
index 0000000000..a5e7587af9
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSignalling.kt
@@ -0,0 +1,74 @@
+package com.droiddeck.launcher.stores.xbox
+
+import org.json.JSONArray
+import org.json.JSONObject
+
+/** Request shapes follow Microsoft's web player as Greenlight (MIT) implements them. */
+internal class XboxCloudSignalling(
+ private val session: XboxCloudSession.Session,
+ private val titleId: String,
+ private val settings: XboxCloudSettings,
+) {
+ @Volatile var path: String? = null
+ private set
+
+ fun op(op: String, arg: String = ""): XboxCloudSession.Reply = when (op) {
+ "start" -> start()
+ "state" -> XboxCloudSession.request(session, "GET", "/$path/state")
+ "connect" -> connect()
+ "sdp" -> sdp(arg)
+ "ice" -> ice(arg)
+ "keepalive" -> XboxCloudSession.request(session, "POST", "/$path/keepalive", "{}")
+ else -> XboxCloudSession.Reply(0, "unknown request")
+ }
+
+ fun start(): XboxCloudSession.Reply {
+ val body = JSONObject().put("clientSessionId", "").put("titleId", titleId).put("systemUpdateGroup", "")
+ .put("settings", JSONObject().put("nanoVersion", "V3;WebrtcTransport.dll").put("enableOptionalDataCollection", false)
+ .put("enableTextToSpeech", false).put("highContrast", 0).put("locale", settings.language.ifEmpty { java.util.Locale.getDefault().toLanguageTag() })
+ .put("useIceConnection", false).put("timezoneOffsetMinutes", java.util.TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 60_000)
+ .put("sdkType", "web").put("osName", settings.osName))
+ .put("serverId", "").put("fallbackRegionNames", JSONArray())
+ return XboxCloudSession.request(session, "POST", "/v5/sessions/cloud/play", body.toString()).also { reply ->
+ if (reply.status in 200..299) path = JSONObject(reply.body).getString("sessionPath").trim('/')
+ }
+ }
+
+ fun connect(): XboxCloudSession.Reply {
+ val token = session.userToken ?: return XboxCloudSession.Reply(0, "no cloud transfer token for this account")
+ return XboxCloudSession.request(session, "POST", "/$path/connect", JSONObject().put("userToken", token).toString())
+ }
+
+ fun sdp(offer: String): XboxCloudSession.Reply {
+ val body = JSONObject().put("messageType", "offer").put("sdp", offer).put("requestId", "1").put("configuration", JSONObject()
+ .put("chatConfiguration", JSONObject().put("bytesPerSample", 2).put("expectedClipDurationMs", 20)
+ .put("format", JSONObject().put("codec", "opus").put("container", "webm")).put("numChannels", 1).put("sampleFrequencyHz", 24000))
+ .put("chat", version(1, 1)).put("control", version(1, 3)).put("input", version(1, 9)).put("message", version(1, 1))
+ .put("reliableinput", version(9, 9)).put("unreliableinput", version(9, 9)))
+ val posted = XboxCloudSession.request(session, "POST", "/$path/sdp", body.toString())
+ return if (posted.status !in 200..299) posted else poll("/$path/sdp")
+ }
+
+ fun ice(candidates: String): XboxCloudSession.Reply {
+ val posted = XboxCloudSession.request(session, "POST", "/$path/ice", JSONObject().put("candidates", JSONArray(candidates)).toString())
+ return if (posted.status !in 200..299) posted else poll("/$path/ice")
+ }
+
+ fun stop(): XboxCloudSession.Reply? {
+ val current = path ?: return null
+ path = null
+ return runCatching { XboxCloudSession.request(session, "DELETE", "/$current") }.getOrNull()
+ }
+
+ private fun version(min: Int, max: Int) = JSONObject().put("minVersion", min).put("maxVersion", max)
+
+ /** The exchange answers 204 until the console has replied. */
+ private fun poll(path: String): XboxCloudSession.Reply {
+ repeat(60) {
+ val reply = XboxCloudSession.request(session, "GET", path)
+ if (reply.status != 204) return reply
+ Thread.sleep(500)
+ }
+ return XboxCloudSession.Reply(0, "no answer from the cloud console")
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudTokenService.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudTokenService.kt
new file mode 100644
index 0000000000..03df4c19d4
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudTokenService.kt
@@ -0,0 +1,74 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.app.Service
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
+import android.content.ServiceConnection
+import android.os.Bundle
+import android.os.Handler
+import android.os.HandlerThread
+import android.os.IBinder
+import android.os.Looper
+import android.os.Message
+import android.os.Messenger
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.Executors
+import java.util.concurrent.TimeUnit
+
+/**
+ * Hands the main process's Xbox Cloud Gaming tokens to the native player's process (:xcloudnative) over Binder, so
+ * they stay in memory (not exported, same app only) and a stream does not wait for a second ~20 s token fetch.
+ */
+class XboxCloudTokenService : Service() {
+ private val worker = Executors.newSingleThreadExecutor()
+ private val messenger = Messenger(Handler(Looper.getMainLooper()) { message ->
+ val replyTo = message.replyTo ?: return@Handler true
+ val account = message.data?.getString("account").orEmpty()
+ worker.execute {
+ val reply = Message.obtain(null, REPLY)
+ reply.data = runCatching { XboxCloudSession.toBundle(XboxCloudSession.get(applicationContext, account)) }
+ .getOrElse { Bundle().apply { putString("error", it.message ?: it.javaClass.simpleName) } }
+ runCatching { replyTo.send(reply) }
+ }
+ true
+ })
+
+ override fun onBind(intent: Intent?): IBinder = messenger.binder
+
+ override fun onDestroy() { worker.shutdown(); super.onDestroy() }
+
+ companion object {
+ private const val REQUEST = 1
+ private const val REPLY = 2
+
+ /** Blocks until the main process answers (its tokens, or "error"), or returns null when it cannot be reached. */
+ fun request(context: Context, account: String, timeoutSeconds: Long): Bundle? {
+ val app = context.applicationContext
+ val done = CountDownLatch(1)
+ var answer: Bundle? = null
+ val thread = HandlerThread("xcloud-token").apply { start() }
+ val replies = Messenger(Handler(thread.looper) { message ->
+ if (message.what == REPLY) { answer = message.data; done.countDown() }
+ true
+ })
+ val connection = object : ServiceConnection {
+ override fun onServiceConnected(name: ComponentName?, binder: IBinder?) {
+ val ask = Message.obtain(null, REQUEST).apply { data = Bundle().apply { putString("account", account) }; replyTo = replies }
+ if (binder == null || runCatching { Messenger(binder).send(ask) }.isFailure) done.countDown()
+ }
+ override fun onServiceDisconnected(name: ComponentName?) { done.countDown() }
+ }
+ val bound = runCatching { app.bindService(Intent(app, XboxCloudTokenService::class.java), connection, Context.BIND_AUTO_CREATE) }
+ .getOrDefault(false)
+ try {
+ if (!bound) return null
+ done.await(timeoutSeconds, TimeUnit.SECONDS)
+ return answer
+ } finally {
+ if (bound) runCatching { app.unbindService(connection) }
+ thread.quitSafely()
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCredentials.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCredentials.kt
index 40cd28225b..f969c20ebb 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCredentials.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCredentials.kt
@@ -14,6 +14,11 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
val name = "droiddeck-xbox-${UUID.randomUUID()}"
private val generation = lifecycle(app, expectedGeneration) { it }
private val server = LocalServerSocket(name)
+ // Some devices refuse the abstract socket from inside PRoot; the backend then falls back to this keyed loopback port.
+ private val loopback = java.net.ServerSocket(0, 8, java.net.InetAddress.getByAddress(byteArrayOf(127, 0, 0, 1)))
+ val port: Int get() = loopback.localPort
+ val key: String = ByteArray(32).also { java.security.SecureRandom().nextBytes(it) }.joinToString("") { "%02x".format(it) }
+ @Volatile private var loopbackUsed = false
@Volatile private var closed = false
private val bound = java.util.concurrent.CountDownLatch(1)
private var backend: Process? = null
@@ -29,10 +34,16 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
}
private fun rejected(reason: String): Boolean {
- android.util.Log.w("XboxCredentials", "Rejected credential peer: $reason")
+ note("Rejected credential peer: $reason")
return false
}
+ /** Also written to the stores log: sign-in runs in its own process, where only that file reaches a shared log. */
+ private fun note(text: String) {
+ android.util.Log.w("XboxCredentials", text)
+ com.droiddeck.launcher.stores.StoreLogFiles.stamped(app, "Xbox credentials: $text")
+ }
+
private fun authorized(pid: Int): Boolean {
if (!bound.await(5, java.util.concurrent.TimeUnit.SECONDS) || closed) return rejected("unbound")
val process = backend ?: return rejected("missing-child")
@@ -73,33 +84,122 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
} }
}
- init {
- Thread({
- while (!closed) {
- val socket = runCatching { server.accept() }.getOrNull() ?: break
- socket.use {
- it.soTimeout = 10_000
- val reply = runCatching {
- val peer = it.peerCredentials
- check(peer.uid == android.os.Process.myUid() && authorized(peer.pid))
- val request = JSONObject(readLine(it.inputStream.buffered(), 2_097_152))
- storage(app) {
- check(!closed && epoch(app) == generation && authorized(peer.pid))
- answer(request)
- }
- }.getOrElse {
- android.util.Log.w("XboxCredentials", "Credential request rejected: ${it.javaClass.simpleName}")
- JSONObject().put("ok", false)
- }
- runCatching { it.outputStream.write((reply.toString() + "\n").toByteArray()) }
- }
+ /** Each connection gets its own thread; an accept error is logged and retried instead of silently ending the loop. */
+ private fun listen(route: String, accept: () -> S, serve: (S) -> Unit) = Thread({
+ var failures = 0
+ while (!closed) {
+ val socket = try { accept() } catch (e: Exception) {
+ if (closed) break
+ failures++
+ note("Credential $route accept failed: ${e.javaClass.simpleName}")
+ if (failures >= 20) { note("Credential $route listener stopped after repeated accept failures"); break }
+ Thread.sleep(100)
+ continue
}
- }, "xbox-credentials").start()
+ failures = 0
+ Thread({ serve(socket) }, "xbox-credentials-$route-request").start()
+ }
+ }, "xbox-credentials-$route").start()
+
+ /** Logs requests that take 2 s or more, and the stage a request is still in after 8 s (the backend waits 30 s). */
+ private fun tracked(route: String, block: (step: (String) -> Unit) -> JSONObject): JSONObject {
+ val started = android.os.SystemClock.elapsedRealtime()
+ val stage = java.util.concurrent.atomic.AtomicReference("auth")
+ val done = java.util.concurrent.CountDownLatch(1)
+ val stages = java.util.Collections.synchronizedList(mutableListOf())
+ var mark = started
+ val step = { next: String ->
+ val now = android.os.SystemClock.elapsedRealtime()
+ stages += "${stage.getAndSet(next)} ${now - mark} ms"
+ mark = now
+ }
+ Thread({
+ if (!done.await(8, java.util.concurrent.TimeUnit.SECONDS)) note("Credential $route request still in ${stage.get()} after 8 s")
+ }, "xbox-credentials-watch").apply { isDaemon = true; start() }
+ try {
+ return block(step)
+ } finally {
+ done.countDown()
+ step("done")
+ val total = android.os.SystemClock.elapsedRealtime() - started
+ if (total >= 2000) note("Credential $route request took $total ms (${stages.joinToString(", ")})")
+ }
}
- private fun answer(request: JSONObject): JSONObject {
+ init {
+ listen("socket", { server.accept() }) { socket ->
+ socket.use {
+ it.soTimeout = 10_000
+ val reply = tracked("socket") { step ->
+ runCatching {
+ val peer = it.peerCredentials
+ check(peer.uid == android.os.Process.myUid() && authorized(peer.pid))
+ step("read")
+ val request = JSONObject(readLine(it.inputStream.buffered(), 2_097_152))
+ step("lock")
+ storage(app) {
+ step("answer")
+ check(!closed && epoch(app) == generation && authorized(peer.pid))
+ answer(request, step)
+ }
+ }.getOrElse {
+ note("Credential request rejected: ${it.javaClass.simpleName}")
+ JSONObject().put("ok", false)
+ }
+ }
+ runCatching { it.outputStream.write((reply.toString() + "\n").toByteArray()) }
+ .onFailure { failure -> note("Credential reply not delivered: ${failure.javaClass.simpleName}") }
+ }
+ }
+ listen("loopback", { loopback.accept() }) { socket ->
+ socket.use {
+ it.soTimeout = 10_000
+ val reply = tracked("loopback") { step ->
+ runCatching {
+ val input = it.getInputStream().buffered()
+ check(it.inetAddress.isLoopbackAddress)
+ if (!java.security.MessageDigest.isEqual(readLine(input, 128).toByteArray(), key.toByteArray())) {
+ rejected("loopback-key"); error("loopback key")
+ }
+ if (!loopbackOwner(it.port)) { rejected("loopback-owner"); error("loopback owner") }
+ check(bound.await(5, java.util.concurrent.TimeUnit.SECONDS) && backend?.isAlive == true)
+ if (!loopbackUsed) { loopbackUsed = true; note("Backend reached the app over the loopback fallback") }
+ step("read")
+ val request = JSONObject(readLine(input, 2_097_152))
+ step("lock")
+ storage(app) {
+ step("answer")
+ check(!closed && epoch(app) == generation)
+ answer(request, step)
+ }
+ }.getOrElse { failure ->
+ note("Credential request rejected: ${failure.javaClass.simpleName}")
+ JSONObject().put("ok", false)
+ }
+ }
+ runCatching { it.getOutputStream().write((reply.toString() + "\n").toByteArray()) }
+ .onFailure { failure -> note("Credential reply not delivered: ${failure.javaClass.simpleName}") }
+ }
+ }
+ }
+
+ /** The connecting socket must belong to this app's user; an unreadable table (newer Android) leaves the key as the check. */
+ private fun loopbackOwner(peerPort: Int): Boolean {
+ val uid = android.os.Process.myUid()
+ val rows = listOf("/proc/net/tcp", "/proc/net/tcp6").mapNotNull { runCatching { java.io.File(it).readLines().drop(1) }.getOrNull() }.flatten()
+ val owners = rows.mapNotNull { row ->
+ val fields = row.trim().split(Regex("\\s+"))
+ val local = fields.getOrNull(1)?.substringAfterLast(':')?.toIntOrNull(16)
+ val remote = fields.getOrNull(2)?.substringAfterLast(':')?.toIntOrNull(16)
+ if (local == peerPort && remote == loopback.localPort) fields.getOrNull(7)?.toIntOrNull() else null
+ }
+ return owners.isEmpty() || owners.all { it == uid }
+ }
+
+ private fun answer(request: JSONObject, step: (String) -> Unit = {}): JSONObject {
val key = request.getString("key")
require(key.isNotEmpty() && key.length <= 512)
+ step("record-read")
val record = StoreAccounts.read(app, Store.XBOX)
check(!StoreAccounts.isUnavailable(Store.XBOX))
val json = record ?: JSONObject()
@@ -112,15 +212,16 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
require(bytes.length() <= 262_144)
for (i in 0 until bytes.length()) require(bytes.getInt(i) in 0..255)
slots.put(key, bytes)
+ step("record-save")
StoreAccounts.write(app, Store.XBOX, json)
}
- "remove" -> { slots.remove(key); StoreAccounts.write(app, Store.XBOX, json) }
+ "remove" -> { slots.remove(key); step("record-save"); StoreAccounts.write(app, Store.XBOX, json) }
else -> error("Invalid credential operation")
}
return result
}
- override fun close() { closed = true; bound.countDown(); runCatching { server.close() } }
+ override fun close() { closed = true; bound.countDown(); runCatching { server.close() }; runCatching { loopback.close() } }
companion object {
val lock = Any()
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxGamertag.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxGamertag.kt
new file mode 100644
index 0000000000..b065e8bafe
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxGamertag.kt
@@ -0,0 +1,51 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import com.droiddeck.launcher.stores.Store
+import com.droiddeck.launcher.stores.StoreAccounts
+import com.droiddeck.launcher.stores.StoresState
+/** Keeps the account's Xbox gamertag in its record so the Stores page can show it instead of the sign-in email. */
+internal object XboxGamertag {
+ /** `xodus-cli profile` allows itself 45 s, and starting it through PRoot adds to that. */
+ private const val TIMEOUT_SECONDS = 75L
+ private val triedGeneration = java.util.concurrent.atomic.AtomicReference(null)
+
+ internal fun valid(value: String): Boolean = value.isNotEmpty() && value.length <= 64 && value.none { it.isISOControl() }
+
+ /** Reads the gamertag with `xodus-cli profile` and stores it; false when Xbox didn't return one. */
+ fun refresh(app: Context, credentialGeneration: String? = null): Boolean = try {
+ val gamertag = Xodus.run(app, listOf("profile", "--json"), timeout = TIMEOUT_SECONDS, credentialGeneration = credentialGeneration)
+ .optString("gamertag").trim()
+ require(valid(gamertag))
+ XboxCredentials.lifecycle(app, credentialGeneration) {
+ val record = StoreAccounts.read(app, Store.XBOX) ?: error("Xbox credentials missing")
+ record.put("gamertag", gamertag)
+ StoreAccounts.write(app, Store.XBOX, record)
+ }
+ StoresState.logLine("Xbox: gamertag read")
+ true
+ } catch (e: Exception) {
+ StoresState.logLine("Xbox: gamertag unavailable (${XboxLoginActivity.failure(e)})")
+ false
+ }
+
+ /** Fetches a missing gamertag once per signed-in account, on its own thread so it never holds up a library sync. */
+ fun ensure(app: Context) {
+ Thread({
+ runCatching {
+ val generation = XboxCredentials.lifecycle(app) { it }
+ if (!StoreAccounts.read(app, Store.XBOX)?.optString("gamertag").isNullOrBlank()) return@runCatching
+ if (!shouldTryRefresh(generation)) return@runCatching
+ if (refresh(app, generation)) StoresState.refresh(app)
+ }.onFailure { StoresState.logLine("Xbox: gamertag check failed (${it.javaClass.simpleName})") }
+ }, "xbox-gamertag").start()
+ }
+
+ internal fun shouldTryRefresh(generation: String): Boolean {
+ while (true) {
+ val previous = triedGeneration.get()
+ if (previous == generation) return false
+ if (triedGeneration.compareAndSet(previous, generation)) return true
+ }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt
index 44e9ceff33..3d02e4db57 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt
@@ -39,11 +39,17 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog
var sequence = -1L
try {
val source = if (content) selected else item.id
+ val guestFolder = StoreInstallRoot.guestPathForXodus(app, folder)
val selection = if (content) emptyList() else listOf("--selected-content-id", selected)
- Xodus.start(app, listOf("streaming", source, folder.path, "--market", market,
+ Xodus.start(app, listOf("streaming", source, guestFolder, "--market", market,
"--progress-json", "--control-stdin") + selection).use { process ->
child = process
- val diagnostics = Xodus.diagnostics(process)
+ val rejected = AtomicBoolean(false)
+ val rejectedLine = Regex(Xodus.SIGN_IN_REJECTED)
+ val diagnostics = Xodus.diagnostics(process) { line ->
+ StoresState.logLine("Xbox: $line")
+ if (line.matches(rejectedLine)) rejected.set(true)
+ }
if (cancelled.get()) process.process.destroy()
process.process.inputStream.bufferedReader().useLines { lines -> lines.forEach { line ->
if (line.startsWith("NEXUS_PROGRESS ")) {
@@ -62,6 +68,7 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog
check(process.process.waitFor(15, TimeUnit.SECONDS)) { "Xbox installer did not exit." }
diagnostics.join(2000)
if (cancelled.get()) return null
+ check(!rejected.get()) { app.getString(com.droiddeck.launcher.R.string.stores_xbox_sign_in_again) }
check(process.process.exitValue() == 0 && complete) { "Xbox download did not complete. Resume to retry with fresh licenses." }
}
if (content) {
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryCache.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryCache.kt
index bf9e7ee703..5de1abcac8 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryCache.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryCache.kt
@@ -23,18 +23,19 @@ internal object XboxLibraryCache {
fun clear(app: Context) { prefs(app).edit().remove("library").commit() }
internal fun encode(account: String, market: String, games: List, now: Long = System.currentTimeMillis()): String =
- JSONObject().put("schema", 1).put("account", account).put("market", market).put("savedAt", now)
+ JSONObject().put("schema", 2).put("account", account).put("market", market).put("savedAt", now)
.put("games", JSONArray().apply {
for (game in games) put(JSONObject().put("id", game.id).put("title", game.title)
.put("image", game.imageUrl).put("poster", game.tallImageUrl).put("description", game.description)
.put("developer", game.developer).put("publisher", game.publisher).put("size", game.sizeBytes)
- .put("access", if (game.subscription) "gamepass" else if (game.owned) "owned" else "none"))
+ .put("access", if (game.subscription) "gamepass" else if (game.owned) "owned" else "none")
+ .put("pc", game.xboxPc).put("cloud", game.xboxCloud).put("cloudId", game.extra["cloudId"].orEmpty()))
}).toString()
internal fun decode(text: String?, account: String, market: String, now: Long = System.currentTimeMillis()): Snapshot? = runCatching {
require(text != null && text.length <= 8_000_000)
val json = JSONObject(text)
- require(json.getInt("schema") == 1 && json.getString("account") == account && json.getString("market") == market)
+ require(json.getInt("schema") == 2 && json.getString("account") == account && json.getString("market") == market)
val savedAt = json.getLong("savedAt")
require(savedAt > 0 && savedAt <= now + 60_000)
val rows = json.getJSONArray("games")
@@ -44,12 +45,14 @@ internal object XboxLibraryCache {
val id = row.getString("id")
val title = row.getString("title")
val access = row.getString("access")
+ val cloudId = row.optString("cloudId").takeIf { it.matches(Regex("[A-Z0-9]{12}")) }.orEmpty()
require(id.matches(Regex("[A-Z0-9]{12}")) && title.isNotBlank() && access in setOf("owned", "gamepass"))
CatalogItem(Store.XBOX, id, title, row.optString("image").takeIf { it.isNotEmpty() },
tallImageUrl = row.optString("poster").takeIf { it.isNotEmpty() },
description = row.optString("description"), developer = row.optString("developer"), publisher = row.optString("publisher"),
sizeBytes = row.optLong("size"), owned = access == "owned", subscription = access == "gamepass",
- storeUrl = "https://www.xbox.com/games/store/$id", extra = mapOf("market" to market, "access" to access))
+ storeUrl = "https://www.xbox.com/games/store/$id", extra = mapOf("market" to market, "access" to access,
+ "pc" to XboxCatalog.flag(row.getBoolean("pc")), "cloud" to XboxCatalog.flag(row.getBoolean("cloud")), "cloudId" to cloudId))
}
require(games.map { it.id }.distinct().size == games.size)
Snapshot(games, savedAt)
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryFilter.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryFilter.kt
new file mode 100644
index 0000000000..3e3e001d7b
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLibraryFilter.kt
@@ -0,0 +1,41 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import com.droiddeck.launcher.stores.CatalogItem
+
+object XboxLibraryFilter {
+ const val ALL = "all"
+ const val OWNED = "owned"
+ const val GAME_PASS = "gamepass"
+ const val CLOUD = "cloud"
+ val ALL_FILTERS = listOf(ALL, OWNED, GAME_PASS, CLOUD)
+
+ var current by mutableStateOf(ALL)
+ private set
+
+ fun load(context: Context) {
+ current = context.getSharedPreferences("xbox", Context.MODE_PRIVATE).getString("libraryFilter", ALL)?.takeIf { it in ALL_FILTERS } ?: ALL
+ }
+
+ fun set(context: Context, filter: String) {
+ current = filter
+ context.getSharedPreferences("xbox", Context.MODE_PRIVATE).edit().putString("libraryFilter", filter).apply()
+ }
+
+ fun keeps(filter: String, item: CatalogItem): Boolean = when (filter) {
+ OWNED -> item.owned
+ GAME_PASS -> item.subscription
+ CLOUD -> item.xboxCloud
+ else -> true
+ }
+
+ fun label(filter: String): String = when (filter) {
+ OWNED -> "Owned"
+ GAME_PASS -> "Game Pass"
+ CLOUD -> "Cloud"
+ else -> "All"
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLoginActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLoginActivity.kt
index 01e19158f1..10fc5ea71a 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLoginActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLoginActivity.kt
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
+import android.util.Log
import android.webkit.CookieManager
import android.webkit.WebResourceRequest
import android.webkit.WebView
@@ -14,8 +15,11 @@ import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.webkit.WebViewCompat
import androidx.webkit.WebViewFeature
+import com.droiddeck.launcher.core.AddonPack
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreAccounts
+import com.droiddeck.launcher.stores.StoreLogFiles
+import com.droiddeck.launcher.stores.StoreLog
import org.json.JSONObject
import java.util.concurrent.TimeUnit
@@ -26,6 +30,8 @@ class XboxLoginActivity : ComponentActivity() {
@Volatile private var child: Xodus.Child? = null
@Volatile private var session = 0L
@Volatile private var closed = false
+ @Volatile private var step = "starting"
+ private val codes = java.util.concurrent.CopyOnWriteArrayList()
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
@@ -48,11 +54,30 @@ class XboxLoginActivity : ComponentActivity() {
Thread({
if (closed) return@Thread
try {
+ // A record without a username is left from a sign-in that never finished; starting clean
+ // also avoids reading it back with an older, slow Keystore key.
+ progress("preparing the sign-in", "Preparing Microsoft sign-in…")
+ val leftover = StoreAccounts.read(applicationContext, Store.XBOX)
+ if (leftover != null && leftover.optString("username").isBlank()) {
+ XboxCredentials.invalidate(applicationContext)
+ logStep("discarded credentials from an unfinished sign-in")
+ }
val accountGeneration = XboxCredentials.lifecycle(applicationContext) { it }
+ progress("downloading the Xbox components", "Downloading Xbox components…")
+ check(AddonPack.XBOX.await(applicationContext, { !closed }) { state ->
+ if (state is AddonPack.State.Downloading) show("Downloading Xbox components… ${(state.progress * 100).toInt()}%")
+ }) { "Couldn't download the Xbox components. Check your connection and try again." }
+ if (closed) return@Thread
+ progress("starting the Xbox helper", "Starting the Xbox helper…")
Xodus.start(applicationContext, listOf("--external-webview-stdio", "login"), credentialGeneration = accountGeneration).use { process ->
child = process
if (closed) return@use
- Xodus.diagnostics(process)
+ // StoresState.logLine writes no file in this process, so the reason would miss the shared log.
+ Xodus.diagnostics(process) { line ->
+ logStep(line)
+ line.removePrefix("NEXUS_CREDENTIAL_ERROR_V1 ").takeIf { it != line && it !in codes && codes.size < 6 }?.let(codes::add)
+ }
+ progress("waiting for the Xbox helper", "Waiting for the Xbox helper…")
val timer = Thread({
runCatching { if (!process.process.waitFor(10, TimeUnit.MINUTES)) process.process.destroy() }
}, "xbox-login-timeout").apply { start() }
@@ -68,16 +93,19 @@ class XboxLoginActivity : ComponentActivity() {
check(!ready && frame.getInt("version") == 1)
ready = true
process.send(JSONObject().put("type", "hello").put("version", 1))
+ progress("waiting for Microsoft's sign-in page", "Opening Microsoft sign-in…")
}
"open" -> {
val next = frame.getLong("session")
check(ready && next > latest && next <= 32 && trusted(frame.getString("url")))
latest = next; session = next
+ step = "loading Microsoft's sign-in page"
runOnUiThread { if (!closed) open(frame) }
}
"close" -> {
check(frame.getLong("session") == session)
session = 0L
+ step = "completing the sign-in"
runOnUiThread { disposeView(); status.text = "Completing Microsoft sign-in…" }
}
"context" -> {
@@ -95,26 +123,53 @@ class XboxLoginActivity : ComponentActivity() {
else -> error("Unsupported Xbox sign-in response")
}
}
- check(process.process.waitFor(5, TimeUnit.SECONDS) && process.process.exitValue() == 0 && ready && latest > 0 && session == 0L)
+ if (closed) return@use
+ check(process.process.waitFor(5, TimeUnit.SECONDS)) { "the Xbox helper did not exit" }
+ val exit = process.process.exitValue()
+ check(exit == 0) { "the Xbox helper stopped with exit code $exit" }
+ check(ready) { "the Xbox helper never became ready" }
+ check(latest > 0) { "Microsoft's sign-in page was never requested" }
+ check(session == 0L) { "the sign-in page was closed before Microsoft finished" }
timer.interrupt()
}
child = null
if (closed) return@Thread
+ step = "saving the account"
val account = Xodus.run(applicationContext, listOf("account", "--json"), credentialGeneration = accountGeneration)
- check(account.optBoolean("stored"))
+ check(account.optBoolean("stored")) { "Xbox did not save the account" }
XboxCredentials.lifecycle(this, accountGeneration) {
val record = StoreAccounts.read(this, Store.XBOX) ?: error("Xbox credentials missing")
record.put("username", account.getString("username"))
StoreAccounts.write(this, Store.XBOX, record)
}
+ logStep("signed in")
runOnUiThread { finish() }
} catch (e: Exception) {
child = null
- if (!closed) runOnUiThread { disposeView(); status.text = "Microsoft sign-in did not complete. Close this window and try again." }
+ if (closed) return@Thread
+ val failed = step
+ val reason = failure(e)
+ logStep("failed while $failed: $reason")
+ runOnUiThread {
+ disposeView()
+ val details = if (codes.isEmpty()) "" else "\nDetails: ${codes.joinToString(", ")}"
+ status.text = "Microsoft sign-in did not complete.\nFailed while $failed: $reason$details\nClose this window and try again."
+ }
}
}, "xbox-login").start()
}
+ private fun show(text: String) = runOnUiThread { if (!closed && view == null) status.text = text }
+
+ private fun progress(name: String, text: String) { step = name; show(text) }
+
+ /** Written to the stores log, which the shared log zip carries; the main process's log helpers don't run in this process. */
+ private fun logStep(line: String) {
+ val text = StoreLog.redactLine("Xbox sign-in: $line")
+ Log.i(TAG, text)
+ StoreLogFiles.stamped(applicationContext, text)
+ }
+
@SuppressLint("SetJavaScriptEnabled")
private fun open(frame: JSONObject) {
disposeView()
@@ -172,6 +227,15 @@ class XboxLoginActivity : ComponentActivity() {
}
companion object {
+ private const val TAG = "XboxLogin"
+
+ /** Our own check messages are safe to show; anything else is named by its type, never its text, which may hold sign-in data. */
+ internal fun failure(e: Exception): String {
+ val message = e.message.orEmpty()
+ return if (e is IllegalStateException && message.isNotBlank() && message != "Check failed." && message.length <= 160) message
+ else e.javaClass.simpleName.ifBlank { "error" }
+ }
+
private val hosts = setOf("login.live.com", "account.live.com", "login.microsoftonline.com", "login.microsoft.com", "account.microsoft.com", "sisu.xboxlive.com")
private val origins = hosts.map { "https://$it" }.toSet()
private val allowedHeaders = setOf("cxh-capabilities", "cxh-correlationid", "cxh-msabinaryversion", "cxh-identityclientbinaryversion", "cxh-osversioninfo", "cxh-platform", "cxh-protocol", "cxh-source", "hostapp")
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePad.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePad.kt
new file mode 100644
index 0000000000..661023d542
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePad.kt
@@ -0,0 +1,80 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.view.InputDevice
+import android.view.KeyEvent
+import android.view.MotionEvent
+
+/**
+ * Controller state for the native cloud player, from Android key and motion events (no Gamepad API). Button
+ * bits follow the xCloud input report (Greenlight's packet.ts): Nexus 2, Menu 4, View 8, A 16, B 32, X 64,
+ * Y 128, D-pad 256..2048, shoulders 4096 / 8192, stick clicks 16384 / 32768.
+ */
+internal class XboxNativePad {
+ data class State(val buttons: Int, val lx: Float, val ly: Float, val rx: Float, val ry: Float, val lt: Float, val rt: Float) {
+ /** Greenlight's rule: any button change, a stick moved past 0.08 or held past 0.15, a trigger past 0.01. */
+ fun differsFrom(o: State): Boolean = buttons != o.buttons ||
+ listOf(lx to o.lx, ly to o.ly, rx to o.rx, ry to o.ry).any { (a, b) -> Math.abs(a - b) > 0.08f || Math.abs(a) > 0.15f } ||
+ Math.abs(lt - o.lt) > 0.01f || Math.abs(rt - o.rt) > 0.01f
+ }
+
+ @Volatile private var buttons = 0
+ @Volatile private var hatButtons = 0
+ @Volatile private var lx = 0f; @Volatile private var ly = 0f
+ @Volatile private var rx = 0f; @Volatile private var ry = 0f
+ @Volatile private var lt = 0f; @Volatile private var rt = 0f
+ /** Called after any change (instant controller input). */
+ @Volatile var onChanged: (() -> Unit)? = null
+
+ /** Buttons pressed on behalf of the app (the menu's Xbox button), OR-ed in. */
+ @Volatile var overrideButtons = 0
+
+ fun snapshot() = State(buttons or hatButtons or overrideButtons, lx, ly, rx, ry, lt, rt)
+
+ /** True when the event was a controller button this pad tracks. */
+ fun onKey(event: KeyEvent): Boolean {
+ val bit = when (event.keyCode) {
+ KeyEvent.KEYCODE_BUTTON_A -> 16
+ KeyEvent.KEYCODE_BUTTON_B -> 32
+ KeyEvent.KEYCODE_BUTTON_X -> 64
+ KeyEvent.KEYCODE_BUTTON_Y -> 128
+ KeyEvent.KEYCODE_DPAD_UP -> 256
+ KeyEvent.KEYCODE_DPAD_DOWN -> 512
+ KeyEvent.KEYCODE_DPAD_LEFT -> 1024
+ KeyEvent.KEYCODE_DPAD_RIGHT -> 2048
+ KeyEvent.KEYCODE_BUTTON_L1 -> 4096
+ KeyEvent.KEYCODE_BUTTON_R1 -> 8192
+ KeyEvent.KEYCODE_BUTTON_THUMBL -> 16384
+ KeyEvent.KEYCODE_BUTTON_THUMBR -> 32768
+ KeyEvent.KEYCODE_BUTTON_START -> 4
+ KeyEvent.KEYCODE_BUTTON_SELECT -> 8
+ // Digital triggers on pads without analog axes.
+ KeyEvent.KEYCODE_BUTTON_L2 -> { lt = if (event.action == KeyEvent.ACTION_DOWN) 1f else 0f; onChanged?.invoke(); return true }
+ KeyEvent.KEYCODE_BUTTON_R2 -> { rt = if (event.action == KeyEvent.ACTION_DOWN) 1f else 0f; onChanged?.invoke(); return true }
+ else -> return false
+ }
+ buttons = if (event.action == KeyEvent.ACTION_DOWN) buttons or bit else buttons and bit.inv()
+ onChanged?.invoke()
+ return true
+ }
+
+ /** True when the event came from a joystick (sticks, triggers, hat). */
+ fun onMotion(event: MotionEvent): Boolean {
+ if (event.source and InputDevice.SOURCE_JOYSTICK != InputDevice.SOURCE_JOYSTICK || event.action != MotionEvent.ACTION_MOVE) return false
+ val device = event.device
+ fun axis(code: Int): Float {
+ val value = event.getAxisValue(code)
+ val flat = device?.getMotionRange(code, event.source)?.flat ?: 0f
+ return if (Math.abs(value) > maxOf(flat, 0.08f)) value else 0f
+ }
+ lx = axis(MotionEvent.AXIS_X); ly = axis(MotionEvent.AXIS_Y)
+ rx = axis(MotionEvent.AXIS_Z); ry = axis(MotionEvent.AXIS_RZ)
+ lt = maxOf(axis(MotionEvent.AXIS_LTRIGGER), axis(MotionEvent.AXIS_BRAKE))
+ rt = maxOf(axis(MotionEvent.AXIS_RTRIGGER), axis(MotionEvent.AXIS_GAS))
+ val hx = event.getAxisValue(MotionEvent.AXIS_HAT_X); val hy = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
+ hatButtons = (if (hy < -0.5f) 256 else 0) or (if (hy > 0.5f) 512 else 0) or (if (hx < -0.5f) 1024 else 0) or (if (hx > 0.5f) 2048 else 0)
+ onChanged?.invoke()
+ return true
+ }
+
+ fun reset() { buttons = 0; hatButtons = 0; overrideButtons = 0; lx = 0f; ly = 0f; rx = 0f; ry = 0f; lt = 0f; rt = 0f }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt
new file mode 100644
index 0000000000..97fd03a3da
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt
@@ -0,0 +1,852 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import android.content.Intent
+import android.graphics.Color
+import android.os.Build
+import android.os.Bundle
+import android.os.VibrationEffect
+import android.view.Gravity
+import android.view.KeyEvent
+import android.view.MotionEvent
+import android.view.SurfaceHolder
+import android.view.SurfaceView
+import android.view.WindowManager
+import android.widget.FrameLayout
+import android.widget.TextView
+import androidx.activity.ComponentActivity
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.input.key.Key
+import androidx.compose.ui.input.key.KeyEventType
+import androidx.compose.ui.input.key.key
+import androidx.compose.ui.input.key.onKeyEvent
+import androidx.compose.ui.input.key.type
+import androidx.compose.ui.unit.dp
+import androidx.core.view.WindowCompat
+import androidx.core.view.WindowInsetsCompat
+import androidx.core.view.WindowInsetsControllerCompat
+import org.json.JSONArray
+import org.json.JSONObject
+import org.webrtc.DataChannel
+import org.webrtc.DefaultVideoEncoderFactory
+import org.webrtc.EglBase
+import org.webrtc.IceCandidate
+import org.webrtc.MediaConstraints
+import org.webrtc.MediaStream
+import org.webrtc.MediaStreamTrack
+import org.webrtc.PeerConnection
+import org.webrtc.PeerConnectionFactory
+import org.webrtc.RtpReceiver
+import org.webrtc.RtpTransceiver
+import org.webrtc.SdpObserver
+import org.webrtc.SessionDescription
+import org.webrtc.VideoTrack
+import org.webrtc.audio.JavaAudioDeviceModule
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.Executors
+import java.util.concurrent.TimeUnit
+
+/**
+ * Native Xbox Cloud Gaming player (opt-in, Android 10+): Google's WebRTC library instead of the web page, the
+ * xCloud channels ported from Greenlight (XboxNativeProtocol), controller from Android input events, and the
+ * picture through DroidDeck's own compositor (XboxNativeVideo) so DDFG or LSFG can generate frames. Runs in
+ * its own process (:xcloudnative): that compositor instance is never the Linux session's.
+ * Sign-in and session requests are the web player's (XboxCloudSession, XboxCloudSignalling).
+ */
+class XboxNativePlayerActivity : ComponentActivity() {
+ private lateinit var root: FrameLayout
+ private lateinit var surfaceView: SurfaceView
+ private lateinit var status: TextView
+ private lateinit var overlay: TextView
+ private val worker = Executors.newSingleThreadExecutor()
+ private val ticker = Executors.newSingleThreadScheduledExecutor()
+ private val pad = XboxNativePad()
+ private var eglBase: EglBase? = null
+ private var factory: PeerConnectionFactory? = null
+ private var pc: PeerConnection? = null
+ private var protocol: XboxNativeProtocol? = null
+ private var video: XboxNativeVideo? = null
+ @Volatile private var signalling: XboxCloudSignalling? = null
+ @Volatile private var settings = XboxCloudSettings()
+ @Volatile private var closed = false
+ /** The stream reached the screen at least once (a later failure is a lost connection, not a failed start). */
+ @Volatile private var connectedOnce = false
+ /** The session was ended because the player stayed in the background (Android freezes the app soon after). */
+ @Volatile private var endedInBackground = false
+ private var backgroundEnd: Runnable? = null
+ private var notice: androidx.compose.ui.platform.ComposeView? = null
+ @Volatile private var regionNames = emptyList()
+ @Volatile private var serverName: String? = null
+ private val candidates = mutableListOf()
+ private val gathered = CountDownLatch(1)
+ private var menu: androidx.compose.ui.platform.ComposeView? = null
+ private var menuPage by androidx.compose.runtime.mutableStateOf("")
+ private var lastMainEntry = 0
+ private val lastRow = mutableMapOf()
+ /** The settings this stream started with (stream-start settings changed since then need a restart). */
+ private var startedWith: XboxCloudSettings? = null
+ /**
+ * The picture's route right now: true = zero-copy (decoder straight onto the screen), false = WebRTC's texture
+ * through the Vulkan compositor. Zero-copy whenever it is chosen and frame generation is off; switched live.
+ */
+ @Volatile private var zeroCopy = false
+ /** The SurfaceView's surface while it exists (UI thread). */
+ private var screen: android.view.Surface? = null
+ private var screenW = 0
+ private var screenH = 0
+ @Volatile private var zeroCopyFrames = 0L
+ @Volatile private var decoders: org.webrtc.DroidDeckLowLatencyDecoderFactory? = null
+ private var lastZeroCopyFrames = 0L
+ private var lastSubmitted = 0L
+ /** The release of the Guide press that opened the menu must not close it again. */
+ private var swallowGuideUp = false
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ hideBars()
+ watchBars()
+ root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) }
+ surfaceView = SurfaceView(this)
+ root.addView(surfaceView, FrameLayout.LayoutParams(-1, -1))
+ status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER }
+ root.addView(status, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 })
+ overlay = TextView(this).apply {
+ setTextColor(Color.WHITE); textSize = 12f; typeface = android.graphics.Typeface.MONOSPACE
+ setBackgroundColor(Color.argb(140, 0, 0, 0)); setPadding(12, 6, 12, 6); visibility = android.view.View.GONE
+ }
+ root.addView(overlay, FrameLayout.LayoutParams(-2, -2, Gravity.TOP or Gravity.END).apply { topMargin = 16; rightMargin = 16 })
+ setContentView(root)
+ settings = XboxCloudSettings.load(this)
+ startedWith = settings
+ applyDisplayRate(settings.fpsTarget)
+ applyOverlay()
+
+ val egl = EglBase.create().also { eglBase = it }
+ val nativeVideo = XboxNativeVideo(this, egl) { log(it) }.also { video = it }
+ surfaceView.holder.addCallback(object : SurfaceHolder.Callback {
+ override fun surfaceCreated(holder: SurfaceHolder) {}
+ override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
+ screen = holder.surface; screenW = width; screenH = height
+ // Zero-copy: the decoder owns this surface (back on it after a stand-in); the Vulkan compositor must not connect to it.
+ if (zeroCopy) { decoders?.setZeroCopySurface(holder.surface); return }
+ @Suppress("DEPRECATION")
+ nativeVideo.setSurface(holder.surface, width, height, windowManager.defaultDisplay.refreshRate)
+ }
+ override fun surfaceDestroyed(holder: SurfaceHolder) {
+ screen = null
+ if (zeroCopy) decoders?.setZeroCopySurface(null) else nativeVideo.setSurface(null, 0, 0, 60f)
+ }
+ })
+ show("Signing in to Xbox Cloud Gaming…")
+ worker.execute { runCatching { run() }.onFailure { fail("start", it.message ?: it.javaClass.simpleName) } }
+ }
+
+ private fun log(text: String) = com.droiddeck.launcher.stores.StoresState.logLine("Xbox: native player: ${text.take(240)}")
+ private fun show(text: String) = runOnUiThread { status.text = text; status.visibility = if (text.isEmpty()) android.view.View.GONE else android.view.View.VISIBLE }
+
+ private fun fail(stage: String, detail: String) {
+ log("failed at $stage: $detail")
+ if (closed) return
+ if (connectedOnce) showNotice("The connection to the cloud console was lost",
+ "The stream stopped reaching this device ($detail). Restart the stream to play again: the game starts over, " +
+ "unsaved progress is lost.", webPlayer = false)
+ else showNotice("The native stream could not start ($stage)",
+ "$detail\n\nYou can try again, or use the web player instead (Stores › Xbox › Cloud settings › Player engine).",
+ webPlayer = true)
+ }
+
+ /** One popup at a time, in the app's dialog style; A or Enter picks the selected button, Back closes the player. */
+ private fun showNotice(title: String, text: String, webPlayer: Boolean) = runOnUiThread {
+ if (notice != null || isFinishing || isDestroyed) return@runOnUiThread
+ closeMenu()
+ show("")
+ // The stream is over: stale numbers must not stay on screen.
+ overlayOn = false
+ overlay.visibility = android.view.View.GONE
+ val view = androidx.compose.ui.platform.ComposeView(this)
+ view.setContent {
+ com.droiddeck.launcher.ui.DroidDeckTheme {
+ val first = androidx.compose.runtime.remember { androidx.compose.ui.focus.FocusRequester() }
+ androidx.compose.runtime.LaunchedEffect(Unit) { androidx.compose.runtime.withFrameNanos { }; runCatching { first.requestFocus() } }
+ @androidx.compose.runtime.Composable
+ fun NoticeButton(label: String, focus: androidx.compose.ui.focus.FocusRequester?, onClick: () -> Unit) =
+ androidx.compose.material3.TextButton(onClick = onClick,
+ modifier = androidx.compose.ui.Modifier.let { if (focus != null) it.focusRequester(focus) else it }
+ .onKeyEvent { e -> if (e.type == KeyEventType.KeyDown && e.key == Key.ButtonA) { onClick(); true } else false }) {
+ androidx.compose.material3.Text(label)
+ }
+ androidx.compose.material3.AlertDialog(
+ onDismissRequest = { finish() },
+ properties = androidx.compose.ui.window.DialogProperties(dismissOnClickOutside = false),
+ title = { androidx.compose.material3.Text(title) },
+ text = { androidx.compose.material3.Text(text) },
+ confirmButton = {
+ androidx.compose.foundation.layout.Row {
+ NoticeButton(if (connectedOnce) "Restart the stream" else "Try again", first) { restartStream() }
+ if (webPlayer) NoticeButton("Open the web player", null) {
+ startActivity(Intent(this@XboxNativePlayerActivity, XboxCloudPlayerActivity::class.java).putExtras(intent)); finish()
+ }
+ }
+ },
+ dismissButton = { NoticeButton("Close", null) { finish() } },
+ )
+ }
+ }
+ notice = view
+ root.addView(view, FrameLayout.LayoutParams(-1, -1))
+ }
+
+ // ---- background ----
+
+ override fun onStop() {
+ super.onStop()
+ if (closed || isChangingConfigurations || signalling == null || endedInBackground) return
+ // Android freezes a background app about a minute after it leaves the screen; the connection then dies
+ // without a goodbye. End the session cleanly before that and offer a restart on return.
+ log("in the background")
+ val end = Runnable { backgroundEnd = null; endInBackground() }
+ backgroundEnd = end
+ root.postDelayed(end, BACKGROUND_GRACE_MS)
+ }
+
+ override fun onStart() {
+ super.onStart()
+ backgroundEnd?.let { root.removeCallbacks(it); log("back before the stream was ended") }
+ backgroundEnd = null
+ if (endedInBackground && notice == null) showNotice("The stream ended while DroidDeck was in the background",
+ "Cloud sessions are closed after ${BACKGROUND_GRACE_MS / 1000} s away, before Android pauses the app. Restart the " +
+ "stream to play again: the game starts over, unsaved progress is lost.", webPlayer = false)
+ }
+
+ private fun endInBackground() {
+ if (closed || endedInBackground) return
+ endedInBackground = true
+ closed = true
+ log("ending the session: ${BACKGROUND_GRACE_MS / 1000} s in the background")
+ val signals = signalling
+ signalling = null
+ ticker.shutdownNow()
+ runOnUiThread { overlayOn = false; overlay.visibility = android.view.View.GONE }
+ Thread({ signals?.stop()?.let { log("session closed: ${it.status}") } }, "xcloud-native-stop").start()
+ runCatching { protocol?.close() }
+ runCatching { pc?.close() }
+ }
+
+ // ---- session ----
+
+ private fun run() {
+ val account = com.droiddeck.launcher.stores.StoreAccounts.signedInAs(applicationContext, com.droiddeck.launcher.stores.Store.XBOX)
+ ?: error("Sign in to the Xbox store first.")
+ val requested = intent.getStringExtra("product").orEmpty()
+ val cached = XboxLibraryCache.read(applicationContext, account, Xodus.market())?.games?.firstOrNull { it.id == requested }
+ val product = cached?.extra?.get("cloudId")?.takeIf { it.isNotEmpty() } ?: requested
+ // The main process's tokens when it has them (no second ~20 s fetch); else this process fetches its own.
+ val shared = runCatching { XboxCloudSession.fromMainProcess(applicationContext, account) }
+ .onFailure { log("tokens from the main process: ${it.message?.take(160)}") }.getOrNull()
+ log(if (shared != null) "tokens from the main process" else "tokens fetched here")
+ val active = (shared ?: XboxCloudSession.get(applicationContext, account)).forStream(settings.region, settings.osName)
+ regionNames = active.regionList.map { it.name }
+ serverName = active.regionList.firstOrNull { it.baseUri == active.baseUri }?.name
+ val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.")
+ val signals = XboxCloudSignalling(active, title, settings).also { signalling = it }
+ log("$product -> $title, region ${java.net.URI(active.baseUri).host}, frame gen ${settings.frameGen}")
+
+ show("Starting the game on Xbox Cloud Gaming…")
+ expect("start", signals.start())
+ var connected = false
+ var waited = 0
+ while (!closed) {
+ val state = JSONObject(expect("state", signals.op("state")).body.ifEmpty { "{}" })
+ when (state.optString("state")) {
+ "Provisioned" -> break
+ "Failed" -> error("provision: ${state.optJSONObject("errorDetails")}")
+ "ReadyToConnect" -> if (!connected) { connected = true; show("Signing in to the cloud console…"); expect("connect", signals.connect()) }
+ "WaitingForResources" -> show("In the queue for a cloud console… ${waited / 1000} s")
+ else -> show("Getting a cloud console ready… ${waited / 1000} s")
+ }
+ Thread.sleep(1000); waited += 1000
+ }
+ if (closed) return
+
+ show("Connecting…")
+ // Small network buffer: no playout delay, frames go to the decoder and screen as soon as they are complete.
+ val trials = if (settings.smallBuffer) "WebRTC-ForcePlayoutDelay/min_ms:0,max_ms:0/WebRTC-ZeroPlayoutDelay/min_pacing:0ms,max_decode_queue_size:8/" else ""
+ PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(applicationContext)
+ .setFieldTrials(trials).createInitializationOptions())
+ val egl = eglBase!!
+ val zeroSurface = if (zeroCopyWanted(settings)) {
+ repeat(40) { if (!surfaceView.holder.surface.isValid) Thread.sleep(50) }
+ surfaceView.holder.surface.takeIf { it.isValid }
+ } else null
+ if (zeroSurface != null) {
+ // The compositor may already hold the screen; it must let go before the decoder takes it.
+ val ready = CountDownLatch(1)
+ runOnUiThread { zeroCopy = true; video?.setSurface(null, 0, 0, 60f); ready.countDown() }
+ ready.await(2, TimeUnit.SECONDS)
+ }
+ log("latency: instant input ${settings.instantInput}, small buffer ${settings.smallBuffer}, fast decoder ${settings.fastDecoder}, " +
+ "zero-copy ${zeroSurface != null}")
+ val f = PeerConnectionFactory.builder()
+ .setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext).createAudioDeviceModule())
+ .setVideoDecoderFactory(org.webrtc.DroidDeckLowLatencyDecoderFactory(egl.eglBaseContext, settings.fastDecoder, zeroSurface) { zeroCopyFrames++ }
+ .also { decoders = it })
+ .setVideoEncoderFactory(DefaultVideoEncoderFactory(egl.eglBaseContext, true, true))
+ .createPeerConnectionFactory().also { factory = it }
+ val config = PeerConnection.RTCConfiguration(emptyList()).apply { sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN }
+ val peer = f.createPeerConnection(config, observer) ?: error("WebRTC unavailable")
+ pc = peer
+ peer.addTransceiver(MediaStreamTrack.MediaType.MEDIA_TYPE_AUDIO, RtpTransceiver.RtpTransceiverInit(RtpTransceiver.RtpTransceiverDirection.SEND_RECV))
+ peer.addTransceiver(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO, RtpTransceiver.RtpTransceiverInit(RtpTransceiver.RtpTransceiverDirection.RECV_ONLY))
+ protocol = XboxNativeProtocol(peer, pad, { log(it) }, ::rumble) { runOnUiThread { finish() } }
+ pad.onChanged = { if (settings.instantInput) protocol?.inputChanged() }
+
+ val offer = await { done -> peer.createOffer(sdpObserver(done), MediaConstraints()) }
+ val local = SessionDescription(offer.type, tweakOffer(offer.description))
+ await { done -> peer.setLocalDescription(sdpObserver(done), local) }
+ val sdpReply = expect("sdp", signals.sdp(local.description))
+ val answer = JSONObject(JSONObject(sdpReply.body).getString("exchangeResponse"))
+ if (answer.has("status") && answer.optString("status") != "success") error("sdp answer: $answer")
+ await { done -> peer.setRemoteDescription(sdpObserver(done), SessionDescription(SessionDescription.Type.ANSWER, answer.getString("sdp"))) }
+
+ gathered.await(3, TimeUnit.SECONDS)
+ val local2 = synchronized(candidates) { candidates.toList() }.map { c ->
+ JSONObject().put("candidate", c.sdp).put("sdpMid", c.sdpMid).put("sdpMLineIndex", c.sdpMLineIndex).put("usernameFragment", JSONObject.NULL).toString()
+ }
+ val iceReply = expect("ice", signals.ice(JSONArray(local2).toString()))
+ val remote = JSONArray(JSONObject(iceReply.body).getString("exchangeResponse"))
+ for (i in 0 until remote.length()) addRemoteCandidate(peer, remote.getJSONObject(i))
+ log("signalling done: ${local2.size} local / ${remote.length()} remote candidates")
+ ticker.scheduleWithFixedDelay({ runCatching { signals.op("keepalive") } }, 30, 30, TimeUnit.SECONDS)
+ ticker.scheduleWithFixedDelay({ runCatching { updateOverlay() } }, 1, 1, TimeUnit.SECONDS)
+ }
+
+ private fun expect(stage: String, reply: XboxCloudSession.Reply): XboxCloudSession.Reply {
+ if (reply.status !in 200..299) error("$stage: ${reply.status} ${reply.body.take(200)}")
+ return reply
+ }
+
+ /** Opus stereo (Greenlight), H.264 profile order (Main first unless the user picked one) and the bitrate cap. */
+ private fun tweakOffer(sdp: String): String {
+ var out = sdp.replace("useinbandfec=1", "useinbandfec=1; stereo=1")
+ val prefix = when (settings.codec) { "low" -> "420"; "normal" -> "42e"; else -> "4d" }
+ val ids = Regex("a=fmtp:(\\d+).*profile-level-id=([0-9a-f]{6})").findAll(out).filter { it.groupValues[2].startsWith(prefix) }.map { it.groupValues[1] }.toList()
+ if (ids.isNotEmpty()) out = out.split("\r\n").joinToString("\r\n") { line ->
+ if (!line.startsWith("m=video")) line else {
+ val parts = line.trim().split(" ")
+ (parts.take(3) + ids + parts.drop(3).filter { it !in ids }).joinToString(" ")
+ }
+ }
+ if (settings.bitrateMbps > 0) {
+ val lines = out.split("\r\n").toMutableList()
+ val start = lines.indexOfFirst { it.startsWith("m=video") }
+ if (start >= 0) {
+ var i = start + 1
+ while (i < lines.size && (lines[i].startsWith("i=") || lines[i].startsWith("c="))) i++
+ if (i < lines.size && lines[i].startsWith("b=AS:")) lines[i] = "b=AS:${settings.bitrateMbps * 1000}" else lines.add(i, "b=AS:${settings.bitrateMbps * 1000}")
+ out = lines.joinToString("\r\n")
+ }
+ }
+ return out
+ }
+
+ /** The server's candidates, plus the IPv4 behind a Teredo address (Greenlight's ice.ts / teredo.ts). */
+ private fun addRemoteCandidate(peer: PeerConnection, c: JSONObject) {
+ val line = c.optString("candidate").removePrefix("a=")
+ if (line.isEmpty() || line == "end-of-candidates") return
+ val mid = c.optString("sdpMid", "0"); val index = c.optString("sdpMLineIndex", "0").toIntOrNull() ?: 0
+ val address = line.split(" ").getOrNull(4).orEmpty()
+ if (address.startsWith("2001")) runCatching {
+ val p = address.split(":")
+ val hex = p[6].padStart(4, '0') + p[7].padStart(4, '0')
+ val ip = (0 until 4).joinToString(".") { k -> ((hex.substring(k * 2, k * 2 + 2).toInt(16)).inv() and 0xFF).toString() }
+ val port = p[5].toInt(16).inv() and 0xFFFF
+ peer.addIceCandidate(IceCandidate(mid, index, "candidate:10 1 UDP 1 $ip 9002 typ host "))
+ peer.addIceCandidate(IceCandidate(mid, index, "candidate:11 1 UDP 1 $ip $port typ host "))
+ }
+ peer.addIceCandidate(IceCandidate(mid, index, line))
+ }
+
+ private val observer = object : PeerConnection.Observer {
+ override fun onSignalingChange(state: PeerConnection.SignalingState) {}
+ override fun onIceConnectionChange(state: PeerConnection.IceConnectionState) { log("ice $state") }
+ override fun onIceConnectionReceivingChange(receiving: Boolean) {}
+ override fun onIceGatheringChange(state: PeerConnection.IceGatheringState) { if (state == PeerConnection.IceGatheringState.COMPLETE) gathered.countDown() }
+ override fun onIceCandidate(candidate: IceCandidate) { synchronized(candidates) { candidates.add(candidate) } }
+ override fun onIceCandidatesRemoved(removed: Array) {}
+ override fun onAddStream(stream: MediaStream) {}
+ override fun onRemoveStream(stream: MediaStream) {}
+ override fun onDataChannel(channel: DataChannel) {}
+ override fun onRenegotiationNeeded() {}
+ override fun onAddTrack(receiver: RtpReceiver, streams: Array) { attach(receiver) }
+ override fun onTrack(transceiver: RtpTransceiver) { attach(transceiver.receiver) }
+ override fun onConnectionChange(state: PeerConnection.PeerConnectionState) {
+ log("connection $state")
+ when (state) {
+ PeerConnection.PeerConnectionState.CONNECTED -> {
+ connectedOnce = true
+ show("")
+ video?.setFpsTarget(settings.fpsTarget)
+ video?.setFrameGeneration(effectiveFrameGen())
+ }
+ PeerConnection.PeerConnectionState.FAILED -> fail("webrtc", "connection failed")
+ PeerConnection.PeerConnectionState.DISCONNECTED -> show("Connection lost…")
+ else -> {}
+ }
+ }
+ }
+
+ private var videoAttached = false
+
+ private fun attach(receiver: RtpReceiver) = synchronized(this) {
+ val track = receiver.track()
+ // Always attached: in zero-copy WebRTC delivers no frames, and after a live switch back they flow again.
+ if (track is VideoTrack && !videoAttached) { videoAttached = true; video?.let { track.addSink(it) }; log("video track") }
+ }
+
+ /** LSFG needs the Lossless.dll and its shader cache built; otherwise DDFG. */
+ private fun effectiveFrameGen(): String {
+ if (!XboxNativeVideo.isLsfg(settings.frameGen)) return settings.frameGen
+ val status = com.droiddeck.launcher.gpu.Lossless.sync(applicationContext)
+ if (status == 0) return settings.frameGen
+ log("LSFG unavailable (status $status), using DDFG")
+ return XboxNativeVideo.FG_DDFG
+ }
+
+ private fun await(start: (done: (Result) -> Unit) -> Unit): T {
+ val latch = CountDownLatch(1)
+ var result: Result? = null
+ start { r -> result = r; latch.countDown() }
+ check(latch.await(15, TimeUnit.SECONDS)) { "WebRTC timed out" }
+ return result!!.getOrThrow()
+ }
+
+ @Suppress("UNCHECKED_CAST")
+ private fun sdpObserver(done: (Result) -> Unit) = object : SdpObserver {
+ override fun onCreateSuccess(description: SessionDescription) = done(Result.success(description as T))
+ override fun onSetSuccess() = done(Result.success(Unit as T))
+ override fun onCreateFailure(error: String) = done(Result.failure(IllegalStateException(error)))
+ override fun onSetFailure(error: String) = done(Result.failure(IllegalStateException(error)))
+ }
+
+ // ---- input, rumble, overlay ----
+
+ private var guideDown = false
+ private var guideDownAt = 0L
+ private var lastGuideUp = 0L
+ private var pendingNexus: Runnable? = null
+ private fun isGuide(event: KeyEvent) = event.keyCode == KeyEvent.KEYCODE_BUTTON_MODE
+
+ private fun pressNexus() {
+ pad.overrideButtons = pad.overrideButtons or 2
+ root.postDelayed({ pad.overrideButtons = pad.overrideButtons and 2.inv() }, 200)
+ }
+
+ override fun dispatchKeyEvent(event: KeyEvent): Boolean {
+ if (menu != null) {
+ // Guide closes the menu; Back goes up one page, then closes it.
+ if (isGuide(event)) { if (event.action == KeyEvent.ACTION_UP) { if (swallowGuideUp) swallowGuideUp = false else closeMenu() }; return true }
+ if (event.keyCode == KeyEvent.KEYCODE_BACK) {
+ if (event.action == KeyEvent.ACTION_UP) { if (menuPage.isNotEmpty()) menuPage = "" else closeMenu() }
+ return true
+ }
+ return super.dispatchKeyEvent(event)
+ }
+ // Guide / the Input Controls menu button: once = the Xbox button, twice or held = the player menu.
+ if (isGuide(event)) {
+ if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
+ val pending = pendingNexus
+ if (pending != null && event.eventTime - lastGuideUp <= 350) { root.removeCallbacks(pending); pendingNexus = null; swallowGuideUp = true; openMenu() }
+ else { guideDown = true; guideDownAt = event.eventTime }
+ } else if (event.action == KeyEvent.ACTION_DOWN && guideDown && event.eventTime - guideDownAt >= 600) {
+ guideDown = false; swallowGuideUp = true; openMenu()
+ } else if (event.action == KeyEvent.ACTION_UP && guideDown) {
+ guideDown = false; lastGuideUp = event.eventTime
+ val tap = Runnable { pendingNexus = null; pressNexus() }
+ pendingNexus = tap; root.postDelayed(tap, 350)
+ }
+ return true
+ }
+ if (event.keyCode == KeyEvent.KEYCODE_BACK) { if (event.action == KeyEvent.ACTION_UP) openMenu(); return true }
+ if (pad.onKey(event)) return true
+ return super.dispatchKeyEvent(event)
+ }
+
+ // With the menu open, sticks and the hat go to Android unhandled, which turns them into D-pad keys for the menu.
+ override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean =
+ (menu == null && pad.onMotion(event)) || super.dispatchGenericMotionEvent(event)
+
+ private fun rumble(strong: Float, weak: Float, durationMs: Int) {
+ val scale = settings.rumble / 100f
+ val amplitude = (maxOf(strong, weak) * scale * 255).toInt().coerceIn(0, 255)
+ if (amplitude == 0 || durationMs <= 0) return
+ val vibrator = (if (Build.VERSION.SDK_INT >= 31) getSystemService(android.os.VibratorManager::class.java)?.defaultVibrator
+ else @Suppress("DEPRECATION") getSystemService(android.os.Vibrator::class.java)) ?: return
+ runCatching { vibrator.vibrate(VibrationEffect.createOneShot(durationMs.coerceAtMost(1000).toLong(), amplitude)) }
+ }
+
+ /** The overlay is remembered with the other cloud settings (on = overlay level above 0). */
+ @Volatile private var overlayOn = false
+
+ private var lastJitterDelay = 0.0
+ private var lastJitterCount = 0.0
+ private var lastDecodeTime = 0.0
+ private var lastDecoded = 0.0
+ private var lastBytes = 0.0
+ private var lastStatsMs = 0.0
+ private var lastLost = 0.0
+ private var lastReceived = 0.0
+
+ /**
+ * The overlay, at the web player's levels and layout (settings statsLevel / statsLayout): 1 fps and frame
+ * generation base -> shown; 2 + resolution, ping; 3 + bitrate, jitter buffer, decode time, packet loss; 4 + frame
+ * generation's added delay, the estimated picture delay (one-way network + buffer + decode + frame generation +
+ * one screen refresh), codec and server.
+ */
+ private fun updateOverlay() {
+ val level = settings.statsLevel
+ if (!overlayOn || level <= 0) return
+ val peer = pc ?: return
+ peer.getStats { report ->
+ var size = ""; var fps = 0; var codec = ""
+ var rttMs = -1.0; var bufferMs = 0.0; var decodeMs = 0.0; var mbps = 0.0; var loss = 0.0
+ val codecs = HashMap()
+ report.statsMap.values.forEach { s -> if (s.type == "codec") codecs[s.id] = (s.members["mimeType"] as? String).orEmpty().removePrefix("video/") }
+ report.statsMap.values.forEach { s ->
+ val m = s.members
+ if (s.type == "inbound-rtp" && m["kind"] == "video") {
+ size = "${m["frameWidth"]}x${m["frameHeight"]}"
+ fps = (m["framesPerSecond"] as? Number)?.toInt() ?: 0
+ codec = codecs[m["codecId"] as? String].orEmpty()
+ val jd = (m["jitterBufferDelay"] as? Number)?.toDouble() ?: 0.0
+ val jc = (m["jitterBufferEmittedCount"] as? Number)?.toDouble() ?: 0.0
+ if (jc > lastJitterCount) bufferMs = (jd - lastJitterDelay) * 1000 / (jc - lastJitterCount)
+ lastJitterDelay = jd; lastJitterCount = jc
+ val dt = (m["totalDecodeTime"] as? Number)?.toDouble() ?: 0.0
+ val df = (m["framesDecoded"] as? Number)?.toDouble() ?: 0.0
+ if (df > lastDecoded) decodeMs = (dt - lastDecodeTime) * 1000 / (df - lastDecoded)
+ lastDecodeTime = dt; lastDecoded = df
+ val bytes = (m["bytesReceived"] as? Number)?.toDouble() ?: 0.0
+ val now = s.timestampUs / 1000.0
+ if (lastStatsMs > 0 && now > lastStatsMs) mbps = (bytes - lastBytes) * 8 / ((now - lastStatsMs) * 1000)
+ lastBytes = bytes; lastStatsMs = now
+ val lost = (m["packetsLost"] as? Number)?.toDouble() ?: 0.0
+ val received = (m["packetsReceived"] as? Number)?.toDouble() ?: 0.0
+ val dl = lost - lastLost; val dr = received - lastReceived
+ if (dl + dr > 0) loss = dl * 100 / (dl + dr)
+ lastLost = lost; lastReceived = received
+ } else if (s.type == "candidate-pair" && m["state"] == "succeeded" && m["nominated"] == true) {
+ (m["currentRoundTripTime"] as? Number)?.toDouble()?.let { rttMs = it * 1000 }
+ }
+ }
+ // Zero-copy: WebRTC never sees a decoded frame, so size and decode time come from the decoder itself.
+ if (zeroCopy) decoders?.let { d ->
+ d.videoSize()?.let { size = it }
+ val ms = d.takeDecodeMs()
+ if (ms >= 0) decodeMs = ms
+ }
+ val fg = video?.stats()
+ val fgOn = fg != null && settings.frameGen != XboxNativeVideo.FG_OFF && fg[2] > 1f
+ val fgWaitMs = if (fgOn) 1000.0 / fg!![2] else 0.0
+ val fgGpuMs = if (fgOn && fg!![5] > 0f) fg[5].toDouble() else 0.0
+ @Suppress("DEPRECATION") val refreshMs = 1000.0 / windowManager.defaultDisplay.refreshRate
+ val total = (if (rttMs >= 0) rttMs / 2 else 0.0) + bufferMs + decodeMs + fgWaitMs + fgGpuMs + refreshMs
+ // What reaches the screen: the decoder's own count in zero-copy, the presented rate with frame generation,
+ // else the frames handed to the compositor (a frame-rate target drops some of WebRTC's decoded frames).
+ val submitted = video?.frames ?: 0L
+ val handed = (submitted - lastSubmitted).toInt().also { lastSubmitted = submitted }
+ val shownFps = when {
+ zeroCopy -> (zeroCopyFrames - lastZeroCopyFrames).toInt().also { lastZeroCopyFrames = zeroCopyFrames }
+ fgOn -> fg!![3].toInt()
+ else -> handed
+ }
+ val items = buildList {
+ add("native · " + if (settings.frameGen == XboxNativeVideo.FG_OFF) "no frame gen" else XboxNativeVideo.modeName(settings.frameGen))
+ add("$shownFps fps" + if (zeroCopy) " zero-copy" else "")
+ if (fgOn) add("${settings.frameGen} ${fg!![2].toInt()} → ${fg[3].toInt()}")
+ if (level >= 2) { add(size); add(if (rttMs >= 0) "ping ${rttMs.toInt()} ms" else "ping –") }
+ if (level >= 3) {
+ add("${"%.1f".format(mbps)} Mb/s"); add("buffer ${"%.1f".format(bufferMs)} ms")
+ add("decode ${"%.1f".format(decodeMs)} ms"); add("loss ${"%.1f".format(loss)}%")
+ }
+ if (level >= 4) {
+ if (fgOn) add("frame gen +${"%.1f".format(fgWaitMs + fgGpuMs)} ms (gpu ${"%.1f".format(fgGpuMs)})")
+ add("picture delay ≈ ${total.toInt()} ms (est.)")
+ if (codec.isNotEmpty()) add(codec)
+ serverName?.let { add(it) }
+ }
+ }
+ val text = items.joinToString(if (settings.statsLayout == "vertical") "\n" else " · ")
+ runOnUiThread { overlay.text = text }
+ }
+ }
+
+ // ---- menu ----
+
+ /** The player menu (as the web player's): Resume, Xbox menu, Frame generation, Stream quality, overlay, Leave. */
+ private fun openMenu() {
+ if (menu != null) return
+ pad.reset()
+ menuPage = ""
+ val regions = regionNames
+ val lsfg = XboxNativeVideo.lsfgReady(this)
+ val view = androidx.compose.ui.platform.ComposeView(this)
+ view.setContent {
+ com.droiddeck.launcher.ui.DroidDeckTheme {
+ var current by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(settings) }
+ val entries = androidx.compose.runtime.remember { List(7) { androidx.compose.ui.focus.FocusRequester() } }
+ val choices = androidx.compose.runtime.remember { List(5) { androidx.compose.ui.focus.FocusRequester() } }
+ androidx.compose.runtime.LaunchedEffect(menuPage) {
+ // Wait a frame so the entries are attached before one of them takes the selection.
+ androidx.compose.runtime.withFrameNanos { }
+ runCatching {
+ if (menuPage.isEmpty()) entries[lastMainEntry.coerceIn(0, 6)].requestFocus()
+ else if (menuPage == "framegen") choices[FG_MODES.indexOf(current.frameGen).coerceIn(0, if (lsfg) 4 else 1)].requestFocus()
+ }
+ }
+ val cs = androidx.compose.material3.MaterialTheme.colorScheme
+ // A full-size box first: the root of a ComposeView gets fixed full-screen constraints, so the panel's
+ // width only holds inside it (as the web player's menu does).
+ androidx.compose.foundation.layout.Box(androidx.compose.ui.Modifier.fillMaxSize()) {
+ androidx.compose.foundation.layout.Column(
+ androidx.compose.ui.Modifier.fillMaxHeight().width(400.dp).background(cs.surface.copy(alpha = 0.95f))
+ .verticalScroll(androidx.compose.foundation.rememberScrollState()).padding(vertical = 12.dp),
+ ) {
+ androidx.compose.material3.Text("${intent.getStringExtra("title").orEmpty()} · native",
+ style = androidx.compose.material3.MaterialTheme.typography.titleMedium, color = cs.onSurface,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
+ fun fgName(mode: String) = when (mode) {
+ XboxNativeVideo.FG_DDFG -> "DDFG 2×"; XboxNativeVideo.FG_LSFG -> "LSFG 2×"
+ XboxNativeVideo.FG_LSFG3 -> "LSFG 3×"; XboxNativeVideo.FG_LSFG4 -> "LSFG 4×"; else -> "Off"
+ }
+ fun fpsName(s: XboxCloudSettings) = if (s.fpsTarget == 0) "the screen's rate" else "${s.fpsTarget} fps"
+ when (menuPage) {
+ "" -> {
+ XboxMenuEntry("Resume", "Back to the game", entries[0], { lastMainEntry = 0 }) { closeMenu() }
+ XboxMenuEntry("Xbox menu", "The game's Xbox menu (also: Guide once)", entries[1], { lastMainEntry = 1 }) { closeMenu(); pressNexus() }
+ XboxMenuEntry("Frame generation & low latency", "Now: ${fgName(current.frameGen)}" + if (zeroCopy) " · zero-copy" else "",
+ entries[2], { lastMainEntry = 2 }) { menuPage = "framegen" }
+ XboxMenuEntry("Frame rate", "Target: ${fpsName(current)}", entries[3], { lastMainEntry = 3 }) { menuPage = "framerate" }
+ XboxMenuEntry("Stream quality", "Engine, resolution, region, codec, bitrate (next stream)", entries[4], { lastMainEntry = 4 }) { menuPage = "stream" }
+ XboxMenuEntry("Performance overlay and rumble", if (current.statsLevel == 0) "Overlay off"
+ else "Overlay: " + listOf("", "FPS only", "Basic", "Detailed", "Full")[current.statsLevel] + ", " + current.statsLayout,
+ entries[5], { lastMainEntry = 5 }) { menuPage = "overlay-native" }
+ XboxMenuEntry("Leave", "End the stream", entries[6], { lastMainEntry = 6 }) { finish() }
+ androidx.compose.material3.Text("Guide twice opens this menu; Back or Guide closes it.",
+ style = androidx.compose.material3.MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 8.dp))
+ }
+ "framegen" -> {
+ XboxMenuEntry("‹ Back", null) { menuPage = "" }
+ val modes = if (lsfg) FG_MODES else FG_MODES.take(2)
+ modes.forEachIndexed { i, mode ->
+ XboxMenuEntry((if (current.frameGen == mode) "✓ " else "") + fgName(mode), when (mode) {
+ XboxNativeVideo.FG_DDFG -> "DroidDeck's own frame generation (DDFG); doubles the shown frame rate"
+ XboxNativeVideo.FG_LSFG, XboxNativeVideo.FG_LSFG3, XboxNativeVideo.FG_LSFG4 ->
+ "Lossless Scaling frame generation (the Lossless.dll DroidDeck uses for games); the frame-rate target caps the output"
+ else -> "Show the stream's own frames only"
+ }, choices[i]) { current = current.copy(frameGen = mode); setFrameGen(mode) }
+ }
+ if (!lsfg) androidx.compose.material3.Text("LSFG appears here once DroidDeck has the Lossless.dll (frame generation settings).",
+ style = androidx.compose.material3.MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 8.dp))
+ if (current.zeroCopy) androidx.compose.material3.Text(
+ "Zero-copy is used while frame generation is Off; picking a frame generation mode switches to the compositor live.",
+ style = androidx.compose.material3.MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant,
+ modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 8.dp))
+ XboxCloudSettingsPanel(current, regionNames, live = true, section = "latency", restoreRow = null,
+ startedWith = startedWith) { changed ->
+ val before = current
+ current = changed
+ applyLive(before, changed)
+ }
+ XboxMenuEntry("Restart the stream with these settings",
+ "Ends this cloud session and starts a new one; the game restarts, unsaved progress is lost.") { restartStream() }
+ }
+ else -> {
+ XboxMenuEntry("‹ Back", null) { menuPage = "" }
+ if (menuPage == "stream") XboxMenuEntry("Restart the stream with these settings",
+ "Ends this cloud session and starts a new one; the game restarts, unsaved progress is lost.") { restartStream() }
+ val page = menuPage
+ XboxCloudSettingsPanel(current, regions, live = true, section = page, restoreRow = lastRow[page] ?: 0,
+ onRowFocused = { lastRow[page] = it }, startedWith = startedWith) { changed ->
+ val before = current
+ current = changed
+ applyLive(before, changed)
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ menu = view
+ root.addView(view, FrameLayout.LayoutParams(-1, -1))
+ view.requestFocus()
+ }
+
+ /**
+ * Applies a settings change from any menu page at once: frame generation, the frame-rate target, zero-copy, instant
+ * input and the overlay. Resolution, region, language, codec, bitrate, the network buffer, the decoder mode and the
+ * engine belong to the cloud session and need a restart (the page says so).
+ */
+ private fun applyLive(before: XboxCloudSettings, changed: XboxCloudSettings) {
+ settings = changed
+ XboxCloudSettings.save(this, changed)
+ if (changed.frameGen != before.frameGen) setFrameGen(changed.frameGen)
+ else if (changed.zeroCopy != before.zeroCopy) applyRoute()
+ if (changed.fpsTarget != before.fpsTarget) { applyDisplayRate(changed.fpsTarget); video?.setFpsTarget(changed.fpsTarget); applyRoute() }
+ applyOverlay()
+ }
+
+ /**
+ * Zero-copy draws every decoded frame straight onto the screen, so it is used only when nothing has to touch the
+ * frames: frame generation off and no frame-rate target below the stream's 60 fps (the compositor drops frames for that).
+ */
+ private fun zeroCopyWanted(s: XboxCloudSettings) =
+ s.zeroCopy && s.frameGen == XboxNativeVideo.FG_OFF && (s.fpsTarget == 0 || s.fpsTarget >= 60)
+
+ private fun applyOverlay() {
+ overlayOn = settings.statsLevel > 0
+ overlay.visibility = if (overlayOn) android.view.View.VISIBLE else android.view.View.GONE
+ overlay.textSize = 12f
+ // Top left keeps clear of the clock Xbox draws top right while its guide is open.
+ val left = settings.statsCorner == "left"
+ overlay.layoutParams = (overlay.layoutParams as FrameLayout.LayoutParams).apply {
+ gravity = Gravity.TOP or (if (left) Gravity.START else Gravity.END)
+ leftMargin = if (left) 16 else 0; rightMargin = if (left) 0 else 16
+ }
+ overlay.gravity = if (left) Gravity.START else Gravity.END
+ }
+
+ /** Stream-start settings need a new cloud session: end this one, then open the player again. */
+ private fun restartStream() {
+ val signals = signalling
+ closed = true
+ closeMenu()
+ notice?.let { root.removeView(it) }
+ notice = null
+ show("Restarting the stream…")
+ Thread({
+ signals?.stop()?.let { log("restart: session closed ${it.status}") }
+ runOnUiThread { if (!isFinishing) { startActivity(XboxCloudPlayerActivity.playerIntent(this, intent.getStringExtra("product").orEmpty(), intent.getStringExtra("title").orEmpty())); finish() } }
+ }, "xcloud-native-restart").start()
+ }
+
+ private fun closeMenu() {
+ menu?.let { root.removeView(it) }
+ menu = null
+ pad.reset()
+ }
+
+ private fun setFrameGen(mode: String) {
+ settings = settings.copy(frameGen = mode)
+ XboxCloudSettings.save(this, settings)
+ applyRoute()
+ worker.execute { video?.setFrameGeneration(effectiveFrameGen()) }
+ }
+
+ /**
+ * Live route switch (UI thread): zero-copy when chosen and frame generation is off, else the compositor.
+ * The screen surface takes one producer at a time, so the old one lets go before the new one connects.
+ */
+ private fun applyRoute() {
+ val d = decoders ?: return
+ val want = zeroCopyWanted(settings)
+ if (want == zeroCopy) return
+ val target = screen
+ if (want) {
+ if (target == null) return
+ video?.setSurface(null, 0, 0, 60f)
+ if (d.useScreen(target)) { lastZeroCopyFrames = zeroCopyFrames; zeroCopy = true; log("route: zero-copy") }
+ else { attachCompositor(target); log("route: zero-copy refused by the decoder, compositor kept") }
+ } else {
+ if (!d.useScreen(null)) { log("route: decoder could not leave the screen, zero-copy kept"); return }
+ zeroCopy = false
+ target?.let { attachCompositor(it) }
+ log("route: compositor")
+ }
+ }
+
+ private fun attachCompositor(target: android.view.Surface) {
+ @Suppress("DEPRECATION")
+ video?.setSurface(target, screenW, screenH, windowManager.defaultDisplay.refreshRate)
+ }
+
+ /**
+ * Ask Android for the display mode whose refresh rate fits the target (at least the target when possible,
+ * else the fastest; the fastest for "the screen's rate"), so generated frames are not held back at 60 Hz.
+ */
+ private fun applyDisplayRate(target: Int) {
+ @Suppress("DEPRECATION") val display = windowManager.defaultDisplay
+ val current = display.mode
+ val modes = display.supportedModes.filter { it.physicalWidth == current.physicalWidth && it.physicalHeight == current.physicalHeight }
+ val pick = (if (target > 0) modes.filter { it.refreshRate >= target - 0.5f }.minByOrNull { it.refreshRate } else null)
+ ?: modes.maxByOrNull { it.refreshRate } ?: return
+ window.attributes = window.attributes.apply { preferredDisplayModeId = pick.modeId }
+ log("display mode ${pick.refreshRate.toInt()} Hz for target ${if (target > 0) target else "screen"}")
+ }
+
+ private val rehideBars = Runnable { if (window.decorView.hasWindowFocus()) hideBars() }
+
+ /**
+ * Bars that come back while the player has focus (return from recents or another app, a swipe) are hidden
+ * again after a moment; focus alone missed the return from the background (10-24).
+ */
+ private fun watchBars() {
+ androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
+ if (insets.isVisible(WindowInsetsCompat.Type.navigationBars()) || insets.isVisible(WindowInsetsCompat.Type.statusBars())) {
+ v.removeCallbacks(rehideBars)
+ v.postDelayed(rehideBars, 1500)
+ }
+ androidx.core.view.ViewCompat.onApplyWindowInsets(v, insets)
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ hideBars()
+ }
+
+ private fun hideBars() {
+ WindowCompat.setDecorFitsSystemWindows(window, false)
+ WindowInsetsControllerCompat(window, window.decorView).apply {
+ hide(WindowInsetsCompat.Type.systemBars())
+ systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
+ }
+ }
+
+ override fun onWindowFocusChanged(hasFocus: Boolean) { super.onWindowFocusChanged(hasFocus); if (hasFocus) hideBars() }
+
+ override fun onDestroy() {
+ closed = true
+ ticker.shutdownNow()
+ val signals = signalling
+ Thread({ signals?.stop()?.let { log("session closed: ${it.status}") } }, "xcloud-native-stop").start()
+ runCatching { protocol?.close() }
+ runCatching { pc?.close(); pc?.dispose() }
+ runCatching { video?.release() }
+ runCatching { factory?.dispose() }
+ runCatching { decoders?.release() }
+ runCatching { eglBase?.release() }
+ worker.shutdownNow()
+ super.onDestroy()
+ }
+
+ companion object {
+ /** How long a stream may stay in the background (Android froze the app ~70 s after it left the screen, 10-24). */
+ private const val BACKGROUND_GRACE_MS = 45_000L
+ private val FG_MODES = listOf(XboxNativeVideo.FG_OFF, XboxNativeVideo.FG_DDFG, XboxNativeVideo.FG_LSFG, XboxNativeVideo.FG_LSFG3, XboxNativeVideo.FG_LSFG4)
+
+ /** True when the native engine can run here (ImageReader GPU buffers need Android 10). */
+ fun supported(): Boolean = Build.VERSION.SDK_INT >= 29
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeProtocol.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeProtocol.kt
new file mode 100644
index 0000000000..348079f527
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeProtocol.kt
@@ -0,0 +1,186 @@
+package com.droiddeck.launcher.stores.xbox
+
+import org.json.JSONObject
+import org.webrtc.DataChannel
+import org.webrtc.PeerConnection
+import java.nio.ByteBuffer
+import java.nio.ByteOrder
+import java.nio.charset.StandardCharsets
+import java.util.UUID
+import java.util.concurrent.Executors
+import java.util.concurrent.ScheduledFuture
+import java.util.concurrent.TimeUnit
+
+/**
+ * The xCloud data-channel protocol for the native player, ported from Greenlight's player (UnknownSKL, MIT;
+ * tools/xcloud-player/greenlight/lib/channel): chat / control / input / message channels, the message
+ * handshake, authorization and gamepad announcements, and the binary input reports. The controller state
+ * comes from Android input events ([pad]); rumble reports come back through [onRumble].
+ */
+internal class XboxNativeProtocol(
+ pc: PeerConnection,
+ private val pad: XboxNativePad,
+ private val log: (String) -> Unit,
+ private val onRumble: (strong: Float, weak: Float, durationMs: Int) -> Unit,
+ private val onServerDisconnect: () -> Unit,
+) {
+ private val chat = pc.createDataChannel("chat", init("chatV1"))
+ private val control = pc.createDataChannel("control", init("controlV1"))
+ private val input = pc.createDataChannel("input", init("1.0"))
+ private val message = pc.createDataChannel("message", init("messageV1"))
+ private val timer = Executors.newSingleThreadScheduledExecutor { r -> Thread(r, "xcloud-input") }
+ private var loop: ScheduledFuture<*>? = null
+ private var sequence = 0
+ private var lastSent: XboxNativePad.State? = null
+ private var lastSentAt = 0L
+ @Volatile var handshakeDone = false
+ private set
+
+ init {
+ message.registerObserver(ChannelObserver(message, ::onMessageOpen, ::onMessageData))
+ control.registerObserver(ChannelObserver(control, {}, {}))
+ input.registerObserver(ChannelObserver(input, {}, ::onInputData))
+ chat.registerObserver(ChannelObserver(chat, {}, {}))
+ }
+
+ private fun init(protocol: String) = DataChannel.Init().apply { ordered = true; this.protocol = protocol }
+
+ private inner class ChannelObserver(
+ private val channel: DataChannel,
+ private val onOpen: () -> Unit,
+ private val onData: (DataChannel.Buffer) -> Unit,
+ ) : DataChannel.Observer {
+ private var opened = false
+ override fun onBufferedAmountChange(previous: Long) {}
+ override fun onStateChange() {
+ if (!opened && channel.state() == DataChannel.State.OPEN) { opened = true; runCatching(onOpen).onFailure { log("channel open failed: ${it.message}") } }
+ }
+ override fun onMessage(buffer: DataChannel.Buffer) { runCatching { onData(buffer) }.onFailure { log("channel message failed: ${it.message}") } }
+ }
+
+ private fun send(channel: DataChannel, text: String) {
+ if (channel.state() != DataChannel.State.OPEN) return
+ channel.send(DataChannel.Buffer(ByteBuffer.wrap(text.toByteArray(StandardCharsets.UTF_8)), false))
+ }
+
+ private fun send(channel: DataChannel, bytes: ByteBuffer) {
+ if (channel.state() != DataChannel.State.OPEN) return
+ channel.send(DataChannel.Buffer(bytes, true))
+ }
+
+ private fun onMessageOpen() {
+ log("message channel open, handshake")
+ send(message, JSONObject().put("type", "Handshake").put("version", "messageV1")
+ .put("id", "be0bfc6d-1e83-4c8a-90ed-fa8601c5a179").put("cv", "0").toString())
+ }
+
+ private fun onMessageData(buffer: DataChannel.Buffer) {
+ val bytes = ByteArray(buffer.data.remaining()).also { buffer.data.get(it) }
+ val data = JSONObject(String(bytes, StandardCharsets.UTF_8))
+ when (data.optString("type")) {
+ "HandshakeAck" -> {
+ handshakeDone = true
+ log("handshake done")
+ // Greenlight's order: authorization (announces controller 0 and removes it), input start, config.
+ send(control, JSONObject().put("message", "authorizationRequest").put("accessKey", "4BDB3609-C1F1-4195-9B37-FEFF45DA8B8E").toString())
+ gamepadChanged(0, true); gamepadChanged(0, false)
+ startInput()
+ sendConfig()
+ // Our controller, after the authorization's add/remove.
+ gamepadChanged(0, true)
+ send(control, JSONObject().put("message", "videoKeyframeRequested").put("ifrRequested", true).toString())
+ }
+ "TransactionStart", "Message" -> handleTransaction(data)
+ else -> {}
+ }
+ }
+
+ private fun handleTransaction(data: JSONObject) {
+ when (data.optString("target")) {
+ "/streaming/sessionLifetimeManagement/serverInitiatedDisconnect" -> {
+ complete(data.optString("id"), "")
+ onServerDisconnect()
+ }
+ // The game's own dialogs: accept (Greenlight shows a confirm; the native player has no page).
+ "/streaming/systemUi/messages/ShowMessageDialog" -> complete(data.optString("id"), JSONObject().put("Result", 0))
+ else -> {}
+ }
+ }
+
+ private fun complete(id: String, content: Any) {
+ send(message, JSONObject().put("type", "TransactionComplete").put("content", content.toString().let { if (content is String) JSONObject.quote(it) else it })
+ .put("id", id).put("cv", "").toString())
+ }
+
+ private fun gamepadChanged(index: Int, added: Boolean) {
+ send(control, JSONObject().put("message", "gamepadChanged").put("gamepadIndex", index).put("wasAdded", added).toString())
+ }
+
+ private fun sendConfig() {
+ fun msg(path: String, content: JSONObject) = JSONObject().put("type", "Message").put("content", content.toString())
+ .put("id", UUID.randomUUID().toString()).put("target", path).put("cv", "").toString()
+ send(message, msg("/streaming/systemUi/configuration", JSONObject().put("version", org.json.JSONArray(listOf(0, 2, 0))).put("systemUis", org.json.JSONArray())))
+ send(message, msg("/streaming/properties/clientappinstallidchanged", JSONObject().put("clientAppInstallId", "c97d7ee0-73b2-4239-bf1d-9d805a338429")))
+ send(message, msg("/streaming/characteristics/orientationchanged", JSONObject().put("orientation", 0)))
+ send(message, msg("/streaming/characteristics/touchinputenabledchanged", JSONObject().put("touchInputEnabled", false)))
+ send(message, msg("/streaming/characteristics/clientdevicecapabilities", JSONObject()))
+ send(message, msg("/streaming/characteristics/dimensionschanged", JSONObject().put("horizontal", 1920).put("vertical", 1080)
+ .put("preferredWidth", 1920).put("preferredHeight", 1080).put("safeAreaLeft", 0).put("safeAreaTop", 0)
+ .put("safeAreaRight", 1920).put("safeAreaBottom", 1080).put("supportsCustomResolution", true)))
+ }
+
+ private fun header(type: Int, size: Int): ByteBuffer = ByteBuffer.allocateDirect(size).order(ByteOrder.LITTLE_ENDIAN).apply {
+ putShort(type.toShort()); putInt(sequence++); putDouble(System.nanoTime() / 1e6)
+ }
+
+ private fun startInput() {
+ // Client metadata: max touch points.
+ send(input, header(8, 15).apply { put(1.toByte()); flip() })
+ loop = timer.scheduleWithFixedDelay({ runCatching { tick() } }, 16, 16, TimeUnit.MILLISECONDS)
+ }
+
+ /** Instant controller input: send a report now if the state changed (the 16 ms loop stays as the heartbeat). */
+ fun inputChanged() {
+ // At most one extra report every 4 ms (stick motion arrives far faster than that).
+ if (handshakeDone && loop != null && System.nanoTime() - lastSentAt > 4_000_000L) timer.execute { runCatching { tick() } }
+ }
+
+ /** Greenlight's queue: a gamepad frame when the state changed (sticks past a small threshold) or every 33 ms. */
+ @Synchronized
+ private fun tick() {
+ val state = pad.snapshot()
+ val now = System.nanoTime()
+ val changed = lastSent?.let { state.differsFrom(it) } ?: true
+ if (!changed && now - lastSentAt < 33_000_000L) return
+ lastSent = state; lastSentAt = now
+ val packet = header(2, 14 + 1 + 23).apply {
+ put(1.toByte()) // one frame
+ put(0.toByte()) // gamepad index
+ putShort(state.buttons.toShort())
+ putShort(axis(state.lx)); putShort(axis(-state.ly)); putShort(axis(state.rx)); putShort(axis(-state.ry))
+ putShort(trigger(state.lt)); putShort(trigger(state.rt))
+ putInt(1) // physical physicality
+ order(ByteOrder.BIG_ENDIAN); putInt(1); order(ByteOrder.LITTLE_ENDIAN) // virtual physicality (Greenlight writes it big-endian)
+ flip()
+ }
+ send(input, packet)
+ }
+
+ private fun axis(value: Float): Short = (value * 32767).toInt().coerceIn(-32767, 32767).toShort()
+ private fun trigger(value: Float): Short = if (value <= 0f) 0 else if (value >= 1f) 65535.toShort() else (value * 65535).toInt().toShort()
+
+ private fun onInputData(buffer: DataChannel.Buffer) {
+ val data = buffer.data.order(ByteOrder.LITTLE_ENDIAN)
+ if (data.remaining() < 13 || (data.get(0).toInt() and 0xFF) != 128) return // vibration report
+ val strong = (data.get(4).toInt() and 0xFF) / 100f
+ val weak = (data.get(5).toInt() and 0xFF) / 100f
+ val duration = data.getShort(8).toInt() and 0xFFFF
+ onRumble(strong, weak, duration)
+ }
+
+ fun close() {
+ loop?.cancel(false)
+ timer.shutdownNow()
+ listOf(chat, control, input, message).forEach { runCatching { it.unregisterObserver(); it.close(); it.dispose() } }
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt
new file mode 100644
index 0000000000..dc3657dbef
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt
@@ -0,0 +1,183 @@
+package com.droiddeck.launcher.stores.xbox
+
+import android.content.Context
+import android.graphics.PixelFormat
+import android.hardware.HardwareBuffer
+import android.media.Image
+import android.media.ImageReader
+import android.os.Handler
+import android.os.HandlerThread
+import android.view.Surface
+import com.droiddeck.launcher.gpu.FrameGen
+import com.droiddeck.launcher.gpu.Lossless
+import com.droiddeck.launcher.wayland.CompositorHost
+import com.droiddeck.launcher.wayland.WaylandCompositor
+import org.webrtc.EglBase
+import org.webrtc.EglRenderer
+import org.webrtc.GlRectDrawer
+import org.webrtc.VideoFrame
+import org.webrtc.VideoSink
+import java.io.File
+import java.util.ArrayDeque
+
+/**
+ * The native player's picture: WebRTC's hardware-decoded frames are drawn (GL, WebRTC's EglRenderer) into an
+ * ImageReader whose images are GPU-shareable HardwareBuffers, and each one goes to DroidDeck's own compositor in
+ * stream mode (WaylandCompositor.nativeStreamFrame) as the whole scene, where DroidDeck's frame generation (DDFG,
+ * or LSFG with the Lossless.dll) multiplies it. The player runs in its own process (:xcloudnative), so this
+ * compositor is never the one a Linux session uses. Android 10+ (ImageReader usage flags).
+ */
+internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, private val log: (String) -> Unit) : VideoSink {
+ companion object {
+ const val FG_OFF = "off"
+ const val FG_DDFG = "ddfg"
+ const val FG_LSFG = "lsfg"
+ const val FG_LSFG3 = "lsfg3"
+ const val FG_LSFG4 = "lsfg4"
+ fun isLsfg(mode: String) = mode == FG_LSFG || mode == FG_LSFG3 || mode == FG_LSFG4
+ fun multiplier(mode: String) = when (mode) { FG_LSFG3 -> 3; FG_LSFG4 -> 4; FG_OFF -> 0; else -> 2 }
+ fun modes(lsfg: Boolean) = if (lsfg) listOf(FG_OFF, FG_DDFG, FG_LSFG, FG_LSFG3, FG_LSFG4) else listOf(FG_OFF, FG_DDFG)
+ fun modeName(mode: String) = when (mode) {
+ FG_DDFG -> "DDFG 2×"; FG_LSFG -> "LSFG 2×"; FG_LSFG3 -> "LSFG 3×"; FG_LSFG4 -> "LSFG 4×"; else -> "Off"
+ }
+ /** LSFG can run: the Lossless.dll was imported (or found in Steam) and its shader cache built. */
+ fun lsfgReady(context: Context) = Lossless.state(context).ready
+ private const val SCALE_FIT = 1
+ private const val ALIGN_CENTER = 0
+ }
+
+ private val lock = Any()
+ private val egl = EglRenderer("xcloud-native").apply { init(eglBase.eglBaseContext, EglBase.CONFIG_RGBA, GlRectDrawer()) }
+ private val readerThread = HandlerThread("xcloud-frames").apply { start() }
+ private val readerHandler = Handler(readerThread.looper)
+ private var reader: ImageReader? = null
+ private var readerW = 0
+ private var readerH = 0
+ /** Images the compositor may still read: the oldest goes back to the reader once two newer ones arrived. */
+ private val held = ArrayDeque()
+ private var surface: Surface? = null
+ private var attached = false
+ @Volatile private var frameGen = FG_OFF
+ @Volatile private var refreshHz = 60f
+ /** The frame-rate target (0 = the screen's rate): the frame-gen pacer's cap, or a limit on stream frames without it. */
+ @Volatile private var fpsTarget = 0
+ private var nextDueNs = 0L
+ @Volatile var frames = 0L
+ private set
+
+ /** The screen: the compositor presents to it (null detaches, e.g. for zero-copy or when the surface goes). */
+ fun setSurface(target: Surface?, width: Int, height: Int, displayRefreshHz: Float) = synchronized(lock) {
+ refreshHz = displayRefreshHz
+ if (target == null) {
+ if (attached) letGo()
+ attached = false; surface = null
+ return@synchronized
+ }
+ surface = target
+ val runtime = File(context.cacheDir, "xcloud-wayland").apply { mkdirs() }
+ // System Vulkan driver; this process's compositor shows only the stream.
+ val started = CompositorHost.startOrAttach(context, target, runtime.path, null, null, context.applicationInfo.nativeLibraryDir,
+ width, height, displayRefreshHz, 0)
+ if (started) {
+ WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
+ log("compositor started on ${width}x$height at ${displayRefreshHz.toInt()} Hz")
+ } else {
+ WaylandCompositor.nativeResizeOutput(width, height)
+ }
+ WaylandCompositor.nativeStreamMode(true)
+ attached = true
+ applyFrameGen()
+ }
+
+ /**
+ * Gives the screen surface up and waits until the compositor has really disconnected from it: the window request
+ * is applied on the compositor thread at its next tick, and the decoder (zero-copy) can only connect after that.
+ */
+ private fun letGo() {
+ WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
+ CompositorHost.detach(surface)
+ WaylandCompositor.nativeVsync(System.nanoTime())
+ if (!WaylandCompositor.nativeWaitSurface(1000)) log("compositor did not let go of the screen within 1 s")
+ }
+
+ /** Frame-rate target, 0 = the screen's rate. Live. */
+ fun setFpsTarget(fps: Int) {
+ fpsTarget = fps
+ synchronized(lock) { if (attached) applyFrameGen() }
+ }
+
+ /** off, ddfg (2x) or lsfg / lsfg3 / lsfg4 (needs the Lossless.dll). Live. */
+ fun setFrameGeneration(mode: String) {
+ frameGen = mode
+ synchronized(lock) { if (attached) applyFrameGen() }
+ }
+
+ override fun onFrame(frame: VideoFrame) {
+ val w = frame.rotatedWidth; val h = frame.rotatedHeight
+ synchronized(lock) { if (w != readerW || h != readerH) startReader(w, h) }
+ egl.onFrame(frame)
+ }
+
+ private fun startReader(w: Int, h: Int) {
+ val old = reader
+ if (old != null) egl.releaseEglSurface { }
+ held.forEach { runCatching { it.close() } }; held.clear()
+ old?.close()
+ readerW = w; readerH = h
+ val next = ImageReader.newInstance(w, h, PixelFormat.RGBA_8888, 4,
+ HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE or HardwareBuffer.USAGE_GPU_COLOR_OUTPUT)
+ next.setOnImageAvailableListener({ r -> onImage(r) }, readerHandler)
+ reader = next
+ egl.createEglSurface(next.surface)
+ log("native video ${w}x$h")
+ }
+
+ private fun onImage(r: ImageReader) {
+ val image = runCatching { r.acquireLatestImage() }.getOrNull() ?: return
+ synchronized(lock) {
+ if (r !== reader) { image.close(); return }
+ val buffer = image.hardwareBuffer
+ // Without frame generation a target below the stream's rate drops stream frames evenly: each frame has a
+ // due time one interval after the last one's, so 30 of 60 frames (or 45: three of four) reach the screen.
+ val now = System.nanoTime()
+ val target = fpsTarget
+ val skip = frameGen == FG_OFF && target in 1 until 60 && run {
+ val interval = 1_000_000_000L / target
+ if (nextDueNs == 0L || now - nextDueNs > interval) nextDueNs = now
+ if (now + 4_000_000L < nextDueNs) true else { nextDueNs += interval; false }
+ }
+ if (attached && buffer != null && !skip) { WaylandCompositor.nativeStreamFrame(buffer); frames++ }
+ buffer?.close()
+ held.addLast(image)
+ while (held.size > 2) held.removeFirst().close()
+ }
+ }
+
+ private fun applyFrameGen() {
+ // The pacer caps generated output at this rate: the user's target, else the screen's.
+ val cap = if (fpsTarget > 0) fpsTarget.toFloat() else refreshHz
+ val mode = when {
+ frameGen == FG_DDFG -> FrameGen.Mode(FrameGen.ENGINE_DDFG, 2)
+ isLsfg(frameGen) -> FrameGen.Mode(FrameGen.ENGINE_LSFG, multiplier(frameGen))
+ else -> FrameGen.Mode.OFF
+ }
+ val problem = FrameGen.apply(context, mode, cap)
+ log("native frame generation: $frameGen, target ${if (fpsTarget > 0) fpsTarget else "screen"} fps" + (problem?.let { " ($it)" } ?: ""))
+ }
+
+ /** {planned, planned, sourceFps, presentedFps, thermal, -1}, or null while nothing is shown. */
+ fun stats(): FloatArray? = synchronized(lock) { if (attached) WaylandCompositor.nativeFrameGenStats() else null }
+
+ fun frameGenProblem(): Int = synchronized(lock) { if (attached) WaylandCompositor.nativeFrameGenProblem() else -1 }
+
+ fun release() {
+ egl.release()
+ synchronized(lock) {
+ if (attached) { WaylandCompositor.nativeStreamMode(false); letGo() }
+ attached = false; surface = null
+ held.forEach { runCatching { it.close() } }; held.clear()
+ reader?.close(); reader = null
+ }
+ readerThread.quitSafely()
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt
index 28d6c12d99..d1ba4a52e7 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt
@@ -46,7 +46,7 @@ internal object XboxRuntime {
val market = game.second.extra["market"]?.takeIf { it.matches(Regex("[A-Z]{2}")) } ?: Xodus.market()
val directory = views.create(app.filesDir)
val process = try {
- Xodus.start(app, listOf("run", game.first.path, "droiddeck:prepare", "--exe", game.second.exe,
+ Xodus.start(app, listOf("run", StoreInstallRoot.guestPathForXodus(app, game.first), "droiddeck:prepare", "--exe", game.second.exe,
"--materialize-chain", "--market", market), launchDirectory = directory, credentialGeneration = credentials)
} catch (e: Exception) { XboxLaunchViews.remove(directory); throw e }
if (!launches.attach(token, process)) { process.close(); error("Xbox launch was cancelled") }
diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt
index 6e7c30df84..5d6160c44d 100644
--- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt
+++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt
@@ -5,7 +5,9 @@ import android.os.Environment
import com.droiddeck.launcher.core.AddonPack
import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent
import com.droiddeck.launcher.runtime.LinuxRuntime
+import com.droiddeck.launcher.runtime.ProotFastPath
import com.droiddeck.launcher.session.SessionPrefs
+import com.droiddeck.launcher.stores.StoreInstallRoot
import org.json.JSONObject
import java.io.Closeable
import java.io.File
@@ -79,17 +81,34 @@ internal object Xodus {
networkLink.publish()
networkLink.start()
val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() }
- val command = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), listOf(
+ val root = LinuxRuntime.rootDir(app)
+ val external = Environment.getExternalStorageDirectory()
+ val extraBinds = StoreInstallRoot.externalBindSpecsForXodus(app)
+ val binds = LinuxRuntime.binds(app, null, null, external, extraBinds)
+ val fastPathPreloaded = runCatching {
+ File(root, "etc/ld.so.preload").useLines { lines -> lines.any { it.trim() == ProotFastPath.LIBRARY } }
+ }.getOrDefault(false)
+ val fastPathKey = if (ProotFastPath.enabled(app) && fastPathPreloaded &&
+ File(root, ProotFastPath.LIBRARY.removePrefix("/")).isFile) ProotFastPath.key(root, binds) else null
+ val guestCommand = mutableListOf(
"/usr/bin/env", "HOME=/root", "XODUS_LOG=off", "RUST_LOG=off",
"XDG_RUNTIME_DIR=${runtime.path}", "DROIDDECK_XBOX_CREDENTIAL_SOCKET=${credentials.name}", binary,
- ) + args)
+ )
+ fastPathKey?.let { key ->
+ guestCommand.addAll(guestCommand.lastIndex, ProotFastPath.guestEnv(root, binds, key))
+ }
+ guestCommand.addAll(args)
+ val command = LinuxRuntime.commandWithBinds(app, root, binds, guestCommand)
val builder = ProcessBuilder(command).directory(LinuxRuntime.rootDir(app))
if (launchDirectory != null) builder.environment()["TMPDIR"] = launchDirectory.path
+ builder.environment()["DROIDDECK_XBOX_CREDENTIAL_PORT"] = credentials.port.toString()
+ builder.environment()["DROIDDECK_XBOX_CREDENTIAL_KEY"] = credentials.key
builder.environment().apply {
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path)
put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path)
if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1")
+ fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } }
LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
}
val digest = java.security.MessageDigest.getInstance("SHA-256")
@@ -133,11 +152,14 @@ internal object Xodus {
}
}
- fun diagnostics(child: Child): Thread = Thread({
+ const val SIGN_IN_REJECTED = "Microsoft content licensing rejected sign-in \\(HTTP 401\\)\\. Sign in again in Settings\\."
+
+ /** Passes the backend's known stderr diagnostics to [report]; other stderr text never leaves the process. */
+ fun diagnostics(child: Child, report: (String) -> Unit = { com.droiddeck.launcher.stores.StoresState.logLine("Xbox: $it") }): Thread = Thread({
runCatching {
child.process.errorStream.bufferedReader().useLines { lines -> lines.forEach { line ->
- if (line.matches(Regex("NEXUS_CREDENTIAL_ERROR_V1 [a-z-]{1,48}|NEXUS_LIBRARY_DIAGNOSTIC_V1 [a-z-]{1,48} [0-9]{1,3} [0-9]{1,6}|NEXUS_SESSION_DIAGNOSTIC_V1 [a-z-]{1,64}|Account library unavailable \\([a-z-]{1,64}\\); credentials and installed games are unchanged\\.|Account library timed out; installed games are unchanged\\.")))
- com.droiddeck.launcher.stores.StoresState.logLine("Xbox: $line")
+ if (line.matches(Regex("NEXUS_CREDENTIAL_ERROR_V1 [a-z-]{1,48}|NEXUS_LIBRARY_DIAGNOSTIC_V1 [a-z-]{1,48} [0-9]{1,3} [0-9]{1,6}|NEXUS_SESSION_DIAGNOSTIC_V1 [a-z-]{1,64}|Account library unavailable \\([a-z-]{1,64}\\); credentials and installed games are unchanged\\.|Account library timed out; installed games are unchanged\\.|Xbox profile is temporarily unavailable \\([a-z-]{1,48}\\); stored account is unchanged\\.|Xbox profile request timed out; stored account is unchanged\\.|NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 [a-z-]{1,48} [0-9]{3}|$SIGN_IN_REJECTED")))
+ report(line)
} }
}
}, "xbox-diagnostics").apply { start() }
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AddAppDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/AddAppDialog.kt
index 5e63d7b0f2..b3b88f0aa4 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/AddAppDialog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/AddAppDialog.kt
@@ -308,6 +308,7 @@ internal fun AppDialog(
width: Dp? = null, fitContent: Boolean = false,
back: (() -> Unit)? = null,
scrollable: Boolean = true,
+ scrollState: androidx.compose.foundation.ScrollState = rememberScrollState(),
content: @Composable ColumnScope.() -> Unit,
) {
val pal = LocalPalette.current
@@ -345,7 +346,7 @@ internal fun AppDialog(
.blockTouches()
.controllerBack(back ?: close)
.then(modifier)
- .then(if (scrollable) Modifier.verticalScroll(rememberScrollState()) else Modifier)
+ .then(if (scrollable) Modifier.verticalScroll(scrollState) else Modifier)
.padding(horizontal = 18.dp, vertical = 16.dp),
content = content,
)
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt b/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt
index a4227d4c28..c4d8053d98 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt
@@ -676,14 +676,15 @@ private fun MoviePreview(url: String, modifier: Modifier = Modifier) {
/** A dialog with one text box, for a search term or a page number; the Android keyboard comes up with it. */
@Composable
-private fun TextEntryDialog(
+internal fun TextEntryDialog(
title: String, initial: String, number: Boolean, confirm: String, onSubmit: (String) -> Unit, onDismiss: () -> Unit,
+ id: String = "boot-movie-entry",
) {
val shown = rememberShown(onDismiss)
val close = { shown.targetState = false }
var text by remember { mutableStateOf(initial) }
val submit = { onSubmit(text.trim()); close() }
- AppDialog(shown, close, "boot-movie-entry", wide = false, maxWidth = 460.dp) {
+ AppDialog(shown, close, id, wide = false, maxWidth = 460.dp) {
DialogTitleRow(title, close)
AdbTextField(
value = text, onValueChange = { text = it }, label = "", keyboardType = if (number) KeyboardType.Number else KeyboardType.Text,
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ColorPickerDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ColorPickerDialog.kt
index e94f193e95..d83e1abe10 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/ColorPickerDialog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/ColorPickerDialog.kt
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@@ -70,12 +71,15 @@ internal fun ColorPickerDialog(title: String, initial: Int, onDismiss: () -> Uni
var hexText by remember { mutableStateOf(ThemeColors.hex(initial)) }
val current = ThemeColors.fromHsv(hue, sat, value)
val first = remember { FocusRequester() }
+ val scroll = rememberScrollState()
+ var typingHex by remember { mutableStateOf(false) }
LaunchedEffect(Unit) { focusSoon { first } }
+ LaunchedEffect(typingHex, scroll.maxValue) { if (typingHex) scroll.animateScrollTo(scroll.maxValue) }
fun picked(h: Float = hue, s: Float = sat, v: Float = value) {
hue = h.coerceIn(0f, 360f); sat = s.coerceIn(0f, 1f); value = v.coerceIn(0f, 1f)
hexText = ThemeColors.hex(ThemeColors.fromHsv(hue, sat, value))
}
- AppDialog(shown, close, "colorPicker", wide = false, maxWidth = 460.dp) {
+ AppDialog(shown, close, "colorPicker", wide = false, maxWidth = 460.dp, scrollState = scroll) {
DialogTitleRow(title, close)
Row(horizontalArrangement = Arrangement.spacedBy(14.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
ColorWheel(hue, sat, value) { h, s -> picked(h = h, s = s) }
@@ -95,6 +99,7 @@ internal fun ColorPickerDialog(title: String, initial: Int, onDismiss: () -> Uni
ThemeColors.parseHex(text)?.let { argb -> ThemeColors.toHsv(argb).let { hsv -> hue = hsv.h; sat = hsv.s; value = hsv.v } }
},
label = "", keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done, placeholder = stringResource(R.string.theme_color_hex),
+ onFocusChange = { typingHex = it },
onDone = { ThemeColors.parseHex(hexText)?.let { onApply(it); close() } },
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth()) {
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt
index f6ce824ea8..39862c0823 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt
@@ -70,6 +70,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
@@ -102,6 +103,7 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
val ctx = LocalContext.current
val density = LocalDensity.current
val narrow = LocalNarrowPane.current
+ val short = compactDesktop()
val colors = MaterialTheme.colorScheme
LaunchedEffect(Unit) { UserAppsState.refresh(ctx) }
LaunchedEffect(s.ready) { com.droiddeck.launcher.store.StoreState.refresh(ctx) }
@@ -120,7 +122,7 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
key = "desktop", tabs = tabs,
onOpen = a.onDesktopSettings, onPrimary = a.onDesktop,
modifier = modifier.clipToBounds(),
- start = if (narrow) 20.dp else 44.dp, bottom = if (narrow) 20.dp else 44.dp,
+ start = if (narrow) 20.dp else 44.dp, bottom = 44.dp,
background = {
DesktopWall(installed.map { it.iconRes } + apps.mapNotNull { it.icon })
},
@@ -132,8 +134,8 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
},
words = {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Text(
- stringResource(R.string.rail_desktop), fontSize = if (narrow) 30.sp else 42.sp, lineHeight = if (narrow) 34.sp else 46.sp,
+ if (LocalConfiguration.current.screenHeightDp >= 400) Text(
+ stringResource(R.string.rail_desktop), fontSize = if (short) 30.sp else 42.sp, lineHeight = if (short) 34.sp else 46.sp,
fontWeight = FontWeight.Black, color = colors.onBackground,
)
BusyChip(s)
@@ -143,11 +145,12 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
PrimaryButton(open, enabled = !s.busy, main = true, large = true, icon = Icons.Outlined.DesktopWindows, onClick = click)
},
beside = {
- Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
- Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
- HeroIconButton(Icons.Outlined.Storefront, stringResource(R.string.flathub_name), FlathubTeal, "desktop:flathub") { at -> openFrom(at, null, "store") }
- HeroIconButton(Icons.Filled.Add, stringResource(R.string.user_apps_add), null, "desktop:add") { if (!s.busy) adding = true }
- }
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.horizontalScroll(rememberScrollState()),
+ ) {
+ HeroIconButton(Icons.Outlined.Storefront, stringResource(R.string.flathub_name), FlathubTeal, "desktop:flathub") { at -> openFrom(at, null, "store") }
+ HeroIconButton(Icons.Filled.Add, stringResource(R.string.user_apps_add), null, "desktop:add") { if (!s.busy) adding = true }
if (s.desktopPresent) UninstallDesktop(enabled = !s.runtimeActionsBlocked, onUninstall = a.onRemoveDesktop)
}
},
@@ -159,6 +162,9 @@ internal fun DesktopPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
if (adding && !s.busy) AddAppDialog(s.ready, onDismiss = { adding = false }) { request, label -> UserAppsState.add(ctx, request, label) }
}
+@Composable
+private fun compactDesktop() = LocalNarrowPane.current || LocalConfiguration.current.screenHeightDp < 600
+
@Composable
private fun DesktopDock(
s: FrontEndState, a: FrontEndActions, installed: List, apps: List,
@@ -177,7 +183,7 @@ private fun DesktopDock(
LaunchedEffect(Unit) { mounted[0] = true }
val scroll = rememberScrollState()
if (keys.isEmpty() && available.isEmpty() && UserAppsState.working == null && UserAppsState.lastError == null) return
- Column(Modifier.fillMaxWidth().padding(top = if (narrow) 14.dp else 22.dp)) {
+ Column(Modifier.fillMaxWidth().padding(top = if (compactDesktop()) 14.dp else 22.dp)) {
Text(
stringResource(R.string.user_apps_section).uppercase(), fontSize = 11.sp, fontWeight = FontWeight.Bold, letterSpacing = 1.6.sp,
color = colors.onSurfaceVariant, modifier = Modifier.padding(start = if (narrow) 20.dp else 44.dp, bottom = 8.dp),
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ExePickerDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ExePickerDialog.kt
index 901bf64850..9fd3631553 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/ExePickerDialog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/ExePickerDialog.kt
@@ -27,6 +27,8 @@ import androidx.compose.material.icons.outlined.Image
import androidx.compose.material.icons.outlined.InsertDriveFile
import androidx.compose.material.icons.outlined.SdCard
import androidx.compose.material.icons.outlined.Smartphone
+import androidx.compose.material.icons.outlined.Visibility
+import androidx.compose.material.icons.outlined.VisibilityOff
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -81,8 +83,8 @@ internal class PickFolder(val dir: File, val readable: Boolean)
internal class PickListing(val folders: List, val files: List)
-internal fun pickListing(dir: File, kind: PickKind): PickListing {
- val all = dir.listFiles()?.filter { !it.name.startsWith(".") }.orEmpty().sortedBy { it.name.lowercase() }
+internal fun pickListing(dir: File, kind: PickKind, showHidden: Boolean = false): PickListing {
+ val all = dir.listFiles()?.filter { showHidden || !it.name.startsWith(".") }.orEmpty().sortedBy { it.name.lowercase() }
return PickListing(
all.filter { it.isDirectory }.map { PickFolder(it, it.canRead() && it.list() != null) },
all.filter { it.isFile && it.extension.lowercase() in kind.extensions },
@@ -92,11 +94,13 @@ internal fun pickListing(dir: File, kind: PickKind): PickListing {
@Composable
internal fun ExePickerDialog(
title: String, kind: PickKind = PickKind.EXE, start: File? = null,
- onAddAll: ((File) -> Unit)? = null, onPick: (File) -> Unit, onDismiss: () -> Unit,
+ onAddAll: ((File, Boolean) -> Unit)? = null, onPick: (File) -> Unit, onDismiss: () -> Unit,
) {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
val density = LocalDensity.current
+ val prefs = remember(ctx) { ctx.getSharedPreferences("game_picker", Context.MODE_PRIVATE) }
+ var showHidden by remember { mutableStateOf(prefs.getBoolean("show_hidden", false)) }
val shown = rememberShown(onDismiss)
val close = { shown.targetState = false }
val volumes = remember { pickVolumes(ctx) }
@@ -107,14 +111,23 @@ internal fun ExePickerDialog(
val back = { if (dir == null) close() else up() }
val first = remember(dir) { FocusRequester() }
LaunchedEffect(dir) { focusWithinFrames({ false }) { first } }
- val listing = remember(dir) { dir?.let { pickListing(it, kind) } }
+ val listing = remember(dir, showHidden) { dir?.let { pickListing(it, kind, showHidden) } }
var locked by remember { mutableStateOf(null) }
AppDialog(
shown, close, "filePicker", wide = false, maxWidth = 520.dp, width = locked, fitContent = locked == null, back = back,
modifier = Modifier.onSizeChanged { if (locked == null && it.width > 0) locked = with(density) { it.width.toDp() } },
) {
Column(verticalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth()) {
- DialogTitleRow(title, onClose = close)
+ DialogTitleRow(title, onClose = close, leading = {
+ SmallIconButton(
+ if (showHidden) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
+ stringResource(if (showHidden) R.string.fm_hide_hidden else R.string.fm_show_hidden),
+ if (showHidden) colors.primary else colors.onSurfaceVariant,
+ ) {
+ showHidden = !showHidden
+ prefs.edit().putBoolean("show_hidden", showHidden).apply()
+ }
+ })
if (dir != null && volume != null) {
val crumbs = listOf(volume.label) + dir!!.path.removePrefix(volume.root.path).split('/').filter { it.isNotEmpty() }
Text(crumbs.joinToString(" › "), fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
@@ -135,7 +148,7 @@ internal fun ExePickerDialog(
val shownListing = listing ?: PickListing(emptyList(), emptyList())
PickerRow(Icons.AutoMirrored.Outlined.ArrowBack, "..", null, focus = first, onClick = up)
if (onAddAll != null && shownListing.folders.any { it.readable }) {
- PickerRow(Icons.Filled.Add, stringResource(R.string.games_add_all), null, accent = true) { onAddAll(dir!!); close() }
+ PickerRow(Icons.Filled.Add, stringResource(R.string.games_add_all), null, accent = true) { onAddAll(dir!!, showHidden); close() }
}
for (f in shownListing.folders) key(f.dir.path) {
PickerRow(Icons.Outlined.Folder, f.dir.name, null, enabled = f.readable) { dir = f.dir }
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndGames.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndGames.kt
index dcb5eece6d..67d228397d 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndGames.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndGames.kt
@@ -27,6 +27,7 @@ import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
@@ -74,16 +75,28 @@ internal fun GamesPage(s: FrontEndState, a: FrontEndActions, selected: String, o
val launcherArt by androidx.compose.runtime.produceState(null, epic.version) {
value = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { EpicClient.icon(pageContext, epic.version) }
}
- val games = remember(s.steamGames, s.shortcutPicker, epic, launcherName, launcherArt) {
+ LaunchedEffect(Unit) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.load(pageContext) }
+ val cloudGames = com.droiddeck.launcher.stores.xbox.XboxCloudGames.entries.toList()
+ val games = remember(s.steamGames, s.shortcutPicker, epic, launcherName, launcherArt, cloudGames) {
val sorted = s.steamGames.sortedByDescending { it.lastPlayed }
- if (s.shortcutPicker) sorted else EpicClient.withLauncher(sorted, EpicClient.launcherEntry(pageContext, launcherName, epic, launcherArt))
+ if (s.shortcutPicker) sorted else {
+ val installedXbox = s.steamGames.filter { it.source == com.droiddeck.launcher.stores.Store.XBOX.id }.mapNotNull { it.storeId }.toSet()
+ EpicClient.withLauncher(sorted, EpicClient.launcherEntry(pageContext, launcherName, epic, launcherArt)) +
+ com.droiddeck.launcher.stores.xbox.XboxCloudGames.rows(pageContext, installedXbox)
+ }
}
val gameCount = games.count { it.library != Library.EPIC_LAUNCHER }
val narrow = LocalNarrowPane.current
val current = games.firstOrNull { "app:${it.appId}" == selected } ?: games.firstOrNull()
GamesDialogs(a, s.steamGames)
val onAdd: (() -> Unit)? = if (s.shortcutPicker) null else ({ GamesDialogState.adding = true })
- val launch: (Library.SteamGame) -> Unit = { g -> if (g.library == Library.EPIC_LAUNCHER) a.onEpicLauncher() else a.onSteamGame(g) }
+ val launch: (Library.SteamGame) -> Unit = { g ->
+ when (g.library) {
+ Library.EPIC_LAUNCHER -> a.onEpicLauncher()
+ Library.XBOX_CLOUD -> com.droiddeck.launcher.stores.xbox.XboxCloudGames.stream(pageContext, g.storeId.orEmpty(), g.name)
+ else -> a.onSteamGame(g)
+ }
+ }
val onEdit: (Library.SteamGame) -> Unit = { g ->
g.gameFiles?.let { GamesDialogState.editing = EditRequest(it.path, openTarget = false, fromSummary = false, preview = EditPreview.of(pageContext, g, it.path)) }
}
@@ -119,8 +132,10 @@ internal fun GamesPage(s: FrontEndState, a: FrontEndActions, selected: String, o
if (!narrow) Poster(current.art, current.name, Modifier.width(168.dp))
}
}
- Rise(1) { SectionTitle(stringResource(R.string.games_launch_settings), null) }
- Rise(2) { LaunchSettings(s, a, host, current) }
+ if (current.library != Library.XBOX_CLOUD) {
+ Rise(1) { SectionTitle(stringResource(R.string.games_launch_settings), null) }
+ Rise(2) { LaunchSettings(s, a, host, current) }
+ }
Rise(3) { GameFileFolderActions(s, a) }
}
return
@@ -138,8 +153,10 @@ internal fun GamesPage(s: FrontEndState, a: FrontEndActions, selected: String, o
GameHeroCopy(current, if (narrow) 24.sp else 32.sp)
GameActions(current, s, a, onEdit, launch)
}
- SectionTitle(stringResource(R.string.games_launch_settings), null)
- LaunchSettings(s, a, host, current)
+ if (current.library != Library.XBOX_CLOUD) {
+ SectionTitle(stringResource(R.string.games_launch_settings), null)
+ LaunchSettings(s, a, host, current)
+ }
GameFileFolderActions(s, a)
}
}
@@ -165,8 +182,25 @@ private fun GameFileFolderActions(s: FrontEndState, a: FrontEndActions) {
@Composable
private fun GameActions(g: Library.SteamGame, s: FrontEndState, a: FrontEndActions, onEdit: (Library.SteamGame) -> Unit, launch: (Library.SteamGame) -> Unit) {
+ val context = androidx.compose.ui.platform.LocalContext.current
+ if (g.library == Library.XBOX_CLOUD) {
+ androidx.compose.runtime.LaunchedEffect(g.gameId) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.prefetch(context) }
+ Actions {
+ PrimaryButton("Stream", enabled = !s.busy, main = true, icon = Icons.Filled.PlayArrow) { launch(g) }
+ SecondaryButton("Download") { com.droiddeck.launcher.stores.StoresState.openGameRequest = "${com.droiddeck.launcher.stores.Store.XBOX.id}:${g.storeId}" }
+ SecondaryButton("Remove from Games", compact = true) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.remove(context, g.storeId.orEmpty()) }
+ BusyChip(s)
+ }
+ return
+ }
+ val xboxStream by androidx.compose.runtime.produceState(false, g.gameId) {
+ value = g.source == com.droiddeck.launcher.stores.Store.XBOX.id && !g.storeId.isNullOrEmpty() && !s.shortcutPicker &&
+ kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.streams(context, g.storeId!!) }
+ }
+ androidx.compose.runtime.LaunchedEffect(xboxStream) { if (xboxStream) com.droiddeck.launcher.stores.xbox.XboxCloudGames.prefetch(context) }
Actions {
PrimaryButton(stringResource(if (s.shortcutPicker) R.string.game_shortcut_choose else R.string.games_launch), enabled = !s.busy, main = true, icon = Icons.Filled.PlayArrow) { launch(g) }
+ if (xboxStream) SecondaryButton("Stream") { com.droiddeck.launcher.stores.xbox.XboxCloudGames.stream(context, g.storeId.orEmpty(), g.name) }
if (g.library == Library.EPIC_LAUNCHER) {
if (!s.shortcutPicker) UninstallEpicLauncher(s, a)
BusyChip(s)
@@ -341,11 +375,24 @@ private fun ColumnScope.GameHeroCopy(g: Library.SteamGame, titleSize: androidx.c
maxLines = 1, overflow = TextOverflow.Ellipsis,
)
}
- Text(
+ GameTitle(g, titleSize)
+ Spacer(Modifier.height(8.dp))
+}
+
+@Composable
+private fun GameTitle(g: Library.SteamGame, titleSize: androidx.compose.ui.unit.TextUnit) {
+ val logo = g.logo
+ var failed by remember(logo) { androidx.compose.runtime.mutableStateOf(false) }
+ if (logo != null && !failed) {
+ AsyncImage(
+ model = logo, contentDescription = g.name, contentScale = ContentScale.Fit, alignment = Alignment.CenterStart,
+ onError = { failed = true },
+ modifier = Modifier.padding(vertical = 4.dp).height((titleSize.value * 2.2f).dp).widthIn(max = (titleSize.value * 9f).dp).testTag("game-logo"),
+ )
+ } else Text(
g.name, fontSize = titleSize, lineHeight = titleSize * 1.15f, fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onBackground, maxLines = 2, overflow = TextOverflow.Ellipsis,
)
- Spacer(Modifier.height(8.dp))
}
@Composable
@@ -410,7 +457,7 @@ private fun GamesDialogs(a: FrontEndActions, games: List) {
val st = GamesDialogState
if (st.adding) ExePickerDialog(
stringResource(R.string.games_add_title),
- onAddAll = { dir ->
+ onAddAll = { dir, showHidden ->
st.summary = emptyList() to 0
st.checking = dir.name
scope.launch {
@@ -419,6 +466,7 @@ private fun GamesDialogs(a: FrontEndActions, games: List) {
ctx.applicationContext, dir,
onGame = { g -> scope.launch { st.summary?.let { (list, n) -> st.summary = (list + g) to n } } },
onChecking = { name -> scope.launch { st.checking = name } },
+ showHidden = showHidden,
)
}
st.checking = null
@@ -622,6 +670,7 @@ private fun playedSpan(lastPlayed: Long): String? {
@Composable
private fun libraryLabel(g: Library.SteamGame): String = when {
g.library == Library.EPIC_LAUNCHER -> EpicClient.status.version?.substringBefore('+')?.let { stringResource(R.string.epic_client_version, it) } ?: ""
+ g.library == Library.XBOX_CLOUD -> "Xbox Cloud Gaming"
g.library != Library.ADDED -> if (g.library == "internal") stringResource(R.string.games_internal) else g.library
g.source != Library.ADDED -> stringResource(R.string.games_store_storage)
else -> ""
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt
index 1c4c9a44bf..d751a90a4b 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt
@@ -145,7 +145,7 @@ class FrontEndState(
/** Setup's "Safe mode" for the Mali bridge (SessionPrefs.vkBridgeSafe), on by default. */
val vkBridgeSafe: Boolean = true,
val showPhantomGate: Boolean = false,
- val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
+ val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
val launcherFullscreen: Boolean = true,
val downloadSource: String = DownloadSource.MODE_AUTO,
val downloadMirror: String = "",
@@ -413,6 +413,9 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
}
a.onNavigated()
}
+ LaunchedEffect(com.droiddeck.launcher.stores.StoresState.openGameRequest) {
+ if (com.droiddeck.launcher.stores.StoresState.openGameRequest != null) selected = "stores"
+ }
var showWirelessAdbFix by rememberSaveable { mutableStateOf(false) }
var showDeveloperDisplayChoice by rememberSaveable { mutableStateOf(false) }
var wirelessAdbDesiredEnabled by rememberSaveable { mutableStateOf(false) }
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt
index 9ce1eacced..b818abe824 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt
@@ -396,6 +396,7 @@ internal fun SetupPanel(
}
}
}
+ if (s.theme == Themes.INNER_GAMER) RgbSpeedRow()
if (s.theme == Themes.GRADIENT) GradientColorRows()
ChoiceRow(
host, "app-scale", stringResource(R.string.setup_app_scale), stringResource(R.string.setup_app_scale_hint),
@@ -831,6 +832,13 @@ private fun LanguageRow(host: MenuHost, chosen: String, onPick: (String) -> Unit
}
}
+/** How fast Inner Gamer cycles its colours. */
+@Composable
+private fun RgbSpeedRow() {
+ val ctx = androidx.compose.ui.platform.LocalContext.current.applicationContext
+ SliderRow(stringResource(R.string.theme_rgb_speed), stringResource(R.string.theme_rgb_speed_hint), Themes.rgbSpeed, 1..Themes.RGB_SPEEDS) { Themes.setRgbSpeed(ctx, it) }
+}
+
/** The two colours of the Gradient theme, each a small square that opens the colour picker. */
@Composable
private fun GradientColorRows() {
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GpuDriversPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/GpuDriversPanel.kt
index 72dcaa42f1..917f86ff37 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/GpuDriversPanel.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/GpuDriversPanel.kt
@@ -23,6 +23,7 @@ import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.AnnotatedString
import com.droiddeck.launcher.gpu.DeviceInfo
+import com.droiddeck.launcher.session.SessionPrefs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import androidx.compose.ui.res.stringResource
@@ -133,6 +134,8 @@ class GpuDriversState(
val runtime: DriverSlot = DriverSlot(),
val canRestart: Boolean = true,
val checkedAt: Long = 0L,
+ val tpUbwcMode: String? = null,
+ val tpUbwcRestartRequired: Boolean = false,
) {
val activePair: PairRow? get() = pairs.firstOrNull { it.active }
}
@@ -153,6 +156,7 @@ class GpuDriversActions(
val onRestoreBundled: () -> Unit = {},
val onMode: (String) -> Unit = {},
val onRestart: () -> Unit = {},
+ val onTpUbwcMode: (String) -> Unit = {},
)
@Composable
@@ -265,6 +269,27 @@ internal fun GpuDriversBody(
GPU_MODE_PAIR -> PairBody(gpu, actions)
else -> MixBody(single, actions, slotFocus, onOpenSlot)
}
+ gpu.tpUbwcMode?.let { selected ->
+ var advanced by rememberSaveable { mutableStateOf(false) }
+ SecondaryButton(stringResource(R.string.gpu_advanced) + if (advanced) " ▴" else " ▾", modifier = Modifier.fillMaxWidth()) { advanced = !advanced }
+ AnimatedVisibility(advanced) {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ ChoiceRow(
+ rememberMenuHost(), "tp-ubwc", stringResource(R.string.gpu_ubwc_title),
+ stringResource(R.string.gpu_ubwc_hint),
+ listOf(
+ SessionPrefs.TP_UBWC_AUTO to stringResource(R.string.common_auto),
+ SessionPrefs.TP_UBWC_ON to stringResource(R.string.widgets_on),
+ SessionPrefs.TP_UBWC_OFF to stringResource(R.string.widgets_off),
+ ), selected, onPick = actions.onTpUbwcMode,
+ )
+ if (gpu.tpUbwcRestartRequired) {
+ Text(stringResource(R.string.gpu_ubwc_restart), fontSize = 13.sp, color = AttentionAmber)
+ if (gpu.canRestart) SecondaryButton(stringResource(R.string.gpu_restart_now), onClick = actions.onRestart)
+ }
+ }
+ }
+ }
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ItchBrowseBar.kt b/app/src/main/java/com/droiddeck/launcher/ui/ItchBrowseBar.kt
new file mode 100644
index 0000000000..276d131fee
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/ui/ItchBrowseBar.kt
@@ -0,0 +1,145 @@
+package com.droiddeck.launcher.ui
+
+import androidx.compose.foundation.LocalIndication
+import androidx.compose.foundation.background
+import androidx.compose.foundation.horizontalScroll
+import androidx.compose.foundation.hoverable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.foundation.selection.selectableGroup
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.LinearProgressIndicator
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import com.droiddeck.launcher.R
+import com.droiddeck.launcher.stores.itch.ItchBrowse
+import com.droiddeck.launcher.stores.itch.ItchBrowseState
+
+@Composable
+internal fun ItchBrowseBar() {
+ val ctx = LocalContext.current
+ val query = ItchBrowseState.query
+ var picking by remember { mutableStateOf(false) }
+ Column(Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 8.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
+ ChipRow {
+ for (sort in ItchBrowse.sorts) BrowseChip(sortLabel(sort), query.sort == sort) { ItchBrowseState.choose(ctx, query.copy(sort = sort)) }
+ }
+ ChipRow {
+ for (price in ItchBrowse.prices) BrowseChip(priceLabel(price), query.price == price) { ItchBrowseState.choose(ctx, query.copy(price = price)) }
+ }
+ ChipRow {
+ BrowseChip(stringResource(R.string.stores_itch_platform_any), query.platforms.isEmpty()) { ItchBrowseState.choose(ctx, query.copy(platforms = emptySet())) }
+ for (platform in ItchBrowse.platformNames) {
+ val on = platform in query.platforms
+ BrowseChip(platformLabel(platform), on) { ItchBrowseState.choose(ctx, query.copy(platforms = if (on) query.platforms - platform else query.platforms + platform)) }
+ }
+ }
+ ChipRow {
+ for (tag in query.tags) BrowseChip("$tag ✕", true) { ItchBrowseState.choose(ctx, query.copy(tags = query.tags - tag)) }
+ BrowseChip(stringResource(R.string.stores_itch_tag_add), false) { picking = true }
+ }
+ }
+ if (picking) TextEntryDialog(
+ stringResource(R.string.stores_itch_tag_title), "", number = false, confirm = stringResource(R.string.common_ok),
+ onSubmit = { value -> ItchBrowse.tagSlug(value).takeIf { it.isNotEmpty() }?.let { ItchBrowseState.choose(ctx, query.copy(tags = (query.tags + it).distinct())) } },
+ onDismiss = { picking = false }, id = "itch-tag",
+ )
+}
+
+@Composable
+internal fun ItchLoadMore() {
+ val ctx = LocalContext.current
+ val count = ItchBrowseState.items.size
+ LaunchedEffect(Unit) { ItchBrowseState.more(ctx) }
+ if (ItchBrowseState.loading) LinearProgressIndicator(Modifier.fillMaxWidth().padding(vertical = 12.dp))
+ else if (ItchBrowseState.failed) Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {
+ BrowseChip(stringResource(R.string.stores_dl_retry), false) { ItchBrowseState.more(ctx, retry = true) }
+ }
+ else if (!ItchBrowseState.ended && count > 0) Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {
+ BrowseChip(stringResource(R.string.stores_itch_load_more), false) { ItchBrowseState.more(ctx) }
+ }
+}
+
+@Composable
+private fun ChipRow(content: @Composable () -> Unit) {
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).selectableGroup(),
+ ) { content() }
+}
+
+@Composable
+private fun BrowseChip(label: String, selected: Boolean, onClick: () -> Unit) {
+ val colors = MaterialTheme.colorScheme
+ val pal = LocalPalette.current
+ val shape = RoundedCornerShape(8.dp)
+ val src = remember { MutableInteractionSource() }
+ val hot = rememberHot(src)
+ Text(
+ label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, maxLines = 1,
+ color = if (selected) pal.onSignal else if (hot) colors.onBackground else colors.onSurfaceVariant,
+ modifier = Modifier.clip(shape).background(if (selected) pal.signal else colors.surfaceVariant)
+ .glideBorder(hot, shape, pal.signal)
+ .hoverable(src).selectable(selected = selected, interactionSource = src, indication = LocalIndication.current, role = Role.Tab, onClick = onClick)
+ .controllerConfirm(onClick = onClick)
+ .padding(horizontal = 12.dp, vertical = 7.dp),
+ )
+}
+
+@Composable
+private fun sortLabel(sort: String): String = stringResource(
+ when (sort) {
+ ItchBrowse.SORT_NEW_POPULAR -> R.string.stores_itch_sort_new_popular
+ ItchBrowse.SORT_TOP_SELLERS -> R.string.stores_itch_sort_top_sellers
+ ItchBrowse.SORT_TOP_RATED -> R.string.stores_itch_sort_top_rated
+ ItchBrowse.SORT_NEWEST -> R.string.stores_itch_sort_new
+ else -> R.string.stores_itch_sort_popular
+ },
+)
+
+@Composable
+private fun platformLabel(platform: String): String = stringResource(
+ when (platform) {
+ "windows" -> R.string.stores_itch_platform_windows
+ "osx" -> R.string.stores_itch_platform_macos
+ "linux" -> R.string.stores_itch_platform_linux
+ "android" -> R.string.stores_itch_platform_android
+ "ios" -> R.string.stores_itch_platform_ios
+ "web" -> R.string.stores_itch_platform_web
+ else -> R.string.stores_itch_platform_mobile_web
+ },
+)
+
+@Composable
+private fun priceLabel(price: String): String = stringResource(
+ when (price) {
+ ItchBrowse.PRICE_FREE -> R.string.stores_itch_price_free
+ ItchBrowse.PRICE_SALE -> R.string.stores_itch_price_sale
+ ItchBrowse.PRICE_PAID -> R.string.stores_itch_price_paid
+ ItchBrowse.PRICE_UNDER_5 -> R.string.stores_itch_price_under_5
+ ItchBrowse.PRICE_UNDER_15 -> R.string.stores_itch_price_under_15
+ else -> R.string.stores_itch_price_any
+ },
+)
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt
index 778673e92d..c546a34c35 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt
@@ -65,8 +65,6 @@ class ModeSettings(
val touchMode: String,
val suspendPolicy: String,
val steamDownloadsInBackground: Boolean = false,
- val zramCompression: Boolean? = null,
- val zramSupported: Boolean? = null,
val pipSupported: Boolean = false,
val pipAutoEnter: Boolean = false,
val oscMode: String?,
@@ -84,6 +82,8 @@ class ModeSettings(
val steamClientArch: String? = null,
/** Steam only: a game launched from the front end returns there when it closes; null hides the row. */
val returnAfterGame: Boolean? = null,
+ /** Steam only: the client's Shader Pre-Caching setting; null hides the row. */
+ val shaderPrecache: Boolean? = null,
val steamRepairQueued: Boolean = false,
val mangoapp: Boolean = true,
val steamController: String? = null,
@@ -121,7 +121,6 @@ class ModeSettingsActions(
val onTouch: (String) -> Unit,
val onSuspendPolicy: (String) -> Unit,
val onSteamDownloadsInBackground: (Boolean) -> Unit = {},
- val onZramCompression: (Boolean) -> Unit = {},
val onPipAutoEnter: (Boolean) -> Unit = {},
val onOsc: (String) -> Unit,
val onBackActionsInverted: (Boolean) -> Unit = {},
@@ -139,6 +138,7 @@ class ModeSettingsActions(
val onSteamClientArch: (String) -> Unit = {},
val onMangoapp: (Boolean) -> Unit = {},
val onReturnAfterGame: (Boolean) -> Unit = {},
+ val onShaderPrecache: (Boolean) -> Unit = {},
val onSteamController: (String) -> Unit = {},
val onUnfoldedControls: (Boolean) -> Unit = {},
val onUnfoldedControlsWithController: (Boolean) -> Unit = {},
@@ -333,12 +333,6 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
stringResource(R.string.mode_background_downloads_hint),
s.steamDownloadsInBackground, onChange = a.onSteamDownloadsInBackground,
)
- if (s.zramCompression != null) ToggleRow(
- host, "zram", stringResource(R.string.mode_zram),
- stringResource(if (s.zramSupported == false) R.string.mode_zram_unsupported else R.string.mode_zram_hint),
- s.zramCompression && s.zramSupported != false, enabled = s.zramSupported == true,
- onChange = a.onZramCompression,
- )
if (s.syncBackend != null) ChoiceRow(
host, "sync", stringResource(R.string.sync_backend_title), stringResource(R.string.sync_backend_hint),
listOf(
@@ -487,6 +481,11 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
stringResource(R.string.mode_return_after_game_hint),
s.returnAfterGame, onChange = a.onReturnAfterGame,
)
+ if (s.shaderPrecache != null) ToggleRow(
+ host, "shaderprecache", stringResource(R.string.mode_shader_precache),
+ stringResource(R.string.mode_shader_precache_hint),
+ s.shaderPrecache, onChange = a.onShaderPrecache,
+ )
SettingsRow(
stringResource(R.string.mode_steam_repair),
stringResource(if (s.steamRepairQueued) R.string.mode_steam_repair_queued else R.string.mode_steam_repair_hint),
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt
index b46133463a..25f344a77a 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt
@@ -46,6 +46,7 @@ fun PerformancePage(
gpuClockPin: Boolean,
prootNoSeccomp: Boolean,
prootFastPath: Boolean,
+ cursorComposite: Boolean,
guestHostname: String,
phantomWarning: String?,
onClientOverride: (Boolean) -> Unit,
@@ -61,6 +62,7 @@ fun PerformancePage(
onGpuClockPin: (Boolean) -> Unit,
onProotNoSeccomp: (Boolean) -> Unit,
onProotFastPath: (Boolean) -> Unit,
+ onCursorComposite: (Boolean) -> Unit,
onGuestHostname: (String) -> Unit,
onClientCore: (Int, Boolean) -> Unit,
onGameCore: (Int, Boolean) -> Unit,
@@ -158,6 +160,11 @@ fun PerformancePage(
else stringResource(R.string.perf_fastpath_hint),
prootFastPath && !prootNoSeccomp, enabled = !prootNoSeccomp, onChange = onProotFastPath,
)
+ ToggleRow(
+ host, "cursorcomposite", stringResource(R.string.perf_cursor_composite),
+ stringResource(R.string.perf_cursor_composite_hint),
+ cursorComposite, onChange = onCursorComposite,
+ )
}
SettingsGroup(stringResource(R.string.perf_identity)) {
var draft by remember(guestHostname) { mutableStateOf(guestHostname) }
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionLoading.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionLoading.kt
index 4a0adea2d4..d1c478eb08 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/SessionLoading.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionLoading.kt
@@ -24,7 +24,6 @@ import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.material.icons.Icons
import androidx.compose.foundation.layout.heightIn
-import androidx.compose.material.icons.filled.Pause
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Icon
import androidx.compose.foundation.Canvas
@@ -345,37 +344,3 @@ private fun CancelHint(onCancel: () -> Unit, modifier: Modifier = Modifier) {
Text(stringResource(R.string.common_cancel), fontSize = 13.sp, color = colors.onSurfaceVariant)
}
}
-
-@Composable
-fun SessionPausedOverlay(title: String = stringResource(R.string.load_steam_paused), onResume: () -> Unit) {
- val colors = MaterialTheme.colorScheme
- val pal = LocalPalette.current
- val resumeFocus = remember { FocusRequester() }
- LaunchedEffect(Unit) {
- androidx.compose.runtime.withFrameNanos { }
- runCatching { resumeFocus.requestFocus() }
- }
- Box(
- modifier = Modifier
- .fillMaxSize()
- .background(pal.background.copy(alpha = 0.94f))
- .blockTouches(),
- contentAlignment = Alignment.Center,
- ) {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(10.dp),
- modifier = Modifier.widthIn(max = 440.dp).padding(32.dp),
- ) {
- Box(contentAlignment = Alignment.Center, modifier = Modifier.padding(bottom = 6.dp).size(64.dp).border(2.dp, pal.line2, CircleShape)) {
- Icon(Icons.Filled.Pause, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(30.dp))
- }
- Text(title, fontSize = 28.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, textAlign = TextAlign.Center)
- PrimaryButton(
- stringResource(R.string.resume_session),
- modifier = Modifier.padding(top = 14.dp).focusRequester(resumeFocus).controllerConfirm(onClick = onResume),
- onClick = onResume,
- )
- }
- }
-}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionPausedOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionPausedOverlay.kt
new file mode 100644
index 0000000000..b7f5cbfebe
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionPausedOverlay.kt
@@ -0,0 +1,276 @@
+package com.droiddeck.launcher.ui
+
+import android.os.Build
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.CubicBezierEasing
+import androidx.compose.animation.core.FastOutLinearInEasing
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.LinearOutSlowInEasing
+import androidx.compose.animation.core.Spring
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.keyframes
+import androidx.compose.animation.core.rememberInfiniteTransition
+import androidx.compose.animation.core.tween
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.rounded.PlayArrow
+import androidx.compose.material3.Icon
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.State
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberUpdatedState
+import androidx.compose.runtime.snapshotFlow
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.withFrameNanos
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.blur
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.draw.drawBehind
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.graphics.ColorMatrix
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.StrokeCap
+import androidx.compose.ui.graphics.drawscope.Stroke
+import androidx.compose.ui.graphics.drawscope.rotate
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.dp
+import com.droiddeck.launcher.R
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withTimeoutOrNull
+
+/** The last game frame, captured as the session left the screen, and where it sat in the overlay. */
+class PausedFrame(val image: ImageBitmap, val bounds: android.graphics.Rect)
+
+private const val CARD_SCALE = 0.82f
+private const val FRAME_WAIT_MS = 600L
+
+private fun tone(saturation: Float, brightness: Float): ColorMatrix =
+ ColorMatrix().apply {
+ setToSaturation(saturation)
+ timesAssign(ColorMatrix().apply { setToScale(brightness, brightness, brightness, 1f) })
+ }
+
+@Composable
+fun SessionPausedOverlay(
+ suspended: Boolean,
+ engaged: Boolean,
+ failures: Int,
+ frame: PausedFrame?,
+ title: String,
+ onResume: () -> Unit,
+ onFrameNeeded: () -> Unit,
+ onHidden: () -> Unit,
+) {
+ val currentFrame by rememberUpdatedState(frame)
+ var shown by remember { mutableStateOf(suspended) }
+ val lift = remember { Animatable(if (suspended) 1f else 0f) }
+ val orb = remember { Animatable(if (suspended) 1f else 0f) }
+ val press = remember { Animatable(1f) }
+ val ring = remember { Animatable(0f) }
+ val shake = remember { Animatable(0f) }
+
+ LaunchedEffect(suspended, engaged) {
+ when {
+ suspended && !engaged -> {
+ if (!shown) {
+ if (currentFrame == null) {
+ onFrameNeeded()
+ withTimeoutOrNull(FRAME_WAIT_MS) { snapshotFlow { currentFrame }.first { it != null } }
+ }
+ // Pausing mostly happens while the screen is off or the app is away, so it appears already settled.
+ press.snapTo(1f)
+ ring.snapTo(0f)
+ lift.snapTo(1f)
+ orb.snapTo(1f)
+ shown = true
+ return@LaunchedEffect
+ }
+ launch { press.animateTo(1f, Motion.sp(0.5f, Spring.StiffnessMedium)) }
+ launch { ring.animateTo(0f, Motion.tw(200)) }
+ orb.animateTo(1f, Motion.tw(200))
+ }
+ suspended -> {
+ if (!shown) return@LaunchedEffect
+ launch { orb.animateTo(1f, Motion.tw(200)) }
+ launch { press.animateTo(0.92f, Motion.tw(140)) }
+ ring.animateTo(0.25f, Motion.tw(140))
+ ring.animateTo(0.8f, Motion.tw(650, easing = CubicBezierEasing(0.1f, 0.6f, 0.3f, 1f)))
+ ring.animateTo(0.92f, Motion.tw(2000, easing = LinearOutSlowInEasing))
+ }
+ shown -> {
+ ring.animateTo(1f, Motion.tw(110))
+ coroutineScope {
+ launch { orb.animateTo(0f, Motion.tw(220, easing = FastOutLinearInEasing)) }
+ lift.animateTo(0f, Motion.sp(0.62f, 380f))
+ }
+ shown = false
+ ring.snapTo(0f)
+ press.snapTo(1f)
+ onHidden()
+ }
+ }
+ }
+
+ val seenFailures = remember { mutableIntStateOf(failures) }
+ LaunchedEffect(failures) {
+ if (failures == seenFailures.intValue) return@LaunchedEffect
+ seenFailures.intValue = failures
+ if (!shown || Motion.scale == 0f) return@LaunchedEffect
+ shake.animateTo(0f, keyframes {
+ durationMillis = Motion.ms(360)
+ 10f at Motion.ms(60)
+ -8f at Motion.ms(140)
+ 5f at Motion.ms(220)
+ -2f at Motion.ms(300)
+ })
+ }
+
+ if (!shown) return
+
+ val presence = lift.value.coerceIn(0f, 1f)
+ val idle = suspended && !engaged
+ val focus = remember { FocusRequester() }
+ LaunchedEffect(Unit) {
+ withFrameNanos { }
+ runCatching { focus.requestFocus() }
+ }
+ val resumeLabel = stringResource(R.string.resume_session)
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .fillMaxSize()
+ .semantics { contentDescription = title }
+ .focusRequester(focus)
+ .controllerConfirm(enabled = idle, onClick = onResume)
+ .clickable(
+ interactionSource = remember { MutableInteractionSource() },
+ indication = null,
+ role = Role.Button,
+ onClickLabel = resumeLabel,
+ ) { if (idle) onResume() },
+ ) {
+ if (frame != null) {
+ PausedCard(frame, lift.value, presence)
+ } else {
+ Box(Modifier.fillMaxSize().graphicsLayer { alpha = presence }.background(Color.Black.copy(alpha = 0.55f)))
+ }
+ ResumeOrb(orb.value, press.value, ring.value, shake.value, idle)
+ }
+}
+
+@Composable
+private fun BoxScope.PausedCard(frame: PausedFrame, lift: Float, presence: Float) {
+ val density = LocalDensity.current
+ val bounds = frame.bounds
+ val ambient = remember { ColorFilter.colorMatrix(tone(0.1f, 0.3f)) }
+ Box(Modifier.fillMaxSize().graphicsLayer { alpha = presence }.background(Color.Black)) {
+ Image(
+ frame.image, contentDescription = null, contentScale = ContentScale.Crop, colorFilter = ambient,
+ modifier = Modifier.fillMaxSize().then(if (Build.VERSION.SDK_INT >= 31) Modifier.blur(32.dp) else Modifier),
+ )
+ }
+ Image(
+ frame.image, contentDescription = null, contentScale = ContentScale.FillBounds,
+ colorFilter = ColorFilter.colorMatrix(tone(1f - 0.92f * presence, 1f - 0.45f * presence)),
+ modifier = Modifier
+ .align(Alignment.TopStart)
+ .offset { IntOffset(bounds.left, bounds.top) }
+ .size(with(density) { bounds.width().toDp() }, with(density) { bounds.height().toDp() })
+ .graphicsLayer {
+ val scale = 1f - (1f - CARD_SCALE) * lift
+ scaleX = scale
+ scaleY = scale
+ shape = RoundedCornerShape((20f * presence).dp)
+ clip = true
+ shadowElevation = 24.dp.toPx() * presence
+ },
+ )
+}
+
+@Composable
+private fun ResumeOrb(presence: Float, press: Float, ring: Float, shake: Float, idle: Boolean) {
+ val glintAlpha by animateFloatAsState(if (idle) 1f else 0f, Motion.tw(160), label = "glintAlpha")
+ val glint: State? = if (Motion.scale > 0f) {
+ rememberInfiniteTransition(label = "glint").animateFloat(
+ 0f, 360f, infiniteRepeatable(tween(Motion.ms(3600), easing = LinearEasing)), label = "glintAngle",
+ )
+ } else null
+ Box(
+ contentAlignment = Alignment.Center,
+ modifier = Modifier
+ .size(96.dp)
+ .graphicsLayer {
+ val scale = press * (0.4f + 0.6f * presence)
+ scaleX = scale
+ scaleY = scale
+ alpha = presence.coerceIn(0f, 1f)
+ translationX = shake.dp.toPx()
+ }
+ .drawBehind {
+ val halo = size.minDimension * 0.8f
+ drawCircle(Brush.radialGradient(0.6f to Color.Black.copy(alpha = 0.35f), 1f to Color.Transparent, radius = halo), radius = halo)
+ }
+ .clip(CircleShape)
+ .background(Color.White.copy(alpha = 0.08f))
+ .drawWithContent {
+ drawContent()
+ val stroke = 2.5.dp.toPx()
+ val radius = size.minDimension / 2f * 0.92f
+ if (glint != null && glintAlpha > 0f) {
+ rotate(glint.value) {
+ drawCircle(
+ Brush.sweepGradient(
+ 0f to Color.Transparent,
+ 0.083f to Color.White.copy(alpha = 0.4f * glintAlpha),
+ 0.166f to Color.Transparent,
+ 1f to Color.Transparent,
+ ),
+ radius = radius, style = Stroke(stroke),
+ )
+ }
+ }
+ if (ring > 0f) {
+ drawArc(
+ Color.White, startAngle = -90f, sweepAngle = 360f * ring.coerceAtMost(1f), useCenter = false,
+ topLeft = Offset(center.x - radius, center.y - radius), size = Size(radius * 2f, radius * 2f),
+ style = Stroke(stroke, cap = StrokeCap.Round),
+ )
+ }
+ },
+ ) {
+ Icon(Icons.Rounded.PlayArrow, contentDescription = null, tint = Color.White, modifier = Modifier.size(48.dp))
+ }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresDetail.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresDetail.kt
index b377f02ec1..37dbd3cf7d 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/StoresDetail.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresDetail.kt
@@ -51,6 +51,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.droiddeck.launcher.R
+import com.droiddeck.launcher.stores.xbox.xboxCloud
+import com.droiddeck.launcher.stores.xbox.xboxPc
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreAchievements
import com.droiddeck.launcher.stores.StoresState
@@ -127,6 +129,7 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
launchStoreGame(ctx, store, id, s, a)
}
ActionChip(stringResource(R.string.stores_in_steam), ok = true)
+ if (store == Store.XBOX && item?.xboxCloud == true) XboxStreamButton(item)
if (store == Store.XBOX) {
SecondaryButton("Update / verify", enabled = download == null && !com.droiddeck.launcher.stores.xbox.XboxRuntime.isActive(id)) {
runCatching { com.droiddeck.launcher.stores.xbox.XboxBackend.update(ctx, installed) }
@@ -157,6 +160,10 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
com.droiddeck.launcher.stores.download.DownloadQueue.clear(ctx, failedDownload.key)
}
}
+ store == Store.XBOX && item != null && !item.xboxPc && item.xboxCloud -> {
+ XboxStreamButton(item, main = true, modifier = leadOn)
+ XboxAddToGamesButton(item)
+ }
item?.installable == true && StoresState.isUnfinished(item) -> {
InstallButton(stringResource(R.string.stores_resume_install), leadOn) { StoresState.requestInstall(ctx, item) }
ConfirmButton(stringResource(R.string.stores_dl_clear), stringResource(R.string.stores_dl_cancel_confirm), compact = true) { StoresState.clearUnfinished(ctx, item) }
@@ -166,6 +173,10 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
if (item.sizeBytes > 0) stringResource(R.string.stores_install_size, formatBytes(item.sizeBytes)) else stringResource(R.string.stores_install),
leadOn,
) { StoresState.requestInstall(ctx, item) }
+ if (store == Store.XBOX && item.xboxCloud) {
+ XboxStreamButton(item)
+ XboxAddToGamesButton(item)
+ }
if (!item.accessible) {
SecondaryButton(
when {
@@ -290,3 +301,29 @@ private fun InstallButton(label: String, modifier: Modifier = Modifier, onInstal
}
}
}
+
+@Composable
+private fun XboxStreamButton(item: com.droiddeck.launcher.stores.CatalogItem, main: Boolean = false, modifier: Modifier = Modifier) {
+ val ctx = LocalContext.current
+ androidx.compose.runtime.LaunchedEffect(Unit) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.prefetch(ctx) }
+ val stream = { com.droiddeck.launcher.stores.xbox.XboxCloudGames.stream(ctx, item.id, item.title) }
+ if (main) PrimaryButton("Stream", main = true, icon = Icons.Filled.PlayArrow, modifier = modifier) { stream() }
+ else SecondaryButton("Stream", modifier = modifier) { stream() }
+}
+
+@Composable
+private fun XboxAddToGamesButton(item: com.droiddeck.launcher.stores.CatalogItem) {
+ val ctx = LocalContext.current
+ androidx.compose.runtime.LaunchedEffect(Unit) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.load(ctx) }
+ // Add and Remove replace each other; the controller focus moves to the new button instead of getting lost.
+ val slot = remember { androidx.compose.ui.focus.FocusRequester() }
+ val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
+ val scope = rememberCoroutineScope()
+ fun refocus() { if (inputMode.inputMode == androidx.compose.ui.input.InputMode.Keyboard) scope.launch { focusSoon { slot } } }
+ if (com.droiddeck.launcher.stores.xbox.XboxCloudGames.isAdded(item.id)) {
+ ActionChip("In Games", ok = true)
+ SecondaryButton("Remove from Games", compact = true, modifier = Modifier.focusRequester(slot)) {
+ com.droiddeck.launcher.stores.xbox.XboxCloudGames.remove(ctx, item.id); refocus()
+ }
+ } else SecondaryButton("Add to Games", modifier = Modifier.focusRequester(slot)) { com.droiddeck.launcher.stores.xbox.XboxCloudGames.add(ctx, item); refocus() }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt
index 175cbecd85..0634a52710 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt
@@ -97,6 +97,8 @@ import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.automirrored.filled.Login
import androidx.compose.material.icons.filled.GridView
import androidx.compose.material.icons.filled.Sort
+import androidx.compose.material.icons.filled.FilterList
+import com.droiddeck.launcher.stores.xbox.XboxLibraryFilter
import androidx.compose.material.icons.filled.ViewList
import androidx.compose.material.icons.filled.ViewModule
import com.droiddeck.launcher.stores.sortCatalogItems
@@ -128,6 +130,7 @@ import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
@@ -145,6 +148,7 @@ import com.droiddeck.launcher.R
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.stores.CatalogItem
+import com.droiddeck.launcher.stores.itch.ItchBrowseState
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreTab
import com.droiddeck.launcher.stores.StoresState
@@ -172,6 +176,7 @@ private data class PaneKey(val chip: String, val tab: String, val signedIn: Bool
@Composable
internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) {
val ctx = LocalContext.current
+ val focusManager = LocalFocusManager.current
com.droiddeck.launcher.stores.xbox.XboxContent.plan?.let { content ->
androidx.compose.material3.AlertDialog(
onDismissRequest = { com.droiddeck.launcher.stores.xbox.XboxContent.dismiss() },
@@ -279,7 +284,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
val heroFocus = remember { androidx.compose.ui.focus.FocusRequester() }
var detailFocused by remember { mutableStateOf(false) }
fun move(kind: String) { focusMove = kind to (focusMove?.second ?: 0) + 1 }
- fun open(key: String) { lastOpened = key; openGame = key; move("detail") }
+ fun open(key: String) { focusManager.clearFocus(force = true); lastOpened = key; openGame = key; move("detail") }
fun closeGame() { openGame = null; move("card") }
fun switchTab(to: String) { tab = to; move("first") }
val pickChip: (String) -> Unit = { id ->
@@ -287,6 +292,11 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
if (id != DOWNLOADS) tab = tabFor(Store.byId(id), if (s.storesOpenTab == SessionPrefs.STORES_OPEN_STORE) "store" else "library")
move("first")
}
+ LaunchedEffect(StoresState.openGameRequest) {
+ val key = StoresState.openGameRequest ?: return@LaunchedEffect
+ StoresState.openGameRequest = null
+ Store.byId(key.substringBefore(':'))?.let { store -> chip = store.id; tab = tabFor(store, "library"); query = ""; open(key) }
+ }
var focusedChip by remember { mutableStateOf(null) }
LaunchedEffect(focusedChip) {
val id = focusedChip ?: return@LaunchedEffect
@@ -477,7 +487,11 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
androidx.compose.material3.LinearProgressIndicator(Modifier.fillMaxWidth().height(3.dp))
}
!k.signedIn -> Box(Modifier.fillMaxWidth().verticalScroll(scroll).padding(top = 4.dp, bottom = 16.dp)) { SignInCard(st, viewportH - 20.dp) }
- else -> Storefront(st, k.tab, query, s, a, grids.getOrPut(k) { LazyGridState() }, onQuery = { query = it }, onOpen = { open(it) }, onTab = { switchTab(it) })
+ else -> Storefront(
+ st, k.tab, query, s, a, grids.getOrPut(k) { LazyGridState() },
+ clearSearchFocus = openGame != null,
+ onQuery = { query = it }, onOpen = { open(it) }, onTab = { switchTab(it) },
+ )
}
}
}
@@ -496,7 +510,8 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
if (detailStore != null) Column(
Modifier.fillMaxWidth()
.onFocusChanged { detailFocused = it.hasFocus }
- .focusProperties { exit = { if (coveringNow.value) androidx.compose.ui.focus.FocusRequester.Cancel else androidx.compose.ui.focus.FocusRequester.Default } }
+ // A step opened from the page (install location, uninstall) sits outside it and has to receive the focus.
+ .focusProperties { exit = { if (coveringNow.value && !StoresMotion.stepOpen) androidx.compose.ui.focus.FocusRequester.Cancel else androidx.compose.ui.focus.FocusRequester.Default } }
.focusGroup(),
) { StoreGameDetail(detailStore, key, s, a, heroFocus, onBack = { closeGame() }) }
}
@@ -538,7 +553,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
seenActive.clear(); seenActive.addAll(activeKeys)
if (fresh.isNotEmpty()) StoresMotion.takeInstall()?.let { StoresMotion.fly(it) }
}
- StoresState.pendingInstall?.let { item -> InstallWhere(item) }
+ StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } }
}
@Composable
@@ -937,6 +952,7 @@ internal fun StoreLogo(store: Store, size: Dp) {
private fun Storefront(
store: Store, tab: String, query: String, s: FrontEndState, a: FrontEndActions,
grid: LazyGridState,
+ clearSearchFocus: Boolean,
onQuery: (String) -> Unit, onOpen: (String) -> Unit, onTab: (String) -> Unit,
) {
val ctx = LocalContext.current
@@ -954,7 +970,8 @@ private fun Storefront(
val everything = remember(library, shelves, found) { (found + library + (shelves?.all ?: emptyList())).distinctBy { it.id } }
LaunchedEffect(store, q) { StoresState.search(ctx, store, q) }
val loaded = StoresState.library.containsKey(store)
- val showGrid = tab != "store" || q.isNotEmpty()
+ val browsing = store == Store.ITCH && tab == "store" && q.isEmpty() && ItchBrowseState.active
+ val showGrid = tab != "store" || q.isNotEmpty() || browsing
val sort = s.storesSort
val lastPlayedFor = remember(s.steamGames) {
val byKey = s.steamGames.associate { "${it.source}:${it.storeId}" to it.lastPlayed }
@@ -967,8 +984,15 @@ private fun Storefront(
lookup
}
val isSizeSort = tab == "library" && (sort == "sizeAsc" || sort == "sizeDesc")
- val candidates = remember(library, everything, tab, q, s.storesShowMature) {
- if (tab == "library") library.filter(::matches) else everything.filter { matches(it) && shown(it) }
+ val browseItems = if (browsing) ItchBrowseState.items else emptyList()
+ LaunchedEffect(Unit) { XboxLibraryFilter.load(ctx) }
+ val xboxFilter = if (store == Store.XBOX) XboxLibraryFilter.current else XboxLibraryFilter.ALL
+ val candidates = remember(library, everything, tab, q, s.storesShowMature, browsing, browseItems, xboxFilter) {
+ if (tab == "library") library.filter { matches(it) && XboxLibraryFilter.keeps(xboxFilter, it) }
+ else if (browsing) {
+ val owned = library.associateBy { it.id }
+ browseItems.map { owned[it.id] ?: it }.filter(::shown)
+ } else everything.filter { matches(it) && shown(it) }
}
val candidateKeys = remember(candidates) { candidates.map { it.key } }
var resolvedSizeSortKey by remember(store, tab) { mutableStateOf?>(null) }
@@ -1006,6 +1030,8 @@ private fun Storefront(
}
val empty = stringResource(when {
tab == "library" && library.isEmpty() && StoresState.status[store] != null -> R.string.stores_library_loading
+ browsing && ItchBrowseState.loading -> R.string.stores_shelves_loading
+ browsing && ItchBrowseState.failed -> R.string.stores_itch_browse_failed
else -> R.string.stores_nothing_matches
})
var firstPlaced = false
@@ -1016,8 +1042,9 @@ private fun Storefront(
// A bar only where the tab has nothing else on it: shelves, the shelf of owned games, or a grid still loading.
val gridEmpty = if (showGrid) visible.isEmpty() else (shelves == null || shelves.isEmpty) && library.isEmpty()
val barLine = StoresState.status[store]?.takeIf { gridEmpty && syncCount(it) != null }
+ val itchBar = store == Store.ITCH && tab == "store" && q.isEmpty()
val headerItems = 1 + (if (sizeSortPending) 1 else 0) + (if (barLine != null) 1 else 0) +
- (if (StoresState.problems[store] != null) 1 else 0)
+ (if (StoresState.problems[store] != null) 1 else 0) + (if (itchBar) 1 else 0)
val listMode = s.storesView == "list" && tab == "library"
val capsules = s.storesView == "capsules" && tab == "library"
val tileWidth = if (capsules) CapsuleWidth else CardWidth
@@ -1066,18 +1093,22 @@ private fun Storefront(
item(key = "header", span = { GridItemSpan(maxLineSpan) }) {
Rise(1) {
val tabs = tabsFor(store)
- val libraryLabel = if (loaded) stringResource(R.string.stores_tab_count, stringResource(R.string.stores_tab_library), library.size)
- else stringResource(R.string.stores_tab_library)
+ val libraryName = if (xboxFilter == XboxLibraryFilter.ALL) stringResource(R.string.stores_tab_library)
+ else stringResource(R.string.stores_tab_library) + " · " + XboxLibraryFilter.label(xboxFilter)
+ val libraryLabel = if (loaded) stringResource(R.string.stores_tab_count, libraryName, library.count { XboxLibraryFilter.keeps(xboxFilter, it) })
+ else libraryName
ModeHeader(
libraryLabel,
query, onQuery,
placeholder = if (tab == "store") stringResource(R.string.stores_search_catalog, store.label) else stringResource(R.string.stores_search_library),
+ clearSearchFocus = clearSearchFocus,
lead = if (tabs.size < 2) null else { {
val labels = tabs.map { if (it == "store") stringResource(R.string.stores_tab_store) else libraryLabel }
HeaderTabs(labels, tabs.indexOf(tab).coerceAtLeast(0)) { onTab(tabs[it]) }
} },
) {
if (tab == "library") {
+ if (store == Store.XBOX) XboxFilterButton()
SortButton(s, a)
ViewButton(s, a)
}
@@ -1086,6 +1117,9 @@ private fun Storefront(
else { EpicClient.install(ctx); StoresState.openDownloads = true }
}
SmallTextButton(stringResource(R.string.stores_refresh)) { StoresState.open(ctx, store, force = true) }
+ if (store == Store.XBOX) SmallTextButton("Cloud settings") {
+ ctx.startActivity(android.content.Intent(ctx, com.droiddeck.launcher.stores.xbox.XboxCloudSettingsActivity::class.java))
+ }
val name = StoresState.accounts[store] ?: ""
SignOutButton(store, name)
}
@@ -1102,6 +1136,7 @@ private fun Storefront(
}
barLine?.let { line -> item(key = "sync", span = { GridItemSpan(maxLineSpan) }) { Rise(3) { SyncBar(line) } } }
StoresState.problems[store]?.let { line -> item(key = "problem", span = { GridItemSpan(maxLineSpan) }) { Rise(3) { Box(Modifier.padding(bottom = 8.dp)) { Note(line) } } } }
+ if (itchBar) item(key = "itch-browse-bar", span = { GridItemSpan(maxLineSpan) }) { ItchBrowseBar() }
when (tab) {
"library" -> if (!loaded) Unit
else if (split == 0) storeGrid(visible, empty, card)
@@ -1112,8 +1147,10 @@ private fun Storefront(
storeGrid(visible.drop(split), empty, card)
}
else -> {
- if (q.isNotEmpty()) storeGrid(visible, empty, card)
- else {
+ if (q.isNotEmpty() || browsing) {
+ storeGrid(visible, empty, card)
+ if (browsing) item(key = "itch-more", span = { GridItemSpan(maxLineSpan) }) { ItchLoadMore() }
+ } else {
item(key = "shelves", span = { GridItemSpan(maxLineSpan) }) {
Column {
Shelf(stringResource(R.string.stores_shelf_new), shelf(shelves?.whatsNew), card)
@@ -1172,6 +1209,7 @@ private fun HeaderTabs(labels: List, selected: Int, onSelect: (Int) -> U
@Composable
internal fun ModeHeader(
title: String, query: String, onQuery: (String) -> Unit, placeholder: String,
+ clearSearchFocus: Boolean = false,
lead: (@Composable () -> Unit)? = null, trailing: @Composable () -> Unit,
) {
val colors = MaterialTheme.colorScheme
@@ -1193,6 +1231,7 @@ internal fun ModeHeader(
AdbTextField(
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
placeholder = placeholder, compact = true, focusOnShow = focusOnOpen,
+ clearFocus = clearSearchFocus,
onFocusChange = { focused -> if (!focused && query.isEmpty()) { searching = false; focusOnOpen = false } },
)
}
@@ -1312,6 +1351,38 @@ private fun SortButton(s: FrontEndState, a: FrontEndActions) {
}
}
+@Composable
+private fun XboxFilterButton() {
+ val pal = LocalPalette.current
+ val ctx = LocalContext.current
+ val title = "Show"
+ var at by remember { mutableStateOf(null) }
+ Box(Modifier.onGloballyPositioned { at = it.boundsInRoot() }) {
+ HeaderIconButton(title, Icons.Filled.FilterList, "xbox-filter") {
+ val from = at ?: return@HeaderIconButton
+ StoresMotion.ask(StepAsk(
+ anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = XboxLibraryFilter.ALL_FILTERS.size,
+ onDismiss = {},
+ handle = { Text(title, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1, overflow = TextOverflow.Ellipsis) },
+ ) {
+ StepTitle(title)
+ StepList {
+ XboxLibraryFilter.ALL_FILTERS.forEachIndexed { i, filter ->
+ StepChoice(
+ XboxLibraryFilter.label(filter), selected = filter == XboxLibraryFilter.current, enabled = open,
+ modifier = Modifier.fillMaxWidth().stepItem(i)
+ .then(if (filter == XboxLibraryFilter.current) Modifier.focusRequester(first) else Modifier),
+ ) {
+ XboxLibraryFilter.set(ctx, filter)
+ StoresMotion.fold()
+ }
+ }
+ }
+ })
+ }
+ }
+}
+
@Composable
private fun ViewButton(s: FrontEndState, a: FrontEndActions) {
val views = SessionPrefs.STORES_VIEWS
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt
index 0f3843fcac..14527f5949 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt
@@ -3,7 +3,15 @@ package com.droiddeck.launcher.ui
import androidx.annotation.StringRes
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.RepeatMode
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.rememberInfiniteTransition
+import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.key
+import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.runtime.getValue
@@ -13,6 +21,7 @@ import android.content.Context
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
+import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import com.droiddeck.launcher.R
import androidx.compose.ui.platform.LocalConfiguration
@@ -33,6 +42,7 @@ object Themes {
const val PAPER = "paper"
const val ICON_BLUE = "blue"
const val ELECTRIC = "electric"
+ const val INNER_GAMER = "inner_gamer"
const val GRADIENT = "gradient"
const val DEFAULT_PRIMARY = 0xFF8B5CF6.toInt()
@@ -42,10 +52,42 @@ object Themes {
var gradientColors by mutableStateOf(DEFAULT_PRIMARY to DEFAULT_SECONDARY)
private set
+ const val RGB_SPEEDS = 10
+ const val DEFAULT_RGB_SPEED = 3
+ const val RGB_HUE_STEP = 3f
+
+ /** How fast Inner Gamer cycles, 1 (slow) to [RGB_SPEEDS] (fast). */
+ var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED)
+ private set
+
+ /** Where Inner Gamer is on the colour wheel, in whole [RGB_HUE_STEP] steps so the app restyles only when the colour visibly moves. */
+ var rgbHue by mutableStateOf(0f)
+ private set
+
+ fun moveRgbHue(hue: Float) {
+ rgbHue = hue
+ }
+
+ fun setRgbSpeed(context: Context, speed: Int) {
+ val value = speed.coerceIn(1, RGB_SPEEDS)
+ SessionPrefs.setRgbSpeed(context, value)
+ rgbSpeed = value
+ }
+
+ /** Milliseconds for one trip round the colour wheel. */
+ fun rgbCycleMillis(speed: Int): Int = 30_000 / speed.coerceIn(1, RGB_SPEEDS)
+
fun loadGradient(context: Context) {
gradientColors = SessionPrefs.gradientColors(context)
+ rgbSpeed = SessionPrefs.rgbSpeed(context)
}
+ /** The Inner Gamer palette at one point on the colour wheel. */
+ fun innerGamer(hue: Float): Palette = ThemeColors.palette(
+ Color.hsv(hue % 360f, 0.9f, 1f).toArgb(), Color.hsv((hue + 60f) % 360f, 0.9f, 1f).toArgb(),
+ R.string.theme_inner_gamer, R.string.theme_inner_gamer_detail, INNER_GAMER,
+ )
+
fun setGradient(context: Context, primary: Int, secondary: Int) {
SessionPrefs.setGradientColors(context, primary, secondary)
gradientColors = primary to secondary
@@ -54,7 +96,7 @@ object Themes {
/** The theme the person chose, with the custom colours read first; for code that is not in a composition. */
fun current(context: Context): Palette {
val id = SessionPrefs.theme(context)
- if (id == GRADIENT) loadGradient(context)
+ if (id == GRADIENT || id == INNER_GAMER) loadGradient(context)
return byId(id)
}
@@ -87,10 +129,12 @@ object Themes {
primary = Color(0xFF2E86FF), primary2 = Color(0xFF2684FF), onPrimary = Color(0xFF03111F), signal = Color(0xFF2E86FF),
good = Color(0xFF4CD37F),
),
+ innerGamer(0f),
ThemeColors.palette(DEFAULT_PRIMARY, DEFAULT_SECONDARY, R.string.theme_gradient, R.string.theme_gradient_detail),
)
fun byId(id: String): Palette {
+ if (id == INNER_GAMER) return innerGamer(rgbHue)
if (id == GRADIENT) return ThemeColors.palette(gradientColors.first, gradientColors.second, R.string.theme_gradient, R.string.theme_gradient_detail)
return all.firstOrNull { it.id == id } ?: all[0]
}
@@ -103,6 +147,7 @@ val Palette.onSignal: Color get() = if (signal.luminance() > 0.18f) Color(0xFF03
@Composable
fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCALE, content: @Composable () -> Unit) {
val id = theme ?: SessionPrefs.theme(LocalContext.current)
+ if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed)
val p = Themes.byId(id)
val scheme = darkColorScheme(
primary = p.primary, onPrimary = p.onPrimary, secondary = p.onSurfaceVariant,
@@ -121,3 +166,21 @@ fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCA
LocalConfiguration provides configuration,
) { MaterialTheme(colorScheme = scheme, content = content) }
}
+
+/** Turns the colour wheel on the system's own animation clock; with animations off, in the app or in Android, the colour holds still. */
+@Composable
+private fun InnerGamerHue(speed: Int) {
+ if (Motion.scale == 0f) return
+ key(speed) { InnerGamerCycle(speed) }
+}
+
+/** One run of the cycle at one speed, picking up from the colour on screen so a new speed takes over at once without a jump. */
+@Composable
+private fun InnerGamerCycle(speed: Int) {
+ val start = remember { Themes.rgbHue }
+ val hue by rememberInfiniteTransition(label = "innerGamer").animateFloat(
+ start, start + 360f, infiniteRepeatable(tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing), RepeatMode.Restart), label = "hue",
+ )
+ val stepped = ((hue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP
+ SideEffect { Themes.moveRgbHue(stepped) }
+}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt b/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt
index b4b57737e1..b2db635623 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt
@@ -132,7 +132,7 @@ internal object ThemeColors {
}
}
- fun palette(primary: Int, secondary: Int, label: Int, detail: Int): Palette {
+ fun palette(primary: Int, secondary: Int, label: Int, detail: Int, id: String = Themes.GRADIENT): Palette {
val seen = readable(primary)
val seenSecond = readable(secondary)
val ink = inkFor(seen, seenSecond)
@@ -146,7 +146,7 @@ internal object ThemeColors {
second = nextSecond
}
return Palette(
- Themes.GRADIENT, label, detail,
+ id, label, detail,
background = tint(first, 0.50f, 0.045f), surface = tint(first, 0.45f, 0.075f), surfaceVariant = tint(first, 0.42f, 0.115f),
line = tint(first, 0.40f, 0.16f), line2 = tint(first, 0.36f, 0.22f),
onBackground = tint(first, 0.05f, 0.97f), onSurfaceVariant = tint(first, 0.16f, 0.68f),
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/WinComponentsEditor.kt b/app/src/main/java/com/droiddeck/launcher/ui/WinComponentsEditor.kt
index 155c6e9b27..235f2f98b6 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/WinComponentsEditor.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/WinComponentsEditor.kt
@@ -56,7 +56,7 @@ import java.io.File
private fun installable(name: String, all: Map): String = WinComponents.installable(name, all)
@Composable
-private fun originName(origin: String): String = stringResource(
+private fun originName(origin: String): String = if (origin == WinCompSources.Origin.XBOX.name) "Xbox" else stringResource(
when (origin) {
WinCompSources.Origin.GOG.name -> R.string.wincomp_src_gog
WinCompSources.Origin.EPIC.name -> R.string.wincomp_src_epic
@@ -71,6 +71,7 @@ private fun autoReason(r: WinComponents.AutoReason): String = when (r.kind) {
WinCompSources.Origin.GOG.name -> stringResource(R.string.wincomp_auto_gog)
WinCompSources.Origin.EPIC.name -> stringResource(R.string.wincomp_auto_epic)
WinCompSources.Origin.AMAZON.name -> stringResource(R.string.wincomp_auto_amazon)
+ WinCompSources.Origin.XBOX.name -> "Xbox games install it with the game (${r.args.getOrElse(0) { "VC14" }})"
else -> ""
}
diff --git a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt
index 8117c3ee5e..5c719ca90d 100644
--- a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt
+++ b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt
@@ -356,6 +356,7 @@ internal fun AdbTextField(
placeholder: String? = null,
compact: Boolean = false,
onFocusChange: (Boolean) -> Unit = {},
+ clearFocus: Boolean = false,
onNext: (() -> Unit)? = null,
onDone: (() -> Unit)? = null,
focusOnShow: Boolean = false,
@@ -444,6 +445,11 @@ internal fun AdbTextField(
?.showSoftInput(editText, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT)
}
}
+ if (clearFocus && editText.hasFocus()) {
+ editText.clearFocus()
+ (editText.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
+ ?.hideSoftInputFromWindow(editText.windowToken, 0)
+ }
editText.setTextColor(colors.onBackground.toArgb())
editText.setHintTextColor(colors.onSurfaceVariant.toArgb())
editText.hint = placeholder
diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt b/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt
index bb466c1330..348e8ff1fb 100644
--- a/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt
+++ b/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt
@@ -23,6 +23,7 @@ object CompositorHost {
@Synchronized
fun startOrAttach(
+ context: android.content.Context,
surface: Surface,
xdgRuntimeDir: String,
driverPath: String?,
@@ -41,7 +42,7 @@ object CompositorHost {
resumeVsync()
return false
}
- com.droiddeck.launcher.gpu.TpUbwcHint.applyToProcess()
+ com.droiddeck.launcher.gpu.TpUbwcHint.applyToProcess(context)
WaylandCompositor.nativeStartWithSurface(
surface, xdgRuntimeDir, driverPath, libraryName, nativeLibDir,
)
diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java
index 952bd2f6f3..35f93c78ea 100644
--- a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java
+++ b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java
@@ -329,6 +329,13 @@ public final class WaylandCompositor {
public static native float[] nativeFrameGenStats();
+ /** Stream mode: the scene is the Xbox Cloud Gaming native player's picture, handed over frame by frame. */
+ public static native void nativeStreamMode(boolean on);
+
+ public static native void nativeStreamFrame(android.hardware.HardwareBuffer buffer);
+
+ public static native int nativeStreamFrames();
+
public static void sendPointerDelta(int dx, int dy) {
if (dx == 0 && dy == 0) return;
nativeSendSceneInput(6, dx * 256, dy * 256);
diff --git a/app/src/main/java/org/webrtc/DroidDeckLowLatencyDecoderFactory.java b/app/src/main/java/org/webrtc/DroidDeckLowLatencyDecoderFactory.java
new file mode 100644
index 0000000000..2a196ed2d9
--- /dev/null
+++ b/app/src/main/java/org/webrtc/DroidDeckLowLatencyDecoderFactory.java
@@ -0,0 +1,257 @@
+package org.webrtc;
+
+import android.graphics.ImageFormat;
+import android.media.Image;
+import android.media.ImageReader;
+import android.media.MediaCodec;
+import android.media.MediaCodecInfo;
+import android.media.MediaCodecList;
+import android.media.MediaCrypto;
+import android.media.MediaFormat;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.SystemClock;
+import android.view.Surface;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+
+/**
+ * DroidDeck's hardware video decoder factory for the native Xbox Cloud Gaming player. It builds WebRTC's own
+ * AndroidVideoDecoder (hence this package) around a MediaCodec wrapper that can:
+ * - ask the decoder for low-latency output (Android's KEY_LOW_LATENCY and Qualcomm's low-latency / picture-order
+ * vendor keys; unknown keys are ignored, and a decoder that refuses them is configured without them);
+ * - for zero-copy, decode straight onto the player's SurfaceView instead of WebRTC's texture, rendering every
+ * output buffer there (no GL copy, no compositor; WebRTC then gets no decoded frames to draw).
+ * Without either option it behaves like WebRTC's HardwareVideoDecoderFactory.
+ * The route is switchable while the decoder runs (setOutputSurface): {@link #useScreen} sends frames straight to the
+ * screen (zero-copy) or, with null, back to WebRTC's texture (for the Vulkan compositor and frame generation);
+ * {@link #setZeroCopySurface} moves a zero-copy decoder to a stand-in surface while the screen surface is gone.
+ * The factory also reports the decoded size and the decode time (input queued to output ready), which WebRTC's
+ * stats lack in zero-copy.
+ */
+public class DroidDeckLowLatencyDecoderFactory implements VideoDecoderFactory {
+ /** Counts frames sent to the display in zero-copy mode (WebRTC's own stats see none). */
+ public interface FrameCounter { void onFrameShown(); }
+
+ private final HardwareVideoDecoderFactory hardware;
+ private final EglBase.Context sharedContext;
+ private final boolean lowLatency;
+ /** Frames go to {@link #zeroCopySurface} (the screen or the stand-in), not WebRTC's texture. */
+ private volatile boolean zeroCopy;
+ private volatile Surface zeroCopySurface;
+ /** Back on WebRTC's texture: render the next buffer there, so WebRTC's pending texture frame completes. */
+ private volatile boolean renderNext;
+ private final FrameCounter counter;
+ private volatile Wrapper live;
+ private ImageReader standIn;
+ private HandlerThread standInThread;
+ private volatile int width, height;
+ private final Object decodeLock = new Object();
+ private final HashMap queuedAt = new HashMap<>();
+ private double decodeSumMs;
+ private int decodeCount;
+
+ public DroidDeckLowLatencyDecoderFactory(EglBase.Context sharedContext, boolean lowLatency, Surface zeroCopySurface, FrameCounter counter) {
+ this.hardware = new HardwareVideoDecoderFactory(sharedContext);
+ this.sharedContext = sharedContext;
+ this.lowLatency = lowLatency;
+ this.zeroCopy = zeroCopySurface != null;
+ this.zeroCopySurface = zeroCopySurface;
+ this.counter = counter;
+ }
+
+ /**
+ * Zero-copy: the surface to decode onto from now on; null = a stand-in that drops every frame (the screen
+ * surface is being destroyed). Must be called before a destroyed surface's callback returns.
+ */
+ public synchronized void setZeroCopySurface(Surface surface) {
+ if (!zeroCopy) return;
+ moveTo(surface != null ? surface : standInSurface(), surface != null ? "the screen" : "a stand-in");
+ }
+
+ /**
+ * Switch the route live: a surface = zero-copy onto it; null = WebRTC's texture again. Returns false when the
+ * decoder refused the new surface (the route is then unchanged).
+ */
+ public synchronized boolean useScreen(Surface screen) {
+ if (screen != null) {
+ Wrapper w = live;
+ if (w != null && !moveTo(screen, "the screen")) return false;
+ zeroCopySurface = screen;
+ zeroCopy = true;
+ return true;
+ }
+ if (!zeroCopy) return true;
+ Wrapper w = live;
+ if (w != null && w.texture != null && !moveTo(w.texture, "WebRTC's texture")) return false;
+ zeroCopy = false;
+ renderNext = true;
+ return true;
+ }
+
+ private boolean moveTo(Surface target, String what) {
+ Wrapper w = live;
+ if (w == null || target == null) { if (zeroCopy) zeroCopySurface = target; return true; }
+ try {
+ w.raw.setOutputSurface(target);
+ if (zeroCopy) zeroCopySurface = target;
+ Logging.d("DroidDeckDecoder", "decoder output moved to " + what);
+ return true;
+ } catch (RuntimeException e) {
+ Logging.w("DroidDeckDecoder", "decoder output change to " + what + " failed: " + e);
+ return false;
+ }
+ }
+
+ private Surface standInSurface() {
+ if (standIn == null) {
+ standInThread = new HandlerThread("bl-decoder-standin");
+ standInThread.start();
+ standIn = ImageReader.newInstance(Math.max(width, 16), Math.max(height, 16), ImageFormat.PRIVATE, 3);
+ standIn.setOnImageAvailableListener(reader -> {
+ Image image = reader.acquireLatestImage();
+ if (image != null) image.close();
+ }, new Handler(standInThread.getLooper()));
+ }
+ return standIn.getSurface();
+ }
+
+ /** The decoder's picture size, or null before the first decoder is configured. */
+ public String videoSize() {
+ return width > 0 ? width + "x" + height : null;
+ }
+
+ /** Average decode time since the last call, in ms (-1 when no frame was decoded in between). */
+ public double takeDecodeMs() {
+ synchronized (decodeLock) {
+ double avg = decodeCount > 0 ? decodeSumMs / decodeCount : -1;
+ decodeSumMs = 0; decodeCount = 0;
+ return avg;
+ }
+ }
+
+ public synchronized void release() {
+ if (standIn != null) { standIn.close(); standIn = null; }
+ if (standInThread != null) { standInThread.quitSafely(); standInThread = null; }
+ }
+
+ @Override
+ public VideoCodecInfo[] getSupportedCodecs() {
+ return hardware.getSupportedCodecs();
+ }
+
+ @Override
+ public VideoDecoder createDecoder(VideoCodecInfo info) {
+ VideoCodecMimeType type;
+ try { type = VideoCodecMimeType.valueOf(info.getName()); } catch (IllegalArgumentException e) { return hardware.createDecoder(info); }
+ MediaCodecInfo codec = findHardwareDecoder(type);
+ if (codec == null) return hardware.createDecoder(info);
+ Integer color = MediaCodecUtils.selectColorFormat(MediaCodecUtils.DECODER_COLOR_FORMATS, codec.getCapabilitiesForType(type.mimeType()));
+ if (color == null) return hardware.createDecoder(info);
+ return new AndroidVideoDecoder(new WrapperFactory(), codec.getName(), type, color, sharedContext);
+ }
+
+ private static MediaCodecInfo findHardwareDecoder(VideoCodecMimeType type) {
+ for (MediaCodecInfo info : new MediaCodecList(MediaCodecList.REGULAR_CODECS).getCodecInfos()) {
+ if (info.isEncoder()) continue;
+ if (MediaCodecUtils.codecSupportsType(info, type) && MediaCodecUtils.isHardwareAccelerated(info)) return info;
+ }
+ return null;
+ }
+
+ private class WrapperFactory implements MediaCodecWrapperFactory {
+ @Override
+ public MediaCodecWrapper createByCodecName(String name) throws IOException {
+ return new Wrapper(MediaCodec.createByCodecName(name));
+ }
+ }
+
+ /** MediaCodec itself (not WebRTC's wrapper) so the output surface can be changed while it runs. */
+ private class Wrapper implements MediaCodecWrapper {
+ final MediaCodec raw;
+ /** WebRTC's texture surface, the route back from zero-copy. */
+ Surface texture;
+ Wrapper(MediaCodec raw) { this.raw = raw; }
+
+ @Override
+ public void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags) {
+ width = format.getInteger(MediaFormat.KEY_WIDTH);
+ height = format.getInteger(MediaFormat.KEY_HEIGHT);
+ texture = surface;
+ live = this;
+ Surface target = surface;
+ if (zeroCopy) { synchronized (DroidDeckLowLatencyDecoderFactory.this) { target = zeroCopySurface != null ? zeroCopySurface : standInSurface(); } }
+ if (lowLatency) {
+ MediaFormat fast = MediaFormat.createVideoFormat(format.getString(MediaFormat.KEY_MIME), width, height);
+ copyInt(format, fast, MediaFormat.KEY_COLOR_FORMAT);
+ if (Build.VERSION.SDK_INT >= 30) fast.setInteger(MediaFormat.KEY_LOW_LATENCY, 1);
+ fast.setInteger(MediaFormat.KEY_PRIORITY, 0);
+ fast.setInteger("vendor.qti-ext-dec-low-latency.enable", 1);
+ fast.setInteger("vendor.qti-ext-dec-picture-order.enable", 1);
+ try {
+ raw.configure(fast, target, crypto, flags);
+ Logging.d("DroidDeckDecoder", "low-latency decoder configured" + (zeroCopy ? " (zero-copy)" : ""));
+ return;
+ } catch (RuntimeException e) {
+ Logging.w("DroidDeckDecoder", "decoder refused low-latency keys: " + e);
+ }
+ }
+ raw.configure(format, target, crypto, flags);
+ }
+
+ private void copyInt(MediaFormat from, MediaFormat to, String key) {
+ if (from.containsKey(key)) to.setInteger(key, from.getInteger(key));
+ }
+
+ // Zero-copy: AndroidVideoDecoder renders one buffer to its texture and drops the rest until the texture
+ // hands the frame back, which never happens with the display surface; show every buffer instead.
+ @Override public void releaseOutputBuffer(int index, boolean render) {
+ if (zeroCopy) { raw.releaseOutputBuffer(index, true); if (counter != null) counter.onFrameShown(); }
+ else if (renderNext) { renderNext = false; raw.releaseOutputBuffer(index, true); }
+ else raw.releaseOutputBuffer(index, render);
+ }
+
+ @Override public void queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags) {
+ synchronized (decodeLock) {
+ if (queuedAt.size() > 64) queuedAt.clear();
+ queuedAt.put(presentationTimeUs, SystemClock.elapsedRealtimeNanos());
+ }
+ raw.queueInputBuffer(index, offset, size, presentationTimeUs, flags);
+ }
+
+ @Override public int dequeueOutputBuffer(MediaCodec.BufferInfo info, long timeoutUs) {
+ int index = raw.dequeueOutputBuffer(info, timeoutUs);
+ if (index >= 0) synchronized (decodeLock) {
+ Long at = queuedAt.remove(info.presentationTimeUs);
+ if (at != null) { decodeSumMs += (SystemClock.elapsedRealtimeNanos() - at) / 1e6; decodeCount++; }
+ }
+ return index;
+ }
+
+ @Override public MediaFormat getOutputFormat() {
+ MediaFormat f = raw.getOutputFormat();
+ if (f.containsKey(MediaFormat.KEY_WIDTH) && f.containsKey(MediaFormat.KEY_HEIGHT)) {
+ width = f.containsKey("crop-right") ? f.getInteger("crop-right") - f.getInteger("crop-left") + 1 : f.getInteger(MediaFormat.KEY_WIDTH);
+ height = f.containsKey("crop-bottom") ? f.getInteger("crop-bottom") - f.getInteger("crop-top") + 1 : f.getInteger(MediaFormat.KEY_HEIGHT);
+ }
+ return f;
+ }
+
+ @Override public void start() { raw.start(); }
+ @Override public void flush() { synchronized (decodeLock) { queuedAt.clear(); } raw.flush(); }
+ @Override public void stop() { raw.stop(); }
+ @Override public void release() { if (live == this) live = null; raw.release(); }
+ @Override public int dequeueInputBuffer(long timeoutUs) { return raw.dequeueInputBuffer(timeoutUs); }
+ @Override public MediaFormat getInputFormat() { return raw.getInputFormat(); }
+ @Override public MediaFormat getOutputFormat(int index) { return raw.getOutputFormat(index); }
+ @Override public ByteBuffer getInputBuffer(int index) { return raw.getInputBuffer(index); }
+ @Override public ByteBuffer getOutputBuffer(int index) { return raw.getOutputBuffer(index); }
+ @Override public Surface createInputSurface() { return raw.createInputSurface(); }
+ @Override public void setParameters(Bundle params) { raw.setParameters(params); }
+ @Override public MediaCodecInfo getCodecInfo() { return raw.getCodecInfo(); }
+ }
+}
diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml
index d60a59fb94..fd412f88b9 100644
--- a/app/src/main/res/values-ar/strings.xml
+++ b/app/src/main/res/values-ar/strings.xml
@@ -287,9 +287,6 @@
«تلقائي» يوقف مؤقتًا ويستأنف عند الظهور. «أصلي» يجهّز Steam للسكون أولًا. «يدوي» ينتظر الضغط على «استئناف». «أبدًا» يُبقيه قيد التشغيل.
مواصلة التنزيلات
تأخير التعليق في الخلفية أثناء قيام Steam بالتنزيل.
- ضغط zRAM
- أثناء تشغيل اللعبة يتم ضغط ذاكرة عميل Steam إلى zram في الجهاز، فتحصل اللعبة على ذاكرة RAM أكبر. يسري عند تشغيل Steam في المرة القادمة.
- غير متاح: لا يحتوي هذا الجهاز على zram أو swap، أو أن النواة أقدم من 5.4.
«تلقائي» يوقف مؤقتًا في الخلفية ويستأنف عند الظهور. «يدوي» ينتظر الضغط على «استئناف». «أبدًا» يُبقيه قيد التشغيل.
بدء التشغيل
تشغيل Steam مع DroidDeck
@@ -552,8 +549,8 @@
Turnip: التصيير عبر sysmem
أسرع لعميل Steam؛ في الألعاب يختار برنامج التشغيل بين العرض المقسّم إلى مربعات والعرض في ذاكرة النظام لكل مرحلة. مطلوب على Adreno 710/720/722.
تجاوز مساعد xalia في Steam
- droiddeck-ntsync (تجريبي)
- بديل في مساحة المستخدم لبرنامج تشغيل ntsync في Linux، للاختبار. أثناء تفعيله، يستخدمه Proton بدلًا من droiddeck-esync وdroiddeck-fsync. يعمل مع Proton Experimental ARM64 وGE-Proton وproton-cachyos. يُطبَّق في الجلسة التالية.
+ droiddeck-ntsync
+ بديل في مساحة المستخدم لبرنامج تشغيل ntsync في Linux. أثناء تفعيله، يستخدمه Proton بدلًا من droiddeck-esync وdroiddeck-fsync. يعمل مع Proton Experimental ARM64 وGE-Proton وproton-cachyos. يُطبَّق في الجلسة التالية.
droiddeck-esync
droiddeck-fsync أولًا
يشغّل خاصية fsync المدمجة في Proton على ملفات Proton الأصلية، مع توفير futex_waitv في مساحة المستخدم، فلا يحتاج إلى حزمة ويستمر في العمل لحظة تحديث Steam لـ Proton. أثناء تفعيله، تستخدمه الألعاب قبل droiddeck-esync، باستثناء القليل الذي يبقيه Proton معطّلًا لـ fsync. يُطبَّق في الجلسة التالية.
@@ -1460,6 +1457,10 @@
خلفية سوداء ونص أبيض، والأزرق لكل عنصر محدَّد أو مُركَّز عليه أو مضغوط.
كحلي كهربائي
أزرق أكثر سطوعًا، على أسطح تميل إلى الكحلي بدلاً من الرمادي.
+ Inner Gamer
+ ألوان تتدرّج عبر ألوان قوس قزح. تتبع إعدادات الرسوم المتحركة في Android.
+ السرعة
+ مدى سرعة تغيّر الألوان.
تدرج لوني
لونك الأساسي والثانوي، ممزوجان على الأزرار وعناصر التمييز.
الأساسي
@@ -1601,6 +1602,13 @@
تخطّي
اختيار هذا المجلد
رجوع
+ خروج
+ العودة إلى المجلد الأول
+ لم يعد المجلد الأول متاحًا
+ إلغاء العملية؟
+ سيتم إلغاء العملية. هل أنت متأكد؟
+ موافق
+ رفض
تم تركيب %1$s لكن تتعذّر قراءته حاليًا
عرض القائمة
عرض الشبكة
@@ -2080,6 +2088,23 @@
لم يتم العثور على لعبة Windows في التنزيل
تعذر استخراج التنزيل (رمز الخروج %1$d)
لم يستجب itch.io
+ الأكثر شعبية
+ الأحدث
+ جديد ورائج
+ مدفوع
+ 5 دولارات أو أقل
+ 15 دولارًا أو أقل
+ الأعلى تقييمًا
+ الأكثر مبيعًا
+ أي سعر
+ مجاني
+ مخفّض
+ تحميل المزيد
+ أي منصة
+ ويب الجوال
+ إضافة وسم
+ التصفية حسب الوسم
+ تعذّر تحميل الألعاب من itch.io
أرشيفات %1$s غير مدعومة
استجاب itch.io بـ HTTP %1$d
مجاني
@@ -2234,6 +2259,7 @@
إغلاق
حاوِل مرة أخرى
جارٍ إنهاء تسجيل الدخول…
+ رفضت Microsoft تسجيل الدخول إلى Xbox. سجّل الخروج من Xbox في المتاجر، ثم سجّل الدخول مجددًا، ثم استأنف.
تعذّر تحميل صفحة تسجيل الدخول: %1$s
يرفض هذا المزوّد تسجيل الدخول من صفحة مضمَّنة. سجِّل الدخول باستخدام كلمة مرور المتجر بدلاً من ذلك.
استجابت صفحة تسجيل الدخول بخطأ (HTTP %1$d).
diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml
index b924266f43..168dd76127 100644
--- a/app/src/main/res/values-b+es+419/strings.xml
+++ b/app/src/main/res/values-b+es+419/strings.xml
@@ -287,9 +287,6 @@
Auto pausa y reanuda al mostrarse. Nativo prepara Steam para la suspensión primero. Manual espera a Reanudar. Nunca sigue ejecutándose.
Mantener las descargas activas
Retrasa la suspensión en segundo plano mientras Steam esté descargando.
- Compresión zRAM
- Mientras se ejecuta un juego, la memoria del cliente de Steam se comprime en la zram del dispositivo, lo que deja más RAM para el juego. Se aplica la próxima vez que se inicie Steam.
- No disponible: este dispositivo no tiene swap activo, o su kernel es anterior a la 5.4.
Auto pausa en segundo plano y reanuda al mostrarse. Manual espera a Reanudar. Nunca sigue ejecutándose.
Inicio
Iniciar Steam con DroidDeck
@@ -539,8 +536,8 @@
Turnip: renderizado sysmem
Más rápido para el cliente de Steam; en los juegos, el controlador elige entre renderizado por mosaicos o en memoria del sistema en cada pasada. Obligatorio en Adreno 710/720/722.
Omitir el asistente xalia de Steam
- droiddeck-ntsync (experimental)
- Un sustituto en espacio de usuario del controlador ntsync de Linux, para pruebas. Mientras está activado, Proton lo usa en lugar de droiddeck-esync y droiddeck-fsync. Funciona con Proton Experimental ARM64, GE-Proton y proton-cachyos. Se aplica en la próxima sesión.
+ droiddeck-ntsync
+ Un sustituto en espacio de usuario del controlador ntsync de Linux. Mientras está activado, Proton lo usa en lugar de droiddeck-esync y droiddeck-fsync. Funciona con Proton Experimental ARM64, GE-Proton y proton-cachyos. Se aplica en la próxima sesión.
droiddeck-esync
droiddeck-fsync primero
Usa el fsync propio de Proton con los archivos originales de Proton, con futex_waitv proporcionado en espacio de usuario, así que no necesita paquete y sigue funcionando en cuanto Steam actualiza Proton. Mientras está activado, los juegos lo usan antes que droiddeck-esync, salvo los pocos que Proton mantiene sin fsync. Se aplica en la próxima sesión.
@@ -1469,6 +1466,10 @@
Fondo negro, texto blanco y el azul para todo lo seleccionado, enfocado o presionado.
Azul marino eléctrico
Un azul más vivo, sobre superficies que tiran a azul marino en vez de gris.
+ Inner Gamer
+ Colores que recorren el arcoíris. Respeta los ajustes de animación de Android.
+ Velocidad
+ Qué tan rápido cambian los colores.
Degradado
Tus propios colores primario y secundario, combinados en botones y resaltados.
Primario
@@ -1595,6 +1596,13 @@
Omitir
Seleccionar esta carpeta
Atrás
+ Salir
+ Volver a la carpeta inicial
+ La carpeta inicial ya no está disponible
+ ¿Cancelar la operación?
+ La operación se cancelará. ¿Estás seguro?
+ Aceptar
+ Rechazar
%1$s está montado, pero ahora mismo no se puede leer
Vista de lista
Vista de cuadrícula
@@ -2186,6 +2194,7 @@
Cerrar
Reintentar
Terminando de iniciar sesión…
+ Microsoft rechazó el inicio de sesión de Xbox. Cierra sesión de Xbox en Tiendas, vuelve a iniciar sesión y luego reanuda.
No se pudo cargar la página de inicio de sesión: %1$s
Este proveedor no permite iniciar sesión desde una página integrada. Inicia sesión con la contraseña de la tienda.
La página de inicio de sesión respondió con un error (HTTP %1$d).
@@ -2763,6 +2772,23 @@
No se encontró un juego de Windows en la descarga
No se pudo extraer la descarga (salida %1$d)
itch.io no respondió
+ Populares
+ Más recientes
+ Nuevos y populares
+ De pago
+ $5 o menos
+ $15 o menos
+ Mejor valorados
+ Más vendidos
+ Cualquier precio
+ Gratis
+ En oferta
+ Cargar más
+ Cualquier plataforma
+ Web móvil
+ Agregar una etiqueta
+ Filtrar por etiqueta
+ No se pudieron cargar los juegos de itch.io
Los archivos %1$s no son compatibles
itch.io respondió HTTP %1$d
Cámaras Luma Ultra — Experimental
diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml
index f6d820e9e4..be27b7ec1f 100644
--- a/app/src/main/res/values-bg/strings.xml
+++ b/app/src/main/res/values-bg/strings.xml
@@ -287,9 +287,6 @@
Автоматично поставя на пауза и продължава, когато се покаже отново. Системно подготвя Steam за заспиване първо. Ръчно изчаква „Продължи“. Никога продължава да работи.
Продължаване на изтеглянията
Отлага фоновото спиране, докато Steam активно изтегля.
- zRAM компресия
- Докато играта работи, паметта на Steam клиента се компресира в zram на устройството, така че играта получава повече RAM. Важи при следващото стартиране на Steam.
- Недостъпно: устройството няма zram или swap, или ядрото е по-старо от 5.4.
Автоматично поставя на пауза във фонов режим и продължава при показване. Ръчно изчаква „Продължи“. Никога продължава да работи.
Стартиране
Стартиране на Steam заедно с DroidDeck
@@ -544,8 +541,8 @@
Turnip: рендиране sysmem
По-бързо за клиента на Steam; в игрите драйверът избира за всеки проход между рендериране на плочки и в системната памет. Задължително на Adreno 710/720/722.
Пропускане на помощника xalia на Steam
- droiddeck-ntsync (експериментално)
- Заместител на потребителско ниво за драйвера ntsync на Linux, за тестване. Докато е включен, Proton го използва вместо droiddeck-esync и droiddeck-fsync. Работи с Proton Experimental ARM64, GE-Proton и proton-cachyos. Прилага се от следващата сесия.
+ droiddeck-ntsync
+ Заместител на потребителско ниво за драйвера ntsync на Linux. Докато е включен, Proton го използва вместо droiddeck-esync и droiddeck-fsync. Работи с Proton Experimental ARM64, GE-Proton и proton-cachyos. Прилага се от следващата сесия.
droiddeck-esync
droiddeck-fsync първо
Стартира собствения fsync на Proton върху оригиналните файлове на Proton, с futex_waitv, подаден от потребителско ниво, затова не изисква пакет и продължава да работи веднага след актуализация на Proton от Steam. Докато е включен, игрите го използват преди droiddeck-esync, освен малкото, които Proton държи извън fsync. Прилага се от следващата сесия.
@@ -1404,6 +1401,10 @@
Черен фон, бял текст, синьото за всичко избрано, на фокус или натиснато.
Яркосиньо
По-яркото синьо, върху повърхности, по-близки до тъмносиньо, вместо сиво.
+ Inner Gamer
+ Цветове, които преминават през дъгата. Следва настройките за анимации на Android.
+ Скорост
+ Колко бързо се сменят цветовете.
Градиент
Вашите основен и вторичен цвят, смесени в бутоните и акцентите.
Основен
@@ -1525,6 +1526,13 @@
Пропускане
Избор на тази папка
Назад
+ Изход
+ Връщане в началната папка
+ Началната папка вече не е достъпна
+ Отмяна на операцията?
+ Операцията ще бъде отменена. Сигурни ли сте?
+ Приемам
+ Отказвам
%1$s е монтирано, но в момента не може да се прочете
Изглед като списък
Изглед като мрежа
@@ -1996,6 +2004,23 @@
В изтеглянето не е намерена игра за Windows
Изтеглянето не можа да бъде разархивирано (код %1$d)
itch.io не отговори
+ Популярни
+ Най-нови
+ Нови и популярни
+ Платени
+ До $5
+ До $15
+ Най-високо оценени
+ Най-продавани
+ Всякаква цена
+ Безплатни
+ С намаление
+ Зареди още
+ Всяка платформа
+ Мобилен уеб
+ Добавяне на таг
+ Филтриране по таг
+ Игрите от itch.io не можаха да се заредят
Архивите %1$s не се поддържат
itch.io отговори HTTP %1$d
Безплатна
@@ -2150,6 +2175,7 @@
Затвори
Опитай отново
Завършване на входа…
+ Microsoft отхвърли входа в Xbox. Излезте от Xbox в Магазини, влезте отново и след това продължете.
Страницата за вход не можа да се зареди: %1$s
Този доставчик отказва вход от вградена страница. Впиши се с паролата си за магазина.
Страницата за вход отговори с грешка (HTTP %1$d).
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 74c7e327f9..9ad560cc46 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -287,9 +287,6 @@
Automaticky pozastaví relaci a obnoví ji při zobrazení. Nativně nejprve připraví Steam na spánek. Manuálně čeká na Obnovit. Nikdy běh nezastavuje.
Nechat stahování běžet
Oddálí pozastavení na pozadí, pokud Steam aktivně stahuje.
- Komprese zRAM
- Během hraní se paměť klienta Steam komprimuje do zram zařízení, takže hra má víc RAM. Platí při příštím spuštění Steamu.
- Není k dispozici: zařízení nemá zram ani swap, nebo je jádro starší než 5.4.
Automaticky pozastaví na pozadí a obnoví při zobrazení. Manuálně čeká na Obnovit. Nikdy běh nezastavuje.
Spouštění
Spustit Steam s DroidDeck
@@ -548,8 +545,8 @@
Turnip: vykreslování sysmem
Rychlejší pro klienta Steam; ve hrách ovladač pro každý průchod volí dlaždicové vykreslování, nebo vykreslování v systémové paměti. Vyžadováno na Adreno 710/720/722.
Vynechat Steamova pomocníka xalia
- droiddeck-ntsync (experimentální)
- Uživatelská náhrada linuxového ovladače ntsync, pro testování. Když je zapnuto, Proton ho používá místo droiddeck-esync a droiddeck-fsync. Funguje s Proton Experimental ARM64, GE-Proton a proton-cachyos. Použije se od příští relace.
+ droiddeck-ntsync
+ Uživatelská náhrada linuxového ovladače ntsync. Když je zapnuto, Proton ho používá místo droiddeck-esync a droiddeck-fsync. Funguje s Proton Experimental ARM64, GE-Proton a proton-cachyos. Použije se od příští relace.
droiddeck-esync
droiddeck-fsync jako první
Spouští vlastní fsync Protonu na původních souborech Protonu, s futex_waitv dodaným v uživatelském prostoru, takže nepotřebuje balíček a funguje i hned po aktualizaci Protonu Steamem. Když je zapnuto, hry ho používají před droiddeck-esync, kromě těch pár, které Proton u fsync nechává vypnuté. Použije se od příští relace.
@@ -1432,6 +1429,10 @@
Černé pozadí, bílé písmo, modrá pro vše vybrané, zaměřené nebo stisknuté.
Elektrická modř
Jasnější modrá na povrchách, které jsou spíše tmavomodré než šedé.
+ Inner Gamer
+ Barvy, které procházejí celou duhu. Respektuje nastavení animací v Androidu.
+ Rychlost
+ Jak rychle se barvy střídají.
Přechod
Vaše vlastní primární a sekundární barva, prolnuté na tlačítkách a zvýrazněních.
Primární
@@ -1563,6 +1564,13 @@
Přeskočit
Vybrat tuto složku
Zpět
+ Ukončit
+ Zpět do výchozí složky
+ Výchozí složka již není dostupná
+ Zrušit operaci?
+ Operace bude zrušena. Opravdu chcete pokračovat?
+ Přijmout
+ Odmítnout
%1$s je připojeno, ale momentálně není čitelné
Zobrazení seznamu
Zobrazení mřížky
@@ -2038,6 +2046,23 @@
Ve stahování nebyla nalezena hra pro Windows
Stažený soubor nelze rozbalit (kód %1$d)
itch.io neodpovědělo
+ Populární
+ Nejnovější
+ Nové a populární
+ Placené
+ Do $5
+ Do $15
+ Nejlépe hodnocené
+ Nejprodávanější
+ Jakákoli cena
+ Zdarma
+ Ve slevě
+ Načíst další
+ Libovolná platforma
+ Mobilní web
+ Přidat štítek
+ Filtrovat podle štítku
+ Hry z itch.io se nepodařilo načíst
Archivy %1$s nejsou podporovány
itch.io odpovědělo HTTP %1$d
Zdarma
@@ -2192,6 +2217,7 @@
Zavřít
Zkusit znovu
Dokončování přihlášení…
+ Microsoft odmítl přihlášení k Xboxu. V Obchodech se z Xboxu odhlaste, znovu se přihlaste a pak pokračujte.
Přihlašovací stránku se nepodařilo načíst: %1$s
Tento poskytovatel odmítá přihlášení ze vložené stránky. Přihlaste se místo toho heslem k obchodu.
Přihlašovací stránka odpověděla chybou (HTTP %1$d).
diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml
index 062bcb4b54..6fa7070bbf 100644
--- a/app/src/main/res/values-da/strings.xml
+++ b/app/src/main/res/values-da/strings.xml
@@ -287,9 +287,6 @@
Auto sætter på pause og genoptager, når den vises. Native forbereder Steam til dvale først. Manuel venter på Genoptag. Aldrig fortsætter med at køre.
Fortsæt downloads
Udskyder baggrundspause, mens Steam aktivt downloader.
- zRAM-komprimering
- Mens et spil kører, komprimeres Steam-klientens hukommelse til enhedens zram, så spillet får mere RAM. Gælder næste gang Steam starter.
- Ikke tilgængeligt: enheden har ingen zram eller swap, eller kernen er ældre end 5.4.
Auto sætter på pause i baggrunden og genoptager, når den vises. Manuel venter på Genoptag. Aldrig fortsætter med at køre.
Opstart
Start Steam med DroidDeck
@@ -544,8 +541,8 @@
Turnip: sysmem-rendering
Hurtigere til Steam-klienten; i spil vælger driveren flise- eller systemhukommelses-rendering for hvert pass. Påkrævet på Adreno 710/720/722.
Spring Steams xalia-hjælper over
- droiddeck-ntsync (eksperimentel)
- En stand-in til ntsync-driveren i Linux-kernen, i brugerrum, til test. Mens den er til, bruger Proton den i stedet for droiddeck-esync og droiddeck-fsync. Fungerer med Proton Experimental ARM64, GE-Proton og proton-cachyos. Gælder fra næste session.
+ droiddeck-ntsync
+ En stand-in til ntsync-driveren i Linux-kernen, i brugerrum. Mens den er til, bruger Proton den i stedet for droiddeck-esync og droiddeck-fsync. Fungerer med Proton Experimental ARM64, GE-Proton og proton-cachyos. Gælder fra næste session.
droiddeck-esync
droiddeck-fsync først
Kører Protons egen fsync på de uændrede Proton-filer, med futex_waitv leveret i brugerrum, så det kræver ingen pack og fortsætter med at virke, lige så snart Steam opdaterer Proton. Mens den er til, bruger spil den før droiddeck-esync, undtagen de få, Proton holder uden for fsync. Gælder fra næste session.
@@ -1404,6 +1401,10 @@
Sort baggrund, hvid skrift, blå til alt, der er valgt, fokuseret eller trykket.
Elektrisk marineblå
Den blå er klarere, på overflader der trækker mod marineblåt i stedet for gråt.
+ Inner Gamer
+ Farver, der skifter gennem regnbuen. Følger Androids animationsindstillinger.
+ Hastighed
+ Hvor hurtigt farverne skifter.
Gradient
Dine egne primære og sekundære farver, blandet på knapper og fremhævninger.
Primær
@@ -1525,6 +1526,13 @@
Spring over
Vælg denne mappe
Tilbage
+ Afslut
+ Tilbage til startmappen
+ Startmappen er ikke længere tilgængelig
+ Annuller handlingen?
+ Handlingen bliver annulleret. Er du sikker?
+ Accepter
+ Afvis
%1$s er monteret, men kan ikke læses lige nu
Listevisning
Gittervisning
@@ -1996,6 +2004,23 @@
Der blev ikke fundet et Windows-spil i downloaden
Downloaden kunne ikke udpakkes (kode %1$d)
itch.io svarede ikke
+ Populære
+ Seneste
+ Nye og populære
+ Betalt
+ $5 eller mindre
+ $15 eller mindre
+ Bedst bedømte
+ Mest solgte
+ Alle priser
+ Gratis
+ På tilbud
+ Indlæs flere
+ Alle platforme
+ Mobilweb
+ Tilføj et tag
+ Filtrer efter tag
+ Kunne ikke hente spil fra itch.io
%1$s-arkiver understøttes ikke
itch.io svarede HTTP %1$d
Gratis
@@ -2150,6 +2175,7 @@
Luk
Forsøg igen
Afslutter login…
+ Microsoft afviste Xbox-login. Log ud af Xbox under Butikker, log ind igen, og genoptag derefter.
Loginsiden kunne ikke indlæses: %1$s
Denne udbyder afviser login fra en indlejret side. Log i stedet ind med din butikskodeord.
Loginsiden svarede med en fejl (HTTP %1$d).
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index d46e0c5758..3a78db29a9 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -541,8 +541,8 @@
Turnip: Sysmem-Rendering
Schneller für den Steam-Client; in Spielen wählt der Treiber pro Durchgang zwischen Kachel- und Systemspeicher-Rendering. Erforderlich bei Adreno 710/720/722.
Steams xalia-Helfer überspringen
- droiddeck-ntsync (experimentell)
- Ein Userspace-Ersatz für den Linux-Treiber ntsync, zum Testen. Solange er aktiv ist, nutzt Proton ihn statt droiddeck-esync und droiddeck-fsync. Funktioniert mit Proton Experimental ARM64, GE-Proton und proton-cachyos. Gilt ab der nächsten Sitzung.
+ droiddeck-ntsync
+ Ein Userspace-Ersatz für den Linux-Treiber ntsync. Solange er aktiv ist, nutzt Proton ihn statt droiddeck-esync und droiddeck-fsync. Funktioniert mit Proton Experimental ARM64, GE-Proton und proton-cachyos. Gilt ab der nächsten Sitzung.
droiddeck-esync
droiddeck-fsync bevorzugen
Führt Protons eigenes fsync mit den unveränderten Proton-Dateien aus, wobei futex_waitv im Userspace bereitgestellt wird. Es braucht daher kein Pack und funktioniert weiter, sobald Steam Proton aktualisiert. Solange es aktiv ist, nutzen Spiele es vor droiddeck-esync, außer den wenigen, die Proton von fsync fernhält. Gilt ab der nächsten Sitzung.
@@ -1393,6 +1393,10 @@
Schwarzer Grund, weiße Schrift, das Blau für alles Ausgewählte, Fokussierte oder Gedrückte.
Elektrisches Marineblau
Das Blau heller, auf Flächen, die eher zu Marineblau als zu Grau tendieren.
+ Inner Gamer
+ Farben, die durch den Regenbogen wechseln. Folgt den Animationseinstellungen von Android.
+ Geschwindigkeit
+ Wie schnell die Farben wechseln.
Farbverlauf
Eigene Primär- und Sekundärfarbe, als Verlauf auf Schaltflächen und Hervorhebungen.
Primär
@@ -1514,6 +1518,13 @@
Überspringen
Diesen Ordner auswählen
Zurück
+ Beenden
+ Zurück zum Startordner
+ Startordner ist nicht mehr verfügbar
+ Vorgang abbrechen?
+ Der Vorgang wird abgebrochen. Bist du sicher?
+ Akzeptieren
+ Ablehnen
%1$s ist eingebunden, aber derzeit nicht lesbar
Listenansicht
Rasteransicht
@@ -1985,6 +1996,23 @@
Im Download wurde kein Windows-Spiel gefunden
Download konnte nicht entpackt werden (Code %1$d)
itch.io hat nicht geantwortet
+ Beliebt
+ Neueste
+ Neu und beliebt
+ Kostenpflichtig
+ 5 $ oder weniger
+ 15 $ oder weniger
+ Bestbewertet
+ Meistverkauft
+ Beliebiger Preis
+ Kostenlos
+ Im Angebot
+ Mehr laden
+ Beliebige Plattform
+ Mobiles Web
+ Tag hinzufügen
+ Nach Tag filtern
+ Spiele von itch.io konnten nicht geladen werden
%1$s-Archive werden nicht unterstützt
itch.io antwortete mit HTTP %1$d
Kostenlos
@@ -2136,6 +2164,7 @@
Schließen
Erneut versuchen
Anmeldung wird abgeschlossen…
+ Microsoft hat die Xbox-Anmeldung abgelehnt. Melde dich unter Stores von Xbox ab, melde dich erneut an und setze dann fort.
Die Anmeldeseite konnte nicht geladen werden: %1$s
Dieser Anbieter lässt keine Anmeldung über eine eingebettete Seite zu. Melde dich stattdessen mit deinem Store-Passwort an.
Die Anmeldeseite antwortete mit einem Fehler (HTTP %1$d).
@@ -2529,9 +2558,6 @@
Komplettierer
%1$s Std.
%1$d Min.
- zRAM-Komprimierung
- Während ein Spiel läuft, wird der Arbeitsspeicher des Steam-Clients in das zram des Geräts komprimiert, sodass mehr RAM für das Spiel bleibt. Wird beim nächsten Start von Steam angewendet.
- Nicht verfügbar: Dieses Gerät hat kein zram oder keinen Swap, oder sein Kernel ist älter als 5.4.
Alle Einstellungen zurücksetzen
Alle Einstellungen zurücksetzen?
Anzeige-, Leistungs-, Controller-, Design-, Sprach- und Launcher-Einstellungen werden auf ihre Standardwerte zurückgesetzt. Deine Spiele, die Steam-Anmeldung, Shop-Konten, heruntergeladene Treiber und Speicherordner bleiben erhalten.
diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml
index dd6458776e..71fbfc6f05 100644
--- a/app/src/main/res/values-el/strings.xml
+++ b/app/src/main/res/values-el/strings.xml
@@ -287,9 +287,6 @@
Το Αυτόματο θέτει σε παύση και συνεχίζει όταν εμφανίζεται. Το Εγγενής προετοιμάζει πρώτα το Steam για αδρανοποίηση. Το Μη αυτόματο περιμένει το Συνέχιση. Το Ποτέ συνεχίζει να εκτελείται.
Διατήρηση των λήψεων σε εξέλιξη
Καθυστερεί την αναστολή παρασκηνίου όσο το Steam κάνει ενεργά λήψη.
- Συμπίεση zRAM
- Όσο τρέχει ένα παιχνίδι, η μνήμη του Steam συμπιέζεται στο zram της συσκευής, ώστε το παιχνίδι να έχει περισσότερη RAM. Ισχύει την επόμενη φορά που θα ξεκινήσει το Steam.
- Μη διαθέσιμο: η συσκευή δεν έχει zram ή swap, ή ο πυρήνας είναι παλαιότερος από 5.4.
Το Αυτόματο θέτει σε παύση στο παρασκήνιο και συνεχίζει όταν εμφανίζεται. Το Μη αυτόματο περιμένει το Συνέχιση. Το Ποτέ συνεχίζει να εκτελείται.
Εκκίνηση
Εκκίνηση του Steam με το DroidDeck
@@ -544,8 +541,8 @@
Turnip: απόδοση sysmem
Ταχύτερο για το πρόγραμμα-πελάτη Steam· στα παιχνίδια ο οδηγός επιλέγει σε κάθε πέρασμα απόδοση με πλακίδια ή στη μνήμη συστήματος. Απαιτείται σε Adreno 710/720/722.
Παράβλεψη του βοηθού xalia του Steam
- droiddeck-ntsync (πειραματικό)
- Ένα υποκατάστατο σε επίπεδο χρήστη για το πρόγραμμα οδήγησης ntsync του Linux, για δοκιμές. Όσο είναι ενεργό, το Proton το χρησιμοποιεί αντί για το droiddeck-esync και το droiddeck-fsync. Λειτουργεί με Proton Experimental ARM64, GE-Proton και proton-cachyos. Εφαρμόζεται στην επόμενη συνεδρία.
+ droiddeck-ntsync
+ Ένα υποκατάστατο σε επίπεδο χρήστη για το πρόγραμμα οδήγησης ntsync του Linux. Όσο είναι ενεργό, το Proton το χρησιμοποιεί αντί για το droiddeck-esync και το droiddeck-fsync. Λειτουργεί με Proton Experimental ARM64, GE-Proton και proton-cachyos. Εφαρμόζεται στην επόμενη συνεδρία.
droiddeck-esync
droiddeck-fsync πρώτα
Εκτελεί το δικό του fsync του Proton στα απλά αρχεία Proton, με το futex_waitv παρεχόμενο σε επίπεδο χρήστη, οπότε δεν χρειάζεται πακέτο και συνεχίζει να λειτουργεί τη στιγμή που το Steam ενημερώνει το Proton. Όσο είναι ενεργό, τα παιχνίδια το χρησιμοποιούν πριν από το droiddeck-esync, εκτός από τα λίγα που το Proton κρατά εκτός fsync. Εφαρμόζεται στην επόμενη συνεδρία.
@@ -1404,6 +1401,10 @@
Μαύρο φόντο, λευκά γράμματα, το μπλε για ό,τι είναι επιλεγμένο, εστιασμένο ή πατημένο.
Ηλεκτρικό ναυτικό μπλε
Το μπλε πιο έντονο, σε επιφάνειες που τείνουν προς το ναυτικό μπλε αντί για γκρι.
+ Inner Gamer
+ Χρώματα που διατρέχουν το ουράνιο τόξο. Ακολουθεί τις ρυθμίσεις animation του Android.
+ Ταχύτητα
+ Πόσο γρήγορα αλλάζουν τα χρώματα.
Διαβάθμιση
Δικά σας πρωτεύον και δευτερεύον χρώμα, σε μίξη στα κουμπιά και τις επισημάνσεις.
Πρωτεύον
@@ -1525,6 +1526,13 @@
Παράλειψη
Επιλογή αυτού του φακέλου
Πίσω
+ Έξοδος
+ Επιστροφή στον αρχικό φάκελο
+ Ο αρχικός φάκελος δεν είναι πλέον διαθέσιμος
+ Ακύρωση ενέργειας;
+ Η ενέργεια θα ακυρωθεί. Είστε σίγουροι;
+ Αποδοχή
+ Απόρριψη
Το %1$s είναι προσαρτημένο αλλά δεν είναι αναγνώσιμο αυτή τη στιγμή
Προβολή λίστας
Προβολή πλέγματος
@@ -1996,6 +2004,23 @@
Δεν βρέθηκε παιχνίδι Windows στη λήψη
Δεν ήταν δυνατή η αποσυμπίεση της λήψης (κωδικός %1$d)
Το itch.io δεν απάντησε
+ Δημοφιλή
+ Πιο πρόσφατα
+ Νέα και δημοφιλή
+ Επί πληρωμή
+ $5 ή λιγότερο
+ $15 ή λιγότερο
+ Κορυφαία βαθμολογία
+ Μπεστ σέλερ
+ Οποιαδήποτε τιμή
+ Δωρεάν
+ Σε προσφορά
+ Φόρτωση περισσότερων
+ Οποιαδήποτε πλατφόρμα
+ Mobile web
+ Προσθήκη ετικέτας
+ Φιλτράρισμα ανά ετικέτα
+ Δεν ήταν δυνατή η φόρτωση παιχνιδιών από το itch.io
Τα αρχεία %1$s δεν υποστηρίζονται
Το itch.io απάντησε HTTP %1$d
Δωρεάν
@@ -2150,6 +2175,7 @@
Κλείσιμο
Δοκιμάστε ξανά
Ολοκλήρωση σύνδεσης…
+ Η Microsoft απέρριψε τη σύνδεση στο Xbox. Αποσυνδεθείτε από το Xbox στα Καταστήματα, συνδεθείτε ξανά και μετά συνεχίστε.
Δεν ήταν δυνατή η φόρτωση της σελίδας σύνδεσης: %1$s
Αυτός ο πάροχος αρνείται να συνδεθεί από μια ενσωματωμένη σελίδα. Συνδεθείτε με τον κωδικό πρόσβασης του καταστήματός σας αντ\' αυτού.
Η σελίδα σύνδεσης απάντησε με σφάλμα (HTTP %1$d).
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index d71362d882..225f38d223 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -545,8 +545,8 @@
Turnip: renderizado sysmem
Más rápido para el cliente de Steam; en los juegos, el controlador elige entre renderizado por mosaicos o en memoria del sistema en cada pasada. Obligatorio en Adreno 710/720/722.
Omitir el asistente xalia de Steam
- droiddeck-ntsync (experimental)
- Un sustituto en espacio de usuario del controlador ntsync de Linux, para pruebas. Mientras está activado, Proton lo usa en lugar de droiddeck-esync y droiddeck-fsync. Funciona con Proton Experimental ARM64, GE-Proton y proton-cachyos. Se aplica en la próxima sesión.
+ droiddeck-ntsync
+ Un sustituto en espacio de usuario del controlador ntsync de Linux. Mientras está activado, Proton lo usa en lugar de droiddeck-esync y droiddeck-fsync. Funciona con Proton Experimental ARM64, GE-Proton y proton-cachyos. Se aplica en la próxima sesión.
droiddeck-esync
droiddeck-fsync primero
Usa el fsync propio de Proton con los archivos originales de Proton, con futex_waitv proporcionado en espacio de usuario, así que no necesita paquete y sigue funcionando en cuanto Steam actualiza Proton. Mientras está activado, los juegos lo usan antes que droiddeck-esync, salvo los pocos que Proton mantiene sin fsync. Se aplica en la próxima sesión.
@@ -1417,6 +1417,10 @@
Fondo negro, texto blanco y el azul para todo lo seleccionado, enfocado o pulsado.
Azul marino eléctrico
Un azul más vivo, sobre superficies que tiran a azul marino en vez de gris.
+ Inner Gamer
+ Colores que recorren el arcoíris. Respeta los ajustes de animación de Android.
+ Velocidad
+ Con qué rapidez cambian los colores.
Degradado
Tus propios colores primario y secundario, combinados en botones y resaltados.
Primario
@@ -1543,6 +1547,13 @@
Omitir
Seleccionar esta carpeta
Atrás
+ Salir
+ Volver a la carpeta inicial
+ La carpeta inicial ya no está disponible
+ ¿Cancelar la operación?
+ La operación se cancelará. ¿Estás seguro?
+ Aceptar
+ Rechazar
%1$s está montado, pero ahora mismo no se puede leer
Vista de lista
Vista de cuadrícula
@@ -2016,6 +2027,23 @@
No se ha encontrado un juego de Windows en la descarga
No se ha podido extraer la descarga (código %1$d)
itch.io no respondió
+ Populares
+ Más recientes
+ Nuevos y populares
+ De pago
+ 5 $ o menos
+ 15 $ o menos
+ Mejor valorados
+ Más vendidos
+ Cualquier precio
+ Gratis
+ En oferta
+ Cargar más
+ Cualquier plataforma
+ Web móvil
+ Añadir una etiqueta
+ Filtrar por etiqueta
+ No se pudieron cargar los juegos de itch.io
Los archivos %1$s no son compatibles
itch.io respondió HTTP %1$d
Gratis
@@ -2167,6 +2195,7 @@
Cerrar
Reintentar
Terminando de iniciar sesión…
+ Microsoft ha rechazado el inicio de sesión de Xbox. Cierra sesión de Xbox en Tiendas, vuelve a iniciar sesión y reanuda.
No se pudo cargar la página de inicio de sesión: %1$s
Este proveedor no permite iniciar sesión desde una página integrada. Inicia sesión con la contraseña de la tienda.
La página de inicio de sesión respondió con un error (HTTP %1$d).
@@ -2564,9 +2593,6 @@
Lo usa el cliente de Steam x86-64
Esta copia está en el cliente de Steam x86-64. Elige x86-64 en Cliente de Steam y desinstálala aquí.
Esta copia está en el cliente de Steam ARM64. Elige ARM64 en Cliente de Steam y desinstálala aquí.
- Compresión zRAM
- Mientras se ejecuta un juego, la memoria del cliente de Steam se comprime en la zram del dispositivo, lo que deja más RAM para el juego. Se aplica la próxima vez que se inicie Steam.
- No disponible: este dispositivo no tiene swap activo, o su kernel es anterior a la 5.4.
No hay suficiente espacio libre: se necesitan %1$s y solo hay %2$s libres
Espacio insuficiente (%1$s libres, se necesitan %2$s)
Espacio libre desconocido
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index a6e7493725..61ca193899 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -287,9 +287,6 @@
Automaattinen keskeyttää ja jatkaa, kun sovellus tulee näkyviin. Natiivi valmistelee Steamin lepotilaan ensin. Manuaalinen odottaa Jatka-painiketta. Ei koskaan pitää sovelluksen aina käynnissä.
Pidä lataukset käynnissä
Viivästytä taustakeskeytystä, kun Steam lataa aktiivisesti.
- zRAM-pakkaus
- Pelin pyöriessä Steam-asiakkaan muisti pakataan laitteen zramiin, jolloin pelille jää enemmän RAM-muistia. Astuu voimaan, kun Steam käynnistetään seuraavan kerran.
- Ei käytettävissä: laitteessa ei ole zramia tai swappia, tai ydin on vanhempi kuin 5.4.
Automaattinen keskeyttää taustalla ja jatkaa, kun sovellus tulee näkyviin. Manuaalinen odottaa Jatka-painiketta. Ei koskaan pitää sovelluksen aina käynnissä.
Käynnistys
Käynnistä Steam DroidDeckin kanssa
@@ -544,8 +541,8 @@
Turnip: sysmem-renderöinti
Nopeampi Steam-asiakasohjelmalle; peleissä ajuri valitsee jokaiselle vaiheelle ruuduittaisen tai järjestelmämuistiin tehtävän renderöinnin. Pakollinen Adreno 710/720/722:lla.
Ohita Steamin xalia-avustaja
- droiddeck-ntsync (kokeellinen)
- Käyttäjätilainen korvike Linuxin ntsync-ajurille, testausta varten. Kun se on päällä, Proton käyttää sitä droiddeck-esyncin ja droiddeck-fsyncin sijaan. Toimii Proton Experimental ARM64:n, GE-Protonin ja proton-cachyosin kanssa. Tulee voimaan seuraavassa istunnossa.
+ droiddeck-ntsync
+ Käyttäjätilainen korvike Linuxin ntsync-ajurille. Kun se on päällä, Proton käyttää sitä droiddeck-esyncin ja droiddeck-fsyncin sijaan. Toimii Proton Experimental ARM64:n, GE-Protonin ja proton-cachyosin kanssa. Tulee voimaan seuraavassa istunnossa.
droiddeck-esync
droiddeck-fsync etusijalle
Käynnistää Protonin omaa fsynciä vakiotiedostoilla, futex_waitv tarjottuna käyttäjätilassa, niin se ei tarvitse pakettia ja toimii edelleen heti kun Steam päivittää Protonin. Kun se on päällä, pelit käyttävät sitä droiddeck-esyncin edellä, paitsi harvat, jotka Proton pitää pois fsyncistä. Tulee voimaan seuraavassa istunnossa.
@@ -1404,6 +1401,10 @@
Musta pohja, valkoinen teksti, sininen kaikessa valitussa, kohdistetussa tai painetussa.
Sähköinen laivastonsininen
Sininen kirkkaampana pinnoilla, jotka taittuvat harmaan sijaan laivastonsiniseen.
+ Inner Gamer
+ Värit, jotka kiertävät sateenkaaren läpi. Noudattaa Androidin animaatioasetuksia.
+ Nopeus
+ Kuinka nopeasti värit vaihtuvat.
Liukuväri
Omat ensisijainen ja toissijainen värisi, sulautettuina painikkeisiin ja korostuksiin.
Ensisijainen
@@ -1525,6 +1526,13 @@
Ohita
Valitse tämä kansio
Takaisin
+ Poistu
+ Palaa aloituskansioon
+ Aloituskansio ei ole enää käytettävissä
+ Peruutetaanko toiminto?
+ Toiminto peruutetaan. Oletko varma?
+ Hyväksy
+ Hylkää
%1$s on liitetty, mutta ei ole luettavissa juuri nyt
Luettelonäkymä
Ruudukkonäkymä
@@ -1996,6 +2004,23 @@
Latauksesta ei löytynyt Windows-peliä
Latausta ei voitu purkaa (koodi %1$d)
itch.io ei vastannut
+ Suositut
+ Uusimmat
+ Uudet ja suositut
+ Maksulliset
+ Enintään 5 $
+ Enintään 15 $
+ Parhaiten arvioidut
+ Myydyimmät
+ Mikä tahansa hinta
+ Ilmaiset
+ Alennuksessa
+ Lataa lisää
+ Mikä tahansa alusta
+ Mobiiliweb
+ Lisää tunniste
+ Suodata tunnisteella
+ Pelien lataaminen itch.io:sta epäonnistui
%1$s-arkistot eivät ole tuettuja
itch.io vastasi HTTP %1$d
Ilmainen
@@ -2150,6 +2175,7 @@
Sulje
Yritä uudelleen
Viimeistellään kirjautumista…
+ Microsoft hylkäsi Xbox-kirjautumisen. Kirjaudu ulos Xboxista Kaupoissa, kirjaudu uudelleen sisään ja jatka sitten.
Kirjautumissivua ei voitu latata: %1$s
Tämä palveluntarjoaja ei salli kirjautumista upotetulta sivulta. Kirjaudu sisään kaupan salasanalla sen sijaan.
Kirjautumissivu vastasi virheellä (HTTP %1$d).
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 27954b6c44..d4b2b58fe9 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -545,8 +545,8 @@
Turnip : rendu sysmem
Le client Steam sera plus rapide ; en jeu, le pilote choisit à chaque passe entre rendu par tuiles et rendu en mémoire système. Requis pour Adreno 710/720/722.
Ignorer l\'assistant xalia de Steam
- droiddeck-ntsync (expérimental)
- Un substitut en espace utilisateur du pilote Linux ntsync, pour les tests. Lorsqu\'il est activé, Proton l\'utilise à la place de droiddeck-esync et de droiddeck-fsync. Fonctionne avec Proton Experimental ARM64, GE-Proton et proton-cachyos. Prendra effet à la prochaine session.
+ droiddeck-ntsync
+ Un substitut en espace utilisateur du pilote Linux ntsync. Lorsqu\'il est activé, Proton l\'utilise à la place de droiddeck-esync et de droiddeck-fsync. Fonctionne avec Proton Experimental ARM64, GE-Proton et proton-cachyos. Prendra effet à la prochaine session.
droiddeck-esync
droiddeck-fsync en priorité
Exécute le fsync propre à Proton sur les fichiers Proton d\'origine, avec futex_waitv fourni en espace utilisateur : aucun pack n\'est nécessaire et il continue de fonctionner dès que Steam met à jour Proton. Lorsqu\'il est activé, les jeux l\'utilisent avant droiddeck-esync, sauf les quelques-uns que Proton exclut de fsync. Prendra effet à la prochaine session.
@@ -1417,6 +1417,10 @@
Fond noir, texte blanc, et le bleu pour tout élément sélectionné, ciblé ou pressé.
Marine électrique
Un bleu plus vif, sur des surfaces qui tirent vers le marine plutôt que vers le gris.
+ Inner Gamer
+ Des couleurs qui parcourent l\'arc-en-ciel. Respecte les réglages d\'animation d\'Android.
+ Vitesse
+ La vitesse de défilement des couleurs.
Dégradé
Vos propres couleurs primaire et secondaire, fondues sur les boutons et les éléments en surbrillance.
Primaire
@@ -1543,6 +1547,13 @@
Ignorer
Sélectionner ce dossier
Retour
+ Quitter
+ Revenir au dossier de départ
+ Le dossier de départ est indisponible
+ Annuler l’opération ?
+ Cette opération sera annulée. Confirmez-vous ?
+ Accepter
+ Refuser
%1$s est monté, mais illisible pour le moment
Vue en liste
Vue en grille
@@ -2016,6 +2027,23 @@
Aucun jeu Windows trouvé dans le téléchargement
Impossible d\'extraire le téléchargement (code %1$d)
itch.io n\'a pas répondu
+ Populaires
+ Plus récents
+ Nouveautés populaires
+ Payants
+ 5 $ ou moins
+ 15 $ ou moins
+ Les mieux notés
+ Meilleures ventes
+ Tous les prix
+ Gratuits
+ En promotion
+ Charger plus
+ Toute plateforme
+ Web mobile
+ Ajouter un tag
+ Filtrer par tag
+ Impossible de charger les jeux d\'itch.io
Les archives %1$s ne sont pas prises en charge
itch.io a répondu HTTP %1$d
Gratuit
@@ -2167,6 +2195,7 @@
Fermer
Réessayer
Finalisation de la connexion…
+ Microsoft a refusé la connexion Xbox. Déconnectez-vous de Xbox dans Boutiques, reconnectez-vous, puis reprenez.
Impossible de charger la page de connexion : %1$s
Ce fournisseur refuse la connexion depuis une page intégrée. Connectez-vous plutôt avec le mot de passe de la boutique.
La page de connexion a renvoyé une erreur (HTTP %1$d).
@@ -2564,9 +2593,6 @@
Télécharger des composants
Les téléchargements sont partagés avec la page « Composants ». Choisissez une version téléchargée ci-dessus pour l\'utiliser au prochain lancement du jeu.
Choisissez une version à télécharger
- Compression zRAM
- Pendant qu\'un jeu tourne, la mémoire du client Steam est compressée dans la zram de l\'appareil, ce qui laisse plus de RAM au jeu. S\'applique au prochain démarrage de Steam.
- Indisponible : cet appareil n\'a pas de swap actif, ou son noyau est antérieur à la version 5.4.
Espace libre insuffisant : %1$s nécessaires, seulement %2$s libres
Espace insuffisant (%1$s libres, %2$s nécessaires)
Espace libre inconnu
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index c7d0f6005e..971ebd34c6 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -287,9 +287,6 @@
ऑटो दिखने पर रुकता है और फिर से शुरू होता है। नेटिव पहले Steam को स्लीप के लिए तैयार करता है। मैनुअल फिर से शुरू करें का इंतज़ार करता है। कभी नहीं वाला चलता रहता है।
डाउनलोड चलते रहने दें
Steam के सक्रिय रूप से डाउनलोड करते समय बैकग्राउंड सस्पेंशन को टालें।
- zRAM कम्प्रेशन
- गेम चलने के दौरान Steam क्लाइंट की मेमोरी डिवाइस के zram में कम्प्रेस होती है, जिससे गेम को ज़्यादा RAM मिलती है। अगली बार Steam शुरू होने पर लागू होगा।
- उपलब्ध नहीं: इस डिवाइस में zram या swap नहीं है, या कर्नेल 5.4 से पुराना है।
ऑटो बैकग्राउंड में रुकता है और दिखने पर फिर से शुरू होता है। मैनुअल फिर से शुरू करें का इंतज़ार करता है। कभी नहीं वाला चलता रहता है।
स्टार्टअप
DroidDeck के साथ Steam शुरू करें
@@ -544,8 +541,8 @@
Turnip: sysmem रेंडरिंग
Steam क्लाइंट के लिए तेज़; गेम में ड्राइवर हर पास के लिए टाइल या सिस्टम मेमोरी रेंडरिंग चुनता है। Adreno 710/720/722 पर ज़रूरी।
Steam के xalia हेल्पर को छोड़ें
- droiddeck-ntsync (एक्सपेरिमेंटल)
- जांच के लिए Linux ntsync ड्राइवर की यूज़रस्पेस जगह लेने वाली चीज़। चालू रहते हुए, Proton इसे droiddeck-esync और droiddeck-fsync के बदले इस्तेमाल करता है। यह Proton Experimental ARM64, GE-Proton और proton-cachyos के साथ काम करता है। अगले सेशन से लागू होता है।
+ droiddeck-ntsync
+ Linux ntsync ड्राइवर की यूज़रस्पेस जगह लेने वाली चीज़। चालू रहते हुए, Proton इसे droiddeck-esync और droiddeck-fsync के बदले इस्तेमाल करता है। यह Proton Experimental ARM64, GE-Proton और proton-cachyos के साथ काम करता है। अगले सेशन से लागू होता है।
droiddeck-esync
droiddeck-fsync पहले
स्टॉक Proton फ़ाइलों पर Proton का अपना fsync चलाता है, futex_waitv यूज़रस्पेस में दिया जाता है, इसलिए इसे किसी पैक की ज़रूरत नहीं और Steam के Proton अपडेट करते ही यह काम करता रहता है। चालू रहते हुए, गेम इसे droiddeck-esync से पहले इस्तेमाल करते हैं, सिवाय उन कुछ के जिन्हें Proton fsync से दूर रखता है। अगले सेशन से लागू होता है।
@@ -1404,6 +1401,10 @@
काली ज़मीन, सफ़ेद टाइप, चुने, फ़ोकस या दबाए गए हर चीज़ के लिए ब्लू रंग।
इलेक्ट्रिक नेवी
ब्लू रंग ज़्यादा चमकीला, उन सतहों पर जो ग्रे के बजाय नेवी की ओर झुकती हैं।
+ Inner Gamer
+ इंद्रधनुष के रंगों में बदलते रंग। Android की एनिमेशन सेटिंग का पालन करती है।
+ गति
+ रंग कितनी तेज़ी से बदलें।
ग्रेडिएंट
आपके अपने प्राथमिक और द्वितीयक रंग, बटनों और हाइलाइट पर मिश्रित।
प्राथमिक
@@ -1525,6 +1526,13 @@
छोड़ें
यह फ़ोल्डर चुनें
बैक
+ बाहर निकलें
+ शुरुआती फ़ोल्डर पर लौटें
+ शुरुआती फ़ोल्डर अब उपलब्ध नहीं है
+ कार्रवाई रद्द करें?
+ कार्रवाई रद्द कर दी जाएगी। क्या आप सुनिश्चित हैं?
+ स्वीकार करें
+ अस्वीकार करें
%1$s माउंट है लेकिन अभी पढ़ा नहीं जा सकता
लिस्ट व्यू
ग्रिड व्यू
@@ -1996,6 +2004,23 @@
डाउनलोड में कोई Windows गेम नहीं मिला
डाउनलोड एक्सट्रैक्ट नहीं हो सका (कोड %1$d)
itch.io ने जवाब नहीं दिया
+ लोकप्रिय
+ सबसे हाल के
+ नए और लोकप्रिय
+ सशुल्क
+ $5 या कम
+ $15 या कम
+ सबसे ऊँची रेटिंग
+ सबसे ज़्यादा बिकने वाले
+ कोई भी कीमत
+ मुफ़्त
+ सेल में
+ और लोड करें
+ कोई भी प्लेटफ़ॉर्म
+ मोबाइल वेब
+ टैग जोड़ें
+ टैग के अनुसार फ़िल्टर करें
+ itch.io से गेम लोड नहीं हो सके
%1$s आर्काइव समर्थित नहीं हैं
itch.io ने HTTP %1$d लौटाया
फ़्री
@@ -2150,6 +2175,7 @@
बंद करें
फिर कोशिश करें
साइन-इन पूरा हो रहा है…
+ Microsoft ने Xbox साइन-इन अस्वीकार कर दिया। स्टोर्स में Xbox से साइन आउट करें, फिर से साइन इन करें, फिर जारी रखें।
साइन-इन पेज लोड नहीं हो सका: %1$s
यह प्रोवाइडर एम्बेडेड पेज से साइन इन करने से मना करता है। इसके बदले अपने स्टोर पासवर्ड से साइन इन करें।
साइन-इन पेज ने एक एरर के साथ जवाब दिया (HTTP %1$d)।
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
index c146857a5e..5463a8a5c6 100644
--- a/app/src/main/res/values-hu/strings.xml
+++ b/app/src/main/res/values-hu/strings.xml
@@ -287,9 +287,6 @@
Az Automatikus szüneteltet, és megjelenéskor folytatja. A Natív előbb felkészíti a Steamet az altatásra. A Manuális megvárja a Folytatást. A Soha mindig futva tartja.
Letöltések futtatásának fenntartása
Elhalasztja a háttérbeli felfüggesztést, amíg a Steam aktívan letölt.
- zRAM-tömörítés
- Játék közben a Steam kliens memóriája a készülék zramjába tömörül, így a játéknak több RAM jut. A Steam következő indításakor lép életbe.
- Nem elérhető: a készüléken nincs zram vagy swap, vagy a kernel régebbi az 5.4-nél.
Az Automatikus szüneteltet a háttérben, és megjelenéskor folytatja. A Manuális megvárja a Folytatást. A Soha mindig futva tartja.
Indítás
Steam indítása a DroidDeckkel
@@ -544,8 +541,8 @@
Turnip: sysmem renderelés
Gyorsabb a Steam kliensnek; játékokban a meghajtó menetenként választ a csempés és a rendszermemóriás renderelés között. Adreno 710/720/722-n szükséges.
A Steam xalia segítőjének kihagyása
- droiddeck-ntsync (kísérleti)
- A Linux ntsync illesztőprogram felhasználói szintű helyettesítője, teszteléshez. Amíg be van kapcsolva, a Proton ezt használja a droiddeck-esync és a droiddeck-fsync helyett. A Proton Experimental ARM64-gyel, a GE-Protonnal és a proton-cachyosszal működik. A következő munkamenettől érvényes.
+ droiddeck-ntsync
+ A Linux ntsync illesztőprogram felhasználói szintű helyettesítője. Amíg be van kapcsolva, a Proton ezt használja a droiddeck-esync és a droiddeck-fsync helyett. A Proton Experimental ARM64-gyel, a GE-Protonnal és a proton-cachyosszal működik. A következő munkamenettől érvényes.
droiddeck-esync
droiddeck-fsync előre
A Proton saját fsyncjét futtatja az eredeti Proton-fájlokon, felhasználói szinten biztosított futex_waitv-vel, így nincs szükség csomagra, és azonnal működik, amint a Steam frissíti a Protont. Amíg be van kapcsolva, a játékok ezt használják a droiddeck-esync előtt, kivéve azt a néhányat, amelyet a Proton kizár az fsyncből. A következő munkamenettől érvényes.
@@ -1404,6 +1401,10 @@
Fekete alap, fehér betűk, a kék minden kijelölt, fókuszált vagy lenyomott elemhez.
Elektromos tengerészkék
Fényesebb kék, szürke helyett tengerészkék felületeken.
+ Inner Gamer
+ A szivárvány színein végigfutó színek. Követi az Android animációs beállításait.
+ Sebesség
+ Milyen gyorsan váltanak a színek.
Színátmenet
Saját elsődleges és másodlagos színed, átmenettel a gombokon és a kiemeléseken.
Elsődleges
@@ -1525,6 +1526,13 @@
Kihagyás
Ennek a mappának a kiválasztása
Vissza
+ Kilépés
+ Vissza a kezdőmappába
+ A kezdőmappa már nem érhető el
+ Művelet megszakítása?
+ A művelet megszakad. Biztos benne?
+ Elfogadom
+ Elutasítom
A %1$s csatolva van, de jelenleg nem olvasható
Listanézet
Rácsnézet
@@ -1996,6 +2004,23 @@
A letöltésben nem található Windows-játék
A letöltés nem bontható ki (kód: %1$d)
Az itch.io nem válaszolt
+ Népszerű
+ Legfrissebb
+ Új és népszerű
+ Fizetős
+ Legfeljebb 5 $
+ Legfeljebb 15 $
+ Legjobbra értékelt
+ Legkelendőbb
+ Bármilyen ár
+ Ingyenes
+ Akciós
+ Továbbiak betöltése
+ Bármely platform
+ Mobilweb
+ Címke hozzáadása
+ Szűrés címke szerint
+ Nem sikerült betölteni a játékokat az itch.io-ról
A(z) %1$s archívumok nem támogatottak
Az itch.io HTTP %1$d választ adott
Ingyenes
@@ -2150,6 +2175,7 @@
Bezárás
Próbálja újra
A bejelentkezés befejezése…
+ A Microsoft elutasította az Xbox-bejelentkezést. Az Áruházakban jelentkezz ki az Xboxból, jelentkezz be újra, majd folytasd.
Nem sikerült betölteni a bejelentkezési oldalt: %1$s
Ez a szolgáltató nem engedi a bejelentkezést egy beágyazott oldalról. Jelentkezzen be helyette az áruház jelszavával.
A bejelentkezési oldal hibával válaszolt (HTTP %1$d).
diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml
index 8208d2fa3c..c04243615b 100644
--- a/app/src/main/res/values-in/strings.xml
+++ b/app/src/main/res/values-in/strings.xml
@@ -287,9 +287,6 @@
Otomatis menjeda dan melanjutkan saat ditampilkan. Native menyiapkan Steam untuk tidur terlebih dahulu. Manual menunggu Lanjutkan. Tidak pernah terus berjalan.
Pertahankan unduhan tetap berjalan
Menunda penjedaan latar belakang saat Steam sedang aktif mengunduh.
- Kompresi zRAM
- Saat bermain, memori klien Steam dipadatkan ke zram perangkat sehingga gim mendapat lebih banyak RAM. Berlaku saat Steam dijalankan berikutnya.
- Tidak tersedia: perangkat ini tidak punya zram atau swap, atau kernelnya lebih lama dari 5.4.
Otomatis menjeda di latar belakang dan melanjutkan saat ditampilkan. Manual menunggu Lanjutkan. Tidak pernah terus berjalan.
Mulai
Mulai Steam bersama DroidDeck
@@ -542,8 +539,8 @@
Turnip: rendering sysmem
Lebih cepat untuk klien Steam; di gim, driver memilih rendering ubin atau memori sistem untuk setiap pass. Diperlukan pada Adreno 710/720/722.
Lewati bantuan xalia milik Steam
- droiddeck-ntsync (eksperimental)
- Pengganti userspace untuk driver ntsync Linux, untuk pengujian. Saat aktif, Proton menggunakannya sebagai pengganti droiddeck-esync dan droiddeck-fsync. Berfungsi dengan Proton Experimental ARM64, GE-Proton, dan proton-cachyos. Berlaku pada sesi berikutnya.
+ droiddeck-ntsync
+ Pengganti userspace untuk driver ntsync Linux. Saat aktif, Proton menggunakannya sebagai pengganti droiddeck-esync dan droiddeck-fsync. Berfungsi dengan Proton Experimental ARM64, GE-Proton, dan proton-cachyos. Berlaku pada sesi berikutnya.
droiddeck-esync
droiddeck-fsync lebih dulu
Menjalankan fsync milik Proton sendiri pada file Proton standar, dengan futex_waitv yang disediakan di userspace, sehingga tidak memerlukan paket dan tetap berfungsi begitu Steam memperbarui Proton. Saat aktif, gim menggunakannya sebelum droiddeck-esync, kecuali beberapa gim yang oleh Proton dijaga tetap di luar fsync. Berlaku pada sesi berikutnya.
@@ -1390,6 +1387,10 @@
Dasar hitam, tipe putih, biru untuk semua yang dipilih, difokuskan, atau ditekan.
Navy elektrik
Biru yang lebih cerah, pada permukaan yang condong ke navy, bukan abu-abu.
+ Inner Gamer
+ Warna yang berganti menyusuri pelangi. Mengikuti pengaturan animasi Android.
+ Kecepatan
+ Seberapa cepat warna berganti.
Gradasi
Warna primer dan sekunder pilihan Anda, dipadukan pada tombol dan sorotan.
Primer
@@ -1506,6 +1507,13 @@
Lewati
Pilih folder ini
Kembali
+ Keluar
+ Kembali ke folder awal
+ Folder awal tidak lagi tersedia
+ Batalkan operasi?
+ Operasi akan dibatalkan. Anda yakin?
+ Terima
+ Tolak
%1$s terpasang tetapi tidak dapat dibaca saat ini
Tampilan daftar
Tampilan kisi
@@ -1975,6 +1983,23 @@
Tidak ada game Windows di unduhan
Tidak dapat mengekstrak unduhan (kode %1$d)
itch.io tidak menjawab
+ Populer
+ Terbaru
+ Baru dan populer
+ Berbayar
+ $5 atau kurang
+ $15 atau kurang
+ Rating tertinggi
+ Terlaris
+ Harga apa saja
+ Gratis
+ Diskon
+ Muat lebih banyak
+ Platform apa saja
+ Web seluler
+ Tambah tag
+ Filter berdasarkan tag
+ Tidak dapat memuat game dari itch.io
Arsip %1$s tidak didukung
itch.io menjawab HTTP %1$d
Gratis
@@ -2129,6 +2154,7 @@
Tutup
Coba lagi
Menyelesaikan proses masuk…
+ Microsoft menolak masuk Xbox. Keluar dari Xbox di Toko, masuk lagi, lalu lanjutkan.
Halaman masuk tidak dapat dimuat: %1$s
Penyedia ini menolak proses masuk dari halaman tersemat. Masuk dengan kata sandi toko Anda sebagai gantinya.
Halaman masuk merespons dengan kesalahan (HTTP %1$d).
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 75e4645136..db15c513c2 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -543,8 +543,8 @@
Turnip: rendering sysmem
Più veloce per il client di Steam; nei giochi il driver sceglie per ogni passata tra rendering a tile e in memoria di sistema. Necessario su Adreno 710/720/722.
Salta l\'assistente xalia di Steam
- droiddeck-ntsync (sperimentale)
- Un sostituto in userspace del driver ntsync di Linux, per i test. Quando è attivo, Proton lo usa al posto di droiddeck-esync e droiddeck-fsync. Funziona con Proton Experimental ARM64, GE-Proton e proton-cachyos. Si applica dalla prossima sessione.
+ droiddeck-ntsync
+ Un sostituto in userspace del driver ntsync di Linux. Quando è attivo, Proton lo usa al posto di droiddeck-esync e droiddeck-fsync. Funziona con Proton Experimental ARM64, GE-Proton e proton-cachyos. Si applica dalla prossima sessione.
droiddeck-esync
Prima droiddeck-fsync
Esegue il fsync di Proton sui file Proton originali, con futex_waitv fornito in userspace, quindi non richiede pacchetti e continua a funzionare appena Steam aggiorna Proton. Quando è attivo, i giochi lo usano prima di droiddeck-esync, tranne i pochi che Proton esclude da fsync. Si applica dalla prossima sessione.
@@ -1407,6 +1407,10 @@
Fondo nero, testo bianco, il blu per tutto ciò che è selezionato, attivo o premuto.
Blu elettrico
Il blu più brillante, su superfici che tendono al blu navy invece che al grigio.
+ Inner Gamer
+ Colori che scorrono lungo l\'arcobaleno. Rispetta le impostazioni di animazione di Android.
+ Velocità
+ Quanto velocemente cambiano i colori.
Gradiente
I tuoi colori primario e secondario, sfumati su pulsanti ed evidenziazioni.
Primario
@@ -1533,6 +1537,13 @@
Salta
Seleziona questa cartella
Indietro
+ Esci
+ Torna alla cartella iniziale
+ La cartella iniziale non è più disponibile
+ Annullare operazione?
+ Questa operazione verrà annullata. Confermi?
+ Accetta
+ Rifiuta
%1$s: montata ma al momento non leggibile
Visualizzazione elenco
Visualizzazione griglia
@@ -2006,6 +2017,23 @@
Nessun gioco Windows trovato nel download
Impossibile estrarre il download (codice %1$d)
itch.io non ha risposto
+ Popolari
+ Più recenti
+ Nuovi e popolari
+ A pagamento
+ 5 $ o meno
+ 15 $ o meno
+ I più votati
+ I più venduti
+ Qualsiasi prezzo
+ Gratis
+ In offerta
+ Carica altri
+ Qualsiasi piattaforma
+ Web mobile
+ Aggiungi un tag
+ Filtra per tag
+ Impossibile caricare i giochi da itch.io
Gli archivi %1$s non sono supportati
itch.io ha risposto HTTP %1$d
Gratis
@@ -2157,6 +2185,7 @@
Chiudi
Riprova
Completamento dell\'accesso…
+ Microsoft ha rifiutato l\'accesso a Xbox. Esci da Xbox in Negozi, accedi di nuovo, poi riprendi.
Impossibile caricare la pagina di accesso: %1$s
Questo provider non consente l\'accesso da una pagina incorporata. Accedi invece con la password del negozio.
La pagina di accesso ha risposto con un errore (HTTP %1$d).
@@ -2554,9 +2583,6 @@
Completista
%1$s h
%1$d min
- Compressione zRAM
- Mentre un gioco è in esecuzione, la memoria del client Steam viene compressa nella zram del dispositivo, lasciando più RAM al gioco. Si applica al prossimo avvio di Steam.
- Non disponibile: questo dispositivo non ha zram o swap, oppure il suo kernel è precedente alla 5.4.
Ripristina tutte le impostazioni
Ripristinare tutte le impostazioni?
Le impostazioni di schermo, prestazioni, controller, tema, lingua e launcher tornano ai valori predefiniti. Giochi, accesso a Steam, account degli store, driver scaricati e cartelle di archiviazione vengono mantenuti.
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index dc8517802d..54766ad802 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -287,9 +287,6 @@
自動では一時停止し、表示すると再開します。ネイティブでは先にSteamをスリープに備えさせます。手動では「再開」をタップするまで待機します。「しない」では実行し続けます。
ダウンロードを継続
Steamがダウンロード中は、バックグラウンドでの一時停止を遅らせます。
- zRAM 圧縮
- ゲームの実行中、Steam クライアントのメモリがデバイスの zram に圧縮され、ゲーム用のメモリが増えます。次回 Steam を起動したときに反映されます。
- 使用できません:このデバイスに zram もしくは swap がないか、カーネルが 5.4 未満です。
自動ではバックグラウンドで一時停止し、表示すると再開します。手動では「再開」をタップするまで待機します。「しない」では実行し続けます。
起動
DroidDeck起動時にSteamを起動
@@ -544,8 +541,8 @@
Turnip:sysmemレンダリング
Steamクライアントが高速になります。ゲームではドライバーがパスごとにタイルレンダリングとシステムメモリレンダリングを選びます。Adreno 710/720/722では必須です。
Steamのxalia補助をスキップ
- droiddeck-ntsync(実験的)
- Linuxのntsyncドライバーをユーザー空間で代替するテスト用機能です。オンの間、Protonはdroiddeck-esyncとdroiddeck-fsyncの代わりにこれを使用します。Proton Experimental ARM64、GE-Proton、proton-cachyosで動作します。次回のセッションで有効になります。
+ droiddeck-ntsync
+ Linuxのntsyncドライバーをユーザー空間で代替する機能です。オンの間、Protonはdroiddeck-esyncとdroiddeck-fsyncの代わりにこれを使用します。Proton Experimental ARM64、GE-Proton、proton-cachyosで動作します。次回のセッションで有効になります。
droiddeck-esync
droiddeck-fsyncを優先
futex_waitvをユーザー空間で提供し、標準のProtonファイルのままProton自身のfsyncを実行します。パックが不要なため、SteamがProtonを更新してもすぐに動作し続けます。オンの間、Protonがfsyncを使わない一部のゲームを除き、ゲームはdroiddeck-esyncよりこちらを優先します。次回のセッションで有効になります。
@@ -1392,6 +1389,10 @@
黒の背景に白の文字、選択・フォーカス・押下時には青を使用します。
エレクトリックネイビー
より明るい青を、グレーではなくネイビー寄りの画面に使用します。
+ Inner Gamer
+ 虹色に変化し続けるカラー。Android のアニメーション設定に従います。
+ 速度
+ 色が切り替わる速さ。
グラデーション
自分で選んだプライマリとセカンダリの色を、ボタンやハイライトにグラデーションで使います。
プライマリ
@@ -1508,6 +1509,13 @@
スキップ
このフォルダを選択
戻る
+ 終了
+ 開始フォルダーに戻る
+ 開始フォルダーは利用できなくなりました
+ 操作をキャンセルしますか?
+ 操作がキャンセルされます。よろしいですか?
+ 承諾
+ 拒否
%1$sはマウントされていますが、現在読み取れません
リスト表示
グリッド表示
@@ -1977,6 +1985,23 @@
ダウンロードに Windows 版のゲームが見つかりません
ダウンロードを展開できませんでした (終了コード %1$d)
itch.io から応答がありません
+ 人気
+ 新着順
+ 新着&人気
+ 有料
+ 5ドル以下
+ 15ドル以下
+ 高評価
+ 売れ筋
+ すべての価格
+ 無料
+ セール中
+ さらに読み込む
+ すべてのプラットフォーム
+ モバイルWeb
+ タグを追加
+ タグで絞り込む
+ itch.io のゲームを読み込めませんでした
%1$s 形式のアーカイブには対応していません
itch.io が HTTP %1$d を返しました
無料
@@ -2131,6 +2156,7 @@
閉じる
再試行
ログインを完了しています…
+ Microsoft が Xbox のサインインを拒否しました。ストアで Xbox からサインアウトし、もう一度サインインしてから再開してください。
ログインページを読み込めませんでした:%1$s
このプロバイダーは埋め込みページからのログインを拒否しています。代わりにストアのパスワードでログインしてください。
ログインページがエラーを返しました(HTTP %1$d)。
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index 4cada9f9f0..0315047d85 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -287,9 +287,6 @@
자동: 일시 중지되고 다시 표시되면 재개됩니다. 네이티브: 먼저 Steam을 절전에 대비시킵니다. 수동: \"재개\"를 탭할 때까지 기다립니다. 안 함: 계속 실행됩니다.
다운로드 계속 진행
Steam이 다운로드 중일 때는 백그라운드 일시 중지를 미룹니다.
- zRAM 압축
- 게임을 실행하는 동안 Steam 클라이언트의 메모리가 기기의 zram으로 압축되어 게임에 더 많은 메모리가 남습니다. 다음에 Steam을 시작할 때 적용됩니다.
- 사용할 수 없음: 이 기기에 zram 또는 swap이 없거나 커널이 5.4 미만입니다.
자동: 백그라운드에서 일시 중지되고 다시 표시되면 재개됩니다. 수동: \"재개\"를 탭할 때까지 기다립니다. 안 함: 계속 실행됩니다.
시작
DroidDeck을 열 때 Steam 시작
@@ -544,8 +541,8 @@
Turnip: sysmem 렌더링
Steam 클라이언트가 빨라집니다. 게임에서는 드라이버가 패스마다 타일 렌더링과 시스템 메모리 렌더링 중 하나를 고릅니다. Adreno 710/720/722에 필수입니다.
Steam의 xalia 도우미 건너뛰기
- droiddeck-ntsync(실험적)
- 테스트용으로 Linux ntsync 드라이버를 사용자 공간에서 대신하는 기능입니다. 켜져 있으면 Proton이 droiddeck-esync와 droiddeck-fsync 대신 이 기능을 사용합니다. Proton Experimental ARM64, GE-Proton 및 proton-cachyos에서 작동합니다. 다음 세션에 적용됩니다.
+ droiddeck-ntsync
+ Linux ntsync 드라이버를 사용자 공간에서 대신하는 기능입니다. 켜져 있으면 Proton이 droiddeck-esync와 droiddeck-fsync 대신 이 기능을 사용합니다. Proton Experimental ARM64, GE-Proton 및 proton-cachyos에서 작동합니다. 다음 세션에 적용됩니다.
droiddeck-esync
droiddeck-fsync 우선
futex_waitv를 사용자 공간에서 제공하여 기본 Proton 파일로 Proton 자체의 fsync를 실행하므로, 팩이 필요 없고 Steam이 Proton을 업데이트해도 바로 작동합니다. 켜져 있으면 게임이 droiddeck-esync보다 이 기능을 우선 사용합니다. 단, Proton이 fsync를 끄는 일부 게임은 예외입니다. 다음 세션에 적용됩니다.
@@ -1392,6 +1389,10 @@
검은색 배경에 흰색 글자, 선택·포커스·누름 상태에는 파란색을 사용합니다.
일렉트릭 네이비
회색 대신 네이비 톤의 화면에 더 밝은 파란색을 사용합니다.
+ Inner Gamer
+ 무지개 색으로 계속 바뀌는 색상입니다. Android의 애니메이션 설정을 따릅니다.
+ 속도
+ 색상이 바뀌는 속도입니다.
그라데이션
직접 고른 기본색과 보조색이 버튼과 강조 표시에 섞여 적용됩니다.
기본색
@@ -1508,6 +1509,13 @@
건너뛰기
이 폴더 선택
뒤로
+ 종료
+ 시작 폴더로 돌아가기
+ 시작 폴더를 더 이상 사용할 수 없습니다
+ 작업을 취소할까요?
+ 작업이 취소됩니다. 계속하시겠습니까?
+ 수락
+ 거절
%1$s이(가) 마운트되었지만 지금은 읽을 수 없습니다
목록 보기
격자 보기
@@ -1977,6 +1985,23 @@
다운로드에서 Windows 게임을 찾을 수 없습니다
다운로드한 파일의 압축을 풀 수 없습니다(코드 %1$d)
itch.io가 응답하지 않았습니다
+ 인기
+ 최신순
+ 신규 및 인기
+ 유료
+ $5 이하
+ $15 이하
+ 평점 높은 순
+ 베스트셀러
+ 모든 가격
+ 무료
+ 할인 중
+ 더 불러오기
+ 모든 플랫폼
+ 모바일 웹
+ 태그 추가
+ 태그로 필터링
+ itch.io에서 게임을 불러오지 못했습니다
%1$s 압축 파일은 지원하지 않습니다
itch.io가 HTTP %1$d을(를) 반환했습니다
무료
@@ -2131,6 +2156,7 @@
닫기
다시 시도
로그인 완료 중…
+ Microsoft에서 Xbox 로그인을 거부했습니다. 스토어에서 Xbox 로그아웃 후 다시 로그인한 다음 재개하세요.
로그인 페이지를 불러올 수 없습니다: %1$s
이 제공업체는 앱에 포함된 페이지에서 로그인을 허용하지 않습니다. 대신 스토어 비밀번호로 로그인하세요.
로그인 페이지에서 오류를 반환했습니다(HTTP %1$d).
diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml
index ef8c7d5f22..80b7d10fb1 100644
--- a/app/src/main/res/values-ms/strings.xml
+++ b/app/src/main/res/values-ms/strings.xml
@@ -287,9 +287,6 @@
Auto menjeda dan menyambung semula apabila dipaparkan. Asli menyediakan Steam untuk tidur dahulu. Manual menunggu Sambung. Jangan sekali-kali terus berjalan.
Teruskan muat turun
Lambatkan penjedaan latar belakang semasa Steam aktif memuat turun.
- Pemampatan zRAM
- Semasa bermain, memori klien Steam dimampatkan ke zram peranti supaya permainan mendapat lebih RAM. Berkuat kuasa pada permulaan Steam seterusnya.
- Tidak tersedia: peranti ini tiada zram atau swap, atau kernelnya lebih lama daripada 5.4.
Auto menjeda di latar belakang dan menyambung semula apabila dipaparkan. Manual menunggu Sambung. Jangan sekali-kali terus berjalan.
Permulaan
Mulakan Steam bersama DroidDeck
@@ -542,8 +539,8 @@
Turnip: rendering sysmem
Lebih pantas untuk klien Steam; dalam permainan, pemacu memilih pemaparan jubin atau memori sistem bagi setiap laluan. Diperlukan pada Adreno 710/720/722.
Langkau pembantu xalia Steam
- droiddeck-ntsync (eksperimen)
- Pengganti ruang pengguna untuk pemacu ntsync Linux, untuk pengujian. Semasa ia hidup, Proton menggunakannya sebagai ganti droiddeck-esync dan droiddeck-fsync. Berfungsi dengan Proton Experimental ARM64, GE-Proton dan proton-cachyos. Berkuat kuasa pada sesi seterusnya.
+ droiddeck-ntsync
+ Pengganti ruang pengguna untuk pemacu ntsync Linux. Semasa ia hidup, Proton menggunakannya sebagai ganti droiddeck-esync dan droiddeck-fsync. Berfungsi dengan Proton Experimental ARM64, GE-Proton dan proton-cachyos. Berkuat kuasa pada sesi seterusnya.
droiddeck-esync
droiddeck-fsync dahulu
Menjalankan fsync Proton sendiri pada fail Proton standard, dengan futex_waitv dibekalkan dalam ruang pengguna, jadi ia tidak memerlukan pek dan terus berfungsi sebaik sahaja Steam mengemas kini Proton. Semasa ia hidup, permainan menggunakannya mendahului droiddeck-esync, kecuali beberapa Proton yang mematikan fsync. Berkuat kuasa pada sesi seterusnya.
@@ -1390,6 +1387,10 @@
Latar hitam, teks putih, biru untuk semua yang dipilih, difokus atau ditekan.
Navy elektrik
Biru lebih cerah, pada permukaan yang lebih cenderung navy daripada kelabu.
+ Inner Gamer
+ Warna yang bertukar merentasi pelangi. Mengikut tetapan animasi Android.
+ Kelajuan
+ Seberapa pantas warna bertukar.
Kecerunan
Warna utama dan sekunder pilihan anda, diadun pada butang dan sorotan.
Utama
@@ -1506,6 +1507,13 @@
Langkau
Pilih folder ini
Kembali
+ Keluar
+ Kembali ke folder asal
+ Folder asal tidak lagi tersedia
+ Batalkan operasi?
+ Operasi akan dibatalkan. Adakah anda pasti?
+ Terima
+ Tolak
%1$s dilekapkan tetapi tidak dapat dibaca sekarang
Paparan senarai
Paparan grid
@@ -1975,6 +1983,23 @@
Tiada permainan Windows ditemui dalam muat turun
Tidak dapat mengekstrak muat turun (kod %1$d)
itch.io tidak menjawab
+ Popular
+ Terkini
+ Baharu dan popular
+ Berbayar
+ $5 atau kurang
+ $15 atau kurang
+ Penilaian tertinggi
+ Terlaris
+ Sebarang harga
+ Percuma
+ Diskaun
+ Muat lagi
+ Mana-mana platform
+ Web mudah alih
+ Tambah tag
+ Tapis mengikut tag
+ Tidak dapat memuatkan permainan daripada itch.io
Arkib %1$s tidak disokong
itch.io menjawab HTTP %1$d
Percuma
@@ -2129,6 +2154,7 @@
Tutup
Cuba lagi
Menyelesaikan log masuk…
+ Microsoft menolak log masuk Xbox. Log keluar daripada Xbox di Kedai, log masuk semula, kemudian sambung.
Halaman log masuk tidak dapat dimuatkan: %1$s
Penyedia ini menolak log masuk daripada halaman terbenam. Log masuk dengan kata laluan kedai anda sebaliknya.
Halaman log masuk menjawab dengan ralat (HTTP %1$d).
diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml
index 5dc36a00c5..210c71f330 100644
--- a/app/src/main/res/values-nb/strings.xml
+++ b/app/src/main/res/values-nb/strings.xml
@@ -287,9 +287,6 @@
Auto setter på pause og gjenopptar når den vises. Nativ forbereder Steam på hvilemodus først. Manuell venter på Gjenoppta. Aldri lar den fortsette å kjøre.
La nedlastinger fortsette
Utsetter bakgrunnspause mens Steam laster aktivt ned.
- zRAM-komprimering
- Mens et spill kjører, komprimeres minnet til Steam-klienten til enhetens zram, slik at spillet får mer RAM. Gjelder neste gang Steam starter.
- Ikke tilgjengelig: enheten har ingen zram eller swap, eller kjernen er eldre enn 5.4.
Auto setter på pause i bakgrunnen og gjenopptar når den vises. Manuell venter på Gjenoppta. Aldri lar den fortsette å kjøre.
Oppstart
Start Steam med DroidDeck
@@ -544,8 +541,8 @@
Turnip: sysmem-rendering
Raskere for Steam-klienten; i spill velger driveren flis- eller systemminnerendering for hvert pass. Påkrevd på Adreno 710/720/722.
Hopp over Steams xalia-hjelper
- droiddeck-ntsync (eksperimentell)
- En erstatning i brukerrom for Linux-driveren ntsync, for testing. Mens dette er på, bruker Proton den i stedet for droiddeck-esync og droiddeck-fsync. Fungerer med Proton Experimental ARM64, GE-Proton og proton-cachyos. Gjelder fra neste sesjon.
+ droiddeck-ntsync
+ En erstatning i brukerrom for Linux-driveren ntsync. Mens dette er på, bruker Proton den i stedet for droiddeck-esync og droiddeck-fsync. Fungerer med Proton Experimental ARM64, GE-Proton og proton-cachyos. Gjelder fra neste sesjon.
droiddeck-esync
droiddeck-fsync først
Kjører Protons egen fsync på de uendrede Proton-filene, med futex_waitv levert i brukerrom, så den trenger ingen pakke og fortsetter å fungere i det Steam oppdaterer Proton. Mens dette er på, bruker spill den foran droiddeck-esync, med unntak av de få Proton holder utenfor fsync. Gjelder fra neste sesjon.
@@ -1404,6 +1401,10 @@
Svart bakgrunn, hvit skrift, det blå for alt som er valgt, fokusert eller trykket.
Elektrisk marineblå
Det blå lysere, på flater som lener mer mot marineblått enn grått.
+ Inner Gamer
+ Farger som går gjennom regnbuen. Følger Androids animasjonsinnstillinger.
+ Hastighet
+ Hvor raskt fargene skifter.
Gradient
Dine egne primær- og sekundærfarger, blandet på knapper og uthevinger.
Primær
@@ -1525,6 +1526,13 @@
Hopp over
Velg denne mappen
Tilbake
+ Avslutt
+ Tilbake til startmappen
+ Startmappen er ikke lenger tilgjengelig
+ Avbryt operasjonen?
+ Operasjonen blir avbrutt. Er du sikker?
+ Godta
+ Avslå
%1$s er montert, men ikke lesbar akkurat nå
Listevisning
Rutenettvisning
@@ -1996,6 +2004,23 @@
Fant ikke noe Windows-spill i nedlastingen
Kunne ikke pakke ut nedlastingen (kode %1$d)
itch.io svarte ikke
+ Populære
+ Nyeste
+ Nye og populære
+ Betalt
+ $5 eller mindre
+ $15 eller mindre
+ Best vurdert
+ Mest solgt
+ Alle priser
+ Gratis
+ På salg
+ Last inn flere
+ Alle plattformer
+ Web på mobil
+ Legg til en tagg
+ Filtrer etter tagg
+ Kunne ikke laste spill fra itch.io
%1$s-arkiver støttes ikke
itch.io svarte HTTP %1$d
Gratis
@@ -2150,6 +2175,7 @@
Lukk
Prøv igjen
Fullfører innlogging…
+ Microsoft avviste Xbox-påloggingen. Logg ut av Xbox under Butikker, logg på igjen, og fortsett deretter.
Innloggingssiden kunne ikke lastes: %1$s
Denne leverandøren tillater ikke innlogging fra en innebygd side. Logg inn med butikkpassordet ditt i stedet.
Innloggingssiden svarte med en feil (HTTP %1$d).
diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml
index 02b1493d52..52f5fc5276 100644
--- a/app/src/main/res/values-nl/strings.xml
+++ b/app/src/main/res/values-nl/strings.xml
@@ -287,9 +287,6 @@
Automatisch pauzeert en hervat zodra de app weer zichtbaar is. Systeemeigen maakt Steam eerst klaar voor de slaapstand. Handmatig wacht op Hervatten. Nooit laat alles doorlopen.
Downloads laten doorlopen
Stel onderbreken op de achtergrond uit zolang Steam actief downloadt.
- zRAM-compressie
- Terwijl een game draait wordt het geheugen van de Steam-client gecomprimeerd naar de zram van het apparaat, zodat de game meer RAM heeft. Geldt de volgende keer dat Steam start.
- Niet beschikbaar: dit apparaat heeft geen zram of swap, of de kernel is ouder dan 5.4.
Automatisch pauzeert op de achtergrond en hervat zodra de app weer zichtbaar is. Handmatig wacht op Hervatten. Nooit laat alles doorlopen.
Opstarten
Steam starten met DroidDeck
@@ -544,8 +541,8 @@
Turnip: sysmem-rendering
Sneller voor de Steam-client; in games kiest het stuurprogramma per pass tussen tegel- en systeemgeheugenrendering. Vereist op Adreno 710/720/722.
Sla de xalia-helper van Steam over
- droiddeck-ntsync (experimenteel)
- Een userspace-vervanger voor de ntsync-driver van Linux, voor tests. Terwijl dit aan staat, gebruikt Proton dit in plaats van droiddeck-esync en droiddeck-fsync. Werkt met Proton Experimental ARM64, GE-Proton en proton-cachyos. Geldt vanaf de volgende sessie.
+ droiddeck-ntsync
+ Een userspace-vervanger voor de ntsync-driver van Linux. Terwijl dit aan staat, gebruikt Proton dit in plaats van droiddeck-esync en droiddeck-fsync. Werkt met Proton Experimental ARM64, GE-Proton en proton-cachyos. Geldt vanaf de volgende sessie.
droiddeck-esync
droiddeck-fsync eerst
Draait de eigen fsync van Proton op de standaard Proton-bestanden, met futex_waitv in userspace geleverd, zodat er geen pakket nodig is en dit blijft werken zodra Steam Proton bijwerkt. Terwijl dit aan staat, gebruiken games dit vóór droiddeck-esync, behalve de paar die Proton niet op fsync laat draaien. Geldt vanaf de volgende sessie.
@@ -1404,6 +1401,10 @@
Zwarte achtergrond, witte tekst, het blauw voor alles wat geselecteerd, gefocust of ingedrukt is.
Elektrisch marineblauw
Het blauw feller, op vlakken die naar marineblauw neigen in plaats van grijs.
+ Inner Gamer
+ Kleuren die door de regenboog lopen. Volgt de animatie-instellingen van Android.
+ Snelheid
+ Hoe snel de kleuren wisselen.
Kleurverloop
Je eigen primaire en secundaire kleur, doorlopend op knoppen en accenten.
Primair
@@ -1525,6 +1526,13 @@
Overslaan
Deze map selecteren
Terug
+ Afsluiten
+ Terug naar beginmap
+ De beginmap is niet meer beschikbaar
+ Bewerking annuleren?
+ De bewerking wordt geannuleerd. Weet je het zeker?
+ Accepteren
+ Weigeren
%1$s is gekoppeld, maar nu niet leesbaar
Lijstweergave
Rasterweergave
@@ -1996,6 +2004,23 @@
Geen Windows-game gevonden in de download
Download kan niet worden uitgepakt (code %1$d)
itch.io gaf geen antwoord
+ Populair
+ Meest recent
+ Nieuw en populair
+ Betaald
+ $5 of minder
+ $15 of minder
+ Hoogst beoordeeld
+ Bestverkocht
+ Elke prijs
+ Gratis
+ In de aanbieding
+ Meer laden
+ Elk platform
+ Mobiel web
+ Tag toevoegen
+ Filteren op tag
+ Games van itch.io konden niet worden geladen
%1$s-archieven worden niet ondersteund
itch.io antwoordde HTTP %1$d
Gratis
@@ -2150,6 +2175,7 @@
Sluiten
Probeer het opnieuw
Aanmelden afronden…
+ Microsoft heeft de Xbox-aanmelding geweigerd. Meld je af bij Xbox in Winkels, meld je opnieuw aan en hervat daarna.
De aanmeldpagina kon niet worden geladen: %1$s
Deze provider staat geen aanmelding via een ingesloten pagina toe. Meld je in plaats daarvan aan met je winkelwachtwoord.
De aanmeldpagina gaf een foutmelding (HTTP %1$d).
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index a135e012d7..5d539ce78e 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -287,9 +287,6 @@
„Auto” wstrzymuje i wznawia po powrocie. „Natywnie” najpierw przygotowuje Steam do uśpienia. „Ręcznie” czeka na „Wznów”. „Nigdy” nie przerywa działania.
Nie przerywaj pobierania
Opóźnia wstrzymanie w tle, gdy Steam aktywnie pobiera.
- Kompresja zRAM
- Gdy gra działa, pamięć klienta Steam jest kompresowana do zram urządzenia, więc gra ma więcej RAM-u. Zadziała przy następnym uruchomieniu Steam.
- Niedostępne: to urządzenie nie ma zram ani swapu, albo jądro jest starsze niż 5.4.
„Auto” wstrzymuje w tle i wznawia po powrocie. „Ręcznie” czeka na „Wznów”. „Nigdy” nie przerywa działania.
Uruchamianie
Uruchamiaj Steam z DroidDeck
@@ -548,8 +545,8 @@
Turnip: renderowanie sysmem
Szybsze dla klienta Steam; w grach sterownik dla każdego przebiegu wybiera renderowanie kafelkowe lub w pamięci systemowej. Wymagane na Adreno 710/720/722.
Pomijaj pomocnika xalia w Steam
- droiddeck-ntsync (eksperymentalne)
- Zastępnik sterownika Linux ntsync w przestrzeni użytkownika, do testów. Gdy jest włączony, Proton używa go zamiast droiddeck-esync i droiddeck-fsync. Zgodny z Proton Experimental ARM64, GE-Proton i proton-cachyos. Działa od następnej sesji.
+ droiddeck-ntsync
+ Zastępnik sterownika Linux ntsync w przestrzeni użytkownika. Gdy jest włączony, Proton używa go zamiast droiddeck-esync i droiddeck-fsync. Zgodny z Proton Experimental ARM64, GE-Proton i proton-cachyos. Działa od następnej sesji.
droiddeck-esync
Najpierw droiddeck-fsync
Uruchamia własny fsync Proton na standardowych plikach Proton, z futex_waitv dostarczanym w przestrzeni użytkownika, więc nie wymaga pakietu i działa od razu po aktualizacji Proton przez Steam. Gdy jest włączony, gry używają go przed droiddeck-esync, z wyjątkiem nielicznych, którym Proton wyłącza fsync. Działa od następnej sesji.
@@ -1432,6 +1429,10 @@
Czarne tło, biały tekst i niebieski dla wszystkiego, co zaznaczone, aktywne lub naciśnięte.
Elektryczny granat
Jaśniejszy niebieski na powierzchniach wpadających w granat zamiast w szarość.
+ Inner Gamer
+ Kolory przechodzące przez całą tęczę. Szanuje ustawienia animacji Androida.
+ Prędkość
+ Jak szybko zmieniają się kolory.
Gradient
Własny kolor podstawowy i dodatkowy, płynnie przechodzące na przyciskach i wyróżnieniach.
Podstawowy
@@ -1563,6 +1564,13 @@
Pomiń
Wybierz ten folder
Wstecz
+ Wyjdź
+ Wróć do folderu początkowego
+ Folder początkowy nie jest już dostępny
+ Anulować operację?
+ Operacja zostanie anulowana. Czy na pewno?
+ Akceptuj
+ Odrzuć
%1$s: zamontowano, ale obecnie nie można odczytać
Widok listy
Widok siatki
@@ -2038,6 +2046,23 @@
W pobranych plikach nie znaleziono gry na Windows
Nie można rozpakować pobranego pliku (kod %1$d)
itch.io nie odpowiedziało
+ Popularne
+ Najnowsze
+ Nowe i popularne
+ Płatne
+ Do 5 $
+ Do 15 $
+ Najwyżej oceniane
+ Najlepiej sprzedające się
+ Dowolna cena
+ Za darmo
+ Na wyprzedaży
+ Wczytaj więcej
+ Dowolna platforma
+ Web mobilny
+ Dodaj tag
+ Filtruj według tagu
+ Nie udało się wczytać gier z itch.io
Archiwa %1$s nie są obsługiwane
itch.io odpowiedziało HTTP %1$d
Bezpłatna
@@ -2195,6 +2220,7 @@
Zamknij
Spróbuj ponownie
Kończenie logowania…
+ Microsoft odrzucił logowanie do Xbox. Wyloguj się z Xbox w Sklepach, zaloguj się ponownie, a potem wznów.
Nie udało się wczytać strony logowania: %1$s
Ten dostawca odmawia logowania z osadzonej strony. Zaloguj się za pomocą hasła do sklepu.
Strona logowania odpowiedziała błędem (HTTP %1$d).
diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml
index b29e753e2d..af19c47e03 100644
--- a/app/src/main/res/values-pt-rPT/strings.xml
+++ b/app/src/main/res/values-pt-rPT/strings.xml
@@ -543,8 +543,8 @@
Turnip: renderização em sysmem
Mais rápido para o cliente Steam; nos jogos, o controlador escolhe em cada passagem entre renderização em mosaico ou na memória do sistema. Obrigatório no Adreno 710/720/722.
Ignorar o assistente xalia do Steam
- droiddeck-ntsync (experimental)
- Um substituto em espaço de utilizador para o controlador ntsync do Linux, para testes. Enquanto estiver ativado, o Proton utiliza-o em vez do droiddeck-esync e do droiddeck-fsync. Funciona com o Proton Experimental ARM64, o GE-Proton e o proton-cachyos. Aplica-se na próxima sessão.
+ droiddeck-ntsync
+ Um substituto em espaço de utilizador para o controlador ntsync do Linux. Enquanto estiver ativado, o Proton utiliza-o em vez do droiddeck-esync e do droiddeck-fsync. Funciona com o Proton Experimental ARM64, o GE-Proton e o proton-cachyos. Aplica-se na próxima sessão.
droiddeck-esync
droiddeck-fsync primeiro
Executa o fsync do próprio Proton sobre os ficheiros originais do Proton, com o futex_waitv fornecido em espaço de utilizador, por isso não precisa de pacote e continua a funcionar assim que o Steam atualiza o Proton. Enquanto estiver ativado, os jogos utilizam-no antes do droiddeck-esync, exceto os poucos que o Proton mantém fora do fsync. Aplica-se na próxima sessão.
@@ -1407,6 +1407,10 @@
Fundo preto, texto branco e o azul para tudo o que está selecionado, focado ou premido.
Azul-marinho elétrico
O azul mais vivo, em superfícies que tendem para o azul-marinho em vez do cinzento.
+ Inner Gamer
+ Cores que percorrem o arco-íris. Respeita as definições de animação do Android.
+ Velocidade
+ Com que rapidez as cores mudam.
Gradiente
As suas próprias cores primária e secundária, combinadas nos botões e destaques.
Primária
@@ -1533,6 +1537,13 @@
Ignorar
Selecionar esta pasta
Voltar
+ Sair
+ Voltar à pasta inicial
+ A pasta inicial já não está disponível
+ Cancelar operação?
+ A operação será cancelada. Tem a certeza?
+ Aceitar
+ Recusar
%1$s está montado, mas não é possível lê-lo de momento
Vista de lista
Vista de grelha
@@ -2006,6 +2017,23 @@
Não foi encontrado nenhum jogo para Windows na transferência
Não foi possível extrair a transferência (código %1$d)
O itch.io não respondeu
+ Populares
+ Mais recentes
+ Novos e populares
+ Pagos
+ 5 $ ou menos
+ 15 $ ou menos
+ Mais bem avaliados
+ Mais vendidos
+ Qualquer preço
+ Grátis
+ Em promoção
+ Carregar mais
+ Qualquer plataforma
+ Web móvel
+ Adicionar uma etiqueta
+ Filtrar por etiqueta
+ Não foi possível carregar os jogos do itch.io
Ficheiros %1$s não são suportados
O itch.io respondeu HTTP %1$d
Grátis
@@ -2157,6 +2185,7 @@
Fechar
Tentar novamente
A concluir o início de sessão…
+ A Microsoft recusou o início de sessão da Xbox. Termine a sessão da Xbox em Lojas, inicie sessão novamente e retome.
Não foi possível carregar a página de início de sessão: %1$s
Este fornecedor recusa o início de sessão a partir de uma página incorporada. Inicie sessão com a palavra-passe da loja.
A página de início de sessão respondeu com um erro (HTTP %1$d).
@@ -2562,9 +2591,6 @@
Repor
Repor também os perfis de jogo (Proton, FEX, componentes e ambiente de cada jogo e o ambiente do perfil Padrão)
Termine a sessão antes de repor as definições.
- Compressão zRAM
- Indisponível: este dispositivo não tem swap ativo ou o kernel é anterior à versão 5.4.
- Enquanto um jogo está a correr, a memória do cliente Steam é comprimida na zram do dispositivo, deixando mais RAM para o jogo. Aplica-se a partir da próxima vez que o Steam iniciar.
Espaço insuficiente (%1$s livres, são necessários %2$s)
Espaço livre insuficiente: são necessários %1$s, só há %2$s livres
Espaço livre desconhecido
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 79239e0c5a..810cb1ab12 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -543,8 +543,8 @@
Turnip: renderização sysmem
Mais rápido para o cliente da Steam; nos jogos, o driver escolhe a cada passagem entre renderização em blocos ou na memória do sistema. Obrigatório nas Adreno 710/720/722.
Pular o assistente xalia da Steam
- droiddeck-ntsync (experimental)
- Um substituto em espaço de usuário para o driver ntsync do Linux, para testes. Enquanto estiver ativado, o Proton o usa no lugar do droiddeck-esync e do droiddeck-fsync. Funciona com o Proton Experimental ARM64, o GE-Proton e o proton-cachyos. Vale a partir da próxima sessão.
+ droiddeck-ntsync
+ Um substituto em espaço de usuário para o driver ntsync do Linux. Enquanto estiver ativado, o Proton o usa no lugar do droiddeck-esync e do droiddeck-fsync. Funciona com o Proton Experimental ARM64, o GE-Proton e o proton-cachyos. Vale a partir da próxima sessão.
droiddeck-esync
droiddeck-fsync primeiro
Roda o fsync do próprio Proton nos arquivos originais do Proton, com o futex_waitv fornecido em espaço de usuário, então não precisa de pacote e continua funcionando assim que a Steam atualiza o Proton. Enquanto estiver ativado, os jogos o usam antes do droiddeck-esync, exceto os poucos que o Proton mantém fora do fsync. Vale a partir da próxima sessão.
@@ -1407,6 +1407,10 @@
Fundo preto, texto branco e o azul em tudo que estiver selecionado, em foco ou pressionado.
Marinho elétrico
O azul mais vivo, sobre superfícies puxadas para o marinho em vez do cinza.
+ Inner Gamer
+ Cores que percorrem o arco-íris. Respeita as configurações de animação do Android.
+ Velocidade
+ Com que rapidez as cores mudam.
Gradiente
Suas próprias cores primária e secundária, combinadas em botões e destaques.
Primária
@@ -1533,6 +1537,13 @@
Pular
Selecionar esta pasta
Voltar
+ Sair
+ Voltar à pasta inicial
+ A pasta inicial não está mais disponível
+ Cancelar operação?
+ A operação será cancelada. Tem certeza?
+ Aceitar
+ Recusar
%1$s está montado, mas não pode ser lido agora
Visualização em lista
Visualização em grade
@@ -2006,6 +2017,23 @@
Nenhum jogo para Windows encontrado no download
Não foi possível extrair o download (código %1$d)
O itch.io não respondeu
+ Populares
+ Mais recentes
+ Novos e populares
+ Pagos
+ US$ 5 ou menos
+ US$ 15 ou menos
+ Mais bem avaliados
+ Mais vendidos
+ Qualquer preço
+ Grátis
+ Em promoção
+ Carregar mais
+ Qualquer plataforma
+ Web mobile
+ Adicionar uma tag
+ Filtrar por tag
+ Não foi possível carregar os jogos do itch.io
Arquivos %1$s não são suportados
O itch.io respondeu HTTP %1$d
Grátis
@@ -2157,6 +2185,7 @@
Fechar
Tentar de novo
Concluindo o login…
+ A Microsoft recusou o login do Xbox. Saia do Xbox em Lojas, entre novamente e depois retome.
Não foi possível carregar a página de login: %1$s
Este provedor não permite login a partir de uma página incorporada. Faça login com a senha da loja.
A página de login respondeu com um erro (HTTP %1$d).
@@ -2554,9 +2583,6 @@
Completista
%1$s h
%1$d min
- Compressão zRAM
- Enquanto um jogo roda, a memória do cliente Steam é comprimida na zram do dispositivo, deixando mais RAM para o jogo. Vale a partir da próxima vez que a Steam iniciar.
- Indisponível: este dispositivo não tem swap ativo, ou o kernel é anterior à versão 5.4.
Redefinir todas as configurações
Redefinir todas as configurações?
As configurações de tela, desempenho, controle, tema, idioma e inicializador voltam ao padrão. Seus jogos, o login da Steam, as contas das lojas, os drivers baixados e as pastas de armazenamento são mantidos.
diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml
index c0736cfe0c..bded086b4f 100644
--- a/app/src/main/res/values-ro/strings.xml
+++ b/app/src/main/res/values-ro/strings.xml
@@ -287,9 +287,6 @@
Automat pune pe pauză și reia atunci când este afișată. Nativ pregătește Steam pentru repaus mai întâi. Manual așteaptă Reluare. Niciodată continuă să ruleze.
Continuă descărcările
Întârzie suspendarea în fundal cât timp Steam descarcă activ.
- Compresie zRAM
- În timpul jocului, memoria clientului Steam este comprimată în zram-ul dispozitivului, astfel încât jocul primește mai mult RAM. Se aplică la următoarea pornire a Steam.
- Indisponibil: dispozitivul nu are zram sau swap, ori kernelul e mai vechi decât 5.4.
Automat pune pe pauză în fundal și reia atunci când este afișată. Manual așteaptă Reluare. Niciodată continuă să ruleze.
Pornire
Pornește Steam odată cu DroidDeck
@@ -546,8 +543,8 @@
Turnip: randare sysmem
Mai rapidă pentru clientul Steam; în jocuri, driverul alege la fiecare trecere între randarea pe dale și cea în memoria sistemului. Necesară pe Adreno 710/720/722.
Omite asistentul xalia al Steam
- droiddeck-ntsync (experimental)
- Un substitut la nivel de utilizator pentru driverul Linux ntsync, pentru testare. Cât timp este activ, Proton îl folosește în locul droiddeck-esync și droiddeck-fsync. Funcționează cu Proton Experimental ARM64, GE-Proton și proton-cachyos. Se aplică la sesiunea următoare.
+ droiddeck-ntsync
+ Un substitut la nivel de utilizator pentru driverul Linux ntsync. Cât timp este activ, Proton îl folosește în locul droiddeck-esync și droiddeck-fsync. Funcționează cu Proton Experimental ARM64, GE-Proton și proton-cachyos. Se aplică la sesiunea următoare.
droiddeck-esync
droiddeck-fsync primul
Rulează propriul fsync al Proton pe fișierele Proton standard, cu futex_waitv furnizat la nivel de utilizator, deci nu are nevoie de pachet și continuă să funcționeze imediat ce Steam actualizează Proton. Cât timp este activ, jocurile îl folosesc înaintea droiddeck-esync, cu excepția celor puține pe care Proton le ține în afara fsync. Se aplică la sesiunea următoare.
@@ -1418,6 +1415,10 @@
Fundal negru, text alb, albastrul pentru tot ce este selectat, focalizat sau apăsat.
Bleumarin electric
Albastrul mai strălucitor, pe suprafețe care tind spre bleumarin în loc de gri.
+ Inner Gamer
+ Culori care parcurg curcubeul. Respectă setările de animație din Android.
+ Viteză
+ Cât de repede se schimbă culorile.
Gradient
Culorile tale primară și secundară, combinate pe butoane și evidențieri.
Primară
@@ -1544,6 +1545,13 @@
Omite
Selectează acest folder
Înapoi
+ Ieșire
+ Înapoi la dosarul inițial
+ Dosarul inițial nu mai este disponibil
+ Anulați operația?
+ Operația va fi anulată. Sunteți sigur?
+ Acceptă
+ Refuză
%1$s este montat, dar nu poate fi citit acum
Vizualizare listă
Vizualizare grilă
@@ -2017,6 +2025,23 @@
Nu s-a găsit niciun joc Windows în descărcare
Descărcarea nu a putut fi extrasă (cod %1$d)
itch.io nu a răspuns
+ Populare
+ Cele mai recente
+ Noi și populare
+ Cu plată
+ 5 $ sau mai puțin
+ 15 $ sau mai puțin
+ Cele mai bine cotate
+ Cele mai vândute
+ Orice preț
+ Gratuite
+ La reducere
+ Încarcă mai multe
+ Orice platformă
+ Web mobil
+ Adaugă o etichetă
+ Filtrează după etichetă
+ Nu s-au putut încărca jocurile de pe itch.io
Arhivele %1$s nu sunt acceptate
itch.io a răspuns HTTP %1$d
Gratuit
@@ -2171,6 +2196,7 @@
Închide
Încearcă din nou
Se finalizează autentificarea…
+ Microsoft a respins conectarea la Xbox. Deconectează-te de la Xbox în Magazine, conectează-te din nou, apoi reia.
Pagina de autentificare nu a putut fi încărcată: %1$s
Acest furnizor refuză autentificarea dintr-o pagină încorporată. Autentifică-te cu parola magazinului în schimb.
Pagina de autentificare a răspuns cu o eroare (HTTP %1$d).
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 2018816c1f..21b6ee6723 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -547,8 +547,8 @@
Turnip: рендеринг sysmem
Клиент Steam будет быстрее; в играх драйвер для каждого прохода выбирает тайловый рендеринг или рендеринг в системной памяти. Требуется для Adreno 710/720/722.
Пропустить помощник xalia в Steam
- droiddeck-ntsync (экспериментально)
- Замена драйвера ntsync Linux в пространстве пользователя, для тестирования. Пока включено, Proton использует ее вместо droiddeck-esync и droiddeck-fsync. Работает с Proton Experimental ARM64, GE-Proton и proton-cachyos. Вступит в силу в следующей сессии.
+ droiddeck-ntsync
+ Замена драйвера ntsync Linux в пространстве пользователя. Пока включено, Proton использует ее вместо droiddeck-esync и droiddeck-fsync. Работает с Proton Experimental ARM64, GE-Proton и proton-cachyos. Вступит в силу в следующей сессии.
droiddeck-esync
droiddeck-fsync в приоритете
Запускает собственный fsync Proton на стандартных файлах Proton, а futex_waitv предоставляется в пространстве пользователя: пакет не нужен, и все продолжает работать сразу после обновления Proton в Steam. Пока включено, игры используют его раньше droiddeck-esync, кроме тех немногих, для которых Proton отключает fsync. Вступит в силу в следующей сессии.
@@ -1431,6 +1431,10 @@
Черный фон, белый текст, синий — для всего выбранного, активного или нажатого.
Электрик
Более яркий синий на поверхностях темно-синего, а не серого оттенка.
+ Inner Gamer
+ Цвета, плавно переходящие по всей радуге. Учитывает настройки анимации Android.
+ Скорость
+ Как быстро меняются цвета.
Градиент
Ваши основной и дополнительный цвета, плавно переходящие на кнопках и выделениях.
Основной
@@ -1562,6 +1566,13 @@
Пропустить
Выбрать эту папку
Назад
+ Выход
+ Вернуться в начальную папку
+ Начальная папка больше недоступна
+ Отменить операцию?
+ Операция будет отменена. Вы уверены?
+ Принять
+ Отклонить
%1$s: подключено, но сейчас недоступно для чтения
Список
Сетка
@@ -2037,6 +2048,23 @@
В загрузке не найдена игра для Windows
Не удалось распаковать загрузку (код %1$d)
itch.io не ответил
+ Популярные
+ Самые новые
+ Новые и популярные
+ Платные
+ До $5
+ До $15
+ С лучшими оценками
+ Бестселлеры
+ Любая цена
+ Бесплатные
+ Со скидкой
+ Загрузить ещё
+ Любая платформа
+ Мобильный веб
+ Добавить тег
+ Фильтр по тегу
+ Не удалось загрузить игры с itch.io
Архивы %1$s не поддерживаются
itch.io ответил HTTP %1$d
Бесплатно
@@ -2188,6 +2216,7 @@
Закрыть
Повторить
Завершение входа…
+ Microsoft отклонила вход в Xbox. Выйдите из Xbox в разделе «Магазины», войдите снова и продолжите.
Не удалось загрузить страницу входа: %1$s
Этот сервис не разрешает вход со встроенной страницы. Войдите с паролем от магазина.
Страница входа вернула ошибку (HTTP %1$d).
@@ -2589,9 +2618,6 @@
Скачать компоненты
Загрузки общие со страницей «Компоненты». Выберите выше скачанную версию, чтобы использовать её при следующем запуске игры.
Выберите версию для скачивания
- Сжатие zRAM
- Пока идёт игра, память клиента Steam сжимается в zram устройства, и игре остаётся больше ОЗУ. Применяется при следующем запуске Steam.
- Недоступно: на устройстве нет zram или swap, либо его ядро старше 5.4.
Недостаточно свободного места: нужно %1$s, свободно только %2$s
Недостаточно места (свободно %1$s, нужно %2$s)
Свободное место неизвестно
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 1da71dc1cb..970c2f790f 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -287,9 +287,6 @@
Auto pausar och återupptar när den visas. Inbyggd förbereder Steam för vila först. Manuell väntar på Återuppta. Aldrig fortsätter köra.
Håll nedladdningar igång
Skjut upp bakgrundspausning medan Steam aktivt laddar ned.
- zRAM-komprimering
- Medan ett spel körs komprimeras Steam-klientens minne till enhetens zram så att spelet får mer RAM. Gäller nästa gång Steam startar.
- Inte tillgängligt: enheten har ingen zram eller swap, eller så är kärnan äldre än 5.4.
Auto pausar i bakgrunden och återupptar när den visas. Manuell väntar på Återuppta. Aldrig fortsätter köra.
Uppstart
Starta Steam med DroidDeck
@@ -544,8 +541,8 @@
Turnip: sysmem-rendering
Snabbare för Steam-klienten; i spel väljer drivrutinen kakel- eller systemminnesrendering för varje pass. Krävs på Adreno 710/720/722.
Hoppa över Steams xalia-hjälp
- droiddeck-ntsync (experimentell)
- En ersättning i användarutrymmet för Linux ntsync-drivrutinen, för testning. Medan det är på använder Proton det i stället för droiddeck-esync och droiddeck-fsync. Fungerar med Proton Experimental ARM64, GE-Proton och proton-cachyos. Gäller från nästa session.
+ droiddeck-ntsync
+ En ersättning i användarutrymmet för Linux ntsync-drivrutinen. Medan det är på använder Proton det i stället för droiddeck-esync och droiddeck-fsync. Fungerar med Proton Experimental ARM64, GE-Proton och proton-cachyos. Gäller från nästa session.
droiddeck-esync
droiddeck-fsync först
Kör Protons egen fsync på de ursprungliga Proton-filerna, med futex_waitv tillhandahållen i användarutrymmet, så det behöver inget paket och fortsätter fungera så snart Steam uppdaterar Proton. Medan det är på använder spel det före droiddeck-esync, förutom de få som Proton håller borta från fsync. Gäller från nästa session.
@@ -1404,6 +1401,10 @@
Svart bakgrund, vit text, den blå färgen för allt som är markerat, i fokus eller nedtryckt.
Elektrisk marinblå
Den blå färgen klarare, på ytor som lutar åt marinblått i stället för grått.
+ Inner Gamer
+ Färger som växlar genom regnbågen. Följer Androids animationsinställningar.
+ Hastighet
+ Hur snabbt färgerna växlar.
Gradient
Dina egna primära och sekundära färger, blandade på knappar och markeringar.
Primär
@@ -1525,6 +1526,13 @@
Hoppa över
Välj den här mappen
Tillbaka
+ Avsluta
+ Tillbaka till startmappen
+ Startmappen är inte längre tillgänglig
+ Avbryt åtgärden?
+ Åtgärden avbryts. Är du säker?
+ Acceptera
+ Avböj
%1$s är monterad men inte läsbar just nu
Listvy
Rutnätsvy
@@ -1996,6 +2004,23 @@
Inget Windows-spel hittades i nedladdningen
Det gick inte att packa upp nedladdningen (kod %1$d)
itch.io svarade inte
+ Populära
+ Senaste
+ Nya och populära
+ Betalda
+ $5 eller mindre
+ $15 eller mindre
+ Högst betyg
+ Mest sålda
+ Alla priser
+ Gratis
+ På rea
+ Ladda fler
+ Alla plattformar
+ Mobilwebb
+ Lägg till en tagg
+ Filtrera efter tagg
+ Det gick inte att läsa in spel från itch.io
%1$s-arkiv stöds inte
itch.io svarade HTTP %1$d
Gratis
@@ -2150,6 +2175,7 @@
Stäng
Försök igen
Slutför inloggningen…
+ Microsoft avvisade Xbox-inloggningen. Logga ut från Xbox under Butiker, logga in igen och återuppta sedan.
Inloggningssidan kunde inte läsas in: %1$s
Den här leverantören vägrar logga in från en inbäddad sida. Logga in med ditt butikslösenord istället.
Inloggningssidan svarade med ett fel (HTTP %1$d).
diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml
index 75dc4f5726..c222677191 100644
--- a/app/src/main/res/values-th/strings.xml
+++ b/app/src/main/res/values-th/strings.xml
@@ -287,9 +287,6 @@
อัตโนมัติจะหยุดชั่วคราวและดำเนินการต่อเมื่อแสดงผล ดั้งเดิมเตรียม Steam เข้าสู่โหมดพักก่อน กำหนดเองรอการกดดำเนินการต่อ ไม่มีวันทำงานต่อเนื่องตลอด
ให้การดาวน์โหลดทำงานต่อไป
เลื่อนการหยุดพื้นหลังชั่วคราวออกไปขณะ Steam กำลังดาวน์โหลดอยู่
- การบีบอัด zRAM
- ระหว่างเล่นเกม หน่วยความจำของไคลเอนต์ Steam จะถูกบีบอัดลง zram ของอุปกรณ์ ทำให้เกมได้ RAM มากขึ้น มีผลเมื่อเริ่ม Steam ครั้งถัดไป
- ใช้ไม่ได้: อุปกรณ์นี้ไม่มี zram หรือ swap หรือเคอร์เนลเก่ากว่า 5.4
อัตโนมัติจะหยุดชั่วคราวเมื่ออยู่ในพื้นหลังและดำเนินการต่อเมื่อแสดงผล กำหนดเองรอการกดดำเนินการต่อ ไม่มีวันทำงานต่อเนื่องตลอด
การเริ่มทำงาน
เริ่ม Steam พร้อมกับ DroidDeck
@@ -542,8 +539,8 @@
Turnip: การเรนเดอร์ sysmem
เร็วขึ้นสำหรับไคลเอนต์ Steam ในเกมไดรเวอร์จะเลือกการเรนเดอร์แบบไทล์หรือในหน่วยความจำระบบในแต่ละพาส จำเป็นสำหรับ Adreno 710/720/722
ข้ามตัวช่วย xalia ของ Steam
- droiddeck-ntsync (ทดลอง)
- ตัวแทนในระดับยูสเซอร์สเปซของไดรเวอร์ ntsync ของ Linux สำหรับการทดสอบ เมื่อเปิดใช้ Proton จะใช้สิ่งนี้แทน droiddeck-esync และ droiddeck-fsync ใช้ได้กับ Proton Experimental ARM64, GE-Proton และ proton-cachyos จะมีผลในเซสชันถัดไป
+ droiddeck-ntsync
+ ตัวแทนในระดับยูสเซอร์สเปซของไดรเวอร์ ntsync ของ Linux เมื่อเปิดใช้ Proton จะใช้สิ่งนี้แทน droiddeck-esync และ droiddeck-fsync ใช้ได้กับ Proton Experimental ARM64, GE-Proton และ proton-cachyos จะมีผลในเซสชันถัดไป
droiddeck-esync
droiddeck-fsync ก่อน
รัน fsync ของ Proton เองบนไฟล์ Proton มาตรฐาน โดยมี futex_waitv ที่จัดเตรียมในระดับยูสเซอร์สเปซ จึงไม่ต้องใช้แพ็กและยังคงทำงานได้ทันทีที่ Steam อัปเดต Proton เมื่อเปิดใช้ เกมจะใช้สิ่งนี้ก่อน droiddeck-esync ยกเว้นบางส่วนที่ Proton ปิด fsync ไว้ จะมีผลในเซสชันถัดไป
@@ -1390,6 +1387,10 @@
พื้นดำ ตัวอักษรขาว สีฟ้าสำหรับทุกสิ่งที่ถูกเลือก โฟกัส หรือกด
กรมท่าไฟฟ้า
สีฟ้าสว่างขึ้น บนพื้นผิวที่เอียงไปทางกรมท่ามากกว่าเทา
+ Inner Gamer
+ สีที่เปลี่ยนวนไปตามสายรุ้ง ทำงานตามการตั้งค่าแอนิเมชันของ Android
+ ความเร็ว
+ สีเปลี่ยนเร็วแค่ไหน
ไล่เฉดสี
สีหลักและสีรองที่คุณเลือกเอง ผสมกันบนปุ่มและส่วนที่เน้น
สีหลัก
@@ -1506,6 +1507,13 @@
ข้าม
เลือกโฟลเดอร์นี้
กลับ
+ ออก
+ กลับไปยังโฟลเดอร์เริ่มต้น
+ โฟลเดอร์เริ่มต้นไม่พร้อมใช้งานแล้ว
+ ยกเลิกการดำเนินการ?
+ การดำเนินการจะถูกยกเลิก คุณแน่ใจหรือไม่?
+ ยอมรับ
+ ปฏิเสธ
%1$s ติดตั้งอยู่แต่อ่านไม่ได้ในขณะนี้
มุมมองรายการ
มุมมองตาราง
@@ -1975,6 +1983,23 @@
ไม่พบเกม Windows ในไฟล์ที่ดาวน์โหลด
แตกไฟล์ที่ดาวน์โหลดไม่ได้ (รหัส %1$d)
itch.io ไม่ตอบสนอง
+ ยอดนิยม
+ ล่าสุด
+ ใหม่และยอดนิยม
+ เสียเงิน
+ ไม่เกิน $5
+ ไม่เกิน $15
+ คะแนนสูงสุด
+ ขายดี
+ ทุกราคา
+ ฟรี
+ ลดราคา
+ โหลดเพิ่มเติม
+ ทุกแพลตฟอร์ม
+ เว็บมือถือ
+ เพิ่มแท็ก
+ กรองตามแท็ก
+ โหลดเกมจาก itch.io ไม่ได้
ไม่รองรับไฟล์ %1$s
itch.io ตอบกลับ HTTP %1$d
ฟรี
@@ -2129,6 +2154,7 @@
ปิด
ลองใหม่
กำลังเสร็จสิ้นการลงชื่อเข้าใช้…
+ Microsoft ปฏิเสธการลงชื่อเข้าใช้ Xbox ลงชื่อออกจาก Xbox ในสโตร์ ลงชื่อเข้าใช้อีกครั้ง แล้วดำเนินการต่อ
ไม่สามารถโหลดหน้าลงชื่อเข้าใช้ได้: %1$s
ผู้ให้บริการนี้ปฏิเสธการลงชื่อเข้าใช้จากหน้าที่ฝังอยู่ ให้ลงชื่อเข้าใช้ด้วยรหัสผ่านของสโตร์แทน
หน้าลงชื่อเข้าใช้ตอบกลับด้วยข้อผิดพลาด (HTTP %1$d)
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index da288eb3ee..e992ce67df 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -541,8 +541,8 @@
Turnip: sysmem işleme
Steam istemcisi için daha hızlı; oyunlarda sürücü her geçişte döşeme tabanlı veya sistem belleğinde işlemeyi seçer. Adreno 710/720/722\'de gereklidir.
Steam\'in xalia yardımcısını atla
- droiddeck-ntsync (deneysel)
- Linux ntsync sürücüsünün test amaçlı, kullanıcı alanında çalışan bir yedeği. Açıkken Proton, droiddeck-esync ve droiddeck-fsync yerine bunu kullanır. Proton Experimental ARM64, GE-Proton ve proton-cachyos ile çalışır. Sonraki oturumda uygulanır.
+ droiddeck-ntsync
+ Linux ntsync sürücüsünün kullanıcı alanında çalışan bir yedeği. Açıkken Proton, droiddeck-esync ve droiddeck-fsync yerine bunu kullanır. Proton Experimental ARM64, GE-Proton ve proton-cachyos ile çalışır. Sonraki oturumda uygulanır.
droiddeck-esync
Önce droiddeck-fsync
Proton\'un kendi fsync\'ini standart Proton dosyalarıyla, futex_waitv kullanıcı alanında sağlanarak çalıştırır; bu yüzden paket gerektirmez ve Steam Proton\'u güncellediği anda da çalışmaya devam eder. Açıkken oyunlar, Proton\'un fsync dışında tuttuğu birkaç oyun hariç, bunu droiddeck-esync\'ten önce kullanır. Sonraki oturumda uygulanır.
@@ -1395,6 +1395,10 @@
Siyah zemin, beyaz yazı; seçilen, odaklanan veya basılan her şey için mavi.
Elektrik laciverti
Daha parlak mavi; gri yerine laciverte çalan yüzeylerde.
+ Inner Gamer
+ Gökkuşağında dolaşan renkler. Android\'in animasyon ayarlarına uyar.
+ Hız
+ Renklerin ne kadar hızlı değiştiği.
Geçiş
Kendi birincil ve ikincil renklerin, düğmelerde ve vurgularda harmanlanır.
Birincil
@@ -1516,6 +1520,13 @@
Atla
Bu klasörü seç
Geri
+ Çıkış
+ Başlangıç klasörüne dön
+ Başlangıç klasörü artık kullanılamıyor
+ İşlem iptal edilsin mi?
+ İşlem iptal edilecek. Emin misiniz?
+ Kabul et
+ Reddet
%1$s bağlı ancak şu anda okunamıyor
Liste görünümü
Izgara görünümü
@@ -1987,6 +1998,23 @@
İndirmede Windows oyunu bulunamadı
İndirme ayıklanamadı (kod %1$d)
itch.io yanıt vermedi
+ Popüler
+ En yeniler
+ Yeni ve popüler
+ Ücretli
+ $5 veya altı
+ $15 veya altı
+ En yüksek puanlı
+ En çok satanlar
+ Herhangi bir fiyat
+ Ücretsiz
+ İndirimde
+ Daha fazla yükle
+ Herhangi bir platform
+ Mobil web
+ Etiket ekle
+ Etikete göre filtrele
+ itch.io oyunları yüklenemedi
%1$s arşivleri desteklenmiyor
itch.io HTTP %1$d yanıtı verdi
Ücretsiz
@@ -2138,6 +2166,7 @@
Kapat
Yeniden dene
Oturum açma tamamlanıyor…
+ Microsoft, Xbox oturum açmayı reddetti. Mağazalar\'da Xbox oturumunu kapatın, yeniden oturum açın ve devam edin.
Oturum açma sayfası yüklenemedi: %1$s
Bu sağlayıcı yerleşik bir sayfadan oturum açmayı reddediyor. Bunun yerine mağaza parolanızla oturum açın.
Oturum açma sayfası bir hatayla yanıt verdi (HTTP %1$d).
@@ -2531,9 +2560,6 @@
Tamamlayıcı
%1$s sa
%1$d dk
- zRAM sıkıştırma
- Bir oyun çalışırken Steam istemcisinin belleği cihazın zram\'ına sıkıştırılır ve oyuna daha fazla RAM kalır. Steam\'in bir sonraki başlatılışında uygulanır.
- Kullanılamıyor: bu cihazda zram veya swap yok ya da çekirdeği 5.4\'ten eski.
Tüm ayarları sıfırla
Tüm ayarlar sıfırlansın mı?
Ekran, performans, denetleyici, tema, dil ve başlatıcı ayarları varsayılanlarına döner. Oyunlarınız, Steam oturum bilgileriniz, mağaza hesaplarınız, indirilen sürücüler ve depolama klasörleriniz korunur.
diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml
index 002514a82a..d2de6b7869 100644
--- a/app/src/main/res/values-uk/strings.xml
+++ b/app/src/main/res/values-uk/strings.xml
@@ -287,9 +287,6 @@
«Авто» призупиняє сеанс і відновлює його, коли додаток знову на екрані. «Нативний» спершу готує Steam до сну. «Вручну» чекає на «Відновити». «Ніколи» — сеанс працює далі.
Не переривати завантаження
Відкладає призупинення у фоні, поки Steam активно щось завантажує.
- Стиснення zRAM
- Під час гри пам\'ять клієнта Steam стискається в zram пристрою, тож гра отримує більше RAM. Застосується під час наступного запуску Steam.
- Недоступно: на пристрої немає zram або swap, чи ядро старіше за 5.4.
«Авто» призупиняє сеанс у фоні й відновлює, коли додаток знову на екрані. «Вручну» чекає на «Відновити». «Ніколи» — сеанс працює далі.
Запуск
Запускати Steam разом із DroidDeck
@@ -548,8 +545,8 @@
Turnip: рендеринг через sysmem
Швидше для клієнта Steam; в іграх драйвер для кожного проходу вибирає тайловий рендеринг або рендеринг у системній пам’яті. Потрібно для Adreno 710/720/722.
Пропускати помічник Steam xalia
- droiddeck-ntsync (експериментально)
- Програмна заміна драйвера ntsync ядра Linux у просторі користувача, для тестування. Поки це увімкнено, Proton використовує її замість droiddeck-esync і droiddeck-fsync. Працює з Proton Experimental ARM64, GE-Proton і proton-cachyos. Застосовується в наступному сеансі.
+ droiddeck-ntsync
+ Програмна заміна драйвера ntsync ядра Linux у просторі користувача. Поки це увімкнено, Proton використовує її замість droiddeck-esync і droiddeck-fsync. Працює з Proton Experimental ARM64, GE-Proton і proton-cachyos. Застосовується в наступному сеансі.
droiddeck-esync
droiddeck-fsync першим
Запускає власний fsync Proton на стандартних файлах Proton, а futex_waitv надається в просторі користувача, тому не потрібен пакет і все працює відразу після оновлення Proton у Steam. Поки це увімкнено, ігри використовують його раніше за droiddeck-esync, окрім кількох, де Proton тримає fsync вимкненим. Застосовується в наступному сеансі.
@@ -1432,6 +1429,10 @@
Чорне тло, білий текст і синій для всього вибраного, у фокусі чи натиснутого.
Електричний темно-синій
Яскравіший синій на поверхнях із темно-синім відтінком замість сірого.
+ Inner Gamer
+ Кольори, що плавно змінюються по всій веселці. Враховує налаштування анімації Android.
+ Швидкість
+ Як швидко змінюються кольори.
Градієнт
Ваші основний і додатковий кольори, що плавно переходять на кнопках і виділеннях.
Основний
@@ -1563,6 +1564,13 @@
Пропустити
Вибрати цю папку
Назад
+ Вийти
+ Повернутися до початкової папки
+ Початкова папка більше недоступна
+ Скасувати операцію?
+ Операцію буде скасовано. Ви впевнені?
+ Прийняти
+ Відхилити
%1$s: підключено, але читання зараз недоступне
Список
Сітка
@@ -2038,6 +2046,23 @@
У завантаженні не знайдено гри для Windows
Не вдалося розпакувати завантаження (код %1$d)
itch.io не відповів
+ Популярні
+ Найновіші
+ Нові й популярні
+ Платні
+ До $5
+ До $15
+ З найвищими оцінками
+ Бестселери
+ Будь-яка ціна
+ Безкоштовні
+ Зі знижкою
+ Завантажити ще
+ Будь-яка платформа
+ Мобільний веб
+ Додати тег
+ Фільтр за тегом
+ Не вдалося завантажити ігри з itch.io
Архіви %1$s не підтримуються
itch.io відповів HTTP %1$d
Безкоштовно
@@ -2192,6 +2217,7 @@
Закрити
Спробувати ще раз
Завершення входу…
+ Microsoft відхилила вхід у Xbox. Вийдіть з Xbox у розділі «Магазини», увійдіть знову й продовжте.
Не вдалося завантажити сторінку входу: %1$s
Цей провайдер не дозволяє вхід із вбудованої сторінки. Увійдіть за допомогою пароля магазину.
Сторінка входу відповіла помилкою (HTTP %1$d).
diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml
index 14e1ffd7e4..57cca067a6 100644
--- a/app/src/main/res/values-vi/strings.xml
+++ b/app/src/main/res/values-vi/strings.xml
@@ -287,9 +287,6 @@
Tự động tạm dừng và tiếp tục khi được hiển thị lại. Gốc chuẩn bị Steam để ngủ trước. Thủ công chờ nhấn Tiếp tục. Không bao giờ giữ nó luôn chạy.
Giữ tải xuống tiếp tục chạy
Trì hoãn tạm dừng nền khi Steam đang tải xuống.
- Nén zRAM
- Khi chơi, bộ nhớ của ứng dụng Steam được nén vào zram của thiết bị để game có thêm RAM. Áp dụng từ lần khởi động Steam tiếp theo.
- Không khả dụng: thiết bị không có zram hoặc swap, hoặc nhân cũ hơn 5.4.
Tự động tạm dừng ở nền và tiếp tục khi hiển thị lại. Thủ công chờ nhấn Tiếp tục. Không bao giờ giữ nó luôn chạy.
Khởi động
Khởi động Steam cùng DroidDeck
@@ -542,8 +539,8 @@
Turnip: render sysmem
Nhanh hơn cho ứng dụng Steam; trong game, trình điều khiển chọn kết xuất theo ô hoặc trong bộ nhớ hệ thống cho từng lượt. Bắt buộc trên Adreno 710/720/722.
Bỏ qua trình trợ giúp xalia của Steam
- droiddeck-ntsync (thử nghiệm)
- Một bản thay thế ở không gian người dùng cho driver ntsync của Linux, dùng để thử nghiệm. Khi đang bật, Proton dùng nó thay cho droiddeck-esync và droiddeck-fsync. Hoạt động với Proton Experimental ARM64, GE-Proton và proton-cachyos. Áp dụng từ phiên sau.
+ droiddeck-ntsync
+ Một bản thay thế ở không gian người dùng cho driver ntsync của Linux. Khi đang bật, Proton dùng nó thay cho droiddeck-esync và droiddeck-fsync. Hoạt động với Proton Experimental ARM64, GE-Proton và proton-cachyos. Áp dụng từ phiên sau.
droiddeck-esync
droiddeck-fsync trước
Chạy fsync riêng của Proton trên các tệp Proton gốc, với futex_waitv được cung cấp ở không gian người dùng, nên không cần pack và vẫn hoạt động ngay khi Steam cập nhật Proton. Khi đang bật, game dùng nó trước droiddeck-esync, trừ một số ít Proton giữ fsync tắt. Áp dụng từ phiên sau.
@@ -1390,6 +1387,10 @@
Nền đen, chữ trắng, xanh cho mọi thứ được chọn, lấy nét hoặc nhấn.
Xanh điện navy
Màu xanh sáng hơn, trên các bề mặt nghiêng về navy thay vì xám.
+ Inner Gamer
+ Màu sắc chuyển dần qua cả dải cầu vồng. Tuân theo cài đặt hiệu ứng động của Android.
+ Tốc độ
+ Màu đổi nhanh đến mức nào.
Chuyển màu
Màu chính và màu phụ do bạn chọn, hòa trộn trên các nút và phần nổi bật.
Chính
@@ -1506,6 +1507,13 @@
Bỏ qua
Chọn thư mục này
Quay lại
+ Thoát
+ Quay lại thư mục ban đầu
+ Thư mục ban đầu không còn khả dụng
+ Hủy thao tác?
+ Thao tác sẽ bị hủy. Bạn có chắc không?
+ Chấp nhận
+ Từ chối
%1$s đã được gắn nhưng hiện không đọc được
Xem dạng danh sách
Xem dạng lưới
@@ -1975,6 +1983,23 @@
Không tìm thấy trò chơi Windows trong bản tải xuống
Không thể giải nén bản tải xuống (mã %1$d)
itch.io không phản hồi
+ Phổ biến
+ Mới nhất
+ Mới và phổ biến
+ Trả phí
+ Từ $5 trở xuống
+ Từ $15 trở xuống
+ Đánh giá cao nhất
+ Bán chạy nhất
+ Mọi mức giá
+ Miễn phí
+ Đang giảm giá
+ Tải thêm
+ Mọi nền tảng
+ Web di động
+ Thêm thẻ
+ Lọc theo thẻ
+ Không tải được game từ itch.io
Không hỗ trợ tệp %1$s
itch.io trả về HTTP %1$d
Miễn phí
@@ -2129,6 +2154,7 @@
Đóng
Thử lại
Đang hoàn tất đăng nhập…
+ Microsoft đã từ chối đăng nhập Xbox. Hãy đăng xuất Xbox trong Cửa hàng game, đăng nhập lại rồi tiếp tục.
Không thể tải trang đăng nhập: %1$s
Nhà cung cấp này từ chối đăng nhập từ một trang nhúng. Hãy đăng nhập bằng mật khẩu store của bạn thay vào đó.
Trang đăng nhập trả về lỗi (HTTP %1$d).
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 4c37e48e4f..2041027738 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -287,9 +287,6 @@
自动会暂停并在显示时恢复。原生会先让 Steam 做好睡眠准备。手动会等待点按恢复。“从不”则保持运行。
后台继续下载
Steam 正在下载时推迟后台暂停。
- zRAM 压缩
- 游戏运行时,Steam 客户端的内存会压缩进设备的 zram,为游戏留出更多内存。下次启动 Steam 时生效。
- 不可用:此设备没有 zram 或 swap,或其内核低于 5.4。
自动会在后台暂停并在显示时恢复。手动会等待点按恢复。“从不”则保持运行。
启动
随 DroidDeck 启动 Steam
@@ -544,8 +541,8 @@
Turnip:sysmem 渲染
Steam 客户端更快;游戏中驱动会为每个渲染通道选择分块渲染或系统内存渲染。Adreno 710/720/722 必需。
跳过 Steam 的 xalia 助手
- droiddeck-ntsync(实验性)
- Linux ntsync 驱动的用户态替代品,供测试使用。开启时,Proton 使用它代替 droiddeck-esync 和 droiddeck-fsync。适用于 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。将在下次会话生效。
+ droiddeck-ntsync
+ Linux ntsync 驱动的用户态替代品。开启时,Proton 使用它代替 droiddeck-esync 和 droiddeck-fsync。适用于 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。将在下次会话生效。
droiddeck-esync
droiddeck-fsync 优先
在原始 Proton 文件上运行 Proton 自带的 fsync,由用户态提供 futex_waitv,因此无需任何包,且 Steam 更新 Proton 后立即继续可用。开启时,除 Proton 自身禁用 fsync 的少数游戏外,各游戏优先使用它而非 droiddeck-esync。将在下次会话生效。
@@ -1468,6 +1465,10 @@
黑色背景、白色文字,选中、聚焦或按下的元素使用蓝色。
电光藏青
更明亮的蓝色,配以偏藏青而非灰色的界面。
+ Inner Gamer
+ 在彩虹色之间循环变化的颜色。遵循 Android 的动画设置。
+ 速度
+ 颜色循环的快慢。
渐变
你自己选择的主色和辅色,在按钮和高亮处渐变呈现。
主色
@@ -1584,6 +1585,13 @@
跳过
选择此文件夹
返回
+ 退出
+ 返回初始文件夹
+ 初始文件夹已不可用
+ 取消操作?
+ 操作将被取消。确定吗?
+ 接受
+ 拒绝
%1$s 已挂载,但当前无法读取
列表视图
网格视图
@@ -2054,6 +2062,23 @@
下载内容中未找到 Windows 游戏
无法解压下载内容(代码 %1$d)
itch.io 没有响应
+ 热门
+ 最新发布
+ 新品与热门
+ 付费
+ 5 美元以下
+ 15 美元以下
+ 评分最高
+ 热销
+ 任意价格
+ 免费
+ 特价
+ 加载更多
+ 任意平台
+ 移动网页
+ 添加标签
+ 按标签筛选
+ 无法从 itch.io 加载游戏
不支持 %1$s 压缩包
itch.io 返回 HTTP %1$d
免费
@@ -2205,6 +2230,7 @@
关闭
重试
正在完成登录…
+ Microsoft 拒绝了 Xbox 登录。请在游戏商店中退出 Xbox,重新登录,然后继续。
无法加载登录页面:%1$s
该第三方登录方式不允许在内嵌页面中登录。请改用商店密码登录。
登录页面返回了错误(HTTP %1$d)。
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 942fbbcb8e..54aefb1fa5 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -287,9 +287,6 @@
「自動」會暫停,並在重新顯示時繼續;「原生」會先讓 Steam 準備好休眠;「手動」會等你按「繼續」;「從不」會保持執行。
保持下載進行
Steam 正在下載時,延遲在背景暫停。
- zRAM 壓縮
- 遊戲運行時,Steam 用戶端的記憶體會壓縮進裝置的 zram,為遊戲騰出更多記憶體。下次啟動 Steam 時生效。
- 無法使用:此裝置沒有 zram 或 swap,或核心版本低於 5.4。
「自動」會在背景時暫停,並在重新顯示時繼續;「手動」會等你按「繼續」;「從不」會保持執行。
啟動
隨 DroidDeck 啟動 Steam
@@ -544,8 +541,8 @@
Turnip:sysmem 渲染
Steam 用戶端會更快;遊戲中驅動程式會為每個渲染通道選擇分塊渲染或系統記憶體渲染。Adreno 710/720/722 必須開啟。
略過 Steam 的 xalia 輔助程式
- droiddeck-ntsync(實驗性)
- 在用戶空間代替 Linux ntsync 驅動程式,供測試使用。開啟時,Proton 會使用它而非 droiddeck-esync 和 droiddeck-fsync。適用於 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。下次會話生效。
+ droiddeck-ntsync
+ 在用戶空間代替 Linux ntsync 驅動程式。開啟時,Proton 會使用它而非 droiddeck-esync 和 droiddeck-fsync。適用於 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。下次會話生效。
droiddeck-esync
優先使用 droiddeck-fsync
在原裝 Proton 檔案上執行 Proton 本身的 fsync,並在用戶空間提供 futex_waitv,因此無需套件,Steam 更新 Proton 後亦能立即繼續運作。開啟時,遊戲會優先使用它而非 droiddeck-esync,Proton 刻意不用 fsync 的少數遊戲除外。下次會話生效。
@@ -1392,6 +1389,10 @@
黑色背景、白色文字,所有已選取、焦點所在或按下的項目都使用藍色。
電光海軍藍
更明亮的藍色,搭配偏海軍藍而非灰色的介面。
+ Inner Gamer
+ 在彩虹色之間循環變化的顏色。遵循 Android 的動畫設定。
+ 速度
+ 顏色循環的快慢。
漸層
你自行選擇的主色與輔色,在按鈕與強調處以漸層呈現。
主色
@@ -1508,6 +1509,13 @@
略過
選擇此資料夾
返回
+ 離開
+ 返回初始資料夾
+ 初始資料夾已無法使用
+ 取消操作?
+ 操作將會取消。確定嗎?
+ 接受
+ 拒絕
%1$s 已掛載,但目前無法讀取
清單檢視
格狀檢視
@@ -1978,6 +1986,23 @@
下載內容中找不到 Windows 遊戲
無法解壓下載內容(代碼 %1$d)
itch.io 沒有回應
+ 熱門
+ 最新發布
+ 新品與熱門
+ 付費
+ 5 美元以下
+ 15 美元以下
+ 評分最高
+ 熱賣
+ 任何價格
+ 免費
+ 特價
+ 載入更多
+ 任何平台
+ 行動網頁
+ 新增標籤
+ 按標籤篩選
+ 無法從 itch.io 載入遊戲
不支援 %1$s 壓縮檔
itch.io 回應 HTTP %1$d
免費
@@ -2132,6 +2157,7 @@
關閉
再試一次
正在完成登入…
+ Microsoft 拒絕了 Xbox 登入。請在商店中登出 Xbox,重新登入,然後繼續。
無法載入登入頁面:%1$s
此提供者不允許從內嵌頁面登入。請改用商店密碼登入。
登入頁面回應錯誤(HTTP %1$d)。
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 99ea1e1879..d7c31545d7 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -287,9 +287,6 @@
「自動」會暫停,並在重新顯示時繼續。「原生」會先讓 Steam 做好睡眠準備。「手動」會等你點擊「繼續」。「從不」則會持續執行。
讓下載持續進行
Steam 正在下載時,延後在背景暫停。
- zRAM 壓縮
- 遊戲執行時,Steam 用戶端記憶體會壓縮進裝置的 zram,為遊戲騰出更多記憶體。下次啟動 Steam 時生效。
- 無法使用:此裝置沒有 zram 或 swap,或核心版本低於 5.4。
「自動」會在背景時暫停,並在重新顯示時繼續。「手動」會等你點擊「繼續」。「從不」則會持續執行。
啟動
隨 DroidDeck 啟動 Steam
@@ -544,8 +541,8 @@
Turnip:sysmem 渲染
Steam 用戶端會更快;遊戲中驅動程式會為每個算繪通道選擇分塊算繪或系統記憶體算繪。Adreno 710/720/722 必需。
跳過 Steam 的 xalia 輔助程式
- droiddeck-ntsync(實驗性)
- 以使用者空間替代 Linux ntsync 驅動程式,供測試使用。開啟時,Proton 會使用它來取代 droiddeck-esync 和 droiddeck-fsync。適用於 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。下次工作階段生效。
+ droiddeck-ntsync
+ 以使用者空間替代 Linux ntsync 驅動程式。開啟時,Proton 會使用它來取代 droiddeck-esync 和 droiddeck-fsync。適用於 Proton Experimental ARM64、GE-Proton 和 proton-cachyos。下次工作階段生效。
droiddeck-esync
優先使用 droiddeck-fsync
在原版 Proton 檔案上執行 Proton 自己的 fsync,並在使用者空間提供 futex_waitv,因此不需要套件,Steam 更新 Proton 後也能立即繼續運作。開啟時,遊戲會優先使用它而非 droiddeck-esync,Proton 本身停用 fsync 的少數遊戲除外。下次工作階段生效。
@@ -1392,6 +1389,10 @@
黑色背景、白色文字,選取、聚焦或按下的項目使用藍色。
電光藏青
更亮的藍色,搭配偏藏青而非灰色的介面。
+ Inner Gamer
+ 在彩虹色之間循環變化的顏色。遵循 Android 的動畫設定。
+ 速度
+ 顏色循環的快慢。
漸層
你自行選擇的主色與輔色,在按鈕與強調處以漸層呈現。
主色
@@ -1508,6 +1509,13 @@
略過
選擇此資料夾
返回
+ 離開
+ 返回起始資料夾
+ 起始資料夾已無法使用
+ 取消操作?
+ 操作將會取消。確定嗎?
+ 接受
+ 拒絕
%1$s 已掛載,但目前無法讀取
清單檢視
格狀檢視
@@ -1978,6 +1986,23 @@
下載內容中找不到 Windows 遊戲
無法解壓縮下載內容(代碼 %1$d)
itch.io 沒有回應
+ 熱門
+ 最新發布
+ 新品與熱門
+ 付費
+ 5 美元以下
+ 15 美元以下
+ 評分最高
+ 熱銷
+ 任何價格
+ 免費
+ 特價
+ 載入更多
+ 任何平台
+ 行動網頁
+ 新增標籤
+ 依標籤篩選
+ 無法從 itch.io 載入遊戲
不支援 %1$s 壓縮檔
itch.io 回應 HTTP %1$d
免費
@@ -2132,6 +2157,7 @@
關閉
再試一次
正在完成登入…
+ Microsoft 拒絕了 Xbox 登入。請在遊戲商店中登出 Xbox,重新登入,然後繼續。
無法載入登入頁面:%1$s
此提供者拒絕從內嵌頁面登入。請改用商店密碼登入。
登入頁面回應錯誤(HTTP %1$d)。
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f1923aeb3e..880491a3a4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -293,9 +293,6 @@
Auto pauses and resumes when shown. Native prepares Steam for sleep first. Manual waits for Resume. Never keeps running.
Keep downloads running
Delay background suspension while Steam is actively downloading.
- zRAM compression
- While a game runs, the Steam client\'s memory is compressed into the device\'s zram, leaving more RAM for the game. Applies the next time Steam starts.
- Unavailable: this device has no zram or swap, or its kernel is older than 5.4.
Auto pauses in the background and resumes when shown. Manual waits for Resume. Never keeps running.
Startup
Start Steam with DroidDeck
@@ -324,6 +321,8 @@
Turn off if games crash or go black in Deck mode. Applies next session.
Return to DroidDeck after a game
When a game you started from DroidDeck or another launcher closes, Steam exits cleanly (cloud saves finish first) and you go back there. Off: stay in Steam.
+ Shader pre-caching
+ Steam downloads shaders prebuilt for your games and processes them in the background, so games stutter less. Off saves data, storage and battery; games build shaders as they play instead. The same setting as Steam’s Downloads > Shader Pre-Caching. Applies next session.
Repair Steam client
Downloads the Steam client again the next time Steam starts. Use it if Steam stays on its loading screen. Games, sign-in and settings are kept.
The Steam client will be downloaded again the next time Steam starts.
@@ -558,8 +557,8 @@
Turnip: sysmem rendering
Faster for the Steam client; in games the driver picks tile or system-memory rendering per pass. Required on Adreno 710/720/722.
Skip Steam\'s xalia helper
- droiddeck-ntsync (experimental)
- A userspace stand-in for the Linux ntsync driver, for testing. While it is on, Proton uses it instead of droiddeck-esync and droiddeck-fsync. Works with Proton Experimental ARM64, GE-Proton and proton-cachyos. Applies next session.
+ droiddeck-ntsync
+ A userspace stand-in for the Linux ntsync driver. While it is on, Proton uses it instead of droiddeck-esync and droiddeck-fsync. Works with Proton Experimental ARM64, GE-Proton and proton-cachyos. Applies next session.
droiddeck-esync
droiddeck-fsync first
Runs Proton\'s own fsync on the stock Proton files, with futex_waitv supplied in userspace, so it needs no pack and keeps working the moment Steam updates Proton. While it is on, games use it ahead of droiddeck-esync, except the few Proton keeps off fsync. Applies next session.
@@ -570,6 +569,8 @@
proot fast path
Needs proot\'s seccomp filter.
Faster file lookups and less stutter. Turn off if a program can\'t find its files.
+ Draw the cursor inside gamescope
+ Gamescope paints the pointer itself instead of handing it to Android. Turn on for a controller-driven cursor. Off is faster on a phone. Applies next session.
Session identity
Host name
The name Steam sees for this device. Blank restores %1$s.
@@ -1111,6 +1112,9 @@
Hide drivers for other GPUs
Show drivers for other GPUs
Advanced
+ UBWC compatibility
+ Try On or Off if Steam or Android shows stripes or flickering. Applies to both drivers after restarting DroidDeck.
+ Restart DroidDeck to apply.
Set together with the display driver: %1$s carries both.
Set together with the runtime driver: %1$s carries both.
Used by games and the desktop.
@@ -1470,6 +1474,10 @@
Black ground, white type, the blue for everything selected, focused or pressed.
Electric navy
The blue brighter, on surfaces that lean navy instead of grey.
+ Inner Gamer
+ Colors that cycle through the rainbow. Follows Android\'s animation settings.
+ Speed
+ How fast the colors cycle.
Gradient
Your own primary and secondary colors, blended on buttons and highlights.
Primary
@@ -1591,6 +1599,13 @@
Skip
Select this folder
Back
+ Exit
+ Return to start
+ Starting folder is no longer available
+ Cancel operation?
+ The operation will be cancelled. Are you sure?
+ Accept
+ Decline
%1$s is mounted but not readable right now
List view
Grid view
@@ -2091,6 +2106,29 @@
No Windows game found in the download
Could not extract the download (exit %1$d)
itch.io did not answer
+ Popular
+ Most recent
+ New & popular
+ Paid
+ $5 or less
+ $15 or less
+ Top rated
+ Top sellers
+ Any price
+ Free
+ On sale
+ Load more
+ Any platform
+ Mobile web
+ Add a tag
+ Filter by tag
+ Windows
+ macOS
+ Linux
+ Android
+ iOS
+ Web
+ Could not load games from itch.io
%1$s archives are not supported
itch.io answered HTTP %1$d
Free
@@ -2259,6 +2297,7 @@
Close
Try again
Finishing sign-in…
+ Microsoft rejected the Xbox sign-in. Sign out of Xbox in Stores, sign in again, then resume.
The sign-in page could not be loaded: %1$s
This provider refuses to sign in from an embedded page. Sign in with your store password instead.
The sign-in page answered with an error (HTTP %1$d).
diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md
index c5cd077443..ee7e5a8278 100644
--- a/app/src/main/rust/stores/JNI.md
+++ b/app/src/main/rust/stores/JNI.md
@@ -160,13 +160,15 @@ synchronous on the calling thread (network calls block: call them off the main t
| `cloud.list` | `accessToken`, `accountId`, `appName` | `files[]` of `name`, `modified` (ms, -1 unknown), `hash`, `readLink` |
| `cloud.writeLinks` | `accessToken`, `accountId`, `appName`, `names[]` | `links`: name → write link |
| `launch.args` | `displayName`, `accountId`, `namespace`, `locale`, `appName`, `deploymentId`, `additional` | `args[]` |
+| `launch.split` | `command` | `args[]` |
| `locale` | `language`, `region` | `key`, `tags[]`, `launchLocale` |
`nativeFetch` ops: `manifest.download` (`info`, optional `cdns`) → the manifest bytes;
`cloud.read` (`url`) → the file. `null` = failed. `nativeSend` op: `cloud.write` (`url`) with the
body → `{"ok": true}` or an error. `nativeInspect` parses manifest bytes: `{"op":"summary"}` →
`buildVersion`, `launchExe`, `prereqName`, `prereqPath`, `prereqRead`, `files[]` (`path`, `size`,
-`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets.
+`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets;
+`{"op":"launch"}` → the manifest's `buildVersion`, its `command` line and the `args[]` split from it.
### `nativeInstall`
@@ -196,7 +198,7 @@ completes.
On-disk protocol: game files are staged in `/.droiddeck-epic-staging/*.stage` (owner
marker `owner` = `DroidDeck Epic staging v1\n`) and renamed over their destination after size and
-SHA-1 checks; reusable chunks live, decompressed, as `` (extra copies `.`, writes via
+SHA-1 checks; a paused run keeps each unfinished file there as `*.part` with its written parts in `*.part.list`; reusable chunks live, decompressed, as `` (extra copies `.`, writes via
`.part`) in `/.chunks` or the scratch directory.
## `com.droiddeck.launcher.stores.amazon.AmazonNative`
diff --git a/app/src/main/rust/stores/src/amazon/library.rs b/app/src/main/rust/stores/src/amazon/library.rs
index ec9ba55f86..46360a907b 100644
--- a/app/src/main/rust/stores/src/amazon/library.rs
+++ b/app/src/main/rust/stores/src/amazon/library.rs
@@ -21,6 +21,7 @@ pub struct Game {
pub parent_product_id: String,
pub art: String,
pub hero: String,
+ pub logo: String,
pub developer: String,
pub publisher: String,
}
@@ -39,6 +40,7 @@ impl Game {
"sku": self.sku,
"art": self.art,
"hero": self.hero,
+ "logo": self.logo,
"developer": self.developer,
"publisher": self.publisher,
"dlc": self.is_dlc(),
@@ -83,6 +85,7 @@ pub fn read_entitlement(e: &Value) -> Option {
],
)
.to_string(),
+ logo: str_at(product, &["productDetail", "details", "logoUrl"]).to_string(),
developer: str_at(product, &["productDetail", "details", "developer"]).to_string(),
publisher: str_at(product, &["productDetail", "details", "publisher"]).to_string(),
})
@@ -178,17 +181,20 @@ mod tests {
fn entitlement_fields_and_fallbacks() {
let e = json!({"id":"ent-1","product":{"id":"amzn1.adg.product.x","title":"Game","sku":"SKU1",
"productDetail":{"iconUrl":"","details":{"pgCrownImageUrl":"crown","backgroundUrl1":"bg1",
- "developer":"Dev","publisher":"Pub","productType":"GAME"}}}});
+ "logoUrl":"logo","developer":"Dev","publisher":"Pub","productType":"GAME"}}}});
let g = read_entitlement(&e).unwrap();
assert_eq!(g.entitlement_id, "ent-1");
assert_eq!(g.art, "crown");
assert_eq!(g.hero, "bg1");
+ assert_eq!(g.logo, "logo");
+ assert_eq!(g.to_json()["logo"], "logo");
assert_eq!(g.product_type, "GAME");
assert!(!g.is_dlc());
let untitled = read_entitlement(&json!({"product":{"id":"p","type":"DLC","baseProductId":"q"}})).unwrap();
assert_eq!(untitled.title, "Unknown");
assert_eq!(untitled.entitlement_id, "");
assert_eq!(untitled.parent_product_id, "q");
+ assert_eq!(untitled.logo, "");
assert!(untitled.is_dlc());
assert!(read_entitlement(&json!({"id":"x"})).is_none());
assert!(read_entitlement(&json!({"id":"x","product":{"id":""}})).is_none());
diff --git a/app/src/main/rust/stores/src/epic/catalog.rs b/app/src/main/rust/stores/src/epic/catalog.rs
index 4589ce276b..420d656e80 100644
--- a/app/src/main/rust/stores/src/epic/catalog.rs
+++ b/app/src/main/rust/stores/src/epic/catalog.rs
@@ -71,6 +71,7 @@ pub fn details_of(entry: &Value) -> Value {
"releaseDate": release,
"tall": image(entry, &["DieselGameBoxTall"]),
"wide": image(entry, &["DieselGameBox", "Thumbnail"]),
+ "logo": image(entry, &["DieselGameBoxLogo"]),
"canRunOffline": offline,
"dlc": main_game.is_some_and(|m| !m.is_null()),
"mainGameId": main_game.map(|m| net::str_of(m, "id")).unwrap_or(""),
@@ -102,7 +103,8 @@ mod tests {
"keyImages": [
{"type": "Thumbnail", "url": "thumb"},
{"type": "DieselGameBox", "url": ""},
- {"type": "DieselGameBoxTall", "url": "tall"}
+ {"type": "DieselGameBoxTall", "url": "tall"},
+ {"type": "DieselGameBoxLogo", "url": "logo"}
],
"customAttributes": {"CanRunOffline": {"value": "FALSE"}, "publisherName": {"value": " Pub "}},
"seller": {"name": "Seller"},
@@ -113,6 +115,7 @@ mod tests {
assert_eq!(d["title"], "Game");
assert_eq!(d["tall"], "tall");
assert_eq!(d["wide"], "thumb");
+ assert_eq!(d["logo"], "logo");
assert_eq!(d["publisher"], "Pub");
assert_eq!(d["canRunOffline"], false);
assert_eq!(d["releaseDate"], "2020-01-01T00:00:00.000Z");
@@ -123,6 +126,7 @@ mod tests {
assert_eq!(dlc["publisher"], "S");
assert_eq!(dlc["releaseDate"], "v");
assert_eq!(dlc["canRunOffline"], true);
+ assert_eq!(dlc["logo"], "");
assert_eq!(pick_entry(&json!({"x": {"title": "Only"}}), "y").unwrap()["title"], "Only");
}
}
diff --git a/app/src/main/rust/stores/src/epic/install/mod.rs b/app/src/main/rust/stores/src/epic/install/mod.rs
index 426e3bdcf9..df20412aca 100644
--- a/app/src/main/rust/stores/src/epic/install/mod.rs
+++ b/app/src/main/rust/stores/src/epic/install/mod.rs
@@ -5,7 +5,7 @@ pub mod space;
pub mod staging;
pub mod writer;
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
@@ -140,6 +140,17 @@ pub fn fetch_manifest(info: &BuildInfo, log: &dyn Fn(&str)) -> Result Option> {
+ let meta = fs::symlink_metadata(stage).ok()?;
+ if !meta.is_file() || meta.len() > size {
+ return None;
+ }
+ let list = fs::read_to_string(staging::list_path(stage)).ok()?;
+ let kept: HashSet = list.lines().map(|l| l.parse().ok()).collect::