diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a1d97cf6..a8a22292b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,17 @@ name: Build APK run-name: ${{ github.event_name == 'pull_request' && format('building pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('building {0} on {1}', github.ref_name, github.sha) }} on: + workflow_call: + inputs: + play_bundle: + type: boolean + default: false + source_sha: + type: string + default: '' + play_version_code: + type: string + default: '' push: branches: [ main ] paths-ignore: @@ -32,7 +43,7 @@ permissions: pull-requests: write concurrency: - group: build-${{ github.event.pull_request.number || (github.event_name == 'push' && 'main') || github.run_id }} + group: build-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref_name) || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} jobs: @@ -47,13 +58,27 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* !/docs/releases/media/ sparse-checkout-cone-mode: false persist-credentials: false + - name: Validate Play distribution inputs + if: inputs.play_bundle == true + env: + PLAY_SOURCE_SHA: ${{ inputs.source_sha }} + run: | + set -euo pipefail + [[ $PLAY_SOURCE_SHA =~ ^[0-9a-f]{40}$ ]] + test "$(git rev-parse HEAD)" = "$PLAY_SOURCE_SHA" + git merge-base --is-ancestor "$PLAY_SOURCE_SHA" origin/playstore + test -f tools/playstore/components.lock.json || { + echo "::error::Production component manifest is incomplete; the Play bundle cannot be built or signed." + exit 1 + } + python3 tools/playstore/payloads.py validate --play-only --manifest tools/playstore/components.lock.json - name: Pin and merge the APK source id: merge if: github.event_name == 'pull_request' @@ -86,7 +111,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* @@ -145,7 +170,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* @@ -304,7 +329,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* @@ -444,8 +469,8 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - BUILD_REF: ${{ github.ref_name }} - BUILD_SHA: ${{ github.sha }} + BUILD_REF: ${{ inputs.play_bundle && 'playstore' || github.ref_name }} + BUILD_SHA: ${{ inputs.source_sha || github.sha }} run: | if [[ -n "$(git status --porcelain)" ]]; then tree_state=dirty @@ -642,6 +667,7 @@ jobs: - uses: actions/upload-artifact@v4 id: apk-upload + if: inputs.play_bundle != true with: name: droiddeck-apk path: app/build/outputs/apk/release/*.apk @@ -649,7 +675,56 @@ jobs: retention-days: 30 compression-level: 0 + - name: Stage verified Play components + if: inputs.play_bundle == true + run: | + set -euo pipefail + bash tools/ci/install-ubuntu-packages.sh zstd + python3 tools/playstore/payloads.py stage --play-only --manifest tools/playstore/components.lock.json \ + --cache "$RUNNER_TEMP/play-component-cache" --output build/playstore-payloads + + - name: Build and check the Play bundle + if: inputs.play_bundle == true + env: + PLAY_VERSION_CODE: ${{ inputs.play_version_code }} + run: | + set -euo pipefail + bash tools/ci/install-ubuntu-packages.sh autoconf automake libtool autopoint gettext pkg-config cmake ninja-build + python3 tools/playstore/build_audio.py build --output app/build/play-audio \ + --ndk "$ANDROID_HOME/ndk/$NDK_VERSION" --cache "$RUNNER_TEMP/play-audio-cache" + ./gradlew :app:bundleRelease :app:lintRelease :app:testReleaseUnitTest -PplayDistribution=true \ + -PndkVersion="$NDK_VERSION" -PplayVersionCode="$PLAY_VERSION_CODE" --tests com.droiddeck.launcher.core.ComponentPayloadStoreTest \ + --tests com.droiddeck.launcher.core.PlayDistributionTest \ + --tests com.droiddeck.launcher.PlayUpdatesTest \ + --tests com.droiddeck.launcher.ui.BuildWatermarkTest --console=plain + python3 tools/playstore/payloads.py verify-bundle --play-only --manifest tools/playstore/components.lock.json \ + --bundle app/build/outputs/bundle/release/app-release.aab + python3 tools/release/check_android_libraries.py app/build/outputs/bundle/release/app-release.aab --page-size 16384 + python3 tools/playstore/check_audio_bundle.py --bundle app/build/outputs/bundle/release/app-release.aab \ + --output app/build/play-audio --ndk "$ANDROID_HOME/ndk/$NDK_VERSION" + curl --fail --location --retry 3 --output "$RUNNER_TEMP/bundletool.jar" \ + https://github.com/google/bundletool/releases/download/1.18.3/bundletool-all-1.18.3.jar + echo "a099cfa1543f55593bc2ed16a70a7c67fe54b1747bb7301f37fdfd6d91028e29 $RUNNER_TEMP/bundletool.jar" | sha256sum -c - + java -jar "$RUNNER_TEMP/bundletool.jar" validate --bundle=app/build/outputs/bundle/release/app-release.aab + java -jar "$RUNNER_TEMP/bundletool.jar" dump manifest --bundle=app/build/outputs/bundle/release/app-release.aab \ + --module=base > app/build/play-manifest.xml + python3 -c 'import xml.etree.ElementTree as E; root=E.parse("app/build/play-manifest.xml").getroot(); assert not any(x.get("{http://schemas.android.com/apk/res/android}name") == "android.permission.REQUEST_INSTALL_PACKAGES" for x in root.findall("uses-permission"))' + - uses: actions/upload-artifact@v4 + if: inputs.play_bundle == true + with: + name: droiddeck-play-bundle-review + path: | + app/build/outputs/bundle/release/*.aab + build/playstore-payloads/provenance.json + build/playstore-payloads/index.json + app/build/play-manifest.xml + if-no-files-found: error + retention-days: 30 + compression-level: 0 + + - uses: actions/upload-artifact@v4 + if: inputs.play_bundle != true with: name: droiddeck-packs path: app/build/packs/*.tar.zst @@ -683,7 +758,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* @@ -737,7 +812,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ inputs.source_sha || (github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }} fetch-depth: 0 sparse-checkout: | /* @@ -809,7 +884,7 @@ jobs: sign: needs: [build, checks] - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + if: ${{ !inputs.play_bundle && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} permissions: contents: read actions: read @@ -821,7 +896,7 @@ jobs: packs: needs: [build, checks] - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + if: ${{ !inputs.play_bundle && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} permissions: contents: read actions: read @@ -830,7 +905,7 @@ jobs: announce: needs: [build, sign, packs] - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + if: ${{ !inputs.play_bundle && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} runs-on: ubuntu-24.04 timeout-minutes: 10 permissions: @@ -880,6 +955,6 @@ jobs: catalog: needs: announce - if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.announce.result != 'skipped' }} + if: ${{ always() && !inputs.play_bundle && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.announce.result != 'skipped' }} uses: ./.github/workflows/update-catalog.yml secrets: inherit diff --git a/.github/workflows/playstore.yml b/.github/workflows/playstore.yml new file mode 100644 index 000000000..863ca6d68 --- /dev/null +++ b/.github/workflows/playstore.yml @@ -0,0 +1,194 @@ +name: Build PlayStore Bundle +run-name: PlayStore ${{ inputs.version || 'branch build' }} from playstore + +on: + workflow_call: + inputs: + version: + type: string + required: true + source_branch: + type: string + default: playstore + push: + branches: [playstore] + workflow_dispatch: + inputs: + version: + description: Version for the file names, e.g. 0.1.7 + required: true + source_branch: + description: Branch to build + type: choice + options: [playstore] + default: playstore + required: true + +permissions: + contents: read + actions: read + pull-requests: write + +concurrency: + group: playstore-bundle + cancel-in-progress: false + +jobs: + checks: + name: Play distribution checks + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'push' && github.sha || inputs.source_branch }} + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - name: Install test dependencies + run: | + sudo apt-get update + sudo apt-get install -y zstd + python3 -m pip install PyYAML==6.0.3 + - name: Test Play distribution safeguards + run: | + python3 -m unittest \ + tools.tests.test_playstore_payloads \ + tools.tests.test_playstore_signing \ + tools.tests.test_playstore_workflow \ + tools.tests.test_playstore_archive_preparation \ + tools.tests.test_playstore_audio_bundle \ + tools.tests.test_playstore_emulators \ + tools.tests.test_android_page_alignment + + source: + runs-on: ubuntu-24.04 + outputs: + sha: ${{ steps.source.outputs.sha }} + version: ${{ steps.source.outputs.version }} + version_code: ${{ steps.source.outputs.version_code }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'push' && github.sha || inputs.source_branch }} + persist-credentials: false + - id: source + env: + VERSION: ${{ inputs.version }} + SOURCE_BRANCH: ${{ inputs.source_branch || 'playstore' }} + PLAY_VERSION_CODE_BASE: ${{ vars.PLAY_VERSION_CODE_BASE }} + run: | + set -euo pipefail + test "$SOURCE_BRANCH" = playstore + test "$GITHUB_REF" = refs/heads/playstore + sha=$(git rev-parse HEAD) + if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then + [[ $VERSION =~ ^[0-9A-Za-z._-]+$ ]] || { echo "::error::invalid version"; exit 1; } + name=$(sed -n 's/^ *versionName "\(.*\)"$/\1/p' app/build.gradle) + [[ $VERSION == "$name" || $VERSION == "$name"-* ]] || { + echo "::error::version must match versionName in app/build.gradle; bump versionName and versionCode first" + exit 1 + } + else + VERSION="playstore-${sha::7}" + fi + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + source_code=$(sed -n 's/^ *versionCode \([0-9][0-9]*\)$/\1/p' app/build.gradle) + base=${PLAY_VERSION_CODE_BASE:-$source_code} + [[ $base =~ ^[0-9]+$ && $source_code =~ ^[0-9]+$ ]] + [ "$base" -ge "$source_code" ] || base=$source_code + elapsed=$(( $(date -u +%s) - 1577836800 )) + [ "$elapsed" -gt 0 ] + version_code=$((base + elapsed)) + [ "$version_code" -le 2100000000 ] + echo "version_code=$version_code" >> "$GITHUB_OUTPUT" + + bundle: + needs: source + uses: ./.github/workflows/build.yml + with: + play_bundle: true + source_sha: ${{ needs.source.outputs.sha }} + play_version_code: ${{ needs.source.outputs.version_code }} + secrets: inherit + + sign: + needs: [checks, source, bundle] + runs-on: ubuntu-24.04 + environment: signing-playstore + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.source.outputs.sha }} + persist-credentials: false + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - uses: actions/download-artifact@v4 + with: + name: droiddeck-play-bundle-review + path: incoming + - name: Sign the verified Play bundle + env: + RELEASE_KEYSTORE_B64: ${{ secrets.RELEASE_KEYSTORE_B64 }} + RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }} + RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} + VERSION: ${{ needs.source.outputs.version }} + run: | + set -euo pipefail + test -n "$RELEASE_KEYSTORE_B64" + key="$RUNNER_TEMP/play-release.p12" + (umask 077; printf '%s' "$RELEASE_KEYSTORE_B64" | base64 -d > "$key") + mapfile -t bundles < <(find incoming -type f -name '*.aab') + test "${#bundles[@]}" = 1 + mkdir -p signed + python3 tools/playstore/sign_bundle.py "${bundles[0]}" "signed/DroidDeck-$VERSION-PlayStore.aab" \ + --keystore "$key" + (cd signed && sha256sum *.aab > SHA256SUMS) + - uses: actions/upload-artifact@v4 + with: + name: droiddeck-play-bundle-signed + path: signed/* + if-no-files-found: error + compression-level: 0 + + publish: + needs: [source, sign] + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-24.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.source.outputs.sha }} + persist-credentials: false + - uses: actions/download-artifact@v4 + with: + name: droiddeck-play-bundle-signed + path: signed + - name: Publish the PlayStore release + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.source.outputs.version }} + SOURCE_SHA: ${{ needs.source.outputs.sha }} + VERSION_CODE: ${{ needs.source.outputs.version_code }} + run: | + set -euo pipefail + tag="playstore-$VERSION" + if gh release view "$tag" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + echo "::error::PlayStore release $tag already exists" + exit 1 + fi + printf 'Signed Android App Bundle for Google Play upload.\n\nSource: `%s` on `playstore`.\nVersion code: `%s`.\n' "$SOURCE_SHA" "$VERSION_CODE" > "$RUNNER_TEMP/play-release.md" + gh release create "$tag" -R "$GITHUB_REPOSITORY" signed/*.aab signed/SHA256SUMS \ + --target "$SOURCE_SHA" --title "DroidDeck $VERSION ยท PlayStore" \ + --notes-file "$RUNNER_TEMP/play-release.md" --latest=false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a15159268..5e53c38fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ name: Release APKs -run-name: release ${{ inputs.version }} from main ${{ github.sha }} +run-name: ${{ github.ref == 'refs/heads/playstore' && format('PlayStore {0} from playstore {1}', inputs.version, github.sha) || format('release {0} from main {1}', inputs.version, github.sha) }} on: workflow_dispatch: @@ -13,10 +13,23 @@ permissions: actions: read concurrency: - group: release + group: ${{ github.ref == 'refs/heads/playstore' && 'release-playstore' || 'release' }} cancel-in-progress: false jobs: + playstore: + name: Build PlayStore Bundle + if: github.ref == 'refs/heads/playstore' + permissions: + contents: write + actions: read + pull-requests: write + uses: ./.github/workflows/playstore.yml + with: + version: ${{ inputs.version }} + source_branch: playstore + secrets: inherit + find: name: find the main build if: github.ref == 'refs/heads/main' @@ -53,6 +66,7 @@ jobs: echo "Signing Build APK run $id (main ${GITHUB_SHA::7}) as $VERSION: $variants" >> "$GITHUB_STEP_SUMMARY" sign: + if: github.ref == 'refs/heads/main' needs: find uses: ./.github/workflows/sign.yml with: @@ -64,6 +78,7 @@ jobs: secrets: inherit packs: + if: github.ref == 'refs/heads/main' needs: find permissions: contents: read @@ -74,6 +89,7 @@ jobs: secrets: inherit publish: + if: github.ref == 'refs/heads/main' name: publish the release needs: [find, sign, packs] runs-on: ubuntu-24.04 diff --git a/PRIVACY.md b/PRIVACY.md index e7a23fd68..0350a2daf 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -27,6 +27,8 @@ You can manage permissions through Android settings. Turning off a permission or DroidDeck connects to the stores, game services, cloud-streaming providers, artwork sources, and download services used by your selected features. Those services can receive information such as your IP address, requests, game identifiers, authentication information, or information you enter directly into their sign-in and purchase pages. Steam, games, and other software running through DroidDeck have their own network activity and privacy policies. Their providers determine how they handle that information. +The Google Play version contacts Google Play to check whether an app update is available. Selecting Update opens the app's Google Play listing. Google handles Play delivery and updates under its own [privacy policy](https://policies.google.com/privacy). + Optional Syncthing synchronization transfers selected files to the devices you configure and can use discovery and relay services. DroidDeck disables Syncthing usage reporting and crash reporting. Selected games or other guest software may use files and resources available within DroidDeck's runtime. DroidDeck's privacy policy does not replace the policies of these separate providers. Review the relevant provider's policy when signing in, purchasing content, streaming, installing software, or enabling synchronization. diff --git a/app/build.gradle b/app/build.gradle index 0d94314d3..8379553ff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,6 +18,7 @@ if (uvcDir) { if (!new File(uvcDir, required).isFile()) throw new GradleException("Incomplete UVC build: missing ${required}") } } + if (vitureSdkDir) { ['android/arm64-v8a/libglasses.so', 'android/arm64-v8a/libcarina_vio.so', 'android/arm64-v8a/libcloud_protocol.so', 'include/viture_glasses_provider.h', @@ -81,6 +82,7 @@ def buildBranch = providers.environmentVariable('GITHUB_HEAD_REF').getOrNull()?. ?: gitValue(['branch', '--show-current']) ?: '' def escapeJava = { String value -> value.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ' ').replace('\r', ' ') } def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true' +def playDistribution = providers.gradleProperty('playDistribution').getOrElse('false').toBoolean() def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim() 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() @@ -138,6 +140,7 @@ android { buildConfigField "String", "PR_TITLE", "\"${escapeJava(prTitle)}\"" buildConfigField "String", "BUILD_BRANCH", "\"${escapeJava(buildBranch)}\"" buildConfigField "boolean", "CI_BUILD", "${ciBuild}" + buildConfigField "boolean", "PLAY_DISTRIBUTION", "${playDistribution}" buildConfigField "String", "RELEASE_SIGNER", "\"${releaseSigner}\"" buildConfigField "long", "COMMIT_TIME", "${commitTime}L * 1000L" buildConfigField "String", "VARIANT_SUFFIXES", "\"${variantSuffixes}\"" @@ -254,6 +257,36 @@ android { } } +def verifyPlayAudio +if (playDistribution) { + def requestedCode = providers.gradleProperty('playVersionCode').orNull + if (requestedCode != null) { + if (!requestedCode.isInteger() || requestedCode.toLong() < android.defaultConfig.versionCode || requestedCode.toLong() > 2100000000L) { + throw new GradleException('Play version code must be a valid increasing Android version code') + } + android.defaultConfig.versionCode = requestedCode.toInteger() + } + def playAudio = layout.buildDirectory.dir('play-audio') + def playNdk = androidComponents.sdkComponents.ndkDirectory.get().asFile + verifyPlayAudio = tasks.register('verifyPlayAudio', Exec) { + workingDir rootProject.projectDir + commandLine pythonExecutable, 'tools/playstore/build_audio.py', 'verify', + '--output', playAudio.get().asFile, '--ndk', playNdk + } + def stagePlayJni = tasks.register('stagePlayJni', Sync) { + dependsOn(verifyPlayAudio) + from(layout.projectDirectory.dir('src/main/jniLibs')) { + exclude(['libltdl.so', 'libpulseaudio.so', 'libpulse.so', 'libpulsecommon-13.0.so', + 'libpulsecore-13.0.so', 'libsndfile.so'].collect { "arm64-v8a/${it}".toString() }) + } + from(playAudio.map { it.dir('jni') }) + into(layout.buildDirectory.dir('playJni')) + } + android.sourceSets.main.jniLibs.setSrcDirs([layout.buildDirectory.dir('playJni')]) + tasks.named('preBuild').configure { dependsOn(stagePlayJni) } +} + + if (vitureSdkDir) { android.sourceSets.main.jniLibs.srcDir(new File(vitureSdkDir, 'android')) def stageVitureNotices = tasks.register('stageVitureNotices', Copy) { @@ -265,7 +298,7 @@ if (vitureSdkDir) { def stageSessionScripts = tasks.register('stageSessionScripts', Copy) { from(rootProject.file('tools/linuxfs/overlay')) { - include 'usr/local/bin/droiddeck-*', 'usr/local/bin/steam-compatibility', 'usr/bin/**' + include 'usr/local/bin/droiddeck-*', 'usr/local/bin/steam-compatibility', 'usr/bin/**', 'usr/local/lib/droiddeck/*.py' } into(layout.projectDirectory.dir('src/main/assets/linuxfs')) } @@ -276,10 +309,24 @@ def stageRuntimeAssets = tasks.register('stageRuntimeAssets', Sync) { dependsOn(stageSessionScripts) from(layout.projectDirectory.dir('src/main/assets')) { exclude 'pulseaudio.tzst' } from(rootProject.file('tools/linuxfs/innoextract')) - from(layout.buildDirectory.dir('prepared-assets')) + from(layout.buildDirectory.dir('prepared-assets')) { + if (playDistribution) exclude 'pulseaudio.tzst' + } + if (playDistribution) { + dependsOn(verifyPlayAudio) + from(layout.buildDirectory.dir('play-audio/assets')) + } into(runtimeAssetsDir) } android.sourceSets.main.assets.setSrcDirs([runtimeAssetsDir]) +if (playDistribution) { + def payloads = rootProject.file('build/playstore-payloads') + def modules = new groovy.json.JsonSlurper().parse(new File(payloads, 'modules.json')) + android.dynamicFeatures = modules.collect { ":${it}".toString() }.toSet() + android.sourceSets.main.assets.srcDir(new File(payloads, 'base/src/main/assets')) + android.sourceSets.debug.manifest.srcFile('src/play/AndroidManifest.xml') + android.sourceSets.release.manifest.srcFile('src/play/AndroidManifest.xml') +} if (vitureSdkDir) android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('vitureAssets').get().asFile) if (uvcDir) { def stageUvcNotices = tasks.register('stageUvcNotices', Copy) { @@ -298,7 +345,7 @@ def stageGogNotices = tasks.register('stageGogNotices', Copy) { android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('gogNotices').get().asFile) tasks.named('preBuild').configure { dependsOn(stageGogNotices) } -if (!ciBuild) { +if (!ciBuild || playDistribution) { def stageLocalPacks = tasks.register('stageLocalPacks', Sync) { from(layout.buildDirectory.dir('packs')) { include '*.tar.zst' } into(layout.buildDirectory.dir('localPackAssets/packs')) @@ -351,6 +398,7 @@ if (!skipRust) android.sourceSets.main.jniLibs.srcDir(rustJniLibsDir.get().asFil tasks.named('preBuild').configure { dependsOn(buildRustStores) } dependencies { + implementation 'com.google.android.play:app-update:2.1.0' implementation "org.opencv:opencv:${trackingPack.OPENCV_VERSION}" implementation 'org.khronos.openxr:openxr_loader_for_android:1.1.49' implementation 'com.github.luben:zstd-jni:1.5.7-4@aar' diff --git a/app/src/main/java/com/droiddeck/launcher/App.kt b/app/src/main/java/com/droiddeck/launcher/App.kt index 0cfb32fe7..59cd56f2c 100644 --- a/app/src/main/java/com/droiddeck/launcher/App.kt +++ b/app/src/main/java/com/droiddeck/launcher/App.kt @@ -16,6 +16,7 @@ class App : Application() { override fun onCreate() { super.onCreate() + com.droiddeck.launcher.core.ComponentDownloads.init(this) com.droiddeck.launcher.ui.Themes.loadGradient(this) com.droiddeck.launcher.ui.BuildWatermark.install(this) HomeApp.trackRecents(this) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 6993cb376..543c43594 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -119,6 +119,7 @@ class FrontEndActivity : ComponentActivity() { private var frameGenLabel by mutableStateOf("") private var lossless by mutableStateOf(Lossless.State.NONE) private var showRemove by mutableStateOf(false) + private var showAccessibilityConsent by mutableStateOf(false) private var showRuntimeActions by mutableStateOf(null) private var pendingSwitch by mutableStateOf(null) private var switchingTo: Intent? = null @@ -323,6 +324,10 @@ class FrontEndActivity : ComponentActivity() { manageHomeApp() } SteamIntegration.Feature.SHORTCUTS -> { + if (!SteamIntegration.accessibilityConsented(this)) { + showAccessibilityConsent = true + return + } if (!integrationState.shortcuts) shortcutsTried = true if (!HomeApp.isDefault(this)) configureIntegration(SteamIntegration.Feature.HOME) else { @@ -1452,6 +1457,17 @@ class FrontEndActivity : ComponentActivity() { page = page, ) } + if (showAccessibilityConsent) ConfirmDialog( + title = androidx.compose.ui.res.stringResource(R.string.integration_shortcuts), + text = androidx.compose.ui.res.stringResource(R.string.integration_shortcuts_service_description), + confirm = androidx.compose.ui.res.stringResource(R.string.glasses_allow), + onConfirm = { + SteamIntegration.acceptAccessibility(this@FrontEndActivity) + integrationState = readIntegration() + configureIntegration(SteamIntegration.Feature.SHORTCUTS) + }, + onDismiss = { showAccessibilityConsent = false }, + ) if (showRoms) RomsDialog( path = romsDir, onChoose = { diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 38cc1d7ca..ac129abfa 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -1939,7 +1939,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { SessionEvents.transition(SessionPhase.INSTALLING_RUNTIME, "proton.installing", mapOf("component" to "proton")) val protonProblem = installProton() if (protonProblem == null) SessionEvents.record("proton.ready") - else SessionEvents.record("proton.skipped", mapOf("reason" to protonProblem)) + else { + SessionEvents.record("proton.skipped", mapOf("reason" to protonProblem)) + if (BuildConfig.PLAY_DISTRIBUTION) { + problem = protonProblem + failedComponent = "proton" + } + } } uiHandler.post { localInstalling = false @@ -1958,6 +1964,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { val code = when (failedComponent) { "runtime" -> "RUNTIME_INSTALL_FAILED" "package" -> "PACKAGE_RESUME_FAILED" + "proton" -> "PROTON_INSTALL_FAILED" else -> "DESKTOP_INSTALL_FAILED" } SessionEvents.fail(code, problem) @@ -2043,6 +2050,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested } SessionState.installCancellation = cancellation return try { + if (BuildConfig.PLAY_DISTRIBUTION) { + var last = "" to Int.MIN_VALUE + return com.droiddeck.launcher.session.ProtonExtras.install( + this, com.droiddeck.launcher.session.ProtonExtras.tools.single(), cancellation, + ) { message, percent -> + val next = message to percent + if (next != last) { + last = next + uiHandler.post { + loading.percent = percent + loading.say(message, PROTON_LINES.topic, readable = true) + } + } + } + } val entry = catalog.fetch(catalog.STEAM_SEED_URL, cancellation)?.firstOrNull { it.id == catalog.PROTON_SEED_ID } ?: return if (cancellation.asBoolean) "cancelled" else "catalog unreachable" catalog.install(this, entry, cancellation, progressFor(PROTON_LINES, entry.size / 1_000_000)) diff --git a/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt b/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt index 6b59112d1..b30e1edfb 100644 --- a/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt @@ -8,6 +8,7 @@ import android.content.IntentFilter import android.content.pm.PackageInstaller import android.os.Build import android.os.Handler +import android.net.Uri import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf @@ -17,8 +18,12 @@ import com.droiddeck.launcher.ui.UpdatesActions import com.droiddeck.launcher.ui.UpdatesState import com.droiddeck.launcher.update.AppUpdates import com.droiddeck.launcher.update.SelfInstaller +import com.google.android.play.core.appupdate.AppUpdateManager +import com.google.android.play.core.appupdate.AppUpdateManagerFactory +import com.google.android.play.core.install.model.UpdateAvailability -internal class UpdatesMenu(private val activity: Activity, private val ui: Handler) { +internal class UpdatesMenu(private val activity: Activity, private val ui: Handler, + private val playManager: () -> AppUpdateManager = { AppUpdateManagerFactory.create(activity) }) { var catalog by mutableStateOf(null) var follow by mutableStateOf(AppUpdates.Follow(AppUpdates.Channel.STABLE)) var checking by mutableStateOf(false) @@ -26,12 +31,15 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl var stage by mutableStateOf(null) var percent by mutableIntStateOf(-1) var askPermission by mutableStateOf(false) + var playUpdateAvailable by mutableStateOf(null) + private var playCheckedAt by mutableStateOf(0L) private var pending: AppUpdates.Release? = null private var lastCheck = 0L private var request = 0 @Volatile private var session = -1 - fun state() = UpdatesState(catalog, follow, checking, error, stage, percent, askPermission) + fun state() = UpdatesState(catalog, follow, checking, error, stage, percent, askPermission, + playUpdateAvailable, playCheckedAt) fun actions() = UpdatesActions( onCheck = { check(force = true) }, @@ -39,15 +47,22 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl onInstall = ::install, onAllowInstalls = { askPermission = false - runCatching { activity.startActivity(SelfInstaller.permissionIntent(activity)) } - .onFailure { error = activity.getString(R.string.upd_unknown_apps_failed); pending = null } + if (!BuildConfig.PLAY_DISTRIBUTION) { + runCatching { activity.startActivity(SelfInstaller.permissionIntent(activity)) } + .onFailure { error = activity.getString(R.string.upd_unknown_apps_failed); pending = null } + } }, onDismissPermission = { askPermission = false; pending = null }, + onOpenPlay = ::openPlay, ) - val hasUpdate: Boolean get() = AppUpdates.hasUpdate(catalog, follow) + val hasUpdate: Boolean get() = if (BuildConfig.PLAY_DISTRIBUTION) playUpdateAvailable == true else AppUpdates.hasUpdate(catalog, follow) fun onResume() { + if (BuildConfig.PLAY_DISTRIBUTION) { + if (!SessionState.running) check(force = false) + return + } pending?.let { r -> if (SelfInstaller.canInstall(activity)) { pending = null; install(r) } } @@ -55,6 +70,10 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl } fun check(force: Boolean) { + if (BuildConfig.PLAY_DISTRIBUTION) { + checkPlay(force) + return + } if (checking || stage != null) return val now = System.currentTimeMillis() if (!force && now - lastCheck < 60_000) return @@ -75,6 +94,45 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl }, "app-updates").start() } + private fun checkPlay(force: Boolean) { + if (checking) return + val now = System.currentTimeMillis() + if (!force && now - lastCheck < 60_000) return + lastCheck = now + checking = true + error = null + val id = ++request + fun failed(failure: Throwable) { + if (id != request || activity.isDestroyed) return + checking = false + if (force) error = activity.getString(R.string.upd_couldnt_check, failure.message ?: failure.javaClass.simpleName) + } + runCatching { + playManager().appUpdateInfo.addOnSuccessListener { info -> + if (id != request || activity.isDestroyed) return@addOnSuccessListener + checking = false + val availability = info.updateAvailability() + playUpdateAvailable = when (availability) { + UpdateAvailability.UPDATE_AVAILABLE, UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS -> true + UpdateAvailability.UPDATE_NOT_AVAILABLE -> false + else -> null + } + playCheckedAt = now + }.addOnFailureListener { failed(it) } + }.onFailure { failed(it) } + } + + private fun openPlay() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + val listing = Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=${activity.packageName}")) + .setPackage("com.android.vending") + runCatching { activity.startActivity(listing) }.onFailure { + runCatching { + activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=${activity.packageName}"))) + }.onFailure { error = activity.getString(R.string.upd_couldnt_check, it.message ?: it.javaClass.simpleName) } + } + } + private fun choose(f: AppUpdates.Follow) { AppUpdates.setFollow(activity, f) follow = f @@ -82,6 +140,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl } private fun install(r: AppUpdates.Release) { + if (BuildConfig.PLAY_DISTRIBUTION) { openPlay(); return } if (stage != null) return val apk = r.apk ?: run { error = activity.getString(R.string.upd_no_download); return } AppUpdates.installBlock(r)?.let { error = it.message(activity); return } @@ -124,6 +183,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl @android.annotation.SuppressLint("UnspecifiedRegisterReceiverFlag") fun start() { + if (BuildConfig.PLAY_DISTRIBUTION) return catalog = AppUpdates.cached(activity) follow = AppUpdates.follow(activity, catalog) val filter = IntentFilter(SelfInstaller.ACTION_STATUS) @@ -132,6 +192,8 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl } fun unregister() { + request++ + checking = false runCatching { activity.unregisterReceiver(receiver) } } } 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 a42a43e07..82315dd0b 100644 --- a/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java +++ b/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java @@ -8,6 +8,7 @@ import com.droiddeck.launcher.core.FileUtils; import com.droiddeck.launcher.core.SessionPart; import com.droiddeck.launcher.core.HostProcess; import com.droiddeck.launcher.core.TarZst; +import com.droiddeck.launcher.BuildConfig; import java.io.File; import java.io.InputStream; @@ -114,6 +115,7 @@ public class PulseAudioComponent extends SessionPart { env.add("TMPDIR=" + workingDir); String command = HostProcess.LINKER + " " + workingDir.getAbsolutePath() + "/libpulseaudio.so" + + (BuildConfig.PLAY_DISTRIBUTION ? " --dl-search-path=" + modules.getAbsolutePath() : "") + " --system=false --disable-shm=true --fail=false" + " -n --file=default.pa --daemonize=false --use-pid-file=false --exit-idle-time=-1" + " --log-level=info"; diff --git a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt index 383dd98bb..742a4129b 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt @@ -95,8 +95,8 @@ internal class AddonPack( } val root = root(context).apply { mkdirs() } val archive = File(root, "$sha256.tar.zst") - val downloaded = bundled(context, archive) || urls.any { url -> - Downloader.downloadFile(url, archive, true, sha256) { p -> mutableState.value = State.Downloading(p.coerceIn(0f, 1f)) } + val downloaded = bundled(context, archive) || !BuildConfig.PLAY_DISTRIBUTION && urls.any { url -> + ComponentDownloads.downloadFile(url, archive, true, sha256) { p -> mutableState.value = State.Downloading(p.coerceIn(0f, 1f)) } .also { if (!it) archive.delete() } } if (!downloaded) return false diff --git a/app/src/main/java/com/droiddeck/launcher/core/ComponentDownloads.java b/app/src/main/java/com/droiddeck/launcher/core/ComponentDownloads.java new file mode 100644 index 000000000..c55df2a78 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/ComponentDownloads.java @@ -0,0 +1,91 @@ +package com.droiddeck.launcher.core; + +import android.content.Context; +import android.util.Log; +import com.droiddeck.launcher.BuildConfig; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; + +public final class ComponentDownloads { + private static volatile ComponentPayloadStore store; + + private ComponentDownloads() {} + + public static void init(Context context) { + if (BuildConfig.PLAY_DISTRIBUTION) { + Context application = context.getApplicationContext(); + store = new ComponentPayloadStore(path -> { + try { + return application.getAssets().open(path); + } catch (IOException error) { + throw new java.io.UncheckedIOException(error); + } + }); + } + } + + private static ComponentPayloadStore bundled() throws IOException { + ComponentPayloadStore current = store; + if (current == null) throw new IOException("Bundled component delivery is unavailable"); + return current; + } + + public static String catalogName(String name) { + return BuildConfig.PLAY_DISTRIBUTION ? "play-" + BuildConfig.SOURCE_COMMIT + "-" + name : name; + } + + public static String downloadString(String url) { + return downloadString(url, null); + } + + public static String downloadString(String url, BooleanSupplier cancelled) { + if (!BuildConfig.PLAY_DISTRIBUTION) return Downloader.downloadString(url, cancelled); + try { + return bundled().read(url, cancelled); + } catch (Exception error) { + Log.w("ComponentDownloads", "Bundled catalog unavailable: " + url, error); + return null; + } + } + + public static String downloadDirect(String url) { + return BuildConfig.PLAY_DISTRIBUTION ? downloadString(url) : Downloader.downloadDirect(url); + } + + public static long copyBundled(String url, OutputStream output, long limit, Consumer progress) throws IOException { + if (!BuildConfig.PLAY_DISTRIBUTION) throw new IOException("Bundled delivery requires a Play distribution"); + try { + return bundled().copy(url, output, limit, null, null, progress); + } catch (java.io.UncheckedIOException error) { + throw error.getCause(); + } catch (Exception error) { + if (error instanceof IOException) throw (IOException) error; + throw new IOException("Invalid bundled component index", error); + } + } + + public static boolean downloadFile(String url, File destination, boolean resume, Consumer progress) { + return downloadFile(url, destination, resume, null, null, progress); + } + + public static boolean downloadFile(String url, File destination, boolean resume, String expectedSha256, Consumer progress) { + return downloadFile(url, destination, resume, expectedSha256, null, progress); + } + + public static boolean downloadFile(String url, File destination, boolean resume, String expectedSha256, + BooleanSupplier cancelled, Consumer progress) { + if (!BuildConfig.PLAY_DISTRIBUTION) { + return Downloader.downloadFile(url, destination, resume, expectedSha256, cancelled, progress); + } + try { + bundled().install(url, destination, expectedSha256, cancelled, progress); + return true; + } catch (Exception error) { + Log.w("ComponentDownloads", "Bundled component unavailable: " + url, error); + return false; + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/core/ComponentPayloadStore.kt b/app/src/main/java/com/droiddeck/launcher/core/ComponentPayloadStore.kt new file mode 100644 index 000000000..6e1c0386c --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/ComponentPayloadStore.kt @@ -0,0 +1,127 @@ +package com.droiddeck.launcher.core + +import org.json.JSONObject +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.nio.file.Files +import java.nio.file.StandardCopyOption +import java.security.MessageDigest +import java.util.function.BooleanSupplier +import java.util.function.Consumer + +internal class ComponentPayloadStore(private val assets: (String) -> InputStream) { + private val entries by lazy { + val index = readObject("play-components/index.json", 2 * 1024 * 1024) + if (index.getInt("schema") != 1) throw IOException("Unsupported component index") + index.getJSONObject("entries") + } + + private fun readObject(path: String, limit: Int = INDEX_LIMIT): JSONObject { + val bytes = assets(path).use { input -> + val output = ByteArrayOutputStream() + val buffer = ByteArray(65536) + while (true) { + val count = input.read(buffer) + if (count < 0) break + if (output.size() + count > limit) throw IOException("Component metadata exceeds its size limit") + output.write(buffer, 0, count) + } + output.toByteArray() + } + return JSONObject(String(bytes, Charsets.UTF_8)) + } + + fun copy(url: String, output: OutputStream, limit: Long, expectedSha256: String? = null, + cancelled: BooleanSupplier? = null, progress: Consumer? = null): Long { + checkCancelled(cancelled) + val entry = entries.optJSONObject(url) ?: throw IOException("Component is absent from this build: $url") + val size = entry.getLong("size") + val digest = entry.getString("sha256") + if (size <= 0 || size > limit || !SHA256.matches(digest)) throw IOException("Invalid component metadata") + if (expectedSha256 != null && !digest.equals(expectedSha256, ignoreCase = true)) { + throw IOException("Component version does not match this build") + } + val recipe = "play-components/recipes/$digest.json" + if (entry.getString("recipe") != recipe) throw IOException("Invalid component recipe path") + val chunks = readObject(recipe).getJSONArray("chunks") + if (chunks.length() == 0) throw IOException("Component contains no payload") + val fullDigest = MessageDigest.getInstance("SHA-256") + val buffer = ByteArray(65536) + var total = 0L + var lastPercent = -1 + for (index in 0 until chunks.length()) { + checkCancelled(cancelled) + val chunk = chunks.getJSONObject(index) + val path = chunk.getString("asset") + val chunkSize = chunk.getLong("size") + val chunkSha256 = chunk.getString("sha256") + if (!ASSET.matches(path) || chunkSize <= 0 || chunkSize > size - total || !SHA256.matches(chunkSha256)) { + throw IOException("Invalid component chunk metadata") + } + val chunkDigest = MessageDigest.getInstance("SHA-256") + var copied = 0L + assets(path).use { input -> + while (true) { + checkCancelled(cancelled) + val count = input.read(buffer) + if (count < 0) break + if (count.toLong() > chunkSize - copied) throw IOException("Component chunk exceeds pinned size") + chunkDigest.update(buffer, 0, count) + fullDigest.update(buffer, 0, count) + output.write(buffer, 0, count) + copied += count + total += count + val percent = (total * 100 / size).toInt().coerceAtMost(99) + if (percent != lastPercent) { + lastPercent = percent + progress?.accept(percent / 100f) + } + } + } + if (copied != chunkSize || hex(chunkDigest.digest()) != chunkSha256) { + throw IOException("Component chunk failed verification") + } + } + checkCancelled(cancelled) + if (total != size || hex(fullDigest.digest()) != digest) throw IOException("Component failed verification") + progress?.accept(1f) + return total + } + + fun read(url: String, cancelled: BooleanSupplier? = null): String { + val output = ByteArrayOutputStream() + copy(url, output, INDEX_LIMIT.toLong(), cancelled = cancelled) + return output.toString(Charsets.UTF_8.name()) + } + + fun install(url: String, destination: File, expectedSha256: String? = null, + cancelled: BooleanSupplier? = null, progress: Consumer? = null) { + val parent = destination.absoluteFile.parentFile ?: throw IOException("Component destination has no parent") + Files.createDirectories(parent.toPath()) + val temporary = Files.createTempFile(parent.toPath(), destination.name + ".", ".component-part") + try { + Files.newOutputStream(temporary).use { output -> + copy(url, output, Long.MAX_VALUE, expectedSha256, cancelled, progress) + } + checkCancelled(cancelled) + Files.move(temporary, destination.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING) + } finally { + Files.deleteIfExists(temporary) + } + } + + private fun checkCancelled(cancelled: BooleanSupplier?) { + if (Thread.currentThread().isInterrupted || cancelled?.asBoolean == true) throw IOException("Component copy cancelled") + } + + private fun hex(bytes: ByteArray) = bytes.joinToString("") { "%02x".format(it.toInt() and 255) } + + companion object { + private const val INDEX_LIMIT = 16 * 1024 * 1024 + private val SHA256 = Regex("[0-9a-f]{64}") + private val ASSET = Regex("play-components/[0-9a-f]{64}/[0-9]{4,}") + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt b/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt index b9968ebdb..36a3a6c4c 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt @@ -13,6 +13,7 @@ import com.droiddeck.launcher.input.HomeButtonService import com.droiddeck.launcher.session.SessionPrefs object SteamIntegration { + private const val ACCESSIBILITY_CONSENT_VERSION = 1 const val ACTION_SETUP = "com.droiddeck.launcher.STEAM_INTEGRATION" const val EXTRA_FEATURE = "integration_feature" enum class Feature { WIFI, BRIGHTNESS, HOME, SHORTCUTS } @@ -36,7 +37,7 @@ object SteamIntegration { locationOn = WifiDiscovery.locationEnabled(context), brightness = Settings.System.canWrite(context), home = HomeApp.isDefault(context), - shortcuts = context.getSystemService(AccessibilityManager::class.java) + shortcuts = accessibilityConsented(context) && context.getSystemService(AccessibilityManager::class.java) .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK).any { val service = it.resolveInfo.serviceInfo ComponentName(service.packageName, service.name) == ComponentName(context, HomeButtonService::class.java) @@ -56,6 +57,14 @@ object SteamIntegration { private fun shortcutsComponent(context: Context) = ComponentName(context, HomeButtonService::class.java) + fun accessibilityConsented(context: Context): Boolean = + SessionPrefs.sessionPrefs(context).getInt("accessibility_consent", 0) == ACCESSIBILITY_CONSENT_VERSION + + fun acceptAccessibility(context: Context) { + SessionPrefs.sessionPrefs(context).edit().putInt("accessibility_consent", ACCESSIBILITY_CONSENT_VERSION).apply() + HomeButtonService.consentChanged() + } + fun shortcutsChosen(context: Context): Boolean = shortcutsSelection(context) == true private fun shortcutsSelection(context: Context): Boolean? { diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt b/app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt index 43540c0e2..102c69aa6 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt @@ -1,9 +1,10 @@ package com.droiddeck.launcher.gpu import com.droiddeck.launcher.core.DownloadSource -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.Hashes import com.droiddeck.launcher.R +import com.droiddeck.launcher.BuildConfig import android.content.Context import android.util.Log import com.droiddeck.launcher.core.FileUtils @@ -17,9 +18,9 @@ import java.net.URL object TurnipReleases { private const val TAG = "TurnipReleases" private const val PREFS = "turnip_releases" - private const val KEY_RELEASE = "latest" + private val KEY_RELEASE = ComponentDownloads.catalogName("latest") private const val KEY_DOWNLOADS = "downloads" - private const val KEY_PICKS = "autoPicks" + private val KEY_PICKS = ComponentDownloads.catalogName("autoPicks") class Asset(val source: String, val tag: String, val name: String, val url: String, val size: Long, val linux: Boolean, val label: String, val sha256: String = "", val pair: String = "", val bundle: Boolean = false) @@ -132,6 +133,8 @@ object TurnipReleases { } private fun get(context: Context, source: String, url: String): String { + if (BuildConfig.PLAY_DISTRIBUTION) return ComponentDownloads.downloadString(url) + ?: throw IOException("Driver catalog is absent from this build") val c = URL(source).openConnection() as HttpURLConnection c.connectTimeout = 15_000 c.readTimeout = 20_000 @@ -188,7 +191,7 @@ object TurnipReleases { fun download(context: Context, asset: Asset, progress: (Int) -> Unit): File { if (asset.sha256.isEmpty()) throw IOException(context.getString(R.string.turnip_list_predates_checksums)) val target = File(context.cacheDir, asset.name) - val ok = Downloader.downloadFile(asset.url, target, true, asset.sha256) { f -> progress(if (f < 0) -1 else (f * 100).toInt()) } + val ok = ComponentDownloads.downloadFile(asset.url, target, true, asset.sha256) { f -> progress(if (f < 0) -1 else (f * 100).toInt()) } if (!ok) throw IOException(context.getString(R.string.turnip_download_failed)) if (!asset.sha256.equals(Hashes.sha256(target), ignoreCase = true)) { FileUtils.delete(target) diff --git a/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt b/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt index 90ba37f23..f82fab3f4 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt @@ -9,6 +9,8 @@ import android.os.Looper import android.view.KeyEvent import android.view.accessibility.AccessibilityEvent import com.droiddeck.launcher.HomeApp +import com.droiddeck.launcher.core.SteamIntegration +import java.lang.ref.WeakReference object HomeButtonShortcuts { private var owner: Any? = null @@ -47,10 +49,20 @@ object HomeButtonShortcuts { class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListener { private var bottomScreen: BottomScreenWatch? = null + private var consented = false override fun onServiceConnected() { + current = WeakReference(this) getSystemService(InputManager::class.java).registerInputDeviceListener(this, Handler(Looper.getMainLooper())) - if (android.os.Build.VERSION.SDK_INT >= 33 && bottomScreen == null && BottomScreenGuests.supported()) bottomScreen = BottomScreenWatch(this).also { it.start() } + updateConsent() + } + + private fun updateConsent() { + consented = SteamIntegration.accessibilityConsented(this) + if (consented && android.os.Build.VERSION.SDK_INT >= 33 && bottomScreen == null && BottomScreenGuests.supported()) { + bottomScreen = BottomScreenWatch(this).also { it.start() } + } + if (!consented) stopBottomScreen() } private fun stopBottomScreen() { @@ -58,7 +70,7 @@ class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListen bottomScreen = null } - override fun onKeyEvent(event: KeyEvent) = HomeButtonShortcuts.onKeyEvent(this, event) + override fun onKeyEvent(event: KeyEvent) = consented && HomeButtonShortcuts.onKeyEvent(this, event) override fun onAccessibilityEvent(event: AccessibilityEvent?) { if (android.os.Build.VERSION.SDK_INT >= 33) event?.let { bottomScreen?.onEvent(it) } } override fun onInterrupt() { HomeButtonShortcuts.release() } override fun onInputDeviceAdded(deviceId: Int) {} @@ -66,6 +78,8 @@ class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListen override fun onInputDeviceRemoved(deviceId: Int) { HomeButtonShortcuts.onDeviceRemoved(deviceId) } override fun onUnbind(intent: Intent?): Boolean { + if (current?.get() === this) current = null + consented = false HomeButtonShortcuts.release() stopBottomScreen() com.droiddeck.launcher.core.SteamIntegration.syncShortcutsListing(this) @@ -73,9 +87,16 @@ class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListen } override fun onDestroy() { + if (current?.get() === this) current = null HomeButtonShortcuts.release() stopBottomScreen() getSystemService(InputManager::class.java).unregisterInputDeviceListener(this) super.onDestroy() } + + companion object { + private var current: WeakReference? = null + + fun consentChanged() { current?.get()?.updateConsent() } + } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt index e8631c1ea..76413cee7 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt @@ -329,6 +329,7 @@ object BwrapSpawner { val verbose = plan.env["DROIDDECK_PROOT_VERBOSE"]?.toIntOrNull() if (verbose != null) { cmd.add(1, "-v"); cmd.add(2, verbose.toString()) } plan.binds.forEach { cmd.add("-b"); cmd.add(it.spec) } + LinuxRuntime.bindComponentBundles(context, plan.root, cmd) cmd.add(plan.envTool) cmd.add("-i") plan.env.forEach { (k, v) -> cmd.add("$k=$v") } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt b/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt index c45c74821..d59bf787a 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt @@ -4,7 +4,7 @@ import com.droiddeck.launcher.core.Hashes import android.content.Context import android.util.Log import com.droiddeck.launcher.R -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.core.ArchivePaths import java.io.BufferedInputStream @@ -101,7 +101,7 @@ object DeckyManager { } fun releaseChannels(context: Context): ReleaseChannels { - val body = Downloader.downloadString(RELEASES) ?: return ReleaseChannels(emptyList(), emptyList()) + val body = ComponentDownloads.downloadString(RELEASES) ?: return ReleaseChannels(emptyList(), emptyList()) return try { val array = JSONArray(body) val stable = mutableListOf() @@ -141,11 +141,11 @@ object DeckyManager { target.parentFile?.mkdirs() val temp = File(target.parentFile, "PluginLoader.download") val downloading = context.getString(R.string.user_apps_downloading, release.tag) - val ok = Downloader.downloadFile(release.url, temp, true, release.digest?.substringAfter(':')) { f -> progress(downloading, if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) } + val ok = ComponentDownloads.downloadFile(release.url, temp, true, release.digest?.substringAfter(':')) { f -> progress(downloading, if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) } if (!ok) { temp.delete(); return context.getString(R.string.deckymgr_download_failed) } if (temp.length() != release.size) { temp.delete(); return context.getString(R.string.deckymgr_size_mismatch) } val expected = release.digest?.substringAfter(':') ?: release.shaUrl?.let { checksumUrl -> - val checksumBody = Downloader.downloadDirect(checksumUrl) ?: run { temp.delete(); return context.getString(R.string.deckymgr_checksum_download_failed) } + val checksumBody = ComponentDownloads.downloadDirect(checksumUrl) ?: run { temp.delete(); return context.getString(R.string.deckymgr_checksum_download_failed) } Regex("(?i)\\b[0-9a-f]{64}\\b").find(checksumBody)?.value } ?: run { temp.delete(); return context.getString(R.string.deckymgr_checksum_missing) } if (!expected.matches(Regex("(?i)[0-9a-f]{64}"))) { temp.delete(); return context.getString(R.string.deckymgr_checksum_invalid) } @@ -270,7 +270,7 @@ object DeckyManager { downloadingBinary = true progress(downloading, -1) val downloaded = try { - Downloader.downloadFile(url, temp, true, hash) { fraction -> + ComponentDownloads.downloadFile(url, temp, true, hash) { fraction -> progress(downloading, if (fraction < 0) -1 else (fraction * 100).toInt().coerceIn(0, 100)) } } finally { diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt b/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt index e3cbecd1d..ed3afe076 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt @@ -6,6 +6,7 @@ import android.util.Log import com.droiddeck.launcher.BuildConfig import com.droiddeck.launcher.R import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.FileUtils import org.json.JSONObject import java.io.File @@ -22,8 +23,10 @@ object DesktopCatalog { val icon: String, val category: String, ) + internal fun offered(entry: Entry): Boolean = !BuildConfig.PLAY_DISTRIBUTION || entry.id == DESKTOP_ID || entry.id == "desktop" + fun fetch(url: String = CATALOG_URL, cancelled: java.util.function.BooleanSupplier? = null): List? { - val body = Downloader.downloadString(url, cancelled) ?: return null + val body = ComponentDownloads.downloadString(url, cancelled) ?: return null return try { val json = JSONObject(body) val arr = json.getJSONArray("packages") @@ -39,7 +42,7 @@ object DesktopCatalog { file.optLong("size", 0L), o.optString("notes", ""), o.optString("icon", "applications-games"), o.optString("category", "Game"), ) - } + }.filter(::offered) } catch (e: Exception) { Log.w(TAG, "catalog: $e"); null } @@ -51,7 +54,7 @@ object DesktopCatalog { private fun journal(root: File, id: String) = File(root, ".droiddeck-pkg-$id$JOURNAL_SUFFIX") - fun interrupted(context: Context): List = interrupted(LinuxRuntime.rootDir(context)) + fun interrupted(context: Context): List = interrupted(LinuxRuntime.rootDir(context)).filter(::offered) fun interrupted(root: File): List = root.listFiles { f -> f.name.startsWith(".droiddeck-pkg-") && f.name.endsWith(JOURNAL_SUFFIX) }.orEmpty() @@ -63,7 +66,7 @@ object DesktopCatalog { private fun downloadFile(context: Context, entry: Entry) = File(context.cacheDir, "pkg-${entry.id}-${entry.sha256.take(12)}.download") fun pruneDownloads(context: Context) = synchronized(installLock) { - val keep = interrupted(context).map { downloadFile(context, it).name }.toSet() + val keep = interrupted(LinuxRuntime.rootDir(context)).map { downloadFile(context, it).name }.toSet() context.cacheDir.listFiles { f -> f.name.startsWith("pkg-") && f.name.removeSuffix(".resume.properties").endsWith(".download") } ?.filter { it.name.removeSuffix(".resume.properties") !in keep }?.forEach { it.delete() } } @@ -107,9 +110,13 @@ object DesktopCatalog { fun installed(context: Context, id: String): String? = FileUtils.readString(marker(context, id))?.trim()?.takeIf { it.isNotEmpty() } - fun protonSeedNeeded(context: Context): Boolean = - installed(context, PROTON_SEED_ID) == null && + fun protonSeedNeeded(context: Context): Boolean { + if (BuildConfig.PLAY_DISTRIBUTION) return com.droiddeck.launcher.session.ProtonExtras.installed( + context, com.droiddeck.launcher.session.ProtonExtras.tools.single(), + ) == null + return installed(context, PROTON_SEED_ID) == null && !File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps/appmanifest_4427310.acf").isFile + } const val DESKTOP_ID = "desktop-kde" const val EMULATORS_ID = "emulators" @@ -172,6 +179,7 @@ object DesktopCatalog { private fun installLocked(context: Context, entry: Entry, cancelled: Downloader.Cancellation?, listener: LinuxRuntimeInstaller.ProgressListener?): String? { + if (!offered(entry)) return context.getString(R.string.deskpkg_install_failed) val root = LinuxRuntime.rootDir(context) if (!root.isDirectory) return context.getString(R.string.deskpkg_runtime_missing) if (entry.id == EMULATORS_ID && desktopFromPack(root)) return installEmulators(context, entry, cancelled, listener) @@ -195,9 +203,9 @@ object DesktopCatalog { report.onProgress(LinuxRuntimeInstaller.Step.DOWNLOADING, downloading, if (f < 0) -1 else Math.round(f * 100f)) } val ok = if (cancelled == null) { - Downloader.downloadFile(entry.url, download, true, entry.sha256, progress) + ComponentDownloads.downloadFile(entry.url, download, true, entry.sha256, progress) } else { - Downloader.downloadFile(entry.url, download, true, entry.sha256, cancelled, progress) + ComponentDownloads.downloadFile(entry.url, download, true, entry.sha256, cancelled, progress) } if (!ok || cancelled?.getAsBoolean() == true) return context.getString(R.string.user_apps_download_failed) report.onProgress(LinuxRuntimeInstaller.Step.VERIFYING, context.getString(R.string.rtinst_verifying), -1) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 11c7a186e..bff72fb14 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -10,6 +10,7 @@ import com.droiddeck.launcher.session.SessionPaths import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.util.concurrent.atomic.AtomicBoolean +import java.util.function.BooleanSupplier object GuestCommand { fun run(context: Context, argv: List, fakeRoot: Boolean = false, logName: String? = null, @@ -22,14 +23,19 @@ object GuestCommand { } log?.println("== ${java.util.Date()} ${argv.joinToString(" ")}") try { - return runLogged(context, argv, fakeRoot, linkDir, extraBinds, fastPath, cancelled) { line -> log?.println(line); log?.flush(); onLine(line) } + return runLogged(context, argv, fakeRoot, linkDir, extraBinds, fastPath, + cancelled?.let { flag -> BooleanSupplier { flag.get() } }) { line -> log?.println(line); log?.flush(); onLine(line) } } finally { log?.close() } } + fun runCancellable(context: Context, argv: List, cancelled: BooleanSupplier?, onLine: (String) -> Unit): Int = + runLogged(context, argv, false, null, null, false, cancelled, onLine) + private fun runLogged(context: Context, argv: List, fakeRoot: Boolean, linkDir: File?, extraBinds: List?, - fastPath: Boolean, cancelled: AtomicBoolean?, onLine: (String) -> Unit): Int { + fastPath: Boolean, cancelled: BooleanSupplier?, onLine: (String) -> Unit): Int { + if (cancelled?.asBoolean == true || Thread.currentThread().isInterrupted) return 130 val root = LinuxRuntime.rootDir(context) LinuxRuntime.writeAccounts(context) SessionFiles.stage(context, root) @@ -65,7 +71,7 @@ object GuestCommand { fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> put(k, v) } } LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } - if (cancelled?.get() == true) return 130 + if (cancelled?.asBoolean == true) return 130 val process = builder.start() val pid = HostProcess.pidOf(process) OrphanReaper.keep(pid) @@ -74,8 +80,8 @@ object GuestCommand { val flag = cancelled Thread({ try { - while (process.isAlive && flag?.get() != true && !caller.isInterrupted) Thread.sleep(200) - if (flag?.get() == true || caller.isInterrupted) { + while (process.isAlive && flag?.asBoolean != true && !caller.isInterrupted) Thread.sleep(200) + if (flag?.asBoolean == true || caller.isInterrupted) { if (pid > 0) { runCatching { android.system.Os.kill(pid, android.system.OsConstants.SIGQUIT) } } else { 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 7e95d7423..b3e0f689c 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java @@ -1,6 +1,8 @@ package com.droiddeck.launcher.runtime; import com.droiddeck.launcher.core.AddonPack; +import com.droiddeck.launcher.BuildConfig; +import com.droiddeck.launcher.core.ArchivePaths; import android.content.Context; import android.os.Process; import android.system.ErrnoException; @@ -89,10 +91,12 @@ public final class LinuxRuntime { } public static boolean patchedProot(Context context) { + if (BuildConfig.PLAY_DISTRIBUTION) return bundledProotReady(context); return bundledProotReady(context) || AddonPack.PROOT.installed(context); } public static File prootBinary(Context context) { + if (BuildConfig.PLAY_DISTRIBUTION) return bundledProot(context, "libproot.so"); if (bundledProotReady(context)) return bundledProot(context, "libproot.so"); if (AddonPack.PROOT.installed(context)) return AddonPack.PROOT.file(context, "libproot.so"); if (SessionPrefs.allowStockProot(context)) return rootfsProot(context); @@ -100,6 +104,7 @@ public final class LinuxRuntime { } public static File prootLoader(Context context) { + if (BuildConfig.PLAY_DISTRIBUTION) return bundledProot(context, "libproot-loader.so"); if (bundledProotReady(context)) return bundledProot(context, "libproot-loader.so"); if (AddonPack.PROOT.installed(context)) return AddonPack.PROOT.file(context, "libproot-loader.so"); if (SessionPrefs.allowStockProot(context)) return rootfsLoader(context); @@ -274,6 +279,7 @@ public final class LinuxRuntime { bindGpuNode(context, cmd); bindAdrenoStats(cmd, extraBinds); bindCpuTemps(cmd, root); + bindComponentBundles(context, root, cmd); if (extraBinds != null) { for (String spec : extraBinds) bind(cmd, spec); } @@ -282,6 +288,27 @@ public final class LinuxRuntime { return specs; } + public static void bindComponentBundles(Context context, File root, List command) { + if (!BuildConfig.PLAY_DISTRIBUTION) return; + java.util.LinkedHashSet directories = new java.util.LinkedHashSet<>(); + directories.add(new File(context.getApplicationInfo().sourceDir).getParentFile()); + String[] splits = context.getApplicationInfo().splitSourceDirs; + if (splits != null) for (String split : splits) directories.add(new File(split).getParentFile()); + int index = 0; + for (File directory : directories) { + File target; + try { + target = ArchivePaths.inside(root, "opt/droiddeck-bundles/" + index++); + } catch (IOException error) { + throw new IllegalStateException("Installed component bundle mount is invalid", error); + } + if (directory == null || !directory.isDirectory() || target == null || !target.isDirectory() && !target.mkdirs()) { + throw new IllegalStateException("Installed component bundles cannot be mounted"); + } + bind(command, directory.getPath() + ":/" + root.toPath().relativize(target.toPath()).toString()); + } + } + private static boolean unreadablePciDevice() { File[] devices = new File("/sys/bus/pci/devices").listFiles(); if (devices == null) return false; diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntimeInstaller.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntimeInstaller.java index 1070e306a..a9b99dc4f 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntimeInstaller.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntimeInstaller.java @@ -8,7 +8,7 @@ import android.util.Log; import com.droiddeck.launcher.R; import com.droiddeck.launcher.session.SessionPrefs; import com.droiddeck.launcher.core.ArchivePaths; -import com.droiddeck.launcher.core.Downloader; +import com.droiddeck.launcher.core.ComponentDownloads; import com.droiddeck.launcher.core.Hashes; import com.droiddeck.launcher.core.FileUtils; @@ -104,7 +104,7 @@ public final class LinuxRuntimeInstaller { } public static Release fetchRelease() { - String body = Downloader.downloadString(catalogUrl()); + String body = ComponentDownloads.downloadString(catalogUrl()); if (body == null || body.isEmpty()) return null; try { JSONObject json = new JSONObject(body); @@ -288,7 +288,7 @@ public final class LinuxRuntimeInstaller { && !SessionPrefs.allowStockProot(context)) throw new IOException("Cannot download proot"); if (!AddonPack.DIRECTAUDIO.await(context)) throw new IOException("Cannot download DirectAudio"); - boolean ok = Downloader.downloadFile(release.url, archive, true, release.sha256, (fraction) -> { + boolean ok = ComponentDownloads.downloadFile(release.url, archive, true, release.sha256, (fraction) -> { if (listener != null) { listener.onProgress(Step.DOWNLOADING, downloading, fraction < 0 ? -1 : Math.round(fraction * 100f)); 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 b1d70902a..00886b61d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -4,7 +4,7 @@ import com.droiddeck.launcher.core.Hashes import com.droiddeck.launcher.R import android.content.Context import android.util.Log -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.core.GameEnvironment import com.droiddeck.launcher.gpu.GpuInfo @@ -87,7 +87,7 @@ object ComponentsManager { private fun packagesDir(context: Context) = File(dataDir(context), "packages").apply { mkdirs() } private fun originalsDir(context: Context) = File(dataDir(context), "originals").apply { mkdirs() } private fun stateFile(context: Context) = File(dataDir(context), "state.json") - private fun catalogFile(context: Context) = File(dataDir(context), "catalog.json") + private fun catalogFile(context: Context) = File(dataDir(context), ComponentDownloads.catalogName("catalog.json")) private const val LAUNCH_DIR = "root/.local/share/droiddeck-components" private const val LEGACY_LAUNCH_DIR = "root/.local/share/bannerlator-components" private fun launchDir(context: Context): File { @@ -283,6 +283,7 @@ object ComponentsManager { for ((base, valve) in bases) { val entries = base.listFiles()?.sortedBy { it.name } ?: continue for (dir in entries) { + if (com.droiddeck.launcher.BuildConfig.PLAY_DISTRIBUTION && (valve || !dir.name.startsWith("DroidDeck-Proton"))) continue if (!File(dir, WINE).isDirectory || !File(dir, "proton").isFile) continue val real = runCatching { dir.canonicalPath }.getOrDefault(dir.path) if (found.containsKey(real)) continue @@ -945,7 +946,7 @@ object ComponentsManager { if (!force) return Catalog(emptyList(), 0) val items = JSONArray() for ((repo, tag) in SOURCES) { - val body = Downloader.downloadString("https://api.github.com/repos/$repo/releases/tags/$tag") ?: continue + val body = ComponentDownloads.downloadString("https://api.github.com/repos/$repo/releases/tags/$tag") ?: continue val assets = runCatching { JSONObject(body).optJSONArray("assets") }.getOrNull() ?: continue for (i in 0 until assets.length()) { val a = assets.getJSONObject(i) @@ -1079,7 +1080,7 @@ object ComponentsManager { require(Hashes.isGithubSha256(item.digest)) { context.getString(R.string.cmgr_list_predates_checksums) } val dest = File(packagesDir(context), safeName(item.file)) val part = File(dest.parentFile, dest.name + ".part") - check(Downloader.downloadFile(item.url, part, true, item.digest.substringAfter(':')) { f -> progress(if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) }) { + check(ComponentDownloads.downloadFile(item.url, part, true, item.digest.substringAfter(':')) { f -> progress(if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) }) { context.getString(if (item.release == DD_NIGHTLY) R.string.cmgr_nightly_replaced else R.string.user_apps_download_failed) } if (!Hashes.sha256(part).equals(item.digest.substringAfter(':'), true)) { part.delete(); error(context.getString(R.string.cmgr_checksum_mismatch)) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/EsyncPacks.kt b/app/src/main/java/com/droiddeck/launcher/session/EsyncPacks.kt index 60044ccb8..660172ba0 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/EsyncPacks.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/EsyncPacks.kt @@ -2,6 +2,8 @@ package com.droiddeck.launcher.session import android.content.Context import android.util.Log +import com.droiddeck.launcher.BuildConfig +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.core.Hashes @@ -861,8 +863,17 @@ object EsyncPacks { return null } - private fun fetch(url: String, limit: Long, out: OutputStream, progress: ((Long) -> Unit)?): Boolean = - fetcher(url, limit, out, progress) + private fun fetch(url: String, limit: Long, out: OutputStream, progress: ((Long) -> Unit)?): Boolean { + if (!BuildConfig.PLAY_DISTRIBUTION) return fetcher(url, limit, out, progress) + return try { + val bytes = ComponentDownloads.copyBundled(url, out, limit, null) + progress?.invoke(bytes) + true + } catch (error: IOException) { + Log.w(TAG, "Bundled synchronization component unavailable: $url", error) + false + } + } private fun httpFetch(url: String, limit: Long, out: OutputStream, progress: ((Long) -> Unit)?): Boolean { var connection: HttpURLConnection? = null diff --git a/app/src/main/java/com/droiddeck/launcher/session/FexCatalog.kt b/app/src/main/java/com/droiddeck/launcher/session/FexCatalog.kt index d3471283e..b1b57e69c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/FexCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/FexCatalog.kt @@ -3,7 +3,7 @@ package com.droiddeck.launcher.session import android.content.Context import android.util.Log import com.droiddeck.launcher.core.DownloadSource -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import org.json.JSONObject import java.io.File @@ -20,7 +20,7 @@ object FexCatalog { @Volatile private var refreshedAt = 0L - private fun file(context: Context) = File(context.filesDir, "fex-catalog.json") + private fun file(context: Context) = File(context.filesDir, ComponentDownloads.catalogName("fex-catalog.json")) internal fun parse(text: String): Build? = runCatching { val o = JSONObject(text) @@ -42,7 +42,7 @@ object FexCatalog { fun refresh(context: Context, now: Long = System.currentTimeMillis()): Build? { if (now - refreshedAt < REFRESH_MS) return cached(context) refreshedAt = now - val text = Downloader.downloadDirect(CATALOG_URL) ?: return cached(context) + val text = ComponentDownloads.downloadDirect(CATALOG_URL) ?: return cached(context) val build = parse(text) ?: run { Log.w(TAG, "fex.json not usable; keeping the last one") return cached(context) 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 962291d2c..c45f718ac 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt @@ -2,13 +2,15 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.core.Hashes import com.droiddeck.launcher.R +import com.droiddeck.launcher.BuildConfig import android.content.Context import android.os.StatFs import android.util.Log -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.runtime.LinuxRuntime import java.io.File +import java.util.function.BooleanSupplier import org.json.JSONArray import org.json.JSONObject @@ -30,17 +32,19 @@ object ProtonExtras { const val OWN = "droiddeck" - val tools = listOf( + internal val sources = listOf( Tool("ge", "GE-Proton", "GE-Proton", "GloriousEggroll/proton-ge-custom", Regex("aarch64\\.tar\\.(gz|xz)$")), Tool("cachyos", "proton-cachyos", "proton-cachyos", "CachyOS/proton-cachyos", Regex("arm64\\.tar\\.(gz|xz)$")), - Tool("droiddeck", "DroidDeck-Proton", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("aarch64\\.tar\\.(gz|xz)$")), + Tool("droiddeck", "DroidDeck-Proton", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex(if (BuildConfig.PLAY_DISTRIBUTION) "aarch64\\.tar\\.(gz|xz|zst)$" else "aarch64\\.tar\\.(gz|xz)$")), ) + val tools = sources.filter { !BuildConfig.PLAY_DISTRIBUTION || it.id == OWN } + private fun home(context: Context) = File(LinuxRuntime.rootDir(context), "root") private fun requests(context: Context) = File(home(context), ".bl-proton-extra") private fun toolsDir(context: Context) = File(home(context), ".local/share/Steam/compatibilitytools.d") private fun releasesFile(context: Context) = File(context.filesDir, "proton-extras.json") - private fun latestFile(context: Context) = File(context.filesDir, "proton-latest.json") + private fun latestFile(context: Context) = File(context.filesDir, ComponentDownloads.catalogName("proton-latest.json")) fun installed(context: Context, tool: Tool): String? = installedIn(toolsDir(context), tool).lastOrNull() @@ -200,13 +204,17 @@ object ProtonExtras { } @Synchronized - fun install(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? { + fun install(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? = install(context, tool, null, onProgress) + + @Synchronized + fun install(context: Context, tool: Tool, cancelled: BooleanSupplier?, onProgress: (String, Int) -> Unit): String? { if (installInProgress) return context.getString(R.string.pextra_busy) installInProgress = true - return try { installNow(context, tool, onProgress) } finally { installInProgress = false } + return try { installNow(context, tool, cancelled, onProgress) } finally { installInProgress = false } } - private fun installNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? { + private fun installNow(context: Context, tool: Tool, cancelled: BooleanSupplier?, onProgress: (String, Int) -> Unit): String? { + if (cancelled?.asBoolean == true || Thread.currentThread().isInterrupted) return context.getString(R.string.pextra_interrupted) if (SessionState.running) return context.getString(R.string.pextra_stop_session) if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required) @@ -223,10 +231,12 @@ object ProtonExtras { onProgress(downloading, 0) var downloaded = false for (attempt in 0 until 5) { - downloaded = Downloader.downloadFile(asset.url, archive, true, asset.sha256) { fraction -> + if (cancelled?.asBoolean == true || Thread.currentThread().isInterrupted) return context.getString(R.string.pextra_interrupted) + downloaded = ComponentDownloads.downloadFile(asset.url, archive, true, asset.sha256, cancelled) { fraction -> onProgress(downloading, if (fraction < 0) -1 else (fraction * 100f).toInt().coerceIn(0, 100)) } if (downloaded) break + if (cancelled?.asBoolean == true) return context.getString(R.string.pextra_interrupted) if (attempt < 4) { onProgress(context.getString(R.string.pextra_retrying, attempt + 2, 5), -1) try { Thread.sleep(3_000) } catch (_: InterruptedException) { @@ -248,7 +258,7 @@ object ProtonExtras { val verified = when { asset.sha256 != null -> asset.sha256.equals(Hashes.sha256(archive), ignoreCase = true) asset.sha512 != null -> { - val expected = Downloader.downloadDirect(asset.sha512)?.let { Regex("(?i)\\b[0-9a-f]{128}\\b").find(it)?.value } + val expected = ComponentDownloads.downloadDirect(asset.sha512)?.let { Regex("(?i)\\b[0-9a-f]{128}\\b").find(it)?.value } ?: return context.getString(R.string.pextra_checksum_unreadable) expected.equals(Hashes.sha512(archive), ignoreCase = true) } @@ -263,38 +273,23 @@ object ProtonExtras { } if (SessionState.running) return context.getString(R.string.pextra_session_started) + if (cancelled?.asBoolean == true || Thread.currentThread().isInterrupted) return context.getString(R.string.pextra_interrupted) val installing = context.getString(R.string.pextra_installing, tool.name) onProgress(installing, -1) return try { val root = LinuxRuntime.rootDir(context) - LinuxRuntime.writeAccounts(context) - com.droiddeck.launcher.session.SessionFiles.stage(context, root) - val runtimeDir = File(context.filesDir, ".proton-install-rt").apply { mkdirs() } val guest = listOf( - "/usr/bin/env", "-i", "HOME=/root", "USER=root", "PATH=/usr/local/bin:/usr/bin:/bin", - "LANG=C.UTF-8", "XDG_DATA_HOME=/root/.local/share", "/usr/local/bin/droiddeck-proton-extra", "/root/.local/share/Steam", archive.absolutePath, ) - val command = LinuxRuntime.command(context, null, runtimeDir, null, guest) - val process = ProcessBuilder(command) - .directory(root) - .redirectErrorStream(true) - val hostEnv = process.environment() - hostEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(context).path - hostEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(context).path - LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { hostEnv["LD_LIBRARY_PATH"] = it } - val child = process.start() var placed: String? = null - child.inputStream.bufferedReader().useLines { lines -> - lines.forEach { line -> - Log.i(TAG, line) - line.substringAfter("droiddeck-proton-extra: installed ", "").takeIf { it.isNotEmpty() }?.let { placed = it } - if (line.contains("unpacking", ignoreCase = true) || line.contains("adopted", ignoreCase = true)) { - onProgress(installing, -1) - } + val status = com.droiddeck.launcher.runtime.GuestCommand.runCancellable(context, guest, cancelled) { line -> + Log.i(TAG, line) + line.substringAfter("droiddeck-proton-extra: installed ", "").takeIf { it.isNotEmpty() }?.let { placed = it } + if (line.contains("unpacking", ignoreCase = true) || line.contains("adopted", ignoreCase = true)) { + onProgress(installing, -1) } } - val status = child.waitFor() + if (cancelled?.asBoolean == true || Thread.currentThread().isInterrupted) return context.getString(R.string.pextra_interrupted) if (status != 0) context.getString(R.string.pextra_install_failed, tool.name, status) else { archive.delete() @@ -318,7 +313,7 @@ object ProtonExtras { } private fun findLatestAsset(tool: Tool): Asset? { - val releases = Downloader.downloadString(RELEASES.format(tool.repo)) ?: return null + val releases = ComponentDownloads.downloadString(RELEASES.format(tool.repo)) ?: return null return try { pickAsset(tool, JSONArray(releases)) } catch (e: Exception) { @@ -341,7 +336,9 @@ object ProtonExtras { }?.optString("browser_download_url")?.takeIf { it.startsWith("http") } return Asset( release.optString("tag_name"), name, - archive.optString("browser_download_url").takeIf { it.startsWith("http") } ?: continue, checksum, + archive.optString("browser_download_url").takeIf { + it.startsWith("http") || BuildConfig.PLAY_DISTRIBUTION && it.startsWith("droiddeck-bundle://") + } ?: continue, checksum, archive.optLong("size", 0L), Hashes.githubSha256(archive.optString("digest")), ) 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 09122644d..ab5576c79 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -45,6 +45,7 @@ object SessionFiles { "usr/local/bin/droiddeck-esync" to "usr/local/bin/droiddeck-esync", "usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat", "usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex", + "usr/local/lib/droiddeck/component_delivery.py" to "usr/local/lib/droiddeck/component_delivery.py", "libblsession.so" to "usr/local/lib/libblsession.so", "libfakeinput.so" to "usr/local/lib/libfakeinput.so", "libblfastpath.so" to "usr/local/lib/libblfastpath.so", 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 82dd9a71b..533f0dd76 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.session +import com.droiddeck.launcher.BuildConfig + import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.gpu.LinuxVulkanDriver import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager @@ -844,7 +846,8 @@ class SessionService : Service() { SessionArtifacts.markSteamLogs(it, File(SessionPrefs.steamRoot(this, arch), "logs")) } } - FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) } + (if (BuildConfig.PLAY_DISTRIBUTION) FexCatalog.refresh(this) else FexCatalog.cached(this)) + ?.let { guest.addAll(FexCatalog.environment(it)) } if (SessionState.mode == MODE_STEAM) { guest.add("BL_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0")) } 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 21398bc4c..a85e798c0 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt @@ -4,7 +4,7 @@ import android.content.Context import android.util.AtomicFile import android.util.Log import com.droiddeck.launcher.core.ArchivePaths -import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.core.ComponentDownloads import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.runtime.GuestCommand import com.droiddeck.launcher.runtime.LinuxRuntime @@ -86,13 +86,13 @@ object WinComponents { private val SNAPSHOT_COVERS = INSTALLER_STEPS + setOf("download_archive", "archive_extract", "copy_dll", "copy_file") + OFFLINE_STEPS - fun fetch(): List? = Downloader.downloadString(CATALOG_URL)?.let { parse(it) } + fun fetch(): List? = ComponentDownloads.downloadString(CATALOG_URL)?.let { parse(it) } - private const val CATALOG_CACHE = "wincomponents-catalog.json" + private val CATALOG_CACHE = ComponentDownloads.catalogName("wincomponents-catalog.json") fun fetch(context: Context): List? { val cache = File(context.filesDir, CATALOG_CACHE) - Downloader.downloadString(CATALOG_URL)?.let { body -> + ComponentDownloads.downloadString(CATALOG_URL)?.let { body -> parse(body)?.let { runCatching { write(cache, body) }; return it } } return runCatching { parse(cache.readText()) }.getOrNull() @@ -241,7 +241,7 @@ object WinComponents { val byRuntime = name.lowercase().let { it.endsWith(".exe") || it.endsWith(".cab") } val file = if (byRuntime) File(root, "$MSI_CACHE/${archives.size}-$name").apply { parentFile?.mkdirs() } else File(work, "${archives.size}-$name") - val ok = Downloader.downloadFile(url, file, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) } + val ok = ComponentDownloads.downloadFile(url, file, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) } if (!ok) return "download failed: $name" step.str("file_checksum").takeIf { it.length == 32 }?.let { md5 -> if (!digest(file, "MD5").equals(md5, ignoreCase = true)) return "checksum mismatch: $name" @@ -368,7 +368,7 @@ object WinComponents { val root = LinuxRuntime.rootDir(context) val name = c.snapshot.substringAfterLast('/') val json = File(work, "${c.name}.snapshot.json") - if (!Downloader.downloadFile(c.snapshot, json, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { + if (!ComponentDownloads.downloadFile(c.snapshot, json, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { return null to "download failed: $name" } val snapshot = runCatching { JSONObject(json.readText()) }.getOrNull() ?: return null to "the recording could not be read" @@ -384,7 +384,7 @@ object WinComponents { val url = c.snapshot.substringBeforeLast('/') + "/" + archiveName val file = File(work, "${c.name}.files.tar.xz") val sha = archive.optString("sha256").takeIf { it.matches(Regex("(?i)[0-9a-f]{64}")) } - if (!Downloader.downloadFile(url, file, false, sha) { f -> onProgress(Progress(c.name, archiveName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { + if (!ComponentDownloads.downloadFile(url, file, false, sha) { f -> onProgress(Progress(c.name, archiveName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { return null to "download failed: $archiveName" } archive.optString("sha256").takeIf { it.length == 64 }?.let { sha -> @@ -403,7 +403,7 @@ object WinComponents { val installer = File(cache, "${c.name}-snapshot-src.bin") var unpacked: File? = null try { - if (!Downloader.downloadFile(url, installer, false) { f -> onProgress(Progress(c.name, installerName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { + if (!ComponentDownloads.downloadFile(url, installer, false) { f -> onProgress(Progress(c.name, installerName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { return null to "download failed: $installerName" } unpacked = unpackInRuntime(context, c, installer, "snapshot", onProgress) ?: return null to "could not open $installerName" @@ -479,7 +479,7 @@ object WinComponents { val ext = if (listOf(step.str("file_name"), name).any { it.endsWith(".exe", ignoreCase = true) }) "exe" else "msi" val file = File(cache, "${c.name}-${c.steps.indexOf(step)}.$ext") try { - if (!Downloader.downloadFile(url, file, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { + if (!ComponentDownloads.downloadFile(url, file, false) { f -> onProgress(Progress(c.name, name, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) { return null to "download failed: $name" } step.str("file_checksum").takeIf { it.length == 32 }?.let { md5 -> diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt index 648d754aa..a221d0c4c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt @@ -26,9 +26,11 @@ object BuildWatermark { commit: String = BuildConfig.SOURCE_COMMIT, title: String = BuildConfig.PR_TITLE, branch: String = BuildConfig.BUILD_BRANCH, + play: Boolean = BuildConfig.PLAY_DISTRIBUTION, ): List? { - if (ci && pr <= 0) return null val hash = commit.take(7).ifEmpty { "unknown" } + if (play) return listOf(hash) + if (ci && pr <= 0) return null val head = if (pr > 0) "PR-$pr | $hash" else "LOCAL | $hash" val detail = (if (pr > 0) title else branch).trim() return if (detail.isEmpty()) listOf(head) else listOf(head, truncate(detail)) 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 28768454c..6b4cba271 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DesktopPage.kt @@ -173,7 +173,7 @@ private fun DesktopDock( val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val narrow = LocalNarrowPane.current - val available = s.emulators.filter { !it.installed } + val available = if (com.droiddeck.launcher.BuildConfig.PLAY_DISTRIBUTION) emptyList() else s.emulators.filter { !it.installed } val flatpaks = com.droiddeck.launcher.store.StoreState.installed.filter { f -> apps.none { it.key == "flatpak:${f.id}" } } val keys = installed.map { "emu:${it.id}" } + apps.map { "user:${it.key}" } + flatpaks.map { "flatpak:${it.id}" } var lastAt by remember { mutableStateOf(null) } 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 4da3ef2fd..056cf890f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -360,6 +360,11 @@ internal fun SetupPanel( } SettingsGroup(stringResource(R.string.setup_runtime)) { runtimeCheck(false) } SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation) + if (com.droiddeck.launcher.BuildConfig.PLAY_DISTRIBUTION) { + SecondaryButton(stringResource(R.string.setup_privacy_policy), compact = true) { + openUrl(ctx, "https://github.com/Droid-Deck/DroidDeck/blob/playstore/PRIVACY.md") + } + } } 1 -> { val controller = s.controller diff --git a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt index dd73939a7..a27208f25 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.BuildConfig + import com.droiddeck.launcher.R import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource @@ -77,8 +79,10 @@ class UpdatesState( val stage: String? = null, val percent: Int = -1, val askPermission: Boolean = false, + val playUpdateAvailable: Boolean? = null, + val playCheckedAt: Long = 0L, ) { - val hasUpdate: Boolean get() = AppUpdates.hasUpdate(catalog, follow) + val hasUpdate: Boolean get() = if (BuildConfig.PLAY_DISTRIBUTION) playUpdateAvailable == true else AppUpdates.hasUpdate(catalog, follow) } class UpdatesActions( @@ -87,6 +91,7 @@ class UpdatesActions( val onInstall: (Release) -> Unit = {}, val onAllowInstalls: () -> Unit = {}, val onDismissPermission: () -> Unit = {}, + val onOpenPlay: () -> Unit = {}, ) @OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class) @@ -106,13 +111,17 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie maxLines = 1, modifier = Modifier.weight(1f) .basicMarquee(iterations = Int.MAX_VALUE, initialDelayMillis = 700, velocity = 40.dp), ) - val checked = u.catalog?.checkedAt?.takeIf { it > 0 } - if (!LocalNarrowPane.current) Text( + val checked = (if (BuildConfig.PLAY_DISTRIBUTION) u.playCheckedAt else u.catalog?.checkedAt)?.takeIf { it > 0 } + if (!BuildConfig.PLAY_DISTRIBUTION && !LocalNarrowPane.current) Text( if (u.checking) stringResource(R.string.common_checking) else if (checked != null) stringResource(R.string.upd_checked, ago(checked).replaceFirstChar { it.lowercase() }) else stringResource(R.string.upd_not_checked), fontSize = 13.sp, color = colors.onSurfaceVariant, ) ToolIcon(Icons.Outlined.Refresh, stringResource(R.string.store_check_updates), busy = u.checking, enabled = !u.checking && u.stage == null, onClick = ua.onCheck) } + if (BuildConfig.PLAY_DISTRIBUTION) { + StatusPanel(s, u, ua, me) + return@Column + } BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) { val stacked = LocalNarrowPane.current || maxWidth < 600.dp Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) { @@ -131,7 +140,7 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie } } } - if (u.askPermission) AlertDialog( + if (!BuildConfig.PLAY_DISTRIBUTION && u.askPermission) AlertDialog( onDismissRequest = ua.onDismissPermission, title = { Text(stringResource(R.string.upd_perm_title)) }, text = { @@ -156,6 +165,14 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m val installBlock = release?.let { AppUpdates.installBlock(it, me) } class Look(val tint: Color, val status: String, val headline: String, val detail: String?) val look = when { + BuildConfig.PLAY_DISTRIBUTION -> Look( + if (u.playUpdateAvailable == true) AttentionAmber else colors.onSurfaceVariant, + stringResource(when { + u.checking -> R.string.common_checking + u.playUpdateAvailable == true -> R.string.upd_available + u.playUpdateAvailable == false -> R.string.upd_current_status + else -> R.string.upd_not_checked + }), stringResource(R.string.upd_title), null) !me.updatable -> Look(colors.onSurfaceVariant, stringResource(R.string.upd_signed_status), stringResource(R.string.upd_signed_headline), stringResource(R.string.upd_signed_detail)) catalog == null -> Look(colors.onSurfaceVariant, if (u.checking) stringResource(R.string.common_checking) else stringResource(R.string.upd_not_checked), stringResource(R.string.upd_title), null) @@ -189,6 +206,9 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m val button = release?.apk?.size?.takeIf { it > 0 }?.let { " ยท ${megabytes(it)}" }.orEmpty() Box(Modifier.padding(top = 14.dp)) { when { + BuildConfig.PLAY_DISTRIBUTION && u.playUpdateAvailable == true -> + PrimaryButton(stringResource(R.string.common_update), onClick = ua.onOpenPlay) + BuildConfig.PLAY_DISTRIBUTION -> Unit u.stage != null -> Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { Text(if (u.percent >= 0) stringResource(R.string.upd_stage_percent, u.stage, u.percent) else stringResource(R.string.upd_stage, u.stage), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) if (u.percent >= 0) LinearProgressIndicator(progress = { u.percent / 100f }, modifier = Modifier.fillMaxWidth().height(6.dp).clip(CircleShape)) diff --git a/app/src/main/java/com/droiddeck/launcher/update/AppUpdates.kt b/app/src/main/java/com/droiddeck/launcher/update/AppUpdates.kt index 1bbeb18e2..a7412db5c 100644 --- a/app/src/main/java/com/droiddeck/launcher/update/AppUpdates.kt +++ b/app/src/main/java/com/droiddeck/launcher/update/AppUpdates.kt @@ -148,6 +148,7 @@ object AppUpdates { } fun hasUpdate(catalog: Catalog?, follow: Follow): Boolean { + if (BuildConfig.PLAY_DISTRIBUTION) return false if (catalog == null) return false val me = installed() val r = release(catalog, follow) ?: return false @@ -247,6 +248,7 @@ object AppUpdates { } fun refresh(context: Context): Catalog { + check(!BuildConfig.PLAY_DISTRIBUTION) { "Application updates are managed by Google Play" } val checkedAt = System.currentTimeMillis() val published = JSONObject(get(context, "$CATALOG_URL?checked=$checkedAt")) val catalog = try { diff --git a/app/src/main/java/com/droiddeck/launcher/update/SelfInstaller.kt b/app/src/main/java/com/droiddeck/launcher/update/SelfInstaller.kt index 5d1d33455..6be150e65 100644 --- a/app/src/main/java/com/droiddeck/launcher/update/SelfInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/update/SelfInstaller.kt @@ -21,12 +21,13 @@ object SelfInstaller { const val ACTION_STATUS = "com.droiddeck.launcher.update.INSTALL_STATUS" fun canInstall(context: Context): Boolean = - Build.VERSION.SDK_INT < 26 || context.packageManager.canRequestPackageInstalls() + !BuildConfig.PLAY_DISTRIBUTION && (Build.VERSION.SDK_INT < 26 || context.packageManager.canRequestPackageInstalls()) fun permissionIntent(context: Context): Intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:${context.packageName}")) fun download(context: Context, apk: AppUpdates.Apk, progress: (Int) -> Unit): File { + check(!BuildConfig.PLAY_DISTRIBUTION) { "Application updates are managed by Google Play" } val dir = File(context.cacheDir, "updates") dir.listFiles()?.forEach { if (it.name != apk.name) FileUtils.delete(it) } dir.mkdirs() @@ -91,6 +92,7 @@ object SelfInstaller { } fun install(context: Context, apk: File, onSession: (Int) -> Unit = {}) { + check(!BuildConfig.PLAY_DISTRIBUTION) { "Application updates are managed by Google Play" } val installer = context.packageManager.packageInstaller val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL).apply { setAppPackageName(context.packageName) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 75e469d14..b1b44148e 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -3669,7 +3669,7 @@ ุบูŠุฑ ู…ุชุงุญ ููŠ AndroidุŸ ู…ุนู„ูˆู…ุงุช ุงู„ุชุทุจูŠู‚ โ†’ โ‹ฎ โ†’ ุงู„ุณู…ุงุญ ุจุงู„ุฅุนุฏุงุฏุงุช ุงู„ู…ุญุธูˆุฑุฉ ู…ุญุธูˆุฑ ู…ู† Android ยท ู…ุนู„ูˆู…ุงุช ุงู„ุชุทุจูŠู‚ โ†’ โ‹ฎ โ†’ ุงู„ุณู…ุงุญ ุจุงู„ุฅุนุฏุงุฏุงุช ุงู„ู…ุญุธูˆุฑุฉ ุฒุฑ ุงู„ุดุงุดุฉ ุงู„ุฑุฆูŠุณูŠุฉ ููŠ DroidDeck - ูŠู…ุฑู‘ุฑ ุถุบุทุงุช ุฒุฑ ุงู„ุดุงุดุฉ ุงู„ุฑุฆูŠุณูŠุฉ ุฅู„ู‰ Steam Guide ุนู†ุฏู…ุง ุชูƒูˆู† ุฌู„ุณุฉ Steam ููŠ ุงู„ู…ู‚ุฏู…ุฉ ูˆูŠูƒูˆู† DroidDeck ุชุทุจูŠู‚ ุงู„ุดุงุดุฉ ุงู„ุฑุฆูŠุณูŠุฉ ุงู„ุงูุชุฑุงุถูŠ. ู„ุง ูŠู‚ุฑุฃ ู…ุญุชูˆู‰ ุงู„ุดุงุดุฉ. + ุชุชูŠุญ ุฎุฏู…ุฉ ุชุณู‡ูŠู„ ุงู„ุงุณุชุฎุฏุงู… ุงุฎุชุตุงุฑุงุช Home/Guide ูˆุชูƒุชุดู ุงู„ุชุทุจูŠู‚ุงุช ุนู„ู‰ ุงู„ุดุงุดุฉ ุงู„ุณูู„ูŠุฉ. ุชู‚ุฑุฃ ู‡ุฐู‡ ุงู„ุฎุฏู…ุฉ ุฃุณู…ุงุก ุญุฒู… ุงู„ุชุทุจูŠู‚ุงุช ูˆุญุฏูˆุฏ ุงู„ู†ูˆุงูุฐ ู…ุญู„ูŠู‹ุง. ูˆู„ุง ุชู‚ุฑุฃ ุงู„ู†ุตูˆุต ุฃูˆ ุชู„ุชู‚ุท ุงู„ุดุงุดุฉ ุฃูˆ ุชุฑุณู„ ู‡ุฐู‡ ุงู„ุจูŠุงู†ุงุช. ูุนู‘ู„ ยซุงู„ุณุทูˆุนยป ู…ู† ุงู„ุฅุนุฏุงุฏ โ†’ ุชูƒุงู…ู„ Steam ุงู„ุจุญุซ ููŠ ุงู„ุชุทุจูŠู‚ุงุช ู„ุง ุชูˆุฌุฏ ุชุทุจูŠู‚ุงุช ุชุทุงุจู‚ โ€%1$sโ€œ. @@ -3799,4 +3799,5 @@ ุฏุฑุฌุฉ ุญุฑุงุฑุฉ ุงู„ู…ุนุงู„ุฌ ุงู„ุจุทุงุฑูŠุฉ ู„ุนุจุฉ + ุณูŠุงุณุฉ ุงู„ุฎุตูˆุตูŠุฉ 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 e395151bf..71221df3b 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -3534,7 +3534,7 @@ ยฟAparece en gris en Android? Informaciรณn de la app โ†’ โ‹ฎ โ†’ Permitir configuraciรณn restringida Bloqueado por Android ยท Informaciรณn de la app โ†’ โ‹ฎ โ†’ Permitir configuraciรณn restringida Botรณn de inicio de DroidDeck - Pasa las pulsaciones del botรณn de inicio a Steam Guide mientras una sesiรณn de Steam estรก en primer plano y DroidDeck es la app de inicio predeterminada. No lee el contenido de la pantalla. + El servicio de accesibilidad permite usar atajos Home/Guide y detecta apps en la pantalla inferior. Lee los nombres de los paquetes de las apps y los lรญmites de las ventanas de forma local. No lee texto, captura pantallas ni envรญa estos datos. Activa Brillo en Configuraciรณn โ†’ Integraciรณn con Steam Buscar apps Ninguna app coincide con ยซ%1$sยป. @@ -3661,4 +3661,5 @@ Temperatura de CPU Baterรญa Juego + Polรญtica de privacidad diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index ad126ac7c..da040bf12 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -3525,7 +3525,7 @@ ะะตะฐะบั‚ะธะฒะฝะพ ะฒ Android? ะ˜ะฝั„ะพั€ะผะฐั†ะธั ะทะฐ ะฟั€ะธะปะพะถะตะฝะธะตั‚ะพ โ†’ โ‹ฎ โ†’ ะ ะฐะทั€ะตัˆะฐะฒะฐะฝะต ะฝะฐ ะพะณั€ะฐะฝะธั‡ะตะฝะธั‚ะต ะฝะฐัั‚ั€ะพะนะบะธ ะ‘ะปะพะบะธั€ะฐะฝะพ ะพั‚ Android ยท ะ˜ะฝั„ะพั€ะผะฐั†ะธั ะทะฐ ะฟั€ะธะปะพะถะตะฝะธะตั‚ะพ โ†’ โ‹ฎ โ†’ ะ ะฐะทั€ะตัˆะฐะฒะฐะฝะต ะฝะฐ ะพะณั€ะฐะฝะธั‡ะตะฝะธั‚ะต ะฝะฐัั‚ั€ะพะนะบะธ ะ‘ัƒั‚ะพะฝ ะทะฐ ะฝะฐั‡ะฐะปะตะฝ ะตะบั€ะฐะฝ ะฝะฐ DroidDeck - ะŸั€ะตะดะฐะฒะฐ ะฝะฐั‚ะธัะบะฐะฝะธัั‚ะฐ ะฝะฐ ะฑัƒั‚ะพะฝะฐ ะทะฐ ะฝะฐั‡ะฐะปะตะฝ ะตะบั€ะฐะฝ ะบัŠะผ Steam Guide, ะดะพะบะฐั‚ะพ ัะตัะธั ะฝะฐ Steam ะต ะฝะฐ ั„ะพะบัƒั ะธ DroidDeck ะต ะฟั€ะธะปะพะถะตะฝะธะตั‚ะพ ะทะฐ ะฝะฐั‡ะฐะปะตะฝ ะตะบั€ะฐะฝ ะฟะพ ะฟะพะดั€ะฐะทะฑะธั€ะฐะฝะต. ะะต ั‡ะตั‚ะต ััŠะดัŠั€ะถะฐะฝะธะตั‚ะพ ะฝะฐ ะตะบั€ะฐะฝะฐ. + ะฃัะปัƒะณะฐั‚ะฐ ะทะฐ ะดะพัั‚ัŠะฟะฝะพัั‚ ะฟะพะทะฒะพะปัะฒะฐ ะฟั€ะตะบะธ ะฟัŠั‚ะธั‰ะฐ Home/Guide ะธ ะพั‚ะบั€ะธะฒะฐ ะฟั€ะธะปะพะถะตะฝะธั ะฝะฐ ะดะพะปะฝะธั ะตะบั€ะฐะฝ. ะขั ั‡ะตั‚ะต ะปะพะบะฐะปะฝะพ ะธะผะตะฝะฐั‚ะฐ ะฝะฐ ะฟะฐะบะตั‚ะธั‚ะต ะฝะฐ ะฟั€ะธะปะพะถะตะฝะธัั‚ะฐ ะธ ะณั€ะฐะฝะธั†ะธั‚ะต ะฝะฐ ะฟั€ะพะทะพั€ั†ะธั‚ะต. ะะต ั‡ะตั‚ะต ั‚ะตะบัั‚, ะฝะต ะทะฐัะฝะตะผะฐ ะตะบั€ะฐะฝะธ ะธ ะฝะต ะธะทะฟั€ะฐั‰ะฐ ั‚ะตะทะธ ะดะฐะฝะฝะธ. ะ’ะบะปัŽั‡ะตั‚ะต โ€žะฏั€ะบะพัั‚โ€œ ะฒ ะะฐัั‚ั€ะพะนะบะฐ โ†’ ะ˜ะฝั‚ะตะณั€ะฐั†ะธั ััŠั Steam ะขัŠั€ัะตะฝะต ะฝะฐ ะฟั€ะธะปะพะถะตะฝะธั ะัะผะฐ ะฟั€ะธะปะพะถะตะฝะธั, ะพั‚ะณะพะฒะฐั€ัั‰ะธ ะฝะฐ โ€ž%1$sโ€œ. @@ -3651,4 +3651,5 @@ ะขะตะผะฟะตั€ะฐั‚ัƒั€ะฐ ะฝะฐ CPU ะ‘ะฐั‚ะตั€ะธั ะ˜ะณั€ะฐ + ะŸะพะปะธั‚ะธะบะฐ ะทะฐ ะฟะพะฒะตั€ะธั‚ะตะปะฝะพัั‚ diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 5aed97a7f..b0ce02779 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -3597,7 +3597,7 @@ V Androidu zaลกedlรฉ? Informace o aplikaci โ†’ โ‹ฎ โ†’ Povolit omezenรก nastavenรญ Blokovรกno Androidem ยท Informace o aplikaci โ†’ โ‹ฎ โ†’ Povolit omezenรก nastavenรญ Tlaฤรญtko Domลฏ pro DroidDeck - Pล™edรกvรก stisky tlaฤรญtka Domลฏ do Steam Guide, kdyลพ je aktivnรญ relace Steamu a DroidDeck je vรฝchozรญ aplikacรญ domovskรฉ obrazovky. Neฤte obsah obrazovky. + Sluลพba usnadnฤ›nรญ umoลพลˆuje zkratky Home/Guide a rozpoznรกvรก aplikace na spodnรญ obrazovce. Mรญstnฤ› ฤte nรกzvy balรญฤkลฏ aplikacรญ a hranice oken. Neฤte text, nesnรญmรก obrazovky ani tyto รบdaje neodesรญlรก. Zapnฤ›te Jas v Pล™รญprava โ†’ Integrace se Steamem Hledat aplikace Vรฝrazu โ€ž%1$sโ€œ neodpovรญdรก ลพรกdnรก aplikace. @@ -3725,4 +3725,5 @@ Teplota CPU Baterie Hra + Zรกsady ochrany osobnรญch รบdajลฏ diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 2875eaf56..8b2da3f9b 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -3525,7 +3525,7 @@ Nedtonet i Android? Appinfo โ†’ โ‹ฎ โ†’ Tillad begrรฆnsede indstillinger Blokeret af Android ยท Appinfo โ†’ โ‹ฎ โ†’ Tillad begrรฆnsede indstillinger DroidDeck Hjem-knap - Sender tryk pรฅ Hjem-knappen til Steam Guide, mens en Steam-session er i fokus, og DroidDeck er standardstartskรฆrmen. Lรฆser ikke skรฆrmindhold. + Tilgรฆngelighedstjenesten muliggรธr Home/Guide-genveje og registrerer apps pรฅ den nederste skรฆrm. Tjenesten lรฆser appenes pakkenavne og vinduesgrรฆnser lokalt. Den lรฆser ikke tekst, tager ikke skรฆrmbilleder og sender ikke disse data. Slรฅ Lysstyrke til under Opsรฆtning โ†’ Steam-integration Sรธg i apps Ingen apps matcher โ€œ%1$sโ€. @@ -3651,4 +3651,5 @@ CPU-temperatur Batteri Spil + Privatlivspolitik diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 688b074ae..38dfef47e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -3525,7 +3525,7 @@ In Android ausgegraut? App-Info โ†’ โ‹ฎ โ†’ Eingeschrรคnkte Einstellungen zulassen Von Android blockiert ยท App-Info โ†’ โ‹ฎ โ†’ Eingeschrรคnkte Einstellungen zulassen DroidDeck-Home-Taste - Leitet Drรผcke der Home-Taste an Steam Guide weiter, wรคhrend eine Steam-Sitzung im Fokus ist und DroidDeck die Standard-Startbildschirm-App ist. Liest keine Bildschirminhalte. + Der Bedienungshilfedienst ermรถglicht Home/Guide-Tastenkรผrzel und erkennt Apps auf dem unteren Bildschirm. Er liest App-Paketnamen und Fenstergrenzen lokal aus. Er liest keine Texte, nimmt keine Bildschirme auf und รผbertrรคgt diese Daten nicht. Aktiviere Helligkeit unter Einrichtung โ†’ Steam-Integration Apps durchsuchen Keine Apps passen zu โ€ž%1$sโ€œ. @@ -3651,4 +3651,5 @@ CPU-Temperatur Akku Spiel + Datenschutzerklรคrung diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index a51fe5644..377f492a1 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -3525,7 +3525,7 @@ ฮ“ฮบฯฮฏฮถฮฟ ฯƒฯ„ฮฟ Android; ฮ ฮปฮทฯฮฟฯ†ฮฟฯฮฏฮตฯ‚ ฮตฯ†ฮฑฯฮผฮฟฮณฮฎฯ‚ โ†’ โ‹ฎ โ†’ ฮฮฑ ฮตฯ€ฮนฯ„ฯฮญฯ€ฮฟฮฝฯ„ฮฑฮน ฮฟฮน ฯ€ฮตฯฮนฮฟฯฮนฯƒฮผฮญฮฝฮตฯ‚ ฯฯ…ฮธฮผฮฏฯƒฮตฮนฯ‚ ฮ‘ฯ€ฮฟฮบฮปฮตฮฏฮตฯ„ฮฑฮน ฮฑฯ€ฯŒ ฯ„ฮฟ Android ยท ฮ ฮปฮทฯฮฟฯ†ฮฟฯฮฏฮตฯ‚ ฮตฯ†ฮฑฯฮผฮฟฮณฮฎฯ‚ โ†’ โ‹ฎ โ†’ ฮฮฑ ฮตฯ€ฮนฯ„ฯฮญฯ€ฮฟฮฝฯ„ฮฑฮน ฮฟฮน ฯ€ฮตฯฮนฮฟฯฮนฯƒฮผฮญฮฝฮตฯ‚ ฯฯ…ฮธฮผฮฏฯƒฮตฮนฯ‚ ฮšฮฟฯ…ฮผฯ€ฮฏ ฮ‘ฯฯ‡ฮนฮบฮฎฯ‚ DroidDeck - ฮœฮตฯ„ฮฑฮฒฮนฮฒฮฌฮถฮตฮน ฯ„ฮฑ ฯ€ฮฑฯ„ฮฎฮผฮฑฯ„ฮฑ ฯ„ฮฟฯ… ฮบฮฟฯ…ฮผฯ€ฮนฮฟฯ ฮ‘ฯฯ‡ฮนฮบฮฎฯ‚ ฯƒฯ„ฮฟ Steam Guide ฯŒฯƒฮฟ ฮผฮนฮฑ ฯƒฯ…ฮฝฮตฮดฯฮฏฮฑ Steam ฮตฮฏฮฝฮฑฮน ฮตฯƒฯ„ฮนฮฑฯƒฮผฮญฮฝฮท ฮบฮฑฮน ฯ„ฮฟ DroidDeck ฮตฮฏฮฝฮฑฮน ฮท ฯ€ฯฮฟฮตฯ€ฮนฮปฮตฮณฮผฮญฮฝฮท ฮตฯ†ฮฑฯฮผฮฟฮณฮฎ ฮ‘ฯฯ‡ฮนฮบฮฎฯ‚. ฮ”ฮตฮฝ ฮดฮนฮฑฮฒฮฌฮถฮตฮน ฯ„ฮฟ ฯ€ฮตฯฮนฮตฯ‡ฯŒฮผฮตฮฝฮฟ ฯ„ฮทฯ‚ ฮฟฮธฯŒฮฝฮทฯ‚. + ฮ— ฯ…ฯ€ฮทฯฮตฯƒฮฏฮฑ ฯ€ฯฮฟฯƒฮฒฮฑฯƒฮนฮผฯŒฯ„ฮทฯ„ฮฑฯ‚ ฮตฮฝฮตฯฮณฮฟฯ€ฮฟฮนฮตฮฏ ฯƒฯ…ฮฝฯ„ฮฟฮผฮตฯฯƒฮตฮนฯ‚ Home/Guide ฮบฮฑฮน ฮตฮฝฯ„ฮฟฯ€ฮฏฮถฮตฮน ฮตฯ†ฮฑฯฮผฮฟฮณฮญฯ‚ ฯƒฯ„ฮทฮฝ ฮบฮฌฯ„ฯ‰ ฮฟฮธฯŒฮฝฮท. ฮ”ฮนฮฑฮฒฮฌฮถฮตฮน ฯ„ฮฟฯ€ฮนฮบฮฌ ฮฟฮฝฯŒฮผฮฑฯ„ฮฑ ฯ€ฮฑฮบฮญฯ„ฯ‰ฮฝ ฮตฯ†ฮฑฯฮผฮฟฮณฯŽฮฝ ฮบฮฑฮน ฯŒฯฮนฮฑ ฯ€ฮฑฯฮฑฮธฯฯฯ‰ฮฝ. ฮ”ฮตฮฝ ฮดฮนฮฑฮฒฮฌฮถฮตฮน ฮบฮตฮฏฮผฮตฮฝฮฟ, ฮดฮตฮฝ ฮบฮฑฯ„ฮฑฮณฯฮฌฯ†ฮตฮน ฮฟฮธฯŒฮฝฮตฯ‚ ฮบฮฑฮน ฮดฮตฮฝ ฮฑฯ€ฮฟฯƒฯ„ฮญฮปฮปฮตฮน ฮฑฯ…ฯ„ฮฌ ฯ„ฮฑ ฮดฮตฮดฮฟฮผฮญฮฝฮฑ. ฮ•ฮฝฮตฯฮณฮฟฯ€ฮฟฮนฮฎฯƒฯ„ฮต ฯ„ฮท ฮฆฯ‰ฯ„ฮตฮนฮฝฯŒฯ„ฮทฯ„ฮฑ ฯƒฯ„ฮท ฮกฯฮธฮผฮนฯƒฮท โ†’ ฮ•ฮฝฯƒฯ‰ฮผฮฌฯ„ฯ‰ฯƒฮท Steam ฮ‘ฮฝฮฑฮถฮฎฯ„ฮทฯƒฮท ฮตฯ†ฮฑฯฮผฮฟฮณฯŽฮฝ ฮšฮฑฮผฮฏฮฑ ฮตฯ†ฮฑฯฮผฮฟฮณฮฎ ฮดฮตฮฝ ฯ„ฮฑฮนฯฮนฮฌฮถฮตฮน ฮผฮต ยซ%1$sยป. @@ -3651,4 +3651,5 @@ ฮ˜ฮตฯฮผฮฟฮบฯฮฑฯƒฮฏฮฑ CPU ฮœฯ€ฮฑฯ„ฮฑฯฮฏฮฑ ฮ ฮฑฮนฯ‡ฮฝฮฏฮดฮน + ฮ ฮฟฮปฮนฯ„ฮนฮบฮฎ ฮฑฯ€ฮฟฯฯฮฎฯ„ฮฟฯ… diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1120b6f95..c21d1cd2d 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3561,7 +3561,7 @@ ยฟAparece en gris en Android? Informaciรณn de la aplicaciรณn โ†’ โ‹ฎ โ†’ Permitir ajustes restringidos Bloqueado por Android ยท Informaciรณn de la aplicaciรณn โ†’ โ‹ฎ โ†’ Permitir ajustes restringidos Botรณn de inicio de DroidDeck - Pasa las pulsaciones del botรณn de inicio a Steam Guide mientras una sesiรณn de Steam estรก en primer plano y DroidDeck es la app de inicio predeterminada. No lee el contenido de la pantalla. + El servicio de accesibilidad permite usar atajos Home/Guide y detecta aplicaciones en la pantalla inferior. Lee los nombres de los paquetes de las aplicaciones y los lรญmites de las ventanas de forma local. No lee texto, captura pantallas ni envรญa estos datos. Activa Brillo en Configuraciรณn โ†’ Integraciรณn con Steam Buscar aplicaciones Ninguna aplicaciรณn coincide con ยซ%1$sยป. @@ -3688,4 +3688,5 @@ Temperatura de CPU Baterรญa Juego + Polรญtica de privacidad diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index ceaeb8f23..bd0ffbde0 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -3525,7 +3525,7 @@ Harmaana Androidissa? Sovelluksen tiedot โ†’ โ‹ฎ โ†’ Salli rajoitetut asetukset Androidin estรคmรค ยท Sovelluksen tiedot โ†’ โ‹ฎ โ†’ Salli rajoitetut asetukset DroidDeckin Koti-painike - Vรคlittรครค Koti-painikkeen painallukset Steam Guidelle, kun Steam-istunto on aktiivinen ja DroidDeck on oletusaloitusnรคyttรถsovellus. Ei lue nรคytรถn sisรคltรถรค. + Esteettรถmyyspalvelu mahdollistaa Home/Guide-pikanรคppรคimet ja tunnistaa alemman nรคytรถn sovellukset. Se lukee sovellusten pakettien nimet ja ikkunoiden rajat paikallisesti. Se ei lue tekstiรค, tallenna nรคyttรถkuvia eikรค lรคhetรค nรคitรค tietoja. Ota Kirkkaus kรคyttรถรถn kohdassa Kรคyttรถรถnotto โ†’ Steam-integraatio Hae sovelluksia Mikรครคn sovellus ei vastaa hakua โ€%1$sโ€. @@ -3651,4 +3651,5 @@ CPU:n lรคmpรถtila Akku Peli + Tietosuojakรคytรคntรถ diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 565f91164..567c3c576 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -3561,7 +3561,7 @@ Grisรฉ dans Android ? Infos sur l\'appli โ†’ โ‹ฎ โ†’ Autoriser les paramรจtres restreints Bloquรฉ par Android ยท Infos sur l\'appli โ†’ โ‹ฎ โ†’ Autoriser les paramรจtres restreints Bouton Accueil DroidDeck - Transmet les appuis sur le bouton Accueil ร  Steam Guide lorsqu\'une session Steam est au premier plan et que DroidDeck est l\'application d\'รฉcran d\'accueil par dรฉfaut. Ne lit pas le contenu de l\'รฉcran. + Le service dโ€™accessibilitรฉ permet les raccourcis Home/Guide et dรฉtecte les applications sur lโ€™รฉcran infรฉrieur. Il lit localement les noms des paquets et les limites des fenรชtres. Il ne lit aucun texte, ne capture pas les รฉcrans et ne transmet pas ces donnรฉes. Activez Luminositรฉ dans Paramรจtres โ†’ Intรฉgration Steam Rechercher des applications Aucune application ne correspond ร  ยซ %1$s ยป. @@ -3688,4 +3688,5 @@ Tempรฉrature du processeur Batterie Jeu + Politique de confidentialitรฉ diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index b7e1e085e..364092b7c 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -3525,7 +3525,7 @@ Android เคฎเฅ‡เค‚ เคงเฅ‚เคธเคฐ เคนเฅˆ? เคเคชเฅเคฒเคฟเค•เฅ‡เคถเคจ เค•เฅ€ เคœเคพเคจเค•เคพเคฐเฅ€ โ†’ โ‹ฎ โ†’ เคชเฅเคฐเคคเคฟเคฌเค‚เคงเคฟเคค เคธเฅ‡เคŸเคฟเค‚เค— เค•เฅ€ เค…เคจเฅเคฎเคคเคฟ เคฆเฅ‡เค‚ Android เคจเฅ‡ เคฌเฅเคฒเฅ‰เค• เค•เคฟเคฏเคพ ยท เคเคชเฅเคฒเคฟเค•เฅ‡เคถเคจ เค•เฅ€ เคœเคพเคจเค•เคพเคฐเฅ€ โ†’ โ‹ฎ โ†’ เคชเฅเคฐเคคเคฟเคฌเค‚เคงเคฟเคค เคธเฅ‡เคŸเคฟเค‚เค— เค•เฅ€ เค…เคจเฅเคฎเคคเคฟ เคฆเฅ‡เค‚ DroidDeck เคนเฅ‹เคฎ เคฌเคŸเคจ - เคœเคฌ Steam เคธเฅ‡เคถเคจ เคซเคผเฅ‹เค•เคธ เคฎเฅ‡เค‚ เคนเฅ‹ เค”เคฐ DroidDeck เคกเคฟเคซเคผเฅ‰เคฒเฅเคŸ เคนเฅ‹เคฎ เคเคช เคนเฅ‹, เคคเคฌ เคนเฅ‹เคฎ เคฌเคŸเคจ เคฆเคฌเคพเคจเฅ‡ เค•เฅ‹ Steam Guide เคคเค• เคญเฅ‡เคœเคคเคพ เคนเฅˆเฅค เคธเฅเค•เฅเคฐเฅ€เคจ เค•เฅ€ เคธเคพเคฎเค—เฅเคฐเฅ€ เคจเคนเฅ€เค‚ เคชเคขเคผเคคเคพเฅค + เคธเฅเคฒเคญเคคเคพ เคธเฅ‡เคตเคพ Home/Guide เคถเฅ‰เคฐเฅเคŸเค•เคŸ เคธเค•เฅเคทเคฎ เค•เคฐเคคเฅ€ เคนเฅˆ เค”เคฐ เคจเคฟเคšเคฒเฅ€ เคธเฅเค•เฅเคฐเฅ€เคจ เคชเคฐ เคเคชเฅเคธ เค•เคพ เคชเคคเคพ เคฒเค—เคพเคคเฅ€ เคนเฅˆเฅค เคฏเคน เคธเฅ‡เคตเคพ เคเคช เคชเฅˆเค•เฅ‡เคœ เค•เฅ‡ เคจเคพเคฎ เค”เคฐ เคตเคฟเค‚เคกเฅ‹ เค•เฅ€ เคธเฅ€เคฎเคพเคเค เคกเคฟเคตเคพเค‡เคธ เคชเคฐ เคนเฅ€ เคชเคขเคผเคคเฅ€ เคนเฅˆเฅค เคฏเคน เคŸเฅ‡เค•เฅเคธเฅเคŸ เคจเคนเฅ€เค‚ เคชเคขเคผเคคเฅ€, เคธเฅเค•เฅเคฐเฅ€เคจ เค•เฅˆเคชเฅเคšเคฐ เคจเคนเฅ€เค‚ เค•เคฐเคคเฅ€ เค”เคฐ เคฏเคน เคกเฅ‡เคŸเคพ เคจเคนเฅ€เค‚ เคญเฅ‡เคœเคคเฅ€เฅค Setup โ†’ Steam เค‡เค‚เคŸเฅ€เค—เฅเคฐเฅ‡เคถเคจ เคฎเฅ‡เค‚ เคฌเฅเคฐเคพเค‡เคŸเคจเฅ‡เคธ เคšเคพเคฒเฅ‚ เค•เคฐเฅ‡เค‚ เคเคช เค–เฅ‹เคœเฅ‡เค‚ โ€œ%1$sโ€ เคธเฅ‡ เค•เฅ‹เคˆ เคเคช เคฎเฅ‡เคฒ เคจเคนเฅ€เค‚ เค–เคพเคคเคพเฅค @@ -3651,4 +3651,5 @@ CPU เคคเคพเคชเคฎเคพเคจ เคฌเฅˆเคŸเคฐเฅ€ เค—เฅ‡เคฎ + เคจเคฟเคœเคคเคพ เคจเฅ€เคคเคฟ diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 5d59f4ca8..80b3fb7fa 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -3525,7 +3525,7 @@ Szรผrke az Androidban? Alkalmazรกsinformรกciรณ โ†’ โ‹ฎ โ†’ Korlรกtozott beรกllรญtรกsok engedรฉlyezรฉse Az Android letiltotta ยท Alkalmazรกsinformรกciรณ โ†’ โ‹ฎ โ†’ Korlรกtozott beรกllรญtรกsok engedรฉlyezรฉse DroidDeck Kezdล‘kรฉpernyล‘ gomb - A Kezdล‘kรฉpernyล‘ gomb lenyomรกsait tovรกbbรญtja a Steam Guide-nak, amรญg egy Steam-munkamenet van fรณkuszban, รฉs a DroidDeck az alapรฉrtelmezett kezdล‘kรฉpernyล‘ alkalmazรกs. Nem olvassa a kรฉpernyล‘ tartalmรกt. + A kisegรญtล‘ szolgรกltatรกs lehetล‘vรฉ teszi a Home/Guide billentyลฑparancsokat, รฉs felismeri az alsรณ kรฉpernyล‘n futรณ alkalmazรกsokat. Helyben olvassa az alkalmazรกscsomagok nevรฉt รฉs az ablakok hatรกrait. Nem olvas szรถveget, nem rรถgzรญti a kรฉpernyล‘t, รฉs nem tovรกbbรญtja ezeket az adatokat. Kapcsolja be a Fรฉnyerล‘t itt: Beรกllรญtรกs โ†’ Steam-integrรกciรณ Alkalmazรกsok keresรฉse Egy alkalmazรกs sem felel meg ennek: โ€ž%1$sโ€. @@ -3651,4 +3651,5 @@ CPU-hล‘mรฉrsรฉklet Akkumulรกtor Jรกtรฉk + Adatvรฉdelmi szabรกlyzat diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index db36bad3a..7c8a731ad 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -3498,7 +3498,7 @@ Berwarna abu-abu di Android? Info aplikasi โ†’ โ‹ฎ โ†’ Izinkan setelan terbatas Diblokir oleh Android ยท Info aplikasi โ†’ โ‹ฎ โ†’ Izinkan setelan terbatas Tombol Home DroidDeck - Meneruskan tekanan tombol Home ke Steam Guide saat sesi Steam sedang aktif dan DroidDeck adalah aplikasi Beranda default. Tidak membaca konten layar. + Layanan aksesibilitas mengaktifkan pintasan Home/Guide dan mendeteksi aplikasi di layar bawah. Layanan ini membaca nama paket aplikasi dan batas jendela secara lokal. Layanan ini tidak membaca teks, merekam layar, atau mengirimkan data tersebut. Aktifkan Kecerahan di Penyiapan โ†’ Integrasi Steam Cari aplikasi Tidak ada aplikasi yang cocok dengan โ€œ%1$sโ€. @@ -3623,4 +3623,5 @@ Suhu CPU Baterai Permainan + Kebijakan privasi diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7fb7d201d..644bc029f 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -3561,7 +3561,7 @@ Disattivato in grigio su Android? Informazioni app โ†’ โ‹ฎ โ†’ Consenti impostazioni con limitazioni Bloccato da Android ยท Informazioni app โ†’ โ‹ฎ โ†’ Consenti impostazioni con limitazioni Tasto Home di DroidDeck - Inoltra le pressioni del tasto Home a Steam Guide mentre una sessione Steam รจ in primo piano e DroidDeck รจ l\'app Home predefinita. Non legge il contenuto dello schermo. + Il servizio di accessibilitร  abilita le scorciatoie Home/Guide e rileva le app sullo schermo inferiore. Legge localmente i nomi dei pacchetti delle app e i limiti delle finestre. Non legge testi, non acquisisce schermate e non invia questi dati. Attiva Luminositร  in Configurazione โ†’ Integrazione con Steam Cerca app Nessuna app corrisponde a ยซ%1$sยป. @@ -3688,4 +3688,5 @@ Temperatura CPU Batteria Gioco + Informativa sulla privacy diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 00d598bac..efeefdb60 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -3498,7 +3498,7 @@ Androidใงใ‚ฐใƒฌใƒผ่กจ็คบใ•ใ‚Œใฆใ„ใพใ™ใ‹๏ผŸใ‚ขใƒ—ใƒชๆƒ…ๅ ฑ โ†’ โ‹ฎ โ†’ ๅˆถ้™ไป˜ใ่จญๅฎšใ‚’่จฑๅฏ Androidใซใ‚ˆใฃใฆใƒ–ใƒญใƒƒใ‚ฏใ•ใ‚Œใฆใ„ใพใ™ ยท ใ‚ขใƒ—ใƒชๆƒ…ๅ ฑ โ†’ โ‹ฎ โ†’ ๅˆถ้™ไป˜ใ่จญๅฎšใ‚’่จฑๅฏ DroidDeckใƒ›ใƒผใƒ ใƒœใ‚ฟใƒณ - Steamใ‚ปใƒƒใ‚ทใƒงใƒณใŒใƒ•ใ‚ฉใƒผใ‚ซใ‚นใ•ใ‚Œใ€DroidDeckใŒใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใฎใƒ›ใƒผใƒ ใ‚ขใƒ—ใƒชใฎๅ ดๅˆใซใ€ใƒ›ใƒผใƒ ใƒœใ‚ฟใƒณใฎๆ“ไฝœใ‚’Steamใ‚ฌใ‚คใƒ‰ใซๆธกใ—ใพใ™ใ€‚็”ป้ขใฎใ‚ณใƒณใƒ†ใƒณใƒ„ใฏ่ชญใฟๅ–ใ‚Šใพใ›ใ‚“ใ€‚ + ใƒฆใƒผใ‚ถใƒผ่ฃœๅŠฉใ‚ตใƒผใƒ“ใ‚นใฏHome/Guideใ‚ทใƒงใƒผใƒˆใ‚ซใƒƒใƒˆใ‚’ๆœ‰ๅŠนใซใ—ใ€ไธ‹ๅดใฎ็”ป้ขใซใ‚ใ‚‹ใ‚ขใƒ—ใƒชใ‚’ๆคœๅ‡บใ—ใพใ™ใ€‚ใ‚ขใƒ—ใƒชใฎใƒ‘ใƒƒใ‚ฑใƒผใ‚ธๅใจใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใฎ็ฏ„ๅ›ฒใ‚’็ซฏๆœซๅ†…ใง่ชญใฟๅ–ใ‚Šใพใ™ใ€‚ใƒ†ใ‚ญใ‚นใƒˆใฎ่ชญใฟๅ–ใ‚Šใ€็”ป้ขใฎใ‚ญใƒฃใƒ—ใƒใƒฃใ€ใ“ใ‚Œใ‚‰ใฎใƒ‡ใƒผใ‚ฟใฎ้€ไฟกใฏ่กŒใ„ใพใ›ใ‚“ใ€‚ ใ€Œใ‚ปใƒƒใƒˆใ‚ขใƒƒใƒ—ใ€โ†’ใ€ŒSteam้€ฃๆบใ€ใงๆ˜Žใ‚‹ใ•ใ‚’ใ‚ชใƒณใซใ—ใฆใใ ใ•ใ„ ใ‚ขใƒ—ใƒชใ‚’ๆคœ็ดข ใ€Œ%1$sใ€ใซไธ€่‡ดใ™ใ‚‹ใ‚ขใƒ—ใƒชใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚ @@ -3623,4 +3623,5 @@ CPUๆธฉๅบฆ ใƒใƒƒใƒ†ใƒชใƒผ ใ‚ฒใƒผใƒ  + ใƒ—ใƒฉใ‚คใƒใ‚ทใƒผใƒใƒชใ‚ทใƒผ diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 1b12a6695..1695b6ef7 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -3498,7 +3498,7 @@ Android์—์„œ ํšŒ์ƒ‰์œผ๋กœ ํ‘œ์‹œ๋˜๋‚˜์š”? ์•ฑ ์ •๋ณด โ†’ โ‹ฎ โ†’ ์ œํ•œ๋œ ์„ค์ • ํ—ˆ์šฉ Android์—์„œ ์ฐจ๋‹จ๋จ ยท ์•ฑ ์ •๋ณด โ†’ โ‹ฎ โ†’ ์ œํ•œ๋œ ์„ค์ • ํ—ˆ์šฉ DroidDeck ํ™ˆ ๋ฒ„ํŠผ - Steam ์„ธ์…˜์— ํฌ์ปค์Šค๊ฐ€ ์žˆ๊ณ  DroidDeck์ด ๊ธฐ๋ณธ ํ™ˆ ์•ฑ์ผ ๋•Œ ํ™ˆ ๋ฒ„ํŠผ ์ž…๋ ฅ์„ Steam Guide๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ํ™”๋ฉด ์ฝ˜ํ…์ธ ๋Š” ์ฝ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. + ์ ‘๊ทผ์„ฑ ์„œ๋น„์Šค๋Š” Home/Guide ๋‹จ์ถ•ํ‚ค๋ฅผ ํ™œ์„ฑํ™”ํ•˜๊ณ  ์•„๋ž˜์ชฝ ํ™”๋ฉด์˜ ์•ฑ์„ ๊ฐ์ง€ํ•ฉ๋‹ˆ๋‹ค. ์ด ์„œ๋น„์Šค๋Š” ๊ธฐ๊ธฐ ๋‚ด์—์„œ ์•ฑ ํŒจํ‚ค์ง€ ์ด๋ฆ„๊ณผ ์ฐฝ ๊ฒฝ๊ณ„๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค. ํ…์ŠคํŠธ๋ฅผ ์ฝ๊ฑฐ๋‚˜ ํ™”๋ฉด์„ ์บก์ฒ˜ํ•˜๊ฑฐ๋‚˜ ์ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์„ค์ • โ†’ Steam ์—ฐ๋™์—์„œ ๋ฐ๊ธฐ๋ฅผ ์ผœ์„ธ์š” ์•ฑ ๊ฒ€์ƒ‰ โ€˜%1$sโ€™์™€(๊ณผ) ์ผ์น˜ํ•˜๋Š” ์•ฑ์ด ์—†์Šต๋‹ˆ๋‹ค. @@ -3623,4 +3623,5 @@ CPU ์˜จ๋„ ๋ฐฐํ„ฐ๋ฆฌ ๊ฒŒ์ž„ + ๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index 1e77cdccd..5a6ec0346 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -3498,7 +3498,7 @@ Dikelabukan dalam Android? Maklumat apl โ†’ โ‹ฎ โ†’ Benarkan tetapan terhad Disekat oleh Android ยท Maklumat apl โ†’ โ‹ฎ โ†’ Benarkan tetapan terhad Butang Laman Utama DroidDeck - Menghantar tekanan butang Laman Utama kepada Steam Guide semasa sesi Steam difokuskan dan DroidDeck ialah apl Laman Utama lalai. Tidak membaca kandungan skrin. + Perkhidmatan kebolehcapaian mengaktifkan pintasan Home/Guide dan mengesan aplikasi pada skrin bawah. Perkhidmatan ini membaca nama pakej aplikasi dan sempadan tetingkap secara setempat. Ia tidak membaca teks, menangkap skrin atau menghantar data ini. Hidupkan Kecerahan dalam Persediaan โ†’ Integrasi Steam Cari apl Tiada apl sepadan dengan โ€œ%1$sโ€. @@ -3623,4 +3623,5 @@ Suhu CPU Bateri Permainan + Dasar privasi diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 9b8fe7484..c49e3333a 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -3525,7 +3525,7 @@ Nedtonet i Android? Appinfo โ†’ โ‹ฎ โ†’ Tillat begrensede innstillinger Blokkert av Android ยท Appinfo โ†’ โ‹ฎ โ†’ Tillat begrensede innstillinger DroidDeck Hjem-knapp - Sender trykk pรฅ Hjem-knappen til Steam Guide mens en Steam-sesjon er i fokus og DroidDeck er standard startskjerm-app. Leser ikke skjerminnhold. + Tilgjengelighetstjenesten aktiverer Home/Guide-snarveier og oppdager apper pรฅ den nederste skjermen. Den leser appenes pakkenavn og vindusgrenser lokalt. Den leser ikke tekst, tar ikke skjermbilder og sender ikke disse dataene. Slรฅ pรฅ Lysstyrke i Oppsett โ†’ Steam-integrering Sรธk i apper Ingen apper samsvarer med ยซ%1$sยป. @@ -3651,4 +3651,5 @@ CPU-temperatur Batteri Spill + Personvernerklรฆring diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index d3ea9e1ef..d0cfa636c 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -3525,7 +3525,7 @@ Grijs in Android? App-info โ†’ โ‹ฎ โ†’ Beperkte instellingen toestaan Geblokkeerd door Android ยท App-info โ†’ โ‹ฎ โ†’ Beperkte instellingen toestaan DroidDeck-startknop - Geeft drukken op de startknop door aan Steam Guide terwijl een Steam-sessie actief is en DroidDeck de standaard startscherm-app is. Leest geen scherminhoud. + De toegankelijkheidsservice maakt Home/Guide-sneltoetsen mogelijk en detecteert apps op het onderste scherm. De service leest pakketnamen van apps en venstergrenzen lokaal. De service leest geen tekst, maakt geen schermopnamen en verzendt deze gegevens niet. Zet Helderheid aan in Installatie โ†’ Steam-integratie Apps zoeken Geen apps gevonden voor โ€˜%1$sโ€™. @@ -3651,4 +3651,5 @@ CPU-temperatuur Accu Spel + Privacybeleid diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 6c35215cc..b68bbc7bc 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -3597,7 +3597,7 @@ Wyszarzone w Androidzie? Informacje o aplikacji โ†’ โ‹ฎ โ†’ Zezwรณl na ustawienia z ograniczeniami Zablokowane przez Androida ยท Informacje o aplikacji โ†’ โ‹ฎ โ†’ Zezwรณl na ustawienia z ograniczeniami Przycisk ekranu gล‚รณwnego DroidDeck - Przekazuje naciล›niฤ™cia przycisku ekranu gล‚รณwnego do Steam Guide, gdy aktywna jest sesja Steam, a DroidDeck jest domyล›lnฤ… aplikacjฤ… ekranu gล‚รณwnego. Nie odczytuje zawartoล›ci ekranu. + Usล‚uga uล‚atwieล„ dostฤ™pu wล‚ฤ…cza skrรณty Home/Guide i wykrywa aplikacje na dolnym ekranie. Lokalnie odczytuje nazwy pakietรณw aplikacji i granice okien. Nie odczytuje tekstu, nie przechwytuje obrazu ekranu ani nie wysyล‚a tych danych. Wล‚ฤ…cz Jasnoล›ฤ‡ w Konfiguracja โ†’ Integracja ze Steam Szukaj aplikacji ลปadna aplikacja nie pasuje do โ€ž%1$sโ€. @@ -3725,4 +3725,5 @@ Temperatura CPU Bateria Gra + Polityka prywatnoล›ci diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index b0a020bbd..da6dac2ed 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -3561,7 +3561,7 @@ Desativado a cinzento no Android? Informaรงรตes da aplicaรงรฃo โ†’ โ‹ฎ โ†’ Permitir definiรงรตes restritas Bloqueado pelo Android ยท Informaรงรตes da aplicaรงรฃo โ†’ โ‹ฎ โ†’ Permitir definiรงรตes restritas Botรฃo Pรกgina inicial do DroidDeck - Envia os toques no botรฃo Pรกgina inicial para o Guide do Steam enquanto uma sessรฃo do Steam estรก em foco e o DroidDeck รฉ a app de pรกgina inicial predefinida. Nรฃo lรช o conteรบdo do ecrรฃ. + O serviรงo de acessibilidade ativa os atalhos Home/Guide e deteta aplicaรงรตes no ecrรฃ inferior. Lรช localmente os nomes dos pacotes das aplicaรงรตes e os limites das janelas. Nรฃo lรช texto, nรฃo captura ecrรฃs nem envia estes dados. Ative Brilho em Configuraรงรฃo โ†’ Integraรงรฃo com o Steam Pesquisar aplicaรงรตes Nenhuma aplicaรงรฃo corresponde a โ€œ%1$sโ€. @@ -3688,4 +3688,5 @@ Temperatura da CPU Bateria Jogo + Polรญtica de privacidade diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 49c7be576..59f72501f 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -3561,7 +3561,7 @@ Esmaecido no Android? Informaรงรตes do app โ†’ โ‹ฎ โ†’ Permitir configuraรงรตes restritas Bloqueado pelo Android ยท Informaรงรตes do app โ†’ โ‹ฎ โ†’ Permitir configuraรงรตes restritas Botรฃo Inรญcio do DroidDeck - Repassa os toques no botรฃo Inรญcio para o Guide da Steam enquanto uma sessรฃo da Steam estรก em foco e o DroidDeck รฉ o app de tela inicial padrรฃo. Nรฃo lรช o conteรบdo da tela. + O serviรงo de acessibilidade ativa os atalhos Home/Guide e detecta apps na tela inferior. Ele lรช os nomes dos pacotes dos apps e os limites das janelas localmente. Nรฃo lรช textos, nรฃo captura telas nem envia esses dados. Ative Brilho em Configuraรงรฃo โ†’ Integraรงรฃo com a Steam Pesquisar apps Nenhum app corresponde a โ€œ%1$sโ€. @@ -3688,4 +3688,5 @@ Temperatura da CPU Bateria Jogo + Polรญtica de privacidade diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 8eba7980c..9808c7254 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -3561,7 +3561,7 @@ Inactiv รฎn Android? Informaศ›ii despre aplicaศ›ie โ†’ โ‹ฎ โ†’ Permite setฤƒrile restricศ›ionate Blocat de Android ยท Informaศ›ii despre aplicaศ›ie โ†’ โ‹ฎ โ†’ Permite setฤƒrile restricศ›ionate Butonul Acasฤƒ DroidDeck - Transmite apฤƒsฤƒrile butonului Acasฤƒ cฤƒtre Steam Guide cรขt timp o sesiune Steam este activฤƒ ศ™i DroidDeck este aplicaศ›ia Acasฤƒ implicitฤƒ. Nu citeศ™te conศ›inutul ecranului. + Serviciul de accesibilitate activeazฤƒ comenzile rapide Home/Guide ศ™i detecteazฤƒ aplicaศ›iile de pe ecranul inferior. Citeศ™te local numele pachetelor aplicaศ›iilor ศ™i limitele ferestrelor. Nu citeศ™te text, nu captureazฤƒ ecrane ศ™i nu trimite aceste date. Activeazฤƒ Luminozitate รฎn Configurare โ†’ Integrare Steam Cautฤƒ aplicaศ›ii Nicio aplicaศ›ie nu se potriveศ™te cu โ€ž%1$sโ€. @@ -3688,4 +3688,5 @@ Temperatura CPU Baterie Joc + Politica de confidenศ›ialitate diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bd6068361..31ccbb509 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -3597,7 +3597,7 @@ ะะตะฐะบั‚ะธะฒะฝะพ ะฒ Android? ยซะž ะฟั€ะธะปะพะถะตะฝะธะธยป โ†’ โ‹ฎ โ†’ ยซะ ะฐะทั€ะตัˆะธั‚ัŒ ะดะพัั‚ัƒะฟ ะบ ะฝะฐัั‚ั€ะพะนะบะฐะผ ั ะพะณั€ะฐะฝะธั‡ะตะฝะฝั‹ะผ ะดะพัั‚ัƒะฟะพะผยป ะ—ะฐะฑะปะพะบะธั€ะพะฒะฐะฝะพ Android ยท ยซะž ะฟั€ะธะปะพะถะตะฝะธะธยป โ†’ โ‹ฎ โ†’ ยซะ ะฐะทั€ะตัˆะธั‚ัŒ ะดะพัั‚ัƒะฟ ะบ ะฝะฐัั‚ั€ะพะนะบะฐะผ ั ะพะณั€ะฐะฝะธั‡ะตะฝะฝั‹ะผ ะดะพัั‚ัƒะฟะพะผยป ะšะฝะพะฟะบะฐ ยซะ”ะพะผะพะนยป DroidDeck - ะŸะตั€ะตะดะฐั‘ั‚ ะฝะฐะถะฐั‚ะธั ะบะฝะพะฟะบะธ ยซะ”ะพะผะพะนยป ะฒ Steam Guide, ะฟะพะบะฐ ะฐะบั‚ะธะฒะฝะฐ ัะตััะธั Steam ะธ DroidDeck ัะฒะปัะตั‚ัั ะณะปะฐะฒะฝั‹ะผ ัะบั€ะฐะฝะพะผ ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ. ะะต ัั‡ะธั‚ั‹ะฒะฐะตั‚ ัะพะดะตั€ะถะธะผะพะต ัะบั€ะฐะฝะฐ. + ะกะปัƒะถะฑะฐ ัะฟะตั†ะธะฐะปัŒะฝั‹ั… ะฒะพะทะผะพะถะฝะพัั‚ะตะน ะฒะบะปัŽั‡ะฐะตั‚ ัะพั‡ะตั‚ะฐะฝะธั Home/Guide ะธ ะพะฟั€ะตะดะตะปัะตั‚ ะฟั€ะธะปะพะถะตะฝะธั ะฝะฐ ะฝะธะถะฝะตะผ ัะบั€ะฐะฝะต. ะžะฝะฐ ะปะพะบะฐะปัŒะฝะพ ัั‡ะธั‚ั‹ะฒะฐะตั‚ ะธะผะตะฝะฐ ะฟะฐะบะตั‚ะพะฒ ะฟั€ะธะปะพะถะตะฝะธะน ะธ ะณั€ะฐะฝะธั†ั‹ ะพะบะพะฝ. ะกะปัƒะถะฑะฐ ะฝะต ั‡ะธั‚ะฐะตั‚ ั‚ะตะบัั‚, ะฝะต ะทะฐะฟะธัั‹ะฒะฐะตั‚ ัะบั€ะฐะฝ ะธ ะฝะต ะฟะตั€ะตะดะฐั‘ั‚ ัั‚ะธ ะดะฐะฝะฝั‹ะต. ะ’ะบะปัŽั‡ะธั‚ะต ยซะฏั€ะบะพัั‚ัŒยป ะฒ ยซะะฐัั‚ั€ะพะนะบะฐ โ†’ ะ˜ะฝั‚ะตะณั€ะฐั†ะธั ัะพ Steamยป ะŸะพะธัะบ ะฟั€ะธะปะพะถะตะฝะธะน ะะตั‚ ะฟั€ะธะปะพะถะตะฝะธะน ะฟะพ ะทะฐะฟั€ะพััƒ ยซ%1$sยป. @@ -3725,4 +3725,5 @@ ะขะตะผะฟะตั€ะฐั‚ัƒั€ะฐ ะฆะŸ ะ‘ะฐั‚ะฐั€ะตั ะ˜ะณั€ะฐ + ะŸะพะปะธั‚ะธะบะฐ ะบะพะฝั„ะธะดะตะฝั†ะธะฐะปัŒะฝะพัั‚ะธ diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ac2bf2669..29cae2303 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -3525,7 +3525,7 @@ Nedtonat i Android? Appinfo โ†’ โ‹ฎ โ†’ Tillรฅt begrรคnsade instรคllningar Blockerat av Android ยท Appinfo โ†’ โ‹ฎ โ†’ Tillรฅt begrรคnsade instรคllningar DroidDeck hemknapp - Skickar tryck pรฅ hemknappen till Steam Guide medan en Steam-session รคr i fokus och DroidDeck รคr standardappen fรถr startskรคrmen. Lรคser inte skรคrminnehรฅll. + Tillgรคnglighetstjรคnsten aktiverar Home/Guide-genvรคgar och upptรคcker appar pรฅ den nedre skรคrmen. Den lรคser apparnas paketnamn och fรถnstergrรคnser lokalt. Den lรคser inte text, tar inte skรคrmbilder och skickar inte dessa data. Slรฅ pรฅ Ljusstyrka under Konfiguration โ†’ Steam-integration Sรถk appar Inga appar matchar โ€%1$sโ€. @@ -3651,4 +3651,5 @@ CPU-temperatur Batteri Spel + Integritetspolicy diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 6ab90c0d9..71d65c7bc 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -3498,7 +3498,7 @@ เน€เธ›เน‡เธ™เธชเธตเน€เธ—เธฒเนƒเธ™ Android? เธ‚เน‰เธญเธกเธนเธฅเนเธญเธ› โ†’ โ‹ฎ โ†’ เธญเธ™เธธเธเธฒเธ•เธเธฒเธฃเธ•เธฑเน‰เธ‡เธ„เนˆเธฒเธ—เธตเนˆเธˆเธณเธเธฑเธ” เธ–เธนเธเธšเธฅเน‡เธญเธเน‚เธ”เธข Android ยท เธ‚เน‰เธญเธกเธนเธฅเนเธญเธ› โ†’ โ‹ฎ โ†’ เธญเธ™เธธเธเธฒเธ•เธเธฒเธฃเธ•เธฑเน‰เธ‡เธ„เนˆเธฒเธ—เธตเนˆเธˆเธณเธเธฑเธ” เธ›เธธเนˆเธกเธซเธ™เน‰เธฒเธซเธฅเธฑเธ DroidDeck - เธชเนˆเธ‡เธเธฒเธฃเธเธ”เธ›เธธเนˆเธกเธซเธ™เน‰เธฒเธซเธฅเธฑเธเน„เธ›เธขเธฑเธ‡ Steam Guide เธ‚เธ“เธฐเน€เธ‹เธชเธŠเธฑเธ™ Steam เธญเธขเธนเนˆเนƒเธ™เน‚เธŸเธเธฑเธชเนเธฅเธฐ DroidDeck เน€เธ›เน‡เธ™เนเธญเธ›เธซเธ™เน‰เธฒเธซเธฅเธฑเธเน€เธฃเธดเนˆเธกเธ•เน‰เธ™ เน„เธกเนˆเธญเนˆเธฒเธ™เน€เธ™เธทเน‰เธญเธซเธฒเธšเธ™เธซเธ™เน‰เธฒเธˆเธญ + เธšเธฃเธดเธเธฒเธฃเธเธฒเธฃเธŠเนˆเธงเธขเน€เธซเธฅเธทเธญเธžเธดเน€เธจเธฉเน€เธ›เธดเธ”เนƒเธŠเน‰เธ—เธฒเธ‡เธฅเธฑเธ” Home/Guide เนเธฅเธฐเธ•เธฃเธงเธˆเธˆเธฑเธšเนเธญเธ›เธšเธ™เธซเธ™เน‰เธฒเธˆเธญเธ”เน‰เธฒเธ™เธฅเนˆเธฒเธ‡ เธšเธฃเธดเธเธฒเธฃเธ™เธตเน‰เธญเนˆเธฒเธ™เธŠเธทเนˆเธญเนเธžเน‡เธเน€เธเธˆเนเธญเธ›เนเธฅเธฐเธ‚เธญเธšเน€เธ‚เธ•เธซเธ™เน‰เธฒเธ•เนˆเธฒเธ‡เธ เธฒเธขเนƒเธ™เธญเธธเธ›เธเธฃเธ“เนŒเน€เธ—เนˆเธฒเธ™เธฑเน‰เธ™ เน‚เธ”เธขเน„เธกเนˆเธญเนˆเธฒเธ™เธ‚เน‰เธญเธ„เธงเธฒเธก เน„เธกเนˆเธˆเธฑเธšเธ เธฒเธžเธซเธ™เน‰เธฒเธˆเธญ เนเธฅเธฐเน„เธกเนˆเธชเนˆเธ‡เธ‚เน‰เธญเธกเธนเธฅเน€เธซเธฅเนˆเธฒเธ™เธตเน‰ เน€เธ›เธดเธ”เธ„เธงเธฒเธกเธชเธงเนˆเธฒเธ‡เนƒเธ™เธเธฒเธฃเธ•เธฑเน‰เธ‡เธ„เนˆเธฒ โ†’ เธเธฒเธฃเธœเธชเธฒเธ™เธฃเธงเธก Steam เธ„เน‰เธ™เธซเธฒเนเธญเธ› เน„เธกเนˆเธกเธตเนเธญเธ›เธ—เธตเนˆเธ•เธฃเธ‡เธเธฑเธš โ€œ%1$sโ€ @@ -3623,4 +3623,5 @@ เธญเธธเธ“เธซเธ เธนเธกเธด CPU เนเธšเธ•เน€เธ•เธญเธฃเธตเนˆ เน€เธเธก + เธ™เน‚เธขเธšเธฒเธขเธ„เธงเธฒเธกเน€เธ›เน‡เธ™เธชเนˆเธงเธ™เธ•เธฑเธง diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 09c418629..e294a47f0 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -3525,7 +3525,7 @@ Android\'de gri mi gรถrรผnรผyor? Uygulama bilgileri โ†’ โ‹ฎ โ†’ KฤฑsฤฑtlanmฤฑลŸ ayarlara izin ver Android tarafฤฑndan engellendi ยท Uygulama bilgileri โ†’ โ‹ฎ โ†’ KฤฑsฤฑtlanmฤฑลŸ ayarlara izin ver DroidDeck Ana ekran dรผฤŸmesi - Bir Steam oturumu odaktayken ve DroidDeck varsayฤฑlan Ana ekran uygulamasฤฑyken Ana ekran dรผฤŸmesine basฤฑลŸlarฤฑ Steam Guide\'a iletir. Ekran iรงeriฤŸini okumaz. + EriลŸilebilirlik hizmeti Home/Guide kฤฑsayollarฤฑnฤฑ etkinleลŸtirir ve alt ekrandaki uygulamalarฤฑ algฤฑlar. Uygulama paket adlarฤฑnฤฑ ve pencere sฤฑnฤฑrlarฤฑnฤฑ cihazda okur. Metin okumaz, ekran gรถrรผntรผsรผ almaz veya bu verileri gรถndermez. Kurulum โ†’ Steam entegrasyonu bรถlรผmรผnde Parlaklฤฑk\'ฤฑ aรงฤฑn Uygulama ara โ€œ%1$sโ€ ile eลŸleลŸen uygulama yok. @@ -3651,4 +3651,5 @@ CPU sฤฑcaklฤฑฤŸฤฑ Pil Oyun + Gizlilik politikasฤฑ diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 789ddf36d..d83e493a0 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -3597,7 +3597,7 @@ ะะตะฐะบั‚ะธะฒะฝะพ ะฒ Android? ยซะŸั€ะพ ะดะพะดะฐั‚ะพะบยป โ†’ โ‹ฎ โ†’ ยซะ”ะพะทะฒะพะปะธั‚ะธ ะพะฑะผะตะถะตะฝั– ะฝะฐะปะฐัˆั‚ัƒะฒะฐะฝะฝัยป ะ—ะฐะฑะปะพะบะพะฒะฐะฝะพ Android ยท ยซะŸั€ะพ ะดะพะดะฐั‚ะพะบยป โ†’ โ‹ฎ โ†’ ยซะ”ะพะทะฒะพะปะธั‚ะธ ะพะฑะผะตะถะตะฝั– ะฝะฐะปะฐัˆั‚ัƒะฒะฐะฝะฝัยป ะšะฝะพะฟะบะฐ ยซะ”ะพะดะพะผัƒยป DroidDeck - ะŸะตั€ะตะดะฐั” ะฝะฐั‚ะธัะบะฐะฝะฝั ะบะฝะพะฟะบะธ ยซะ”ะพะดะพะผัƒยป ะฒ Steam Guide, ะฟะพะบะธ ะฐะบั‚ะธะฒะฝะธะน ัะตะฐะฝั Steam ั– DroidDeck ั” ั‚ะธะฟะพะฒะธะผ ะณะพะปะพะฒะฝะธะผ ะตะบั€ะฐะฝะพะผ. ะะต ะทั‡ะธั‚ัƒั” ะฒะผั–ัั‚ ะตะบั€ะฐะฝะฐ. + ะกะปัƒะถะฑะฐ ัะฟะตั†ั–ะฐะปัŒะฝะธั… ะผะพะถะปะธะฒะพัั‚ะตะน ะฒะผะธะบะฐั” ะบะพะผะฑั–ะฝะฐั†ั–ั— Home/Guide ั‚ะฐ ะฒะธะทะฝะฐั‡ะฐั” ะฟั€ะพะณั€ะฐะผะธ ะฝะฐ ะฝะธะถะฝัŒะพะผัƒ ะตะบั€ะฐะฝั–. ะ’ะพะฝะฐ ะปะพะบะฐะปัŒะฝะพ ะทั‡ะธั‚ัƒั” ะฝะฐะทะฒะธ ะฟะฐะบะตั‚ั–ะฒ ะฟั€ะพะณั€ะฐะผ ั– ะผะตะถั– ะฒั–ะบะพะฝ. ะกะปัƒะถะฑะฐ ะฝะต ั‡ะธั‚ะฐั” ั‚ะตะบัั‚, ะฝะต ะทะฐะฟะธััƒั” ะตะบั€ะฐะฝ ั– ะฝะต ะฟะตั€ะตะดะฐั” ั†ั– ะดะฐะฝั–. ะฃะฒั–ะผะบะฝั–ั‚ัŒ ยซะฏัะบั€ะฐะฒั–ัั‚ัŒยป ัƒ ยซะะฐะปะฐัˆั‚ัƒะฒะฐะฝะฝั โ†’ ะ†ะฝั‚ะตะณั€ะฐั†ั–ั ะทั– Steamยป ะŸะพัˆัƒะบ ะทะฐัั‚ะพััƒะฝะบั–ะฒ ะะตะผะฐั” ะทะฐัั‚ะพััƒะฝะบั–ะฒ ะทะฐ ะทะฐะฟะธั‚ะพะผ ยซ%1$sยป. @@ -3725,4 +3725,5 @@ ะขะตะผะฟะตั€ะฐั‚ัƒั€ะฐ ะฆะŸ ะ‘ะฐั‚ะฐั€ะตั ะ“ั€ะฐ + ะŸะพะปั–ั‚ะธะบะฐ ะบะพะฝั„ั–ะดะตะฝั†ั–ะนะฝะพัั‚ั– diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 0744e6f25..d89d51493 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -3498,7 +3498,7 @@ Bแป‹ lร m mแป trong Android? Thรดng tin แปฉng dแปฅng โ†’ โ‹ฎ โ†’ Cho phรฉp chแบฟ ฤ‘แป™ cร i ฤ‘แบทt bแป‹ hแบกn chแบฟ Bแป‹ Android chแบทn ยท Thรดng tin แปฉng dแปฅng โ†’ โ‹ฎ โ†’ Cho phรฉp chแบฟ ฤ‘แป™ cร i ฤ‘แบทt bแป‹ hแบกn chแบฟ Nรบt Home DroidDeck - Chuyแปƒn cรกc lแบงn nhแบฅn nรบt Home ฤ‘แบฟn Steam Guide khi phiรชn Steam ฤ‘ang ฤ‘ฦฐแปฃc chแปn vร  DroidDeck lร  แปฉng dแปฅng mร n hรฌnh chรญnh mแบทc ฤ‘แป‹nh. Khรดng ฤ‘แปc nแป™i dung mร n hรฌnh. + Dแป‹ch vแปฅ hแป— trแปฃ tiแบฟp cแบญn bแบญt phรญm tแบฏt Home/Guide vร  phรกt hiแป‡n แปฉng dแปฅng trรชn mร n hรฌnh dฦฐแป›i. Dแป‹ch vแปฅ nร y ฤ‘แปc tรชn gรณi แปฉng dแปฅng vร  giแป›i hแบกn cแปญa sแป• ngay trรชn thiแบฟt bแป‹. Dแป‹ch vแปฅ khรดng ฤ‘แปc vฤƒn bแบฃn, chแปฅp mร n hรฌnh hay gแปญi dแปฏ liแป‡u nร y. Bแบญt ฤแป™ sรกng trong Thiแบฟt lแบญp โ†’ Tรญch hแปฃp Steam Tรฌm แปฉng dแปฅng Khรดng cรณ แปฉng dแปฅng nร o khแป›p vแป›i โ€œ%1$sโ€. @@ -3623,4 +3623,5 @@ Nhiแป‡t ฤ‘แป™ CPU Pin Trรฒ chฦกi + Chรญnh sรกch quyแปn riรชng tฦฐ diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 651e5c7ae..ffcf62c86 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -3498,7 +3498,7 @@ ๅœจ Android ไธญๆ˜พ็คบไธบ็ฐ่‰ฒ๏ผŸๅบ”็”จไฟกๆฏ โ†’ โ‹ฎ โ†’ ๅ…่ฎธๅ—้™่ฎพ็ฝฎ ๅทฒ่ขซ Android ้˜ปๆญข ยท ๅบ”็”จไฟกๆฏ โ†’ โ‹ฎ โ†’ ๅ…่ฎธๅ—้™่ฎพ็ฝฎ DroidDeck ไธปๅฑๅน•ๆŒ‰้’ฎ - ๅฝ“ Steam ไผš่ฏๅค„ไบŽ็„ฆ็‚นไธ” DroidDeck ไธบ้ป˜่ฎคไธปๅฑๅน•ๅบ”็”จๆ—ถ๏ผŒๅฐ†ไธปๅฑๅน•ๆŒ‰้’ฎ็š„ๆŒ‰ไธ‹ๆ“ไฝœไผ ้€’็ป™ Steam Guide ๆŒ‰้’ฎใ€‚ไธไผš่ฏปๅ–ๅฑๅน•ๅ†…ๅฎนใ€‚ + ๆ— ้šœ็ขๆœๅŠก็”จไบŽๅฏ็”จHome/Guideๅฟซๆท้”ฎๅนถๆฃ€ๆต‹ไธ‹ๆ–นๅฑๅน•ไธŠ็š„ๅบ”็”จใ€‚ๆญคๆœๅŠกไป…ๅœจ่ฎพๅค‡ๆœฌๅœฐ่ฏปๅ–ๅบ”็”จๅŒ…ๅๅ’Œ็ช—ๅฃ่พน็•Œ๏ผŒไธ่ฏปๅ–ๆ–‡ๅญ—ใ€ไธๆˆชๅ–ๅฑๅน•๏ผŒไนŸไธๅ‘้€่ฟ™ไบ›ๆ•ฐๆฎใ€‚ ่ฏทๅœจโ€œ้…็ฝฎโ€โ†’โ€œSteam ้›†ๆˆโ€ไธญๅผ€ๅฏไบฎๅบฆ ๆœ็ดขๅบ”็”จ ๆฒกๆœ‰ไธŽโ€œ%1$sโ€ๅŒน้…็š„ๅบ”็”จใ€‚ @@ -3623,4 +3623,5 @@ CPU ๆธฉๅบฆ ็”ตๆฑ  ๆธธๆˆ + ้š็งๆ”ฟ็ญ– diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index ab5c9458c..2936b69ab 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -3498,7 +3498,7 @@ ๅœจ Android ไธญๅ‘ˆ็ฐ่‰ฒ๏ผŸๆ‡‰็”จ็จ‹ๅผ่ณ‡่จŠ โ†’ โ‹ฎ โ†’ ๅ…่จฑๅ—้™ๅˆถ็š„่จญๅฎš ๅทฒ่ขซ Android ๅฐ้Ž– ยท ๆ‡‰็”จ็จ‹ๅผ่ณ‡่จŠ โ†’ โ‹ฎ โ†’ ๅ…่จฑๅ—้™ๅˆถ็š„่จญๅฎš DroidDeck ไธป็•ซ้ขๆŒ‰้ˆ• - ็•ถ Steam ๆœƒ่ฉฑ่™•ๆ–ผ็„ฆ้ปžไธ” DroidDeck ็‚บ้ ่จญไธป็•ซ้ขๆ‡‰็”จ็จ‹ๅผๆ™‚๏ผŒๅฐ‡ไธป็•ซ้ขๆŒ‰้ˆ•็š„ๆŒ‰ๅฃ“ๅ‚ณ้€็ตฆ Steam Guideใ€‚ไธๆœƒ่ฎ€ๅ–่žขๅน•ๅ…งๅฎนใ€‚ + ็„ก้šœ็ค™ๆœๅ‹™็”จๆ–ผๅ•Ÿ็”จHome/Guideๅฟซๆท้ต๏ผŒไธฆๅตๆธฌไธ‹ๆ–น่žขๅน•ไธŠ็š„ๆ‡‰็”จ็จ‹ๅผใ€‚ๆญคๆœๅ‹™ๅชๅœจ่ฃ็ฝฎๆœฌๆฉŸ่ฎ€ๅ–ๆ‡‰็”จ็จ‹ๅผๅฅ—ไปถๅ็จฑๅŠ่ฆ–็ช—้‚Š็•Œ๏ผŒไธๆœƒ่ฎ€ๅ–ๆ–‡ๅญ—ใ€ๆ“ทๅ–่žขๅน•ๆˆ–ๅ‚ณ้€้€™ไบ›่ณ‡ๆ–™ใ€‚ ่ซ‹ๅœจใ€Œๅˆๅง‹่จญๅฎš โ†’ Steam ๆ•ดๅˆใ€ไธญ้–‹ๅ•Ÿใ€Œไบฎๅบฆใ€ ๆœๅฐ‹ๆ‡‰็”จ็จ‹ๅผ ๆฒ’ๆœ‰็ฌฆๅˆใ€Œ%1$sใ€็š„ๆ‡‰็”จ็จ‹ๅผใ€‚ @@ -3623,4 +3623,5 @@ CPU ๆบซๅบฆ ้›ปๆฑ  ้Šๆˆฒ + ็ง้šฑๆ”ฟ็ญ– diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b991ac2b0..bfb47d4a1 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -3498,7 +3498,7 @@ ๅœจ Android ไธญๅ‘ˆ็ฐ่‰ฒ๏ผŸๆ‡‰็”จ็จ‹ๅผ่ณ‡่จŠ โ†’ โ‹ฎ โ†’ ๅ…่จฑๅ—้™ๅˆถ็š„่จญๅฎš ๅทฒ่ขซ Android ๅฐ้Ž– ยท ๆ‡‰็”จ็จ‹ๅผ่ณ‡่จŠ โ†’ โ‹ฎ โ†’ ๅ…่จฑๅ—้™ๅˆถ็š„่จญๅฎš DroidDeck ไธป็•ซ้ขๆŒ‰้ˆ• - ็•ถ Steam ๅทฅไฝœ้šŽๆฎต่™•ๆ–ผ็„ฆ้ปžไธ” DroidDeck ็‚บ้ ่จญไธป็•ซ้ขๆ‡‰็”จ็จ‹ๅผๆ™‚๏ผŒๅฐ‡ไธป็•ซ้ขๆŒ‰้ˆ•็š„ๆŒ‰ๅฃ“ๅ‚ณ้€็ตฆ Steam Guideใ€‚ไธๆœƒ่ฎ€ๅ–่žขๅน•ๅ…งๅฎนใ€‚ + ็„ก้šœ็ค™ๆœๅ‹™็”จๆ–ผๅ•Ÿ็”จHome/Guideๅฟซๆท้ต๏ผŒไธฆๅตๆธฌไธ‹ๆ–น่žขๅน•ไธŠ็š„ๆ‡‰็”จ็จ‹ๅผใ€‚ๆญคๆœๅ‹™ๅƒ…ๅœจ่ฃ็ฝฎๆœฌๆฉŸ่ฎ€ๅ–ๆ‡‰็”จ็จ‹ๅผๅฅ—ไปถๅ็จฑๅŠ่ฆ–็ช—้‚Š็•Œ๏ผŒไธๆœƒ่ฎ€ๅ–ๆ–‡ๅญ—ใ€ๆ“ทๅ–่žขๅน•ๆˆ–ๅ‚ณ้€้€™ไบ›่ณ‡ๆ–™ใ€‚ ่ซ‹ๅœจใ€Œๅˆๅง‹่จญๅฎš โ†’ Steam ๆ•ดๅˆใ€ไธญ้–‹ๅ•Ÿใ€Œไบฎๅบฆใ€ ๆœๅฐ‹ๆ‡‰็”จ็จ‹ๅผ ๆฒ’ๆœ‰็ฌฆๅˆใ€Œ%1$sใ€็š„ๆ‡‰็”จ็จ‹ๅผใ€‚ @@ -3623,4 +3623,5 @@ CPU ๆบซๅบฆ ้›ปๆฑ  ้Šๆˆฒ + ้šฑ็งๆฌŠๆ”ฟ็ญ– diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4655dbaa..9ad79f006 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3663,7 +3663,7 @@ Greyed out in Android? App info โ†’ โ‹ฎ โ†’ Allow restricted settings Blocked by Android ยท App info โ†’ โ‹ฎ โ†’ Allow restricted settings DroidDeck Home button - Pass Home button presses to Steam Guide while a Steam session is focused and DroidDeck is the default Home app. Does not read screen content. + Accessibility enables Home/Guide shortcuts and detects apps on the lower screen. This service reads app package names and window bounds locally. It does not read text, capture screens, or send this data. Turn on Brightness in Setup โ†’ Steam integration Restoring your software Reinstalling the apps you added after a DroidDeck update. @@ -3685,4 +3685,5 @@ Later All files access Local network + Privacy policy diff --git a/app/src/play/AndroidManifest.xml b/app/src/play/AndroidManifest.xml new file mode 100644 index 000000000..a50bde04a --- /dev/null +++ b/app/src/play/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/test/java/com/droiddeck/launcher/PlayUpdatesTest.kt b/app/src/test/java/com/droiddeck/launcher/PlayUpdatesTest.kt new file mode 100644 index 000000000..4727bc402 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/PlayUpdatesTest.kt @@ -0,0 +1,83 @@ +package com.droiddeck.launcher + +import android.app.Activity +import android.os.Handler +import android.os.Looper +import com.droiddeck.launcher.core.DroidDeckTestRunner +import com.google.android.play.core.appupdate.testing.FakeAppUpdateManager +import com.google.android.play.core.install.model.InstallErrorCode +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.Robolectric +import org.robolectric.Shadows.shadowOf + +@RunWith(DroidDeckTestRunner::class) +class PlayUpdatesTest { + @Test fun availablePlayUpdateSetsTheExistingUpdateIndicatorWithoutInstalling() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + Robolectric.buildActivity(Activity::class.java).setup().use { controller -> + val activity = controller.get() + val manager = FakeAppUpdateManager(activity) + manager.setUpdateAvailable(Int.MAX_VALUE) + val menu = UpdatesMenu(activity, Handler(Looper.getMainLooper())) { manager } + menu.check(true) + shadowOf(Looper.getMainLooper()).idle() + assertTrue(menu.hasUpdate) + assertTrue(menu.state().hasUpdate) + assertFalse(menu.checking) + assertNull(menu.stage) + assertNull(shadowOf(activity).nextStartedActivity) + assertFalse(manager.isImmediateFlowVisible) + assertFalse(manager.isConfirmationDialogVisible) + menu.actions().onOpenPlay() + val intent = shadowOf(activity).nextStartedActivity + assertEquals("market://details?id=${activity.packageName}", intent.dataString) + assertEquals("com.android.vending", intent.`package`) + } + } + + @Test fun playCanReportNoUpdateWithoutConsultingAnExternalCatalog() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + Robolectric.buildActivity(Activity::class.java).setup().use { controller -> + val manager = FakeAppUpdateManager(controller.get()) + manager.setUpdateNotAvailable() + val menu = UpdatesMenu(controller.get(), Handler(Looper.getMainLooper())) { manager } + menu.check(true) + shadowOf(Looper.getMainLooper()).idle() + assertEquals(false, menu.playUpdateAvailable) + assertFalse(menu.hasUpdate) + assertNull(menu.catalog) + assertTrue(menu.state().playCheckedAt > 0) + } + } + + @Test fun failedPlayCheckDoesNotClaimTheAppIsCurrent() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + Robolectric.buildActivity(Activity::class.java).setup().use { controller -> + val manager = FakeAppUpdateManager(controller.get()) + manager.setInstallErrorCode(InstallErrorCode.ERROR_API_NOT_AVAILABLE) + val menu = UpdatesMenu(controller.get(), Handler(Looper.getMainLooper())) { manager } + menu.check(true) + shadowOf(Looper.getMainLooper()).idle() + assertNull(menu.playUpdateAvailable) + assertNotNull(menu.error) + assertFalse(menu.checking) + } + } + + @Test fun playCannotOpenTheUnknownPackageInstallationSettings() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + Robolectric.buildActivity(Activity::class.java).setup().use { controller -> + val activity = controller.get() + val menu = UpdatesMenu(activity, Handler(Looper.getMainLooper())) + menu.actions().onAllowInstalls() + assertFalse(menu.askPermission) + assertNull(shadowOf(activity).nextStartedActivity) + } + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/core/ComponentPayloadStoreTest.kt b/app/src/test/java/com/droiddeck/launcher/core/ComponentPayloadStoreTest.kt new file mode 100644 index 000000000..7a20b00cb --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/ComponentPayloadStoreTest.kt @@ -0,0 +1,133 @@ +package com.droiddeck.launcher.core + +import org.json.JSONArray +import org.json.JSONObject +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertThrows +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import org.junit.runner.RunWith +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.IOException +import java.nio.file.Files +import java.security.MessageDigest +import java.util.function.BooleanSupplier +import java.util.function.Consumer + +@RunWith(DroidDeckTestRunner::class) +class ComponentPayloadStoreTest { + @get:Rule val temporary = TemporaryFolder() + private val url = "https://example.test/component" + private val content = ByteArray(180000) { (it % 251).toByte() } + private val digest get() = hash(content) + private fun hash(bytes: ByteArray) = MessageDigest.getInstance("SHA-256").digest(bytes) + .joinToString("") { "%02x".format(it.toInt() and 255) } + + private fun fixture(transform: (JSONObject, MutableMap) -> Unit = { _, _ -> }): ComponentPayloadStore { + val assets = mutableMapOf() + val chunks = JSONArray() + content.toList().chunked(60000).forEachIndexed { number, bytes -> + val path = "play-components/$digest/${number.toString().padStart(4, '0')}" + val data = bytes.toByteArray() + assets[path] = data + chunks.put(JSONObject().put("asset", path).put("size", data.size).put("sha256", hash(data))) + } + val entry = JSONObject().put("size", content.size).put("sha256", digest).put("chunks", chunks) + transform(entry, assets) + val recipe = "play-components/recipes/${entry.getString("sha256")}.json" + assets[recipe] = JSONObject().put("chunks", entry.getJSONArray("chunks")).toString().toByteArray() + entry.remove("chunks") + entry.put("recipe", recipe) + assets["play-components/index.json"] = JSONObject().put("schema", 1) + .put("entries", JSONObject().put(url, entry)).toString().toByteArray() + return ComponentPayloadStore { path -> + ByteArrayInputStream(assets[path] ?: throw IOException("Missing asset: $path")) + } + } + + @Test fun reassemblesChunksAndVerifiesFullPayload() { + val output = ByteArrayOutputStream() + assertEquals(content.size.toLong(), fixture().copy(url, output, content.size.toLong(), digest)) + assertArrayEquals(content, output.toByteArray()) + } + + @Test fun missingComponentCannotUseNetwork() { + assertThrows(IOException::class.java) { + fixture().copy("https://other.test/component", ByteArrayOutputStream(), Long.MAX_VALUE) + } + } + + @Test fun corruptChunkPreservesPreviouslyInstalledDestination() { + val store = fixture { entry, assets -> + val path = entry.getJSONArray("chunks").getJSONObject(1).getString("asset") + assets[path] = ByteArray(60000) + } + val destination = temporary.newFile("installed") + destination.writeText("existing") + assertThrows(IOException::class.java) { store.install(url, destination) } + assertEquals("existing", destination.readText()) + assertEquals(listOf("installed"), temporary.root.listFiles()!!.map { it.name }) + } + + @Test fun cancellationDuringCopyPreservesDestinationAndStopsProgress() { + var cancelled = false + var progressCount = 0 + val destination = temporary.newFile("installed") + destination.writeText("existing") + assertThrows(IOException::class.java) { + fixture().install(url, destination, cancelled = BooleanSupplier { cancelled }, progress = Consumer { + progressCount++ + cancelled = true + }) + } + assertEquals(1, progressCount) + assertEquals("existing", destination.readText()) + } + + @Test fun successfulInstallAtomicallyReplacesDestination() { + val destination = temporary.newFile("installed") + destination.writeText("existing") + fixture().install(url, destination, digest) + assertArrayEquals(content, destination.readBytes()) + assertEquals(listOf("installed"), temporary.root.listFiles()!!.map { it.name }) + } + + @Test fun wrongVersionAndOversizedMetadataAreRejectedBeforeWritingBytes() { + val output = ByteArrayOutputStream() + assertThrows(IOException::class.java) { fixture().copy(url, output, Long.MAX_VALUE, "0".repeat(64)) } + assertThrows(IOException::class.java) { fixture().copy(url, output, content.size - 1L) } + assertEquals(0, output.size()) + } + + @Test fun truncatedAndOverlongChunksFailVerification() { + for (size in listOf(59999, 60001)) { + val store = fixture { entry, assets -> + assets[entry.getJSONArray("chunks").getJSONObject(0).getString("asset")] = ByteArray(size) + } + assertThrows(IOException::class.java) { store.copy(url, ByteArrayOutputStream(), Long.MAX_VALUE) } + } + } + + @Test fun traversalPathIsRejectedWithoutOpeningIt() { + val store = fixture { entry, _ -> entry.getJSONArray("chunks").getJSONObject(0).put("asset", "../secret") } + assertThrows(IOException::class.java) { store.copy(url, ByteArrayOutputStream(), Long.MAX_VALUE) } + } + + @Test fun fullDigestIsCheckedEvenWhenEachChunkIsValid() { + val store = fixture { entry, _ -> entry.put("sha256", "0".repeat(64)) } + assertThrows(IOException::class.java) { store.copy(url, ByteArrayOutputStream(), Long.MAX_VALUE) } + } + + @Test fun cancelledBeforeStartCreatesNoDestination() { + val destination = temporary.root.resolve("installed") + assertThrows(IOException::class.java) { + fixture().install(url, destination, cancelled = BooleanSupplier { true }) + } + assertFalse(Files.exists(destination.toPath())) + assertEquals(0, temporary.root.listFiles()!!.size) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/core/PlayDistributionTest.kt b/app/src/test/java/com/droiddeck/launcher/core/PlayDistributionTest.kt new file mode 100644 index 000000000..09a177a33 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/PlayDistributionTest.kt @@ -0,0 +1,111 @@ +package com.droiddeck.launcher.core + +import android.content.Context +import android.content.pm.PackageManager +import androidx.test.core.app.ApplicationProvider +import com.droiddeck.launcher.BuildConfig +import com.droiddeck.launcher.update.SelfInstaller +import com.droiddeck.launcher.session.ProtonExtras +import com.droiddeck.launcher.runtime.DesktopCatalog +import com.droiddeck.launcher.runtime.LinuxRuntime +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertThrows +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import org.junit.runner.RunWith +import java.net.ServerSocket +import java.net.SocketTimeoutException +import java.io.File +import java.util.function.BooleanSupplier + +@RunWith(DroidDeckTestRunner::class) +class PlayDistributionTest { + @get:Rule val temporary = TemporaryFolder() + private val context: Context = ApplicationProvider.getApplicationContext() + + @Test fun mergedManifestRestrictsPackageInstallationToStandaloneDistribution() { + val permissions = context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS) + .requestedPermissions.orEmpty() + assertEquals(!BuildConfig.PLAY_DISTRIBUTION, "android.permission.REQUEST_INSTALL_PACKAGES" in permissions) + } + + @Test fun missingPlayComponentCannotContactAnExternalServerOrReplaceExistingData() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + ComponentDownloads.init(context) + val destination = temporary.newFile("component") + destination.writeText("existing") + ServerSocket(0).use { server -> + server.soTimeout = 100 + assertFalse(ComponentDownloads.downloadFile("http://127.0.0.1:${server.localPort}/missing", destination, true, null)) + assertThrows(SocketTimeoutException::class.java) { server.accept() } + } + assertEquals("existing", destination.readText()) + } + + @Test fun playDistributionRejectsSelfInstallationBeforeOpeningPackageInstaller() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + assertFalse(SelfInstaller.canInstall(context)) + assertThrows(IllegalStateException::class.java) { SelfInstaller.install(context, temporary.newFile("update.apk")) } + } + + @Test fun playOffersOnlyDroidDeckProtonWhileStandaloneKeepsItsChoices() { + assertEquals(if (BuildConfig.PLAY_DISTRIBUTION) listOf("droiddeck") else listOf("ge", "cachyos", "droiddeck"), + ProtonExtras.tools.map { it.id }) + } + + @Test fun freshPlayInstallationRequiresDroidDeckProtonInsteadOfValveSeed() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + assertEquals(true, DesktopCatalog.protonSeedNeeded(context)) + val directory = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d/DroidDeck-Proton-test") + directory.mkdirs() + File(directory, "toolmanifest.vdf").writeText("fixture") + assertFalse(DesktopCatalog.protonSeedNeeded(context)) + } + + @Test fun cancelledProtonBootstrapStopsBeforeRuntimeChanges() { + val root = LinuxRuntime.rootDir(context) + val before = root.exists() + val tool = ProtonExtras.tools.first { it.id == ProtonExtras.OWN } + val result = ProtonExtras.install(context, tool, BooleanSupplier { true }) { _, _ -> + throw AssertionError("Cancelled bootstrap reported installation progress") + } + assertEquals(context.getString(com.droiddeck.launcher.R.string.pextra_interrupted), result) + assertEquals(before, root.exists()) + assertFalse(ProtonExtras.installInProgress) + } + + @Test fun standaloneCatalogCannotOfferAnUnbundledFexVersionAfterPlayUpgrade() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + val old = File(context.filesDir, "fex-catalog.json") + val body = """{"release":"fex-2601-r1","url":"https://github.com/Droid-Deck/DroidDeck-Components/releases/download/fex-2601-r1/fex.tzst","sha256":"${"a".repeat(64)}"}""" + old.writeText(body) + assertEquals("fex-2601-r1", com.droiddeck.launcher.session.FexCatalog.parse(body)?.tag) + assertEquals(null, com.droiddeck.launcher.session.FexCatalog.cached(context)) + assertEquals(body, old.readText()) + } + + @Test fun extraDesktopEmulatorsAreOnlyOfferedByTheStandaloneDistribution() { + val entry = DesktopCatalog.Entry("emulators", "Emulators", 1, "r1", "tar", "https://example.test/emulators.tar.zst", + "a".repeat(64), 100, "", "", "Game") + assertEquals(!BuildConfig.PLAY_DISTRIBUTION, DesktopCatalog.offered(entry)) + val desktop = DesktopCatalog.Entry(DesktopCatalog.DESKTOP_ID, "Desktop", 1, "r1", "tar", + "https://example.test/desktop.tar.zst", "b".repeat(64), 100, "", "", "") + assertEquals(true, DesktopCatalog.offered(desktop)) + } + + @Test fun playDoesNotResumeOrDiscardAnOldExtraEmulatorInstallation() { + if (!BuildConfig.PLAY_DISTRIBUTION) return + val root = LinuxRuntime.rootDir(context).apply { mkdirs() } + val entry = DesktopCatalog.Entry("emulators", "Emulators", 1, "r1", "tar", "https://example.test/emulators.tar.zst", + "a".repeat(64), 100, "", "", "Game") + val journal = File(root, ".droiddeck-pkg-emulators.installing") + val original = DesktopCatalog.entryJson(entry).toString() + journal.writeText(original) + assertEquals(emptyList(), DesktopCatalog.interrupted(context)) + assertEquals(null, DesktopCatalog.resumeInterrupted(context, null)) + assertEquals(original, journal.readText()) + assertEquals(listOf("emulators"), DesktopCatalog.interrupted(root).map { it.id }) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt b/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt index 4aac1334e..b94a6cfb8 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt @@ -43,6 +43,15 @@ class SteamIntegrationShortcutsTest { assertTrue(SteamIntegration.shortcutsChosen(context)) } + @Test fun enablingTheSystemServiceDoesNotBypassDisclosureConsent() { + choose(service.flattenToString()) + assertTrue(SteamIntegration.shortcutsChosen(context)) + assertFalse(SteamIntegration.accessibilityConsented(context)) + SteamIntegration.acceptAccessibility(context) + assertTrue(SteamIntegration.accessibilityConsented(context)) + assertTrue(SteamIntegration.shortcutsChosen(context)) + } + @Test fun openingShortcutSetupListsTheServiceAndBackingOutHidesItAgain() { SteamIntegration.setShortcutsListed(context, true) assertTrue(listed()) diff --git a/app/src/test/java/com/droiddeck/launcher/session/ProtonExtrasTest.kt b/app/src/test/java/com/droiddeck/launcher/session/ProtonExtrasTest.kt index a961badd3..a75b5fba8 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/ProtonExtrasTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/ProtonExtrasTest.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.BuildConfig +import com.droiddeck.launcher.core.ComponentDownloads import org.json.JSONArray import org.json.JSONObject import org.junit.Assert.assertEquals @@ -21,7 +23,7 @@ import java.io.File class ProtonExtrasTest { @get:Rule val temp = TemporaryFolder() - private fun tool(id: String) = ProtonExtras.tools.single { it.id == id } + private fun tool(id: String) = ProtonExtras.sources.single { it.id == id } private fun asset(name: String, digest: String? = null) = JSONObject() .put("name", name) @@ -47,8 +49,8 @@ class ProtonExtrasTest { } @Test - fun theThreeSourcesInOrder() { - assertEquals(listOf("ge", "cachyos", "droiddeck"), ProtonExtras.tools.map { it.id }) + fun theSourcesForTheDistributionInOrder() { + assertEquals(if (BuildConfig.PLAY_DISTRIBUTION) listOf("droiddeck") else listOf("ge", "cachyos", "droiddeck"), ProtonExtras.tools.map { it.id }) val droiddeck = tool("droiddeck") assertEquals("DroidDeck-Proton", droiddeck.name) assertEquals("DroidDeck-Proton", droiddeck.prefix) @@ -70,6 +72,16 @@ class ProtonExtrasTest { assertNull(picked.sha256) } + @Test fun preparedProtonArchiveIsRecognizedOnlyByThePlayDistribution() { + val entry = asset("DroidDeck-Proton-11-11.11-aarch64.tar.zst", "sha256:" + "ab".repeat(32)) + .put("browser_download_url", "droiddeck-bundle://droiddeck-proton/DroidDeck-Proton-11-11.11-aarch64.tar.zst") + val picked = ProtonExtras.pickAsset(tool("droiddeck"), JSONArray().put(release("DroidDeck-Proton-11-11.11", entry))) + if (BuildConfig.PLAY_DISTRIBUTION) { + assertEquals("ab".repeat(32), picked?.sha256) + assertEquals(entry.getString("browser_download_url"), picked?.url) + } else assertNull(picked) + } + @Test fun githubsDigestIsKeptBesideTheSha512File() { val sum = "ab".repeat(32) @@ -146,7 +158,7 @@ class ProtonExtrasTest { .put("ge", JSONObject().put("tag", "GE-Proton11-7").put("at", now - 60_000)) .put("cachyos", JSONObject().put("tag", "cachyos-11.0-20261005-slr").put("at", now - 60_000)) .put("droiddeck", JSONObject().put("tag", "DroidDeck-Proton-11-7.6").put("at", now - ProtonExtras.CHECK_EVERY_MS + 60_000)) - File(context.filesDir, "proton-latest.json").writeText(latest.toString()) + File(context.filesDir, ComponentDownloads.catalogName("proton-latest.json")).writeText(latest.toString()) assertFalse(ProtonExtras.checkLatest(context, now = now)) assertEquals("DroidDeck-Proton-11-7.6", ProtonExtras.update(context, tool("droiddeck"))) assertNull(ProtonExtras.update(context, tool("ge"))) @@ -175,28 +187,32 @@ class ProtonExtrasTest { @Test fun removingABuildDropsItsStoredOriginalsAndSelections() { val context = RuntimeEnvironment.getApplication() + val source = if (BuildConfig.PLAY_DISTRIBUTION) "droiddeck" else "ge" + val prefix = if (BuildConfig.PLAY_DISTRIBUTION) "DroidDeck-Proton-" else "GE-Proton" + val removedId = "${prefix}11-7" + val keptId = "${prefix}11-8" val tools = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d") File(LinuxRuntime.rootDir(context), "root/.local/share/droiddeck-components").mkdirs() - installTool(tools, "GE-Proton11-7") - val kept = installTool(tools, "GE-Proton11-8").apply { + installTool(tools, removedId) + val kept = installTool(tools, keptId).apply { File(this, "files/lib/wine").mkdirs() File(this, "proton").writeText("") } val originals = File(context.filesDir, "components/originals") - for (id in listOf("GE-Proton11-7", "GE-Proton11-8")) File(originals, "$id/$id/dxvk.wcp").apply { parentFile?.mkdirs(); writeText("x") } - val pick = JSONObject().put("dxvk", JSONObject().put("file", "dxvk.wcp").put("protonVersion", "GE-Proton11-7")) + for (id in listOf(removedId, keptId)) File(originals, "$id/$id/dxvk.wcp").apply { parentFile?.mkdirs(); writeText("x") } + val pick = JSONObject().put("dxvk", JSONObject().put("file", "dxvk.wcp").put("protonVersion", removedId)) File(context.filesDir, "components/state.json").writeText(JSONObject() - .put("active", JSONObject().put("GE-Proton11-7", pick).put("GE-Proton11-8", pick)) - .put("queued", JSONObject().put("GE-Proton11-7", pick)).toString()) - ProtonExtras.remove(context, tool("ge"), "GE-Proton11-7") - assertFalse(File(originals, "GE-Proton11-7").exists()) - assertTrue(File(originals, "GE-Proton11-8/GE-Proton11-8/dxvk.wcp").isFile) + .put("active", JSONObject().put(removedId, pick).put(keptId, pick)) + .put("queued", JSONObject().put(removedId, pick)).toString()) + ProtonExtras.remove(context, tool(source), removedId) + assertFalse(File(originals, removedId).exists()) + assertTrue(File(originals, "$keptId/$keptId/dxvk.wcp").isFile) val state = JSONObject(File(context.filesDir, "components/state.json").readText()) - assertFalse(state.getJSONObject("active").has("GE-Proton11-7")) - assertFalse(state.getJSONObject("queued").has("GE-Proton11-7")) - assertTrue(state.getJSONObject("active").has("GE-Proton11-8")) + assertFalse(state.getJSONObject("active").has(removedId)) + assertFalse(state.getJSONObject("queued").has(removedId)) + assertTrue(state.getJSONObject("active").has(keptId)) ComponentsManager.forgetProton(context, kept.name) - assertTrue(File(originals, "GE-Proton11-8/GE-Proton11-8/dxvk.wcp").isFile) + assertTrue(File(originals, "$keptId/$keptId/dxvk.wcp").isFile) } @Test @@ -217,7 +233,7 @@ class ProtonExtrasTest { val context = RuntimeEnvironment.getApplication() val tools = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d") tools.deleteRecursively() - File(context.filesDir, "proton-latest.json").writeText( + File(context.filesDir, ComponentDownloads.catalogName("proton-latest.json")).writeText( """{"droiddeck":{"tag":"DroidDeck-Proton-11-11.4","at":1},"ge":{"tag":"GE-Proton11-7","at":1}}""") ProtonExtras.setDeclined(context, false) assertEquals("DroidDeck-Proton-11-11.4", ProtonExtras.missing(context, tool("droiddeck"))) diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BuildWatermarkTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BuildWatermarkTest.kt index 35f2c8cf0..5ad619c56 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/BuildWatermarkTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/BuildWatermarkTest.kt @@ -7,20 +7,20 @@ import org.junit.Test class BuildWatermarkTest { @Test fun stableAndPreviewBuildsHaveNoWatermark() { - assertNull(BuildWatermark.lines(pr = 0, ci = true, commit = "abcdef0123", title = "", branch = "")) + assertNull(BuildWatermark.lines(pr = 0, ci = true, commit = "abcdef0123", title = "", branch = "", play = false)) } @Test fun prBuildShowsNumberHashAndTitle() { assertEquals( listOf("PR-1234 | abcdef0", "Fix: foo the bar"), - BuildWatermark.lines(pr = 1234, ci = true, commit = "abcdef0123", title = "Fix: foo the bar", branch = "x"), + BuildWatermark.lines(pr = 1234, ci = true, commit = "abcdef0123", title = "Fix: foo the bar", branch = "x", play = false), ) } @Test fun longTitlesTruncateAtEightyCharacters() { - val lines = BuildWatermark.lines(pr = 7, ci = true, commit = "abcdef0", title = "a".repeat(120), branch = "")!! + val lines = BuildWatermark.lines(pr = 7, ci = true, commit = "abcdef0", title = "a".repeat(120), branch = "", play = false)!! assertEquals(80, lines[1].length) assertEquals('โ€ฆ', lines[1].last()) } @@ -29,7 +29,16 @@ class BuildWatermarkTest { fun localBuildShowsBranch() { assertEquals( listOf("LOCAL | abcdef0", "feat/thing"), - BuildWatermark.lines(pr = 0, ci = false, commit = "abcdef0123", title = "", branch = "feat/thing"), + BuildWatermark.lines(pr = 0, ci = false, commit = "abcdef0123", title = "", branch = "feat/thing", play = false), ) } + + @Test + fun playBuildShowsOnlyTheShortSourceCommit() { + for (ci in listOf(true, false)) for (pr in listOf(0, 1234)) { + assertEquals(listOf("abcdef0"), BuildWatermark.lines( + pr = pr, ci = ci, commit = "abcdef0123456789", title = "Build title", branch = "playstore", play = true, + )) + } + } } diff --git a/settings.gradle b/settings.gradle index d61486498..47ec19064 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,3 +16,18 @@ dependencyResolutionManagement { rootProject.name = "DroidDeck" include ':app' + +if (providers.gradleProperty('playDistribution').getOrElse('false').toBoolean()) { + def payloads = file('build/playstore-payloads') + def registry = new File(payloads, 'modules.json') + if (!registry.isFile()) throw new GradleException('Stage verified Play payloads before building the Play distribution') + def modules = new groovy.json.JsonSlurper().parse(registry) + if (!(modules instanceof List) || modules.isEmpty() || modules.size() > 10 || modules.unique(false).size() != modules.size()) { + throw new GradleException('Invalid Play feature module registry') + } + modules.each { name -> + if (!(name instanceof String) || !(name ==~ /playpayload[0-9]{2}/)) throw new GradleException('Invalid Play feature module name') + include ":${name}" + project(":${name}").projectDir = new File(payloads, name) + } +} diff --git a/tools/aaudio-sink/build.sh b/tools/aaudio-sink/build.sh index 049675f49..0f15a9838 100755 --- a/tools/aaudio-sink/build.sh +++ b/tools/aaudio-sink/build.sh @@ -7,7 +7,7 @@ mkdir -p "$OUTDIR" API=26 HERE=$(cd "$(dirname "$0")" && pwd) REPO=$(cd "$HERE/../.." && pwd) -LIBS="$REPO/app/src/main/jniLibs/arm64-v8a" +LIBS=${DROIDDECK_PULSE_LIBS:-"$REPO/app/src/main/jniLibs/arm64-v8a"} case "$(uname -s):$(uname -m)" in Darwin:arm64) NDK_HOST=darwin-arm64 ;; Darwin:x86_64) NDK_HOST=darwin-x86_64 ;; @@ -38,7 +38,7 @@ build_one() { local src=$1 OUT=$2 extra=$3 cc=${4:-$CC} "$cc" -O2 -shared -fPIC -Wall -Wno-unused-parameter -Wno-error=int-conversion -Wno-visibility -DHAVE_CONFIG_H \ -I"$INC" -I"$PA_SRC/src" -I"$HERE" \ - -o "$OUT" "$HERE/$src" \ + -Wl,-z,max-page-size=16384 -o "$OUT" "$HERE/$src" \ -L"$LIBS" -l:libpulsecore-13.0.so -l:libpulsecommon-13.0.so -l:libpulse.so $extra "$TOOLCHAIN/llvm-strip" --strip-unneeded "$OUT" for sym in pa__init pa__done pa__get_author pa__get_description pa__get_usage pa__get_version pa__load_once; do diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-emulators b/tools/linuxfs/overlay/usr/local/bin/droiddeck-emulators index a937b4e8e..9bcb650a3 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-emulators +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-emulators @@ -1,5 +1,8 @@ #!/bin/bash set -u +if compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null; then + exit 2 +fi export FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap cores="libretro-core-info libretro-beetle-pce-fast libretro-beetle-psx libretro-beetle-vb libretro-beetle-wswan libretro-bsnes-mercury-performance libretro-desmume libretro-gambatte libretro-genesisplusgx libretro-mgba diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex-update b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex-update index d88a4a97e..91bb5353c 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex-update +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex-update @@ -16,7 +16,11 @@ fex_install() { local tag=$1 sha=$2 urls=$3 dst=/ tmp u f tmp=$(mktemp -d) for u in $urls; do - curl -fsSL --retry 2 --connect-timeout 20 --speed-limit 1024 --speed-time 60 "$u" -o "$tmp/fex.tzst" && echo "$sha $tmp/fex.tzst" | sha256sum -c --quiet >/dev/null 2>&1 && break + if compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null; then + python3 /usr/local/lib/droiddeck/component_delivery.py fetch "$u" "$tmp/fex.tzst" --sha256 "$sha" && break + else + curl -fsSL --retry 2 --connect-timeout 20 --speed-limit 1024 --speed-time 60 "$u" -o "$tmp/fex.tzst" && echo "$sha $tmp/fex.tzst" | sha256sum -c --quiet >/dev/null 2>&1 && break + fi rm -f "$tmp/fex.tzst" done if [ ! -s "$tmp/fex.tzst" ]; then diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-extra b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-extra index b7b1c27b0..a064f76c9 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-extra +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-extra @@ -1,5 +1,6 @@ #!/usr/bin/python3 import hashlib +import glob import json import os import re @@ -17,6 +18,11 @@ SOURCES = { } USER_AGENT = "droiddeck-proton-extra" NEED_BYTES = 4 * 1024 * 1024 * 1024 +PLAY_BUNDLES = bool(glob.glob('/opt/droiddeck-bundles/*/*.apk')) +if PLAY_BUNDLES: + SOURCES = {"droiddeck": (SOURCES["droiddeck"][0], re.compile(r"aarch64\.tar\.(gz|xz|zst)$"))} + sys.path.insert(0, '/usr/local/lib/droiddeck') + import component_delivery def log(*args): @@ -24,6 +30,9 @@ def log(*args): def fetch_json(url): + if PLAY_BUNDLES: + with component_delivery.BundleReader() as reader: + return json.loads(reader.read(url)) req = urllib.request.Request(url, headers={ "User-Agent": USER_AGENT, "Accept": "application/vnd.github+json"}) with urllib.request.urlopen(req, timeout=60) as r: @@ -58,6 +67,10 @@ def release_asset(source, tag): def download(url, path): log("downloading %s" % os.path.basename(path)) + if PLAY_BUNDLES: + with component_delivery.BundleReader() as reader: + reader.fetch(url, path) + return rc = subprocess.call([ "curl", "-fL", "--retry", "5", "--retry-delay", "3", "--retry-connrefused", "-C", "-", "-A", USER_AGENT, "-o", path, url]) @@ -71,10 +84,16 @@ def verify(path, sums_url): log("no checksum published; skipping verification") return try: - req = urllib.request.Request(sums_url, headers={"User-Agent": USER_AGENT}) - with urllib.request.urlopen(req, timeout=60) as r: - want = r.read().decode("utf-8", "replace").split()[0].lower() + if PLAY_BUNDLES: + with component_delivery.BundleReader() as reader: + want = reader.read(sums_url).decode('utf-8').split()[0].lower() + else: + req = urllib.request.Request(sums_url, headers={"User-Agent": USER_AGENT}) + with urllib.request.urlopen(req, timeout=60) as r: + want = r.read().decode("utf-8", "replace").split()[0].lower() except (urllib.error.URLError, IndexError, OSError) as e: + if PLAY_BUNDLES: + raise log("could not read the checksum (%s); skipping verification" % e) return h = hashlib.sha512() @@ -138,7 +157,7 @@ def main(): if not url: raise SystemExit("droiddeck-proton-extra: no ARM64 build published for %s" % what) log("%s -> %s" % (what, tag)) - elif what.startswith("http"): + elif what.startswith("http") or PLAY_BUNDLES and what.startswith("droiddeck-bundle://"): url, sums = what, None elif os.path.isfile(what): local, url, sums = what, None, None diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 82e19c3db..fcc6e42bc 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -507,6 +507,10 @@ case $mode in _bl_got_proton=0 while read -r _bl_extra || [ -n "$_bl_extra" ]; do case ${_bl_extra# } in ""|"#"*) continue ;; esac + if compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null && [ "${_bl_extra%% *}" != droiddeck ]; then + echo "$_bl_extra" >> "$_bl_left" + continue + fi step "installing Proton '$_bl_extra' (large download, several minutes)" if droiddeck-proton-extra "$_bl_proton_root" $_bl_extra; then _bl_got_proton=1 diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 index 2a97bcb81..a90e4ccfd 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-x64 @@ -21,7 +21,13 @@ x64_default_dir() { while IFS= read -r d; do [ -f "$d/.droiddeck-arm64-proton" ] && { echo "$d"; return; } done < <(ls -d "$STEAM_X64"/compatibilitytools.d/DroidDeck-Proton* 2>/dev/null | sort -V -r - ls -d "$STEAM_X64"/compatibilitytools.d/GE-Proton*-aarch64 2>/dev/null | sort -V -r) + if ! compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null; then + ls -d "$STEAM_X64"/compatibilitytools.d/GE-Proton*-aarch64 2>/dev/null | sort -V -r + fi) + if compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null; then + echo "$STEAM_X64/compatibilitytools.d/DroidDeck-Proton" + return + fi echo "$STEAM_X64/compatibilitytools.d/droiddeck-proton-arm64" } x64_default_tool() { @@ -321,6 +327,10 @@ PY x64_fetch() { local url=$1 out=$2 label=$3 total pid rc=0 last=-1 pct + if compgen -G '/opt/droiddeck-bundles/*/*.apk' >/dev/null; then + python3 /usr/local/lib/droiddeck/component_delivery.py fetch "$url" "$out" --sha256 "$ROOTFS_SHA256" + return $? + fi total=$(curl -fsSIL "$url" 2>/dev/null | tr -d '\r' | awk 'tolower($1) == "content-length:" { v = $2 } END { print v + 0 }') curl -fL -sS -C - "$url" -o "$out" & pid=$! diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr index 176f92aad..a819f15aa 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr @@ -102,7 +102,15 @@ install) mkdir -p "$cache" pkg=$cache/steamvr.pkg.tar.zst echo "downloading SteamVR (571 MB) from Valve's package server" - curl -fsSL --retry 5 -C - -o "$pkg" "$PKG_URL" || { echo "download failed"; exit 1; } + play_bundle= + for apk in /opt/droiddeck-bundles/*/*.apk; do + if [ -f "$apk" ]; then play_bundle=1; break; fi + done + if [ -n "$play_bundle" ]; then + python3 /usr/local/lib/droiddeck/component_delivery.py fetch "$PKG_URL" "$pkg" --sha256 "$PKG_SHA256" || exit 1 + else + curl -fsSL --retry 5 -C - -o "$pkg" "$PKG_URL" || { echo "download failed"; exit 1; } + fi echo "$PKG_SHA256 $pkg" | sha256sum -c - >/dev/null 2>&1 || { echo "checksum mismatch: removing the download"; rm -f "$pkg"; exit 1; } tmp=$cache/extract rm -rf "$tmp" && mkdir -p "$tmp" diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 6e876a506..6beaa873c 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -1,5 +1,6 @@ #!/usr/bin/python3 import json +import glob import os import re import runpy @@ -13,6 +14,7 @@ LABEL_FILE = "/etc/steam-compatibility-label" PROTON_ARM64_APPID = "4427310" LAUNCHER = "droiddeck-proton" LEGACY_LAUNCHER = "bannerlator-proton" +PLAY_BUNDLES = bool(glob.glob('/opt/droiddeck-bundles/*/*.apk')) LIBRARY = "/mnt/droiddeck" SOURCES = ("Proton Experimental (ARM64)", "Proton 11.0 (ARM64)") OWN_TOOLS = ((TOOL, SOURCES), (TOOL_11, ("Proton 11.0 (ARM64)",))) @@ -1131,7 +1133,7 @@ def tool_catalog(steam_root, extras=None): extras[first_key(os.path.join(tool_dir, "compatibilitytool.vdf"), ["compatibilitytools", "compat_tools"]) or entry] = entry for name, entry in sorted(extras.items()): catalog.append(tool_entry(name, display_name(entry), os.path.join(tools, entry), False)) - return catalog + return own_builds(catalog) if PLAY_BUNDLES else catalog def requested_tool(request, catalog): @@ -1141,6 +1143,8 @@ def requested_tool(request, catalog): for tool in catalog: if tool["dir"] and tool["dir"] == request.get("dir") and tool["valve"] == bool(request.get("valve")): return tool["name"] + if PLAY_BUNDLES: + return own_proton_moves({}, catalog)[0] return None @@ -1298,7 +1302,7 @@ def choose_default(steam_default, state, request, catalog, adopt_steam=True, app elif adopt_steam and steam_default in names and steam_default != state.get("default"): state.update(default=steam_default, seq=now or now_ms(), source="steam") if state.get("default") not in names: - state["default"] = TOOL + state["default"] = (own_proton_moves({}, catalog)[0] or TOOL) if PLAY_BUNDLES else TOOL return state["default"], state diff --git a/tools/linuxfs/overlay/usr/local/lib/droiddeck/component_delivery.py b/tools/linuxfs/overlay/usr/local/lib/droiddeck/component_delivery.py new file mode 100644 index 000000000..96c25fa61 --- /dev/null +++ b/tools/linuxfs/overlay/usr/local/lib/droiddeck/component_delivery.py @@ -0,0 +1,151 @@ +import argparse +import hashlib +import io +import json +import os +from pathlib import Path +import re +import sys +import tempfile +import zipfile + + +DIRECTORY = Path('/opt/droiddeck-bundles') +INDEX = 'assets/play-components/index.json' +INDEX_LIMIT = 16 * 1024 * 1024 +SHA256 = re.compile(r'[0-9a-f]{64}') +ASSET = re.compile(r'play-components/[0-9a-f]{64}/[0-9]{4,}') + + +def enabled(directory=DIRECTORY): + return any(directory.glob('*/*.apk')) + + +class BundleReader: + def __init__(self, directory=DIRECTORY): + self.archives = [] + self.assets = {} + try: + paths = sorted(directory.glob('*/*.apk')) + if not paths or len(paths) > 128: + raise ValueError('Installed component bundles are unavailable') + for path in paths: + archive = zipfile.ZipFile(path) + self.archives.append(archive) + for entry in archive.infolist(): + if not entry.filename.startswith('assets/play-components/'): + continue + if entry.filename in self.assets: + raise ValueError('Duplicate component asset: ' + entry.filename) + self.assets[entry.filename] = (archive, entry) + index = self.read_object(INDEX, 2 * 1024 * 1024) + if index.get('schema') != 1 or not isinstance(index.get('entries'), dict): + raise ValueError('Unsupported component index') + self.entries = index['entries'] + except BaseException: + self.close() + raise + + def close(self): + for archive in self.archives: + archive.close() + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def read_object(self, path, limit=INDEX_LIMIT): + archive, entry = self.assets[path] + if entry.file_size > limit: + raise ValueError('Component metadata exceeds its size limit') + with archive.open(entry) as source: + return json.load(source) + + def copy(self, url, output, limit, expected_sha256=None): + entry = self.entries.get(url) + if entry is None: + raise ValueError('Component is absent from this build: ' + url) + size, digest = entry['size'], entry['sha256'] + if type(size) is not int or size <= 0 or size > limit or not SHA256.fullmatch(digest): + raise ValueError('Invalid component metadata') + if expected_sha256 is not None and digest != expected_sha256.lower(): + raise ValueError('Component version does not match this build') + recipe = 'play-components/recipes/' + digest + '.json' + if entry.get('recipe') != recipe: + raise ValueError('Invalid component recipe path') + chunks = self.read_object('assets/' + recipe)['chunks'] + if not chunks: + raise ValueError('Component contains no payload') + full_digest = hashlib.sha256() + total = 0 + for chunk in chunks: + path, chunk_size, chunk_sha256 = chunk['asset'], chunk['size'], chunk['sha256'] + if not ASSET.fullmatch(path) or type(chunk_size) is not int or not 0 < chunk_size <= size - total: + raise ValueError('Invalid component chunk metadata') + if not SHA256.fullmatch(chunk_sha256): + raise ValueError('Invalid component chunk digest') + archive, asset = self.assets['assets/' + path] + if asset.file_size != chunk_size: + raise ValueError('Component chunk size mismatch') + chunk_digest = hashlib.sha256() + copied = 0 + with archive.open(asset) as source: + for block in iter(lambda: source.read(65536), b''): + copied += len(block) + total += len(block) + if copied > chunk_size: + raise ValueError('Component chunk exceeds pinned size') + chunk_digest.update(block) + full_digest.update(block) + output.write(block) + if copied != chunk_size or chunk_digest.hexdigest() != chunk_sha256: + raise ValueError('Component chunk failed verification') + if total != size or full_digest.hexdigest() != digest: + raise ValueError('Component failed verification') + return total + + def read(self, url): + output = io.BytesIO() + self.copy(url, output, INDEX_LIMIT) + return output.getvalue() + + def fetch(self, url, destination, expected_sha256=None): + destination = Path(destination) + destination.parent.mkdir(parents=True, exist_ok=True) + descriptor, temporary = tempfile.mkstemp(prefix=destination.name + '.', suffix='.component-part', dir=destination.parent) + try: + with os.fdopen(descriptor, 'wb') as output: + self.copy(url, output, sys.maxsize, expected_sha256) + os.replace(temporary, destination) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('command', choices=['enabled', 'read', 'fetch']) + parser.add_argument('url', nargs='?') + parser.add_argument('destination', nargs='?', type=Path) + parser.add_argument('--sha256') + arguments = parser.parse_args() + if arguments.command == 'enabled': + return 0 if enabled() else 1 + if not arguments.url or arguments.command == 'fetch' and arguments.destination is None: + parser.error('Component URL and fetch destination are required') + with BundleReader() as reader: + if arguments.command == 'read': + sys.stdout.buffer.write(reader.read(arguments.url)) + else: + reader.fetch(arguments.url, arguments.destination, arguments.sha256) + return 0 + + +if __name__ == '__main__': + try: + sys.exit(main()) + except (OSError, ValueError, KeyError, TypeError, zipfile.BadZipFile) as error: + print('Bundled component unavailable: ' + str(error), file=sys.stderr) + sys.exit(1) diff --git a/tools/playstore/SignBundle.java b/tools/playstore/SignBundle.java new file mode 100644 index 000000000..15826b554 --- /dev/null +++ b/tools/playstore/SignBundle.java @@ -0,0 +1,62 @@ +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.security.KeyStore; +import java.security.MessageDigest; +import java.security.cert.Certificate; +import java.util.Arrays; +import java.util.HexFormat; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; +import jdk.security.jarsigner.JarSigner; + +class SignBundle { + static String fingerprint(Certificate certificate) throws Exception { + return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(certificate.getEncoded())); + } + + public static void main(String[] arguments) { + char[] password = null; + try { + password = System.getenv("RELEASE_STORE_PASSWORD").toCharArray(); + KeyStore keys = KeyStore.getInstance(Path.of(System.getenv("RELEASE_KEYSTORE_PATH")).toFile(), password); + var entry = (KeyStore.PrivateKeyEntry) keys.getEntry(System.getenv("RELEASE_KEY_ALIAS"), new KeyStore.PasswordProtection(password)); + if (entry == null) throw new IllegalStateException(); + if (!fingerprint(entry.getCertificate()).equals(arguments[2])) { + System.err.println("Signing certificate differs from the pinned release identity"); + System.exit(2); + } + var signer = new JarSigner.Builder(entry).digestAlgorithm("SHA-256").signerName("RELEASE").build(); + try (var source = new ZipFile(arguments[0]); + OutputStream output = Files.newOutputStream(Path.of(arguments[1]), StandardOpenOption.CREATE_NEW)) { + signer.sign(source, output); + } + try (var signed = new JarFile(arguments[1], true)) { + var entries = signed.entries(); + while (entries.hasMoreElements()) { + var item = entries.nextElement(); + if (item.isDirectory()) continue; + try (InputStream input = signed.getInputStream(item)) { + input.transferTo(OutputStream.nullOutputStream()); + } + String name = item.getName().toUpperCase(java.util.Locale.ROOT); + boolean signature = name.equals("META-INF/MANIFEST.MF") || name.startsWith("META-INF/") && name.indexOf('/', 9) < 0 && + (name.endsWith(".SF") || name.endsWith(".RSA") || name.endsWith(".DSA") || name.endsWith(".EC") || name.substring(9).startsWith("SIG-")); + if (signature) continue; + var identities = item.getCodeSigners(); + if (identities == null || identities.length != 1 || !fingerprint(identities[0].getSignerCertPath().getCertificates().get(0)).equals(arguments[2])) { + throw new IllegalStateException(); + } + } + } + System.out.println("Bundle signature and payload coverage verified"); + } catch (Exception failure) { + System.err.println("Bundle signing or signature verification failed"); + System.exit(1); + } finally { + if (password != null) Arrays.fill(password, '\0'); + } + } +} diff --git a/tools/playstore/audio-sources.json b/tools/playstore/audio-sources.json new file mode 100644 index 000000000..6ae8907ca --- /dev/null +++ b/tools/playstore/audio-sources.json @@ -0,0 +1,22 @@ +{ + "android-module": { + "sha256": "77637cae61e6200a8b3340b58080e9cf5b8740b924275009a86cb2ad3ba0b934", + "size": 3378196, + "url": "https://codeload.github.com/brunodev85/pulseaudio-android/tar.gz/77c8a7217c5746d44787e78f9b141e7503c981f4" + }, + "libsndfile": { + "sha256": "82f6a864fb7fb5e9254f91d9191271a8d76ae01848f7284a21602329310088f9", + "size": 663130, + "url": "https://codeload.github.com/libsndfile/libsndfile/tar.gz/d60deb5d8691997b6bb28d88e3b43f322073d146" + }, + "libtool": { + "sha256": "7c87a8c2c8c0fc9cd5019e402bed4292462d00a718a7cd5f11218153bf28b26f", + "size": 973080, + "url": "https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz" + }, + "pulseaudio": { + "sha256": "8da3360e199609e64a413e0e181a121770b6aac16e6ec5327abb8f75928a0c7d", + "size": 2531732, + "url": "https://codeload.github.com/pulseaudio/pulseaudio/tar.gz/200618b32f0964a479d69c9b6e5073e6931c370a" + } +} diff --git a/tools/playstore/build_audio.py b/tools/playstore/build_audio.py new file mode 100644 index 000000000..a8e5ffb97 --- /dev/null +++ b/tools/playstore/build_audio.py @@ -0,0 +1,205 @@ +import argparse +import hashlib +import io +import json +import os +import re +from pathlib import Path +import shutil +import subprocess +import sys +import tarfile + + +ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(ROOT)) +from tools.playstore.payloads import fetch, sha256 +from tools.release.check_android_libraries import page_alignment + + +LIBRARIES = ['libltdl.so', 'libpulseaudio.so', 'libpulse.so', 'libpulsecommon-13.0.so', + 'libpulsecore-13.0.so', 'libsndfile.so'] +SOURCES = Path(__file__).with_name('audio-sources.json') + + +def identity(ndk): + paths = [Path(__file__), SOURCES, *sorted((ROOT / 'tools/aaudio-sink').glob('*')), + *sorted((ROOT / 'tools/directaudio/sink').glob('*')), + *[ROOT / 'app/src/main/jniLibs/arm64-v8a' / name for name in LIBRARIES]] + entries = {str(path.relative_to(ROOT)): sha256(path) for path in paths if path.is_file()} + entries['ndk'] = sha256(ndk / 'source.properties') + return hashlib.sha256(json.dumps(entries, sort_keys=True).encode()).hexdigest() + + +def verify(output, ndk): + manifest = json.loads((output / 'complete.json').read_text()) + if manifest.get('identity') != identity(ndk): + raise ValueError('Play audio sources or toolchain changed') + for name, digest in manifest['outputs'].items(): + path = output / name + if path.is_symlink() or not path.is_file() or sha256(path) != digest: + raise ValueError('Play audio output failed verification: ' + name) + if set(LIBRARIES) != {Path(name).name for name in manifest['outputs'] if name.startswith('jni/arm64-v8a/')}: + raise ValueError('Play audio native inventory is incomplete') + if 'assets/pulseaudio.tzst' not in manifest['outputs']: + raise ValueError('Play audio modules are missing') + return manifest + + +def extract(source, destination): + destination.mkdir(parents=True) + with tarfile.open(source, 'r:*') as archive: + archive.extractall(destination, filter='data') + roots = list(destination.iterdir()) + if len(roots) != 1 or not roots[0].is_dir(): + raise ValueError('Unexpected audio source archive layout') + return roots[0] + + +def build(output, cache, ndk): + if output.exists(): + return verify(output, ndk) + output.mkdir(parents=True) + work = output / 'work' + work.mkdir() + definitions = json.loads(SOURCES.read_text()) + sources = {} + for name, definition in definitions.items(): + archive = fetch(dict(definition, id=name, urls=[definition['url']]), cache) + sources[name] = extract(archive, work / name) + notices = output / 'assets/licenses/play-audio/sources' + notices.mkdir(parents=True, exist_ok=True) + shutil.copyfile(archive, notices / (name + ('.tar.xz' if name == 'libtool' else '.tar.gz'))) + prefix = work / 'prefix' + prefix.mkdir() + toolchain = ndk / 'toolchains/llvm/prebuilt/linux-x86_64/bin' + environment = dict(os.environ) + environment.update({name: str(toolchain / value) for name, value in { + 'CC': 'aarch64-linux-android26-clang', 'CXX': 'aarch64-linux-android26-clang++', + 'AR': 'llvm-ar', 'NM': 'llvm-nm', 'RANLIB': 'llvm-ranlib', 'STRIP': 'llvm-strip', + }.items()}) + environment.update(CFLAGS=f'-O2 -fPIC -Wno-error=int-conversion -I{prefix}/include', + LDFLAGS=f'-Wl,-z,max-page-size=16384 -L{prefix}/lib', + PKG_CONFIG_PATH=str(prefix / 'lib/pkgconfig'), PKG_CONFIG_LIBDIR=str(prefix / 'lib/pkgconfig'), + ac_cv_func_mkfifo='yes', ac_cv_func_getuid='no', ac_cv_func_seteuid='no', + ax_cv_PTHREAD_PRIO_INHERIT='no', ac_cv_header_glob_h='no', ac_cv_header_execinfo_h='no', + ac_cv_func_malloc_0_nonnull='yes', ac_cv_func_realloc_0_nonnull='yes', + ac_cv_lib_ltdl_lt_dladvise_init='yes') + environment['CXXFLAGS'] = environment['CFLAGS'] + + def run(arguments, directory=work): + subprocess.run([str(value) for value in arguments], cwd=directory, env=environment, check=True) + + libtool = work / 'libtool-build' + libtool.mkdir() + run([sources['libtool'] / 'configure', '--host=aarch64-linux-android', '--prefix=' + str(prefix), + 'HELP2MAN=/bin/true', 'MAKEINFO=/bin/true'], libtool) + run(['make', '-j8'], libtool) + run(['make', 'install'], libtool) + sndfile = work / 'sndfile-build' + run(['cmake', '-S', sources['libsndfile'], '-B', sndfile, '-G', 'Ninja', + '-DCMAKE_TOOLCHAIN_FILE=' + str(ndk / 'build/cmake/android.toolchain.cmake'), + '-DANDROID_ABI=arm64-v8a', '-DANDROID_PLATFORM=android-26', '-DCMAKE_BUILD_TYPE=Release', + '-DBUILD_SHARED_LIBS=ON', '-DBUILD_PROGRAMS=OFF', '-DBUILD_EXAMPLES=OFF', '-DBUILD_TESTING=OFF', + '-DENABLE_EXTERNAL_LIBS=OFF', '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=16384', + '-DCMAKE_INSTALL_PREFIX=' + str(prefix)]) + run(['cmake', '--build', sndfile, '-j8']) + run(['cmake', '--install', sndfile]) + pulse = sources['pulseaudio'] + (pulse / '.tarball-version').write_text('13.0\n') + run(['autoreconf', '--install', '--force'], pulse) + pulse_build = work / 'pulse-build' + pulse_build.mkdir() + disabled = ['rpath', 'nls', 'x11', 'oss-wrapper', 'alsa', 'esound', 'waveout', 'glib2', 'gtk3', 'gconf', + 'avahi', 'jack', 'asyncns', 'tcpwrap', 'lirc', 'dbus', 'bluez5', 'udev', 'openssl', 'manpages', + 'samplerate', 'orc', 'systemd-daemon', 'systemd-login', 'systemd-journal', 'webrtc-aec', + 'tests', 'neon-opt', 'gsettings'] + run([pulse / 'configure', '--host=aarch64-linux-android', '--prefix=' + str(prefix), '--disable-static', + '--enable-shared', '--with-database=simple', '--without-speex', '--without-caps', '--without-fftw', + *['--disable-' + name for name in disabled]], pulse_build) + run(['make', '-j8'], pulse_build) + run(['make', 'install'], pulse_build) + jni = output / 'jni/arm64-v8a' + jni.mkdir(parents=True) + for name in LIBRARIES: + source = prefix / ('bin/pulseaudio' if name == 'libpulseaudio.so' else + 'lib/pulseaudio/' + name if name.startswith(('libpulsecommon-', 'libpulsecore-')) else 'lib/' + name) + shutil.copyfile(source, jni / name) + modules = work / 'android-modules' + environment.update(NDK=str(ndk), DROIDDECK_PULSE_LIBS=str(jni)) + run(['bash', ROOT / 'tools/aaudio-sink/build.sh', pulse, modules], ROOT) + run([environment['CC'], '-O2', '-shared', '-fPIC', '-Wno-error=int-conversion', + '-Wl,-z,max-page-size=16384', '-I' + str(pulse_build), '-I' + str(pulse / 'src'), + '-I' + str(prefix / 'include'), '-L' + str(jni), '-lpulsecore-13.0', '-lpulsecommon-13.0', '-lpulse', + '-laaudio', '-o', modules / 'module-aaudio-classic-sink.so', + sources['android-module'] / 'pulseaudio-module/module-aaudio-sink.c']) + replacements = {'modules/arm64/' + name: prefix / 'lib/pulse-13.0/modules' / name for name in + ['module-pipe-source.so', 'module-pipe-sink.so', 'libprotocol-native.so', 'module-native-protocol-unix.so']} + replacements.update({'modules/arm64/' + name: modules / name for name in + ['module-aaudio-sink.so', 'module-directaudio-native-sink.so', 'module-aaudio-classic-sink.so']}) + replacements['pactl'] = prefix / 'bin/pactl' + for path in [*jni.glob('*.so'), *replacements.values()]: + errors = page_alignment(path, str(toolchain / 'llvm-readelf'), 16384) + if errors: + raise ValueError('\n'.join(errors)) + def exports(path): + symbols = subprocess.check_output([str(toolchain / 'llvm-nm'), '-D', '--defined-only', str(path)], text=True) + return {line.split()[-1].split('@')[0] for line in symbols.splitlines() if line.split()} + + for name in LIBRARIES: + old = ROOT / 'app/src/main/jniLibs/arm64-v8a' / name + if exports(old) - exports(jni / name): + raise ValueError('Play audio library dropped existing exports: ' + name) + original_dynamic = subprocess.check_output([str(toolchain / 'llvm-readelf'), '-d', str(old)], text=True) + rebuilt_dynamic = subprocess.check_output([str(toolchain / 'llvm-readelf'), '-d', str(jni / name)], text=True) + if re.findall(r'SONAME.*\[(.*?)\]', original_dynamic) != re.findall(r'SONAME.*\[(.*?)\]', rebuilt_dynamic): + raise ValueError('Play audio library changed its load identity: ' + name) + original = ROOT / 'app/src/main/assets/pulseaudio.tzst' + process = subprocess.Popen(['zstd', '-dc', str(original)], stdout=subprocess.PIPE) + seen = set() + plain = work / 'pulseaudio.tar' + with tarfile.open(fileobj=process.stdout, mode='r|') as source, tarfile.open(plain, 'w') as target: + for member in source: + name = member.name.removeprefix('./') + stream = source.extractfile(member) if member.isfile() else None + if name in replacements: + data = replacements[name].read_bytes() + member.size = len(data) + stream = io.BytesIO(data) + seen.add(name) + target.addfile(member, stream) + for name in sorted(set(replacements) - seen): + data = replacements[name].read_bytes() + member = tarfile.TarInfo(name) + member.size, member.mode = len(data), 0o755 + target.addfile(member, io.BytesIO(data)) + process.stdout.close() + if process.wait(): + raise ValueError('Original audio archive failed to decode') + with (output / 'assets/pulseaudio.tzst').open('xb') as destination: + subprocess.run(['zstd', '-19', '-c', str(plain)], stdout=destination, check=True) + files = [path for tree in ['jni', 'assets'] for path in (output / tree).rglob('*') if path.is_file()] + manifest = {'identity': identity(ndk), 'sources': definitions, + 'outputs': {path.relative_to(output).as_posix(): sha256(path) for path in files}} + (output / 'complete.json').write_text(json.dumps(manifest, indent=2, sort_keys=True) + '\n') + return verify(output, ndk) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('command', choices=['build', 'verify']) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--ndk', type=Path, required=True) + parser.add_argument('--cache', type=Path) + arguments = parser.parse_args() + if arguments.command == 'build': + if arguments.cache is None: + parser.error('build requires --cache') + manifest = build(arguments.output.resolve(), arguments.cache.resolve(), arguments.ndk.resolve()) + else: + manifest = verify(arguments.output.resolve(), arguments.ndk.resolve()) + print(json.dumps({'verified_outputs': len(manifest['outputs']), 'identity': manifest['identity']})) + + +if __name__ == '__main__': + main() diff --git a/tools/playstore/check_audio_bundle.py b/tools/playstore/check_audio_bundle.py new file mode 100644 index 000000000..011f36406 --- /dev/null +++ b/tools/playstore/check_audio_bundle.py @@ -0,0 +1,66 @@ +import argparse +import gzip +import hashlib +from pathlib import Path +import subprocess +import sys +import tempfile +from zipfile import ZipFile + + +ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(ROOT)) +from tools.playstore.build_audio import LIBRARIES, verify +from tools.release.check_android_libraries import page_alignment + + +def check(bundle, output, ndk): + manifest = verify(output, ndk) + readelf = str(ndk / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf') + nm = str(ndk / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm') + with ZipFile(bundle) as package, tempfile.TemporaryDirectory() as temporary: + names = package.namelist() + if len(names) != len(set(names)): + raise ValueError('Bundle contains duplicate entries') + for name, digest in manifest['outputs'].items(): + if name.startswith('assets/'): + asset = 'base/' + name + if asset not in names and name.endswith('.tar.gz'): + asset = asset.removesuffix('.gz') + expected = hashlib.sha256() + with gzip.open(output / name, 'rb') as source: + for block in iter(lambda: source.read(1024 * 1024), b''): + expected.update(block) + digest = expected.hexdigest() + actual = hashlib.sha256() + with package.open(asset) as stream: + for block in iter(lambda: stream.read(1024 * 1024), b''): + actual.update(block) + if actual.hexdigest() != digest: + raise ValueError('Bundle audio asset differs from verified output: ' + asset) + for name in LIBRARIES: + path = Path(temporary) / name + path.write_bytes(package.read('base/lib/arm64-v8a/' + name)) + errors = page_alignment(path, readelf, 16384) + if errors: + raise ValueError('\n'.join(errors)) + def exports(library): + result = subprocess.check_output([nm, '-D', '--defined-only', str(library)], text=True) + return {line.split()[-1].split('@')[0] for line in result.splitlines() if line.split()} + rebuilt = output / 'jni/arm64-v8a' / name + if exports(rebuilt) - exports(path): + raise ValueError('Bundle audio library dropped rebuilt exports: ' + name) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--bundle', type=Path, required=True) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--ndk', type=Path, required=True) + arguments = parser.parse_args() + check(arguments.bundle, arguments.output, arguments.ndk) + print('Bundle audio assets, corresponding sources and native exports verified') + + +if __name__ == '__main__': + main() diff --git a/tools/playstore/payloads.py b/tools/playstore/payloads.py new file mode 100644 index 000000000..5b6cf5ec8 --- /dev/null +++ b/tools/playstore/payloads.py @@ -0,0 +1,366 @@ +import argparse +import hashlib +import json +import re +import ssl +import sys +import urllib.parse +import urllib.request +from pathlib import Path +import zipfile + + +ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(ROOT)) + + +CHUNK_BYTES = 64 * 1024 * 1024 +MODULE_BYTES = 448 * 1024 * 1024 +TOTAL_BYTES = 4_000_000_000 +RESERVED_BYTES = 250_000_000 + + +def sha256(path): + result = hashlib.sha256() + with path.open('rb') as stream: + for block in iter(lambda: stream.read(1024 * 1024), b''): + result.update(block) + return result.hexdigest() + + +def https_url(value): + if not isinstance(value, str): + raise ValueError('URL must be a string') + parsed = urllib.parse.urlsplit(value) + if parsed.scheme != 'https' or not parsed.hostname or parsed.username or parsed.password or parsed.fragment: + raise ValueError('Expected a public HTTPS URL: ' + value) + return value + + +def catalog_bytes(content): + if not isinstance(content, (dict, list)): + raise ValueError('Frozen catalog must be a JSON object or array') + data = (json.dumps(content, sort_keys=True, separators=(',', ':'), ensure_ascii=False) + '\n').encode('utf-8') + if len(data) > 16 * 1024 * 1024: + raise ValueError('Frozen catalog exceeds its size limit') + return data + + +def load_manifest(path): + manifest = json.loads(path.read_text()) + if manifest.get('schema') != 1: + raise ValueError('Unsupported payload manifest schema') + entries = manifest.get('entries') + if not isinstance(entries, list) or not entries: + raise ValueError('Payload manifest is empty') + urls = set() + identities = {} + ids = set() + for entry in entries: + identity = entry.get('id', '') + if not re.fullmatch(r'[a-z0-9][a-z0-9._-]{0,127}', identity) or identity in ids: + raise ValueError('Invalid or duplicate payload id: ' + identity) + ids.add(identity) + digest = entry.get('sha256', '') + if not re.fullmatch(r'[a-f0-9]{64}', digest): + raise ValueError('Payload requires a SHA-256: ' + identity) + size = entry.get('size') + if type(size) is not int or size < 1: + raise ValueError('Payload requires a positive byte size: ' + identity) + if digest in identities and identities[digest] != size: + raise ValueError('Inconsistent size for identical payload: ' + identity) + identities[digest] = size + aliases = entry.get('urls') + if not isinstance(aliases, list) or not aliases: + raise ValueError('Payload requires URL aliases: ' + identity) + for url in aliases: + if url.startswith('droiddeck-bundle://'): + if not re.fullmatch(r'droiddeck-bundle://[a-z0-9][a-z0-9._-]*/[A-Za-z0-9._+-]+', url) or not entry.get('prepare'): + raise ValueError('Invalid prepared component alias: ' + identity) + else: + https_url(url) + if url in urls: + raise ValueError('Duplicate URL alias: ' + url) + urls.add(url) + preparation = entry.get('prepare') + if 'content' in entry: + data = catalog_bytes(entry['content']) + if preparation is not None or 'upstream' in entry or len(data) != size or hashlib.sha256(data).hexdigest() != digest: + raise ValueError('Frozen catalog identity mismatch: ' + identity) + if preparation is None and 'upstream' in entry: + raise ValueError('Upstream archive requires explicit component preparation: ' + identity) + if preparation is not None: + if preparation.get('method') != 'gzip-to-zstd-19' or not re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', preparation.get('zstd_version', '')): + raise ValueError('Invalid component preparation method: ' + identity) + if not re.fullmatch(r'[a-f0-9]{64}', preparation.get('tar_sha256', '')) or type(preparation.get('tar_size')) is not int or not 0 < preparation['tar_size'] <= 16 * 1024 * 1024 * 1024: + raise ValueError('Prepared component requires a pinned tar identity: ' + identity) + upstream = entry.get('upstream', {}) + if not re.fullmatch(r'[a-f0-9]{64}', upstream.get('sha256', '')) or type(upstream.get('size')) is not int or upstream['size'] < 1: + raise ValueError('Prepared component requires a pinned upstream archive: ' + identity) + if not isinstance(upstream.get('urls'), list) or not upstream['urls']: + raise ValueError('Prepared component requires upstream URLs: ' + identity) + for url in upstream['urls']: + https_url(url) + https_url(entry.get('source', '')) + if not re.fullmatch(r'[a-f0-9]{40}', entry.get('source_commit', '')): + raise ValueError('Payload requires a pinned source commit: ' + identity) + license_info = entry.get('license', {}) + if not license_info.get('expression') or not license_info.get('redistribution_review'): + raise ValueError('Payload requires license and redistribution review: ' + identity) + https_url(license_info.get('url', '')) + required = manifest.get('required') + if not isinstance(required, list) or not required or len(set(required)) != len(required): + raise ValueError('Manifest requires a unique component coverage list') + provided = {feature for entry in entries for feature in entry.get('provides', [])} + missing = set(required) - provided + if missing: + raise ValueError('Missing component coverage: ' + ', '.join(sorted(missing))) + total = sum(identities.values()) + if total + RESERVED_BYTES > TOTAL_BYTES: + raise ValueError(f'Payload size budget exceeded: {total} + {RESERVED_BYTES} reserved > {TOTAL_BYTES}') + return manifest + + +def validate_play_engines(manifest): + if manifest.get('release_ready') is False: + raise ValueError('Review-only component inventory cannot be published') + pending = [entry['id'] for entry in manifest['entries'] if entry.get('license', {}).get('approved') is not True] + if pending: + raise ValueError('Component redistribution review is incomplete: ' + ', '.join(pending)) + if 'proton:droiddeck' not in manifest['required']: + raise ValueError('Play distribution requires DroidDeck Proton') + for entry in manifest['entries']: + if any(feature.startswith('emulator:') for feature in entry.get('provides', [])): + raise ValueError('Extra desktop emulators are excluded from the Play distribution') + engines = {name for name in entry.get('provides', []) if name.startswith('proton:')} + if engines - {'proton:droiddeck'}: + raise ValueError('Play distribution permits only DroidDeck Proton') + source_urls = entry.get('upstream', {}).get('urls', entry['urls']) + for url in [*entry['urls'], *source_urls]: + lower = url.lower() + parsed = urllib.parse.urlsplit(url) + if '/steamdeck-desktop-' in parsed.path and parsed.path.rsplit('/', 1)[-1] != 'desktop.tar.zst': + raise ValueError('Extra desktop emulator payload is forbidden in the Play distribution: ' + entry['id']) + if any(name in lower for name in ['/proton-ge-custom/', '/proton-cachyos/', '/steam-seed.json']): + raise ValueError('Alternate Proton input is forbidden in the Play distribution: ' + entry['id']) + if engines and not any('/Droid-Deck/DroidDeck-Proton/' in url for url in source_urls): + raise ValueError('DroidDeck Proton must come from its pinned release') + + +class HttpsRedirects(urllib.request.HTTPRedirectHandler): + def redirect_request(self, request, file, code, message, headers, url): + https_url(url) + return super().redirect_request(request, file, code, message, headers, url) + + +def fetch(entry, cache): + cache.mkdir(parents=True, exist_ok=True) + target = cache / entry['sha256'] + if target.exists(): + if target.is_symlink() or target.stat().st_size != entry['size'] or sha256(target) != entry['sha256']: + raise ValueError('Existing cache payload failed verification: ' + entry['id']) + return target + temporary = cache / (entry['sha256'] + '.part') + if temporary.exists(): + raise ValueError('Incomplete payload exists; preserve it and select a fresh cache: ' + str(temporary)) + if 'content' in entry: + data = catalog_bytes(entry['content']) + if len(data) != entry['size'] or hashlib.sha256(data).hexdigest() != entry['sha256']: + raise ValueError('Frozen catalog identity mismatch: ' + entry['id']) + with temporary.open('xb') as output: + output.write(data) + temporary.rename(target) + return target + if entry.get('prepare'): + from tools.playstore.prepare_archive import prepare + upstream = fetch(dict(entry['upstream'], id='upstream-' + entry['id']), cache) + prepare(upstream, temporary, entry['prepare']) + if temporary.stat().st_size != entry['size'] or sha256(temporary) != entry['sha256']: + raise ValueError('Prepared payload digest or size mismatch: ' + entry['id']) + temporary.rename(target) + return target + opener = urllib.request.build_opener(HttpsRedirects(), urllib.request.HTTPSHandler(context=ssl.create_default_context())) + request = urllib.request.Request(entry['urls'][0], headers={'Accept-Encoding': 'identity'}) + digest = hashlib.sha256() + size = 0 + with opener.open(request, timeout=60) as response, temporary.open('xb') as output: + https_url(response.url) + for block in iter(lambda: response.read(1024 * 1024), b''): + size += len(block) + if size > entry['size']: + raise ValueError('Payload exceeds pinned size: ' + entry['id']) + digest.update(block) + output.write(block) + if size != entry['size'] or digest.hexdigest() != entry['sha256']: + raise ValueError('Payload digest or size mismatch: ' + entry['id']) + temporary.rename(target) + return target + + +def stage(manifest, cache, output, chunk_bytes=CHUNK_BYTES, module_bytes=MODULE_BYTES): + if chunk_bytes < 1 or module_bytes < chunk_bytes or module_bytes > MODULE_BYTES: + raise ValueError('Invalid chunk or module size') + if output.exists(): + raise ValueError('Output must be a new directory: ' + str(output)) + payloads = {} + for entry in manifest['entries']: + if entry['sha256'] not in payloads: + payloads[entry['sha256']] = fetch(entry, cache) + output.mkdir(parents=True) + index = {'schema': 1, 'manifest_sha256': hashlib.sha256( + json.dumps(manifest, sort_keys=True, separators=(',', ':')).encode()).hexdigest(), 'entries': {}} + module = 1 + used = 0 + chunks = {} + for digest, path in sorted(payloads.items()): + pieces = [] + with path.open('rb') as stream: + number = 0 + for block in iter(lambda: stream.read(chunk_bytes), b''): + if used + len(block) > module_bytes: + module += 1 + used = 0 + name = f'playpayload{module:02d}' + asset = f'play-components/{digest}/{number:04d}' + target = output / name / 'src/main/assets' / asset + target.parent.mkdir(parents=True, exist_ok=True) + with target.open('xb') as destination: + destination.write(block) + pieces.append({'asset': asset, 'module': name, 'size': len(block), + 'sha256': hashlib.sha256(block).hexdigest()}) + used += len(block) + number += 1 + chunks[digest] = pieces + base = output / 'base/src/main/assets/play-components' + recipes = base / 'recipes' + recipes.mkdir(parents=True) + for digest, pieces in chunks.items(): + (recipes / (digest + '.json')).write_text(json.dumps({'chunks': pieces}, separators=(',', ':')) + '\n') + for entry in manifest['entries']: + for url in entry['urls']: + index['entries'][url] = {'id': entry['id'], 'sha256': entry['sha256'], 'size': entry['size'], + 'recipe': 'play-components/recipes/' + entry['sha256'] + '.json'} + (output / 'index.json').write_text(json.dumps(index, indent=2, sort_keys=True) + '\n') + (output / 'provenance.json').write_text(json.dumps(manifest, indent=2, sort_keys=True) + '\n') + (base / 'index.json').write_text(json.dumps(index, sort_keys=True, separators=(',', ':')) + '\n') + (base / 'provenance.json').write_text(json.dumps(manifest, sort_keys=True, separators=(',', ':')) + '\n') + modules = [f'playpayload{number:02d}' for number in range(1, module + 1)] + for name in modules: + (output / name / 'build.gradle').write_text( + "plugins { id 'com.android.dynamic-feature' }\n" + "android {\n" + f" namespace 'com.droiddeck.launcher.{name}'\n" + " compileSdk 37\n" + " defaultConfig { minSdk 26 }\n" + "}\n" + "dependencies { implementation project(':app') }\n") + (output / name / 'src/main/AndroidManifest.xml').write_text( + '\n' + ' \n' + ' ' + '\n' + ' \n' + ' \n' + ' \n' + '\n') + (output / 'modules.json').write_text(json.dumps(modules) + '\n') + return index + + +def verify_bundle(manifest, bundle): + expected = {url: entry for entry in manifest['entries'] for url in entry['urls']} + with zipfile.ZipFile(bundle) as package: + if len(package.namelist()) != len(set(package.namelist())): + raise ValueError('Bundle contains duplicate ZIP entries') + index = json.loads(package.read('base/assets/play-components/index.json')) + provenance = json.loads(package.read('base/assets/play-components/provenance.json')) + if provenance != manifest or index.get('schema') != 1 or set(index.get('entries', {})) != set(expected): + raise ValueError('Bundle component inventory differs from the pinned manifest') + canonical = hashlib.sha256(json.dumps(manifest, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + if index.get('manifest_sha256') != canonical: + raise ValueError('Bundle manifest identity mismatch') + referenced = set() + referenced_recipes = set() + verified = set() + for url, pinned in expected.items(): + entry = index['entries'][url] + if any(entry.get(field) != pinned[field] for field in ['id', 'sha256', 'size']): + raise ValueError('Bundle component metadata mismatch: ' + pinned['id']) + recipe = 'play-components/recipes/' + pinned['sha256'] + '.json' + if entry.get('recipe') != recipe: + raise ValueError('Bundle component recipe path mismatch') + recipe_path = 'base/assets/' + recipe + referenced_recipes.add(recipe_path) + if package.getinfo(recipe_path).file_size > 16 * 1024 * 1024: + raise ValueError('Bundle component recipe exceeds its size limit') + pieces = json.loads(package.read(recipe_path)).get('chunks') + if not isinstance(pieces, list) or not pieces: + raise ValueError('Bundle component contains no chunks: ' + pinned['id']) + digest = hashlib.sha256() + size = 0 + identity = json.dumps(entry, sort_keys=True) + for chunk in pieces: + if not re.fullmatch(r'playpayload[0-9]{2}', chunk['module']) or not re.fullmatch( + r'play-components/[0-9a-f]{64}/[0-9]{4,}', chunk['asset']): + raise ValueError('Invalid bundle chunk path') + path = chunk['module'] + '/assets/' + chunk['asset'] + referenced.add(path) + if identity in verified: + continue + info = package.getinfo(path) + if info.file_size != chunk['size'] or not 0 < chunk['size'] <= CHUNK_BYTES: + raise ValueError('Bundle chunk size mismatch: ' + path) + chunk_digest = hashlib.sha256() + with package.open(info) as source: + for block in iter(lambda: source.read(1024 * 1024), b''): + digest.update(block) + chunk_digest.update(block) + size += len(block) + if chunk_digest.hexdigest() != chunk['sha256']: + raise ValueError('Bundle chunk digest mismatch: ' + path) + if identity not in verified and (digest.hexdigest() != pinned['sha256'] or size != pinned['size']): + raise ValueError('Bundle payload failed verification: ' + pinned['id']) + verified.add(identity) + delivered = {name for name in package.namelist() if '/assets/play-components/' in name and + not name.startswith('base/assets/play-components/')} + if delivered != referenced: + raise ValueError('Bundle contains unreferenced component chunks') + base_assets = {name for name in package.namelist() if name.startswith('base/assets/play-components/')} + if base_assets != referenced_recipes | {'base/assets/play-components/index.json', 'base/assets/play-components/provenance.json'}: + raise ValueError('Bundle contains unreferenced component recipes') + sizes = {} + for info in package.infolist(): + module = info.filename.split('/')[0] + if module == 'base' or module.startswith('playpayload'): + sizes[module] = sizes.get(module, 0) + info.compress_size + if any(size > 500_000_000 for size in sizes.values()) or sum(sizes.values()) > TOTAL_BYTES: + raise ValueError('Bundle exceeds the conservative module download-size budget') + return sizes + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('command', choices=['validate', 'stage', 'verify-bundle']) + parser.add_argument('--manifest', type=Path, required=True) + parser.add_argument('--cache', type=Path) + parser.add_argument('--output', type=Path) + parser.add_argument('--bundle', type=Path) + parser.add_argument('--play-only', action='store_true') + arguments = parser.parse_args() + manifest = load_manifest(arguments.manifest) + if arguments.play_only: + validate_play_engines(manifest) + if arguments.command == 'stage': + if arguments.cache is None or arguments.output is None: + parser.error('stage requires --cache and --output') + stage(manifest, arguments.cache, arguments.output) + if arguments.command == 'verify-bundle': + if arguments.bundle is None: + parser.error('verify-bundle requires --bundle') + print(json.dumps({'compressed_module_bytes': verify_bundle(manifest, arguments.bundle)}, sort_keys=True)) + print(json.dumps({'entries': len(manifest['entries']), 'required': len(manifest['required'])})) + + +if __name__ == '__main__': + main() diff --git a/tools/playstore/prepare_archive.py b/tools/playstore/prepare_archive.py new file mode 100644 index 000000000..68c9d6ecc --- /dev/null +++ b/tools/playstore/prepare_archive.py @@ -0,0 +1,34 @@ +import gzip +import hashlib +from pathlib import Path +import subprocess + + +def prepare(source, destination, definition): + if definition['method'] != 'gzip-to-zstd-19': + raise ValueError('Unsupported component preparation method') + version = subprocess.check_output(['zstd', '--version'], text=True) + if 'v' + definition['zstd_version'] + ',' not in version: + raise ValueError('Component preparation requires the pinned zstd version') + digest = hashlib.sha256() + size = 0 + with gzip.open(source, 'rb') as original, Path(destination).open('xb') as output: + process = subprocess.Popen(['zstd', '-19', '-T4', '-c'], stdin=subprocess.PIPE, stdout=output) + try: + for block in iter(lambda: original.read(1024 * 1024), b''): + size += len(block) + if size > definition['tar_size']: + raise ValueError('Prepared archive exceeds its pinned tar size') + digest.update(block) + process.stdin.write(block) + process.stdin.close() + if process.wait(): + raise ValueError('Component archive compression failed') + except BaseException: + process.stdin.close() + if process.poll() is None: + process.terminate() + process.wait() + raise + if size != definition['tar_size'] or digest.hexdigest() != definition['tar_sha256']: + raise ValueError('Prepared archive changed its pinned tar content') diff --git a/tools/playstore/sign_bundle.py b/tools/playstore/sign_bundle.py new file mode 100644 index 000000000..9c16d74b6 --- /dev/null +++ b/tools/playstore/sign_bundle.py @@ -0,0 +1,59 @@ +import argparse +import os +from pathlib import Path +import re +import subprocess +import tempfile +import zipfile + + +def sign(source, destination, keystore, alias, expected_signer): + if source.resolve() == destination.resolve() or destination.exists(): + raise ValueError('Signing requires a new output file') + if not re.fullmatch(r'[0-9a-f]{64}', expected_signer): + raise ValueError('Invalid pinned signing certificate') + password = os.environ.get('RELEASE_STORE_PASSWORD') + if not password: + raise ValueError('Signing password is unavailable') + if not alias: + raise ValueError('Signing alias is unavailable') + with tempfile.TemporaryDirectory(prefix='play-signing-') as temporary: + unsigned = Path(temporary) / 'unsigned.aab' + sanitize(source, unsigned) + environment = dict(os.environ, RELEASE_KEY_ALIAS=alias, RELEASE_KEYSTORE_PATH=str(keystore.resolve())) + result = subprocess.run(['java', '--add-modules', 'jdk.jartool', str(Path(__file__).with_name('SignBundle.java')), + str(unsigned), str(destination), expected_signer], env=environment, capture_output=True, text=True) + if result.returncode == 2: + raise ValueError('Signing certificate differs from the pinned release identity') + if result.returncode: + raise ValueError('Bundle signing or signature verification failed') + print('Bundle signature and payload coverage verified') + + +def sanitize(source, destination): + with zipfile.ZipFile(source) as original, zipfile.ZipFile(destination, 'x') as output: + if len(original.namelist()) != len(set(original.namelist())): + raise ValueError('Bundle contains duplicate ZIP entries') + for entry in original.infolist(): + name = entry.filename.upper() + signature = name == 'META-INF/MANIFEST.MF' or name.startswith('META-INF/') and '/' not in name[9:] and ( + name.endswith(('.SF', '.RSA', '.DSA', '.EC')) or name[9:].startswith('SIG-')) + if signature: + continue + with original.open(entry) as source_stream, output.open(entry, 'w', force_zip64=True) as target: + while block := source_stream.read(1024 * 1024): + target.write(block) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('source', type=Path) + parser.add_argument('destination', type=Path) + parser.add_argument('--keystore', type=Path, required=True) + parser.add_argument('--signer', type=Path, default=Path('keystore/release-signer.sha256')) + arguments = parser.parse_args() + sign(arguments.source, arguments.destination, arguments.keystore, os.environ.get('RELEASE_KEY_ALIAS'), arguments.signer.read_text().strip()) + + +if __name__ == '__main__': + main() diff --git a/tools/release/check_android_libraries.py b/tools/release/check_android_libraries.py index 5d6c77556..c0ce65408 100644 --- a/tools/release/check_android_libraries.py +++ b/tools/release/check_android_libraries.py @@ -18,16 +18,28 @@ EXPORTS = ['Java_com_droiddeck_launcher_stores_StoresNative_nativeVersion', 'Java_com_droiddeck_launcher_stores_amazon_AmazonNative_nativeInstall'] -def check(apk, readelf, stores=True): +def page_alignment(path, readelf, page_size): + headers = subprocess.check_output([readelf, '--program-headers', '--wide', str(path)], text=True) + loads = [line.split() for line in headers.splitlines() if line.strip().startswith('LOAD ')] + if not loads: + return ['Library has no loadable segments: ' + path.name] + return [f'{path.name} has a LOAD segment incompatible with {page_size}-byte pages' + for load in loads if int(load[-1], 16) < page_size or + (int(load[1], 16) - int(load[2], 16)) % page_size != 0] + + +def check(apk, readelf, stores=True, page_size=None): errors = [] with tempfile.TemporaryDirectory() as temp, ZipFile(apk) as package: libraries = {} for name in package.namelist(): - if name.startswith('lib/arm64-v8a/') and name.endswith('.so'): + if (name.startswith('lib/arm64-v8a/') or name.startswith('base/lib/arm64-v8a/')) and name.endswith('.so'): path = Path(temp) / Path(name).name path.write_bytes(package.read(name)) libraries[path.name] = path for name, path in libraries.items(): + if page_size is not None: + errors.extend(page_alignment(path, readelf, page_size)) dynamic = subprocess.check_output([readelf, '-d', str(path)], text=True) for dependency in re.findall(r'NEEDED.*\[(.*?)\]', dynamic): if dependency not in libraries and dependency not in SYSTEM: @@ -51,8 +63,9 @@ if __name__ == '__main__': parser.add_argument('apk') parser.add_argument('--readelf', default='readelf') parser.add_argument('--without-stores', action='store_true') + parser.add_argument('--page-size', type=int, choices=[4096, 16384]) args = parser.parse_args() - errors = check(args.apk, args.readelf, not args.without_stores) + errors = check(args.apk, args.readelf, not args.without_stores, args.page_size) if errors: parser.exit(1, '\n'.join(errors) + '\n') print('APK native exports and dependencies verified') diff --git a/tools/release/check_session_assets.py b/tools/release/check_session_assets.py index 2042e470f..5471ad3c4 100644 --- a/tools/release/check_session_assets.py +++ b/tools/release/check_session_assets.py @@ -19,6 +19,7 @@ def source_assets(overlay=OVERLAY): sources = list((overlay / 'usr/local/bin').glob('droiddeck-*')) sources += [path for path in [overlay / 'usr/local/bin/steam-compatibility'] if path.is_file()] sources += [path for path in (overlay / 'usr/bin').rglob('*') if path.is_file()] + sources += list((overlay / 'usr/local/lib/droiddeck').glob('*.py')) result = {source: 'assets/linuxfs/' + source.relative_to(overlay).as_posix() for source in sources} if overlay == OVERLAY: desktop = overlay.parent / 'desktop' diff --git a/tools/tests/test_android_page_alignment.py b/tools/tests/test_android_page_alignment.py new file mode 100644 index 000000000..e6abc897c --- /dev/null +++ b/tools/tests/test_android_page_alignment.py @@ -0,0 +1,33 @@ +import importlib.util +from pathlib import Path +import unittest +from unittest.mock import patch + + +SPEC = importlib.util.spec_from_file_location('android_libraries', Path(__file__).resolve().parents[1] / 'release/check_android_libraries.py') +libraries = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(libraries) + + +class AndroidPageAlignmentTest(unittest.TestCase): + def check(self, headers): + with patch.object(libraries.subprocess, 'check_output', return_value=headers): + return libraries.page_alignment(Path('libsample.so'), 'readelf', 16384) + + def test_sixteen_kilobyte_segments_are_accepted(self): + self.assertEqual([], self.check(' LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x001000 0x001000 R E 0x4000\n')) + + def test_old_four_kilobyte_segments_are_rejected(self): + self.assertEqual(1, len(self.check(' LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x001000 0x001000 R E 0x1000\n'))) + + def test_each_segment_must_have_congruent_offset_and_address(self): + headers = (' LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x001000 0x001000 R E 0x4000\n' + ' LOAD 0x001000 0x0000000000008000 0x0000000000008000 0x001000 0x001000 RW 0x4000\n') + self.assertEqual(1, len(self.check(headers))) + + def test_missing_load_segments_do_not_pass(self): + self.assertEqual(1, len(self.check('Program Headers:\n'))) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_droiddeck_proton_default.py b/tools/tests/test_droiddeck_proton_default.py index 6c0665d57..129aa6195 100644 --- a/tools/tests/test_droiddeck_proton_default.py +++ b/tools/tests/test_droiddeck_proton_default.py @@ -2,6 +2,7 @@ import json import runpy import tempfile import unittest +from unittest.mock import patch from pathlib import Path BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" @@ -19,6 +20,14 @@ def config_text(entries): class DroidDeckProtonDefaultTest(unittest.TestCase): + def test_play_migrates_unavailable_alternate_requests_to_droiddeck_proton(self): + with patch.dict(COMPAT['requested_tool'].__globals__, PLAY_BUNDLES=True): + self.assertEqual(NEW['name'], COMPAT['requested_tool'](GE, [NEW])) + self.assertEqual(NEW['name'], COMPAT['requested_tool'](VALVE, [NEW])) + default, state = COMPAT['choose_default'](GE['name'], {'default': GE['name']}, {}, [NEW]) + self.assertEqual(NEW['name'], default) + self.assertEqual(NEW['name'], state['default']) + def run_default(self, state, mapping, catalog, apps=(), request=None, settle=True): with tempfile.TemporaryDirectory() as tmp: directory = Path(tmp) diff --git a/tools/tests/test_playstore_archive_preparation.py b/tools/tests/test_playstore_archive_preparation.py new file mode 100644 index 000000000..fc1847f12 --- /dev/null +++ b/tools/tests/test_playstore_archive_preparation.py @@ -0,0 +1,51 @@ +import gzip +import hashlib +from pathlib import Path +import re +import shutil +import subprocess +import tempfile +import unittest + +from tools.playstore.prepare_archive import prepare + + +@unittest.skipUnless(shutil.which('zstd'), 'zstd is unavailable') +class PlayArchivePreparationTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = Path(self.temporary.name) + self.content = b'archive bytes including headers and file metadata\x00' * 1024 + self.source = self.root / 'original.tar.gz' + self.source.write_bytes(gzip.compress(self.content)) + version = re.search(r'v([0-9]+\.[0-9]+\.[0-9]+)', subprocess.check_output(['zstd', '--version'], text=True)).group(1) + self.definition = {'method': 'gzip-to-zstd-19', 'zstd_version': version, + 'tar_sha256': hashlib.sha256(self.content).hexdigest(), 'tar_size': len(self.content)} + + def test_recompression_preserves_every_original_archive_byte(self): + output = self.root / 'prepared.tar.zst' + prepare(self.source, output, self.definition) + self.assertEqual(self.content, subprocess.check_output(['zstd', '-dc', str(output)])) + self.assertEqual(self.content, gzip.decompress(self.source.read_bytes())) + + def test_changed_archive_content_cannot_pass_the_pinned_identity(self): + self.definition['tar_sha256'] = '0' * 64 + with self.assertRaisesRegex(ValueError, 'tar content'): + prepare(self.source, self.root / 'bad.tar.zst', self.definition) + + def test_decompression_cannot_exceed_its_expected_size(self): + self.definition['tar_size'] -= 1 + with self.assertRaisesRegex(ValueError, 'tar size'): + prepare(self.source, self.root / 'oversize.tar.zst', self.definition) + + def test_different_compressor_version_is_rejected_before_writing(self): + self.definition['zstd_version'] = '0.0.0' + output = self.root / 'unexpected.tar.zst' + with self.assertRaisesRegex(ValueError, 'pinned zstd version'): + prepare(self.source, output, self.definition) + self.assertFalse(output.exists()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_playstore_audio_bundle.py b/tools/tests/test_playstore_audio_bundle.py new file mode 100644 index 000000000..1ec397cc8 --- /dev/null +++ b/tools/tests/test_playstore_audio_bundle.py @@ -0,0 +1,47 @@ +import gzip +import hashlib +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch +from zipfile import ZipFile + +from tools.playstore import check_audio_bundle + + +class PlayAudioBundleTest(unittest.TestCase): + def test_packaged_sources_allow_lossless_android_gzip_expansion(self): + self.check_source(b'corresponding source', b'corresponding source', expanded=True) + + def test_packaged_sources_must_match_even_after_android_gzip_expansion(self): + with self.assertRaisesRegex(ValueError, 'differs'): + self.check_source(b'corresponding source', b'other source', expanded=True) + + def test_packaged_audio_asset_cannot_be_replaced_with_stale_output(self): + with self.assertRaisesRegex(ValueError, 'differs'): + self.check_source(b'rebuilt audio', b'old audio', expanded=False) + + def test_packaged_sources_cannot_be_omitted(self): + with self.assertRaises(KeyError): + self.check_source(b'corresponding source', None, expanded=True) + + def check_source(self, expected, actual, expanded): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + name = 'assets/licenses/play-audio/sources/pulse.tar.gz' if expanded else 'assets/pulseaudio.tzst' + source = gzip.compress(expected) if expanded else expected + path = root / name + path.parent.mkdir(parents=True) + path.write_bytes(source) + bundle = root / 'test.aab' + with ZipFile(bundle, 'w') as package: + if actual is not None: + package.writestr('base/' + (name.removesuffix('.gz') if expanded else name), actual) + manifest = {'outputs': {name: hashlib.sha256(source).hexdigest()}} + with patch.object(check_audio_bundle, 'verify', return_value=manifest), \ + patch.object(check_audio_bundle, 'LIBRARIES', []): + check_audio_bundle.check(bundle, root, root / 'ndk') + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_playstore_emulators.py b/tools/tests/test_playstore_emulators.py new file mode 100644 index 000000000..29f771dfe --- /dev/null +++ b/tools/tests/test_playstore_emulators.py @@ -0,0 +1,28 @@ +import os +from pathlib import Path +import subprocess +import tempfile +import unittest + + +SCRIPT = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/droiddeck-emulators' + + +class PlayEmulatorsTest(unittest.TestCase): + def test_guest_play_install_cannot_reach_external_package_managers(self): + with tempfile.TemporaryDirectory() as directory: + marker = Path(directory) / 'package-manager-called' + environment = dict(os.environ, SCRIPT=str(SCRIPT), MARKER=str(marker)) + result = subprocess.run(['bash', '-c', ''' +compgen() { return 0; } +droiddeck-root() { printf called > "$MARKER"; return 1; } +flatpak() { printf called > "$MARKER"; return 1; } +export -f compgen droiddeck-root flatpak +exec bash "$SCRIPT" install +'''], env=environment, capture_output=True, text=True) + self.assertEqual(2, result.returncode) + self.assertFalse(marker.exists()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_playstore_payloads.py b/tools/tests/test_playstore_payloads.py new file mode 100644 index 000000000..d591bbc92 --- /dev/null +++ b/tools/tests/test_playstore_payloads.py @@ -0,0 +1,313 @@ +import hashlib +import importlib.util +import json +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch +import zipfile + + +SPEC = importlib.util.spec_from_file_location('playstore_payloads', Path(__file__).resolve().parents[1] / 'playstore/payloads.py') +payloads = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(payloads) +READER_SPEC = importlib.util.spec_from_file_location('component_delivery', Path(__file__).resolve().parents[1] / + 'linuxfs/overlay/usr/local/lib/droiddeck/component_delivery.py') +delivery = importlib.util.module_from_spec(READER_SPEC) +READER_SPEC.loader.exec_module(delivery) + + +class PlaystorePayloadsTest(unittest.TestCase): + def setUp(self): + directory = tempfile.TemporaryDirectory() + self.addCleanup(directory.cleanup) + self.root = Path(directory.name) + self.cache = self.root / 'cache' + self.cache.mkdir() + self.content = b'component-payload-for-offline-installation' + self.digest = hashlib.sha256(self.content).hexdigest() + (self.cache / self.digest).write_bytes(self.content) + self.manifest = {'schema': 1, 'required': ['runtime'], 'entries': [{ + 'id': 'runtime', 'size': len(self.content), 'sha256': self.digest, + 'urls': ['https://example.test/runtime.tar.zst'], 'provides': ['runtime'], + 'source': 'https://example.test/source', 'source_commit': 'a' * 40, + 'license': {'expression': 'MIT', 'url': 'https://example.test/LICENSE', 'approved': True, + 'redistribution_review': 'License permits redistribution with included notice'}, + }]} + + def validate(self): + path = self.root / 'manifest.json' + path.write_text(json.dumps(self.manifest)) + return payloads.load_manifest(path) + + def chunks(self, entry, staged=None): + staged = staged or self.root / "staged" + return json.loads((staged / "base/src/main/assets" / entry["recipe"]).read_text())["chunks"] + + def test_chunks_reassemble_exactly_across_module_boundaries_without_network(self): + with patch.object(payloads.urllib.request, 'build_opener', side_effect=AssertionError('Unexpected network')): + index = payloads.stage(self.validate(), self.cache, self.root / 'staged', chunk_bytes=7, module_bytes=14) + entry = index['entries'][self.manifest['entries'][0]['urls'][0]] + restored = bytearray() + modules = {} + for chunk in self.chunks(entry): + content = (self.root / 'staged' / chunk['module'] / 'src/main/assets' / chunk['asset']).read_bytes() + self.assertEqual(hashlib.sha256(content).hexdigest(), chunk['sha256']) + self.assertEqual(len(content), chunk['size']) + modules[chunk['module']] = modules.get(chunk['module'], 0) + len(content) + restored.extend(content) + self.assertGreater(len(modules), 1) + self.assertTrue(all(size <= 14 for size in modules.values())) + self.assertEqual(restored, self.content) + self.assertEqual(hashlib.sha256(restored).hexdigest(), entry['sha256']) + + def test_equal_payloads_share_chunks_without_duplicate_delivery(self): + duplicate = dict(self.manifest['entries'][0], id='driver', urls=['https://example.test/driver'], provides=['driver']) + self.manifest['entries'].append(duplicate) + self.manifest['required'].append('driver') + index = payloads.stage(self.validate(), self.cache, self.root / 'staged', chunk_bytes=7, module_bytes=14) + entries = list(index['entries'].values()) + self.assertEqual(self.chunks(entries[0]), self.chunks(entries[1])) + delivered = [path for path in (self.root / 'staged').rglob('*') if path.is_file() and path.name.isdigit()] + self.assertEqual(sum(path.stat().st_size for path in delivered), len(self.content)) + + def test_corrupt_cache_does_not_fall_back_to_network_or_write_output(self): + (self.cache / self.digest).write_bytes(b'corrupt') + with patch.object(payloads.urllib.request, 'build_opener', side_effect=AssertionError('Unexpected network')): + with self.assertRaisesRegex(ValueError, 'verification'): + payloads.stage(self.validate(), self.cache, self.root / 'staged') + self.assertFalse((self.root / 'staged').exists()) + self.assertEqual((self.cache / self.digest).read_bytes(), b'corrupt') + + def test_existing_output_is_preserved(self): + output = self.root / 'staged' + output.mkdir() + sentinel = output / 'keep' + sentinel.write_bytes(b'existing') + with self.assertRaisesRegex(ValueError, 'new directory'): + payloads.stage(self.validate(), self.cache, output) + self.assertEqual(sentinel.read_bytes(), b'existing') + + def test_required_feature_cannot_be_silently_omitted(self): + self.manifest['required'].append('proton') + with self.assertRaisesRegex(ValueError, 'Missing component coverage: proton'): + self.validate() + + def test_unknown_schema_and_empty_manifest_are_rejected(self): + self.manifest['schema'] = 2 + with self.assertRaisesRegex(ValueError, 'schema'): + self.validate() + self.manifest['schema'] = 1 + self.manifest['entries'] = [] + with self.assertRaisesRegex(ValueError, 'empty'): + self.validate() + + def test_prepared_alias_cannot_bypass_upstream_pinning(self): + entry = self.manifest['entries'][0] + entry['urls'] = ['droiddeck-bundle://runtime/runtime.tar.zst'] + with self.assertRaisesRegex(ValueError, 'prepared component alias'): + self.validate() + entry['prepare'] = {'method': 'gzip-to-zstd-19', 'zstd_version': '1.5.5', + 'tar_sha256': 'a' * 64, 'tar_size': 1024} + with self.assertRaisesRegex(ValueError, 'upstream archive'): + self.validate() + entry['upstream'] = {'urls': ['https://example.test/runtime.tar.gz'], 'sha256': 'b' * 64, 'size': 100} + self.validate() + entry['upstream']['urls'] = ['http://example.test/runtime.tar.gz'] + with self.assertRaisesRegex(ValueError, 'HTTPS'): + self.validate() + + def test_review_only_inventory_cannot_enter_the_play_release_workflow(self): + self.manifest['release_ready'] = False + with self.assertRaisesRegex(ValueError, 'Review-only'): + payloads.validate_play_engines(self.manifest) + + def test_unconfirmed_redistribution_cannot_be_published_by_toggling_the_release_flag(self): + self.manifest['release_ready'] = True + self.manifest['entries'][0]['license']['approved'] = False + with self.assertRaisesRegex(ValueError, 'redistribution review is incomplete'): + payloads.validate_play_engines(self.manifest) + + def test_play_bundle_cannot_include_extra_desktop_emulators(self): + self.manifest['required'].append('proton:droiddeck') + entry = self.manifest['entries'][0] + entry['provides'].append('proton:droiddeck') + entry['urls'] = ['https://github.com/Droid-Deck/DroidDeck-Proton/releases/download/pinned/proton.tar.gz'] + entry['provides'].append('emulator:ppsspp') + with self.assertRaisesRegex(ValueError, 'Extra desktop emulators'): + payloads.validate_play_engines(self.manifest) + + def test_frozen_catalog_is_served_without_consulting_a_mutable_external_api(self): + entry = self.manifest['entries'][0] + entry['content'] = {'version': 'pinned', 'assets': []} + data = payloads.catalog_bytes(entry['content']) + entry['sha256'], entry['size'] = hashlib.sha256(data).hexdigest(), len(data) + with patch.object(payloads.urllib.request, 'build_opener', side_effect=AssertionError('Unexpected network')): + target = payloads.fetch(self.validate()['entries'][0], self.cache) + self.assertEqual(data, target.read_bytes()) + + def test_frozen_catalog_changes_cannot_keep_the_old_hash(self): + entry = self.manifest['entries'][0] + entry['content'] = {'version': 'changed'} + with self.assertRaisesRegex(ValueError, 'Frozen catalog identity'): + self.validate() + + def test_unpinned_or_unreviewed_component_is_rejected(self): + for field, value, message in [('sha256', 'bad', 'SHA-256'), ('size', True, 'positive byte'), + ('source_commit', 'main', 'pinned source'), ('license', {}, 'redistribution')]: + with self.subTest(field=field): + original = self.manifest['entries'][0][field] + self.manifest['entries'][0][field] = value + with self.assertRaisesRegex(ValueError, message): + self.validate() + self.manifest['entries'][0][field] = original + + def test_duplicate_urls_and_unsafe_sources_are_rejected(self): + entry = self.manifest['entries'][0] + entry['urls'].append(entry['urls'][0]) + with self.assertRaisesRegex(ValueError, 'Duplicate URL'): + self.validate() + for url in ['http://example.test/component', 'https://user:secret@example.test/component', + 'file:///tmp/component', 'https://example.test/component#fragment']: + entry['urls'] = [url] + with self.subTest(url=url), self.assertRaisesRegex(ValueError, 'HTTPS'): + self.validate() + + def test_total_delivery_budget_counts_unique_content_and_base_reserve(self): + with patch.object(payloads, 'TOTAL_BYTES', len(self.content) + payloads.RESERVED_BYTES - 1): + with self.assertRaisesRegex(ValueError, 'budget exceeded'): + self.validate() + + def test_redirect_cannot_downgrade_to_plain_http(self): + with self.assertRaisesRegex(ValueError, 'HTTPS'): + payloads.HttpsRedirects().redirect_request(None, None, 302, '', {}, 'http://example.test/payload') + + def test_partial_download_is_preserved_and_not_resumed_without_identity(self): + target = self.cache / self.digest + alternate = self.root / 'other-cache' + alternate.mkdir() + part = alternate / (self.digest + '.part') + part.write_bytes(target.read_bytes()[:3]) + with self.assertRaisesRegex(ValueError, 'Incomplete payload'): + payloads.fetch(self.manifest['entries'][0], alternate) + self.assertEqual(part.read_bytes(), self.content[:3]) + + def apk_set(self, change=None): + staged = self.root / 'staged' + index = payloads.stage(self.validate(), self.cache, staged, chunk_bytes=7, module_bytes=14) + installed = self.root / 'installed/0' + installed.mkdir(parents=True) + if change is not None: + change(staged, index) + for module in staged.iterdir(): + if not module.is_dir(): + continue + assets = module / 'src/main/assets' + with zipfile.ZipFile(installed / (module.name + '.apk'), 'w', zipfile.ZIP_DEFLATED) as archive: + for path in sorted(assets.rglob('*')): + if path.is_file(): + archive.write(path, 'assets/' + path.relative_to(assets).as_posix()) + return installed.parent + + def test_guest_reads_the_same_chunked_payload_directly_from_split_apks(self): + installed = self.apk_set() + self.assertTrue(delivery.enabled(installed)) + with delivery.BundleReader(installed) as reader: + destination = self.root / 'restored' + reader.fetch(self.manifest['entries'][0]['urls'][0], destination, self.digest) + self.assertEqual(destination.read_bytes(), self.content) + + def test_guest_corruption_preserves_existing_file_without_external_fallback(self): + def corrupt(staged, index): + chunk = self.chunks(next(iter(index['entries'].values())), staged)[0] + (staged / chunk['module'] / 'src/main/assets' / chunk['asset']).write_bytes(b'corrupt') + installed = self.apk_set(corrupt) + destination = self.root / 'restored' + destination.write_bytes(b'existing') + with delivery.BundleReader(installed) as reader: + with self.assertRaisesRegex(ValueError, 'verification'): + reader.fetch(self.manifest['entries'][0]['urls'][0], destination) + self.assertEqual(destination.read_bytes(), b'existing') + self.assertEqual(list(self.root.glob('*.component-part')), []) + + def test_guest_missing_split_is_a_failure_without_any_download(self): + installed = self.apk_set() + split = installed / '0/playpayload02.apk' + split.rename(self.root / 'preserved-split.apk') + with delivery.BundleReader(installed) as reader: + with self.assertRaises(KeyError): + reader.read(self.manifest['entries'][0]['urls'][0]) + + def test_guest_rejects_missing_component_and_wrong_digest(self): + with delivery.BundleReader(self.apk_set()) as reader: + with self.assertRaisesRegex(ValueError, 'absent'): + reader.read('https://example.test/not-bundled') + with self.assertRaisesRegex(ValueError, 'version'): + reader.fetch(self.manifest['entries'][0]['urls'][0], self.root / 'restored', '0' * 64) + + def test_guest_rejects_duplicate_assets_across_splits(self): + installed = self.apk_set() + original = installed / '0/base.apk' + (installed / '0/duplicate.apk').write_bytes(original.read_bytes()) + with self.assertRaisesRegex(ValueError, 'Duplicate'): + delivery.BundleReader(installed) + + def bundle(self, change=None): + staged = self.root / 'staged' + index = payloads.stage(self.validate(), self.cache, staged, chunk_bytes=7, module_bytes=14) + if change is not None: + change(staged, index) + target = self.root / 'fixture.aab' + with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED) as archive: + for module in staged.iterdir(): + if module.is_dir(): + assets = module / 'src/main/assets' + for path in sorted(assets.rglob('*')): + if path.is_file(): + archive.write(path, module.name + '/assets/' + path.relative_to(assets).as_posix()) + return target + + def test_final_bundle_inventory_and_each_delivered_byte_are_verified(self): + sizes = payloads.verify_bundle(self.validate(), self.bundle()) + self.assertIn('base', sizes) + self.assertIn('playpayload02', sizes) + + def test_final_bundle_cannot_contain_corrupt_chunk_bytes(self): + def corrupt(staged, index): + entry = next(iter(index['entries'].values())) + chunk = self.chunks(entry, staged)[0] + (staged / chunk['module'] / 'src/main/assets' / chunk['asset']).write_bytes(b'corrupt') + with self.assertRaisesRegex(ValueError, 'digest mismatch'): + payloads.verify_bundle(self.validate(), self.bundle(corrupt)) + + def test_final_bundle_cannot_silently_include_stale_unreferenced_components(self): + def add_stale(staged, index): + path = staged / 'playpayload01/src/main/assets/play-components/stale' + path.write_bytes(b'old component') + with self.assertRaisesRegex(ValueError, 'unreferenced'): + payloads.verify_bundle(self.validate(), self.bundle(add_stale)) + + def test_final_bundle_must_match_the_release_manifest(self): + bundle = self.bundle() + self.manifest['entries'][0]['id'] = 'changed' + with self.assertRaisesRegex(ValueError, 'inventory differs'): + payloads.verify_bundle(self.manifest, bundle) + + def test_play_distribution_rejects_alternate_proton_engines_and_valve_seed(self): + with self.assertRaisesRegex(ValueError, 'requires DroidDeck'): + payloads.validate_play_engines(self.manifest) + self.manifest['required'].append('proton:droiddeck') + entry = self.manifest['entries'][0] + entry['provides'].append('proton:droiddeck') + entry['urls'] = ['https://github.com/Droid-Deck/DroidDeck-Proton/releases/download/pinned/proton.tar.gz'] + payloads.validate_play_engines(self.manifest) + for url in ['https://github.com/GloriousEggroll/proton-ge-custom/releases/download/pinned/proton.tar.gz', + 'https://github.com/CachyOS/proton-cachyos/releases/download/pinned/proton.tar.xz', + 'https://raw.githubusercontent.com/Droid-Deck/DroidDeck-Components/main/steam-seed.json']: + entry['urls'] = [url] + with self.assertRaisesRegex(ValueError, 'forbidden'): + payloads.validate_play_engines(self.manifest) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_playstore_signing.py b/tools/tests/test_playstore_signing.py new file mode 100644 index 000000000..6d0e0929a --- /dev/null +++ b/tools/tests/test_playstore_signing.py @@ -0,0 +1,82 @@ +import importlib.util +import contextlib +import io +import os +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch +import zipfile + + +ROOT = Path(__file__).resolve().parents[2] +SPEC = importlib.util.spec_from_file_location('playstore_signing', ROOT / 'tools/playstore/sign_bundle.py') +signing = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(signing) + + +class PlaystoreSigningTest(unittest.TestCase): + def setUp(self): + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + self.root = Path(temporary.name) + self.source = self.root / 'input.aab' + self.destination = self.root / 'signed.aab' + self.keystore = ROOT / 'keystore/testkey.p12' + self.signer = 'a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc' + with zipfile.ZipFile(self.source, 'w', zipfile.ZIP_DEFLATED) as package: + package.writestr('base/assets/runtime', b'component payload') + package.writestr('base/manifest/AndroidManifest.xml', b'fixture manifest') + package.writestr('META-INF/OLD.SF', b'old signature') + package.writestr('META-INF/OLD.RSA', b'old certificate') + package.writestr('META-INF/services/runtime', b'keep service metadata') + + def sign(self, signer=None): + with patch.dict(os.environ, RELEASE_STORE_PASSWORD='android'): + signing.sign(self.source, self.destination, self.keystore, 'testkey', signer or self.signer) + + def test_signs_with_pinned_certificate_preserving_every_payload_and_source(self): + original = self.source.read_bytes() + self.sign() + self.assertEqual(original, self.source.read_bytes()) + with zipfile.ZipFile(self.source) as source, zipfile.ZipFile(self.destination) as output: + self.assertNotIn('META-INF/OLD.SF', output.namelist()) + self.assertNotIn('META-INF/OLD.RSA', output.namelist()) + for name in ['base/assets/runtime', 'base/manifest/AndroidManifest.xml', 'META-INF/services/runtime']: + self.assertEqual(source.read(name), output.read(name)) + + def test_unexpected_signing_identity_creates_no_output(self): + with self.assertRaisesRegex(ValueError, 'release identity'): + self.sign('0' * 64) + self.assertFalse(self.destination.exists()) + + def test_existing_destination_cannot_be_overwritten(self): + self.destination.write_bytes(b'keep existing') + with self.assertRaisesRegex(ValueError, 'new output'): + self.sign() + self.assertEqual(self.destination.read_bytes(), b'keep existing') + + def test_missing_password_cannot_sign_a_bundle(self): + with patch.dict(os.environ, RELEASE_STORE_PASSWORD=''): + with self.assertRaisesRegex(ValueError, 'password'): + signing.sign(self.source, self.destination, self.keystore, 'testkey', self.signer) + self.assertFalse(self.destination.exists()) + + def test_alias_is_not_used_as_signature_metadata_or_printed(self): + output = io.StringIO() + with contextlib.redirect_stdout(output): + self.sign() + self.assertNotIn('testkey', output.getvalue()) + with zipfile.ZipFile(self.destination) as package: + self.assertIn('META-INF/RELEASE.SF', package.namelist()) + self.assertFalse(any('TESTKEY' in name.upper() for name in package.namelist())) + + def test_wrong_alias_fails_without_printing_it_or_creating_an_output(self): + with patch.dict(os.environ, RELEASE_STORE_PASSWORD='android'): + with self.assertRaisesRegex(ValueError, '^Bundle signing or signature verification failed$'): + signing.sign(self.source, self.destination, self.keystore, 'private-alias-value', self.signer) + self.assertFalse(self.destination.exists()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_playstore_workflow.py b/tools/tests/test_playstore_workflow.py new file mode 100644 index 000000000..eb42415a8 --- /dev/null +++ b/tools/tests/test_playstore_workflow.py @@ -0,0 +1,106 @@ +from pathlib import Path +import re +import unittest +import yaml + + +ROOT = Path(__file__).resolve().parents[2] + + +class PlaystoreWorkflowTest(unittest.TestCase): + def setUp(self): + self.play = yaml.load((ROOT / '.github/workflows/playstore.yml').read_text(), Loader=yaml.BaseLoader) + self.shared = yaml.load((ROOT / '.github/workflows/build.yml').read_text(), Loader=yaml.BaseLoader) + self.release = yaml.load((ROOT / '.github/workflows/release.yml').read_text(), Loader=yaml.BaseLoader) + + def test_play_source_defaults_to_playstore_and_is_pinned_for_build_and_signing(self): + self.assertEqual(['playstore'], self.play['on']['push']['branches']) + inputs = self.play['on']['workflow_dispatch']['inputs'] + self.assertEqual('playstore', inputs['source_branch']['default']) + self.assertEqual(['playstore'], inputs['source_branch']['options']) + self.assertEqual('Version for the file names, e.g. 0.1.7', inputs['version']['description']) + self.assertEqual('true', inputs['version']['required']) + call = self.play['jobs']['bundle'] + self.assertEqual('./.github/workflows/build.yml', call['uses']) + self.assertEqual('true', call['with']['play_bundle']) + self.assertEqual('${{ needs.source.outputs.sha }}', call['with']['source_sha']) + for name in ['sign', 'publish']: + self.assertEqual('${{ needs.source.outputs.sha }}', self.play['jobs'][name]['steps'][0]['with']['ref']) + self.assertEqual('signing-playstore', self.play['jobs']['sign']['environment']) + signing = next(step for step in self.play['jobs']['sign']['steps'] if step.get('name') == 'Sign the verified Play bundle') + self.assertEqual('${{ secrets.RELEASE_KEY_ALIAS }}', signing['env']['RELEASE_KEY_ALIAS']) + self.assertNotIn('--alias', signing['run']) + self.assertEqual('${{ needs.source.outputs.version_code }}', call['with']['play_version_code']) + + def test_shared_release_and_catalog_jobs_cannot_run_for_a_play_bundle(self): + for name in ['sign', 'packs', 'announce', 'catalog']: + with self.subTest(job=name): + condition = self.shared['jobs'][name]['if'] + self.assertIn('!inputs.play_bundle', condition) + self.assertIn("github.ref == 'refs/heads/main'", condition) + + def test_only_manual_play_releases_can_publish_and_never_replace_latest(self): + self.assertEqual('read', self.play['permissions']['contents']) + self.assertEqual('Build PlayStore Bundle', self.play['name']) + publish = self.play['jobs']['publish'] + self.assertEqual("github.event_name == 'workflow_dispatch'", publish['if']) + self.assertEqual('write', publish['permissions']['contents']) + command = publish['steps'][-1]['run'] + self.assertIn('--latest=false', command) + self.assertIn('tag="playstore-$VERSION"', command) + self.assertNotRegex(command, r'--latest(?:\s|$)') + allowed = {'actions/checkout@v4', 'actions/setup-java@v4', 'actions/download-artifact@v4', + 'actions/upload-artifact@v4', 'actions/setup-python@v5'} + artifacts = [] + for name, job in self.play['jobs'].items(): + if name != 'publish': + self.assertNotEqual('write', job.get('permissions', {}).get('contents')) + for step in job.get('steps', []): + if 'uses' in step: + self.assertIn(step['uses'], allowed) + command = step.get('run', '') + if name != 'publish': + self.assertIsNone(re.search(r'gh\s+(?:release|api\b[^\n]*releases)|publish-ci|announce-preview|update-catalog', command)) + if step.get('uses') == 'actions/upload-artifact@v4': + artifacts.append(step['with']['name']) + self.assertIn('droiddeck-play-bundle-signed', artifacts) + + def test_play_source_hash_reaches_every_shared_compile_and_test_checkout(self): + for name in ['source', 'xbox', 'components', 'build', 'store-tests', 'python-tests']: + checkout = self.shared['jobs'][name]['steps'][0] + self.assertIn('inputs.source_sha', checkout['with']['ref']) + + def test_existing_manual_release_entry_point_can_build_play_without_changing_main(self): + entry = self.release['jobs']['playstore'] + self.assertEqual("github.ref == 'refs/heads/playstore'", entry['if']) + self.assertEqual('./.github/workflows/playstore.yml', entry['uses']) + self.assertEqual('playstore', entry['with']['source_branch']) + self.assertEqual('${{ inputs.version }}', entry['with']['version']) + self.assertEqual('true', self.play['on']['workflow_call']['inputs']['version']['required']) + for name in ['find', 'sign', 'packs', 'publish']: + self.assertEqual("github.ref == 'refs/heads/main'", self.release['jobs'][name]['if']) + self.assertIn("'release-playstore' || 'release'", self.release['concurrency']['group']) + + def test_play_version_codes_are_independent_of_the_entry_workflow_counter(self): + self.assertEqual('playstore-bundle', self.play['concurrency']['group']) + self.assertEqual('false', self.play['concurrency']['cancel-in-progress']) + source = self.play['jobs']['source']['steps'][-1]['run'] + self.assertIn('date -u +%s', source) + self.assertNotIn('GITHUB_RUN_NUMBER', source) + self.assertIn('version_code=$((base + elapsed))', source) + + def test_distribution_checks_run_without_the_production_manifest_or_signing_secrets(self): + checks = self.play['jobs']['checks'] + self.assertNotIn('needs', checks) + self.assertNotIn('environment', checks) + self.assertEqual('read', checks['permissions']['contents']) + self.assertIn('checks', self.play['jobs']['sign']['needs']) + for step in checks['steps']: + self.assertNotIn('secrets.', str(step)) + command = checks['steps'][-1]['run'] + self.assertIn('tools.tests.test_playstore_signing', command) + self.assertIn('tools.tests.test_playstore_payloads', command) + + +if __name__ == '__main__': + unittest.main()