mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 11:05:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
733db7ab7d | ||
|
|
5a445356e4 | ||
|
|
25ee14aa2f | ||
|
|
2c95ebd22d | ||
|
|
7ce53ccbed | ||
|
|
1b4aaf8a3b | ||
|
|
4793d1df62 |
No files matched your search
@@ -7,7 +7,7 @@ on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_run:
|
||||
workflows: [Build APK]
|
||||
workflows: [Build APK, Unit tests]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
+2
-115
@@ -349,7 +349,7 @@ jobs:
|
||||
|
||||
build:
|
||||
needs: [source, components, xbox, build-runner]
|
||||
name: Compile APK and Android tests
|
||||
name: Compile APK
|
||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||
runs-on: ${{ fromJSON(needs.build-runner.outputs.labels) }}
|
||||
timeout-minutes: 45
|
||||
@@ -507,23 +507,7 @@ jobs:
|
||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
BUILD_REF: ${{ github.ref_name }}
|
||||
BUILD_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
tree_state=dirty
|
||||
else
|
||||
tree_state=clean
|
||||
fi
|
||||
echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV"
|
||||
if [[ -n "$PR_NUMBER" ]]; then
|
||||
label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}"
|
||||
else
|
||||
label="${BUILD_REF} at ${BUILD_SHA:0:7}"
|
||||
fi
|
||||
echo "label=$label" >> "$GITHUB_OUTPUT"
|
||||
echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV"
|
||||
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
|
||||
run: bash tools/ci/build-label.sh
|
||||
|
||||
- name: Rust toolchain for the store engines (aarch64-linux-android)
|
||||
id: rust
|
||||
@@ -734,101 +718,6 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
|
||||
- name: Resolve the Robolectric version
|
||||
id: robolectric
|
||||
run: |
|
||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
||||
# "..". Runners that keep their own ~/.m2 skip the cache.
|
||||
- name: Place Robolectric's Android jars beside the workspace
|
||||
id: robolectric-jars
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mkdir -p "$jars" "$(dirname "$m2")"
|
||||
jars=$(cd "$jars" && pwd)
|
||||
ln -sfn "$jars" "$m2"
|
||||
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Restore Robolectric's Android jars
|
||||
id: robolectric-cache
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
||||
- name: Count the restored Robolectric jars
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
mkdir -p app/build
|
||||
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
||||
for wait in 60 180 0; do
|
||||
status=0
|
||||
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
|
||||
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
|
||||
exit "$status"
|
||||
fi
|
||||
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
|
||||
sleep "$wait"
|
||||
done
|
||||
|
||||
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
||||
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
||||
- name: Save Robolectric's Android jars
|
||||
id: robolectric-jars-final
|
||||
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import glob, os, zipfile
|
||||
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
||||
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
||||
if not os.path.isfile(f):
|
||||
continue
|
||||
try:
|
||||
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
||||
except Exception:
|
||||
ok = False
|
||||
if not ok:
|
||||
os.remove(f)
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
|
||||
- name: Upload unit test diagnostics
|
||||
id: unit-test-diagnostics
|
||||
if: always() && steps.unit-tests.outcome != 'skipped'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: unit-test-results
|
||||
path: |
|
||||
app/build/unit-tests.log
|
||||
app/build/test-results/testReleaseUnitTest/
|
||||
app/build/reports/tests/testReleaseUnitTest/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
overwrite: true
|
||||
|
||||
- name: Sign with the testkey (v1 + v2 + v3)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -884,8 +773,6 @@ jobs:
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
BUILD_OUTCOME: ${{ steps.build.outcome }}
|
||||
UNIT_TEST_OUTCOME: ${{ steps.unit-tests.outcome }}
|
||||
TEST_DIAGNOSTICS_URL: ${{ steps.unit-test-diagnostics.outputs.artifact-url }}
|
||||
APK_OUTCOME: ${{ steps.apk-upload.outcome }}
|
||||
run: bash tools/release/report-build.sh
|
||||
|
||||
|
||||
@@ -47,6 +47,13 @@ jobs:
|
||||
echo "::error::main ${GITHUB_SHA::7} has no successful Build APK run yet: wait for it, then release"
|
||||
exit 1
|
||||
fi
|
||||
tests=$(gh run list -R "$GITHUB_REPOSITORY" --workflow unit-tests.yml --branch main --commit "$GITHUB_SHA" \
|
||||
--json conclusion,event,headSha -L 20 |
|
||||
jq -r --arg sha "$GITHUB_SHA" '[.[] | select(.headSha == $sha and (.event == "push" or .event == "workflow_dispatch"))][0].conclusion // empty')
|
||||
if [ "$tests" != success ]; then
|
||||
echo "::error::main ${GITHUB_SHA::7} has no passing Unit tests run (${tests:-none yet}): fix or wait for it, then release"
|
||||
exit 1
|
||||
fi
|
||||
variants=$(awk '!/^#/ && NF { print $1 }' tools/release/variants.txt | jq -R . | jq -sc .)
|
||||
echo "run_id=$id" >> "$GITHUB_OUTPUT"
|
||||
echo "variants=$variants" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
name: Unit tests
|
||||
run-name: ${{ github.event_name == 'pull_request' && format('unit tests for pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('unit tests for {0} on {1}', github.ref_name, github.sha) }}
|
||||
|
||||
# Runs beside Build APK rather than inside it, so a test build is published as soon as the APK compiles.
|
||||
# Build validation folds this workflow's result into the "Build APK" commit status, and Release APKs requires it.
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- 'docs/**'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
types: [ opened, synchronize, reopened, ready_for_review ]
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- 'docs/**'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
concurrency:
|
||||
group: unit-tests-${{ github.event.pull_request.number || (github.event_name == 'push' && 'main') || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit tests
|
||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ 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: Merge onto main
|
||||
if: github.event_name == 'pull_request'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config user.name "ci"
|
||||
git config user.email "ci@users.noreply.github.com"
|
||||
git fetch --no-tags origin main
|
||||
git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true
|
||||
git merge --no-ff --no-edit FETCH_HEAD || { echo "::error::the pull request conflicts with main; Build APK lists the files"; exit 1; }
|
||||
|
||||
- name: Check out MaliBridge
|
||||
run: git submodule update --init external/MaliBridge
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
cache-cleanup: ${{ github.event_name == 'pull_request' && 'never' || 'on-success' }}
|
||||
|
||||
- name: Resolve the pinned Android NDK
|
||||
run: bash tools/ci/resolve-ndk.sh
|
||||
|
||||
- name: Set the APK build label
|
||||
id: build-label
|
||||
env:
|
||||
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 }}
|
||||
run: bash tools/ci/build-label.sh
|
||||
|
||||
- name: Resolve the Robolectric version
|
||||
id: robolectric
|
||||
run: |
|
||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
||||
# "..". Runners that keep their own ~/.m2 skip the cache.
|
||||
- name: Place Robolectric's Android jars beside the workspace
|
||||
id: robolectric-jars
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mkdir -p "$jars" "$(dirname "$m2")"
|
||||
jars=$(cd "$jars" && pwd)
|
||||
ln -sfn "$jars" "$m2"
|
||||
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Restore Robolectric's Android jars
|
||||
id: robolectric-cache
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
||||
- name: Count the restored Robolectric jars
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
mkdir -p app/build
|
||||
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
||||
for wait in 60 180 0; do
|
||||
status=0
|
||||
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PskipRust=true -PunitTestsOnly=true -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
|
||||
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
|
||||
exit "$status"
|
||||
fi
|
||||
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
|
||||
sleep "$wait"
|
||||
done
|
||||
|
||||
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
||||
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
||||
- name: Save Robolectric's Android jars
|
||||
id: robolectric-jars-final
|
||||
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import glob, os, zipfile
|
||||
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
||||
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
||||
if not os.path.isfile(f):
|
||||
continue
|
||||
try:
|
||||
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
||||
except Exception:
|
||||
ok = False
|
||||
if not ok:
|
||||
os.remove(f)
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
|
||||
- name: Upload unit test diagnostics
|
||||
id: unit-test-diagnostics
|
||||
if: always() && steps.unit-tests.outcome != 'skipped'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: unit-test-results
|
||||
path: |
|
||||
app/build/unit-tests.log
|
||||
app/build/test-results/testReleaseUnitTest/
|
||||
app/build/reports/tests/testReleaseUnitTest/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
overwrite: true
|
||||
@@ -7,7 +7,7 @@
|
||||
- For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step.
|
||||
- `tools/build_local.sh` reuses the components a main CI run prepared when every recipe identity matches the local tree (it prints `components: … reusing`). It builds them locally when no usable CI artifact matches (after you change their inputs, or when the lookup fails) or with `DROIDDECK_CI_COMPONENTS=0`.
|
||||
- Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout.
|
||||
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest`; when a test fails only in CI, run the release variant locally.
|
||||
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest` in the `Unit tests` workflow, beside Build APK; when a test fails only in CI, run the release variant locally.
|
||||
- Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI.
|
||||
- For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape.
|
||||
- After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`.
|
||||
@@ -31,7 +31,7 @@
|
||||
- CI builds the PR merged onto `main`. Before pushing, merge or rebase onto `origin/main` and compile: most "works locally" Kotlin failures come from that merge.
|
||||
- Before a PR that touches strings or resources, run `./gradlew :app:lintVitalRelease`. The fast loop skips lint, and lint catches `ExtraTranslation` and missing-locale errors.
|
||||
- Commit messages and PR bodies must not carry `Co-Authored-By` or other bot trailers. `tools/release/check_authorship.py` fails the build on them.
|
||||
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results`. Don't call a failure a runner problem until you have read it.
|
||||
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results` from the `Unit tests` workflow run. Don't call a failure a runner problem until you have read it.
|
||||
- Only these are known flakes worth a `gh run rerun <run> --failed`: `ProtonMenuAutoTest` "Proton work did not finish", Robolectric `HTTP response code: 429` from Maven, `Gradle Test Executor N finished with non-zero exit value 2`, apt mirror and GitHub API rate-limit errors. Treat any other failure as real.
|
||||
- A workflow step that names a script your branch lacks means the branch predates a CI change. Rebase onto `main`.
|
||||
|
||||
|
||||
+5
-1
@@ -82,6 +82,8 @@ 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'
|
||||
// The Unit tests workflow compiles no APK, so it has no add-on packs to pin.
|
||||
def unitTestsOnly = project.findProperty('unitTestsOnly')?.toString()?.toBoolean() ?: false
|
||||
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()
|
||||
@@ -96,10 +98,12 @@ def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
||||
def pack = file("build/packs/${name}.tar.zst")
|
||||
if (!pack.isFile()) {
|
||||
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
if (ciBuild && !unitTestsOnly) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
if (name == 'proot' && prootPackPin.PROOT_PACK_SHA256) {
|
||||
return [(name): [sha256: prootPackPin.PROOT_PACK_SHA256, size: (prootPackPin.PROOT_PACK_SIZE ?: '0') as long]]
|
||||
}
|
||||
// A CI APK pins every pack, and CI_BUILD code assumes that, so the tests see a placeholder pin.
|
||||
if (unitTestsOnly) return [(name): [sha256: '0' * 64, size: 0L]]
|
||||
return [(name): [sha256: '', size: 0L]]
|
||||
}
|
||||
def digest = java.security.MessageDigest.getInstance('SHA-256')
|
||||
|
||||
@@ -807,6 +807,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
private var isHomeApp by mutableStateOf(false)
|
||||
private var androidApps by mutableStateOf<List<HomeApp.LaunchableApp>>(emptyList())
|
||||
private var padConnected by mutableStateOf(false)
|
||||
|
||||
private val deviceListener = object : InputManager.InputDeviceListener {
|
||||
override fun onInputDeviceAdded(deviceId: Int) {
|
||||
@@ -1264,7 +1265,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
) { headTracker?.recenter() }
|
||||
if (!phonePanel && glasses.present && !drawerOpen && !pcKeyboardOpen && !loading.visible) com.droiddeck.launcher.ui.GlassesCornerButton(glassesSlot,
|
||||
controllerSettings?.tint ?: android.graphics.Color.rgb(90, 160, 255), controllerSettings?.opacity ?: 100) {
|
||||
drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.GLASSES
|
||||
drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.VR
|
||||
drawerOpen = true
|
||||
}
|
||||
if (!drawerOpen && !pcKeyboardOpen && !loading.visible) {
|
||||
@@ -1451,7 +1452,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
LaunchedEffect(drawerOpen, achievementsOpen, AgentGuest.focusRevision, StoreAchievements.revision) {
|
||||
if (!drawerOpen && !achievementsOpen) return@LaunchedEffect
|
||||
if (!drawerOpen && !achievementsOpen) {
|
||||
achievementsInFront = null
|
||||
return@LaunchedEffect
|
||||
}
|
||||
val found = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
|
||||
runCatching { resolveAchievementsInFront() }
|
||||
.onFailure { Log.w(TAG, "achievements in front: ${it.javaClass.simpleName}") }.getOrNull()
|
||||
@@ -1787,7 +1791,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onBlackFrameInsertion = { on ->
|
||||
SessionPrefs.setBlackFrameInsertion(this@SessionActivity, on)
|
||||
blackFrameInsertion = on
|
||||
CompositorHost.setBlackFrameInsertion(on, refreshHz(), outputFpsLimit())
|
||||
CompositorHost.setBlackFrameInsertion(on, refreshHz(), compositorFpsLimit())
|
||||
},
|
||||
hdr = hdrWanted,
|
||||
hdrAvailable = hdrAvailable,
|
||||
@@ -1824,7 +1828,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } },
|
||||
onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null,
|
||||
onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null,
|
||||
onAchievements = achievementsInFront?.let { { drawerOpen = false; achievementsOpen = true } },
|
||||
controllerConnected = padConnected,
|
||||
achievementsGame = achievementsInFront?.game,
|
||||
achievementsTitle = achievementsInFront?.title,
|
||||
achievementsProgress = achievementsInFront?.progress,
|
||||
padType = if (SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad) padType else null,
|
||||
onPadType = { id ->
|
||||
@@ -2990,7 +2996,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
CompositorHost.startOrAttach(
|
||||
this, holder.surface, runtimeDir.path,
|
||||
driverId?.let { turnip.driverPath(it) }, driverId?.let { turnip.libraryName(it) },
|
||||
applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(holder), outputFpsLimit(),
|
||||
applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(holder), compositorFpsLimit(),
|
||||
)
|
||||
onOutputAttached(holder)
|
||||
if (SessionState.running && size != previous) {
|
||||
@@ -3181,6 +3187,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun outputFpsLimit(): Int = outputFpsLimit(pipUi)
|
||||
|
||||
// Android holds the window to the Game Mode override while the panel runs faster; the guest paces to the panel,
|
||||
// so without this cap every frame past the override is drawn and dropped.
|
||||
private fun hostFrameCap(): Int {
|
||||
if (glassesScreen != null || bottomOutputActive) return 0
|
||||
val display = (if (Build.VERSION.SDK_INT >= 30) display else @Suppress("DEPRECATION") windowManager.defaultDisplay) ?: return 0
|
||||
return SessionPrefs.hostFrameCap(display.refreshRate, display.mode.refreshRate)
|
||||
}
|
||||
|
||||
private fun compositorFpsLimit(): Int = SessionPrefs.compositorFpsLimit(
|
||||
mirrorRefreshLimit(), if (noSteamSession()) SessionState.fpsLimit else 0, pipUi, hostFrameCap(),
|
||||
)
|
||||
|
||||
private fun outputFpsLimit(pip: Boolean): Int =
|
||||
SessionPrefs.compositorFpsLimit(mirrorRefreshLimit(), if (noSteamSession()) SessionState.fpsLimit else 0, pip)
|
||||
|
||||
@@ -3218,7 +3236,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
)
|
||||
val hz = refreshHz()
|
||||
val changed = kotlin.math.abs(SessionState.refreshHz - hz) > 0.1f
|
||||
CompositorHost.updatePacing(hz, outputFpsLimit())
|
||||
CompositorHost.updatePacing(hz, compositorFpsLimit())
|
||||
pushCardboard(activeCardboard)
|
||||
if (changed && ::surfaceView.isInitialized) applyFrameGen()
|
||||
}
|
||||
@@ -3789,7 +3807,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||
// The bumpers walk the tabs on the strip; a page kept inside More counts as the More tab.
|
||||
val pages = sessionDrawerPages(glasses.present)
|
||||
val pages = sessionDrawerPages(achievementsInFront != null)
|
||||
drawerPage = pages.strip().step(pages.tabFor(drawerPage), if (event.keyCode == KeyEvent.KEYCODE_BUTTON_R1) 1 else -1)
|
||||
releaseDrawerDirection()
|
||||
}
|
||||
@@ -4945,6 +4963,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun refreshControls() {
|
||||
padConnected = controllerConnected()
|
||||
applyUnfoldedControls()
|
||||
updateOnScreenControls()
|
||||
}
|
||||
@@ -6385,6 +6404,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
(getSystemService(INPUT_SERVICE) as? InputManager)
|
||||
?.registerInputDeviceListener(deviceListener, Handler(Looper.getMainLooper()))
|
||||
padConnected = controllerConnected()
|
||||
padBridge?.setStickDeadZone(ControllerPrefs.deadZone(this))
|
||||
refreshSecondScreenDisplays()
|
||||
if (SessionState.guestPid > 1) padBridge?.syncConnectedControllers()
|
||||
|
||||
@@ -493,6 +493,17 @@ object SessionPrefs {
|
||||
prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun drawerSections(context: Context): Map<String, Boolean> =
|
||||
idList(prefs(context).getString("drawerSections", null)).mapNotNull { entry ->
|
||||
val at = entry.lastIndexOf('=').takeIf { it > 0 } ?: return@mapNotNull null
|
||||
entry.substring(0, at) to (entry.substring(at + 1) == "1")
|
||||
}.toMap()
|
||||
|
||||
fun setDrawerSections(context: Context, sections: Map<String, Boolean>) {
|
||||
prefs(context).edit().putString("drawerSections", sections.entries.filter { ',' !in it.key }
|
||||
.joinToString(",") { "${it.key}=${if (it.value) 1 else 0}" }).apply()
|
||||
}
|
||||
|
||||
fun setNavTabHidden(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
||||
}
|
||||
@@ -1807,16 +1818,15 @@ object SessionPrefs {
|
||||
|
||||
const val PIP_FPS = 30
|
||||
|
||||
fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false): Int {
|
||||
val limit = when {
|
||||
mirrorRefreshLimit <= 0 && sessionLimit <= 0 -> FPS_UNPACED
|
||||
mirrorRefreshLimit <= 0 -> sessionLimit
|
||||
sessionLimit <= 0 -> mirrorRefreshLimit
|
||||
else -> minOf(mirrorRefreshLimit, sessionLimit)
|
||||
}
|
||||
fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false, hostCap: Int = 0): Int {
|
||||
val limit = listOf(mirrorRefreshLimit, sessionLimit, hostCap).filter { it > 0 }.minOrNull() ?: FPS_UNPACED
|
||||
return if (pip && mirrorRefreshLimit <= 0 && (limit <= 0 || limit > PIP_FPS)) PIP_FPS else limit
|
||||
}
|
||||
|
||||
/** The per-app rate Android holds this window to (Game Mode's FPS override), or 0 when the panel's rate applies. */
|
||||
fun hostFrameCap(overrideHz: Float, panelHz: Float): Int =
|
||||
if (overrideHz > 1f && panelHz - overrideHz > 1f) Math.round(overrideHz) else 0
|
||||
|
||||
val upscalerChoices = listOf(
|
||||
2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
|
||||
8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only",
|
||||
|
||||
@@ -18,7 +18,7 @@ object SettingsReset {
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
||||
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ExpandMore
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.stateDescription
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/**
|
||||
* Inside the session menu every top-level settings group folds to its header and a summary of its values.
|
||||
* Groups start folded; a group the player opens or folds stays that way across sessions.
|
||||
*/
|
||||
internal object DrawerSectionState {
|
||||
private val chosen = mutableStateMapOf<String, Boolean>()
|
||||
|
||||
fun load(context: Context) {
|
||||
if (DevPreview.drawer != null) return
|
||||
chosen.clear()
|
||||
chosen.putAll(SessionPrefs.drawerSections(context))
|
||||
}
|
||||
|
||||
fun isOpen(key: String) = chosen[key] ?: false
|
||||
|
||||
fun toggle(context: Context, key: String) {
|
||||
chosen[key] = !isOpen(key)
|
||||
if (DevPreview.drawer == null) SessionPrefs.setDrawerSections(context, chosen.toMap())
|
||||
}
|
||||
}
|
||||
|
||||
internal class DrawerSections(val context: Context, val track: (String) -> Modifier)
|
||||
|
||||
internal val LocalDrawerSections = compositionLocalOf<DrawerSections?> { null }
|
||||
|
||||
@Composable
|
||||
internal fun DrawerSection(
|
||||
sections: DrawerSections, key: String, title: String, summary: String?, tag: String?,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val open = DrawerSectionState.isOpen(key)
|
||||
val source = remember { MutableInteractionSource() }
|
||||
val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value
|
||||
val rotation by animateFloatAsState(if (open) 180f else 0f, Motion.tw(180), label = "sectionArrow")
|
||||
val state = stringResource(if (open) R.string.widgets_expanded else R.string.widgets_collapsed)
|
||||
val toggle = { DrawerSectionState.toggle(sections.context, key) }
|
||||
val shape = RoundedCornerShape(14.dp)
|
||||
Column(
|
||||
Modifier.fillMaxWidth().padding(top = 6.dp).clip(shape)
|
||||
.background(colors.surface).border(1.dp, if (open) pal.line2 else pal.line, shape),
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxWidth().heightIn(min = 48.dp)
|
||||
.then(sections.track("section-$key"))
|
||||
.testTag("drawer-section-$key")
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.12f) else androidx.compose.ui.graphics.Color.Transparent)
|
||||
.glideBorder(hot, shape, pal.signal)
|
||||
.hoverable(source)
|
||||
.clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = toggle)
|
||||
.controllerConfirm(onClick = toggle)
|
||||
.semantics { contentDescription = title; stateDescription = state }
|
||||
.padding(start = 12.dp, end = 8.dp, top = 6.dp, bottom = 6.dp),
|
||||
) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text(title.uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp,
|
||||
color = if (open) colors.onBackground else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f, fill = false))
|
||||
if (tag != null) Text(
|
||||
tag, fontSize = 10.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1,
|
||||
modifier = Modifier.clip(RoundedCornerShape(6.dp)).background(pal.signal.copy(alpha = 0.14f))
|
||||
.padding(horizontal = 6.dp, vertical = 2.dp),
|
||||
)
|
||||
}
|
||||
if (!open && !summary.isNullOrEmpty()) Text(
|
||||
summary, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(top = 2.dp),
|
||||
)
|
||||
}
|
||||
Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = colors.onSurfaceVariant,
|
||||
modifier = Modifier.size(22.dp).rotate(rotation))
|
||||
}
|
||||
AnimatedVisibility(open, enter = expandVertically(Motion.tw(200)) + fadeIn(Motion.tw(160)),
|
||||
exit = shrinkVertically(Motion.tw(160)) + fadeOut(Motion.tw(120))) {
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line))
|
||||
// Only top-level groups fold; groups and dialogs opened from inside one draw normally.
|
||||
CompositionLocalProvider(LocalDrawerSections provides null) { content() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
fun on(key: String) = cfg[key] == "1"
|
||||
fun int(key: String, fallback: Int) = cfg[key]?.toIntOrNull() ?: fallback
|
||||
|
||||
SettingsGroup(stringResource(R.string.drawer_hud)) {
|
||||
SettingsGroup(stringResource(R.string.drawer_hud), key = "performance-hud",
|
||||
detail = stringResource(if (a.hudOn) R.string.widgets_on else R.string.widgets_off)) {
|
||||
ToggleRow(host, "hud", stringResource(R.string.drawer_hud), null, a.hudOn, chipModifier = track("hud"), onChange = a.onHud)
|
||||
if (a.hudOn) ToggleRow(
|
||||
host, "hud-only-during-game", stringResource(R.string.hud_only_during_game),
|
||||
@@ -62,7 +63,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
if (a.dashboardAvailable && a.secondScreenDisplays.isNotEmpty()) BottomStripSettings(host, track)
|
||||
if (!a.hudOn) return
|
||||
|
||||
SettingsGroup(stringResource(R.string.hud_group_look)) {
|
||||
SettingsGroup(stringResource(R.string.hud_group_look), key = "performance-hud-look") {
|
||||
SliderRow(stringResource(R.string.hud_scale), null, int("hudScale", 100), 50..150, step = 5, format = { "$it%" },
|
||||
modifier = track("hud-scale")) { a.onHudSetting("hudScale", it.toString()) }
|
||||
SliderRow(stringResource(R.string.drawer_hud_opacity), null, int("hudOpacity", 80), 0..100, step = 5, format = { "$it%" },
|
||||
@@ -85,7 +86,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
}
|
||||
|
||||
var editing by remember { mutableStateOf(false) }
|
||||
SettingsGroup(stringResource(R.string.hud_group_metrics)) {
|
||||
SettingsGroup(stringResource(R.string.hud_group_metrics), key = "performance-hud-metrics") {
|
||||
ActionRow(stringResource(R.string.hud_group_metrics), null, stringResource(R.string.common_edit),
|
||||
onClick = { editing = true }, modifier = track("hud-readings"))
|
||||
val rows = DroidDeckHudSize.rowsFor(DroidDeckHudSize.from(cfg["hudSize"]), cfg)
|
||||
@@ -103,7 +104,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
)
|
||||
}
|
||||
|
||||
if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps)) {
|
||||
if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps), key = "performance-hud-temps") {
|
||||
ChoiceRow(host, "hud-temp-unit", stringResource(R.string.hud_temp_unit), null,
|
||||
listOf("c" to "°C", "f" to "°F"), if (cfg["tempUnit"].equals("f", true)) "f" else "c",
|
||||
chipModifier = track("hud-temp-unit")) { a.onHudSetting("tempUnit", it) }
|
||||
@@ -129,7 +130,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
}
|
||||
}
|
||||
|
||||
SettingsGroup(stringResource(R.string.hud_group_more)) {
|
||||
SettingsGroup(stringResource(R.string.hud_group_more), key = "performance-hud-more") {
|
||||
ActionRow(stringResource(R.string.hud_export), stringResource(R.string.hud_export_hint),
|
||||
stringResource(R.string.hud_export_button), onClick = a.onHudExport, modifier = track("hud-export"))
|
||||
ActionRow(stringResource(R.string.hud_reset), null, stringResource(R.string.hud_reset_button),
|
||||
@@ -145,7 +146,7 @@ private fun BottomStripSettings(host: MenuHost, track: (String) -> Modifier) {
|
||||
var hudOn by remember { mutableStateOf(SessionPrefs.bottomHud(context)) }
|
||||
var onTabs by remember { mutableStateOf(SessionPrefs.bottomStripOnTabs(context)) }
|
||||
var shown by remember { mutableStateOf(SessionPrefs.bottomStripMetrics(context)) }
|
||||
SettingsGroup(stringResource(R.string.bottom_hud_group)) {
|
||||
SettingsGroup(stringResource(R.string.bottom_hud_group), key = "performance-bottom-hud") {
|
||||
ToggleRow(host, "bottom-hud", stringResource(R.string.bottom_hud_group), null, hudOn,
|
||||
chipModifier = track("bottom-hud")) { on ->
|
||||
hudOn = on
|
||||
|
||||
@@ -88,7 +88,7 @@ internal fun VrControllerGroups(host: MenuHost, track: (String) -> Modifier = {
|
||||
androidx.compose.runtime.LaunchedEffect(Unit) { com.droiddeck.launcher.input.VrControllers.load(context) }
|
||||
val c by com.droiddeck.launcher.input.VrControllers.settings.collectAsState()
|
||||
val emulate = com.droiddeck.launcher.input.VrControllers.Emulate.entries
|
||||
SettingsGroup(stringResource(R.string.vr_controllers_group)) {
|
||||
SettingsGroup(stringResource(R.string.vr_controllers_group), key = "vr-controllers") {
|
||||
ChoiceRow(host, "vr-emulate", stringResource(R.string.vr_controllers_emulate), stringResource(R.string.vr_controllers_emulate_hint),
|
||||
emulate.map { it to stringResource(when (it) {
|
||||
com.droiddeck.launcher.input.VrControllers.Emulate.OFF -> R.string.vr_controllers_off
|
||||
@@ -142,13 +142,13 @@ internal fun GlassesGroups(
|
||||
val directView = usesGlasses && picture == GlassesRendering.Picture.STEREO
|
||||
val menuScreen = !inSession && g.usable && s.gameOnGlasses && s.screen3dof
|
||||
if (g.canControl && onRecenter != null && s.headTracking && (virtualScreen || menuScreen || (directView && steamVrRunning))) {
|
||||
SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true) {
|
||||
SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true, key = "vr-glasses-quick") {
|
||||
ActionRow(stringResource(R.string.glasses_recenter),
|
||||
if (virtualScreen || menuScreen) stringResource(R.string.glasses_recenter_screen_hint) else null,
|
||||
stringResource(R.string.cardboard_recenter_button), onRecenter)
|
||||
}
|
||||
}
|
||||
if (display) SettingsGroup(g.model) {
|
||||
if (display) SettingsGroup(g.model, key = "vr-glasses") {
|
||||
if (g.experimental) SettingsRow(stringResource(R.string.glasses_control), stringResource(
|
||||
if (g.supportsDisplayModeControl) R.string.glasses_xreal_experimental else R.string.glasses_pro2_experimental)) {}
|
||||
val status = if (g.hasDisplay) stringResource(R.string.glasses_status, g.width, g.height, kotlin.math.round(g.hz).toInt(),
|
||||
@@ -170,7 +170,7 @@ internal fun GlassesGroups(
|
||||
s.gameOnGlasses, chipModifier = track("glasses-game")) { Glasses.setGameOnGlasses(it) }
|
||||
}
|
||||
if (display && g.canControl && g.supportsDisplayModeControl && (inSession || g.sbs || g.sbsSupport == GlassesState.SBS_FAILS)) {
|
||||
SettingsGroup(stringResource(R.string.glasses_display_mode)) {
|
||||
SettingsGroup(stringResource(R.string.glasses_display_mode), key = "vr-glasses-mode") {
|
||||
if (g.sbsSupport == GlassesState.SBS_FAILS && !g.sbs) {
|
||||
ActionRow(stringResource(R.string.glasses_3d), stringResource(R.string.glasses_3d_failed),
|
||||
stringResource(R.string.stores_dl_retry), { Glasses.set3d(true) })
|
||||
@@ -182,12 +182,12 @@ internal fun GlassesGroups(
|
||||
val profiles = if (inSession) listOf(GlassesDisplayModes.profile(g.sbs, false))
|
||||
else listOf(GlassesDisplayProfile.TWO_D, GlassesDisplayProfile.THREE_D)
|
||||
for (profile in profiles) SettingsGroup(stringResource(if (profile == GlassesDisplayProfile.TWO_D)
|
||||
R.string.glasses_output_2d else R.string.glasses_output_3d)) {
|
||||
R.string.glasses_output_2d else R.string.glasses_output_3d), key = "vr-glasses-output-${profile.name.lowercase()}") {
|
||||
GlassesResolutionRow(host, g, s, profile, track)
|
||||
if ((profile == GlassesDisplayProfile.THREE_D) == g.sbs) GlassesRefreshRow(host, g, s, track)
|
||||
}
|
||||
}
|
||||
if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group)) {
|
||||
if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group), key = "vr-glasses-picture") {
|
||||
ChoiceRow(host, "glasses-picture", stringResource(R.string.glasses_picture), stringResource(R.string.glasses_picture_hint),
|
||||
listOf(
|
||||
GlassesSettings.PICTURE_AUTO to stringResource(R.string.glasses_picture_auto),
|
||||
@@ -213,7 +213,7 @@ internal fun GlassesGroups(
|
||||
format = { SpatialMeasurements.distance(it / 10f) }, modifier = track("glasses-distance")) { Glasses.setScreenDistanceDm(it) }
|
||||
}
|
||||
}
|
||||
if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr)) {
|
||||
if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr), key = "vr-glasses-steamvr") {
|
||||
steamVr()
|
||||
if (g.supportsDisplayModeControl) ToggleRow(host, "glasses-auto3d", stringResource(R.string.glasses_auto3d),
|
||||
stringResource(R.string.glasses_auto3d_hint), s.auto3d, chipModifier = track("glasses-auto3d")) { Glasses.setAuto3d(it) }
|
||||
@@ -226,7 +226,7 @@ internal fun GlassesGroups(
|
||||
format = { "$it°" }, modifier = track("glasses-vr-fov")) { Glasses.setVrFovDeg(it) }
|
||||
}
|
||||
if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) {
|
||||
SettingsGroup(stringResource(R.string.glasses_head_tracking)) {
|
||||
SettingsGroup(stringResource(R.string.glasses_head_tracking), key = "vr-glasses-tracking") {
|
||||
val trackingHint = when {
|
||||
inSession && !usesGlasses -> R.string.glasses_screen_no_output
|
||||
spatialVr -> R.string.glasses_head_tracking_spatial_vr_hint
|
||||
@@ -240,13 +240,13 @@ internal fun GlassesGroups(
|
||||
chipModifier = track("glasses-tracking")) { Glasses.setHeadTracking(it) }
|
||||
}
|
||||
val calibration by Glasses.calibration.collectAsState()
|
||||
if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration)) {
|
||||
if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration), key = "vr-glasses-calibration") {
|
||||
GlassesCalibrationControls(calibration,
|
||||
onStart = Glasses::startCalibration, onCancel = Glasses::cancelCalibration,
|
||||
onReset = Glasses::resetCalibration, onDone = { onRecenter?.invoke() })
|
||||
}
|
||||
}
|
||||
if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware)) {
|
||||
if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware), key = "vr-glasses-hardware") {
|
||||
if (g.brightnessMax > 0) SliderRow(stringResource(R.string.glasses_brightness), null, g.brightness.coerceAtLeast(0), 0..g.brightnessMax, step = 1,
|
||||
modifier = track("glasses-brightness")) { Glasses.setBrightness(it) }
|
||||
if (g.volumeMax > 0) SliderRow(stringResource(R.string.glasses_volume), null, g.volume.coerceAtLeast(0), 0..g.volumeMax, step = 1,
|
||||
@@ -259,7 +259,7 @@ internal fun GlassesGroups(
|
||||
androidx.compose.runtime.LaunchedEffect(Unit) { HandTracking.load(context) }
|
||||
if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) {
|
||||
if (g.spatialConnected) {
|
||||
SettingsGroup(stringResource(R.string.glasses_experimental)) {
|
||||
SettingsGroup(stringResource(R.string.glasses_experimental), key = "vr-glasses-experimental") {
|
||||
val spatial by SpatialTracking.status.collectAsState()
|
||||
ToggleRow(host, "glasses-position", stringResource(R.string.glasses_position), stringResource(R.string.glasses_position_hint),
|
||||
s.positionalTracking, chipModifier = track("glasses-position")) { Glasses.setPositionalTracking(it) }
|
||||
@@ -282,7 +282,7 @@ internal fun GlassesGroups(
|
||||
s.joyConTracking, enabled = s.positionalTracking, chipModifier = track("glasses-joycons")) { Glasses.setJoyConTracking(it) }
|
||||
}
|
||||
}
|
||||
if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group)) {
|
||||
if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group), key = "vr-hand-camera") {
|
||||
HandCameraRows(host, track, inSession)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.hypot
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
@@ -63,6 +64,7 @@ class InputSurfaceView(
|
||||
private val art by lazy(LazyThreadSafetyMode.NONE) { PadArt(context) }
|
||||
private var artworkDpad = emptyList<HoldButton>()
|
||||
private val artworkDpadBounds = RectF()
|
||||
private var crossDpads = emptyList<Pair<List<HoldButton>, RectF>>()
|
||||
private var requestedLayout = customLayout
|
||||
init { customLayout = surfaceStyle.shown(customLayout); addView(content, LayoutParams(-1, -1)); renderCustom(pad) }
|
||||
|
||||
@@ -185,6 +187,7 @@ class InputSurfaceView(
|
||||
|
||||
private fun renderCustom(pad: PadBridge?) {
|
||||
artworkDpad = emptyList()
|
||||
crossDpads = emptyList()
|
||||
val canvas = object : ViewGroup(context) {
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
val layout = customLayout
|
||||
@@ -203,6 +206,7 @@ class InputSurfaceView(
|
||||
child.layout(x, y, x + child.measuredWidth, y + child.measuredHeight)
|
||||
}
|
||||
updateArtworkDpad(this)
|
||||
updateCrossDpad(this)
|
||||
}
|
||||
|
||||
override fun dispatchDraw(canvas: Canvas) {
|
||||
@@ -244,11 +248,39 @@ class InputSurfaceView(
|
||||
canvas.getChildAt(index) as? HoldButton
|
||||
}
|
||||
val previous = artworkDpad
|
||||
artworkDpad = if (crossed(buttons)) buttons else emptyList()
|
||||
artworkDpad = if (crossed(buttons, artworkDpadBounds)) buttons else emptyList()
|
||||
if (artworkDpad != previous) (previous + artworkDpad).forEach { it.invalidate() }
|
||||
}
|
||||
|
||||
private fun crossed(buttons: List<HoldButton>): Boolean {
|
||||
private fun updateCrossDpad(canvas: ViewGroup) {
|
||||
val buttons = (0 until canvas.childCount).map(canvas::getChildAt).filterIsInstance<HoldButton>()
|
||||
val (ups, rights, downs, lefts) = DIRECTIONS.map { direction -> buttons.filter { (it.tag as? InputSurfaceElement)?.control == direction } }
|
||||
crossDpads = ups.flatMap { up -> rights.flatMap { right -> downs.flatMap { down ->
|
||||
lefts.mapNotNull { left -> listOf(up, right, down, left).let { arms -> hole(arms)?.let { arms to it } } } } } }
|
||||
}
|
||||
|
||||
private fun hole(buttons: List<HoldButton>): RectF? {
|
||||
val (up, right, down, left) = buttons
|
||||
val hole = RectF(left.right.toFloat(), up.bottom.toFloat(), right.left.toFloat(), down.top.toFloat())
|
||||
val across = max(up.left, down.left) to min(up.right, down.right)
|
||||
val along = max(left.top, right.top) to min(left.bottom, right.bottom)
|
||||
return hole.takeIf {
|
||||
!it.isEmpty && across.first < across.second && along.first < along.second &&
|
||||
across.first < it.right && across.second > it.left && along.first < it.bottom && along.second > it.top
|
||||
}
|
||||
}
|
||||
|
||||
private fun crossTarget(x: Float, y: Float): HoldButton? {
|
||||
val first = crossDpads.firstOrNull()?.first?.first() ?: return null
|
||||
val hx = x - (originX(first) - first.left)
|
||||
val hy = y - (originY(first) - first.top)
|
||||
return crossDpads.filter { (arms, hole) -> arms.all { it.visibility == VISIBLE } && hole.contains(hx, hy) }
|
||||
.flatMap { it.first }.distinct().minByOrNull { arm ->
|
||||
hypot(max(max(arm.left - hx, hx - arm.right), 0f), max(max(arm.top - hy, hy - arm.bottom), 0f))
|
||||
}
|
||||
}
|
||||
|
||||
private fun crossed(buttons: List<HoldButton>, bounds: RectF): Boolean {
|
||||
if (buttons.size != DIRECTIONS.size) return false
|
||||
val (up, right, down, left) = buttons
|
||||
val centerX = (left.left + right.right) / 2f
|
||||
@@ -258,7 +290,7 @@ class InputSurfaceView(
|
||||
kotlin.math.abs((left.top + left.bottom) / 2f - centerY) > 2f ||
|
||||
kotlin.math.abs((right.top + right.bottom) / 2f - centerY) > 2f ||
|
||||
up.bottom >= down.top || left.right >= right.left) return false
|
||||
artworkDpadBounds.set(left.left.toFloat(), up.top.toFloat(), right.right.toFloat(), down.bottom.toFloat())
|
||||
bounds.set(left.left.toFloat(), up.top.toFloat(), right.right.toFloat(), down.bottom.toFloat())
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -284,6 +316,7 @@ class InputSurfaceView(
|
||||
val views = (canvas.childCount - 1 downTo 0).map(canvas::getChildAt).filter { it.visibility == VISIBLE }
|
||||
views.firstOrNull { !(it is StickView && it.adaptive) && hits(it, x, y, 0f) }?.let { return it }
|
||||
views.filter { it is HoldButton && hits(it, x, y, slack(it)) }.minByOrNull { distance(it, x, y) }?.let { return it }
|
||||
crossTarget(x, y)?.let { return it }
|
||||
if (views.any { it is HoldButton && hits(it, x, y, slack(it) + ADAPTIVE_CLEARANCE_PX) }) return null
|
||||
return views.filter { it is StickView && it.adaptive && it !in owners.values && (hits(it, x, y, 0f) || it.captures(x - originX(it), y - originY(it))) }
|
||||
.minByOrNull { distance(it, x, y) }
|
||||
|
||||
@@ -116,10 +116,7 @@ internal object NavTabs {
|
||||
|
||||
fun more(s: FrontEndState) = listed(s).filter { place(s, it) == TabPlace.MORE }
|
||||
|
||||
fun bar(s: FrontEndState): List<String> {
|
||||
val shown = listed(s).filter { place(s, it) == TabPlace.BAR }
|
||||
return if (more(s).isEmpty()) shown else shown + MORE
|
||||
}
|
||||
fun bar(s: FrontEndState): List<String> = listed(s).filter { place(s, it) == TabPlace.BAR } + MORE
|
||||
|
||||
fun setHidden(context: Context, key: String, hide: Boolean) {
|
||||
hidden = if (hide && hideable(key)) hidden + key else hidden - key
|
||||
|
||||
@@ -11,7 +11,7 @@ internal fun PenSettingsGroup(
|
||||
host: MenuHost, pen: SessionPrefs.Pen, track: (String) -> Modifier = { Modifier },
|
||||
onPick: (key: String, value: String) -> Unit,
|
||||
) {
|
||||
SettingsGroup(stringResource(R.string.mode_pen)) {
|
||||
SettingsGroup(stringResource(R.string.mode_pen), key = "controller-pen") {
|
||||
ChoiceRow(host, "pen", stringResource(R.string.mode_pen), null,
|
||||
listOf(SessionPrefs.PEN_MOUSE to stringResource(R.string.mode_pen_mouse),
|
||||
SessionPrefs.PEN_TOUCH to stringResource(R.string.mode_pen_touch)),
|
||||
|
||||
@@ -218,7 +218,7 @@ fun PerformancePage(
|
||||
|
||||
@Composable
|
||||
internal fun GpuClockGroup(host: MenuHost, on: Boolean, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) {
|
||||
SettingsGroup(stringResource(R.string.perf_gpu)) {
|
||||
SettingsGroup(stringResource(R.string.perf_gpu), key = "performance-gpu") {
|
||||
ToggleRow(
|
||||
host, "gpuclock", stringResource(R.string.perf_gpuclock),
|
||||
null,
|
||||
|
||||
@@ -6,17 +6,18 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/** HUD holds the Performance page and GAMES the Game page; the names stay because saved page orders use them. */
|
||||
internal enum class SessionDrawerPage(val firstControl: String) {
|
||||
CONTROLLER("input-profile"),
|
||||
GLASSES("glasses-game"),
|
||||
DISPLAY("fg"),
|
||||
HUD("hud"),
|
||||
EFFECTS("look"),
|
||||
GAMES("anisotropy"),
|
||||
AGENT("agent-input"),
|
||||
SESSION("suspend"),
|
||||
CONTROLLER("section-controller-input"),
|
||||
HUD("section-performance-pacing"),
|
||||
DISPLAY("section-display"),
|
||||
EFFECTS("section-effects-look"),
|
||||
GAMES("section-game-profile"),
|
||||
VR("section-vr-steamvr"),
|
||||
SESSION("pause"),
|
||||
MORE("more-edit"),
|
||||
VR("steamvr"),
|
||||
ACHIEVEMENTS("achievements"),
|
||||
AGENT("agent-input"),
|
||||
}
|
||||
|
||||
internal object DrawerPages {
|
||||
@@ -71,16 +72,16 @@ internal object DrawerPages {
|
||||
}
|
||||
|
||||
internal fun offeredDrawerPages(
|
||||
hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
): List<SessionDrawerPage> =
|
||||
DrawerPages.order.filter {
|
||||
(hasGlasses || it != SessionDrawerPage.GLASSES) &&
|
||||
(hasAchievements || it != SessionDrawerPage.ACHIEVEMENTS) &&
|
||||
(hasAgent || it != SessionDrawerPage.AGENT)
|
||||
}
|
||||
|
||||
internal fun sessionDrawerPages(
|
||||
hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
): List<SessionDrawerPage> = offeredDrawerPages(hasGlasses, hasAgent).filter { it !in DrawerPages.hidden }
|
||||
hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
): List<SessionDrawerPage> = offeredDrawerPages(hasAchievements, hasAgent).filter { it !in DrawerPages.hidden }
|
||||
|
||||
/** The pages shown as tabs: everything up to and including the More tab. */
|
||||
internal fun List<SessionDrawerPage>.strip(): List<SessionDrawerPage> {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -443,7 +443,11 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, content: @Composable ColumnScope.() -> Unit) {
|
||||
fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, key: String? = null, tag: String? = null, content: @Composable ColumnScope.() -> Unit) {
|
||||
LocalDrawerSections.current?.let { sections ->
|
||||
DrawerSection(sections, key ?: title, title, detail, tag, content)
|
||||
return
|
||||
}
|
||||
val tight = compact || LocalCompactSettings.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
|
||||
@@ -56,6 +56,7 @@ import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -358,6 +359,67 @@ internal fun SessionAchievementsPanel(label: String, state: AchievementsState, t
|
||||
}
|
||||
}
|
||||
|
||||
/** The Achievements page of the session menu: the same list as the full panel, inside the menu's own scroll. */
|
||||
@Composable
|
||||
internal fun DrawerAchievementsPage(game: StoreAchievements.Game, title: String?, track: (String) -> Modifier) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val label = StoreAchievements.forSource(game.source)?.label.orEmpty()
|
||||
val state = rememberAchievements(game) ?: AchievementsState.READING
|
||||
val kinds = remember(state.list) {
|
||||
val list = state.list.orEmpty()
|
||||
val split = groups(list)
|
||||
if (split.size < 2) emptyList() else listOf(R.string.stores_tab_all to list) + split
|
||||
}
|
||||
var pick by remember { mutableIntStateOf(0) }
|
||||
if (pick >= kinds.size) pick = 0
|
||||
var noteHadFocus by remember { mutableStateOf(false) }
|
||||
val firstRow = remember { FocusRequester() }
|
||||
val loaded = !state.list.isNullOrEmpty()
|
||||
LaunchedEffect(loaded) {
|
||||
if (loaded && noteHadFocus) {
|
||||
noteHadFocus = false
|
||||
withFrameNanos { }
|
||||
runCatching { firstRow.requestFocus() }
|
||||
}
|
||||
}
|
||||
Column(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp, end = 4.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
Text(title.orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
state.list?.takeIf { it.isNotEmpty() }?.let { list ->
|
||||
if (state.all) Trophy(18.dp, Modifier.padding(end = 6.dp))
|
||||
Text(stringResource(R.string.achievements_count_short, state.done, list.size), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = pal.signal)
|
||||
}
|
||||
}
|
||||
val list = state.list
|
||||
if (list.isNullOrEmpty()) {
|
||||
Text(achievementsNote(state, label).orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant,
|
||||
modifier = Modifier.padding(top = 12.dp).then(track("achievements"))
|
||||
.onFocusChanged { if (it.isFocused) noteHadFocus = true }.focusable())
|
||||
return@Column
|
||||
}
|
||||
LinearProgressIndicator(
|
||||
progress = { state.done / list.size.toFloat() }, color = pal.signal, trackColor = pal.line,
|
||||
modifier = Modifier.padding(top = 8.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)),
|
||||
)
|
||||
if (kinds.isNotEmpty()) TabStrip(
|
||||
kinds.map { (name, group) -> if (name == R.string.stores_tab_all) stringResource(name) + " · " + group.size else stringResource(name, group.size) },
|
||||
pick, { pick = it }, Modifier.padding(top = 10.dp), bumpers = false, compact = true,
|
||||
)
|
||||
val shown = kinds.getOrNull(pick)?.second ?: list
|
||||
val sections = if (pick == 0) groups(shown).filter { it.second.isNotEmpty() } else listOf(null to shown)
|
||||
val first = sections.firstOrNull()?.second?.firstOrNull()?.id
|
||||
Column(Modifier.padding(top = 6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
for ((group, items) in sections) {
|
||||
if (group != null) AchievementGroupLabel(stringResource(group, items.size))
|
||||
for (a in items) androidx.compose.runtime.key(a.id) {
|
||||
AchievementRow(a, compact = true, if (a.id == first) track("achievements").focusRequester(firstRow) else Modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DrawerAchievementsRow(progress: Pair<Int, Int>?, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
|
||||
@@ -707,7 +707,22 @@
|
||||
<string name="drawer_next_page">Next page</string>
|
||||
<string name="drawer_manage_pages">Arrange pages</string>
|
||||
<string name="drawer_page_more">More</string>
|
||||
<string name="drawer_more_back">Back to %1$s</string>
|
||||
<string name="drawer_page_performance">Performance</string>
|
||||
<string name="drawer_page_game">Game</string>
|
||||
<string name="drawer_page_vr">VR & glasses</string>
|
||||
<string name="drawer_section_pacing">Frame pacing</string>
|
||||
<string name="drawer_section_mouse">Mouse</string>
|
||||
<string name="drawer_section_keyboard_layout">Keyboard layout</string>
|
||||
<string name="drawer_section_input">Input profile</string>
|
||||
<string name="drawer_section_compat">Compatibility</string>
|
||||
<string name="drawer_section_tuning">Fine tuning</string>
|
||||
<string name="drawer_tag_controller">controller connected</string>
|
||||
<string name="drawer_tag_no_controller">no controller</string>
|
||||
<string name="drawer_tag_running">running</string>
|
||||
<string name="drawer_tag_custom">custom look</string>
|
||||
<string name="drawer_tag_attached">attached</string>
|
||||
<string name="drawer_tag_downloading">downloading</string>
|
||||
<string name="drawer_pause_game">Pause game</string> <string name="drawer_more_back">Back to %1$s</string>
|
||||
<string name="drawer_more_empty">Nothing is kept here. Arrange pages and move one below the More row.</string>
|
||||
<string name="drawer_pages_reset">Reset</string>
|
||||
<string name="drawer_pages_done">Done</string>
|
||||
|
||||
@@ -30,4 +30,16 @@ class OutputPacingTest {
|
||||
@Test fun mirroringKeepsTheGlassesRate() {
|
||||
assertEquals(60, SessionPrefs.compositorFpsLimit(60))
|
||||
}
|
||||
|
||||
@Test fun gameModeOverrideCapsAPanelThatRunsFaster() {
|
||||
assertEquals(60, SessionPrefs.hostFrameCap(60.000004f, 120.00001f))
|
||||
assertEquals(0, SessionPrefs.hostFrameCap(120.00001f, 120.00001f))
|
||||
assertEquals(0, SessionPrefs.hostFrameCap(0f, 120f))
|
||||
}
|
||||
|
||||
@Test fun hostCapPacesSteamSessionsAndYieldsToLowerLimits() {
|
||||
assertEquals(60, SessionPrefs.compositorFpsLimit(0, 0, hostCap = 60))
|
||||
assertEquals(45, SessionPrefs.compositorFpsLimit(0, 45, hostCap = 60))
|
||||
assertEquals(SessionPrefs.PIP_FPS, SessionPrefs.compositorFpsLimit(0, 0, pip = true, hostCap = 60))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
|
||||
/** Session menu groups start folded; a test opens the one whose rows it checks. */
|
||||
internal fun SemanticsNodeInteractionsProvider.openSection(key: String) {
|
||||
if (DrawerSectionState.isOpen(key)) return
|
||||
onNodeWithTag("drawer-section-$key").performScrollTo().performClick()
|
||||
}
|
||||
@@ -227,6 +227,81 @@ class InputSurfaceTouchTest {
|
||||
touch(MotionEvent.ACTION_UP, 1 to (750f to 285f))
|
||||
}
|
||||
|
||||
@Test fun theMiddleOfACrossedDpadPressesTheNearestArmInsteadOfFallingThrough() {
|
||||
val up = InputSurfaceElement(InputControl.UP, .45f, .1f, .1f, .15f)
|
||||
val down = InputSurfaceElement(InputControl.DOWN, .45f, .45f, .1f, .15f)
|
||||
show(up, down, InputSurfaceElement(InputControl.LEFT, .3f, .25f, .15f, .2f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .55f, .25f, .15f, .2f), a)
|
||||
val missed = mutableListOf<Int>()
|
||||
view.onTouchMiss = { missed += it.actionMasked }
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (500f to 170f))
|
||||
assertEquals(-1, state().hatY())
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (540f to 215f))
|
||||
assertEquals(1, state().hatX())
|
||||
assertEquals(0, state().hatY())
|
||||
touch(MotionEvent.ACTION_UP, 1 to (540f to 215f))
|
||||
assertEquals(0, state().hatX())
|
||||
assertTrue(missed.isEmpty())
|
||||
assertFalse(view.takesTouchAt(250f, 210f))
|
||||
assertFalse(view.takesTouchAt(800f, 500f))
|
||||
assertFalse(view.takesTouchAt(350f, 100f))
|
||||
show(up, down)
|
||||
assertFalse(view.takesTouchAt(500f, 210f))
|
||||
view.onTouchMiss = null
|
||||
}
|
||||
|
||||
@Test fun aHandPlacedDpadWithOffArmsStillTakesItsMiddle() {
|
||||
show(InputSurfaceElement(InputControl.UP, .42f, .1f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.DOWN, .42f, .45f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.LEFT, .3f, .27f, .15f, .15f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .5f, .25f, .15f, .2f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (475f to 225f))
|
||||
assertTrue(state().hatX() != 0 || state().hatY() != 0)
|
||||
touch(MotionEvent.ACTION_UP, 1 to (475f to 225f))
|
||||
assertFalse(view.takesTouchAt(750f, 225f))
|
||||
}
|
||||
|
||||
@Test fun aTallGapPicksTheNearestArmAndSplitArmsAreNoCross() {
|
||||
show(InputSurfaceElement(InputControl.UP, .45f, .1f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.DOWN, .45f, .65f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.LEFT, .3f, .35f, .15f, .2f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .55f, .35f, .15f, .2f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (530f to 290f))
|
||||
assertEquals(1, state().hatX())
|
||||
assertEquals(0, state().hatY())
|
||||
touch(MotionEvent.ACTION_UP, 1 to (530f to 290f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (530f to 180f))
|
||||
assertEquals(-1, state().hatY())
|
||||
assertEquals(0, state().hatX())
|
||||
touch(MotionEvent.ACTION_UP, 1 to (530f to 180f))
|
||||
show(InputSurfaceElement(InputControl.UP, .2f, .1f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.DOWN, .7f, .6f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.LEFT, .1f, .35f, .15f, .2f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .8f, .35f, .15f, .2f))
|
||||
assertFalse(view.takesTouchAt(500f, 300f))
|
||||
}
|
||||
|
||||
@Test fun aSecondUpButtonDoesNotHideTheCross() {
|
||||
show(InputSurfaceElement(InputControl.UP, .1f, .7f, .1f, .15f, "extra-up"),
|
||||
InputSurfaceElement(InputControl.UP, .45f, .1f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.DOWN, .45f, .45f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.LEFT, .3f, .25f, .15f, .2f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .55f, .25f, .15f, .2f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (500f to 170f))
|
||||
assertEquals(-1, state().hatY())
|
||||
touch(MotionEvent.ACTION_UP, 1 to (500f to 170f))
|
||||
assertEquals(0, state().hatY())
|
||||
show(InputSurfaceElement(InputControl.UP, .45f, 0f, .1f, .05f, "extra-up"),
|
||||
InputSurfaceElement(InputControl.UP, .45f, .1f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.DOWN, .45f, .45f, .1f, .15f),
|
||||
InputSurfaceElement(InputControl.LEFT, .3f, .25f, .15f, .2f),
|
||||
InputSurfaceElement(InputControl.RIGHT, .55f, .25f, .15f, .2f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (490f to 170f))
|
||||
assertEquals(-1, state().hatY())
|
||||
assertEquals(0, state().hatX())
|
||||
touch(MotionEvent.ACTION_UP, 1 to (490f to 170f))
|
||||
}
|
||||
|
||||
@Test fun adaptiveSticksCaptureAroundThemAndTheLeftOneToTheEdge() {
|
||||
val left = InputSurfaceElement(InputControl.LS, .3f, .3f, .2f, .4f, hideWhenIdle = true)
|
||||
val right = InputSurfaceElement(InputControl.RS, .6f, .3f, .2f, .4f, hideWhenIdle = true)
|
||||
|
||||
@@ -77,6 +77,17 @@ class NavTabsTest {
|
||||
assertFalse("desktop" in navigationKeys(s))
|
||||
}
|
||||
|
||||
@Test fun moreStaysOnTheBarWhenNoTabIsShelvedSoTabsCanStillBeEdited() {
|
||||
NavTabs.more(state()).forEach { place(it, TabPlace.HIDDEN) }
|
||||
assertTrue(NavTabs.more(state()).isEmpty())
|
||||
assertEquals(NavTabs.MORE, navigationKeys(state()).last())
|
||||
NavTabs.reset(ctx)
|
||||
NavTabs.more(state()).forEach { place(it, TabPlace.BAR) }
|
||||
assertTrue(NavTabs.more(state()).isEmpty())
|
||||
assertEquals(NavTabs.MORE, navigationKeys(state()).last())
|
||||
assertEquals(1, navigationKeys(state()).count { it == NavTabs.MORE })
|
||||
}
|
||||
|
||||
@Test fun appsAndTheDevHarnessCanBeShownWithoutHomeScreenOrDeveloperTools() {
|
||||
place("android-apps", TabPlace.MORE)
|
||||
assertTrue("android-apps" in NavTabs.more(state()))
|
||||
|
||||
@@ -31,7 +31,9 @@ class PenSettingsGroupTest {
|
||||
|
||||
@Test fun theDrawerHasNoPenGroupUntilAPenIsKnown() {
|
||||
compose.setContent { DroidDeckTheme { SessionDrawer(true, SessionDrawerPage.CONTROLLER, false, {}, actions(pen = null)) } }
|
||||
compose.openSection("controller-touch")
|
||||
compose.onNodeWithTag("setting-touch").assertExists()
|
||||
compose.onNodeWithTag("drawer-section-controller-pen").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-pen").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-pen-button").assertDoesNotExist()
|
||||
}
|
||||
@@ -43,6 +45,7 @@ class PenSettingsGroupTest {
|
||||
SessionDrawer(true, SessionDrawerPage.CONTROLLER, false, {}, actions(SessionPrefs.Pen()) { k, v -> picks += k to v })
|
||||
}
|
||||
}
|
||||
compose.openSection("controller-pen")
|
||||
compose.onNodeWithTag("setting-pen-button").performScrollTo().performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.gesture_middle_click)).performScrollTo().performClick()
|
||||
compose.onNodeWithTag("setting-pen").performScrollTo().performClick()
|
||||
|
||||
@@ -4,60 +4,51 @@ import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class SessionDrawerPageTest {
|
||||
@Test fun navigationStartsWithControllerAndGoesStraightToDisplay() {
|
||||
@Test fun navigationRunsControllerPerformanceDisplayEffectsGameVrSession() {
|
||||
val pages = sessionDrawerPages(hasAgent = false)
|
||||
assertEquals(SessionDrawerPage.CONTROLLER, pages.first())
|
||||
assertEquals(SessionDrawerPage.DISPLAY, pages.step(SessionDrawerPage.CONTROLLER, 1))
|
||||
assertEquals(SessionDrawerPage.VR, pages.step(SessionDrawerPage.CONTROLLER, -1))
|
||||
assertEquals(SessionDrawerPage.HUD, pages.step(SessionDrawerPage.DISPLAY, 1))
|
||||
assertEquals(SessionDrawerPage.EFFECTS, pages.step(SessionDrawerPage.HUD, 1))
|
||||
assertEquals(SessionDrawerPage.GAMES, pages.step(SessionDrawerPage.EFFECTS, 1))
|
||||
assertEquals(SessionDrawerPage.SESSION, pages.step(SessionDrawerPage.GAMES, 1))
|
||||
assertEquals(
|
||||
listOf(SessionDrawerPage.CONTROLLER, SessionDrawerPage.HUD, SessionDrawerPage.DISPLAY, SessionDrawerPage.EFFECTS,
|
||||
SessionDrawerPage.GAMES, SessionDrawerPage.VR, SessionDrawerPage.SESSION, SessionDrawerPage.MORE),
|
||||
pages.strip(),
|
||||
)
|
||||
assertEquals(SessionDrawerPage.MORE, pages.step(SessionDrawerPage.CONTROLLER, -1))
|
||||
}
|
||||
|
||||
@Test fun moreKeepsSteamVrByDefaultAndStandsInForThePagesInsideIt() {
|
||||
val pages = sessionDrawerPages(hasAgent = false)
|
||||
assertEquals(listOf(SessionDrawerPage.VR), pages.inMore())
|
||||
assertEquals(SessionDrawerPage.MORE, pages.strip().last())
|
||||
assertFalse(SessionDrawerPage.VR in pages.strip())
|
||||
assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.VR))
|
||||
@Test fun achievementsAndTheAgentStartInsideMore() {
|
||||
val pages = sessionDrawerPages(hasAchievements = true, hasAgent = true)
|
||||
assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.AGENT), pages.inMore())
|
||||
assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.ACHIEVEMENTS))
|
||||
assertEquals(SessionDrawerPage.GAMES, pages.tabFor(SessionDrawerPage.GAMES))
|
||||
val strip = pages.strip()
|
||||
assertEquals(SessionDrawerPage.MORE, strip.step(SessionDrawerPage.SESSION, 1))
|
||||
assertEquals(SessionDrawerPage.CONTROLLER, strip.step(SessionDrawerPage.MORE, 1))
|
||||
assertEquals(SessionDrawerPage.SESSION, strip.step(pages.tabFor(SessionDrawerPage.VR), -1))
|
||||
assertEquals(SessionDrawerPage.CONTROLLER, strip.step(pages.tabFor(SessionDrawerPage.AGENT), 1))
|
||||
}
|
||||
|
||||
@Test fun achievementsAreOfferedOnlyForAGameThatHasThem() {
|
||||
assertFalse(SessionDrawerPage.ACHIEVEMENTS in sessionDrawerPages(hasAchievements = false, hasAgent = false))
|
||||
assertFalse(SessionDrawerPage.AGENT in sessionDrawerPages(hasAgent = false))
|
||||
assertTrue(sessionDrawerPages(hasAgent = false).inMore().isEmpty())
|
||||
}
|
||||
|
||||
@Test fun anOlderSavedOrderKeepsItsPagesAndGetsAMoreTabAfterSession() {
|
||||
val saved = listOf("CONTROLLER", "DISPLAY", "HUD", "EFFECTS", "VR", "GAMES", "AGENT", "SESSION")
|
||||
val saved = listOf("CONTROLLER", "GLASSES", "DISPLAY", "HUD", "EFFECTS", "VR", "GAMES", "AGENT", "SESSION")
|
||||
val out = DrawerPages.arrange(saved)
|
||||
assertEquals(SessionDrawerPage.entries.toSet(), out.toSet())
|
||||
assertEquals(SessionDrawerPage.MORE, out[out.indexOf(SessionDrawerPage.SESSION) + 1])
|
||||
assertTrue(out.indexOf(SessionDrawerPage.VR) < out.indexOf(SessionDrawerPage.EFFECTS) + 2)
|
||||
assertTrue(out.inMore().isEmpty())
|
||||
assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS), out.inMore())
|
||||
assertTrue(SessionDrawerPage.AGENT in out.strip())
|
||||
}
|
||||
|
||||
@Test fun sessionCanBeKeptInsideMore() {
|
||||
val saved = listOf("CONTROLLER", "DISPLAY", "HUD", "EFFECTS", "GAMES", "AGENT", "MORE", "SESSION", "VR")
|
||||
val out = DrawerPages.arrange(saved)
|
||||
assertEquals(listOf(SessionDrawerPage.SESSION, SessionDrawerPage.VR), out.inMore())
|
||||
assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.SESSION, SessionDrawerPage.VR), out.inMore())
|
||||
assertFalse(SessionDrawerPage.SESSION in out.strip())
|
||||
}
|
||||
|
||||
@Test fun moreAndSessionCannotBeHidden() {
|
||||
assertFalse(DrawerPages.hideable(SessionDrawerPage.MORE))
|
||||
}
|
||||
|
||||
@Test fun glassesAddTheirPageAfterController() {
|
||||
val pages = sessionDrawerPages(hasGlasses = true, hasAgent = false)
|
||||
assertEquals(SessionDrawerPage.GLASSES, pages.step(SessionDrawerPage.CONTROLLER, 1))
|
||||
assertEquals(sessionDrawerPages(hasAgent = false), pages.filter { it != SessionDrawerPage.GLASSES })
|
||||
}
|
||||
|
||||
@Test fun theAgentPageComesBeforeSessionOnlyWhenTheTabIsShown() {
|
||||
val with = sessionDrawerPages(hasAgent = true)
|
||||
assertEquals(SessionDrawerPage.AGENT, with.step(SessionDrawerPage.GAMES, 1))
|
||||
assertEquals(SessionDrawerPage.SESSION, with.step(SessionDrawerPage.AGENT, 1))
|
||||
assertFalse(SessionDrawerPage.AGENT in sessionDrawerPages(hasAgent = false))
|
||||
assertFalse(DrawerPages.hideable(SessionDrawerPage.SESSION))
|
||||
assertTrue(DrawerPages.hideable(SessionDrawerPage.HUD))
|
||||
}
|
||||
|
||||
@Test fun arrangeKeepsSavedOrderAndSlotsNewPagesAfterTheirNeighbour() {
|
||||
@@ -67,9 +58,4 @@ class SessionDrawerPageTest {
|
||||
assertEquals(listOf(SessionDrawerPage.SESSION, SessionDrawerPage.HUD), out.filter { it in setOf(SessionDrawerPage.SESSION, SessionDrawerPage.HUD) })
|
||||
assertTrue(out.indexOf(SessionDrawerPage.HUD) < out.indexOf(SessionDrawerPage.CONTROLLER))
|
||||
}
|
||||
|
||||
@Test fun sessionPageCannotBeHidden() {
|
||||
assertFalse(DrawerPages.hideable(SessionDrawerPage.SESSION))
|
||||
assertTrue(DrawerPages.hideable(SessionDrawerPage.HUD))
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,8 @@ class SessionSecondScreenTest {
|
||||
actions(true, listOf(SecondScreenDisplay(1, "Bottom screen"), SecondScreenDisplay(2, "Monitor")), gameSwap = true))
|
||||
}
|
||||
}
|
||||
compose.onNodeWithText(context.getString(R.string.swap_game_screen)).assertDoesNotExist()
|
||||
compose.openSection("display-second")
|
||||
compose.onNodeWithText(context.getString(R.string.swap_game_screen)).performScrollTo().assertIsDisplayed()
|
||||
compose.onNodeWithText("Bottom screen").performScrollTo().assertIsDisplayed()
|
||||
}
|
||||
@@ -265,7 +267,7 @@ class SessionSecondScreenTest {
|
||||
state<Boolean>("drawerOpenState").value = true
|
||||
state<Boolean>("drawerControllerActive").value = true
|
||||
state<List<SecondScreenDisplay>>("secondScreenDisplays").value = listOf(SecondScreenDisplay(1, "Bottom screen"))
|
||||
for ((button, page) in listOf(KeyEvent.KEYCODE_BUTTON_R1 to SessionDrawerPage.DISPLAY,
|
||||
for ((button, page) in listOf(KeyEvent.KEYCODE_BUTTON_R1 to SessionDrawerPage.HUD,
|
||||
KeyEvent.KEYCODE_BUTTON_L1 to SessionDrawerPage.CONTROLLER)) {
|
||||
assertTrue(activity.dispatchKeyEvent(KeyEvent(0L, 0L, KeyEvent.ACTION_DOWN, button, 0, 0,
|
||||
device.id, 0, 0, InputDevice.SOURCE_GAMEPAD)))
|
||||
@@ -309,6 +311,7 @@ class SessionSecondScreenTest {
|
||||
actions(true, emptyList(), micAvailable = true, micEnabled = true, onMic = changes::add))
|
||||
}
|
||||
}
|
||||
compose.openSection("session-behavior")
|
||||
compose.onNodeWithTag("setting-microphone").assertIsEnabled()
|
||||
.assert(SemanticsMatcher.expectValue(StateDescription, context.getString(R.string.widgets_on))).performClick()
|
||||
assertEquals(listOf(false), changes)
|
||||
@@ -322,6 +325,7 @@ class SessionSecondScreenTest {
|
||||
actions(true, emptyList(), micAvailable = true, onMic = changes::add))
|
||||
}
|
||||
}
|
||||
compose.openSection("session-behavior")
|
||||
compose.onNodeWithTag("setting-microphone").assertIsEnabled()
|
||||
.assert(SemanticsMatcher.expectValue(StateDescription, context.getString(R.string.widgets_off))).performClick()
|
||||
assertEquals(listOf(true), changes)
|
||||
@@ -333,6 +337,7 @@ class SessionSecondScreenTest {
|
||||
SessionDrawer(true, SessionDrawerPage.SESSION, false, {}, actions(false, emptyList()))
|
||||
}
|
||||
}
|
||||
compose.openSection("session-behavior")
|
||||
compose.onNodeWithTag("setting-microphone").assertDoesNotExist()
|
||||
compose.onNodeWithText(context.getString(R.string.mode_mic)).assertDoesNotExist()
|
||||
}
|
||||
@@ -354,6 +359,7 @@ class SessionSecondScreenTest {
|
||||
onInputSelection = { panel.refreshControls() }, onClose = { open.value = false }))
|
||||
}
|
||||
}
|
||||
compose.openSection("controller-input")
|
||||
compose.onNodeWithTag("setting-input-profile").performScrollTo().performClick()
|
||||
compose.onNodeWithText("Desktop").performScrollTo().performClick()
|
||||
compose.onNodeWithTag("input-profile-expand").performScrollTo().performClick()
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Exports the build metadata Gradle bakes into BuildConfig and prints the label for DROIDDECK_BUILD_LABEL.
|
||||
set -euo pipefail
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
tree_state=dirty
|
||||
else
|
||||
tree_state=clean
|
||||
fi
|
||||
echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV"
|
||||
if [[ -n "${PR_NUMBER:-}" ]]; then
|
||||
label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}"
|
||||
else
|
||||
label="${BUILD_REF} at ${BUILD_SHA:0:7}"
|
||||
fi
|
||||
echo "label=$label" >> "$GITHUB_OUTPUT"
|
||||
echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV"
|
||||
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -10,13 +10,18 @@ flowchart LR
|
||||
Source[Pin source tree] --> Components[Prepare verified components]
|
||||
Source --> Xbox[Xbox ARM64 backend]
|
||||
Source --> Tests[Python and native tests]
|
||||
Components --> APK[Compile APK and Android tests]
|
||||
Components --> APK[Compile APK]
|
||||
Xbox --> APK
|
||||
APK --> Gate[Compile and test APK gate]
|
||||
Tests --> Gate
|
||||
Gate --> Publish[Main only: signing and publishing]
|
||||
```
|
||||
|
||||
Kotlin unit tests run in the separate `Unit tests` workflow (`unit-tests.yml`), so a
|
||||
PR test build is published as soon as the APK compiles. Build validation folds both
|
||||
workflows into the `Build APK` commit status, and Release APKs requires both for the
|
||||
released commit.
|
||||
|
||||
All workers verify the same source tree. The component artifact records that tree,
|
||||
recipe identities and every output hash; the APK worker verifies the inventory
|
||||
before building. This handoff verifies consistency within the same CI run. It is
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#define _GNU_SOURCE
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "named_semaphores.h"
|
||||
#endif
|
||||
@@ -1,127 +0,0 @@
|
||||
static int posix_shm_path(const char *name, const char *prefix, char *path, size_t size) {
|
||||
if (!name) { errno = EINVAL; return -1; }
|
||||
while (*name == '/') name++;
|
||||
size_t len = strlen(name) + strlen(prefix);
|
||||
if (len == strlen(prefix) || len > NAME_MAX || strchr(name, '/') || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||
errno = len > NAME_MAX ? ENAMETOOLONG : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (snprintf(path, size, "/dev/shm/%s%s", prefix, name) >= (int)size) { errno = ENAMETOOLONG; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct posix_sem {
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
sem_t *addr;
|
||||
unsigned int refs;
|
||||
struct posix_sem *next;
|
||||
};
|
||||
static struct posix_sem *g_posix_sems;
|
||||
static pthread_mutex_t g_posix_sems_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void posix_sems_unlock(void) { pthread_mutex_unlock(&g_posix_sems_lock); }
|
||||
|
||||
static void posix_sems_hold(void) { pthread_mutex_lock(&g_posix_sems_lock); }
|
||||
|
||||
__attribute__((constructor)) static void posix_sems_across_fork(void) {
|
||||
pthread_atfork(posix_sems_hold, posix_sems_unlock, posix_sems_unlock);
|
||||
}
|
||||
|
||||
static void close_keeping_errno(int fd) {
|
||||
int saved = errno;
|
||||
close(fd);
|
||||
errno = saved;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_map(int fd) {
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0) return SEM_FAILED;
|
||||
sem_t *sem = SEM_FAILED;
|
||||
posix_sems_hold();
|
||||
struct posix_sem *e = g_posix_sems;
|
||||
while (e && (e->dev != st.st_dev || e->ino != st.st_ino)) e = e->next;
|
||||
if (e) {
|
||||
e->refs++;
|
||||
sem = e->addr;
|
||||
} else {
|
||||
void *addr = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
e = addr == MAP_FAILED ? NULL : malloc(sizeof(*e));
|
||||
if (e) {
|
||||
*e = (struct posix_sem){st.st_dev, st.st_ino, addr, 1, g_posix_sems};
|
||||
g_posix_sems = e;
|
||||
sem = addr;
|
||||
} else if (addr != MAP_FAILED) {
|
||||
munmap(addr, sizeof(sem_t));
|
||||
errno = ENOMEM;
|
||||
}
|
||||
}
|
||||
posix_sems_unlock();
|
||||
return sem;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_open_fd(int fd) {
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
sem_t *sem = posix_sem_map(fd);
|
||||
close_keeping_errno(fd);
|
||||
return sem;
|
||||
}
|
||||
|
||||
sem_t *sem_open(const char *name, int oflag, ...) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return SEM_FAILED;
|
||||
if (!(oflag & O_CREAT)) return posix_sem_open_fd(open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC));
|
||||
va_list args;
|
||||
va_start(args, oflag);
|
||||
mode_t mode = va_arg(args, mode_t);
|
||||
unsigned int value = va_arg(args, unsigned int);
|
||||
va_end(args);
|
||||
static unsigned int serial;
|
||||
for (;;) {
|
||||
if (!(oflag & O_EXCL)) {
|
||||
int fd = open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC);
|
||||
if (fd >= 0 || errno != ENOENT) return posix_sem_open_fd(fd);
|
||||
}
|
||||
if (value > SEM_VALUE_MAX) { errno = EINVAL; return SEM_FAILED; }
|
||||
sem_t initial;
|
||||
memset(&initial, 0, sizeof(initial));
|
||||
sem_init(&initial, 1, value);
|
||||
char temp[PATH_MAX];
|
||||
int fd;
|
||||
do {
|
||||
snprintf(temp, sizeof(temp), "/dev/shm/.sem-%d-%u", (int)getpid(), __atomic_fetch_add(&serial, 1, __ATOMIC_RELAXED));
|
||||
fd = open(temp, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, mode);
|
||||
} while (fd < 0 && errno == EEXIST);
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
errno = EIO;
|
||||
sem_t *sem = write(fd, &initial, sizeof(initial)) == (ssize_t)sizeof(initial) ? posix_sem_map(fd) : SEM_FAILED;
|
||||
close_keeping_errno(fd);
|
||||
if (sem != SEM_FAILED && renameat2(AT_FDCWD, temp, AT_FDCWD, path, RENAME_NOREPLACE) == 0) return sem;
|
||||
int saved = errno;
|
||||
if (sem != SEM_FAILED) sem_close(sem);
|
||||
unlink(temp);
|
||||
errno = saved;
|
||||
if (errno != EEXIST || (oflag & O_EXCL)) return SEM_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int sem_close(sem_t *sem) {
|
||||
posix_sems_hold();
|
||||
struct posix_sem **link = &g_posix_sems;
|
||||
while (*link && (*link)->addr != sem) link = &(*link)->next;
|
||||
struct posix_sem *e = *link;
|
||||
if (e && --e->refs == 0) {
|
||||
*link = e->next;
|
||||
munmap(e->addr, sizeof(sem_t));
|
||||
free(e);
|
||||
}
|
||||
posix_sems_unlock();
|
||||
if (!e) { errno = EINVAL; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_unlink(const char *name) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return -1;
|
||||
return unlink(path);
|
||||
}
|
||||
@@ -6,7 +6,17 @@
|
||||
|
||||
#ifndef DDNATV_HOST_TEST
|
||||
|
||||
#include "../../linuxfs/preload/named_semaphores.h"
|
||||
static int posix_shm_path(const char *name, const char *prefix, char *path, size_t size) {
|
||||
if (!name) { errno = EINVAL; return -1; }
|
||||
while (*name == '/') name++;
|
||||
size_t len = strlen(name) + strlen(prefix);
|
||||
if (len == strlen(prefix) || len > NAME_MAX || strchr(name, '/') || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||
errno = len > NAME_MAX ? ENAMETOOLONG : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (snprintf(path, size, "/dev/shm/%s%s", prefix, name) >= (int)size) { errno = ENAMETOOLONG; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shm_open(const char *name, int oflag, mode_t mode) {
|
||||
char path[PATH_MAX];
|
||||
@@ -20,6 +30,121 @@ int shm_unlink(const char *name) {
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
struct posix_sem {
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
sem_t *addr;
|
||||
unsigned int refs;
|
||||
struct posix_sem *next;
|
||||
};
|
||||
static struct posix_sem *g_posix_sems;
|
||||
static pthread_mutex_t g_posix_sems_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void posix_sems_unlock(void) { pthread_mutex_unlock(&g_posix_sems_lock); }
|
||||
|
||||
static void posix_sems_hold(void) { pthread_mutex_lock(&g_posix_sems_lock); }
|
||||
|
||||
__attribute__((constructor)) static void posix_sems_across_fork(void) {
|
||||
pthread_atfork(posix_sems_hold, posix_sems_unlock, posix_sems_unlock);
|
||||
}
|
||||
|
||||
static void close_keeping_errno(int fd) {
|
||||
int saved = errno;
|
||||
close(fd);
|
||||
errno = saved;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_map(int fd) {
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0) return SEM_FAILED;
|
||||
sem_t *sem = SEM_FAILED;
|
||||
posix_sems_hold();
|
||||
struct posix_sem *e = g_posix_sems;
|
||||
while (e && (e->dev != st.st_dev || e->ino != st.st_ino)) e = e->next;
|
||||
if (e) {
|
||||
e->refs++;
|
||||
sem = e->addr;
|
||||
} else {
|
||||
void *addr = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
e = addr == MAP_FAILED ? NULL : malloc(sizeof(*e));
|
||||
if (e) {
|
||||
*e = (struct posix_sem){st.st_dev, st.st_ino, addr, 1, g_posix_sems};
|
||||
g_posix_sems = e;
|
||||
sem = addr;
|
||||
} else if (addr != MAP_FAILED) {
|
||||
munmap(addr, sizeof(sem_t));
|
||||
errno = ENOMEM;
|
||||
}
|
||||
}
|
||||
posix_sems_unlock();
|
||||
return sem;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_open_fd(int fd) {
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
sem_t *sem = posix_sem_map(fd);
|
||||
close_keeping_errno(fd);
|
||||
return sem;
|
||||
}
|
||||
|
||||
sem_t *sem_open(const char *name, int oflag, ...) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return SEM_FAILED;
|
||||
if (!(oflag & O_CREAT)) return posix_sem_open_fd(open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC));
|
||||
va_list args;
|
||||
va_start(args, oflag);
|
||||
mode_t mode = va_arg(args, mode_t);
|
||||
unsigned int value = va_arg(args, unsigned int);
|
||||
va_end(args);
|
||||
static unsigned int serial;
|
||||
for (;;) {
|
||||
if (!(oflag & O_EXCL)) {
|
||||
int fd = open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC);
|
||||
if (fd >= 0 || errno != ENOENT) return posix_sem_open_fd(fd);
|
||||
}
|
||||
if (value > SEM_VALUE_MAX) { errno = EINVAL; return SEM_FAILED; }
|
||||
sem_t initial;
|
||||
memset(&initial, 0, sizeof(initial));
|
||||
sem_init(&initial, 1, value);
|
||||
char temp[PATH_MAX];
|
||||
int fd;
|
||||
do {
|
||||
snprintf(temp, sizeof(temp), "/dev/shm/.sem-%d-%u", (int)getpid(), __atomic_fetch_add(&serial, 1, __ATOMIC_RELAXED));
|
||||
fd = open(temp, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, mode);
|
||||
} while (fd < 0 && errno == EEXIST);
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
errno = EIO;
|
||||
sem_t *sem = write(fd, &initial, sizeof(initial)) == (ssize_t)sizeof(initial) ? posix_sem_map(fd) : SEM_FAILED;
|
||||
close_keeping_errno(fd);
|
||||
if (sem != SEM_FAILED && renameat2(AT_FDCWD, temp, AT_FDCWD, path, RENAME_NOREPLACE) == 0) return sem;
|
||||
int saved = errno;
|
||||
if (sem != SEM_FAILED) sem_close(sem);
|
||||
unlink(temp);
|
||||
errno = saved;
|
||||
if (errno != EEXIST || (oflag & O_EXCL)) return SEM_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int sem_close(sem_t *sem) {
|
||||
posix_sems_hold();
|
||||
struct posix_sem **link = &g_posix_sems;
|
||||
while (*link && (*link)->addr != sem) link = &(*link)->next;
|
||||
struct posix_sem *e = *link;
|
||||
if (e && --e->refs == 0) {
|
||||
*link = e->next;
|
||||
munmap(e->addr, sizeof(sem_t));
|
||||
free(e);
|
||||
}
|
||||
posix_sems_unlock();
|
||||
if (!e) { errno = EINVAL; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_unlink(const char *name) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return -1;
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
#endif /* !DDNATV_HOST_TEST */
|
||||
|
||||
|
||||
@@ -7,37 +7,21 @@ MARK="<!-- droiddeck-pr-build -->"
|
||||
echo
|
||||
[ -f /tmp/pr-merge.md ] && cat /tmp/pr-merge.md
|
||||
echo
|
||||
case "$BUILD_OUTCOME:$UNIT_TEST_OUTCOME:$APK_OUTCOME" in
|
||||
success:success:success)
|
||||
case "$BUILD_OUTCOME:$APK_OUTCOME" in
|
||||
success:success)
|
||||
echo "### Build passed"
|
||||
echo
|
||||
echo "The \`droiddeck-apk\` artifact is [on this run]($RUN_URL), signed with the public test key."
|
||||
echo "The \`droiddeck-apk\` artifact is [on this run]($RUN_URL), signed with the public test key. Unit tests run in the separate **Unit tests** workflow and must pass before merging."
|
||||
echo
|
||||
echo "Same-repository PRs and PRs opened by contributors listed in \`.github/trusted-test-builds.txt\` are eligible for automatic release-signed test builds after the full build passes. Label the PR \`no-test-build\` to skip that."
|
||||
echo "Same-repository PRs and PRs opened by contributors listed in \`.github/trusted-test-builds.txt\` are eligible for automatic release-signed test builds once the APK compiles. Label the PR \`no-test-build\` to skip that."
|
||||
echo "For other PRs, a maintainer can add the \`publish-test\` label to request a signed build."
|
||||
echo
|
||||
echo "Fallback: [open **PR Release Publish**]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/workflows/pr-release-publish.yml) on \`main\` and enter PR \`$PR\`."
|
||||
;;
|
||||
success:success:*)
|
||||
success:*)
|
||||
echo "### APK publication incomplete"
|
||||
echo
|
||||
echo "Compilation and unit tests passed, but APK publication did not complete. See [the run]($RUN_URL)."
|
||||
;;
|
||||
success:failure:*)
|
||||
echo "### ERROR: Unit tests failed"
|
||||
echo
|
||||
echo "The APK compiled, but unit tests failed. No installable artifact was published."
|
||||
echo
|
||||
if [ -n "$TEST_DIAGNOSTICS_URL" ]; then
|
||||
echo "The [unit-test-results]($TEST_DIAGNOSTICS_URL) artifact contains the test log and any generated reports."
|
||||
else
|
||||
echo "The test diagnostics upload did not complete. See [the test log]($RUN_URL)."
|
||||
fi
|
||||
;;
|
||||
success:*)
|
||||
echo "### Build incomplete"
|
||||
echo
|
||||
echo "The APK compiled, but unit tests did not complete successfully. See [the run]($RUN_URL)."
|
||||
echo "Compilation passed, but APK publication did not complete. See [the run]($RUN_URL)."
|
||||
;;
|
||||
failure:*)
|
||||
echo "### ERROR: Build failed"
|
||||
|
||||
@@ -40,6 +40,31 @@ def compilation_state(run, jobs):
|
||||
return "failure" if run["status"] == "completed" else "pending"
|
||||
|
||||
|
||||
def run_state(run):
|
||||
if run["status"] != "completed":
|
||||
return "pending"
|
||||
return "success" if run["conclusion"] == "success" else "failure"
|
||||
|
||||
|
||||
def latest_run(repo, workflow, sha, source_event):
|
||||
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
|
||||
runs = api(f"repos/{repo}/actions/workflows/{workflow}/runs?{query}")["workflow_runs"]
|
||||
runs = [item for item in runs if item["head_sha"] == sha]
|
||||
return max(runs, key=lambda item: item["id"]) if runs else None
|
||||
|
||||
|
||||
def combined_state(build, tests):
|
||||
if build == "failure":
|
||||
return "failure", "APK compilation failed"
|
||||
if tests == "failure":
|
||||
return "failure", "Unit tests failed"
|
||||
if build == "pending":
|
||||
return "pending", "Source validated; awaiting APK compilation"
|
||||
if tests == "pending":
|
||||
return "pending", "APK compiled; awaiting unit tests"
|
||||
return "success", "Source validation, APK compilation and unit tests passed"
|
||||
|
||||
|
||||
def fetch_source(ref, sha):
|
||||
subprocess.run(["git", "fetch", "--no-tags", "origin", ref], check=True)
|
||||
fetched = subprocess.check_output(["git", "rev-parse", "FETCH_HEAD"], text=True).strip()
|
||||
@@ -123,19 +148,18 @@ def main():
|
||||
state = "success"
|
||||
description = "Source validated; no APK source changes"
|
||||
return
|
||||
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
|
||||
runs = api(f"repos/{repo}/actions/workflows/build.yml/runs?{query}")["workflow_runs"]
|
||||
runs = [item for item in runs if item["head_sha"] == sha]
|
||||
if runs:
|
||||
latest = max(runs, key=lambda item: item["id"])
|
||||
build_state = tests_state = "pending"
|
||||
latest = latest_run(repo, "build.yml", sha, source_event)
|
||||
if latest:
|
||||
jobs = api(f"repos/{repo}/actions/runs/{latest['id']}/jobs?per_page=100")["jobs"]
|
||||
state = compilation_state(latest, jobs)
|
||||
build_state = compilation_state(latest, jobs)
|
||||
target = latest["html_url"]
|
||||
else:
|
||||
state = "pending"
|
||||
description = {"pending": "Source validated; awaiting APK compilation",
|
||||
"success": "Source validation and APK compilation passed",
|
||||
"failure": "APK compilation failed"}[state]
|
||||
tests = latest_run(repo, "unit-tests.yml", sha, source_event)
|
||||
if tests:
|
||||
tests_state = run_state(tests)
|
||||
if tests_state == "failure" and build_state != "failure":
|
||||
target = tests["html_url"]
|
||||
state, description = combined_state(build_state, tests_state)
|
||||
finally:
|
||||
api(f"repos/{repo}/statuses/{sha}", "--method", "POST",
|
||||
"-f", "context=Build APK", "-f", f"state={state}",
|
||||
|
||||
@@ -25,7 +25,7 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertIn("gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit])", gradle)
|
||||
|
||||
def test_robolectric_cache_saves_and_restores_the_same_absolute_path(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
caches = [step['with'] for step in steps if step.get('uses', '').startswith('actions/cache')]
|
||||
for cache in caches:
|
||||
for path in cache['path'].split('\n'):
|
||||
@@ -34,7 +34,7 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2)
|
||||
|
||||
def test_unit_test_retry_requires_maven_exception(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
run = next(step['run'] for step in steps if step.get('id') == 'unit-tests')
|
||||
line = next(line for line in run.splitlines() if 'grep -Eq' in line)
|
||||
pattern = shlex.split(line)[shlex.split(line).index('-Eq') + 1]
|
||||
@@ -59,15 +59,31 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertEqual(result.strip(), '2')
|
||||
|
||||
def test_build_and_tests_use_identical_generated_metadata(self):
|
||||
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
||||
steps = {step.get('id'): step for step in jobs['build']['steps']}
|
||||
self.assertEqual(steps['build']['env'], steps['unit-tests']['env'])
|
||||
self.assertIn('DROIDDECK_BUILD_LABEL', steps['unit-tests']['env'])
|
||||
self.assertIn('SGDB_API_KEY', steps['unit-tests']['env'])
|
||||
build = {step.get('id'): step for step in
|
||||
yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']}
|
||||
tests = {step.get('id'): step for step in
|
||||
yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']}
|
||||
self.assertEqual(build['build']['env'], tests['unit-tests']['env'])
|
||||
self.assertIn('DROIDDECK_BUILD_LABEL', tests['unit-tests']['env'])
|
||||
self.assertIn('SGDB_API_KEY', tests['unit-tests']['env'])
|
||||
self.assertEqual(build['build-label'], tests['build-label'])
|
||||
gradle = (ROOT / 'app/build.gradle').read_text()
|
||||
self.assertIn("outputs.doNotCacheIf('CI executes the test suite on every run') { true }", gradle)
|
||||
self.assertIn('outputs.upToDateWhen { false }', gradle)
|
||||
|
||||
def test_unit_tests_do_not_hold_up_the_apk(self):
|
||||
build = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())
|
||||
for step in build['jobs']['build']['steps']:
|
||||
self.assertNotIn('UnitTest', step.get('run', ''))
|
||||
tests = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())
|
||||
for event in ('push', 'pull_request'):
|
||||
self.assertEqual(tests[True][event], build[True][event])
|
||||
authorship = yaml.safe_load((ROOT / '.github/workflows/authorship.yml').read_text())
|
||||
self.assertEqual(set(authorship[True]['workflow_run']['workflows']), {build['name'], tests['name']})
|
||||
self.assertIn('unit-tests.yml', (ROOT / '.github/workflows/release.yml').read_text())
|
||||
run = next(step['run'] for step in tests['jobs']['unit-tests']['steps'] if step.get('id') == 'unit-tests')
|
||||
self.assertIn('-PunitTestsOnly=true', run)
|
||||
|
||||
def test_independent_jobs_wait_only_for_the_pinned_source(self):
|
||||
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
||||
for name in ('xbox', 'python-tests', 'components-runner'):
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_native_hook_named_semaphores import CALLS, KEEP, PROBE
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||
|
||||
DENY_LINKS = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <linux/filter.h>
|
||||
#include <linux/seccomp.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct sock_filter filter[] = {
|
||||
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)),
|
||||
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SYS_link, 1, 0),
|
||||
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SYS_linkat, 0, 1),
|
||||
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ERRNO | EPERM),
|
||||
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
|
||||
};
|
||||
struct sock_fprog prog = {sizeof(filter) / sizeof(filter[0]), filter};
|
||||
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) return 125;
|
||||
execvp(argv[1], argv + 1);
|
||||
return 126;
|
||||
}
|
||||
"""
|
||||
|
||||
OPEN_EXISTING = r"""
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv) {
|
||||
sem_t *sem = sem_open(argv[1], 0);
|
||||
int value;
|
||||
if (sem == SEM_FAILED || sem_getvalue(sem, &value) || value != atoi(argv[2])) return 1;
|
||||
return sem_trywait(sem) || sem_close(sem);
|
||||
}
|
||||
"""
|
||||
|
||||
PYTHON_PROBE = '''
|
||||
import multiprocessing as mp
|
||||
import _multiprocessing
|
||||
import os
|
||||
import sys
|
||||
|
||||
def square(n):
|
||||
return n * n
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = "/dd-py-sem-" + str(os.getpid())
|
||||
sem = _multiprocessing.SemLock(1, 1, 1, name, True)
|
||||
assert sem.acquire(False)
|
||||
assert not sem.acquire(False)
|
||||
sem.release()
|
||||
for method in mp.get_all_start_methods():
|
||||
ctx = mp.get_context(method)
|
||||
lock = ctx.Lock()
|
||||
with lock:
|
||||
assert not lock.acquire(False)
|
||||
queue = ctx.Queue()
|
||||
queue.put(7)
|
||||
assert queue.get(timeout=10) == 7
|
||||
queue.close()
|
||||
queue.join_thread()
|
||||
with ctx.Pool(2) as pool:
|
||||
assert pool.map(square, [1, 2, 3]) == [1, 4, 9]
|
||||
print(method, flush=True)
|
||||
'''
|
||||
|
||||
|
||||
@unittest.skipUnless(platform.machine() == "x86_64" and shutil.which("cc"), "needs an x86-64 compiler and host")
|
||||
class NamedSemaphoresPreloadTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
cls.root = Path(cls.tmp.name)
|
||||
cls.lib = cls.root / "semaphores.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-Werror", "-pthread", "-o", str(cls.lib),
|
||||
str(PRELOAD / "named_semaphores.c")], check=True)
|
||||
for name, source in (("deny", DENY_LINKS), ("probe", PROBE), ("keep", KEEP), ("existing", OPEN_EXISTING)):
|
||||
path = cls.root / (name + ".c")
|
||||
path.write_text(source)
|
||||
subprocess.run(["cc", "-pthread", "-o", str(cls.root / name), str(path)], check=True)
|
||||
cls.script = cls.root / "pool.py"
|
||||
cls.script.write_text(PYTHON_PROBE)
|
||||
|
||||
def run_program(self, args, hooked=True, denied=True):
|
||||
env = dict(os.environ)
|
||||
env.pop("LD_PRELOAD", None)
|
||||
if hooked:
|
||||
env["LD_PRELOAD"] = str(self.lib)
|
||||
command = ([str(self.root / "deny")] if denied else []) + list(map(str, args))
|
||||
return subprocess.run(command, env=env, text=True, capture_output=True, timeout=60)
|
||||
|
||||
def test_glibc_semlock_fails_when_hard_links_are_denied(self):
|
||||
result = self.run_program([sys.executable, "-c",
|
||||
"import multiprocessing; multiprocessing.Lock()"], hooked=False)
|
||||
self.assertNotEqual(0, result.returncode)
|
||||
self.assertIn("PermissionError: [Errno 1]", result.stderr)
|
||||
|
||||
def test_named_semaphore_contract_with_and_without_hard_links(self):
|
||||
for denied in (True, False):
|
||||
with self.subTest(denied=denied):
|
||||
result = self.run_program([self.root / "probe", f"/dd-preload-{os.getpid()}-{int(denied)}"], denied=denied)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertEqual({call: "1" for call in CALLS}, dict(line.split("\t") for line in result.stdout.splitlines()))
|
||||
|
||||
def test_semaphores_remain_compatible_with_glibc_and_keep_the_requested_mode(self):
|
||||
for hooked in (True, False):
|
||||
with self.subTest(creator_hooked=hooked):
|
||||
name = f"/dd-preload-existing-{os.getpid()}-{int(hooked)}"
|
||||
path = Path("/dev/shm/sem." + name[1:])
|
||||
self.addCleanup(path.unlink, missing_ok=True)
|
||||
result = self.run_program([self.root / "keep", name], hooked=hooked, denied=hooked)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
umask = os.umask(0)
|
||||
os.umask(umask)
|
||||
self.assertEqual(0o640 & ~umask, path.stat().st_mode & 0o777)
|
||||
for reader, value in ((not hooked, 3), (hooked, 2)):
|
||||
result = self.run_program([self.root / "existing", name, value], hooked=reader, denied=reader)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
|
||||
def test_python_semlock_queues_and_explicit_pool_contexts(self):
|
||||
for denied in (True, False):
|
||||
with self.subTest(denied=denied):
|
||||
result = self.run_program([sys.executable, self.script], denied=denied)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertEqual({"fork", "forkserver", "spawn"}, set(result.stdout.splitlines()))
|
||||
@@ -28,7 +28,7 @@ class ValidateApkTest(unittest.TestCase):
|
||||
def git(self, *args):
|
||||
return subprocess.check_output(["git", "-C", self.root, *args], text=True).strip()
|
||||
|
||||
def validate(self, message="Source change", body="", result="success", stale=False, completed=False, filename="source.kt", permission="write", role_name="write", fork=False):
|
||||
def validate(self, message="Source change", body="", result="success", stale=False, completed=False, filename="source.kt", permission="write", role_name="write", fork=False, tests="success"):
|
||||
(self.root / filename).parent.mkdir(parents=True, exist_ok=True)
|
||||
(self.root / filename).write_text(message)
|
||||
self.git("add", filename)
|
||||
@@ -57,6 +57,12 @@ class ValidateApkTest(unittest.TestCase):
|
||||
return [pr]
|
||||
if "workflows/build.yml/runs?" in path:
|
||||
return {"workflow_runs": [{"id": 7, "head_sha": sha, "status": "completed", "html_url": "https://example.org/build"}]}
|
||||
if "workflows/unit-tests.yml/runs?" in path:
|
||||
if tests is None:
|
||||
return {"workflow_runs": []}
|
||||
return {"workflow_runs": [{"id": 9, "head_sha": sha, "html_url": "https://example.org/tests",
|
||||
"status": "in_progress" if tests == "pending" else "completed",
|
||||
"conclusion": None if tests == "pending" else tests}]}
|
||||
if path.endswith("/jobs?per_page=100"):
|
||||
return {"jobs": [{"name": "Compile and test APK", "status": "in_progress" if result == "pending" else "completed", "conclusion": result}]}
|
||||
raise AssertionError(path)
|
||||
@@ -85,6 +91,18 @@ class ValidateApkTest(unittest.TestCase):
|
||||
self.validate(result=result)
|
||||
self.assertEqual(self.statuses[-1]["state"], result)
|
||||
|
||||
def test_unit_tests_must_pass_too(self):
|
||||
for tests, state in (("pending", "pending"), (None, "pending"), ("failure", "failure"), ("cancelled", "failure")):
|
||||
with self.subTest(tests=tests):
|
||||
self.validate(tests=tests)
|
||||
self.assertEqual(self.statuses[-1]["state"], state)
|
||||
self.assertEqual(self.statuses[-1]["target_url"], "https://example.org/tests")
|
||||
|
||||
def test_a_compile_failure_is_reported_before_test_results(self):
|
||||
self.validate(result="failure", tests="failure")
|
||||
self.assertEqual(self.statuses[-1]["description"], "APK compilation failed")
|
||||
self.assertEqual(self.statuses[-1]["target_url"], "https://example.org/build")
|
||||
|
||||
def test_superseded_event_cannot_replace_current_status(self):
|
||||
self.validate(stale=True)
|
||||
self.assertEqual(self.statuses, [])
|
||||
|
||||
Reference in new issue
Block a user