diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b62f336..b2bc9ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,6 +169,11 @@ jobs: with: name: android path: androidApp/dist/*.apk + # The RuStore build: uploaded to the store by hand, not a file of the release. + - uses: actions/upload-artifact@v7 + with: + name: rustore + path: androidApp/dist-rustore/*.apk publish: needs: [version, linux, flatpak, windows, macos, android] @@ -180,6 +185,9 @@ jobs: with: path: dist merge-multiple: true + # The RuStore build stays an artifact of the run (merge-multiple brought it here). + - name: Not the store's build + run: rm -f dist/*-rustore.apk - name: Stockfish source (GPL-3.0 source offer for the engine bundled in the Flatpak and Android) run: packaging/stockfish.sh source dist - name: Checksums diff --git a/androidApp/.gitignore b/androidApp/.gitignore index f4bbe68..5772074 100644 --- a/androidApp/.gitignore +++ b/androidApp/.gitignore @@ -14,4 +14,5 @@ .cxx local.properties /dist +/dist-rustore .env diff --git a/androidApp/app/build.gradle.kts b/androidApp/app/build.gradle.kts index 55d5d9e..81b9fde 100644 --- a/androidApp/app/build.gradle.kts +++ b/androidApp/app/build.gradle.kts @@ -147,6 +147,9 @@ android { buildConfigField("String", "NET_NAME", "\"nn-1a298aa575a0.nnue\"") buildConfigField("String", "NET_SHA256", "\"1a298aa575a085434d29027978dc36867fe9c5bcea9376654b7a8eba1e52dfc2\"") buildConfigField("long", "NET_SIZE", "98511183L") + // The app checks for its releases and installs them itself (android-ui.md §25); + // the check is what the site counts installations by. Off for stores. + buildConfigField("boolean", "SELF_UPDATE", "true") buildConfigField( "String", "NET_URL", @@ -182,6 +185,14 @@ android { proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") signingConfig = signingConfigs.findByName("release") } + // RuStore (docs/decisions.md «RuStore»): the release, signed with the same key, + // without the app's own updates and the check the site counts installations by; + // the store updates it. Its manifest (src/rustore) drops the install permissions. + create("rustore") { + initWith(getByName("release")) + buildConfigField("boolean", "SELF_UPDATE", "false") + matchingFallbacks += listOf("release") + } } // The languages of the interface; the libraries' other translations stay out. androidResources { @@ -229,6 +240,11 @@ tasks.named("preBuild") { dependsOn(uniffiBindings, bundleAssets, stockfish, rodent4) } +// RuStore gets the full build only (Stockfish inside: nothing to fetch from GitHub). +androidComponents { + beforeVariants(selector().withBuildType("rustore").withFlavor("engine" to "light")) { it.enable = false } +} + dependencies { val composeBom = platform(libs.androidx.compose.bom) implementation(composeBom) diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/AppUpdates.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/AppUpdates.kt index 3e6e0dd..c3e0ef7 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/AppUpdates.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/data/AppUpdates.kt @@ -186,8 +186,9 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope } val update = known() when { - // Installed by hand from the site, or never newer than this app. - update == null || !newer(update.version) -> forgetAll() + // Installed by hand from the site, or never newer than this app; or a store's + // build put over the site's (the store updates it, a release kept is dropped). + !BuildConfig.SELF_UPDATE || update == null || !newer(update.version) -> forgetAll() prefs.getLong(DOWNLOAD, -1L) != -1L -> watch(update, prefs.getLong(DOWNLOAD, -1L)) update.sha256.isEmpty() -> _state.value = UpdateState.Failed(update, UpdateProblem.BadRelease, null) prefs.getString(READY, null) == update.version && apk(update).exists() -> _state.value = UpdateState.Ready(update, aborted = false) @@ -205,7 +206,7 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope /// of the app, as the desktop does (a release out since the last check is offered at /// once), and on return 6 h after the last answer (1 h after a failed try). fun checkIfDue() { - if (!_auto.value || busy()) return + if (!BuildConfig.SELF_UPDATE || !_auto.value || busy()) return val now = System.currentTimeMillis() if (askedThisRun && (now - _lastCheck.value < RECHECK || now - prefs.getLong(LAST_ATTEMPT, 0L) < HOUR)) return askedThisRun = true @@ -214,11 +215,13 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope /// «Check now» (works with the automatic check off). fun checkNow() { - if (_check.value == CheckState.Checking) return + if (!BuildConfig.SELF_UPDATE || _check.value == CheckState.Checking) return scope.launch { runCheck(manual = true) } } private suspend fun runCheck(manual: Boolean) { + // A store's build never asks the site (nor counts itself there). + if (!BuildConfig.SELF_UPDATE) return if (busy()) { if (manual) _check.value = CheckState.Idle return diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/AboutScreen.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/AboutScreen.kt index 8e5c50f..0b73632 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/AboutScreen.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/ui/AboutScreen.kt @@ -86,9 +86,12 @@ fun AboutScreen(onBack: () -> Unit) { val build = stringResource(if (BuildConfig.NET_BUILT_IN) R.string.build_full else R.string.build_light) Text("${BuildConfig.VERSION_NAME} ${stringResource(R.string.alpha)} · $build", color = MaterialTheme.colorScheme.onSurfaceVariant) Spacer(Modifier.height(24.dp)) - // Right under the version (android-ui.md §25.5). - AboutUpdates() - Spacer(Modifier.height(24.dp)) + // Right under the version (android-ui.md §25.5); a store's build is updated by + // the store. + if (BuildConfig.SELF_UPDATE) { + AboutUpdates() + Spacer(Modifier.height(24.dp)) + } Text(stringResource(R.string.about_text), style = MaterialTheme.typography.bodyLarge) TextButton(onClick = { uri.openUri(SITE) }, contentPadding = androidx.compose.foundation.layout.PaddingValues(0.dp)) { Text(stringResource(R.string.website)) diff --git a/androidApp/app/src/rustore/AndroidManifest.xml b/androidApp/app/src/rustore/AndroidManifest.xml new file mode 100644 index 0000000..ecf6e33 --- /dev/null +++ b/androidApp/app/src/rustore/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/androidApp/scripts/release.sh b/androidApp/scripts/release.sh index a2fd540..30badc5 100755 --- a/androidApp/scripts/release.sh +++ b/androidApp/scripts/release.sh @@ -2,6 +2,9 @@ # Builds the two signed release APKs into androidApp/dist: # ChessPenguin--android.apk Stockfish built in ("full") # ChessPenguin--android-noengine.apk Stockfish downloaded in the app ("light") +# and, apart (not a file of the release), into androidApp/dist-rustore: +# ChessPenguin--rustore.apk the full one for RuStore: no updates of its +# own, no check the site counts # The key comes from the environment or from ~/.config/chesspenguin/android/.env. set -euo pipefail cd "$(dirname "$0")/.." @@ -13,15 +16,22 @@ if [[ -z "${CP_KEYSTORE:-}" && -f "${env_file}" ]]; then set +a fi : "${CP_KEYSTORE:?no release key: set CP_KEYSTORE and the passwords, or CP_SIGNING_ENV}" -./gradlew --console=plain assembleFullRelease assembleLightRelease +./gradlew --console=plain assembleFullRelease assembleLightRelease assembleFullRustore version="$(sed -n 's/^version = "\(.*\)"/\1/p' ../Cargo.toml | head -n1)" mkdir -p dist cp app/build/outputs/apk/full/release/app-full-release.apk "dist/ChessPenguin-${version}-android.apk" cp app/build/outputs/apk/light/release/app-light-release.apk "dist/ChessPenguin-${version}-android-noengine.apk" +mkdir -p dist-rustore +cp app/build/outputs/apk/full/rustore/app-full-rustore.apk "dist-rustore/ChessPenguin-${version}-rustore.apk" build_tools="$(ls -d "${ANDROID_HOME:-$HOME/Android/Sdk}"/build-tools/* | sort -V | tail -n1)" -for apk in dist/ChessPenguin-"${version}"-android*.apk; do +for apk in dist/ChessPenguin-"${version}"-android*.apk dist-rustore/ChessPenguin-"${version}"-rustore.apk; do "${build_tools}/apksigner" verify "${apk}" "${build_tools}/zipalign" -c -P 16 4 "${apk}" done (cd dist && sha256sum ChessPenguin-"${version}"-android*.apk > ChessPenguin-"${version}"-android.sha256) -ls -l dist +# The store's build asks for nothing it would not need. +if "${build_tools}/aapt2" dump permissions "dist-rustore/ChessPenguin-${version}-rustore.apk" | grep -q 'INSTALL_PACKAGES'; then + echo "the RuStore build may install packages" >&2 + exit 1 +fi +ls -l dist dist-rustore diff --git a/docs/decisions.md b/docs/decisions.md index 26df3f0..0c7a3e5 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -157,3 +157,12 @@ ## Ход назад — только в блице (2026-10-27) Владелец: «для всех контролей игры с движком кроме блицов убрал кнопку отменить ход»; уточнено: кнопка «↶ Ход назад» (и Ctrl+Z) есть только в блице (3+0, 3+2, 5+0, 5+3); в рапиде, классике и игре без часов её нет (скрыта, не серая). Только компьютер; телефон не меняется. + +## Сборка для RuStore (2026-10-27) + +Владелец: приложение выкладывается в RuStore; в сборке для магазина не должно быть самообновления и учёта установок, а сборка для сайта остаётся как есть. Решено: +- **Не отдельная ветка**, а тип сборки `rustore` в той же основной ветке (`androidApp/app/build.gradle.kts`): копия `release` с флагом `SELF_UPDATE = false`. Ветку пришлось бы каждый раз догонять до основной; тип сборки всегда собирается из свежего кода. Сборки для сайта (`assembleFullRelease`, `assembleLightRelease`) не меняются. +- В сборке RuStore приложение **не проверяет выпуски и не обращается к сайту** (эта проверка и есть учёт установок: `/api/update` с id установки), не скачивает и не ставит обновления; в «О программе» нет блока обновлений; сохранённое ранее найденное обновление (если её поставили поверх сайтовой) забывается. Манифест `src/rustore/AndroidManifest.xml` убирает `REQUEST_INSTALL_PACKAGES`, `UPDATE_PACKAGES_WITHOUT_USER_ACTION` и приёмник ответа установщика. Обновляет приложение магазин. +- **Только полная сборка** (Stockfish внутри): лёгкая для `rustore` отключена. +- **Тот же пакет и тот же ключ**, что у сайта: одно и то же приложение, ставится поверх с сохранением баз и настроек в обе стороны. +- **Собирается на GitHub при каждом выпуске** (`androidApp/scripts/release.sh` → `androidApp/dist-rustore/ChessPenguin-<версия>-rustore.apk`): артефакт `rustore` прогона «Release», **не файл выпуска** — на сайте и в списке скачиваний его нет; в RuStore загружается вручную. Скрипт проверяет, что разрешения на установку в нём нет. diff --git a/docs/design/android-ui.md b/docs/design/android-ui.md index b328930..a5a744b 100644 --- a/docs/design/android-ui.md +++ b/docs/design/android-ui.md @@ -1844,6 +1844,8 @@ ## 25. Обновление приложения (2026-10-23) +> Сборка для RuStore (`decisions.md` «Сборка для RuStore», 2026-10-27) — без всего этого раздела: проверки, карточки, листа, блока в «О программе» и разрешений на установку; обновляет магазин. + Приложение ставится не из магазина, а файлом APK с сайта или со страницы выпуска на GitHub. Чтобы человек не ходил за новой версией сам, приложение узнаёт о ней, скачивает лёгкую сборку, проверяет и передаёт Android на установку. Базы, настройки и движок при этом остаются. Проверка — запрос к сайту, который отвечает сведениями о последнем выпуске и заодно считает установки (§25.6), и сверка с `SHA256SUMS.txt`, как на компьютере (`apps/desktop/src/update.rs`). Слова тоже взяты с компьютера, где они там есть. Решения: