This commit is contained in:
1 parent
c89c6a7e53
commit
72c5f75939
6 files changed
+77
-70
No files matched your search
@@ -1,18 +0,0 @@
|
|||||||
# fileapi forge CI (https://fileapi.fastapicloud.dev/forge/nandi.uk/launcher).
|
|
||||||
# This repo is where the launcher is built and released: each push to main here builds the
|
|
||||||
# Qt APK on Depot and publishes it as a release, which the phone's updater reads
|
|
||||||
# (releases/latest/assets/version.json). Needs DEPOT_TOKEN and DEPOT_PROJECT_ID (user secrets).
|
|
||||||
|
|
||||||
[[job]]
|
|
||||||
name = "apk"
|
|
||||||
branches = ["main"]
|
|
||||||
timeout = 3600
|
|
||||||
image = "eclipse-temurin:17-jdk-noble"
|
|
||||||
run = "bash ci/forge-apk.sh"
|
|
||||||
|
|
||||||
[[job]]
|
|
||||||
name = "wasm-apk"
|
|
||||||
branches = ["main"]
|
|
||||||
timeout = 3600
|
|
||||||
image = "eclipse-temurin:17-jdk-noble"
|
|
||||||
run = "bash ci/forge-wasm-apk.sh"
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: Launcher
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
apk:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
container: eclipse-temurin:17-jdk-noble
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Test, build and release the Qt APK
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
|
run: bash ci/gitea-apk.sh
|
||||||
@@ -4,7 +4,7 @@ An Android home screen written as an [ultra](https://github.com/nandi-conda/ultr
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Get the APK from the [`launcher-latest` release](https://github.com/codegod100/launcher/releases/tag/launcher-latest), which CI rebuilds on every push to `main`. Open it once, press Home, and pick **ultra Home** as the default. Builds are signed with the committed `android/app/debug.keystore`, so each one installs over the last.
|
Get the APK from the [latest release](https://git.site.latha.org/experiments/launcher/releases/latest) on the Gitea forge, which CI rebuilds on every push to `main`. Open it once, press Home, and pick **ultra Home** as the default. Builds are signed with the committed `android/app/debug.keystore`, so each one installs over the last.
|
||||||
|
|
||||||
The **Windows** button uses an accessibility service (`RecentsService`, which only performs the Recents action). Enable it once under Settings → Accessibility; on Android 13+ a sideloaded APK may first need App info → ⋮ → Allow restricted settings.
|
The **Windows** button uses an accessibility service (`RecentsService`, which only performs the Recents action). Enable it once under Settings → Accessibility; on Android 13+ a sideloaded APK may first need App info → ⋮ → Allow restricted settings.
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ Every push to ultra's main publishes a new `ultra` package. To pick it up, run `
|
|||||||
|
|
||||||
## Qt rewrite (in progress)
|
## Qt rewrite (in progress)
|
||||||
|
|
||||||
`qt/` is the launcher rewritten as a Qt Quick (QML) app for Android, replacing ultra and the WebView. `qt/qml` is the UI (`Main.qml`, with the grid packing in `Layout.js`), `qt/src` a thin C++ backend, and `qt/android` the Java side (`HomeActivity`, a `QtActivity` that lists apps, draws icons, launches, and hosts the native widget views over the QML slots). It uses the same package (`dev.ultra.launcher`) and key as the WebView build, so it installs over it, from the releases on the fileapi forge ([nandi.uk/launcher](https://fileapi.fastapicloud.dev/forge/nandi.uk/launcher)), where `.forge/jobs.toml` builds and publishes an APK on every push to main (`ci/forge-apk.sh`).
|
`qt/` is the launcher rewritten as a Qt Quick (QML) app for Android, replacing ultra and the WebView. `qt/qml` is the UI (`Main.qml`, with the grid packing in `Layout.js`), `qt/src` a thin C++ backend, and `qt/android` the Java side (`HomeActivity`, a `QtActivity` that lists apps, draws icons, launches, and hosts the native widget views over the QML slots). It uses the same package (`dev.ultra.launcher`) and key as the WebView build, so it installs over it, from the releases on the Gitea forge ([experiments/launcher](https://git.site.latha.org/experiments/launcher)), where `.gitea/workflows/launcher.yml` tests, builds and publishes an APK on every push to main (`ci/gitea-apk.sh`); the installed app updates itself from the latest release there.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
node qt/tests/layout.test.mjs # grid packing
|
node qt/tests/layout.test.mjs # grid packing
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Builds the WASI launcher component (wasi/) and the wasmtime runtime APK (android-wasm/).
|
|
||||||
set -euo pipefail
|
|
||||||
cd /src
|
|
||||||
|
|
||||||
export PIXI_HOME=/opt/pixi
|
|
||||||
curl -fsSL https://pixi.sh/install.sh | bash
|
|
||||||
export PATH="$PIXI_HOME/bin:$PATH"
|
|
||||||
|
|
||||||
pixi run --manifest-path wasi/pixi.toml build
|
|
||||||
mkdir -p android-wasm/assets
|
|
||||||
cp wasi/build/launcher.wasm android-wasm/assets/launcher.wasm
|
|
||||||
|
|
||||||
curl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --target aarch64-linux-android
|
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
cargo install cargo-apk --version 0.10.0 --locked
|
|
||||||
|
|
||||||
bash android-wasm/build.sh
|
|
||||||
cp android-wasm/target/release/apk/ultra-launcher-wasm.apk ultra-launcher-wasm.apk
|
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Builds the Qt launcher APK (qt/) and publishes it as a forge release: build-<versionCode>,
|
# Tests the Qt launcher (qt/), builds its APK and publishes it as a Gitea release:
|
||||||
# holding ultra-launcher.apk and version.json, made a draft first and published once both
|
# build-<versionCode>, holding ultra-launcher.apk and version.json, made a draft first
|
||||||
# files are up, so releases/latest never lacks them. Runs in .forge/jobs.toml's "apk" job.
|
# and published once both files are up, so the latest release never lacks them.
|
||||||
|
# Runs in .gitea/workflows/launcher.yml's "apk" job (JDK 17 container, as root).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd /src
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
QT_VERSION=6.8.3
|
QT_VERSION=6.8.3
|
||||||
NDK=26.1.10909125
|
NDK=26.1.10909125
|
||||||
# Minutes since the epoch: always above the GitHub builds' run numbers and always rising.
|
# Minutes since the epoch: always above the GitHub builds' run numbers and always rising.
|
||||||
VERSION_CODE=$(( $(date +%s) / 60 ))
|
VERSION_CODE=$(( $(date +%s) / 60 ))
|
||||||
|
COMMIT="${GITHUB_SHA:-$(git rev-parse HEAD)}"
|
||||||
|
|
||||||
echo "== tools"
|
echo "== tools"
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
# The host Qt tools (moc, qmlimportscanner, qmlcachegen) need glib, GL and friends.
|
# The host Qt tools (moc, qmlimportscanner, qmlcachegen) need glib, GL and friends;
|
||||||
apt-get install -y -qq --no-install-recommends python3-pip python3-venv ninja-build cmake unzip curl ca-certificates \
|
# g++ builds the desktop test and nodejs runs the layout test.
|
||||||
|
apt-get install -y -qq --no-install-recommends python3-pip python3-venv ninja-build cmake g++ nodejs unzip curl ca-certificates git \
|
||||||
libglib2.0-0t64 libgl1 libegl1 libopengl0 libfontconfig1 libfreetype6 libxkbcommon0 libdbus-1-3 >/dev/null
|
libglib2.0-0t64 libgl1 libegl1 libopengl0 libfontconfig1 libfreetype6 libxkbcommon0 libdbus-1-3 >/dev/null
|
||||||
python3 -m venv /opt/aqt && /opt/aqt/bin/pip install -q aqtinstall
|
python3 -m venv /opt/aqt && /opt/aqt/bin/pip install -q aqtinstall
|
||||||
|
|
||||||
@@ -22,6 +25,12 @@ echo "== Qt $QT_VERSION (android arm64 + host)"
|
|||||||
QT_ROOT=/opt/Qt/$QT_VERSION/android_arm64_v8a
|
QT_ROOT=/opt/Qt/$QT_VERSION/android_arm64_v8a
|
||||||
QT_HOST=/opt/Qt/$QT_VERSION/gcc_64
|
QT_HOST=/opt/Qt/$QT_VERSION/gcc_64
|
||||||
|
|
||||||
|
echo "== tests (desktop Qt)"
|
||||||
|
node qt/tests/layout.test.mjs
|
||||||
|
cmake -S qt -B build-desktop -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$QT_HOST"
|
||||||
|
cmake --build build-desktop
|
||||||
|
QT_QPA_PLATFORM=offscreen build-desktop/ultrahome_e2e
|
||||||
|
|
||||||
echo "== Android SDK + NDK $NDK"
|
echo "== Android SDK + NDK $NDK"
|
||||||
export ANDROID_SDK_ROOT=/opt/android-sdk
|
export ANDROID_SDK_ROOT=/opt/android-sdk
|
||||||
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||||
@@ -33,7 +42,7 @@ export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDK
|
|||||||
|
|
||||||
echo "== build (versionCode $VERSION_CODE)"
|
echo "== build (versionCode $VERSION_CODE)"
|
||||||
# Signed with the committed key, like every earlier build, so it installs over them.
|
# Signed with the committed key, like every earlier build, so it installs over them.
|
||||||
export QT_ANDROID_KEYSTORE_PATH=/src/android/app/debug.keystore
|
export QT_ANDROID_KEYSTORE_PATH="$PWD/android/app/debug.keystore"
|
||||||
export QT_ANDROID_KEYSTORE_ALIAS=androiddebugkey
|
export QT_ANDROID_KEYSTORE_ALIAS=androiddebugkey
|
||||||
export QT_ANDROID_KEYSTORE_STORE_PASS=android
|
export QT_ANDROID_KEYSTORE_STORE_PASS=android
|
||||||
export QT_ANDROID_KEYSTORE_KEY_PASS=android
|
export QT_ANDROID_KEYSTORE_KEY_PASS=android
|
||||||
@@ -44,17 +53,20 @@ cmake --build build-android --target apk
|
|||||||
apk=$(find build-android -name "*-signed.apk" | head -1)
|
apk=$(find build-android -name "*-signed.apk" | head -1)
|
||||||
test -n "$apk" || { find build-android -name "*.apk"; exit 1; }
|
test -n "$apk" || { find build-android -name "*.apk"; exit 1; }
|
||||||
cp "$apk" ultra-launcher.apk
|
cp "$apk" ultra-launcher.apk
|
||||||
printf '{"versionCode": %s, "commit": "%s"}\n' "$VERSION_CODE" "${FORGE_SHA:-}" > version.json
|
printf '{"versionCode": %s, "commit": "%s"}\n' "$VERSION_CODE" "$COMMIT" > version.json
|
||||||
|
|
||||||
echo "== release build-$VERSION_CODE"
|
echo "== release build-$VERSION_CODE"
|
||||||
api="${FORGE_URL:-https://fileapi.fastapicloud.dev}"
|
server="${GITHUB_SERVER_URL:-https://git.site.latha.org}"
|
||||||
api="${api%/}/api/forge/repos/${FORGE_REPO:-nandi.uk/launcher}/releases"
|
repo="${GITHUB_REPOSITORY:-experiments/launcher}"
|
||||||
echo "env: FORGE_REPO=${FORGE_REPO:-} FORGE_URL=${FORGE_URL:-} FORGE_API=${FORGE_API:-}"
|
api="${server%/}/api/v1/repos/$repo"
|
||||||
auth=(-H "Authorization: Bearer $FORGE_TOKEN")
|
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||||
|
test -n "$token" || { echo "no GITEA_TOKEN/GITHUB_TOKEN in the environment"; exit 1; }
|
||||||
|
auth=(-H "Authorization: token $token")
|
||||||
tag="build-$VERSION_CODE"
|
tag="build-$VERSION_CODE"
|
||||||
curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X POST "$api" \
|
id=$(curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X POST "$api/releases" \
|
||||||
-d "{\"tag\": \"$tag\", \"name\": \"ultra Home build $VERSION_CODE\", \"ref\": \"${FORGE_SHA:-}\", \"draft\": true, \"notes\": \"Qt launcher built from ${FORGE_SHA:-?}.\"}" >/dev/null
|
-d "{\"tag_name\": \"$tag\", \"name\": \"ultra Home build $VERSION_CODE\", \"target_commitish\": \"$COMMIT\", \"draft\": true, \"body\": \"Qt launcher built from $COMMIT.\"}" \
|
||||||
curl -fsS "${auth[@]}" -T ultra-launcher.apk "$api/$tag/assets/ultra-launcher.apk" >/dev/null
|
| python3 -c 'import sys, json; print(json.load(sys.stdin)["id"])')
|
||||||
curl -fsS "${auth[@]}" -T version.json "$api/$tag/assets/version.json" >/dev/null
|
curl -fsS "${auth[@]}" -F "attachment=@ultra-launcher.apk" "$api/releases/$id/assets?name=ultra-launcher.apk" >/dev/null
|
||||||
curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X PATCH "$api/$tag" -d '{"draft": false}' >/dev/null
|
curl -fsS "${auth[@]}" -F "attachment=@version.json" "$api/releases/$id/assets?name=version.json" >/dev/null
|
||||||
echo "published $tag"
|
curl -fsS "${auth[@]}" -H "Content-Type: application/json" -X PATCH "$api/releases/$id" -d '{"draft": false}' >/dev/null
|
||||||
|
echo "published $tag to $server/$repo"
|
||||||
@@ -14,6 +14,7 @@ import android.os.Looper;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -26,19 +27,20 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the launcher from the newest release on V's fileapi forge (nandi.uk/launcher),
|
* Updates the launcher from the newest release on the Gitea forge (experiments/launcher
|
||||||
* which .forge/jobs.toml builds on every commit to main. Each release holds
|
* on git.site.latha.org), which .gitea/workflows/launcher.yml builds on every commit to
|
||||||
* version.json ({"versionCode": N, "commit": SHA}) next to ultra-launcher.apk, with N the
|
* main. Each release holds version.json ({"versionCode": N, "commit": SHA}) next to
|
||||||
* APK's versionCode. When N is newer than the installed
|
* ultra-launcher.apk, with N the APK's versionCode; the latest-release API names their
|
||||||
* build, the APK is streamed into a PackageInstaller session and committed. Android then asks
|
* download URLs. When N is newer than the installed build, the APK is streamed into a
|
||||||
* the user to confirm (or, on Android 12+ once this app installed itself, may not ask at all).
|
* PackageInstaller session and committed. Android then asks the user to confirm (or, on
|
||||||
|
* Android 12+ once this app installed itself, may not ask at all).
|
||||||
*
|
*
|
||||||
* The home screen checks on start at most every CHECK_EVERY; the home menu's
|
* The home screen checks on start at most every CHECK_EVERY; the home menu's
|
||||||
* "Check for updates" checks now and reports what it found.
|
* "Check for updates" checks now and reports what it found.
|
||||||
*/
|
*/
|
||||||
final class Updater {
|
final class Updater {
|
||||||
static final String BASE =
|
static final String LATEST =
|
||||||
"https://fileapi.fastapicloud.dev/api/forge/repos/nandi.uk/launcher/releases/latest/assets/";
|
"https://git.site.latha.org/api/v1/repos/experiments/launcher/releases/latest";
|
||||||
static final long CHECK_EVERY = 6 * 60 * 60 * 1000L;
|
static final long CHECK_EVERY = 6 * 60 * 60 * 1000L;
|
||||||
static final String EXTRA_VERSION = "dev.ultra.launcher.VERSION";
|
static final String EXTRA_VERSION = "dev.ultra.launcher.VERSION";
|
||||||
|
|
||||||
@@ -75,7 +77,10 @@ final class Updater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void run(Context c, boolean manual) throws Exception {
|
private static void run(Context c, boolean manual) throws Exception {
|
||||||
JSONObject v = new JSONObject(new String(get(BASE + "version.json"), StandardCharsets.UTF_8));
|
JSONObject release = new JSONObject(new String(get(LATEST), StandardCharsets.UTF_8));
|
||||||
|
String versionUrl = assetUrl(release, "version.json");
|
||||||
|
String apkUrl = assetUrl(release, "ultra-launcher.apk");
|
||||||
|
JSONObject v = new JSONObject(new String(get(versionUrl), StandardCharsets.UTF_8));
|
||||||
long latest = v.getLong("versionCode");
|
long latest = v.getLong("versionCode");
|
||||||
long installed = installedVersion(c);
|
long installed = installedVersion(c);
|
||||||
if (latest <= installed) {
|
if (latest <= installed) {
|
||||||
@@ -85,7 +90,17 @@ final class Updater {
|
|||||||
// An install the user cancelled isn't offered again until there is a newer one, or they ask.
|
// An install the user cancelled isn't offered again until there is a newer one, or they ask.
|
||||||
if (!manual && latest == prefs(c).getLong("declined", -1)) return;
|
if (!manual && latest == prefs(c).getLong("declined", -1)) return;
|
||||||
toast(c, "Downloading launcher update (build " + latest + ")…");
|
toast(c, "Downloading launcher update (build " + latest + ")…");
|
||||||
install(c, latest);
|
install(c, apkUrl, latest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The download URL of the named asset in a release's JSON. */
|
||||||
|
private static String assetUrl(JSONObject release, String name) throws Exception {
|
||||||
|
JSONArray assets = release.getJSONArray("assets");
|
||||||
|
for (int i = 0; i < assets.length(); i++) {
|
||||||
|
JSONObject a = assets.getJSONObject(i);
|
||||||
|
if (name.equals(a.getString("name"))) return a.getString("browser_download_url");
|
||||||
|
}
|
||||||
|
throw new IOException("no " + name + " asset in the latest release");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -94,7 +109,7 @@ final class Updater {
|
|||||||
return Build.VERSION.SDK_INT >= 28 ? p.getLongVersionCode() : p.versionCode;
|
return Build.VERSION.SDK_INT >= 28 ? p.getLongVersionCode() : p.versionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void install(Context c, long version) throws IOException {
|
private static void install(Context c, String apkUrl, long version) throws IOException {
|
||||||
PackageInstaller pi = c.getPackageManager().getPackageInstaller();
|
PackageInstaller pi = c.getPackageManager().getPackageInstaller();
|
||||||
PackageInstaller.SessionParams params =
|
PackageInstaller.SessionParams params =
|
||||||
new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
|
new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
|
||||||
@@ -104,7 +119,7 @@ final class Updater {
|
|||||||
}
|
}
|
||||||
int id = pi.createSession(params);
|
int id = pi.createSession(params);
|
||||||
try (PackageInstaller.Session s = pi.openSession(id)) {
|
try (PackageInstaller.Session s = pi.openSession(id)) {
|
||||||
HttpURLConnection conn = open(BASE + "ultra-launcher.apk");
|
HttpURLConnection conn = open(apkUrl);
|
||||||
try (InputStream in = conn.getInputStream();
|
try (InputStream in = conn.getInputStream();
|
||||||
OutputStream out = s.openWrite("ultra-launcher.apk", 0, conn.getContentLengthLong())) {
|
OutputStream out = s.openWrite("ultra-launcher.apk", 0, conn.getContentLengthLong())) {
|
||||||
byte[] buf = new byte[64 * 1024];
|
byte[] buf = new byte[64 * 1024];
|
||||||
@@ -128,7 +143,7 @@ final class Updater {
|
|||||||
conn.setConnectTimeout(15000);
|
conn.setConnectTimeout(15000);
|
||||||
conn.setReadTimeout(30000);
|
conn.setReadTimeout(30000);
|
||||||
conn.setUseCaches(false);
|
conn.setUseCaches(false);
|
||||||
conn.setInstanceFollowRedirects(true); // github.com redirects assets to its download host
|
conn.setInstanceFollowRedirects(true); // asset downloads redirect to their storage host
|
||||||
int code = conn.getResponseCode();
|
int code = conn.getResponseCode();
|
||||||
if (code != HttpURLConnection.HTTP_OK) {
|
if (code != HttpURLConnection.HTTP_OK) {
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
|
|||||||
Reference in new issue
Block a user