Android: a RuStore build, without the app's own updates and the counted check
The owner puts the app in RuStore: the store updates it, and the store's build must neither update itself nor be counted by the site. A build type «rustore» on the same branch (not a branch to catch up each time): the release with SELF_UPDATE off — no check of releases (the check is what the site counts installations by), no download or install, no updates block in About, a release kept from the site's build forgotten; its manifest drops the install permissions and the installer's receiver. The full build only; the same package and key, so it goes over the site's one and back with the databases. release.sh builds it into dist-rustore and checks it asks for no install permission; the release workflow keeps it as the run's «rustore» artifact, not a file of the release. The site's builds are as they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f31023dcd7
commit
dd4572fd8a
9 changed files with 73 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
11
androidApp/app/src/rustore/AndroidManifest.xml
Normal file
11
androidApp/app/src/rustore/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- The RuStore build (build.gradle.kts, buildType "rustore"): the store installs and
|
||||
updates the app, so it neither installs packages nor receives the installer's answer. -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove" />
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" tools:node="remove" />
|
||||
<application>
|
||||
<receiver android:name=".data.InstallResult" tools:node="remove" />
|
||||
</application>
|
||||
</manifest>
|
||||
Loading…
Add table
Add a link
Reference in a new issue